MDL-26788 - grading in lesson containing essays (head)

This commit is contained in:
Rossiani Wijaya 2011-04-29 18:20:19 +08:00
parent b8df9414bd
commit f672e3e920
2 changed files with 7 additions and 2 deletions

View File

@ -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) {

View File

@ -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)) {