コード例 #1
0
 function get_correct_responses(&$question, &$state)
 {
     wrsqz_swap('match', 'wmatprom', $question, $state);
     $response = parent::get_correct_responses($question, $state);
     return wrsqz_get_correct_responses('match', 'wmatprom', $response, $question, $state);
 }
コード例 #2
0
/**
* This is a copy & paste of original shortanswer/questiontype.php print_question_grading_details() but 
* filters correct answers before printing.
*/
function wrsqz_print_question_grading_details($questionType, $dbType, &$question, &$state, $cmoptions, $options){
	if($questionType=='shortanswer'){
	    global $QTYPES ;
        // MDL-7496 show correct answer after "Incorrect"
        $correctanswer = '';
		
        if ($correctanswers =  wrsqz_get_correct_responses('shortanswer', 'wshanprom', null, $question, $state, 'W')) {
            if ($options->readonly && $options->correct_responses) {
                $delimiter = '';
                if ($correctanswers) {
                    foreach ($correctanswers as $ca) {
                        $correctanswer .= $delimiter.$ca;
                        $delimiter = ', ';
                    }
                }
            }
        }
        if (QUESTION_EVENTDUPLICATE == $state->event) {
            echo ' ';
            print_string('duplicateresponse', 'quiz');
        }
        if (!empty($question->maxgrade) && $options->scores) {
            if (question_state_is_graded($state->last_graded)) {
                // Display the grading details from the last graded state
                $grade = new stdClass;
                $grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
                $grade->max = $question->maxgrade;
                $grade->raw = round($state->last_graded->raw_grade, $cmoptions->decimalpoints);

                // let student know wether the answer was correct
                echo '<div class="correctness ';
                if ($state->last_graded->raw_grade >= $question->maxgrade/1.01) { // We divide by 1.01 so that rounding errors dont matter.
                    echo ' correct">';
                    print_string('correct', 'quiz');
                } else if ($state->last_graded->raw_grade > 0) {
                    echo ' partiallycorrect">';
                    print_string('partiallycorrect', 'quiz');
                    // MDL-7496
                    if ($correctanswer) {
                        echo ('<div class="correctness">');
                        $format_options = new StdClass();
                        $format_options->filter=true;
                        $format_options->smiley=false;
                        $format_options->para=false;
                        $format_options->newlines=false;
                        $filtered_correct_answer = format_text($correctanswer, $question->questiontextformat, $format_options, $cmoptions->course);
                        print_string('correctansweris', 'quiz', $filtered_correct_answer);
                        echo ('</div>');
                    }
                } else {
                    echo ' incorrect">';
                    // MDL-7496
                    print_string('incorrect', 'quiz');
                    if ($correctanswer) {
                        echo ('<div class="correctness">');
                        $format_options = new StdClass();
                        $format_options->filter=true;
                        $format_options->smiley=false;
                        $format_options->para=false;
                        $format_options->newlines=false;
                        $filtered_correct_answer = format_text($correctanswer, FORMAT_MOODLE, $format_options, $cmoptions->course);
                        print_string('correctansweris', 'quiz', $filtered_correct_answer);
                        echo ('</div>');
                    }
                }
                echo '</div>';

                echo '<div class="gradingdetails">';
                // print grade for this submission
                print_string('gradingdetails', 'quiz', $grade);
                if ($cmoptions->penaltyscheme) {
                    // print details of grade adjustment due to penalties
                    if ($state->last_graded->raw_grade > $state->last_graded->grade){
                        echo ' ';
                        print_string('gradingdetailsadjustment', 'quiz', $grade);
                    }
                    // print info about new penalty
                    // penalty is relevant only if the answer is not correct and further attempts are possible
                    if (($state->last_graded->raw_grade < $question->maxgrade) and (QUESTION_EVENTCLOSEANDGRADE != $state->event)) {
                        if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) {
                            // A penalty was applied so display it
                            echo ' ';
                            print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty);
                        } else {
                            /* No penalty was applied even though the answer was
                            not correct (eg. a syntax error) so tell the student
                            that they were not penalised for the attempt */
                            echo ' ';
                            print_string('gradingdetailszeropenalty', 'quiz');
                        }
                    }
                }
                echo '</div>';
            }
        }
	}
}
コード例 #3
0
	function get_correct_responses(&$question, &$state) {
		wrsqz_swap('truefalse', 'wtrflsprom', $question, $state);
		
		$response = parent::get_correct_responses($question, $state);
		return wrsqz_get_correct_responses('truefalse', 'wtrflsprom', $response, $question, $state);
	}
コード例 #4
0
 function get_correct_responses(&$question, &$state)
 {
     wrsqz_swap('shortanswer', 'wshanprom', $question, $state);
     return wrsqz_get_correct_responses('shortanswer', 'wshanprom', null, $question, $state);
 }