Navigation Menu

Skip to content

Commit

Permalink
Merge branch 'MDL-41756-master' of https://github.com/jamiepratt/moodle
Browse files Browse the repository at this point in the history
Conflicts:
	lib/db/upgrade.php
	version.php
  • Loading branch information
Sam Hemelryk committed Feb 4, 2014
2 parents 9433b01 + 4f7516f commit 8213574
Show file tree
Hide file tree
Showing 12 changed files with 687 additions and 501 deletions.
1 change: 1 addition & 0 deletions lib/db/install.xml
Expand Up @@ -1476,6 +1476,7 @@
<FIELD NAME="questionid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="slot" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="The position in the quiz where this question appears"/>
<FIELD NAME="subquestion" TYPE="int" LENGTH="4" NOTNULL="true" SEQUENCE="false"/>
<FIELD NAME="variant" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false"/>
<FIELD NAME="s" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
<FIELD NAME="effectiveweight" TYPE="number" LENGTH="15" NOTNULL="false" SEQUENCE="false" DECIMALS="5"/>
<FIELD NAME="negcovar" TYPE="int" LENGTH="2" NOTNULL="true" DEFAULT="0" SEQUENCE="false"/>
Expand Down
14 changes: 14 additions & 0 deletions lib/db/upgrade.php
Expand Up @@ -3005,5 +3005,19 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2014012400.00);
}

if ($oldversion < 2014020500.00) {
// Define field variant to be added to question_statistics.
$table = new xmldb_table('question_statistics');
$field = new xmldb_field('variant', XMLDB_TYPE_INTEGER, '10', null, null, null, null, 'subquestion');

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

// Main savepoint reached.
upgrade_main_savepoint(true, 2014020500.00);
}

return true;
}
1 change: 1 addition & 0 deletions mod/quiz/report/statistics/lang/en/quiz_statistics.php
Expand Up @@ -66,6 +66,7 @@
$string['lastcalculated'] = 'Last calculated {$a->lastcalculated} ago there have been {$a->count} attempts since then.';
$string['median'] = 'Median grade (for {$a})';
$string['modelresponse'] = 'Model response';
$string['nameforvariant'] = 'Variant {$a->variant} of {$a->name}';
$string['negcovar'] = 'Negative covariance of grade with total attempt grade';
$string['negcovar_help'] = 'This question\'s grade for this set of attempts on the quiz varies in an opposite way to the overall attempt grade. This means overall attempt grade tends to be below average when the grade for this question is above average and vice-versa.
Expand Down
18 changes: 18 additions & 0 deletions mod/quiz/report/statistics/report.php
Expand Up @@ -412,16 +412,34 @@ protected function output_quiz_structure_analysis_table($s, $questionstats, $sub
foreach ($questionstats as $questionstat) {
// Output the data for these question statistics.
$this->table->add_data_keyed($this->table->format_row($questionstat));
if (count($questionstat->variantstats) > 1) {
ksort($questionstat->variantstats);
foreach ($questionstat->variantstats as $variantstat) {
$this->table->add_data_keyed($this->table->format_row($variantstat));
}
}

if (empty($questionstat->subquestions)) {
continue;
}

// And its subquestions, if it has any.
$subitemstodisplay = explode(',', $questionstat->subquestions);
$displayorder = 1;
foreach ($subitemstodisplay as $subitemid) {
$subquestionstats[$subitemid]->maxmark = $questionstat->maxmark;
$subquestionstats[$subitemid]->subqdisplayorder = $displayorder;
$subquestionstats[$subitemid]->question->number = $questionstat->question->number;
$this->table->add_data_keyed($this->table->format_row($subquestionstats[$subitemid]));
if (count($subquestionstats[$subitemid]->variantstats) > 1) {
ksort($subquestionstats[$subitemid]->variantstats);
foreach ($subquestionstats[$subitemid]->variantstats as $variantstat) {
$variantstat->subqdisplayorder = $displayorder;
$variantstat->question->number = $questionstat->question->number;
$this->table->add_data_keyed($this->table->format_row($variantstat));
}
}
$displayorder++;
}
}

Expand Down
17 changes: 15 additions & 2 deletions mod/quiz/report/statistics/statistics_table.php
Expand Up @@ -136,11 +136,17 @@ public function statistics_setup($quiz, $cmid, $reporturl, $s) {
* @return string contents of this table cell.
*/
protected function col_number($questionstat) {
$number = $questionstat->question->number;

if ($questionstat->subquestion) {
return '';
$number = $number . '.'.$questionstat->subqdisplayorder;
}

if ($questionstat->question->qtype != 'random' && !is_null($questionstat->variant)) {
$number = $number . '.'.$questionstat->variant;
}

return $questionstat->question->number;
return $number;
}

/**
Expand Down Expand Up @@ -180,6 +186,13 @@ protected function col_qtype($questionstat) {
protected function col_name($questionstat) {
$name = $questionstat->question->name;

if (!is_null($questionstat->variant)) {
$a = new stdClass();
$a->name = $name;
$a->variant = $questionstat->variant;
$name = get_string('nameforvariant', 'quiz_statistics', $a);
}

if ($this->is_downloading()) {
return $name;
}
Expand Down

0 comments on commit 8213574

Please sign in to comment.