Moodle

Essay quiz Manual grading "these are no attempts to show" when there are actually attempts

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9, 1.9.1
  • Fix Version/s: 1.9.3
  • Component/s: Questions, Quiz
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

Tested on the most recent 1.9.1+ code (20080605 build), when there are attempts from students, when login as admin or teacher, see screenshot

Issue Links

Activity

Hide
Wen Hao Chuang added a comment -

Also, personally I think the yellow-highlighted is not accessible nor good looking, what do people think?

Show
Wen Hao Chuang added a comment - Also, personally I think the yellow-highlighted is not accessible nor good looking, what do people think?
Hide
Jamie Pratt added a comment -

See the screen shot. I chose yellow since it needs to be different to the colour used to indicate that a question has been marked correct. And also to hopefully distinguish the colour from that used in the overview report.

Also see that I have used text as well to indicate a graded question. The highlighting is just extra help to identify graded questions.

Show
Jamie Pratt added a comment - See the screen shot. I chose yellow since it needs to be different to the colour used to indicate that a question has been marked correct. And also to hopefully distinguish the colour from that used in the overview report. Also see that I have used text as well to indicate a graded question. The highlighting is just extra help to identify graded questions.
Hide
Jamie Pratt added a comment -

Can't find what could be causing your problem Wen. I did find a LIMIT clause which I removed since it is not cross db compatible. But I don't think this could be causing trouble for you.

Show
Jamie Pratt added a comment - Can't find what could be causing your problem Wen. I did find a LIMIT clause which I removed since it is not cross db compatible. But I don't think this could be causing trouble for you.
Hide
Jamie Pratt added a comment -

Hi Wen!

Would you have time to insert this line, marked by the comment, in mod/quiz/report/grading/report.php in the attempt_sql method just before the return :

} else { // get all user attempts $where = 'WHERE u.id IN ('.$this->userids.') '; }

$where .= ' AND u.id = qa.userid AND qa.quiz = '.$quizid;
// ignore previews
$where .= ' AND preview = 0 ';

$where .= ' AND qa.timefinish != 0 ';
//insert this next line :
print_object(func_get_args()+ compact('select', 'from', 'where', 'params'));

return array($select, $from, $where);
}

And let me know what it outputs?

Jamie

Show
Jamie Pratt added a comment - Hi Wen! Would you have time to insert this line, marked by the comment, in mod/quiz/report/grading/report.php in the attempt_sql method just before the return : } else { // get all user attempts $where = 'WHERE u.id IN ('.$this->userids.') '; } $where .= ' AND u.id = qa.userid AND qa.quiz = '.$quizid; // ignore previews $where .= ' AND preview = 0 '; $where .= ' AND qa.timefinish != 0 '; //insert this next line : print_object(func_get_args()+ compact('select', 'from', 'where', 'params')); return array($select, $from, $where); } And let me know what it outputs? Jamie
Hide
Jamie Pratt added a comment -

Wen are you still experiencing problems with this??

Show
Jamie Pratt added a comment - Wen are you still experiencing problems with this??
Hide
Wen Hao Chuang added a comment -

Hi Jamie, sorry been really busy recently. Will test this next Monday (July 14) and update it here. thanks!

Show
Wen Hao Chuang added a comment - Hi Jamie, sorry been really busy recently. Will test this next Monday (July 14) and update it here. thanks!
Hide
Jamie Pratt added a comment -

Thanks Wen!

Show
Jamie Pratt added a comment - Thanks Wen!
Hide
Jamie Pratt added a comment -

Hi Wen,

Just a bump to remind you about this issue.

Jamie

Show
Jamie Pratt added a comment - Hi Wen, Just a bump to remind you about this issue. Jamie
Hide
Tak Auyeung added a comment -

I think I resolved this issue. At least for PostgreSQL, the problem is with the function quiz_get_total_qas_graded_and_ungraded. The query uses the following expression to compute the number of graded attempts:

sum(qs.event in (...)) as gradedattempts

This does not work in PostgreSQL because sum expects an integers, and "... in ..." returns a boolean. This needs to be changed to use the cast operator. My final revision of this function is as follows:

function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){
global $CFG;
$sql = "SELECT qs.question, COUNT(1) AS totalattempts, " .
"sum(cast ((qs.event IN (".QUESTION_EVENTS_GRADED.")) as integer)) AS gradedattempts " .
"FROM " .
"{$CFG->prefix}quiz_attempts qa, " .
"{$CFG->prefix}question_sessions qns, " .
"{$CFG->prefix}question_states qs " .
"WHERE " .
"qa.quiz = {$quiz->id} AND " .
"qa.userid IN ({$userids}) AND " .
"qns.attemptid = qa.uniqueid AND " .
"qns.newgraded = qs.id AND " .
"qs.question IN ({$questionids}) " .
"GROUP BY qs.question";
return get_records_sql($sql);
}

