Here is a summary of all the known problems in item analysis quiz report and solutions when available.
1)
The "Warning: Cannot use a scalar value as an array" problem
Discussion : several threads in this forum
Bugtracker report : bug 3492
Fix : given in attachment to bug 3492 thanks to James Dugal
2)
The "Warning: Cannot modify header information" and the download as Excel or text or Open office file not working
BugTracker reports : bug 3617 and bug 3618.
Fix : see attachment to my comment on bug 3617
3)
The misplaced group selection dropdownmenu
This problem is also solved with the fix given for the previous bug
4)
The "Analysis Options" help button produce a file not found error
Fix change :
helpbutton("analysisoptions", get_string("analysisoptions",'quiz_analysis'), 'quiz_analysis');
to :
helpbutton("analysisoptions", get_string("analysisoptions",'quiz_analysis'), 'quiz');
5)
The true/false question problem : responses to true/false questions aren't displayed correctly
Bugtrtacker report : bug 3720
Fix : currently none
The "Attempts to analyze per user" options problem. The only working option is "all attempts" all other produce inexpected results.
Discussion : forum thread
Bugtracker report : bug 3769
Fix : currently none
For all those needing to use item analysis without waiting for Enrique to look into these bugs, I am attaching a modified mod/quiz/report/analysis/report.php with all problem except the last 2 ones fixed.
For the remaining bugs, I am working on a solution.
Here is a fix for problem #5 (responses to true/false questions aren't displayed correctly - bug 3720)
in file mod/quiz/questiontypes/truefalse/questiontype.php, add the lines :
function get_actual_response($question, $state) {
$answers = $question->options->answers;
if (!empty($state->responses)) {
foreach ($state->responses as $aid =>$rid){
$responses[] = ($answers['true']->id === $rid) ? get_string("true", "quiz") : get_string("false", "quiz");
}
} else {
$responses[] = '';
}
return $responses;
}
just before the lines :
}
//// END OF CLASS ////
near the end of the file.
Et voila true/false questions are now correctly analysed
in file mod/quiz/questiontypes/truefalse/questiontype.php, add the lines :
function get_actual_response($question, $state) {
$answers = $question->options->answers;
if (!empty($state->responses)) {
foreach ($state->responses as $aid =>$rid){
$responses[] = ($answers['true']->id === $rid) ? get_string("true", "quiz") : get_string("false", "quiz");
}
} else {
$responses[] = '';
}
return $responses;
}
just before the lines :
}
//// END OF CLASS ////
near the end of the file.
Et voila true/false questions are now correctly analysed
Well not that brilliant Martin, my code can be somewhat simplified because truefalse questions can't have several answers (I didn't realised that at first) and also === is not needed == is enought
so I suggest the code :
function get_actual_response($question, $state) {
$answers = $question->options->answers;
if (!empty($state->responses)) {
$responses[] = ($answers['true']->id == $state->responses['']) ? get_string("true", "quiz") : get_string("false", "quiz");
} else {
$responses[] = '';
}
return $responses;
}
Gustav if you get that in CVS, don't forget to also fix mod/quiz/report/analysis/report.php so that no more errors are displayed because it confuse a lot of Moodle users. I think item analysis is a wonderfull addition to the quiz module (and I like the fact that it support random questions contrary to the old detailed statistics Mooldle 1.4x quiz plugin) and I think other will enjoy using it as much as I do. Thanks to Enrique.
so I suggest the code :
function get_actual_response($question, $state) {
$answers = $question->options->answers;
if (!empty($state->responses)) {
$responses[] = ($answers['true']->id == $state->responses['']) ? get_string("true", "quiz") : get_string("false", "quiz");
} else {
$responses[] = '';
}
return $responses;
}
Gustav if you get that in CVS, don't forget to also fix mod/quiz/report/analysis/report.php so that no more errors are displayed because it confuse a lot of Moodle users. I think item analysis is a wonderfull addition to the quiz module (and I like the fact that it support random questions contrary to the old detailed statistics Mooldle 1.4x quiz plugin) and I think other will enjoy using it as much as I do. Thanks to Enrique.
For the Moodle users interested in a rapid fix of their item analysis report plugin and not wanting to wait for CVS update, here is a zip file with my 2 modified files :
- quiz/questiontypes/truefalse/questiontype.php
- quiz/report/analysis/report.php
These files contain all my fixes for the bugs reported in this thread (with the correction reported by james), including an inelegant one for the "Attempts to analyze per user" options problem (rather than fixing the SQL query wich proved very difficult with mysql not supporting subqueries, I choose to fetch all attempts and discard the unwanted ones in the loop). There is certainly a better way !!
I must mention that if you choose "highest grade" and if some of your students made several attempts with exactly the same highest grade ALL these attempts will be analyzed not just one per student. Maybe we can call that a "feature" because I see no real way to choose a particular attempt among all the best graded for these students ?
- quiz/questiontypes/truefalse/questiontype.php
- quiz/report/analysis/report.php
These files contain all my fixes for the bugs reported in this thread (with the correction reported by james), including an inelegant one for the "Attempts to analyze per user" options problem (rather than fixing the SQL query wich proved very difficult with mysql not supporting subqueries, I choose to fetch all attempts and discard the unwanted ones in the loop). There is certainly a better way !!
I must mention that if you choose "highest grade" and if some of your students made several attempts with exactly the same highest grade ALL these attempts will be analyzed not just one per student. Maybe we can call that a "feature" because I see no real way to choose a particular attempt among all the best graded for these students ?