mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
This has extra code to exclude preview attempts from the grading
This commit is contained in:
parent
6ed15ea50a
commit
ec65c6ad7c
1 changed files with 15 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
<?php
|
<?php // $Id$
|
||||||
|
|
||||||
// This file allows a teacher to grade essay questions.
|
// This file allows a teacher to grade essay questions.
|
||||||
// Could be later expanded to change grades for all question types
|
// Could be later expanded to change grades for all question types
|
||||||
|
@ -124,6 +124,11 @@ class quiz_report extends quiz_default_report {
|
||||||
}
|
}
|
||||||
notify(get_string('changessaved', 'quiz'));
|
notify(get_string('changessaved', 'quiz'));
|
||||||
|
|
||||||
|
// Provide grading form for a particular question
|
||||||
|
// (either for a particular attempt, a particular user, or for all attempts)
|
||||||
|
|
||||||
|
// First select the attempts to work on
|
||||||
|
|
||||||
} else if ( ( !empty($attemptid) or !empty($gradeall) or !empty($userid)) and !empty($questionid) ) { // need attemptid and questionid or gradeall and a questionid
|
} else if ( ( !empty($attemptid) or !empty($gradeall) or !empty($userid)) and !empty($questionid) ) { // need attemptid and questionid or gradeall and a questionid
|
||||||
// this sql joins the attempts table and the user table
|
// this sql joins the attempts table and the user table
|
||||||
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid,
|
$select = 'SELECT '.$db->Concat('u.id', '\'#\'', $db->IfNull('qa.attempt', '0')).' AS userattemptid,
|
||||||
|
@ -139,11 +144,16 @@ class quiz_report extends quiz_default_report {
|
||||||
$where = 'WHERE qa.id='.$attemptid.' ';
|
$where = 'WHERE qa.id='.$attemptid.' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ignore previews
|
||||||
|
$where .= ' AND preview = 0';
|
||||||
|
|
||||||
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
|
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
|
||||||
$where .= 'AND '.$db->IfNull('qa.timefinish', '0').' != 0 ';
|
$where .= 'AND '.$db->IfNull('qa.timefinish', '0').' != 0 ';
|
||||||
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
|
$sort = 'ORDER BY u.firstname, u.lastname, qa.attempt ASC';
|
||||||
$attempts = get_records_sql($select.$from.$where.$sort);
|
$attempts = get_records_sql($select.$from.$where.$sort);
|
||||||
|
|
||||||
|
// Display the form with one part for each selected attempt
|
||||||
|
|
||||||
echo '<form method="post" action="report.php">'.
|
echo '<form method="post" action="report.php">'.
|
||||||
'<input type="hidden" name="mode" value="grading">'.
|
'<input type="hidden" name="mode" value="grading">'.
|
||||||
'<input type="hidden" name="q" value="'.$quiz->id.'">'.
|
'<input type="hidden" name="q" value="'.$quiz->id.'">'.
|
||||||
|
@ -210,7 +220,7 @@ class quiz_report extends quiz_default_report {
|
||||||
" {$CFG->prefix}quiz_question_instances i".
|
" {$CFG->prefix}quiz_question_instances i".
|
||||||
" WHERE i.quiz = '$quiz->id' AND q.id = i.question".
|
" WHERE i.quiz = '$quiz->id' AND q.id = i.question".
|
||||||
" AND q.id IN ($questionlist)".
|
" AND q.id IN ($questionlist)".
|
||||||
" AND q.qtype = '".ESSAY."'".
|
" AND q.qtype = 'essay'".
|
||||||
" ORDER BY q.name";
|
" ORDER BY q.name";
|
||||||
if (empty($questionlist) or !$questions = get_records_sql($sql)) {
|
if (empty($questionlist) or !$questions = get_records_sql($sql)) {
|
||||||
print_heading(get_string('noessayquestionsfound', 'quiz'));
|
print_heading(get_string('noessayquestionsfound', 'quiz'));
|
||||||
|
@ -218,7 +228,7 @@ class quiz_report extends quiz_default_report {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
// get all the finished attempts by the users
|
// get all the finished attempts by the users
|
||||||
if ($attempts = get_records_select('quiz_attempts', "quiz = $quiz->id and timefinish > 0 and userid IN ($userids)", 'userid, attempt')) {
|
if ($attempts = get_records_select('quiz_attempts', "quiz = $quiz->id and timefinish > 0 AND userid IN ($userids) AND preview = 0", 'userid, attempt')) {
|
||||||
foreach($questions as $question) {
|
foreach($questions as $question) {
|
||||||
|
|
||||||
$link = "<a href=\"report.php?mode=grading&q=$quiz->id&action=viewquestion&questionid=$question->id\">".
|
$link = "<a href=\"report.php?mode=grading&q=$quiz->id&action=viewquestion&questionid=$question->id\">".
|
||||||
|
@ -283,6 +293,7 @@ class quiz_report extends quiz_default_report {
|
||||||
$where = 'WHERE u.id IN ('.implode(',', array_keys($users)).') ';
|
$where = 'WHERE u.id IN ('.implode(',', array_keys($users)).') ';
|
||||||
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
|
$where .= 'AND '.$db->IfNull('qa.attempt', '0').' != 0 ';
|
||||||
$where .= 'AND '.$db->IfNull('qa.timefinish', '0').' != 0 ';
|
$where .= 'AND '.$db->IfNull('qa.timefinish', '0').' != 0 ';
|
||||||
|
$where .= 'AND preview = 0 '; // ignore previews
|
||||||
|
|
||||||
if($table->get_sql_where()) { // forgot what this does
|
if($table->get_sql_where()) { // forgot what this does
|
||||||
$where .= 'AND '.$table->get_sql_where();
|
$where .= 'AND '.$table->get_sql_where();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue