Index: mod/quiz/report/reportlib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/report/reportlib.php,v
retrieving revision 1.32
diff -u -r1.32 reportlib.php
--- mod/quiz/report/reportlib.php 11 Sep 2008 12:48:09 -0000 1.32
+++ mod/quiz/report/reportlib.php 18 Sep 2008 16:05:33 -0000
@@ -131,14 +131,18 @@
}
function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){
- global $CFG, $DB;
+ global $CFG, $DB, $QUESTION_EVENTS_GRADED, $QUESTION_EVENTS_CLOSED;
$params = array($quiz->id);
list($u_sql, $u_params) = $DB->get_in_or_equal($userids);
list($q_sql, $q_params) = $DB->get_in_or_equal($questionids);
+ list($graded_sql, $graded_params) = $DB->get_in_or_equal($QUESTION_EVENTS_GRADED);
+
+ $closedorgradedevents = array_unique(array_merge($QUESTION_EVENTS_GRADED, $QUESTION_EVENTS_CLOSED));
+ list($closedorgraded_sql, $closedorgraded_params) = $DB->get_in_or_equal($closedorgradedevents);
- $params = array_merge($params, $u_params, $q_params);
+ $params = array_merge($graded_params, $params, $u_params, $closedorgraded_params, $q_params);
$sql = "SELECT qs.question, COUNT(1) AS totalattempts,
- SUM(CASE WHEN (qs.event IN (".QUESTION_EVENTS_GRADED.")) THEN 1 ELSE 0 END) AS gradedattempts
+ SUM(CASE WHEN (qs.event $graded_sql) THEN 1 ELSE 0 END) AS gradedattempts
FROM
{quiz_attempts} qa,
{question_sessions} qns,
@@ -147,7 +151,8 @@
qa.quiz = ? AND
qa.userid $u_sql AND
qns.attemptid = qa.uniqueid AND
- qns.newgraded = qs.id AND
+ qns.newest = qs.id AND
+ qs.event $closedorgraded_sql AND
qs.question $q_sql
GROUP BY qs.question";
return $DB->get_records_sql($sql, $params);
Index: mod/quiz/report/grading/report.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/quiz/report/grading/report.php,v
retrieving revision 1.46
diff -u -r1.46 report.php
--- mod/quiz/report/grading/report.php 18 Sep 2008 07:39:10 -0000 1.46
+++ mod/quiz/report/grading/report.php 18 Sep 2008 16:05:33 -0000
@@ -160,8 +160,6 @@
groups_print_activity_menu($this->cm, $this->viewurl->out(false, array('userid'=>0, 'attemptid'=>0)));
}
- echo '
' . quiz_num_attempt_summary($quiz, $cm, true, $currentgroup) . '
';
-
if(empty($this->users)) {
if ($currentgroup){
notify(get_string('nostudentsingroup'));
@@ -427,7 +425,7 @@
}
function attempts_sql($quizid, $wantstateevent=false, $questionid=0, $userid=0, $attemptid=0, $gradeungraded=0, $gradenextungraded=0){
- global $CFG, $DB;
+ global $CFG, $DB, $QUESTION_EVENTS_GRADED, $QUESTION_EVENTS_CLOSED;
// this sql joins the attempts table and the user table
$select = 'SELECT qa.id AS attemptid, qa.uniqueid, qa.attempt, qa.timefinish, qa.preview,
u.id AS userid, u.firstname, u.lastname, u.picture ';
@@ -438,18 +436,20 @@
'{quiz_attempts} qa ';
$params = array();
- if (($wantstateevent|| $gradenextungraded || $gradeungraded) && $questionid){
- $from .= "LEFT JOIN {question_sessions} qns " .
- "ON (qns.attemptid = qa.uniqueid AND qns.questionid = ?) ";
- $params[] = $questionid;
- $from .= "LEFT JOIN {question_states} qs " .
- "ON (qs.id = qns.newgraded AND qs.question = ?) ";
- $params[] = $questionid;
- }
+ $from .= "LEFT JOIN {question_sessions} qns " .
+ "ON (qns.attemptid = qa.uniqueid AND qns.questionid = ?) ";
+ $params[] = $questionid;
+ $from .= "LEFT JOIN {question_states} qs " .
+ "ON (qs.id = qns.newest AND qs.question = ?) ";
+ $params[] = $questionid;
+
list($usql, $u_params) = $DB->get_in_or_equal(array_keys($this->users));
if ($gradenextungraded || $gradeungraded) { // get ungraded attempts
- $where = "WHERE u.id $usql AND qs.event NOT IN (".QUESTION_EVENTS_GRADED.') ';
+ list($gradedevent_sql, $gradedevent_params)
+ = $DB->get_in_or_equal($QUESTION_EVENTS_GRADED, SQL_PARAMS_QM, '', false);
+ $where = "WHERE u.id $usql AND qs.event $gradedevent_sql";
$params = array_merge($params, $u_params);
+ $params = array_merge($params, $gradedevent_params);
} else if ($userid) { // get all the attempts for a specific user
$where = 'WHERE u.id=?';
$params[] = $userid;
@@ -460,6 +460,12 @@
$where = "WHERE u.id $usql ";
$params = array_merge($params, $u_params);
}
+
+ $closedorgradedevents = array_unique(array_merge($QUESTION_EVENTS_GRADED, $QUESTION_EVENTS_CLOSED));
+ list($closedorgraded_sql, $closedorgraded_params) = $DB->get_in_or_equal($closedorgradedevents);
+ $params = array_merge($params, $closedorgraded_params);
+ $where .= ' AND qs.event '.$closedorgraded_sql;
+
$where .= ' AND u.id = qa.userid AND qa.quiz = ?';
$params[] = $quizid;
Index: lib/questionlib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/questionlib.php,v
retrieving revision 1.169
diff -u -r1.169 questionlib.php
--- lib/questionlib.php 18 Sep 2008 07:39:10 -0000 1.169
+++ lib/questionlib.php 18 Sep 2008 16:05:33 -0000
@@ -41,6 +41,10 @@
$QUESTION_EVENTS_GRADED = array(QUESTION_EVENTGRADE, QUESTION_EVENTCLOSEANDGRADE,
QUESTION_EVENTMANUALGRADE);
+global $QUESTION_EVENTS_CLOSED;
+$QUESTION_EVENTS_CLOSED = array(QUESTION_EVENTCLOSE, QUESTION_EVENTCLOSEANDGRADE,
+ QUESTION_EVENTMANUALGRADE);
+
/**#@-*/
/**#@+
@@ -1240,8 +1244,8 @@
* @param object $state
*/
function question_state_is_graded($state) {
- $gradedevents = explode(',', QUESTION_EVENTS_GRADED);
- return (in_array($state->event, $gradedevents));
+ global $QUESTION_EVENTS_GRADED;
+ return (in_array($state->event, $QUESTION_EVENTS_GRADED));
}
/**
@@ -1251,9 +1255,8 @@
* @param object $state
*/
function question_state_is_closed($state) {
- return ($state->event == QUESTION_EVENTCLOSE
- or $state->event == QUESTION_EVENTCLOSEANDGRADE
- or $state->event == QUESTION_EVENTMANUALGRADE);
+ global $QUESTION_EVENTS_CLOSED;
+ return (in_array($state->event, $QUESTION_EVENTS_CLOSED));
}