public function build_table() { if ($this->rawdata) { $this->strtimeformat = str_replace(',', ' ', get_string('strftimedatetime')); parent::build_table(); } }
public function build_table() { global $DB; if ($this->rawdata) { $this->strtimeformat = str_replace(',', '', get_string('strftimedatetime')); parent::build_table(); //end of adding data from attempts data to table / download //now add averages at bottom of table : $params = array($this->quiz->id); $averagesql = ' SELECT AVG(qg.grade) AS grade, COUNT(qg.grade) AS numaveraged FROM {quiz_grades} qg WHERE quiz = ?'; $this->add_separator(); if ($this->is_downloading()) { $namekey = 'lastname'; } else { $namekey = 'fullname'; } if ($this->groupstudents) { list($usql, $uparams) = $DB->get_in_or_equal($this->groupstudents); $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql, array_merge($params, $uparams)); $groupaveragerow = array( $namekey => get_string('groupavg', 'grades'), 'sumgrades' => $this->format_average($record), 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade( $record->grade, $this->quiz->id, $this->context))); if ($this->detailedmarks && ($this->quiz->attempts == 1 || $this->qmsubselect)) { $avggradebyq = $this->load_average_question_grades($this->groupstudents); $groupaveragerow += $this->format_average_grade_for_questions($avggradebyq); } $this->add_data_keyed($groupaveragerow); } if ($this->students) { list($usql, $uparams) = $DB->get_in_or_equal($this->students); $record = $DB->get_record_sql($averagesql . ' AND qg.userid ' . $usql, array_merge($params, $uparams)); $overallaveragerow = array( $namekey => get_string('overallaverage', 'grades'), 'sumgrades' => $this->format_average($record), 'feedbacktext'=> strip_tags(quiz_report_feedback_for_grade( $record->grade, $this->quiz->id, $this->context))); if ($this->detailedmarks && ($this->quiz->attempts == 1 || $this->qmsubselect)) { $avggradebyq = $this->load_average_question_grades($this->students); $overallaveragerow += $this->format_average_grade_for_questions($avggradebyq); } $this->add_data_keyed($overallaveragerow); } } }
public function build_table() { global $DB; if (!$this->rawdata) { return; } $this->strtimeformat = str_replace(',', '', get_string('strftimedatetime')); parent::build_table(); // End of adding the data from attempts. Now add averages at bottom. $this->add_separator(); if ($this->groupstudents) { $this->add_average_row(get_string('groupavg', 'grades'), $this->groupstudents); } if ($this->students) { $this->add_average_row(get_string('overallaverage', 'grades'), $this->students); } }