From 746860479f3f20b131a1dc5b54db1472a1ec82e3 Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Mon, 10 Nov 2008 11:56:37 +0000 Subject: [PATCH] MDL-17188 "effective question weight equation cannot cope with negative covariance of question grades" excluding such questions from equation --- lang/en_utf8/help/quiz_statistics/negcovar.html | 4 ++++ lang/en_utf8/quiz_statistics.php | 2 +- mod/quiz/report/statistics/db/install.xml | 7 ++++--- mod/quiz/report/statistics/db/upgrade.php | 17 +++++++++++++++++ mod/quiz/report/statistics/qstats.php | 15 ++++++++++++--- mod/quiz/report/statistics/statistics_table.php | 12 +++++++++++- mod/quiz/report/statistics/version.php | 2 +- theme/standard/styles_color.css | 3 +++ 8 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 lang/en_utf8/help/quiz_statistics/negcovar.html diff --git a/lang/en_utf8/help/quiz_statistics/negcovar.html b/lang/en_utf8/help/quiz_statistics/negcovar.html new file mode 100644 index 0000000000..5c6b58459d --- /dev/null +++ b/lang/en_utf8/help/quiz_statistics/negcovar.html @@ -0,0 +1,4 @@ +

Negative covariance of grade for this question with total quiz attempt grade

+

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.

+

Our equation for effective question weight cannot be calculated in this case. The calculations for effective question weight for other questions in this quiz are the effective question weight for these questions if the highlighted questions with a negative covariance are given a maximum grade of zero.

+

If you edit a quiz and give these question(s) with negative covariance a max grade of zero then the effective question weight of these questions will be zero and the real effective question weight of other questions will be as calculated now.

\ No newline at end of file diff --git a/lang/en_utf8/quiz_statistics.php b/lang/en_utf8/quiz_statistics.php index 1a6ff7d356..d8de227c2b 100644 --- a/lang/en_utf8/quiz_statistics.php +++ b/lang/en_utf8/quiz_statistics.php @@ -65,5 +65,5 @@ $string['frequency'] = 'Frequency'; $string['backtoquizreport'] = 'Back to main statistics report page.'; $string['analysisofresponsesfor'] = 'Analysis of responses for $a.'; $string['downloadeverything'] = 'Download full report as'; - +$string['negcovar'] ='Negative covariance of grade with total attempt grade'; ?> \ No newline at end of file diff --git a/mod/quiz/report/statistics/db/install.xml b/mod/quiz/report/statistics/db/install.xml index 08d69ea025..6610052e61 100644 --- a/mod/quiz/report/statistics/db/install.xml +++ b/mod/quiz/report/statistics/db/install.xml @@ -1,5 +1,5 @@ - @@ -34,8 +34,9 @@ - - + + + diff --git a/mod/quiz/report/statistics/db/upgrade.php b/mod/quiz/report/statistics/db/upgrade.php index 4b65ff2c74..a889be710c 100644 --- a/mod/quiz/report/statistics/db/upgrade.php +++ b/mod/quiz/report/statistics/db/upgrade.php @@ -117,6 +117,23 @@ function xmldb_quizreport_statistics_upgrade($oldversion) { } } } + if ($result && $oldversion < 2008111000) { + //delete all cached results first + $result = $result && $DB->delete_records('quiz_statistics'); + $result = $result && $DB->delete_records('quiz_question_statistics'); + $result = $result && $DB->delete_records('quiz_question_response_stats'); + if ($result){ + /// Define field anssubqid to be dropped from quiz_question_response_stats + $table = new xmldb_table('quiz_question_statistics'); + /// Define field subqid to be added to quiz_question_response_stats + $field = new xmldb_field('negcovar', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'effectiveweight'); + + /// Conditionally launch add field subqid + if (!$dbman->field_exists($table, $field)) { + $dbman->add_field($table, $field); + } + } + } return $result; } diff --git a/mod/quiz/report/statistics/qstats.php b/mod/quiz/report/statistics/qstats.php index 8d2dc0f08c..9a260d3673 100644 --- a/mod/quiz/report/statistics/qstats.php +++ b/mod/quiz/report/statistics/qstats.php @@ -249,15 +249,24 @@ class qstats{ foreach (array_keys($this->questions) as $qid){ $this->_secondary_question_walker($this->questions[$qid]->_stats); $this->sumofgradevariance += $this->questions[$qid]->_stats->gradevariance; - $sumofcovariancewithoverallgrade += sqrt($this->questions[$qid]->_stats->covariancewithoverallgrade); + if ($this->questions[$qid]->_stats->covariancewithoverallgrade >= 0){ + $sumofcovariancewithoverallgrade += sqrt($this->questions[$qid]->_stats->covariancewithoverallgrade); + $this->questions[$qid]->_stats->negcovar = 0; + } else { + $this->questions[$qid]->_stats->negcovar = 1; + } } foreach (array_keys($this->subquestions) as $qid){ $this->_secondary_question_walker($this->subquestions[$qid]->_stats); } foreach (array_keys($this->questions) as $qid){ if ($sumofcovariancewithoverallgrade){ - $this->questions[$qid]->_stats->effectiveweight = 100 * sqrt($this->questions[$qid]->_stats->covariancewithoverallgrade) - / $sumofcovariancewithoverallgrade; + if ($this->questions[$qid]->_stats->negcovar){ + $this->questions[$qid]->_stats->effectiveweight = null; + } else { + $this->questions[$qid]->_stats->effectiveweight = 100 * sqrt($this->questions[$qid]->_stats->covariancewithoverallgrade) + / $sumofcovariancewithoverallgrade; + } } else { $this->questions[$qid]->_stats->effectiveweight = null; } diff --git a/mod/quiz/report/statistics/statistics_table.php b/mod/quiz/report/statistics/statistics_table.php index 694fd06d6e..61596e08d5 100644 --- a/mod/quiz/report/statistics/statistics_table.php +++ b/mod/quiz/report/statistics/statistics_table.php @@ -142,7 +142,17 @@ class quiz_report_statistics_table extends flexible_table { } function col_effective_weight($question){ if (!$question->_stats->subquestion){ - return number_format($question->_stats->effectiveweight, 2).'%'; + if ($question->_stats->negcovar){ + $negcovar = get_string('negcovar', 'quiz_statistics'); + if (!$this->is_downloading()){ + $negcovar .= helpbutton('negcovar', $negcovar, 'quiz_statistics', true, false, '', true); + return '
'.$negcovar.'
'; + } else { + return $negcovar; + } + } else { + return number_format($question->_stats->effectiveweight, 2).'%'; + } } else { return ''; } diff --git a/mod/quiz/report/statistics/version.php b/mod/quiz/report/statistics/version.php index e08b511b26..53af2cdaad 100644 --- a/mod/quiz/report/statistics/version.php +++ b/mod/quiz/report/statistics/version.php @@ -1,4 +1,4 @@ version = 2008090500; // The (date) version of this module +$plugin->version = 2008111000; // The (date) version of this module ?> \ No newline at end of file diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index bc39d38f70..ff24cbd0e6 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -1088,6 +1088,9 @@ table.quizreviewsummary td.cell { border :medium solid yellow; background-color:lightYellow; } +#mod-quiz-report .negcovar{ + border :medium solid pink; +} /*** *** Modules: Resource ***/ -- 2.39.5