Línea 42... |
Línea 42... |
42 |
*
|
42 |
*
|
43 |
* @package quiz_overview
|
43 |
* @package quiz_overview
|
44 |
* @copyright 2014 The Open University
|
44 |
* @copyright 2014 The Open University
|
45 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
45 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
46 |
*/
|
46 |
*/
|
47 |
class report_test extends \advanced_testcase {
|
47 |
final class report_test extends \advanced_testcase {
|
48 |
use \quiz_question_helper_test_trait;
|
48 |
use \quiz_question_helper_test_trait;
|
Línea 49... |
Línea 49... |
49 |
|
49 |
|
50 |
/**
|
50 |
/**
|
51 |
* Data provider for test_report_sql.
|
51 |
* Data provider for test_report_sql.
|
52 |
*
|
52 |
*
|
53 |
* @return array the data for the test sub-cases.
|
53 |
* @return array the data for the test sub-cases.
|
54 |
*/
|
54 |
*/
|
55 |
public function report_sql_cases(): array {
|
55 |
public static function report_sql_cases(): array {
|
56 |
return [[null], ['csv']]; // Only need to test on or off, not all download types.
|
56 |
return [[null], ['csv']]; // Only need to test on or off, not all download types.
|
Línea 57... |
Línea 57... |
57 |
}
|
57 |
}
|
58 |
|
58 |
|
Línea 107... |
Línea 107... |
107 |
$attempts = [
|
107 |
$attempts = [
|
108 |
[$quiz, $student1, 1, 0.0, quiz_attempt::FINISHED],
|
108 |
[$quiz, $student1, 1, 0.0, quiz_attempt::FINISHED],
|
109 |
[$quiz, $student1, 2, 5.0, quiz_attempt::FINISHED],
|
109 |
[$quiz, $student1, 2, 5.0, quiz_attempt::FINISHED],
|
110 |
[$quiz, $student1, 3, 8.0, quiz_attempt::FINISHED],
|
110 |
[$quiz, $student1, 3, 8.0, quiz_attempt::FINISHED],
|
111 |
[$quiz, $student1, 4, null, quiz_attempt::ABANDONED],
|
111 |
[$quiz, $student1, 4, null, quiz_attempt::ABANDONED],
|
- |
|
112 |
[$quiz, $student1, 5, null, quiz_attempt::SUBMITTED],
|
112 |
[$quiz, $student1, 5, null, quiz_attempt::IN_PROGRESS],
|
113 |
[$quiz, $student1, 6, null, quiz_attempt::IN_PROGRESS],
|
113 |
[$quiz, $student2, 1, null, quiz_attempt::ABANDONED],
|
114 |
[$quiz, $student2, 1, null, quiz_attempt::ABANDONED],
|
114 |
[$quiz, $student2, 2, null, quiz_attempt::ABANDONED],
|
115 |
[$quiz, $student2, 2, null, quiz_attempt::ABANDONED],
|
115 |
[$quiz, $student2, 3, 7.0, quiz_attempt::FINISHED],
|
116 |
[$quiz, $student2, 3, 7.0, quiz_attempt::FINISHED],
|
116 |
[$quiz, $student2, 4, null, quiz_attempt::ABANDONED],
|
117 |
[$quiz, $student2, 4, null, quiz_attempt::ABANDONED],
|
117 |
[$quiz, $student2, 5, null, quiz_attempt::ABANDONED],
|
118 |
[$quiz, $student2, 5, null, quiz_attempt::ABANDONED],
|
Línea 141... |
Línea 142... |
141 |
|
142 |
|
142 |
case quiz_attempt::IN_PROGRESS:
|
143 |
case quiz_attempt::IN_PROGRESS:
|
143 |
// Do nothing.
|
144 |
// Do nothing.
|
Línea -... |
Línea 145... |
- |
|
145 |
break;
|
- |
|
146 |
|
- |
|
147 |
case quiz_attempt::SUBMITTED:
|
- |
|
148 |
// Save answers but do not grade attempt.
|
- |
|
149 |
$attemptobj->process_submitted_actions(
|
- |
|
150 |
$timestart + 300,
|
- |
|
151 |
false,
|
- |
|
152 |
[
|
- |
|
153 |
1 => ['answer' => 'My essay by ' . $student->firstname, 'answerformat' => FORMAT_PLAIN],
|
- |
|
154 |
]
|
- |
|
155 |
);
|
- |
|
156 |
$attemptobj->process_submit($timestart + 600, false);
|
144 |
break;
|
157 |
break;
|
145 |
|
158 |
|
146 |
case quiz_attempt::FINISHED:
|
159 |
case quiz_attempt::FINISHED:
|
- |
|
160 |
// Save answer and finish attempt.
|
- |
|
161 |
$attemptobj->process_submitted_actions(
|
- |
|
162 |
$timestart + 300,
|
147 |
// Save answer and finish attempt.
|
163 |
false,
|
- |
|
164 |
[
|
- |
|
165 |
1 => ['answer' => 'My essay by ' . $student->firstname, 'answerformat' => FORMAT_PLAIN],
|
148 |
$attemptobj->process_submitted_actions($timestart + 300, false, [
|
166 |
]
|
- |
|
167 |
);
|
Línea 149... |
Línea 168... |
149 |
1 => ['answer' => 'My essay by ' . $student->firstname, 'answerformat' => FORMAT_PLAIN]]);
|
168 |
$attemptobj->process_submit($timestart + 600, false);
|
150 |
$attemptobj->process_finish($timestart + 600, false);
|
169 |
$attemptobj->process_grade_submission($timestart + 600);
|
151 |
|
170 |
|
152 |
// Manually grade it.
|
171 |
// Manually grade it.
|
Línea 205... |
Línea 224... |
205 |
// The array key is {student id}#{attempt number}.
|
224 |
// The array key is {student id}#{attempt number}.
|
206 |
$this->assertEquals(4, count($table->rawdata));
|
225 |
$this->assertEquals(4, count($table->rawdata));
|
207 |
$this->assertArrayHasKey($student1->id . '#3', $table->rawdata);
|
226 |
$this->assertArrayHasKey($student1->id . '#3', $table->rawdata);
|
208 |
$this->assertEquals(1, $table->rawdata[$student1->id . '#3']->gradedattempt);
|
227 |
$this->assertEquals(1, $table->rawdata[$student1->id . '#3']->gradedattempt);
|
209 |
$this->assertArrayHasKey($student1->id . '#3', $table->rawdata);
|
228 |
$this->assertArrayHasKey($student1->id . '#3', $table->rawdata);
|
210 |
$this->assertEquals(0, $table->rawdata[$student1->id . '#5']->gradedattempt);
|
229 |
$this->assertEquals(0, $table->rawdata[$student1->id . '#6']->gradedattempt);
|
211 |
$this->assertArrayHasKey($student2->id . '#3', $table->rawdata);
|
230 |
$this->assertArrayHasKey($student2->id . '#3', $table->rawdata);
|
212 |
$this->assertEquals(1, $table->rawdata[$student2->id . '#3']->gradedattempt);
|
231 |
$this->assertEquals(1, $table->rawdata[$student2->id . '#3']->gradedattempt);
|
213 |
$this->assertArrayHasKey($student3->id . '#0', $table->rawdata);
|
232 |
$this->assertArrayHasKey($student3->id . '#0', $table->rawdata);
|
214 |
$this->assertEquals(0, $table->rawdata[$student3->id . '#0']->gradedattempt);
|
233 |
$this->assertEquals(0, $table->rawdata[$student3->id . '#0']->gradedattempt);
|
Línea 243... |
Línea 262... |
243 |
|
262 |
|
244 |
/**
|
263 |
/**
|
245 |
* Bands provider.
|
264 |
* Bands provider.
|
246 |
* @return array
|
265 |
* @return array
|
247 |
*/
|
266 |
*/
|
248 |
public function get_bands_count_and_width_provider(): array {
|
267 |
public static function get_bands_count_and_width_provider(): array {
|
249 |
return [
|
268 |
return [
|
250 |
[10, [20, .5]],
|
269 |
[10, [20, .5]],
|
251 |
[20, [20, 1]],
|
270 |
[20, [20, 1]],
|
252 |
[30, [15, 2]],
|
271 |
[30, [15, 2]],
|
Línea 359... |
Línea 378... |
359 |
// Attempt the quiz, submitting response 'toad'.
|
378 |
// Attempt the quiz, submitting response 'toad'.
|
360 |
$quizobj = quiz_settings::create($quiz->id);
|
379 |
$quizobj = quiz_settings::create($quiz->id);
|
361 |
$attempt = quiz_prepare_and_start_new_attempt($quizobj, 1, null);
|
380 |
$attempt = quiz_prepare_and_start_new_attempt($quizobj, 1, null);
|
362 |
$attemptobj = quiz_attempt::create($attempt->id);
|
381 |
$attemptobj = quiz_attempt::create($attempt->id);
|
363 |
$attemptobj->process_submitted_actions(time(), false, [1 => ['answer' => 'toad']]);
|
382 |
$attemptobj->process_submitted_actions(time(), false, [1 => ['answer' => 'toad']]);
|
364 |
$attemptobj->process_finish(time(), false);
|
383 |
$attemptobj->process_submit(time(), false);
|
- |
|
384 |
$attemptobj->process_grade_submission(time());
|
Línea 365... |
Línea 385... |
365 |
|
385 |
|
366 |
// We should be using 'always latest' version, which is currently v2, so should be right.
|
386 |
// We should be using 'always latest' version, which is currently v2, so should be right.
|
Línea 367... |
Línea 387... |
367 |
$this->assertEquals(10, $attemptobj->get_question_usage()->get_total_mark());
|
387 |
$this->assertEquals(10, $attemptobj->get_question_usage()->get_total_mark());
|