mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-58138 completion: Fixes for a number of small issues.
This commit is contained in:
parent
32b93ea7f8
commit
273d310601
25 changed files with 90 additions and 146 deletions
|
@ -83,13 +83,9 @@ class core_completion_bulkedit_form extends core_completion_edit_base_form {
|
|||
|
||||
// Initialise the form but discard all JS requirements it adds, our form has already added them.
|
||||
$mformclassname = 'mod_'.$modname.'_mod_form';
|
||||
if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
|
||||
$PAGE->start_collecting_javascript_requirements();
|
||||
}
|
||||
$PAGE->start_collecting_javascript_requirements();
|
||||
$this->_moduleform = new $mformclassname($data, 0, $cmrec, $course);
|
||||
if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
|
||||
$PAGE->end_collecting_javascript_requirements();
|
||||
}
|
||||
$PAGE->end_collecting_javascript_requirements();
|
||||
|
||||
return $this->_moduleform;
|
||||
}
|
||||
|
|
|
@ -83,13 +83,9 @@ class core_completion_defaultedit_form extends core_completion_edit_base_form {
|
|||
|
||||
// Initialise the form but discard all JS requirements it adds, our form has already added them.
|
||||
$mformclassname = 'mod_'.$modname.'_mod_form';
|
||||
if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
|
||||
$PAGE->start_collecting_javascript_requirements();
|
||||
}
|
||||
$PAGE->start_collecting_javascript_requirements();
|
||||
$this->_moduleform = new $mformclassname($data, 0, $cmrec, $course);
|
||||
if (!defined('PHPUNIT_TEST') || !PHPUNIT_TEST) {
|
||||
$PAGE->end_collecting_javascript_requirements();
|
||||
}
|
||||
$PAGE->end_collecting_javascript_requirements();
|
||||
|
||||
return $this->_moduleform;
|
||||
}
|
||||
|
|
|
@ -110,8 +110,9 @@ class manager {
|
|||
} else {
|
||||
$moduleobject->completionstatus = ['icon' => null, 'string' => null];
|
||||
}
|
||||
|
||||
$activities[] = $moduleobject;
|
||||
if (self::can_edit_bulk_completion($this->courseid, $mod)) {
|
||||
$activities[] = $moduleobject;
|
||||
}
|
||||
}
|
||||
return $activities;
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ class manager {
|
|||
$module->icon = $OUTPUT->image_url('icon', $module->name)->out();
|
||||
$module->formattedname = format_string(get_string('modulenameplural', 'mod_' . $module->name),
|
||||
true, ['context' => $coursecontext]);
|
||||
$module->canmanage = $canmanage && \course_allowed_module($course, $module->name);
|
||||
$module->canmanage = $canmanage && course_allowed_module($course, $module->name);
|
||||
$defaults = self::get_default_completion($course, $module, false);
|
||||
$defaults->modname = $module->name;
|
||||
$module->completionstatus = $this->get_completion_detail($defaults);
|
||||
|
@ -390,8 +391,12 @@ class manager {
|
|||
if (!$modids = $data->modids) {
|
||||
return;
|
||||
}
|
||||
$defaults = ['completion' => COMPLETION_DISABLED, 'completionview' => COMPLETION_VIEW_NOT_REQUIRED,
|
||||
'completionexpected' => 0, 'completionusegrade' => 0];
|
||||
$defaults = [
|
||||
'completion' => COMPLETION_DISABLED,
|
||||
'completionview' => COMPLETION_VIEW_NOT_REQUIRED,
|
||||
'completionexpected' => 0,
|
||||
'completionusegrade' => 0
|
||||
];
|
||||
|
||||
$data = (array)$data;
|
||||
|
||||
|
@ -407,22 +412,30 @@ class manager {
|
|||
$params[] = 1;
|
||||
$modules = $DB->get_records_select_menu('modules', 'id ' . $modidssql . ' and visible = ?', $params, '', 'id, name');
|
||||
|
||||
// Get an associative array of [module_id => course_completion_defaults_id].
|
||||
list($in, $params) = $DB->get_in_or_equal($modids);
|
||||
$params[] = $courseid;
|
||||
$defaultsids = $DB->get_records_select_menu('course_completion_defaults', 'module ' . $in . ' and course = ?', $params, '',
|
||||
'module, id');
|
||||
|
||||
foreach ($modids as $modid) {
|
||||
if (!array_key_exists($modid, $modules)) {
|
||||
continue;
|
||||
}
|
||||
if ($defaultsid = $DB->get_field('course_completion_defaults', 'id', ['course' => $courseid, 'module' => $modid])) {
|
||||
$DB->update_record('course_completion_defaults', $data + ['id' => $defaultsid]);
|
||||
if (isset($defaultsids[$modid])) {
|
||||
$DB->update_record('course_completion_defaults', $data + ['id' => $defaultsids[$modid]]);
|
||||
} else {
|
||||
$defaultsid = $DB->insert_record('course_completion_defaults', $data + ['course' => $courseid, 'module' => $modid]);
|
||||
$defaultsids[$modid] = $DB->insert_record('course_completion_defaults', $data + ['course' => $courseid,
|
||||
'module' => $modid]);
|
||||
}
|
||||
// Trigger event.
|
||||
\core\event\completion_defaults_updated::create([
|
||||
'objectid' => $defaultsid,
|
||||
'objectid' => $defaultsids[$modid],
|
||||
'context' => $coursecontext,
|
||||
'other' => ['modulename' => $modules[$modid]],
|
||||
])->trigger();
|
||||
}
|
||||
|
||||
// Add notification.
|
||||
\core\notification::add(get_string('defaultcompletionupdated', 'completion'), \core\notification::SUCCESS);
|
||||
}
|
||||
|
|
|
@ -58,4 +58,3 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
|
|||
And I should see "Student must receive a grade to complete this activity" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
|
||||
And I should see "Student must submit to this activity to complete it" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
|
||||
And I should not see "Completion expected on" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Test assignment two']]" "xpath_element"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
@core @core_completion
|
||||
Feature: Allow teachers to bulk edit activity completion rules in a course.
|
||||
In order to avoid editing single activities
|
||||
Feature: Allow teachers to edit the default activity completion rules in a course.
|
||||
In order to set the activity completion defaults for new activities
|
||||
As a teacher
|
||||
I need to be able to edit the completion rules for a group of activities.
|
||||
|
||||
|
@ -8,7 +8,7 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
|
|||
# When I edit activity completion defaults for activity types.
|
||||
# Then the completion rule defaults should apply only to activities created from that point onwards.
|
||||
@javascript
|
||||
Scenario: Bulk edit activity completion rules
|
||||
Scenario: Bulk edit activity completion default rules
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
|
@ -50,4 +50,3 @@ Feature: Allow teachers to bulk edit activity completion rules in a course.
|
|||
And I should see "Student must receive a grade to complete this activity" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Assignments']]" "xpath_element"
|
||||
And I should see "Student must submit to this activity to complete it" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Assignments']]" "xpath_element"
|
||||
And I should not see "Completion expected on" in the "//div[contains(concat(' ', normalize-space(@class), ' '), ' row ')][.//*[text() = 'Assignments']]" "xpath_element"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue