The following changes were made to help reduce confusion for students when essay questions are being used in a quiz.

- When a essay question has been submitted or being reviewed and has not been graded by the instructor, then the Marks are not shown and displays a message to the student instead of saying Incorrect. (changes to questiontypes/questiontype.php in functions print_question and print_question_grading_details).

    - For students, in view.php, a notice is printed to inform him/her that s/he has ungraded essay question(s).
    - For teachers, in view.php, a notice is printed to inform him/her that s/he has X number of ungraded essays for X number of studnets

    - In review.php, next to the grade output, informs the viewer if X number of ungraded essays in this attempt.

    - In questiontypes/essay/questiontype.php created a utility function to generate the numbers used in the above changes.

    - In lang/en/quiz.php added new lang entries.

So, hopefully the student will now understand that their grade does not include the ungraded essay questions.  Modification of lang entries might be needed to further drive this point.
This commit is contained in:
michaelpenne 2006-02-13 20:27:34 +00:00
parent d8ed413b92
commit b9376ebef0
5 changed files with 116 additions and 4 deletions

View file

@ -4,13 +4,17 @@ $string['changessaved'] = 'Grading Changes Saved';
$string['comments'] = 'Comments';
$string['editingessay'] = 'Editing Essay';
$string['essay'] = 'Essay';
$string['essayonly'] = 'Manual grading is so far only implemented for essay questions';
$string['essayquestions'] = 'Essay Questions';
$string['gradeall'] = 'Grade All';
$string['gradeessays'] = 'Grade Essays';
$string['manualgrading'] = 'Manual grading';
$string['nocommentsyet'] = 'No comments yet.';
$string['noessayquestionsfound'] = 'No Essay Questions Found';
$string['essayonly'] = 'Manual grading is so far only implemented for essay questions';
$string['numungraded'] = '($a ungraded)';
$string['ungraded'] = 'Ungraded';
$string['ungradednotice'] = 'Note: $a ungraded essay(s) in this attempt.';
$string['viewessaystograde'] = 'View $a->ungradedessays ungraded essay(s) ($a->usercount $a->students)';
$string['willbegradedby'] = 'This question will be graded by your $a.';
$string['youhaveungradedessays'] = 'You have $a essay(s) waiting to be graded.';
?>

View file

@ -237,6 +237,72 @@ class quiz_essay_qtype extends quiz_default_questiontype {
return true;
}
/**
* Utility function to count the number of ungraded essays
* and the number of students those essays belong to.
*
* @param object $cmoptions Course module options
* @param mixed $users string/array Specify a specific user or a set of users as an array with ids as keys or as a comma separated list. Defaults to current user.
* @param string $attemptid Specify a specific attempt
* @return array First item in array is the number of ungraded essays and the second is the number of students
* @todo make this function quiz independent
*/
function get_ungraded_count($cmoptions, $users=0, $attemptid=0) {
global $USER, $CFG;
// prep the userids variable
if (empty($users)) {
$userids = $USER->id;
}else if (is_array($users)) {
$userids = implode(', ', array_keys($users));
} else {
$userids = $users;
}
$ungradedcount = 0; // holds the number of ungraded essays
$usercount = array(); // holds the number of users of ungraded essays
// get the essay questions
$questionlist = quiz_questions_in_quiz($cmoptions->questions);
$sql = "SELECT q.*, i.grade AS maxgrade, i.id AS instance".
" FROM {$CFG->prefix}quiz_questions q,".
" {$CFG->prefix}quiz_question_instances i".
" WHERE i.quiz = '$cmoptions->id' AND q.id = i.question".
" AND q.id IN ($questionlist)".
" AND q.qtype = '".ESSAY."'".
" ORDER BY q.name";
if (empty($attemptid)) {
$attemptsql = "quiz = $cmoptions->id and timefinish > 0 and userid IN ($userids)";
} else {
$attemptsql = "id = $attemptid";
}
if ($questions = get_records_sql($sql)) {
// get all the finished attempts by the users
if ($attempts = get_records_select('quiz_attempts', $attemptsql, 'userid, attempt')) {
foreach($questions as $question) {
// determine the number of ungraded attempts essays
foreach ($attempts as $attempt) {
// grab the state then check if it is graded
if (!$neweststate = get_record('quiz_newest_states', 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) {
error("Can not find newest states for attempt $attempt->uniqueid for question $question->id");
}
if (!$questionstate = get_record('quiz_essay_states', 'stateid', $neweststate->newest)) {
error('Could not find question state');
}
if (!$questionstate->graded) {
$ungradedcount++;
}
// keep track of users
$usercount[$attempt->userid] = 1;
}
}
}
}
return array($ungradedcount, count($usercount));
}
}
//// END OF CLASS ////

