Skip to content

Commit

Permalink
MDL-20636 Convert the overview report.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Feb 16, 2011
1 parent 2a3bdbf commit e24ee79
Show file tree
Hide file tree
Showing 14 changed files with 924 additions and 810 deletions.
35 changes: 16 additions & 19 deletions mod/quiz/report/attemptsreport.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,33 +412,30 @@ public function col_picture($attempt) {
return $OUTPUT->user_picture($user);
}


public function col_timestart($attempt) {
if (!$attempt->attempt) {
return '-';
public function col_fullname($attempt) {
$html = parent::col_fullname($attempt);
if ($this->is_downloading()) {
return $html;
}

$startdate = userdate($attempt->timestart, $this->strtimeformat);
if (!$this->is_downloading()) {
return html_writer::link(new moodle_url('/mod/quiz/review.php', array('attempt' => $attempt->attempt)), $startdate);
} else {
return $startdate;
}
return $html . html_writer::empty_tag('br') . html_writer::link(
new moodle_url('/mod/quiz/review.php', array('attempt' => $attempt->attempt)),
get_string('reviewattempt', 'quiz'), array('class' => 'reviewlink'));
}

public function col_timefinish($attempt) {
if (!$attempt->attempt) {
return '-';
}
if (!$attempt->timefinish) {
public function col_timestart($attempt) {
if ($attempt->attempt) {
return userdate($attempt->timestart, $this->strtimeformat);
} else {
return '-';
}
}

$timefinish = userdate($attempt->timefinish, $this->strtimeformat);
if (!$this->is_downloading()) {
return html_writer::link(new moodle_url('/mod/quiz/review.php', array('attempt' => $attempt->attempt)), $timefinish);
public function col_timefinish($attempt) {
if ($attempt->attempt && $attempt->timefinish) {
return userdate($attempt->timefinish, $this->strtimeformat);
} else {
return $timefinish;
return '-';
}
}

Expand Down
14 changes: 7 additions & 7 deletions mod/quiz/report/overview/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
xsi:noNamespaceSchemaLocation="../../../../../lib/xmldb/xmldb.xsd"
>
<TABLES>
<TABLE NAME="quiz_question_regrade" COMMENT="This table records which question attempts need regrading and the grade they will be regraded to.">
<TABLE NAME="quiz_overview_regrades" COMMENT="This table records which question attempts need regrading and the grade they will be regraded to.">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="questionid"/>
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key references question.id." PREVIOUS="id" NEXT="attemptid"/>
<FIELD NAME="attemptid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key references question_attempt.id, or equivalently quiz_attempt.uniqueid." PREVIOUS="questionid" NEXT="newgrade"/>
<FIELD NAME="newgrade" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The new grade for this question after regrading." PREVIOUS="attemptid" NEXT="oldgrade"/>
<FIELD NAME="oldgrade" TYPE="number" LENGTH="12" NOTNULL="true" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The previous grade for this question in this attempt." PREVIOUS="newgrade" NEXT="regraded"/>
<FIELD NAME="regraded" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="set to 0 if element has just been regraded. Set to 1 if element has been marked as needing regrading." PREVIOUS="oldgrade" NEXT="timemodified"/>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" NEXT="questionusageid"/>
<FIELD NAME="questionusageid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key references question_usages.id, or equivalently quiz_attempt.uniqueid." PREVIOUS="id" NEXT="slot"/>
<FIELD NAME="slot" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Foreign key, references question_attempts.slot" PREVIOUS="questionusageid" NEXT="newfraction"/>
<FIELD NAME="newfraction" TYPE="number" LENGTH="12" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The new fraction for this question_attempt after regrading." PREVIOUS="slot" NEXT="oldfraction"/>
<FIELD NAME="oldfraction" TYPE="number" LENGTH="12" NOTNULL="false" UNSIGNED="false" SEQUENCE="false" DECIMALS="7" COMMENT="The previous fraction for this question_attempt." PREVIOUS="newfraction" NEXT="regraded"/>
<FIELD NAME="regraded" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="set to 0 if element has just been regraded. Set to 1 if element has been marked as needing regrading." PREVIOUS="oldfraction" NEXT="timemodified"/>
<FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="false" COMMENT="Timestamp of when this row was last modified." PREVIOUS="regraded"/>
</FIELDS>
<KEYS>
Expand Down
188 changes: 179 additions & 9 deletions mod/quiz/report/overview/db/upgrade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?php

function xmldb_quiz_overview_upgrade($oldversion) {
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Quiz overview report upgrade script.
*
* @package quiz
* @subpackage overview
* @copyright 2008 Jamie Pratt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/


/**
* Quiz overview report upgrade function.
* @param number $oldversion
*/function xmldb_quiz_overview_upgrade($oldversion) {
global $CFG, $DB;

$dbman = $DB->get_manager();
Expand All @@ -9,10 +37,10 @@ function xmldb_quiz_overview_upgrade($oldversion) {

if ($oldversion < 2009091400) {

/// Define table quiz_question_regrade to be created
// Define table quiz_question_regrade to be created
$table = new xmldb_table('quiz_question_regrade');

/// Adding fields to table quiz_question_regrade
// Adding fields to table quiz_question_regrade
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('questionid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
Expand All @@ -21,19 +49,161 @@ function xmldb_quiz_overview_upgrade($oldversion) {
$table->add_field('regraded', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);

/// Adding keys to table quiz_question_regrade
// Adding keys to table quiz_question_regrade
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));

/// Conditionally launch create table for quiz_question_regrade
// Conditionally launch create table for quiz_question_regrade
if (!$dbman->table_exists($table)) {
$dbman->create_table($table);
}

/// overview savepoint reached
upgrade_plugin_savepoint(true, 2009091400, 'quizreport', 'overview');
// overview savepoint reached
upgrade_plugin_savepoint(true, 2009091400, 'quiz', 'overview');
}

return true;
}
if ($oldversion < 2010040600) {

// Wipe the quiz_question_regrade before we changes its structure. The data
// It contains is not important long-term, and it is almost impossible to upgrade.
$DB->delete_records('quiz_question_regrade');

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040600, 'quiz', 'overview');
}

if ($oldversion < 2010040601) {

// Rename field attemptid on table quiz_question_regrade to questionusageid
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('attemptid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'id');

// Launch rename field questionusageid
$dbman->rename_field($table, $field, 'questionusageid');

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040601, 'quiz', 'overview');
}

if ($oldversion < 2010040602) {

// Define field slot to be added to quiz_question_regrade
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('slot', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, 'questionusageid');

// Conditionally launch add field slot
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040602, 'quiz', 'overview');
}

if ($oldversion < 2010040603) {

// Define field questionid to be dropped from quiz_question_regrade
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('questionid');

// Conditionally launch drop field questionusageid
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040603, 'quiz', 'overview');
}

if ($oldversion < 2010040604) {

// Rename field newgrade on table quiz_question_regrade to newfraction
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('newgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch rename field newfraction
$dbman->rename_field($table, $field, 'newfraction');

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040604, 'quiz', 'overview');
}

if ($oldversion < 2010040605) {

// Rename field oldgrade on table quiz_question_regrade to oldfraction
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('oldgrade', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch rename field newfraction
$dbman->rename_field($table, $field, 'oldfraction');

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040605, 'quiz', 'overview');
}

if ($oldversion < 2010040606) {

// Changing precision of field newfraction on table quiz_question_regrade to (12, 7)
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch change of precision for field newfraction
$dbman->change_field_precision($table, $field);

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040606, 'quiz', 'overview');
}

if ($oldversion < 2010040607) {

// Changing precision of field oldfraction on table quiz_question_regrade to (12, 7)
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch change of precision for field newfraction
$dbman->change_field_precision($table, $field);

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010040607, 'quiz', 'overview');
}

if ($oldversion < 2010082700) {

// Changing nullability of field newfraction on table quiz_question_regrade to null
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('newfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch change of nullability for field newfraction
$dbman->change_field_notnull($table, $field);

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010082700, 'quiz', 'overview');
}

if ($oldversion < 2010082701) {

// Changing nullability of field oldfraction on table quiz_question_regrade to null
$table = new xmldb_table('quiz_question_regrade');
$field = new xmldb_field('oldfraction', XMLDB_TYPE_NUMBER, '12, 7', null, null, null, null, 'slot');

// Launch change of nullability for field newfraction
$dbman->change_field_notnull($table, $field);

// overview savepoint reached
upgrade_plugin_savepoint(true, 2010082701, 'quiz', 'overview');
}

if ($oldversion < 2011021600) {

// Define table quiz_question_regrade to be renamed to quiz_overview_regrades
// so that it follows the Moodle coding guidelines.
$table = new xmldb_table('quiz_question_regrade');

// Launch rename table for quiz_question_regrade
$dbman->rename_table($table, 'quiz_overview_regrades');

// overview savepoint reached
upgrade_plugin_savepoint(true, 2011021600, 'quiz', 'overview');
}

return true;
}
8 changes: 4 additions & 4 deletions mod/quiz/report/overview/lang/en/quiz_overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
$string['optonlyregradedattempts'] = 'that have been regraded / are marked as needing regrading';
$string['overview'] = 'Grades';
$string['overviewdownload'] = 'Overview download';
$string['overviewfilename'] = 'grades';
$string['overviewreport'] = 'Grades report';
$string['overviewreportgraph'] = 'Overall number of students achieving grade ranges';
$string['overviewreportgraphgroup'] = 'Number of students in group \'{$a}\' achieving grade ranges';
Expand All @@ -64,10 +65,9 @@
$string['regradeallgroup'] = 'Full regrade for group \'{$a->groupname}\'';
$string['regradeheader'] = 'Regrading';
$string['regradeselected'] = 'Regrade selected attempts';
$string['requiresgrading'] = 'Requires grading';
$string['show'] = 'Include';
$string['showattempts'] = 'Include attempts';
$string['showdetailedmarks'] = 'Marks for each question';
$string['show'] = 'Show / download';
$string['showattempts'] = 'Only show / download attempts';
$string['showdetailedmarks'] = 'Show / download marks for each question';
$string['showinggraded'] = 'Showing only the attempt graded for each user.';
$string['showinggradedandungraded'] = 'Showing graded and ungraded attempts for each user. The one attempt for each user that is graded is highlighted. The grading method for this quiz is {$a}.';
$string['studentingroup'] = '\'{$a->coursestudent}\' in group \'{$a->groupname}\'';
Expand Down
Loading

0 comments on commit e24ee79

Please sign in to comment.