Línea 46... |
Línea 46... |
46 |
}
|
46 |
}
|
Línea 47... |
Línea 47... |
47 |
|
47 |
|
48 |
/**
|
48 |
/**
|
49 |
* Test start_submission if assignment doesn't exist matching id.
|
49 |
* Test start_submission if assignment doesn't exist matching id.
|
50 |
*/
|
50 |
*/
|
51 |
public function test_start_submission_with_invalid_assign_id() {
|
51 |
public function test_start_submission_with_invalid_assign_id(): void {
|
52 |
$this->expectException(\dml_exception::class);
|
52 |
$this->expectException(\dml_exception::class);
|
53 |
start_submission::execute(123);
|
53 |
start_submission::execute(123);
|
Línea 54... |
Línea 54... |
54 |
}
|
54 |
}
|
55 |
|
55 |
|
56 |
/**
|
56 |
/**
|
57 |
* Test start_submission if user is not able to access activity or course.
|
57 |
* Test start_submission if user is not able to access activity or course.
|
58 |
*/
|
58 |
*/
|
59 |
public function test_start_submission_when_user_has_no_capability_to_view_assignment() {
|
59 |
public function test_start_submission_when_user_has_no_capability_to_view_assignment(): void {
|
60 |
$user = $this->getDataGenerator()->create_user();
|
60 |
$user = $this->getDataGenerator()->create_user();
|
61 |
$this->setUser($user);
|
61 |
$this->setUser($user);
|
Línea 67... |
Línea 67... |
67 |
}
|
67 |
}
|
Línea 68... |
Línea 68... |
68 |
|
68 |
|
69 |
/**
|
69 |
/**
|
70 |
* Test start_submission if assignment cut off date has elapsed.
|
70 |
* Test start_submission if assignment cut off date has elapsed.
|
71 |
*/
|
71 |
*/
|
72 |
public function test_start_submission_when_assignment_past_due_date() {
|
72 |
public function test_start_submission_when_assignment_past_due_date(): void {
|
73 |
$fiveminago = time() - 300;
|
73 |
$fiveminago = time() - 300;
|
74 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
74 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
75 |
false, ['cutoffdate' => $fiveminago]);
|
75 |
false, ['cutoffdate' => $fiveminago]);
|
76 |
$result = start_submission::execute($instance->id);
|
76 |
$result = start_submission::execute($instance->id);
|
Línea 85... |
Línea 85... |
85 |
}
|
85 |
}
|
Línea 86... |
Línea 86... |
86 |
|
86 |
|
87 |
/**
|
87 |
/**
|
88 |
* Test start_submission if time limit is disabled.
|
88 |
* Test start_submission if time limit is disabled.
|
89 |
*/
|
89 |
*/
|
90 |
public function test_start_submission_when_time_limit_disabled() {
|
90 |
public function test_start_submission_when_time_limit_disabled(): void {
|
91 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status();
|
91 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status();
|
92 |
$result = start_submission::execute($instance->id);
|
92 |
$result = start_submission::execute($instance->id);
|
93 |
$filteredwarnings = array_filter($result['warnings'], function($warning) {
|
93 |
$filteredwarnings = array_filter($result['warnings'], function($warning) {
|
94 |
return $warning['warningcode'] === 'timelimitnotenabled';
|
94 |
return $warning['warningcode'] === 'timelimitnotenabled';
|
Línea 101... |
Línea 101... |
101 |
}
|
101 |
}
|
Línea 102... |
Línea 102... |
102 |
|
102 |
|
103 |
/**
|
103 |
/**
|
104 |
* Test start_submission if time limit is not set for assignment.
|
104 |
* Test start_submission if time limit is not set for assignment.
|
105 |
*/
|
105 |
*/
|
106 |
public function test_start_submission_when_time_limit_not_set() {
|
106 |
public function test_start_submission_when_time_limit_not_set(): void {
|
107 |
set_config('enabletimelimit', '1', 'assign');
|
107 |
set_config('enabletimelimit', '1', 'assign');
|
108 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status();
|
108 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status();
|
109 |
$result = start_submission::execute($instance->id);
|
109 |
$result = start_submission::execute($instance->id);
|
110 |
$filteredwarnings = array_filter($result['warnings'], function($warning) {
|
110 |
$filteredwarnings = array_filter($result['warnings'], function($warning) {
|
Línea 118... |
Línea 118... |
118 |
}
|
118 |
}
|
Línea 119... |
Línea 119... |
119 |
|
119 |
|
120 |
/**
|
120 |
/**
|
121 |
* Test start_submission if user already has open submission.
|
121 |
* Test start_submission if user already has open submission.
|
122 |
*/
|
122 |
*/
|
123 |
public function test_start_submission_when_submission_already_open() {
|
123 |
public function test_start_submission_when_submission_already_open(): void {
|
124 |
global $DB;
|
124 |
global $DB;
|
125 |
set_config('enabletimelimit', '1', 'assign');
|
125 |
set_config('enabletimelimit', '1', 'assign');
|
126 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
126 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
127 |
false, ['timelimit' => 300]);
|
127 |
false, ['timelimit' => 300]);
|
Línea 140... |
Línea 140... |
140 |
}
|
140 |
}
|
Línea 141... |
Línea 141... |
141 |
|
141 |
|
142 |
/**
|
142 |
/**
|
143 |
* Test start_submission if user has already submitted with no additional attempts available.
|
143 |
* Test start_submission if user has already submitted with no additional attempts available.
|
144 |
*/
|
144 |
*/
|
145 |
public function test_start_submission_with_no_attempts_available() {
|
145 |
public function test_start_submission_with_no_attempts_available(): void {
|
146 |
global $DB;
|
146 |
global $DB;
|
147 |
set_config('enabletimelimit', '1', 'assign');
|
147 |
set_config('enabletimelimit', '1', 'assign');
|
148 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
148 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
149 |
false, ['timelimit' => 300]);
|
149 |
false, ['timelimit' => 300]);
|
Línea 162... |
Línea 162... |
162 |
}
|
162 |
}
|
Línea 163... |
Línea 163... |
163 |
|
163 |
|
164 |
/**
|
164 |
/**
|
165 |
* Test start_submission if user has no open submissions.
|
165 |
* Test start_submission if user has no open submissions.
|
166 |
*/
|
166 |
*/
|
167 |
public function test_start_submission_with_new_submission() {
|
167 |
public function test_start_submission_with_new_submission(): void {
|
168 |
global $DB;
|
168 |
global $DB;
|
169 |
set_config('enabletimelimit', '1', 'assign');
|
169 |
set_config('enabletimelimit', '1', 'assign');
|
170 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
170 |
list($assign, $instance, $student1, $student2, $teacher, $g1, $g2) = $this->create_submission_for_testing_status(
|
171 |
false, ['timelimit' => 300]);
|
171 |
false, ['timelimit' => 300]);
|