From: mark-nielsen $stranswer: $strcomment: ".
- '
+
+
+
+
+ print_question_submit_buttons($question, $state, $cmoptions, $options); ?>
+
+
+
+
+
+
+
+
+
+
+
$strcomment:
". - '$answer->feedback
", '', $formatoptions, $cmoptions->course); - } } - $this->print_question_submit_buttons($question, $state, $cmoptions, $options); } function grade_responses(&$question, &$state, $cmoptions) { - $state->raw_grade = 0; - // if a fraction is submitted, then we use it, otherwise the raw grade is 0 - if (isset($state->responses['fraction']) and $state->responses['fraction']) { - $state->raw_grade = $state->responses['fraction']; - $state->options->graded = 1; - // mark the state as graded - $state->event = ($state->event == QUESTION_EVENTCLOSE) ? QUESTION_EVENTCLOSEANDGRADE : QUESTION_EVENTGRADE; - } else { - $state->raw_grade = 0; - } - - // Make sure we don't assign negative or too high marks - $state->raw_grade = min(max((float) $state->raw_grade, - 0.0), 1.0) * $question->maxgrade; - $state->penalty = $question->penalty * $question->maxgrade; // should be no penalty for essays - - return true; - } - - function create_session_and_responses(&$question, &$state, $cmoptions, $attempt) { - $state->options->graded = 0; // our flag to indicated wheather an essay has been graded or not - $state->responses['fraction'] = 0; // this fraction is used for grading. The teacher sets it while grading - $state->responses['response'] = ''; // this is teacher response to the students essay - - return true; - } - - function restore_session_and_responses(&$question, &$state) { - if (!$options = get_record('question_essay_states', 'stateid', $state->id)) { - return false; - } - $state->options->graded = $options->graded; - $state->responses['fraction'] = $options->fraction; - $state->responses['response'] = $options->response; + // All grading takes place in Manual Grading - return true; - } - - function save_session_and_responses(&$question, &$state) { - $options->stateid = $state->id; + clean_param($state->responses[''], PARAM_CLEANHTML); - if (isset($state->options->graded)) { - $options->graded = $state->options->graded; - } else { - $options->graded = 0; - } - - if (isset($state->responses['fraction'])) { - $options->fraction = $state->responses['fraction']; - } - if (isset($state->responses['response'])) { - $options->response = addslashes( clean_param($state->responses['response'], PARAM_CLEANHTML) ); - } - if (isset($state->update)) { - if (!$options->id = get_field('question_essay_states', 'id', 'stateid', $state->id)) { - return false; - } - if (!update_record('question_essay_states', $options)) { - return false; - } - } else { - if (!insert_record('question_essay_states', $options)) { - return false; - } - } + $state->raw_grade = 0; + $state->penalty = 0; 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}question 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('question_sessions', 'attemptid', $attempt->uniqueid, 'questionid', $question->id)) { - error("Can not find newest states for attempt $attempt->uniqueid for question $question->id"); - } - if (!$questionstate = get_record('question_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)); - } - /// BACKUP FUNCTIONS //////////////////////////// /*