From e0be8fd6a3b03c4090d7a3d89a137ccba6c2aaac Mon Sep 17 00:00:00 2001 From: Rossiani Wijaya Date: Fri, 29 Apr 2011 18:17:36 +0800 Subject: [PATCH] MDL-26788 - grading in lesson containing essays --- mod/lesson/essay.php | 4 +++- mod/lesson/locallib.php | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mod/lesson/essay.php b/mod/lesson/essay.php index 04d3fad54c7..981a833c987 100644 --- a/mod/lesson/essay.php +++ b/mod/lesson/essay.php @@ -76,6 +76,8 @@ switch ($mode) { } $attemptid = required_param('attemptid', PARAM_INT); + $score = optional_param('score', 0, PARAM_INT); + if (!$attempt = $DB->get_record('lesson_attempts', array('id' => $attemptid))) { print_error('cannotfindattempt', 'lesson'); } @@ -87,7 +89,7 @@ switch ($mode) { $essayinfo = unserialize($attempt->useranswer); $essayinfo->graded = 1; - $essayinfo->score = clean_param($form->score, PARAM_INT); + $essayinfo->score = $score; $essayinfo->response = clean_param($form->response, PARAM_RAW); $essayinfo->sent = 0; if (!$lesson->custom && $essayinfo->score == 1) { diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 17919300d04..b4fb01e7a15 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -318,7 +318,10 @@ function lesson_grade($lesson, $ntries, $userid = 0) { $attempt = end($attempts); // If essay question, handle it, otherwise add to score if ($page->requires_manual_grading()) { - $earned += $page->earned_score($answers, $attempt); + $useranswerobj = unserialize($attempt->useranswer); + if (isset($useranswerobj->score)) { + $earned += $useranswerobj->score; + } $nmanual++; $manualpoints += $answers[$attempt->answerid]->score; } else if (!empty($attempt->answerid)) {