Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove Undefined property notices on index.php

  • Loading branch information...
commit 3ff883ca5c5882960c1c1954e579e4fea69fd4aa 1 parent cb767bf
@jpichon authored
Showing with 39 additions and 24 deletions.
  1. +39 −24 blocks/dvreport/index.php
View
63 blocks/dvreport/index.php
@@ -1,4 +1,5 @@
<?php
+
require_once('../../config.php');
require_once('lib.php');
@@ -6,9 +7,9 @@
$action = required_param('action', PARAM_TEXT);
$studentid = optional_param('student', 0, PARAM_INT);
-global $CFG,$COURSE,$USER;
+global $CFG, $COURSE, $USER;
-if(!$COURSE = get_record('course', 'id', $courseid)) {
+if (!$COURSE = get_record('course', 'id', $courseid)) {
error(get_string('invalidcourseid','block_dvreport'));
}
@@ -27,22 +28,28 @@
$insertproblem = false;
//General settings
- $settings = get_record('block_dvreport','course',$COURSE->id);
- $until = mktime(23,59,59,$form->endmonth,$form->endday,$form->endyear);
+ $settings = get_record('block_dvreport', 'course', $COURSE->id);
+ $until = mktime(23, 59, 59, $form->endmonth, $form->endday, $form->endyear);
+
//Any change ?
- if (($form->runinterval != $settings->runinterval)||(isset($form->runmonth))||($form->until != $until)){
- $dataobject->course = $COURSE->id;
- if (isset($form->runmonth)){
+ if (isset($form->runmonth) || ($form->until != $until) ||
+ (isset($settings) && ($form->runinterval != $settings->runinterval))) {
+
+ $dataobject->course = $COURSE->id;
+
+ if (isset($form->runmonth)){
$dataobject->lastgraph = mktime(0,0,0,$form->runmonth,$form->runday-$form->runinterval,$form->runyear);
}else{
$dataobject->lastgraph = $settings->lastgraph;
}
- $dataobject->until = mktime(23,59,59,$form->endmonth,$form->endday,$form->endyear);
- $dataobject->runinterval = clean_param($form->runinterval,PARAM_INT);
+
+ $dataobject->until = mktime(23,59,59,$form->endmonth,$form->endday,$form->endyear);
+ $dataobject->runinterval = clean_param($form->runinterval, PARAM_INT);
$dataobject->timemodified = time();
addslashes_object($dataobject);
- //Already exists?
- if ($settings->id) {
+
+ //Already exists?
+ if (isset($settings) && isset($settings->id)) {
$dataobject->id = $settings->id;
if (!update_record('block_dvreport',$dataobject)){
$insertproblem = true;
@@ -82,7 +89,8 @@
$dataobject->qual = $forum->qual;
$dataobject->quant = $forum->quant;
$dataobject->timemodified = time();
- if (record_exists('block_dvreport_forums','course',$dataobject->course,'forumid',$dataobject->forumid)){
+
+ if (record_exists('block_dvreport_forums','course',$dataobject->course,'forumid',$dataobject->forumid)){
$dataobject->id = get_field('block_dvreport_forums','id','course',$dataobject->course,'forumid',$dataobject->forumid);
if (!update_record('block_dvreport_forums',$dataobject)){
$insertproblem = true;
@@ -105,8 +113,10 @@
}
//Check $action is valid
-if (($action != 'manage')&&($action != 'viewall')&&($action != 'viewstudent')) {
- if(has_capability('block/dvreport:viewall', $context)) {
+if (($action != 'manage') && ($action != 'viewall')
+ && ($action != 'viewstudent')) {
+
+ if(has_capability('block/dvreport:viewall', $context)) {
$action = 'viewall';
}else{
$action = 'viewstudent';
@@ -186,8 +196,7 @@
$graph = 2;
}
- block_dvreport_viewstudent_print_dropdown_menu('viewall',$courseid, $studentid, $forumid, $graph_types,$graph,
- $categories, $category, $dates, $timestamp);
+ block_dvreport_viewstudent_print_dropdown_menu('viewall',$courseid, $studentid, $forumid, $graph_types, $graph, $categories, $category, $dates, $timestamp);
} else {
echo '</table><p />';
}
@@ -206,7 +215,9 @@
AND g.type = 'user'
ORDER BY g.id";
$graphdata = get_records_sql($sql);
+
}else{ //All forums view
+
if (($category == 2) && (!block_dvreport_all_forums_use_same_scale($COURSE->id))) {
$different_scale = true;
}
@@ -225,7 +236,7 @@
}
}
- if (!$graphdata){
+ if (!$graphdata) {
if ($different_scale){
notify(get_string('differentscales','block_dvreport'));
}else{
@@ -240,7 +251,8 @@
block_dvreport_viewall_print_header($COURSE->id, $forumid, $category, $timestamp, $order);
block_dvreport_viewall_print_allstudents($listing, $forum, $headers, $category, $timestamp);
block_dvreport_viewall_print_allstudents_raw($COURSE->id, $forumid, $category, $timestamp, $listing);
- }else{ //View one student
+
+ }else{ //View one student
if ($category == 2) {
$scales_menu = block_dvreport_get_scale($COURSE->id, $forum);
}
@@ -278,7 +290,7 @@
$forums = array();
$forums_settings = block_dvreport_get_forums_settings($COURSE->id);
- if (!$forums_settings){
+ if (!$forums_settings) {
notify(get_string('nodatayet','block_dvreport'));
}else{
//Prepare the forum dropdown menu
@@ -318,7 +330,7 @@
$graphdata = block_dvreport_viewstudent_get_graphdata($COURSE->id, $forumid, $timestamp, $category, $USER->id);
- if (!$graphdata){
+ if (!$graphdata) {
notify(get_string('nodatayet','block_dvreport'));
}else{
$forum = block_dvreport_get_forum_info($forumid);
@@ -379,12 +391,14 @@ function block_dvreport_settings_print_forums_list() {
}
echo '">'.$forum->name.'</a></td>';
$checked = false;
- if($forumsettings[$forumid]->quant == 1){
+ if (isset($forumsettings[$forumid]->quant) &&
+ ($forumsettings[$forumid]->quant == 1)) {
$checked = true;
}
echo '<td align="center" class="cell c1">'.print_checkbox('quant_'.$forumid,$forumid,$checked,'','','',true).'</td>';
$checked = false;
- if($forumsettings[$forumid]->qual == 1){
+ if (isset($forumsettings[$forumid]->qual) &&
+ ($forumsettings[$forumid]->qual == 1)) {
$checked = true;
}
echo '<td align="center" class="cell c1">'.print_checkbox('qual_'.$forumid,$forumid,$checked,'','','',true).'</td>';
@@ -441,7 +455,7 @@ function block_dvreport_settings_print_general_settings() {
//Already ran before?
if(!$firstrun){
//Is a date already set?
- if ($generalsettings->lastgraph){
+ if (isset($generalsettings->lastgraph)) {
//Note: To launch the cron, the lastgraph date is adjusted according to runinterval
$timestamp = $generalsettings->lastgraph+$generalsettings->runinterval*86400;
}else{
@@ -460,8 +474,9 @@ function block_dvreport_settings_print_general_settings() {
echo '<select name="runmonth" disabled><option value="'.$firstrun['mon'].'" selected="selected">'.userdate(gmmktime(12,0,0,$firstrun['mon'],1,2000), '%B').'</option></select>';
echo '<select name="runyear" disabled><option value="'.$firstrun['year'].'" selected="selected">'.$firstrun['year'].'</option></select></td></tr>';
}
+
//End date, to stop the data processing
- if ($generalsettings->until > 0) {
+ if (isset($generalsettings->until) && ($generalsettings->until > 0)) {
$timestamp = $generalsettings->until;
}else{
//Suggest startdate + number of weeks/topics
Please sign in to comment.
Something went wrong with that request. Please try again.