Skip to content

Moodle 4.4 compatibilty fixes for hsuforum #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions classes/output/big_search_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class big_search_form implements renderable, templatable {
public $user;
public $words;
public $tags;

public $forumid;
/** @var string The URL of the search form. */
public $actionurl;

Expand Down
20 changes: 13 additions & 7 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function standard_grading_coursemodule_elements() {
* Adds all the standard elements to a form to edit the settings for an activity module for Hsuforum.
*/
protected function standard_hsuforum_coursemodule_elements() {
global $COURSE, $CFG, $DB;
global $COURSE, $CFG, $DB, $OUTPUT;
$mform =& $this->_form;

if (!empty($CFG->core_outcome_enable)) {
Expand Down Expand Up @@ -370,6 +370,13 @@ protected function standard_hsuforum_coursemodule_elements() {
// So it uses a long name that will not conflict.
$mform->addElement('textarea', 'availabilityconditionsjson',
get_string('accessrestrictions', 'availability'));
// Availability loading indicator.
$loadingcontainer = $OUTPUT->container(
$OUTPUT->render_from_template('core/loading', []),
'd-flex justify-content-center py-5 icon-size-5',
'availabilityconditions-loading'
);
$mform->addElement('html', $loadingcontainer);
// The _cm variable may not be a proper cm_info, so get one from modinfo.
if ($this->_cm) {
$modinfo = get_fast_modinfo($COURSE);
Expand All @@ -395,7 +402,7 @@ protected function standard_hsuforum_coursemodule_elements() {

$trackingdefault = COMPLETION_TRACKING_NONE;
// If system and activity default is on, set it.
if ($CFG->completiondefault && $this->_features->defaultcompletion) {
if (!empty($CFG->completiondefault) && $this->_features->defaultcompletion) {
$hasrules = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_HAS_RULES, true);
$tracksviews = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, true);
if ($hasrules || $tracksviews) {
Expand All @@ -414,7 +421,7 @@ protected function standard_hsuforum_coursemodule_elements() {
// Automatic completion once you view it
$gotcompletionoptions = false;
if (plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, false)) {
$mform->addElement('checkbox', 'completionview', get_string('completionview', 'completion'),
$mform->addElement('checkbox', 'completionview', '',
get_string('completionview_desc', 'completion'));
$mform->hideIf('completionview', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
// Check by default if automatic completion tracking is set.
Expand All @@ -437,11 +444,10 @@ protected function standard_hsuforum_coursemodule_elements() {
$mform->addElement(
'checkbox',
'completionusegrade',
get_string('completionusegrade', 'completion'),
'',
get_string('completionusegrade_desc', 'completion')
);
$mform->hideIf('completionusegrade', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
$mform->addHelpButton('completionusegrade', 'completionusegrade', 'completion');

// The disabledIf logic differs between ratings and other grade items due to different field types.
if ($this->_features->rating) {
Expand Down Expand Up @@ -675,11 +681,11 @@ protected function add_hsuforum_rating_settings() {
$mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'rating'));
$mform->hideIf('ratingtime', $assessedfieldname, 'eq', 0);

$mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
$mform->addElement('date_time_selector', 'assesstimestart', get_string('fromdate'));
$mform->hideIf('assesstimestart', $assessedfieldname, 'eq', 0);
$mform->hideIf('assesstimestart', 'ratingtime');

$mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
$mform->addElement('date_time_selector', 'assesstimefinish', get_string('todate'));
$mform->hideIf('assesstimefinish', $assessedfieldname, 'eq', 0);
$mform->hideIf('assesstimefinish', 'ratingtime');
}
Expand Down
4 changes: 2 additions & 2 deletions post.php
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@
}

$formheading = '';
$hidehtml = '';
if (!empty($parent)) {
$formheading = get_string("yourreply", "hsuforum");
} else {
Expand All @@ -578,15 +579,13 @@
} else {
$formheading = get_string('yournewtopic', 'hsuforum');
// Hide duplicated hsuforum description when creating a new discussion topic, see INT-18928.
$hidehtml = '';
$hidehtml .= html_writer::start_tag('style', array('type' => 'text/css')) . "\n";
$hidehtml .= '
#page-mod-hsuforum-post .activity-description,
#page-mod-hsuforum-post [role="main"] h2 {
display: none;
};';
$hidehtml .= html_writer::end_tag('style') . "\n";
echo $hidehtml;
}
}

Expand Down Expand Up @@ -998,6 +997,7 @@
$renderer = $PAGE->get_renderer('mod_hsuforum');
$PAGE->requires->js_init_call('M.mod_hsuforum.init', null, false, $renderer->get_js_module());
echo $OUTPUT->header();
echo $hidehtml;
echo $OUTPUT->heading(format_string($forum->name), 2);

// Checkup.
Expand Down
3 changes: 1 addition & 2 deletions search.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@
$post->id
),
$post->messageformat,
$options,
$course->id),
$options),
0, '<fgw9sdpq4>', '</fgw9sdpq4>');

foreach ($searchterms as $searchterm) {
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/accessibility_pin_button.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: When creating a new discussion the unpin option should exist as a butto
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/add_forum.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Feature: Add Open Forum activities and discussions
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down Expand Up @@ -59,7 +59,7 @@ Feature: Add Open Forum activities and discussions
| teacher1 | C1 | editingteacher |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
11 changes: 7 additions & 4 deletions tests/behat/advanced_editor_pass_data_to_new_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ Feature: Users see their typed information in the advanced editor view when clic
| enabletimedposts | 1 | hsuforum |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
And I log out

@javascript
@editor_tiny
Scenario: User can continue writing after clicking "Use advanced editor"
When I log in as "teacher1"
And I am on "Course 1" course homepage
Expand All @@ -39,7 +40,7 @@ Feature: Users see their typed information in the advanced editor view when clic
And I should not see "Add your discussion"
And I should see "Your new discussion topic"
And I set the field with xpath "//*[@id='id_subject']" to "Test discussion 1 to be cancelled"
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test discussion 1 to be cancelled description"
And I set the field with xpath "//*[@id='id_message']" to "Test discussion 1 to be cancelled description"
And I press "Post to forum"
Then I log out
And I log in as "student1"
Expand All @@ -54,7 +55,7 @@ Feature: Users see their typed information in the advanced editor view when clic
And I wait until the page is ready
And I should see "Your reply"
And I set the field with xpath "//*[@id='id_subject']" to "Test reply subject"
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test reply message"
And I set the field with xpath "//*[@id='id_message']" to "Test reply message"
And I press "Post to forum"
And I log out
And I log in as "teacher1"
Expand All @@ -68,6 +69,8 @@ Feature: Users see their typed information in the advanced editor view when clic
And I set editable div with break line ".hsuforum-post.depth0 .hsuforum-textarea" "css_element" to "This is a reply \n This is a new line"
And I click on ".hsuforum-post.depth0 .hsuforum-use-advanced" "css_element"
And I wait until the page is ready
And I switch to the "Message" TinyMCE editor iframe
And ".text_to_html br" "css_element" should exist
And I switch to the main frame
And I should see "Your reply"
And I set the field with xpath "//*[@id='id_messageeditable']" to "This is a reply"
And I set the field with xpath "//*[@id='id_message']" to "This is a reply"
2 changes: 1 addition & 1 deletion tests/behat/edit_post_student.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Feature: Students can edit or delete their Open Forum posts within a set time li
And I log out
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/edit_post_teacher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Teachers can edit or delete any Open Forum post
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand Down
8 changes: 4 additions & 4 deletions tests/behat/forum_subscriptions_availability.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced forum lists all subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -39,7 +39,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced forum does not allow to edit the subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 2 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -55,7 +55,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: A forced and hidden forum lists only teachers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 2 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand All @@ -70,7 +70,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe

@javascript
Scenario: An automatic forum lists all subscribers
When I add a "Open Forum" to section "1" and I fill the form with:
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Forced Forum 1 |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/grading_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Feature: While creating a new activity, the grade settings should remain in the
| Grade category 1 | C1 |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down Expand Up @@ -68,5 +68,5 @@ Feature: While creating a new activity, the grade settings should remain in the
# Test forum name Open forum, should exist as a Grade category 1 which is the Grade category chosen before.
And I should see "Grade category 1"
And I should see "Test forum name"
And "//h4[contains(text(), 'Grade category 1')]" "xpath_element" should exist
And "//div[contains(text(), 'Grade category 1')]" "xpath_element" should exist
And "//a[contains(text(), 'Test forum name')]" "xpath_element" should exist
4 changes: 2 additions & 2 deletions tests/behat/hsuforum_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand All @@ -47,7 +47,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
Given I log in as "admin"
And I navigate to "Appearance > Manage tags" in site administration
And I follow "Default collection"
And I follow "Add standard tags"
And I press "Add standard tags"
And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3"
And I press "Continue"
And I log out
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/inline_edit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Teachers and students can add discussions inline
| enabletimedposts | 1 | hsuforum |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Forum type | Standard forum for general use |
| Description | Test forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/maintain_start_end_date.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: In Open Forums users can change start and end date and the changes rema
And the following config values are set as admin:
| enabletimedposts | 1 | hsuforum |
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
And I add a new discussion to "Test forum name" Open Forum with:
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/posts_ordering_blog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Course blog forum |
| Description | Single discussion forum description |
| Forum type | Standard forum displayed in a blog-like format |
Expand Down Expand Up @@ -65,7 +65,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
And I follow "Blog post 1"
And I follow "Reply"
And I follow "Use advanced editor and additional options"
And I set the field with xpath "//*[@id='id_messageeditable']" to "Reply to the first post"
And I set the field with xpath "//*[@id='id_message']" to "Reply to the first post"
And I press "Post to forum"
And I wait to be redirected to open forum
And I am on "Course 1" course homepage
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/posts_ordering_general.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: New Open discussions and discussions with recently added replies are di
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Course general forum |
| Description | Single discussion forum description |
| Forum type | Standard forum for general use |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/rate_posts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Users can rate other users forum posts
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Test forum name |
| Description | Test forum description |
| Aggregate type | Average of ratings |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/separate_group_single_group_discussions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ Feature: In Open Forums, posting to groups in a separate group discussion when r
| G2 | G2G1 |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Multiple groups forum |
| Forum type | Standard forum for general use |
| Description | Standard forum description |
| Group mode | Separate groups |
| Grouping | G1 |
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
| Forum name | Single groups forum |
| Forum type | Standard forum for general use |
| Description | Standard forum description |
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/split_forum_discussion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Feature: Open Forum discussions can be split
| student1 | C1 | student |
And I log in as "teacher1"
And I am on "Science 101" course homepage with editing mode on
And I add a "Open Forum" to section "1" and I fill the form with:
And I add a "hsuforum" activity to course "Science 101" section "1" and I fill the form with:
| Forum name | Study discussions |
| Forum type | Standard forum for general use |
| Description | Forum to discuss your coursework. |
Expand Down