Skip to content

Commit 6897b44

Browse files
committed
Moodle 4.4 compatibilty fixes for hsuforum
Removed some of the depricated functions and depricated strings that were causing test cases to fail when running on moodle 4.4 Fixed some the test cases as well which were using deprecated functions
1 parent 6d41aa8 commit 6897b44

19 files changed

+47
-37
lines changed

classes/output/big_search_form.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class big_search_form implements renderable, templatable {
5353
public $user;
5454
public $words;
5555
public $tags;
56+
57+
public $forumid;
5658
/** @var string The URL of the search form. */
5759
public $actionurl;
5860

mod_form.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ function standard_grading_coursemodule_elements() {
276276
* Adds all the standard elements to a form to edit the settings for an activity module for Hsuforum.
277277
*/
278278
protected function standard_hsuforum_coursemodule_elements() {
279-
global $COURSE, $CFG, $DB;
279+
global $COURSE, $CFG, $DB, $OUTPUT;
280280
$mform =& $this->_form;
281281

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

396403
$trackingdefault = COMPLETION_TRACKING_NONE;
397404
// If system and activity default is on, set it.
398-
if ($CFG->completiondefault && $this->_features->defaultcompletion) {
405+
if (!empty($CFG->completiondefault) && $this->_features->defaultcompletion) {
399406
$hasrules = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_HAS_RULES, true);
400407
$tracksviews = plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, true);
401408
if ($hasrules || $tracksviews) {
@@ -414,7 +421,7 @@ protected function standard_hsuforum_coursemodule_elements() {
414421
// Automatic completion once you view it
415422
$gotcompletionoptions = false;
416423
if (plugin_supports('mod', $this->_modname, FEATURE_COMPLETION_TRACKS_VIEWS, false)) {
417-
$mform->addElement('checkbox', 'completionview', get_string('completionview', 'completion'),
424+
$mform->addElement('checkbox', 'completionview', '',
418425
get_string('completionview_desc', 'completion'));
419426
$mform->hideIf('completionview', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
420427
// Check by default if automatic completion tracking is set.
@@ -437,11 +444,10 @@ protected function standard_hsuforum_coursemodule_elements() {
437444
$mform->addElement(
438445
'checkbox',
439446
'completionusegrade',
440-
get_string('completionusegrade', 'completion'),
447+
'',
441448
get_string('completionusegrade_desc', 'completion')
442449
);
443450
$mform->hideIf('completionusegrade', 'completion', 'ne', COMPLETION_TRACKING_AUTOMATIC);
444-
$mform->addHelpButton('completionusegrade', 'completionusegrade', 'completion');
445451

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

678-
$mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
684+
$mform->addElement('date_time_selector', 'assesstimestart', get_string('fromdate'));
679685
$mform->hideIf('assesstimestart', $assessedfieldname, 'eq', 0);
680686
$mform->hideIf('assesstimestart', 'ratingtime');
681687

682-
$mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
688+
$mform->addElement('date_time_selector', 'assesstimefinish', get_string('todate'));
683689
$mform->hideIf('assesstimefinish', $assessedfieldname, 'eq', 0);
684690
$mform->hideIf('assesstimefinish', 'ratingtime');
685691
}

post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@
570570
}
571571

572572
$formheading = '';
573+
$hidehtml = '';
573574
if (!empty($parent)) {
574575
$formheading = get_string("yourreply", "hsuforum");
575576
} else {
@@ -578,15 +579,13 @@
578579
} else {
579580
$formheading = get_string('yournewtopic', 'hsuforum');
580581
// Hide duplicated hsuforum description when creating a new discussion topic, see INT-18928.
581-
$hidehtml = '';
582582
$hidehtml .= html_writer::start_tag('style', array('type' => 'text/css')) . "\n";
583583
$hidehtml .= '
584584
#page-mod-hsuforum-post .activity-description,
585585
#page-mod-hsuforum-post [role="main"] h2 {
586586
display: none;
587587
};';
588588
$hidehtml .= html_writer::end_tag('style') . "\n";
589-
echo $hidehtml;
590589
}
591590
}
592591

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

10031003
// Checkup.

search.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@
312312
$post->id
313313
),
314314
$post->messageformat,
315-
$options,
316-
$course->id),
315+
$options),
317316
0, '<fgw9sdpq4>', '</fgw9sdpq4>');
318317

319318
foreach ($searchterms as $searchterm) {

tests/behat/accessibility_pin_button.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Feature: When creating a new discussion the unpin option should exist as a butto
3636
| teacher1 | C1 | editingteacher |
3737
And I log in as "teacher1"
3838
And I am on "Course 1" course homepage with editing mode on
39-
And I add a "Open Forum" to section "1" and I fill the form with:
39+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
4040
| Forum name | Test forum name |
4141
| Forum type | Standard forum for general use |
4242
| Description | Test forum description |

tests/behat/add_forum.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Feature: Add Open Forum activities and discussions
1919
| student1 | C1 | student |
2020
And I log in as "teacher1"
2121
And I am on "Course 1" course homepage with editing mode on
22-
And I add a "Open Forum" to section "1" and I fill the form with:
22+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2323
| Forum name | Test forum name |
2424
| Forum type | Standard forum for general use |
2525
| Description | Test forum description |
@@ -59,7 +59,7 @@ Feature: Add Open Forum activities and discussions
5959
| teacher1 | C1 | editingteacher |
6060
And I log in as "teacher1"
6161
And I am on "Course 1" course homepage with editing mode on
62-
And I add a "Open Forum" to section "1" and I fill the form with:
62+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
6363
| Forum name | Test forum name |
6464
| Forum type | Standard forum for general use |
6565
| Description | Test forum description |

tests/behat/advanced_editor_pass_data_to_new_page.feature

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ Feature: Users see their typed information in the advanced editor view when clic
1717
| enabletimedposts | 1 | hsuforum |
1818
And I log in as "admin"
1919
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:
20+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2121
| Forum name | Test forum name |
2222
| Forum type | Standard forum for general use |
2323
| Description | Test forum description |
2424
And I log out
2525
2626
@javascript
27+
@editor_tiny
2728
Scenario: User can continue writing after clicking "Use advanced editor"
2829
When I log in as "teacher1"
2930
And I am on "Course 1" course homepage
@@ -39,7 +40,7 @@ Feature: Users see their typed information in the advanced editor view when clic
3940
And I should not see "Add your discussion"
4041
And I should see "Your new discussion topic"
4142
And I set the field with xpath "//*[@id='id_subject']" to "Test discussion 1 to be cancelled"
42-
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test discussion 1 to be cancelled description"
43+
And I set the field with xpath "//*[@id='id_message']" to "Test discussion 1 to be cancelled description"
4344
And I press "Post to forum"
4445
Then I log out
4546
And I log in as "student1"
@@ -54,7 +55,7 @@ Feature: Users see their typed information in the advanced editor view when clic
5455
And I wait until the page is ready
5556
And I should see "Your reply"
5657
And I set the field with xpath "//*[@id='id_subject']" to "Test reply subject"
57-
And I set the field with xpath "//*[@id='id_messageeditable']" to "Test reply message"
58+
And I set the field with xpath "//*[@id='id_message']" to "Test reply message"
5859
And I press "Post to forum"
5960
And I log out
6061
And I log in as "teacher1"
@@ -68,6 +69,8 @@ Feature: Users see their typed information in the advanced editor view when clic
6869
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"
6970
And I click on ".hsuforum-post.depth0 .hsuforum-use-advanced" "css_element"
7071
And I wait until the page is ready
72+
And I switch to the "Message" TinyMCE editor iframe
7173
And ".text_to_html br" "css_element" should exist
74+
And I switch to the main frame
7275
And I should see "Your reply"
73-
And I set the field with xpath "//*[@id='id_messageeditable']" to "This is a reply"
76+
And I set the field with xpath "//*[@id='id_message']" to "This is a reply"

tests/behat/edit_post_student.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Feature: Students can edit or delete their Open Forum posts within a set time li
5151
And I log out
5252
And I log in as "admin"
5353
And I am on "Course 1" course homepage with editing mode on
54-
And I add a "Open Forum" to section "1" and I fill the form with:
54+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
5555
| Forum name | Test forum name |
5656
| Forum type | Standard forum for general use |
5757
| Description | Test forum description |

tests/behat/edit_post_teacher.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: Teachers can edit or delete any Open Forum post
1818
| student1 | C1 | student |
1919
And I log in as "teacher1"
2020
And I am on "Course 1" course homepage with editing mode on
21-
And I add a "Open Forum" to section "1" and I fill the form with:
21+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2222
| Forum name | Test forum name |
2323
| Description | Test forum description |
2424
And I add a new discussion to "Test forum name" Open Forum with:

tests/behat/forum_subscriptions_availability.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: In Open Forums as a teacher I need to see an accurate list of subscribe
2525

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

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

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

7171
@javascript
7272
Scenario: An automatic forum lists all subscribers
73-
When I add a "Open Forum" to section "1" and I fill the form with:
73+
When I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
7474
| Forum name | Forced Forum 1 |
7575
| Forum type | Standard forum for general use |
7676
| Description | Test forum description |

tests/behat/grading_settings.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Feature: While creating a new activity, the grade settings should remain in the
3939
| Grade category 1 | C1 |
4040
And I log in as "teacher1"
4141
And I am on "Course 1" course homepage with editing mode on
42-
And I add a "Open Forum" to section "1" and I fill the form with:
42+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
4343
| Forum name | Test forum name |
4444
| Forum type | Standard forum for general use |
4545
| Description | Test forum description |
@@ -68,5 +68,5 @@ Feature: While creating a new activity, the grade settings should remain in the
6868
# Test forum name Open forum, should exist as a Grade category 1 which is the Grade category chosen before.
6969
And I should see "Grade category 1"
7070
And I should see "Test forum name"
71-
And "//h4[contains(text(), 'Grade category 1')]" "xpath_element" should exist
71+
And "//div[contains(text(), 'Grade category 1')]" "xpath_element" should exist
7272
And "//a[contains(text(), 'Test forum name')]" "xpath_element" should exist

tests/behat/hsuforum_tags.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
3737
| student1 | C1 | student |
3838
And I log in as "teacher1"
3939
And I am on "Course 1" course homepage with editing mode on
40-
And I add a "Open Forum" to section "1" and I fill the form with:
40+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
4141
| Forum name | Test forum name |
4242
| Description | Test forum description |
4343
And I add a new discussion to "Test forum name" Open Forum with:
@@ -47,7 +47,7 @@ Feature: Open forum posts and new discussions handle tags correctly, in order to
4747
Given I log in as "admin"
4848
And I navigate to "Appearance > Manage tags" in site administration
4949
And I follow "Default collection"
50-
And I follow "Add standard tags"
50+
And I press "Add standard tags"
5151
And I set the field "Enter comma-separated list of new tags" to "OT1, OT2, OT3"
5252
And I press "Continue"
5353
And I log out

tests/behat/inline_edit.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Feature: Teachers and students can add discussions inline
1717
| enabletimedposts | 1 | hsuforum |
1818
And I log in as "admin"
1919
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:
20+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2121
| Forum name | Test forum name |
2222
| Forum type | Standard forum for general use |
2323
| Description | Test forum description |

tests/behat/maintain_start_end_date.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Feature: In Open Forums users can change start and end date and the changes rema
1717
And the following config values are set as admin:
1818
| enabletimedposts | 1 | hsuforum |
1919
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:
20+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2121
| Forum name | Test forum name |
2222
| Description | Test forum description |
2323
And I add a new discussion to "Test forum name" Open Forum with:

tests/behat/posts_ordering_blog.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
1818
| student1 | C1 | student |
1919
And I log in as "teacher1"
2020
And I am on "Course 1" course homepage with editing mode on
21-
And I add a "Open Forum" to section "1" and I fill the form with:
21+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2222
| Forum name | Course blog forum |
2323
| Description | Single discussion forum description |
2424
| Forum type | Standard forum displayed in a blog-like format |
@@ -65,7 +65,7 @@ Feature: In Open Forums, blog posts are always displayed in reverse chronologica
6565
And I follow "Blog post 1"
6666
And I follow "Reply"
6767
And I follow "Use advanced editor and additional options"
68-
And I set the field with xpath "//*[@id='id_messageeditable']" to "Reply to the first post"
68+
And I set the field with xpath "//*[@id='id_message']" to "Reply to the first post"
6969
And I press "Post to forum"
7070
And I wait to be redirected to open forum
7171
And I am on "Course 1" course homepage

tests/behat/posts_ordering_general.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: New Open discussions and discussions with recently added replies are di
1818
| student1 | C1 | student |
1919
And I log in as "teacher1"
2020
And I am on "Course 1" course homepage with editing mode on
21-
And I add a "Open Forum" to section "1" and I fill the form with:
21+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2222
| Forum name | Course general forum |
2323
| Description | Single discussion forum description |
2424
| Forum type | Standard forum for general use |

tests/behat/rate_posts.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: Users can rate other users forum posts
1818
| student1 | C1 | student |
1919
And I log in as "teacher1"
2020
And I am on "Course 1" course homepage with editing mode on
21-
And I add a "Open Forum" to section "1" and I fill the form with:
21+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
2222
| Forum name | Test forum name |
2323
| Description | Test forum description |
2424
| Aggregate type | Average of ratings |

tests/behat/separate_group_single_group_discussions.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ Feature: In Open Forums, posting to groups in a separate group discussion when r
4040
| G2 | G2G1 |
4141
And I log in as "admin"
4242
And I am on "Course 1" course homepage with editing mode on
43-
And I add a "Open Forum" to section "1" and I fill the form with:
43+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
4444
| Forum name | Multiple groups forum |
4545
| Forum type | Standard forum for general use |
4646
| Description | Standard forum description |
4747
| Group mode | Separate groups |
4848
| Grouping | G1 |
49-
And I add a "Open Forum" to section "1" and I fill the form with:
49+
And I add a "hsuforum" activity to course "Course 1" section "1" and I fill the form with:
5050
| Forum name | Single groups forum |
5151
| Forum type | Standard forum for general use |
5252
| Description | Standard forum description |

tests/behat/split_forum_discussion.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: Open Forum discussions can be split
1818
| student1 | C1 | student |
1919
And I log in as "teacher1"
2020
And I am on "Science 101" course homepage with editing mode on
21-
And I add a "Open Forum" to section "1" and I fill the form with:
21+
And I add a "hsuforum" activity to course "Science 101" section "1" and I fill the form with:
2222
| Forum name | Study discussions |
2323
| Forum type | Standard forum for general use |
2424
| Description | Forum to discuss your coursework. |

0 commit comments

Comments
 (0)