Skip to content

Commit

Permalink
By popular request - quiz report now shows students with attempts onl…
Browse files Browse the repository at this point in the history
…y, students with no attempts only, students with attempts AND no attempts. This fixes bugs #4406 and #4353
  • Loading branch information
mjollnir_ committed Mar 1, 2006
1 parent 6ae92cf commit 03c8c27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
2 changes: 2 additions & 0 deletions lang/en_utf8/quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
$string['attemptlast'] = 'Last attempt';
$string['attemptquiznow'] = 'Attempt quiz now';
$string['attempts'] = 'Attempts';
$string['attemptsonly'] = 'Show only students with attempts';
$string['attemptsallowed'] = 'Attempts allowed';
$string['attemptselection'] = 'Select which attempts to analyze per user: ';
$string['attemptsexist'] = 'This quiz has already been attempted.<br />You can no longer add or remove questions.';
$string['attemptsunlimited'] = 'Unlimited attempts';
$string['back'] = 'Back to preview question';
$string['backtoquiz'] = 'Back to quiz editing';
$string['bestgrade'] = 'Best grade';
$string['bothattempts'] = 'Show students with and without attempts';
$string['blackboard'] = 'Blackboard';
$string['calculated'] = 'Calculated';
$string['calculatedquestion'] = 'Calculated Question not supported at line $a. The question will be ignored';
Expand Down
24 changes: 21 additions & 3 deletions mod/quiz/report/overview/report.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function display($quiz, $cm, $course) { /// This function just displays the
/// Define some strings
$strreallydel = addslashes(get_string('deleteattemptcheck','quiz'));
$strnoattempts = get_string('noattempts','quiz');
$strnoattemptsonly = get_string('shownoattemptsonly', 'quiz');
$strattemptsonly = get_string('attemptsonly','quiz');
$strbothattempts = get_string('bothattempts','quiz');
$strtimeformat = get_string('strftimedatetime');
$strreviewquestion = get_string('reviewresponse', 'quiz');

Expand Down Expand Up @@ -250,7 +253,10 @@ function display($quiz, $cm, $course) { /// This function just displays the
// So join on groups_members and do a left join on attempts where the right side is null (no records in the attempts table)
$from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id JOIN '.$CFG->prefix.'groups_members gm ON u.id = gm.userid '.
'LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE us.course = '.$course->id.' AND gm.groupid = '.$currentgroup.' AND qa.userid IS NULL';
$where = ' WHERE us.course = '.$course->id.' AND gm.groupid = '.$currentgroup;
if ($noattempts == 1) {
$where .= ' AND qa.userid IS NULL'; // show ONLY no attempts;
}
} else if (empty($currentgroup) && empty($noattempts)) {
// We don't care about group, and we only want to see students WITH attempts.
// So just do a striaght inner join on attempts, don't worry about the groups_members table
Expand All @@ -260,7 +266,10 @@ function display($quiz, $cm, $course) { /// This function just displays the
// We don't care about group, and we only want to see students WITHOUT attempts.
// So do a left join on attempts where the right side is null (no records in the attempts table), and don't worry about groups_members.
$from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'user_students us ON us.userid = u.id LEFT JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid AND qa.quiz = '.$quiz->id;
$where = ' WHERE us.course = '.$course->id.' AND qa.userid IS NULL';
$where = ' WHERE us.course = '.$course->id;
if ($noattempts == 1) {
$where .= ' AND qa.userid IS NULL';
}
}
$countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where;
} else {
Expand Down Expand Up @@ -469,7 +478,16 @@ function display($quiz, $cm, $course) { /// This function just displays the
echo '<td><input type="text" id="pagesize" name="pagesize" size="1" value="'.$pagesize.'" /></td>';
echo '</tr>';
echo '<tr align="left">';
echo '<td colspan="2"><input type="checkbox" id="checknoattempts" name="noattempts" '.($noattempts?'checked="checked" ':'').'value="1" '.(($course->id == SITEID) ? ' disabled="disabled"' : '') .' /> <label for="checknoattempts">'.get_string('shownoattemptsonly', 'quiz').'</label> ';
echo '<td colspan="2">';
$options = array(0 => $strattemptsonly);
if ($course->id != SITEID) {
$options[1] = $strnoattemptsonly;
$options[2] = $strbothattempts;
}
choose_from_menu($options,'noattempts',$noattempts,'');
/*
<input type="checkbox" id="checknoattempts" name="noattempts" '.($noattempts?'checked="checked" ':'').'value="1" '.(($course->id == SITEID) ? ' disabled="disabled"' : '') .' /> <label for="checknoattempts">'.get_string('shownoattemptsonly', 'quiz').'</label> ';
*/
echo '</td></tr>';
echo '<tr align="left">';
echo '<td colspan="2"><input type="checkbox" id="checkdetailedmarks" name="detailedmarks" '.($detailedmarks?'checked="checked" ':'').'value="1" /> <label for="checkdetailedmarks">'.get_string('showdetailedmarks', 'quiz').'</label> ';
Expand Down

0 comments on commit 03c8c27

Please sign in to comment.