forked from tuttorsOfTheTUBerlin/javaunittest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
questiontype.php
107 lines (100 loc) · 3.87 KB
/
questiontype.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* The question type class for this question type.
*
* @package qtype
* @subpackage javaunittest
* @author Gergely Bertalan, [email protected]
* @reference sojunit 2008, Süreç Özcan, [email protected]
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined ( 'MOODLE_INTERNAL' ) || die ();
require_once ($CFG->libdir . '/questionlib.php');
/**
* The javaunittest question type.
*
* @copyright 2005 Mark Nielsen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class qtype_javaunittest extends question_type {
/**
* Whether this question type can perform a frequency analysis of student responses.
* If this method returns true, you must implement the get_possible_responses method, and the question_definition
* class must implement the classify_response method.
*
* @return bool whether this report can analyse all the student responses for things like the quiz statistics
* report.
*/
public function can_analyse_responses() {
return false;
}
/**
* If your question type has a table that extends the question table, and you want the base class to automatically
* save, backup and restore the extra fields, override this method to return an array wherer the first element is
* the table name, and the subsequent entries are the column names (apart from id and questionid).
*
* @return mixed array as above, or null to tell the base class to do nothing.
*/
public function extra_question_fields() {
return array (
'qtype_javaunittest_options',
'responsefieldlines',
'givencode',
'testclassname',
'junitcode',
'solution',
'signature',
'feedbacklevel_studentcompiler',
'feedbacklevel_studentsignature',
'feedbacklevel_junitcompiler',
'feedbacklevel_times',
'feedbacklevel_counttests',
'feedbacklevel_junitheader',
'feedbacklevel_assertstring',
'feedbacklevel_assertexpected',
'feedbacklevel_assertactual',
'feedbacklevel_junitcomplete'
);
}
/**
* Whether or not to break down question stats and response analysis, for a question defined by $questiondata.
*
* @param object $questiondata The full question definition data.
* @return bool
*/
public function break_down_stats_and_response_analysis_by_variant($questiondata) {
return false;
}
/**
*
* @return array the different response formats that the question type supports. internal name => human-readable
* name.
*/
public function response_formats() {
return array (
'plain' => get_string ( 'formatplain', 'qtype_javaunittest' )
);
}
/**
*
* @return array the choices that should be offered for the input box size.
*/
public function response_sizes() {
$choices = array ();
for ( $lines = 5; $lines <= 40; $lines += 5 ) {
$choices[$lines] = get_string ( 'nlines', 'qtype_javaunittest', $lines );
}
return $choices;
}
public function move_files($questionid, $oldcontextid, $newcontextid) {
parent::move_files ( $questionid, $oldcontextid, $newcontextid );
$fs = get_file_storage ();
$fs->move_area_files_to_new_context ( $oldcontextid, $newcontextid, 'qtype_javaunittest', 'graderinfo',
$questionid );
}
protected function delete_files($questionid, $contextid) {
parent::delete_files ( $questionid, $contextid );
$fs = get_file_storage ();
$fs->delete_area_files ( $contextid, 'qtype_javaunittest', 'graderinfo', $questionid );
}
}