MDL-15268 "Content for Quiz Statistics report table" more columns of Quiz Statistics report table.
This commit is contained in:
@@ -12,8 +12,10 @@ $string['quizname'] = 'Quiz name';
|
||||
$string['coursename'] = 'Course name';
|
||||
$string['nooffirstattempts'] = 'Number of first attempts';
|
||||
$string['noofallattempts'] = 'Total number of attempts';
|
||||
$string['statsforfirstattempts'] = 'Statistics for first attempts';
|
||||
$string['statsforallattempts'] = 'Statistics for all attempts';
|
||||
$string['statsfor'] = 'Statistics (for $a)';
|
||||
$string['attempts'] = 'Attempts';
|
||||
$string['firstattempts'] = 'for first attempts';
|
||||
$string['allattempts'] = 'for all attempts';
|
||||
$string['firstattemptsavg'] = 'Average grade of first attempts';
|
||||
$string['allattemptsavg'] = 'Average grade of all attempts';
|
||||
$string['attemptsall'] = 'all attempts';
|
||||
@@ -33,4 +35,5 @@ $string['quizstructureanalysis'] = 'Quiz structure analysis';
|
||||
$string['questiontype'] = 'Q type';
|
||||
$string['intended_weight'] = 'Intended question weight';
|
||||
$string['random_guess_score'] = 'Random guess score';
|
||||
$string['facility'] = 'Facility index';
|
||||
?>
|
||||
@@ -142,13 +142,14 @@ class quiz_report extends quiz_default_report {
|
||||
if (!$table->is_downloading()) {
|
||||
if ($useallattempts){
|
||||
$usingattempts = $allattempts;
|
||||
$usingattempts->heading = get_string('statsforallattempts', 'quiz_statistics');
|
||||
$usingattempts->attempts = get_string('allattempts', 'quiz_statistics');
|
||||
$usingattempts->sql = '';
|
||||
} else {
|
||||
$usingattempts = $firstattempt;
|
||||
$usingattempts->heading = get_string('statsforfirstattempts', 'quiz_statistics');
|
||||
$usingattempts->attempts = get_string('firstattempts', 'quiz_statistics');
|
||||
$usingattempts->sql = 'AND qa.attempt=1 ';
|
||||
}
|
||||
$usingattempts->heading = get_string('statsfor', 'quiz_statistics', $usingattempts->attempts);
|
||||
print_heading($usingattempts->heading);
|
||||
if (($usingattempts->countrecs/2)==floor($usingattempts->countrecs/2)){
|
||||
//even number of attempts
|
||||
@@ -228,25 +229,25 @@ class quiz_report extends quiz_default_report {
|
||||
}
|
||||
//CIC, ER and SE.
|
||||
//http://docs.moodle.org/en/Development:Quiz_item_analysis_calculations_in_practise#CIC.2C_ER_and_SE
|
||||
list($qsql, $sqlparams) = $DB->get_in_or_equal(array_keys($questions), SQL_PARAMS_QM);
|
||||
array_unshift($sqlparams, $quiz->id);//put quiz id in at beginning of array
|
||||
$qgradeavgsql = "SELECT qs.question, AVG(qs.grade) FROM " .
|
||||
"{question_sessions} qns, " .
|
||||
"{question_states} qs, " .
|
||||
"{question} q, " .
|
||||
$fromqa.' '.
|
||||
'WHERE ' .$whereqa.
|
||||
'AND qns.attemptid = qa.uniqueid '.
|
||||
'AND qs.question = q.id ' .
|
||||
'AND q.length > 0 '.
|
||||
'AND qs.question '.$qsql.' ' .
|
||||
$usingattempts->sql.
|
||||
'AND qns.newgraded = qs.id GROUP BY qs.question';
|
||||
$qgradeavgs = $DB->get_records_sql_menu($qgradeavgsql, array($quiz->id));
|
||||
$qgradeavgs = $DB->get_records_sql_menu($qgradeavgsql, $sqlparams);
|
||||
|
||||
$sum = 0;
|
||||
$sql = 'SELECT ' .
|
||||
$sql = 'SELECT COUNT(1) as s,' .
|
||||
'SUM(POWER((qs.grade - ?),2)) AS power2 ' .
|
||||
'FROM ' .
|
||||
'{question_sessions} qns, ' .
|
||||
'{question_states} qs, ' .
|
||||
'{question} q, ' .
|
||||
'{question_states} qs, '.
|
||||
$fromqa.' '.
|
||||
'WHERE ' .$whereqa.
|
||||
'AND qns.attemptid = qa.uniqueid '.
|
||||
@@ -255,11 +256,15 @@ class quiz_report extends quiz_default_report {
|
||||
'AND qns.newgraded = qs.id';
|
||||
foreach ($qgradeavgs as $qid => $qgradeavg){
|
||||
$params = array($qgradeavg, $quiz->id, $qid);
|
||||
$power = $DB->get_field_sql($sql, $params);
|
||||
if ($power === false){
|
||||
$fromdb = $DB->get_record_sql($sql, $params);
|
||||
if ($fromdb === false){
|
||||
print_error('errorpowerquestions', 'quiz_statistics');
|
||||
}
|
||||
$sum += $power;
|
||||
$questions[$qid]->facility = $qgradeavg / $questions[$qid]->grade;
|
||||
$questions[$qid]->power = $fromdb->power2;
|
||||
$questions[$qid]->s = $fromdb->s;
|
||||
$questions[$qid]->sd = sqrt($questions[$qid]->power / ($questions[$qid]->s -1));
|
||||
$sum += $questions[$qid]->power;
|
||||
}
|
||||
$sumofvarianceforallpositions = $sum / ($usingattempts->countrecs -1);
|
||||
$p = count($qgradeavgs);//no of positions
|
||||
@@ -277,7 +282,7 @@ class quiz_report extends quiz_default_report {
|
||||
if (!$table->is_downloading()){
|
||||
print_heading(get_string('quizstructureanalysis', 'quiz_statistics'));
|
||||
}
|
||||
$table->setup($quiz, $cm->id, $reporturl);
|
||||
$table->setup($quiz, $cm->id, $reporturl, $s);
|
||||
foreach ($questions as $question){
|
||||
$table->add_data_keyed($table->format_row($question));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class quiz_report_statistics_table extends flexible_table {
|
||||
* Setup the columns and headers and other properties of the table and then
|
||||
* call flexible_table::setup() method.
|
||||
*/
|
||||
function setup($quiz, $cmid, $reporturl){
|
||||
function setup($quiz, $cmid, $reporturl, $s){
|
||||
$this->quiz = $quiz;
|
||||
$this->cmid = $cmid;
|
||||
// Define table columns
|
||||
@@ -35,12 +35,22 @@ class quiz_report_statistics_table extends flexible_table {
|
||||
$columns[]= 'name';
|
||||
$headers[]= get_string('questionname', 'quiz');
|
||||
|
||||
$columns[]= 'intended_weight';
|
||||
$headers[]= get_string('intended_weight', 'quiz_statistics');
|
||||
|
||||
$columns[]= 's';
|
||||
$headers[]= get_string('attempts', 'quiz_statistics');
|
||||
|
||||
if ($s>1){
|
||||
$columns[]= 'facility';
|
||||
$headers[]= get_string('facility', 'quiz_statistics');
|
||||
|
||||
$columns[]= 'sd';
|
||||
$headers[]= get_string('standarddeviation', 'quiz_statistics');
|
||||
}
|
||||
$columns[]= 'random_guess_score';
|
||||
$headers[]= get_string('random_guess_score', 'quiz_statistics');
|
||||
|
||||
$columns[]= 'intended_weight';
|
||||
$headers[]= get_string('intended_weight', 'quiz_statistics');
|
||||
|
||||
$this->define_columns($columns);
|
||||
$this->define_headers($headers);
|
||||
$this->sortable(false);
|
||||
@@ -96,11 +106,21 @@ class quiz_report_statistics_table extends flexible_table {
|
||||
|
||||
function col_random_guess_score($question){
|
||||
$randomguessscore = question_get_random_guess_score($question);
|
||||
if (is_number($randomguessscore)){
|
||||
if (is_numeric($randomguessscore)){
|
||||
return number_format($randomguessscore * 100, 2).' %';
|
||||
} else {
|
||||
return $randomguessscore; // empty string returned by random question.
|
||||
}
|
||||
}
|
||||
|
||||
function col_sd($question){
|
||||
return number_format($question->sd*100 / $question->grade, 2).' %';
|
||||
}
|
||||
function col_s($question){
|
||||
return $question->s;
|
||||
}
|
||||
function col_facility($question){
|
||||
return number_format($question->facility*100, 2).' %';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user