mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-70781 course: setting for displaying completion conditions
Part of MDL-70817
This commit is contained in:
parent
c0d0679c8a
commit
a4f7c1d91f
7 changed files with 44 additions and 1 deletions
|
@ -170,6 +170,17 @@ if ($hassiteconfig or has_any_capability($capabilities, $systemcontext)) {
|
||||||
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
|
$temp->add(new admin_setting_configselect('moodlecourse/enablecompletion', new lang_string('completion', 'completion'),
|
||||||
new lang_string('enablecompletion_help', 'completion'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
new lang_string('enablecompletion_help', 'completion'), 1, array(0 => new lang_string('no'), 1 => new lang_string('yes'))));
|
||||||
|
|
||||||
|
// Display completion conditions.
|
||||||
|
$temp->add(new admin_setting_heading('showcompletionconditions',
|
||||||
|
new lang_string('showcompletionconditions', 'completion'), ''));
|
||||||
|
$temp->add(new admin_setting_configselect('moodlecourse/showcompletionconditions',
|
||||||
|
new lang_string('showcompletionconditions', 'completion'),
|
||||||
|
new lang_string('showcompletionconditions_help', 'completion'), 1, [
|
||||||
|
0 => new lang_string('no'),
|
||||||
|
1 => new lang_string('yes')
|
||||||
|
]
|
||||||
|
));
|
||||||
|
|
||||||
// Groups.
|
// Groups.
|
||||||
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
$temp->add(new admin_setting_heading('groups', new lang_string('groups', 'group'), ''));
|
||||||
$choices = array();
|
$choices = array();
|
||||||
|
|
|
@ -317,6 +317,12 @@ class course_edit_form extends moodleform {
|
||||||
$mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion'));
|
$mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion'));
|
||||||
$mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
|
$mform->setDefault('enablecompletion', $courseconfig->enablecompletion);
|
||||||
$mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion');
|
$mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion');
|
||||||
|
|
||||||
|
$showcompletionconditions = $courseconfig->showcompletionconditions ?? COMPLETION_SHOW_CONDITIONS;
|
||||||
|
$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);
|
||||||
} else {
|
} else {
|
||||||
$mform->addElement('hidden', 'enablecompletion');
|
$mform->addElement('hidden', 'enablecompletion');
|
||||||
$mform->setType('enablecompletion', PARAM_INT);
|
$mform->setType('enablecompletion', PARAM_INT);
|
||||||
|
|
|
@ -221,6 +221,8 @@ $string['seedetails'] = 'See details';
|
||||||
$string['select'] = 'Select';
|
$string['select'] = 'Select';
|
||||||
$string['self'] = 'Self';
|
$string['self'] = 'Self';
|
||||||
$string['selfcompletion'] = 'Self completion';
|
$string['selfcompletion'] = 'Self completion';
|
||||||
|
$string['showcompletionconditions'] = 'Show completion conditions';
|
||||||
|
$string['showcompletionconditions_help'] = 'The activity completion conditions are displayed in the list of activities on the course page.';
|
||||||
$string['showinguser'] = 'Showing user';
|
$string['showinguser'] = 'Showing user';
|
||||||
$string['unenrolingfromcourse'] = 'Unenrolling from course';
|
$string['unenrolingfromcourse'] = 'Unenrolling from course';
|
||||||
$string['unenrolment'] = 'Unenrolment';
|
$string['unenrolment'] = 'Unenrolment';
|
||||||
|
|
|
@ -141,6 +141,15 @@ define('COMPLETION_AGGREGATION_ALL', 1);
|
||||||
*/
|
*/
|
||||||
define('COMPLETION_AGGREGATION_ANY', 2);
|
define('COMPLETION_AGGREGATION_ANY', 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completion conditions will be displayed to user.
|
||||||
|
*/
|
||||||
|
define('COMPLETION_SHOW_CONDITIONS', 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Completion conditions will be hidden from user.
|
||||||
|
*/
|
||||||
|
define('COMPLETION_HIDE_CONDITIONS', 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility function for checking if the logged in user can view
|
* Utility function for checking if the logged in user can view
|
||||||
|
|
|
@ -104,6 +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="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="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="4" NOTNULL="true" DEFAULT="0" SEQUENCE="false" COMMENT="Whether to display activity dates to user. 0 = do not display, 1 = display activity dates"/>
|
<FIELD NAME="showactivitydates" TYPE="int" LENGTH="4" 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"/>
|
||||||
</FIELDS>
|
</FIELDS>
|
||||||
<KEYS>
|
<KEYS>
|
||||||
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
|
||||||
|
|
|
@ -2531,5 +2531,19 @@ function xmldb_main_upgrade($oldversion) {
|
||||||
upgrade_main_savepoint(true, 2021052500.74);
|
upgrade_main_savepoint(true, 2021052500.74);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($oldversion < 2021052500.75) {
|
||||||
|
// Define field 'showcompletionconditions' to be added to course.
|
||||||
|
$table = new xmldb_table('course');
|
||||||
|
$field = new xmldb_field('showcompletionconditions', XMLDB_TYPE_INTEGER, '1', null,
|
||||||
|
XMLDB_NOTNULL, null, '1', 'completionnotify');
|
||||||
|
|
||||||
|
if (!$dbman->field_exists($table, $field)) {
|
||||||
|
$dbman->add_field($table, $field);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main savepoint reached.
|
||||||
|
upgrade_main_savepoint(true, 2021052500.75);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
defined('MOODLE_INTERNAL') || die();
|
defined('MOODLE_INTERNAL') || die();
|
||||||
|
|
||||||
$version = 2021052500.74; // YYYYMMDD = weekly release date of this DEV branch.
|
$version = 2021052500.75; // YYYYMMDD = weekly release date of this DEV branch.
|
||||||
// RR = release increments - 00 in DEV branches.
|
// RR = release increments - 00 in DEV branches.
|
||||||
// .XX = incremental changes.
|
// .XX = incremental changes.
|
||||||
$release = '4.0dev (Build: 20210330)'; // Human-friendly version name
|
$release = '4.0dev (Build: 20210330)'; // Human-friendly version name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue