Merge branch 'MDL-71370-master-test' of git://github.com/junpataleta/moodle
This commit is contained in:
@@ -50,20 +50,32 @@ Feature: Allow teachers to edit the visibility of completion conditions in a cou
|
||||
And I follow "Test choice manual"
|
||||
And the manual completion button for "Test choice manual" should be disabled
|
||||
|
||||
Scenario: Default show completion conditions value in course form when default show completion conditions admin setting is set to No
|
||||
Scenario Outline: Default showcompletionconditions value in course form on course creation
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Courses > Course default settings" in site administration
|
||||
When I set the following fields to these values:
|
||||
| Show completion conditions | No |
|
||||
And I click on "Save changes" "button"
|
||||
And I navigate to "Courses > Add a new course" in site administration
|
||||
Then the field "showcompletionconditions" matches value "No"
|
||||
And I set the field "Show completion conditions" to "<siteshowcompletion>"
|
||||
And I press "Save changes"
|
||||
When I navigate to "Courses > Add a new course" in site administration
|
||||
Then the field "showcompletionconditions" matches value "<expected>"
|
||||
|
||||
Scenario: Default show completion conditions value in course form when default show completion conditions admin setting is set to Yes
|
||||
Examples:
|
||||
| siteshowcompletion | expected |
|
||||
| Yes | Yes |
|
||||
| No | No |
|
||||
|
||||
Scenario Outline: Default showcompletionconditions displayed when editing a course with disabled completion tracking
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Courses > Course default settings" in site administration
|
||||
When I set the following fields to these values:
|
||||
| Show completion conditions | Yes |
|
||||
And I click on "Save changes" "button"
|
||||
And I navigate to "Courses > Add a new course" in site administration
|
||||
Then the field "showcompletionconditions" matches value "Yes"
|
||||
And I set the field "Show completion conditions" to "<siteshowcompletion>"
|
||||
And I press "Save changes"
|
||||
And I am on "Course 1" course homepage with editing mode on
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
And I set the field "Enable completion tracking" to "No"
|
||||
And I press "Save and display"
|
||||
And I navigate to "Edit settings" in current page administration
|
||||
Then the field "Show completion conditions" matches value "<expected>"
|
||||
|
||||
Examples:
|
||||
| siteshowcompletion | expected |
|
||||
| Yes | Yes |
|
||||
| No | No |
|
||||
|
||||
@@ -322,7 +322,7 @@ class course_edit_form extends moodleform {
|
||||
$mform->addElement('selectyesno', 'showcompletionconditions', get_string('showcompletionconditions', 'completion'));
|
||||
$mform->addHelpButton('showcompletionconditions', 'showcompletionconditions', 'completion');
|
||||
$mform->setDefault('showcompletionconditions', $showcompletionconditions);
|
||||
$mform->hideIf('showcompletionconditions', 'enablecompletion', 'eq', COMPLETION_HIDE_CONDITIONS);
|
||||
$mform->hideIf('showcompletionconditions', 'enablecompletion', 'eq', COMPLETION_DISABLED);
|
||||
} else {
|
||||
$mform->addElement('hidden', 'enablecompletion');
|
||||
$mform->setType('enablecompletion', PARAM_INT);
|
||||
|
||||
@@ -2362,6 +2362,19 @@ function create_course($data, $editoroptions = NULL) {
|
||||
$data->summary_format = FORMAT_HTML;
|
||||
}
|
||||
|
||||
// Get default completion settings as a fallback in case the enablecompletion field is not set.
|
||||
$courseconfig = get_config('moodlecourse');
|
||||
$defaultcompletion = !empty($CFG->enablecompletion) ? $courseconfig->enablecompletion : COMPLETION_DISABLED;
|
||||
$enablecompletion = $data->enablecompletion ?? $defaultcompletion;
|
||||
// Unset showcompletionconditions when completion tracking is not enabled for the course.
|
||||
if ($enablecompletion == COMPLETION_DISABLED) {
|
||||
unset($data->showcompletionconditions);
|
||||
} else if (!isset($data->showcompletionconditions)) {
|
||||
// Show completion conditions should have a default value when completion is enabled. Set it to the site defaults.
|
||||
// This scenario can happen when a course is created through data generators or through a web service.
|
||||
$data->showcompletionconditions = $courseconfig->showcompletionconditions;
|
||||
}
|
||||
|
||||
if (!isset($data->visible)) {
|
||||
// data not from form, add missing visibility info
|
||||
$data->visible = $category->visible;
|
||||
@@ -2540,6 +2553,11 @@ function update_course($data, $editoroptions = NULL) {
|
||||
}
|
||||
}
|
||||
|
||||
// Set showcompletionconditions to null when completion tracking has been disabled for the course.
|
||||
if (isset($data->enablecompletion) && $data->enablecompletion == COMPLETION_DISABLED) {
|
||||
$data->showcompletionconditions = null;
|
||||
}
|
||||
|
||||
// Update custom fields if there are any of them in the form.
|
||||
$handler = core_course\customfield\course_handler::create();
|
||||
$handler->instance_form_save($data);
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<XMLDB PATH="lib/db" VERSION="20210415" COMMENT="XMLDB file for core Moodle tables"
|
||||
<XMLDB PATH="lib/db" VERSION="20210422" COMMENT="XMLDB file for core Moodle tables"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
|
||||
>
|
||||
@@ -104,7 +104,7 @@
|
||||
<FIELD NAME="cacherev" TYPE="int" LENGTH="10" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Incrementing revision for validating the course content cache"/>
|
||||
<FIELD NAME="originalcourseid" TYPE="int" LENGTH="10" NOTNULL="false" SEQUENCE="false" COMMENT="the id of the source course when a new course originates from a restore of another course on the same site."/>
|
||||
<FIELD NAME="showactivitydates" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether to display activity dates to user. 0 = do not display, 1 = display activity dates"/>
|
||||
<FIELD NAME="showcompletionconditions" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="Whether to display completion conditions to user. 0 = do not display, 1 = display conditions"/>
|
||||
<FIELD NAME="showcompletionconditions" TYPE="int" LENGTH="1" NOTNULL="false" SEQUENCE="false" COMMENT="Whether to display completion conditions to user. 0 = do not display, 1 = display conditions"/>
|
||||
</FIELDS>
|
||||
<KEYS>
|
||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||
|
||||
@@ -2621,5 +2621,26 @@ function xmldb_main_upgrade($oldversion) {
|
||||
upgrade_main_savepoint(true, 2021052500.85);
|
||||
}
|
||||
|
||||
if ($oldversion < 2021052500.87) {
|
||||
// Changing the default of field showcompletionconditions on table course to 0.
|
||||
$table = new xmldb_table('course');
|
||||
$field = new xmldb_field('showcompletionconditions', XMLDB_TYPE_INTEGER, '1', null, null, null, null, 'showactivitydates');
|
||||
|
||||
// Launch change of nullability for field showcompletionconditions.
|
||||
$dbman->change_field_notnull($table, $field);
|
||||
|
||||
// Launch change of default for field showcompletionconditions.
|
||||
$dbman->change_field_default($table, $field);
|
||||
|
||||
// Set showcompletionconditions to null for courses which don't track completion.
|
||||
$sql = "UPDATE {course}
|
||||
SET showcompletionconditions = null
|
||||
WHERE enablecompletion <> 1";
|
||||
$DB->execute($sql);
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2021052500.87);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2021052500.86; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2021052500.87; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
$release = '4.0dev (Build: 20210423)'; // Human-friendly version name
|
||||
|
||||
Reference in New Issue
Block a user