View file

@ -464,7 +464,8 @@ class quiz_default_questiontype {
'editquestion', get_string('edit'), 450, 550, get_string('edit'));
echo '</font>';
}
if ($question->maxgrade and $options->scores) {
if ($question->maxgrade and $options->scores and
!($question->qtype == ESSAY and !$state->last_graded->options->graded)) { // do not print for ungraded essays
echo '<div class="grade">';
echo get_string('marks', 'quiz').': ';
if ($cmoptions->optionflags & QUIZ_ADAPTIVE) {
@ -566,7 +567,20 @@ class quiz_default_questiontype {
responses (and penalties) */
if (!empty($question->maxgrade) && $options->scores) {
if (!('' === $state->last_graded->grade)) {
if (!('' === $state->last_graded->grade) and
($question->qtype == ESSAY and !$state->last_graded->options->graded)) {
// Special handling for ungraded essay questions
// get the word for teacher
if (isset($cmoptions->course) and $course = get_record('course', 'id', $cmoptions->course)) {
$teacher = $course->teacher;
} else {
$teacher = get_string('defaultcourseteacher');
}
echo '<div class="correctness notgraded">';
print_string('willbegradedby', 'quiz', $teacher);
echo '</div>';
} else if (!('' === $state->last_graded->grade)) {
// Display the grading details from the last graded state
$grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
$grade->max = $question->maxgrade;

View file

@ -180,10 +180,19 @@
$result->sumgrades = "0";
$result->grade = "0.0";
}
// if the student has ungraded essay(s), notify him/her of it
list($ungradedessays, $usercount) = $QUIZ_QTYPES[ESSAY]->get_ungraded_count($quiz, $attempt->userid, $attempt->id);
if ($ungradedessays) {
$ungradednotice = '<br /><strong>'.get_string('ungradednotice', 'quiz', $ungradedessays).'</strong>';
} else {
$ungradednotice = '';
}
$percentage = round(($attempt->sumgrades/$quiz->sumgrades)*100, 0);
$grade = round(($attempt->sumgrades/$quiz->sumgrades)*$quiz->grade, $CFG->quiz_decimalpoints);
$table->data[] = array("$strscore:", "$attempt->sumgrades/$quiz->sumgrades ($percentage %)");
$table->data[] = array("$strgrade:", $grade.get_string('outof', 'quiz').$quiz->grade);
$table->data[] = array("$strgrade:", $grade.get_string('outof', 'quiz').$quiz->grade.$ungradednotice);
}
if ($isteacher and $attempt->userid == $USER->id) {
// the teacher is at the end of a preview. Print button to start new preview

View file

@ -124,6 +124,19 @@
notify("<a href=\"report.php?mode=overview&amp;id=$cm->id\">$strviewallanswers ($usercount $strusers)</a>");
}
if ($users = get_course_students($course->id)) {
list($ungradedessays, $usercount) = $QUIZ_QTYPES[ESSAY]->get_ungraded_count($quiz, $users);
if ($ungradedessays) {
$a = new stdClass;
$a->ungradedessays = $ungradedessays;
$a->usercount = $usercount;
$a->students = $strusers;
notify("<a href=\"grading.php?quizid=$quiz->id\">".get_string('viewessaystograde', 'quiz', $a).'</a>');
}
}
echo '</td></tr></table>';
print_footer($course);
exit;
@ -169,6 +182,12 @@
/// Now print table with existing attempts
if ($numattempts) {
/// notify the student of ungraded essays
list($ungradedessays, $usercount) = $QUIZ_QTYPES[ESSAY]->get_ungraded_count($quiz);
if ($ungradedessays) {
notify(get_string('youhaveungradedessays', 'quiz', $ungradedessays));
}
/// prepare table header
if ($quiz->grade and $quiz->sumgrades) { // Grades used so have more columns in table
if ($quiz->grade <> $quiz->sumgrades) {