Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions classes/post/post_control.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,6 @@ private function build_prepost_reply(int $replypostid): void {
throw new moodle_exception('activityiscurrentlyhidden');
}

// Append 'RE: ' to the discussions subject.
$strre = get_string('re', 'moodleoverflow');
if (!(str_starts_with($this->prepost->subject, $strre))) {
$this->prepost->subject = $strre . ' ' . $this->prepost->subject;
}

// Unset where the user is coming from.
// Allows to calculate the correct return url later.
unset($SESSION->fromdiscussion);
Expand Down
15 changes: 9 additions & 6 deletions classes/post_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ public function definition() {
// Fill in the data depending on page params later using set_data.
$modform->addElement('header', 'general', '');

// The subject.
$modform->addElement('text', 'subject', get_string('subject', 'moodleoverflow'), 'size="48"');
$modform->setType('subject', PARAM_TEXT);
$modform->addRule('subject', get_string('required'), 'required', null, 'client');
$modform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
// Show the subject only when this is a new post.
if (empty($post->parentid)) {
$modform->addElement('text', 'subject', get_string('subject', 'moodleoverflow'), 'size="48"');
$modform->setType('subject', PARAM_TEXT);
$modform->addRule('subject', get_string('required'), 'required', null, 'client');
$modform->addRule('subject', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
}

// The message.
$modform->addElement(
Expand Down Expand Up @@ -125,7 +127,8 @@ public function validation($data, $files) {
if (empty($data['message']['text'])) {
$errors['message'] = get_string('erroremptymessage', 'moodleoverflow');
}
if (empty($data['subject'])) {
// Subject must not be empty when creating a new discussion only.
if (empty($data['subject']) && empty($this->_customdata['post']->parentid)) {
$errors['subject'] = get_string('erroremptysubject', 'moodleoverflow');
}

Expand Down
1 change: 0 additions & 1 deletion tests/behat/delete_file.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Feature: Delete attachments
And I follow "Forum post 1"
And I click on "Answer" "link"
And I set the following fields to these values:
| Subject | A reply post |
| Message | This is the message of the answer post |
And I upload "mod/moodleoverflow/tests/fixtures/NH.jpg" file to "Attachment" filemanager
And I press "Post to forum"
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/delete_post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Feature: Teachers and students can delete posts
And I log out
And I navigate as "student1" to "Course 1" "Moodleoverflow 1" "Discussion 1"
And I try to delete moodleoverflow post "Answer from student"
Then I should see "You are not allowed to delete this post because it already has replies."
Then I should see "You are not allowed to delete this post because it already has replies."
1 change: 0 additions & 1 deletion tests/behat/limitedanswer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Feature: Moodleoverflows can start in a limited answer mode, where answers from
And I click on "Answer" "text"
Then I should see "Your reply"
And I set the following fields to these values:
| Subject | Re: Forum post 1 |
| Message | This is the answer message |
And I press "Post to forum"
Then I should "" see the elements:
Expand Down
4 changes: 3 additions & 1 deletion tests/behat/reply_post.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ Feature: Replying to posts in a moodleoverflow
When I click on "#moodleoverflow_showpost" "css_element"
Then I should see "Message from teacher"
When I click on "#moodleoverflow_showpost" "css_element"
Then I should not see "Message from teacher"
Then I should not see "Message from teacher"
And I should not see "Subject"
And I should see "Message"
1 change: 0 additions & 1 deletion tests/behat/track_read_posts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ Feature: A teacher can set one of 3 possible options for tracking read moodleove
When I click on "Mark all posts as read" "link"
And I am on "Course 1" course homepage
Then I should not see "2 unread post"

Loading