I tried this with my local Moodle installation and it fixed the reported problem.

Show
Tak Auyeung added a comment - I think I resolved this issue. At least for PostgreSQL, the problem is with the function quiz_get_total_qas_graded_and_ungraded. The query uses the following expression to compute the number of graded attempts: sum(qs.event in (...)) as gradedattempts This does not work in PostgreSQL because sum expects an integers, and "... in ..." returns a boolean. This needs to be changed to use the cast operator. My final revision of this function is as follows: function quiz_get_total_qas_graded_and_ungraded($quiz, $questionids, $userids){ global $CFG; $sql = "SELECT qs.question, COUNT(1) AS totalattempts, " . "sum(cast ((qs.event IN (".QUESTION_EVENTS_GRADED.")) as integer)) AS gradedattempts " . "FROM " . "{$CFG->prefix}quiz_attempts qa, " . "{$CFG->prefix}question_sessions qns, " . "{$CFG->prefix}question_states qs " . "WHERE " . "qa.quiz = {$quiz->id} AND " . "qa.userid IN ({$userids}) AND " . "qns.attemptid = qa.uniqueid AND " . "qns.newgraded = qs.id AND " . "qs.question IN ({$questionids}) " . "GROUP BY qs.question"; return get_records_sql($sql); } I tried this with my local Moodle installation and it fixed the reported problem.
Hide
David Wong added a comment -

I'm having the same problem in that the system indicates that there are no attempts to show when there many attempts. We're using:

PHP 5.2.6
Postgres 8.3.3
Apache 2.0/Linux
Moodle 1.9.2+

Show
David Wong added a comment - I'm having the same problem in that the system indicates that there are no attempts to show when there many attempts. We're using: PHP 5.2.6 Postgres 8.3.3 Apache 2.0/Linux Moodle 1.9.2+
Hide
Mike Churchward added a comment -

The fix described above seems to solve the problem on PostGres sites. Can this not be committed to core?

Show
Mike Churchward added a comment - The fix described above seems to solve the problem on PostGres sites. Can this not be committed to core?
Hide
Jamie Pratt added a comment -

Hi,

Sorry to be slow responding to this bug report.

It has already been fixed in 1.9 stable and HEAD. It is fixed in 1.9.3. Marking this as a duplicate of MDL-15973

J

Show
Jamie Pratt added a comment - Hi, Sorry to be slow responding to this bug report. It has already been fixed in 1.9 stable and HEAD. It is fixed in 1.9.3. Marking this as a duplicate of MDL-15973 J
Hide
Mike Churchward added a comment -

Thanks Jamie. I hadn't noticed the duplicate.

Show
Mike Churchward added a comment - Thanks Jamie. I hadn't noticed the duplicate.
Hide
Jerome Mouneyrac added a comment -

Tested on 1.9 Stable with Postgres, graded attempts appear.
Thanks for your participation

Show
Jerome Mouneyrac added a comment - Tested on 1.9 Stable with Postgres, graded attempts appear. Thanks for your participation

People

Dates

  • Created:
    Updated:
    Resolved: