Example #1
0
 public function process_comment(question_attempt_pending_step $pendingstep)
 {
     if ($pendingstep->has_behaviour_var('mark')) {
         throw new coding_exception('Information items cannot be graded.');
     }
     return parent::process_comment($pendingstep);
 }
 public function apply_attempt_state(question_attempt_step $step)
 {
     parent::apply_attempt_state($step);
     if ($this->question->is_complete_response($step->get_qt_data())) {
         $step->set_state(question_state::$complete);
     }
 }
Example #3
0
// Can only grade finished attempts.
if (!$attemptobj->is_finished()) {
    print_error('attemptclosed', 'quiz');
}
// Check login and permissions.
require_login($attemptobj->get_course(), false, $attemptobj->get_cm());
$attemptobj->require_capability('mod/quiz:grade');
// Log this action.
add_to_log($attemptobj->get_courseid(), 'quiz', 'manualgrade', 'comment.php?attempt=' . $attemptobj->get_attemptid() . '&slot=' . $slot, $attemptobj->get_quizid(), $attemptobj->get_cmid());
// Print the page header.
$PAGE->set_pagelayout('popup');
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($attemptobj->get_question_name($slot)));
// Process any data that was submitted.
if (data_submitted() && confirm_sesskey()) {
    if (optional_param('submit', false, PARAM_BOOL) && question_behaviour::is_manual_grade_in_range($attemptobj->get_uniqueid(), $slot)) {
        $transaction = $DB->start_delegated_transaction();
        $attemptobj->process_submitted_actions(time());
        $transaction->allow_commit();
        echo $OUTPUT->notification(get_string('changessaved'), 'notifysuccess');
        close_window(2, true);
        die;
    }
}
// Print the comment form.
echo '<form method="post" class="mform" id="manualgradingform" action="' . $CFG->wwwroot . '/mod/quiz/comment.php">';
echo $attemptobj->render_question_for_commenting($slot);
?>
<div>
    <input type="hidden" name="attempt" value="<?php 
echo $attemptobj->get_attemptid();
Example #4
0
 /**
  * @param string $behaviour the name of a behaviour.
  * @return array of {@link question_display_options} field names, that are
  * not relevant to this behaviour before a 'finish' action.
  */
 public static function get_behaviour_unused_display_options($behaviour) {
     self::load_behaviour_class($behaviour);
     $class = 'qbehaviour_' . $behaviour;
     if (!method_exists($class, 'get_unused_display_options')) {
         return question_behaviour::get_unused_display_options();
     }
     return call_user_func(array($class, 'get_unused_display_options'));
 }
Example #5
0
    protected function validate_submitted_marks() {

        $qubaids = optional_param('qubaids', null, PARAM_SEQUENCE);
        if (!$qubaids) {
            return false;
        }
        $qubaids = clean_param_array(explode(',', $qubaids), PARAM_INT);

        $slots = optional_param('slots', '', PARAM_SEQUENCE);
        if (!$slots) {
            $slots = array();
        } else {
            $slots = explode(',', $slots);
        }

        foreach ($qubaids as $qubaid) {
            foreach ($slots as $slot) {
                if (!question_behaviour::is_manual_grade_in_range($qubaid, $slot)) {
                    return false;
                }
            }
        }

        return true;
    }