Skip to content

Commit 23c861a

Browse files
author
Juan Ibarra - Open LMS
committed
INT-15833: Fix bug of keeping dates on discussions
1 parent 9c9084a commit 23c861a

File tree

6 files changed

+61
-13
lines changed

6 files changed

+61
-13
lines changed

classes/controller/edit_controller.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ public function update_post_action() {
223223
$parent = $DB->get_record('hsuforum_posts', array('id' => $post->parent), '*', MUST_EXIST);
224224
$privatereply = $parent->userid;
225225
}
226+
227+
// Check if discussion has a set timestart and timeend.
228+
$timestart = $timestart === 0 ? $discussion->timestart : 0;
229+
$timeend = $timeend === 0 ? $discussion->timeend : 0;
230+
226231
return $this->postservice->handle_update_post($course, $cm, $forum, $context, $discussion, $post, $files, array(
227232
'subject' => $subject,
228233
'name' => $subject,
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@mod @mod_hsuforum
2+
Feature: In Open Forums users can change start and end date and the changes remain
3+
As a teacher
4+
I need to set a discussion time start and time end and it should be maintained through time
5+
6+
Background:
7+
Given the following "users" exist:
8+
| username | firstname | lastname | email |
9+
| teacher1 | Teacher | 1 | teacher1@example.com |
10+
And the following "courses" exist:
11+
| fullname | shortname | category |
12+
| Course 1 | C1 | 0 |
13+
And the following "course enrolments" exist:
14+
| user | course | role |
15+
| teacher1 | C1 | editingteacher |
16+
And I log in as "teacher1"
17+
And the following config values are set as admin:
18+
| enabletimedposts | 1 | hsuforum |
19+
And I am on "Course 1" course homepage with editing mode on
20+
And I add a "Open Forum" to section "1" and I fill the form with:
21+
| Forum name | Test forum name |
22+
| Description | Test forum description |
23+
And I add a new discussion to "Test forum name" Open Forum with:
24+
| Subject | Discussion 1 |
25+
| Message | Discussion contents 1, first message |
26+
| timestart[enabled] | 1 |
27+
| timestart[year] | 2014 |
28+
| timeend[enabled] | 1 |
29+
| timeend[year] | 2020 |
30+
And I log out
31+
32+
@javascript
33+
Scenario: Teacher should see the start and end date after editing post
34+
Given I log in as "teacher1"
35+
And I am on "Course 1" course homepage
36+
And I follow "Test forum name"
37+
And I follow "Discussion 1"
38+
And I click on "//div[contains(@class, 'hsuforum-thread-tools')]//a[contains(text(), 'Edit')]" "xpath_element"
39+
And I click on "//form[contains(@class, 'hsuforum-discussion')]//button[contains(@type, 'submit')]" "xpath_element"
40+
And I click on "//div[contains(@class, 'hsuforum-thread-tools')]//a[contains(text(), 'Edit')]" "xpath_element"
41+
And I follow "Use advanced editor and additional options"
42+
Then "input[name='timestart[enabled]'][checked]" "css_element" should exist
43+
And "input[name='timeend[enabled]'][checked]" "css_element" should exist
44+
And the following fields match these values:
45+
| timestart[year] | 2014 |
46+
| timeend[year] | 2020 |
47+
Then I set the following fields to these values:
48+
| timestart[enabled] | 0 |
49+
Then I press "Save changes"
50+
Then I click on "//div[contains(@class, 'hsuforum-thread-tools')]//a[contains(text(), 'Edit')]" "xpath_element"
51+
And I follow "Use advanced editor and additional options"
52+
Then "input[name='timestart[enabled]'][checked]" "css_element" should not exist
53+
And "input[name='timeend[enabled]'][checked]" "css_element" should exist
54+
And the following fields match these values:
55+
| timeend[year] | 2020 |

yui/build/moodle-mod_hsuforum-article/moodle-mod_hsuforum-article-debug.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,9 @@ Y.extend(FORM, Y.Base,
918918
setDateFields: function(startuts, enduts) {
919919
if (startuts == 0) {
920920
this.resetDateField('start');
921-
} else {
922-
this.setDateField('start', true, startuts);
923921
}
924922
if (enduts == 0) {
925923
this.resetDateField('end');
926-
} else {
927-
this.setDateField('end', true, enduts);
928924
}
929925
},
930926

0 commit comments

Comments
 (0)