MDL-78742 tool_uploadcourse: configure show activity dates value.

This commit is contained in:
Paul Holden 2023-07-18 12:42:01 +01:00
parent 272fdb321a
commit 5f35d838d1
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
4 changed files with 14 additions and 1 deletions

View File

@ -101,7 +101,7 @@ class tool_uploadcourse_course {
/** @var array fields allowed as course data. */
static protected $validfields = array('fullname', 'shortname', 'idnumber', 'category', 'visible', 'startdate', 'enddate',
'summary', 'format', 'theme', 'lang', 'newsitems', 'showgrades', 'showreports', 'legacyfiles', 'maxbytes',
'groupmode', 'groupmodeforce', 'enablecompletion', 'downloadcontent');
'groupmode', 'groupmodeforce', 'enablecompletion', 'downloadcontent', 'showactivitydates');
/** @var array fields required on course creation. */
static protected $mandatoryfields = array('fullname', 'category');

View File

@ -192,6 +192,10 @@ class tool_uploadcourse_step2_form extends tool_uploadcourse_base_form {
$mform->addHelpButton('defaults[enablecompletion]', 'enablecompletion', 'completion');
}
$mform->addElement('selectyesno', 'defaults[showactivitydates]', get_string('showactivitydates'));
$mform->addHelpButton('defaults[showactivitydates]', 'showactivitydates');
$mform->setDefault('defaults[showactivitydates]', $courseconfig->showactivitydates);
// Add custom fields to the form.
$handler = \core_course\customfield\course_handler::create();
$handler->instance_form_definition($mform, 0, 'defaultvaluescustomfieldcategory', 'tool_uploadcourse');

View File

@ -166,6 +166,7 @@ $defaults['groupmodeforce'] = $courseconfig->groupmodeforce;
$defaults['visible'] = $courseconfig->visible;
$defaults['lang'] = $courseconfig->lang;
$defaults['enablecompletion'] = $courseconfig->enablecompletion;
$defaults['showactivitydates'] = $courseconfig->showactivitydates;
// Course template.
if (isset($options['templatecourse'])) {

View File

@ -425,6 +425,7 @@ class course_test extends \advanced_testcase {
'groupmode' => '2',
'groupmodeforce' => '1',
'enablecompletion' => '1',
'showactivitydates' => '1',
'tags' => 'Cat, Dog',
'role_teacher' => 'Knight',
@ -478,6 +479,7 @@ class course_test extends \advanced_testcase {
$this->assertEquals($data['groupmode'], $course->groupmode);
$this->assertEquals($data['groupmodeforce'], $course->groupmodeforce);
$this->assertEquals($data['enablecompletion'], $course->enablecompletion);
$this->assertEquals($data['showactivitydates'], $course->showactivitydates);
$this->assertEquals($data['tags'], join(', ', \core_tag_tag::get_item_tags_array('core', 'course', $course->id)));
// Roles.
@ -530,6 +532,7 @@ class course_test extends \advanced_testcase {
'groupmode' => '1',
'groupmodeforce' => '0',
'enablecompletion' => '0',
'showactivitydates' => '0',
'role_teacher' => 'Teacher',
'role_manager' => 'Manager',
@ -583,6 +586,7 @@ class course_test extends \advanced_testcase {
$this->assertEquals($data['groupmode'], $course->groupmode);
$this->assertEquals($data['groupmodeforce'], $course->groupmodeforce);
$this->assertEquals($data['enablecompletion'], $course->enablecompletion);
$this->assertEquals($data['showactivitydates'], $course->showactivitydates);
// Roles.
$roleids = array();
@ -644,6 +648,7 @@ class course_test extends \advanced_testcase {
'groupmode' => '2',
'groupmodeforce' => '1',
'enablecompletion' => '1',
'showactivitydates' => '1',
);
$this->assertFalse($DB->record_exists('course', array('shortname' => 'c1')));
@ -673,6 +678,7 @@ class course_test extends \advanced_testcase {
$this->assertEquals($defaultdata['groupmode'], $course->groupmode);
$this->assertEquals($defaultdata['groupmodeforce'], $course->groupmodeforce);
$this->assertEquals($defaultdata['enablecompletion'], $course->enablecompletion);
$this->assertEquals($defaultdata['showactivitydates'], $course->showactivitydates);
// Update.
$cat = $this->getDataGenerator()->create_category();
@ -701,6 +707,7 @@ class course_test extends \advanced_testcase {
'groupmode' => '1',
'groupmodeforce' => '0',
'enablecompletion' => '0',
'showactivitydates' => '0',
);
$this->assertTrue($DB->record_exists('course', array('shortname' => 'c1')));
@ -730,6 +737,7 @@ class course_test extends \advanced_testcase {
$this->assertEquals($defaultdata['groupmode'], $course->groupmode);
$this->assertEquals($defaultdata['groupmodeforce'], $course->groupmodeforce);
$this->assertEquals($defaultdata['enablecompletion'], $course->enablecompletion);
$this->assertEquals($defaultdata['showactivitydates'], $course->showactivitydates);
}
public function test_rename() {