forked from jobe-appstester/qtype_appstester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion.php
executable file
·81 lines (66 loc) · 2.49 KB
/
question.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
use qtype_appstester\checker_definitions\checker_definitions_registry;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/question/behaviour/appstester/behaviour.php');
class qtype_appstester_question extends question_graded_automatically {
/**
* @param array $response
* @return array
*/
public function grade_response(array $response): array {
$fraction = 0;
$state = question_state::$invalid;
return array($fraction, $state);
}
public function get_expected_data(): array {
$checker_system_name = $this->checker_system_name;
$checker = checker_definitions_registry::get_by_system_name($checker_system_name);
$expected_data = array();
foreach ($checker->get_student_parameters() as $student_parameter) {
$expected_data[$student_parameter->get_parameter_name()] = $student_parameter->get_param_type();
}
return $expected_data;
}
public function get_correct_response() {
}
/**
* @param array $response
* @return bool
*/
public function is_complete_response(array $response): bool {
if (!empty($response['submission'])) {
if ($files = $response['submission']->get_files()) {
return true;
}
}
\core\notification::warning(get_string('no_files_submitted', 'qtype_appstester'));
return false;
}
/**
* @param array $prevresponse
* @param array $newresponse
* @return false
*/
public function is_same_response(array $prevresponse, array $newresponse): bool {
$responses_are_identical = question_utils::arrays_same_at_key_missing_is_blank(
$prevresponse, $newresponse, 'submission');
if ($responses_are_identical) {
\core\notification::warning(get_string('same_response_submitted', 'qtype_appstester'));
}
return $responses_are_identical;
}
public function summarise_response(array $response): string {
return get_string('summarise_response', 'qtype_appstester');
}
public function get_validation_error(array $response) {
}
/**
* @throws coding_exception
*/
public function make_behaviour(question_attempt $qa, $preferredbehaviour): qbehaviour_appstester {
return new qbehaviour_appstester($qa, $preferredbehaviour);
}
public function check_file_access($qa, $options, $component, $filearea, $args, $forcedownload): bool {
return true;
}
}