MDL-41752 question statistics class moved and improved

quiz_question_statistics_stats renamed to question_statistics_calculator
separate class question_statistics used to store calculated stats
and api changed, also code generally cleaned up.
This commit is contained in:
Jamie Pratt 2013-09-25 13:27:55 +07:00
parent 515b3ae6a7
commit 59abb70716
15 changed files with 4 additions and 32 deletions

View File

@ -864,11 +864,9 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012062000.01);
}
// Moodle v2.3.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012062500.02) {
// Drop some old backup tables, not used anymore
@ -1497,7 +1495,6 @@ function xmldb_main_upgrade($oldversion) {
// Moodle v2.4.0 release upgrade line
// Put any upgrade step following this
if ($oldversion < 2012120300.01) {
// Make sure site-course has format='site' //MDL-36840

View File

@ -166,7 +166,6 @@ class quiz_statistics_calculated {
}
}
/**
* @var array of names of properties of this class that are cached in db record.
*/

View File

@ -90,7 +90,6 @@ class quiz_statistics_calculator {
}
}
$quizstats->cache(quiz_statistics_qubaids_condition($quizid, $currentgroup, $groupstudents, $useallattempts));
return $quizstats;

View File

@ -21,10 +21,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Post-install script
*/

View File

@ -22,10 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Quiz statistics report upgrade code.
*/

View File

@ -22,10 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Serve questiontext files in the question text when they are displayed in this report.
*

View File

@ -22,7 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/quiz/report/statistics/statistics_form.php');
@ -106,7 +105,6 @@ class quiz_statistics_report extends quiz_default_report {
$qubaids = quiz_statistics_qubaids_condition($quiz->id, $currentgroup, $groupstudents, $useallattempts);
// If recalculate was requested, handle that.
if ($recalculate && confirm_sesskey()) {
$this->clear_cached_data($qubaids);
@ -532,7 +530,6 @@ class quiz_statistics_report extends quiz_default_report {
$quizstats = $quizcalc->calculate($quiz->id, $currentgroup, $useallattempts,
$groupstudents, count($questions), $qcalc->get_sum_of_mark_variance());
if ($quizstats->s()) {
$this->calculate_responses_for_all_questions_and_subquestions($qubaids, $questions, $subquestionstats);
}

View File

@ -22,12 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
/**
* This is the settings form for the quiz statistics report.
*

View File

@ -28,7 +28,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(__FILE__) . '/../../../../config.php');
require_once($CFG->libdir . '/graphlib.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');

View File

@ -22,12 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/tablelib.php');
/**
* This table shows statistics about a particular question.
*

View File

@ -22,12 +22,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir.'/tablelib.php');
/**
* This table has one row for each question in the quiz, with sub-rows when
* random questions appear. There are columns for the various statistics.

View File

@ -23,7 +23,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
@ -31,7 +30,6 @@ require_once($CFG->libdir . '/questionlib.php');
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/report/reportlib.php');
/**
* Test helper subclass of question_statistics
*

View File

@ -38,7 +38,6 @@ class calculated {
public $questionid;
// These first fields are the final fields cached in the db and shown in reports.
// See : http://docs.moodle.org/dev/Quiz_statistics_calculations#Position_statistics .
@ -175,5 +174,4 @@ class calculated {
$this->timemodified = $record->timemodified;
}
}

View File

@ -171,7 +171,7 @@ class calculator {
foreach ($lateststeps as $step) {
$this->secondary_steps_walker($step, $this->questionstats[$step->slot], $summarks, $summarksavg);
if ($this->questionstats[$step->slot]->subquestion) {
if ($this->questionstats[$step->slot]->subquestions) {
$this->secondary_steps_walker($step, $this->subquestionstats[$step->questionid], $summarks, $summarksavg);
}
}
@ -217,7 +217,7 @@ class calculator {
public function get_cached($qubaids) {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
$questionstatrecs = $DB->get_record_select('question_statistics', 'hashcode = ? AND timemodified > ?',
$questionstatrecs = $DB->get_records_select('question_statistics', 'hashcode = ? AND timemodified > ?',
array($qubaids->get_hash_code(), $timemodified));
$questionids = array();
@ -250,7 +250,8 @@ class calculator {
global $DB;
$timemodified = time() - self::TIME_TO_CACHE;
return $DB->get_field_select('question_statistics', 'timemodified', 'hashcode = ? AND timemodified > ?',
return $DB->get_field_select('question_statistics', 'timemodified', 'hashcode = ? AND timemodified > ? '.
'ORDER BY timemodified DESC LIMIT 1',
array($qubaids->get_hash_code(), $timemodified));
}
@ -404,8 +405,6 @@ class calculator {
$stats->negcovar = 0;
}
if ($stats->markvariance * $stats->othermarkvariance) {
$stats->discriminationindex = 100 * $stats->covariance /
sqrt($stats->markvariance * $stats->othermarkvariance);

View File

@ -24,10 +24,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* Question statistics cron code. Deletes cached stats more than a certain age.
*/