Skip to content

[M4.3] Default activity completion page in Couse completion setting b… #487

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

Merged
merged 2 commits into from
Apr 17, 2024
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
1 change: 0 additions & 1 deletion .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
# - each moodle version at least once
# - each database at least once
include:
- {php: '7.3', moodle-branch: MOODLE_400_STABLE, database: pgsql}
- {php: '7.4', moodle-branch: MOODLE_401_STABLE, database: mariadb}
- {php: '8.0', moodle-branch: MOODLE_402_STABLE, database: pgsql}
- {php: '8.2', moodle-branch: MOODLE_403_STABLE, database: mariadb}
Expand Down
32 changes: 25 additions & 7 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
require_once(__DIR__ . '/locallib.php');
require_once(__DIR__ . '/reportlib.php');

use mod_studentquiz\utils;

/**
* Module instance settings form
*
Expand Down Expand Up @@ -297,16 +299,19 @@ public function data_preprocessing(&$defaultvalues) {
*/
public function add_completion_rules(): array {
$mform =& $this->_form;
$completionpointel = $this->get_suffixed_name('completionpointgroup');
$completionquestionpublishedel = $this->get_suffixed_name('completionquestionpublishedgroup');
$completionquestionapprovedgel = $this->get_suffixed_name('completionquestionapprovedgroup');

// Require point.
$group = [];
$group[] =& $mform->createElement('checkbox', 'completionpointenabled', '',
get_string('completionpoint', 'mod_studentquiz'));
$group[] =& $mform->createElement('text', 'completionpoint', '', ['size' => 3]);
$mform->setType('completionpoint', PARAM_INT);
$mform->addGroup($group, 'completionpointgroup', get_string('completionpointgroup',
$mform->addGroup($group, $completionpointel, get_string('completionpointgroup',
'mod_studentquiz'), [' '], false);
$mform->addHelpButton('completionpointgroup', 'completionpointgroup',
$mform->addHelpButton($completionpointel, 'completionpointgroup',
'mod_studentquiz');
$mform->disabledIf('completionpoint', 'completionpointenabled', 'notchecked');

Expand All @@ -317,10 +322,10 @@ public function add_completion_rules(): array {
$group[] =& $mform->createElement('text', 'completionquestionpublished', '',
['size' => 3]);
$mform->setType('completionquestionpublished', PARAM_INT);
$mform->addGroup($group, 'completionquestionpublishedgroup',
$mform->addGroup($group, $completionquestionpublishedel,
get_string('completionquestionpublishedgroup', 'mod_studentquiz'),
[' '], false);
$mform->addHelpButton('completionquestionpublishedgroup',
$mform->addHelpButton($completionquestionpublishedel,
'completionquestionpublishedgroup', 'mod_studentquiz');
$mform->disabledIf('completionquestionpublished', 'completionquestionpublishedenabled',
'notchecked');
Expand All @@ -333,15 +338,15 @@ public function add_completion_rules(): array {
$group[] =& $mform->createElement('text',
'completionquestionapproved', '', ['size' => 3]);
$mform->setType('completionquestionapproved', PARAM_INT);
$mform->addGroup($group, 'completionquestionapprovedgroup',
$mform->addGroup($group, $completionquestionapprovedgel,
get_string('completionquestionapprovedgroup', 'mod_studentquiz'), [' '],
false);
$mform->addHelpButton('completionquestionapprovedgroup',
$mform->addHelpButton($completionquestionapprovedgel,
'completionquestionapprovedgroup', 'mod_studentquiz');
$mform->disabledIf('completionquestionapproved',
'completionquestionapprovedenabled', 'notchecked');

return ['completionpointgroup', 'completionquestionpublishedgroup', 'completionquestionapprovedgroup'];
return [$completionpointel, $completionquestionpublishedel, $completionquestionapprovedgel];
}

/**
Expand Down Expand Up @@ -437,4 +442,17 @@ public function get_data() {
return $data;
}

/**
* Get the suffix of name.
*
* @param string $fieldname The field name of the question.
* @return string The suffixed name.
*/
protected function get_suffixed_name(string $fieldname): string {
if (utils::moodle_version_is("<=", "42")) {
return $fieldname;
}

return $fieldname . $this->get_suffix();
}
}
6 changes: 3 additions & 3 deletions tests/behat/add_studentquiz.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Feature: Activities can be created

@javascript
Scenario: Check an Activity can be created
When I add a "StudentQuiz" to section "1" and I fill the form with:
When I add a studentquiz activity to course "Course 1" section "1" and I fill the form with:
| StudentQuiz Name | Test quiz name |
| Description | Test quiz description |
And I am on the "Test quiz name" "mod_studentquiz > View" page
Then I should see "Create new question"

@javascript
Scenario: Check an Activity can be created with comment deletion period = 0.
When I add a "StudentQuiz" to section "1" and I fill the form with:
When I add a studentquiz activity to course "Course 1" section "1" and I fill the form with:
| StudentQuiz Name | Test quiz name |
| Description | Test quiz description |
| Comment editing/deletion period (minutes) | 0 |
Expand All @@ -38,7 +38,7 @@ Feature: Activities can be created

@javascript
Scenario: Check an Activity can not be created with invalid date restriction.
Given I add a "StudentQuiz" to section "1"
Given I add a studentquiz activity to course "Course 1" section "1"
And I set the following fields to these values:
| StudentQuiz Name | Test SQ name |
| Description | Test SQ description |
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/admin_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Feature: New activities instances setting will be inherited from Admin setting
And the following config values are set as admin:
| defaultqtypes | truefalse | studentquiz |
And I am on "Course 1" course homepage with editing mode on
And I add a "StudentQuiz" to section "1"
And I add a studentquiz activity to course "Course 1" section "1"
And I expand all fieldsets
Then the following fields match these values:
| allowedqtypes[truefalse] | 1 |
Expand All @@ -34,7 +34,7 @@ Feature: New activities instances setting will be inherited from Admin setting
And I press "Cancel"
And the following config values are set as admin:
| defaultqtypes | truefalse,multichoice | studentquiz |
And I add a "StudentQuiz" to section "1"
And I add a studentquiz activity to course "Course 1" section "1"
And I expand all fieldsets
And the following fields match these values:
| allowedqtypes[truefalse] | 1 |
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/backup.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Feature: Restore specific studentquiz old backup to test UI feature
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |

@javascript @_file_upload
Scenario: Restore moodle backups containing history comments.
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/backup_restore_availability_setting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Feature: Backup and restore activity studentquiz
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |

@javascript @_file_upload
Scenario: Restore moodle backups containing old StudentQuiz activity has availability and question publishing setting.
Expand Down
1 change: 1 addition & 0 deletions tests/behat/behat_mod_studentquiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use mod_studentquiz\utils;
use Behat\Mink\Exception\ExpectationException as ExpectationException;
use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
use Behat\Gherkin\Node\TableNode as TableNode;

/**
* Steps definitions related to mod_studentquiz.
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Feature: Filtering in Studentquiz view.
@javascript
Scenario: Using filter without Creation filter should not causing warning.
When I am on the "StudentQuiz Test 1" "mod_studentquiz > View" page logged in as "admin"
And I click on "New" "link"
And I click on "New" "link" in the "#id_filtertabcontainer" "css_element"
And I press "id_submitbutton"
And I click on "Sort by Question ascending" "link"
Then I should see "Test question 1"
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/pagination.feature
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Feature: Test pagination for StudentQuiz
Given I am on the "StudentQuiz 1" "mod_studentquiz > View" page logged in as "admin"
And I set the field "qperpage" to "25"
And I press enter
And I click on "New" "link"
And I click on "New" "link" in the "#id_filtertabcontainer" "css_element"
And I press "id_submitbutton"
Then "input[name='changepagesize']" "css_element" should not exist
And I should see "Test question 24"
Expand Down
4 changes: 2 additions & 2 deletions tests/behat/question_submission_answering_phases.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Feature: Question submission and answering will follow the availability setting
Scenario: New availability settings should exist
When I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "StudentQuiz" to section "1"
And I add a studentquiz activity to course "Course 1" section "1"
And I expand all fieldsets
Then I should see "Open for question submission from"
And I should see "Closed for question submission from"
Expand All @@ -32,7 +32,7 @@ Feature: Question submission and answering will follow the availability setting
Scenario: Availability settings validation
When I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add a "StudentQuiz" to section "1"
And I add a studentquiz activity to course "Course 1" section "1"
And I expand all fieldsets
And I set the field "id_name" to "StudentQuiz Test Availability"

Expand Down
2 changes: 1 addition & 1 deletion tests/behat/startpageview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Feature: View comprehensive information about this studentquiz activity
And I should not see "Question 2"
And I click on "Reset" "button"

And I click on "New" "link"
And I click on "New" "link" in the "#id_filtertabcontainer" "css_element"
And I press "id_submitbutton"
And I should see "Question 2"
And I should not see "Question 1"
Expand Down
2 changes: 2 additions & 0 deletions tests/behat/state_visibility_old_backup_import.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Feature: Restore of studentquizzes in moodle exports contain old approved column
And the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C1 | 0 |
And the following config values are set as admin:
| enableasyncbackup | 0 |

@javascript @_file_upload
Scenario: Restore moodle backups containing old StudentQuiz activity with old approved column
Expand Down