From: gustav_delius Date: Thu, 13 Apr 2006 00:02:36 +0000 (+0000) Subject: Now there is an option to see all attempts, even for users who have since unenrolled... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=d6d29245e7d87f65bf3b295d44398d4f7f2a8323;p=moodle.git Now there is an option to see all attempts, even for users who have since unenrolled. That is necessary in order to be able to delete these attempts, see http://moodle.org/mod/forum/discuss.php?d=34421 --- diff --git a/lang/en_utf8/quiz_overview.php b/lang/en_utf8/quiz_overview.php index 04373eea48..216686011e 100644 --- a/lang/en_utf8/quiz_overview.php +++ b/lang/en_utf8/quiz_overview.php @@ -2,4 +2,9 @@ $string['overview'] = 'Overview'; +$string['attemptsonly'] = 'Show $a with attempts only'; +$string['allattempts'] = 'Show all attempts'; +$string['allstudents'] = 'Show all $a'; +$string['noattemptsonly'] = 'Show $a with no attempts only'; + ?> diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index 0005d9a6ba..98f7eebe6c 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -11,10 +11,6 @@ class quiz_report extends quiz_default_report { /// 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'); @@ -267,11 +263,15 @@ class quiz_report extends quiz_default_report { $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'"; if (empty($noattempts)) { - $where .= ' AND qa.userid IS NOT NULL'; // show ONLY attempts; + $where .= ' AND qa.userid IS NOT NULL'; // show ONLY students with attempts; } elseif ($noattempts == 1) { // noattempts = 1 means only no attempts, so make the left join ask for only records where the right is null (no attempts) - $where .= ' AND qa.userid IS NULL'; // show ONLY no attempts; - } // no else, the left join is not filtered, which means we get both back. + $where .= ' AND qa.userid IS NULL'; // show ONLY students without attempts; + } elseif ($noattempts == 3) { + // we want all attempts + $from = 'FROM '.$CFG->prefix.'user u JOIN '.$CFG->prefix.'quiz_attempts qa ON u.id = qa.userid '; + $where = ' WHERE qa.quiz = '.$quiz->id.' AND qa.preview = 0'; + } // noattempts = 2 means we want all students, with or without attempts } $countsql = 'SELECT COUNT(DISTINCT('.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).')) '.$from.$where; } else { @@ -516,10 +516,11 @@ class quiz_report extends quiz_default_report { echo ''; echo ''; echo ''; - $options = array(0 => $strattemptsonly); + $options = array(0 => get_string('attemptsonly','quiz_overview', $course->students)); if ($course->id != SITEID) { - $options[1] = $strnoattemptsonly; - $options[2] = $strbothattempts; + $options[1] = get_string('noattemptsonly', 'quiz_overview', $course->students); + $options[2] = get_string('allstudents','quiz_overview', $course->students); + $options[3] = get_string('allattempts','quiz_overview'); } choose_from_menu($options,'noattempts',$noattempts,''); echo '';