|
By dservos:
CONTRIB-496
*Fixed a minor bug in lib.php witch caused some problems geting a list of statistics used in the plug-in.
|
| 90 |
* generate the statstics. |
* generate the statstics. |
| 91 |
* @var array $stats |
* @var array $stats |
| 92 |
*/ |
*/ |
| 93 |
private $stats = array(); |
private static $stats = array(); |
| 94 |
|
|
| 95 |
/** |
/** |
| 96 |
* Constructor. Initialises grade_tree, sets up group, baseurl |
* Constructor. Initialises grade_tree, sets up group, baseurl |
| 165 |
if($return) { |
if($return) { |
| 166 |
return $stats; |
return $stats; |
| 167 |
} else { |
} else { |
| 168 |
$this->stats = $stats; |
grade_report_stats::$stats = $stats; |
| 169 |
} |
} |
| 170 |
} |
} |
| 171 |
|
|
| 175 |
* @returns array array of classes that extend stats |
* @returns array array of classes that extend stats |
| 176 |
*/ |
*/ |
| 177 |
public function get_stats() { |
public function get_stats() { |
| 178 |
if(!isset($this->stats) || is_null($this->stats) || empty($this->stats)) { |
if(!isset(grade_report_stats::$stats) || is_null(grade_report_stats::$stats) || empty(grade_report_stats::$stats)) { |
| 179 |
return grade_report_stats::load_stats(true); |
return grade_report_stats::load_stats(true); |
| 180 |
} else { |
} else { |
| 181 |
return $this->stats; |
return grade_report_stats::$stats; |
| 182 |
} |
} |
| 183 |
} |
} |
| 184 |
|
|
| 344 |
public function report_data() { |
public function report_data() { |
| 345 |
$this->reportedstats = array(); |
$this->reportedstats = array(); |
| 346 |
|
|
| 347 |
foreach($this->stats as $name=>$stat) { |
foreach(grade_report_stats::$stats as $name=>$stat) { |
| 348 |
if($this->get_pref('stats', $name) || is_null($this->get_pref('stats', $name))) { |
if($this->get_pref('stats', $name) || is_null($this->get_pref('stats', $name))) { |
| 349 |
$this->reportedstats[$name] = array(); |
$this->reportedstats[$name] = array(); |
| 350 |
|
|
| 384 |
|
|
| 385 |
foreach($this->reportedstats as $name=>$data) { |
foreach($this->reportedstats as $name=>$data) { |
| 386 |
array_push($tablecolumns, $name); |
array_push($tablecolumns, $name); |
| 387 |
array_push($tableheaders, $this->stats[$name]->name); |
array_push($tableheaders, grade_report_stats::$stats[$name]->name); |
| 388 |
} |
} |
| 389 |
|
|
| 390 |
if($this->get_pref('stats', 'shownumgrades')) { |
if($this->get_pref('stats', 'shownumgrades')) { |
| 445 |
$stat = $data[$itemid]; |
$stat = $data[$itemid]; |
| 446 |
|
|
| 447 |
if(!is_array($stat)) { |
if(!is_array($stat)) { |
| 448 |
array_push($row, format_text(grade_format_gradevalue($stat, $item, true, $this->stats[$name]->displaytype, $this->stats[$name]->decimals), FORMAT_HTML)); |
array_push($row, format_text(grade_format_gradevalue($stat, $item, true, grade_report_stats::$stats[$name]->displaytype, grade_report_stats::$stats[$name]->decimals), FORMAT_HTML)); |
| 449 |
} else { |
} else { |
| 450 |
$statstring = ""; |
$statstring = ""; |
| 451 |
|
|
| 453 |
if($i >= count($stat)) { |
if($i >= count($stat)) { |
| 454 |
break; |
break; |
| 455 |
} |
} |
| 456 |
$statstring .= grade_format_gradevalue($stat[$i], $item, true, $this->stats[$name]->displaytype, $this->stats[$name]->decimals) . ', '; |
$statstring .= grade_format_gradevalue($stat[$i], $item, true, grade_report_stats::$stats[$name]->displaytype, grade_report_stats::$stats[$name]->decimals) . ', '; |
| 457 |
} |
} |
| 458 |
|
|
| 459 |
if($i < count($stat)) { |
if($i < count($stat)) { |
| 460 |
if(!$printerversion) { |
if(!$printerversion) { |
| 461 |
$statstring = "<a href=\"#\" onClick=\"javascript:window.open('{$CFG->wwwroot}/grade/report/stats/arrayview.php?id={$this->courseid}&data={$this->encode_array($stat, $item, $this->stats[$name])}','{$this->get_lang_string('moredata', 'gradereport_stats')}','width=300,height=500,menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars=yes');\">". format_text($statstring, FORMAT_HTML) . '....</a>'; |
$statstring = "<a href=\"#\" onClick=\"javascript:window.open('{$CFG->wwwroot}/grade/report/stats/arrayview.php?id={$this->courseid}&data={$this->encode_array($stat, $item, grade_report_stats::$stats[$name])}','{$this->get_lang_string('moredata', 'gradereport_stats')}','width=300,height=500,menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars=yes');\">". format_text($statstring, FORMAT_HTML) . '....</a>'; |
| 462 |
} else { |
} else { |
| 463 |
$statstring .= '...'; |
$statstring .= '...'; |
| 464 |
} |
} |
| 477 |
} |
} |
| 478 |
} else { |
} else { |
| 479 |
foreach($this->reportedstats as $name=>$data) { |
foreach($this->reportedstats as $name=>$data) { |
| 480 |
$row = array(format_text('<strong>' . $this->stats[$name]->name . '</strong>', FORMAT_HTML)); |
$row = array(format_text('<strong>' . grade_report_stats::$stats[$name]->name . '</strong>', FORMAT_HTML)); |
| 481 |
|
|
| 482 |
foreach($data as $itemid=>$stat) { |
foreach($data as $itemid=>$stat) { |
| 483 |
if(!is_array($stat)) { |
if(!is_array($stat)) { |
| 484 |
array_push($row, format_text(grade_format_gradevalue($stat, $this->gtree->items[$itemid], true, $this->stats[$name]->displaytype, $this->stats[$name]->decimals), FORMAT_HTML)); |
array_push($row, format_text(grade_format_gradevalue($stat, $this->gtree->items[$itemid], true, grade_report_stats::$stats[$name]->displaytype, grade_report_stats::$stats[$name]->decimals), FORMAT_HTML)); |
| 485 |
} else { |
} else { |
| 486 |
$statstring = ""; |
$statstring = ""; |
| 487 |
|
|
| 489 |
if($i >= count($stat)) { |
if($i >= count($stat)) { |
| 490 |
break; |
break; |
| 491 |
} |
} |
| 492 |
$statstring .= grade_format_gradevalue($stat[$i], $this->gtree->items[$itemid], true, $this->stats[$name]->displaytype, $this->stats[$name]->decimals) . ', '; |
$statstring .= grade_format_gradevalue($stat[$i], $this->gtree->items[$itemid], true, grade_report_stats::$stats[$name]->displaytype, grade_report_stats::$stats[$name]->decimals) . ', '; |
| 493 |
} |
} |
| 494 |
|
|
| 495 |
if($i < count($stat)) { |
if($i < count($stat)) { |
| 496 |
if(!$printerversion) { |
if(!$printerversion) { |
| 497 |
$statstring = "<a href=\"#\" onClick=\"javascript:window.open('{$CFG->wwwroot}/grade/report/stats/arrayview.php?id={$this->courseid}&data={$this->encode_array($stat, $this->gtree->items[$itemid], $this->stats[$name])}','{$this->get_lang_string('moredata', 'gradereport_stats')}','width=300,height=500,menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars=yes');\">". format_text($statstring, FORMAT_HTML) . '....</a>'; |
$statstring = "<a href=\"#\" onClick=\"javascript:window.open('{$CFG->wwwroot}/grade/report/stats/arrayview.php?id={$this->courseid}&data={$this->encode_array($stat, $this->gtree->items[$itemid], grade_report_stats::$stats[$name])}','{$this->get_lang_string('moredata', 'gradereport_stats')}','width=300,height=500,menubar=no,status=no,location=no,directories=no,toolbar=no,scrollbars=yes');\">". format_text($statstring, FORMAT_HTML) . '....</a>'; |
| 498 |
} else { |
} else { |
| 499 |
$statstring .= '...'; |
$statstring .= '...'; |
| 500 |
} |
} |