Skip to content

Commit baa6e32

Browse files
committed
WIP: tests for limitedanswer
1 parent bc2d091 commit baa6e32

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

mod_form.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ public function definition() {
261261
$mform->setType('la_answersfound', PARAM_BOOL);
262262
$mform->addElement('date_time_selector', 'la_starttime', get_string('la_starttime', 'moodleoverflow'),
263263
['optional' => true]);
264-
//$mform->setType('la_starttime', PARAM_INT);
264+
265265
$mform->addHelpButton('la_starttime', 'la_starttime', 'moodleoverflow');
266266
$mform->disabledIf('la_starttime', 'la_answersfound', 'eq', true);
267267

268268
$mform->addElement('date_time_selector', 'la_endtime', get_string('la_endtime', 'moodleoverflow'),
269269
['optional' => true]);
270-
//$mform->setType('la_endtime', PARAM_INT);
270+
271271
$mform->addHelpButton('la_endtime', 'la_endtime', 'moodleoverflow');
272272

273273
$mform->addElement('hidden', 'la_error');
@@ -294,6 +294,13 @@ public function data_postprocessing($data) {
294294
}
295295
}
296296

297+
/**
298+
* Validates set data in mod_form
299+
* @param $data
300+
* @param $files
301+
* @return array
302+
* @throws coding_exception
303+
*/
297304
public function validation($data, $files) {
298305
$errors = parent::validation($data, $files);
299306

@@ -307,7 +314,7 @@ public function validation($data, $files) {
307314
}
308315
if ($isendtime) {
309316
if ($data['la_endtime'] < $currenttime) {
310-
$errors['la_endtime'] = get_string('la_endtime_ruleerror', 'moodleoverflow');
317+
$errors['la_endtime'] = get_string('la_endtime_ruleerror', 'moodleoverflow');
311318
}
312319

313320
if ($isstarttime && $data['la_endtime'] <= $data['la_starttime']) {

tests/behat/limitedanswer.feature

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,16 @@
4444
| Message | This is the answer message |
4545
And I press "Post to forum"
4646
Then I should see "This is the answer message"
47-
And I should see "This is the question message"
47+
And I should see "This is the question message"
48+
49+
Scenario: Setting up the limited answer mode, the times need to be in order and in the future.
50+
Given the following "activities" exist:
51+
| activity | name | intro | course | idnumber |
52+
| moodleoverflow | Test Moodleoverflow | Test moodleoverflow description | C1 | 1 |
53+
And I log in as "teacher1"
54+
And I am on "Course 1" course homepage
55+
And I follow "Test Moodleoverflow"
56+
And I follow "Settings"
57+
And I follow "Limited Answer Mode"
58+
And
59+
And I pause

0 commit comments

Comments
 (0)