| Línea 181... |
Línea 181... |
| 181 |
core_tag_tag::set_item_tags('core', 'course_modules', $moduleinfo->coursemodule, $modcontext, $moduleinfo->tags);
|
181 |
core_tag_tag::set_item_tags('core', 'course_modules', $moduleinfo->coursemodule, $modcontext, $moduleinfo->tags);
|
| 182 |
}
|
182 |
}
|
| Línea 183... |
Línea 183... |
| 183 |
|
183 |
|
| 184 |
// Course_modules and course_sections each contain a reference to each other.
|
184 |
// Course_modules and course_sections each contain a reference to each other.
|
| 185 |
// So we have to update one of them twice.
|
185 |
// So we have to update one of them twice.
|
| - |
|
186 |
$sectionid = course_add_cm_to_section(
|
| - |
|
187 |
$course,
|
| - |
|
188 |
$moduleinfo->coursemodule,
|
| - |
|
189 |
$moduleinfo->section,
|
| - |
|
190 |
$moduleinfo->beforemod,
|
| - |
|
191 |
$moduleinfo->modulename
|
| Línea 186... |
Línea 192... |
| 186 |
$sectionid = course_add_cm_to_section($course, $moduleinfo->coursemodule, $moduleinfo->section, $moduleinfo->beforemod);
|
192 |
);
|
| 187 |
|
193 |
|
| 188 |
// Trigger event based on the action we did.
|
194 |
// Trigger event based on the action we did.
|
| 189 |
// Api create_from_cm expects modname and id property, and we don't want to modify $moduleinfo since we are returning it.
|
195 |
// Api create_from_cm expects modname and id property, and we don't want to modify $moduleinfo since we are returning it.
|
| Línea 396... |
Línea 402... |
| 396 |
// If regrading will be slow, and this is happening in response to front-end UI...
|
402 |
// If regrading will be slow, and this is happening in response to front-end UI...
|
| 397 |
if (!empty($moduleinfo->frontend) && grade_needs_regrade_progress_bar($course->id)) {
|
403 |
if (!empty($moduleinfo->frontend) && grade_needs_regrade_progress_bar($course->id)) {
|
| 398 |
// And if it actually needs regrading...
|
404 |
// And if it actually needs regrading...
|
| 399 |
$courseitem = grade_item::fetch_course_item($course->id);
|
405 |
$courseitem = grade_item::fetch_course_item($course->id);
|
| 400 |
if ($courseitem->needsupdate) {
|
406 |
if ($courseitem->needsupdate) {
|
| 401 |
// Then don't do it as part of this form save, do it on an extra web request with a
|
- |
|
| 402 |
// progress bar.
|
407 |
// Queue an asynchronous regrade.
|
| 403 |
$moduleinfo->needsfrontendregrade = true;
|
408 |
grade_regrade_final_grades($course->id, async: true);
|
| 404 |
}
|
409 |
}
|
| 405 |
} else {
|
410 |
} else {
|
| 406 |
// Regrade now.
|
411 |
// Regrade now.
|
| 407 |
grade_regrade_final_grades($course->id);
|
412 |
$result = grade_regrade_final_grades($course->id);
|
| - |
|
413 |
if (is_array($result)) {
|
| - |
|
414 |
foreach ($result as $error) {
|
| - |
|
415 |
\core\notification::add($error, \core\output\notification::NOTIFY_ERROR);
|
| - |
|
416 |
}
|
| - |
|
417 |
}
|
| 408 |
}
|
418 |
}
|
| 409 |
}
|
419 |
}
|
| Línea 410... |
Línea 420... |
| 410 |
|
420 |
|
| 411 |
// Allow plugins to extend the course module form.
|
421 |
// Allow plugins to extend the course module form.
|
| Línea 421... |
Línea 431... |
| 421 |
$adhocktask->set_component('course');
|
431 |
$adhocktask->set_component('course');
|
| 422 |
\core\task\manager::queue_adhoc_task($adhocktask, true);
|
432 |
\core\task\manager::queue_adhoc_task($adhocktask, true);
|
| 423 |
}
|
433 |
}
|
| 424 |
}
|
434 |
}
|
| Línea -... |
Línea 435... |
| - |
|
435 |
|
| - |
|
436 |
if (plugin_supports('mod', $moduleinfo->modulename, FEATURE_USES_QUESTIONS) && empty($moduleinfo->skipdefaultcategory)) {
|
| - |
|
437 |
// Create the default question category.
|
| - |
|
438 |
question_get_default_category($modcontext->id, true);
|
| - |
|
439 |
}
|
| 425 |
|
440 |
|
| 426 |
return $moduleinfo;
|
441 |
return $moduleinfo;
|
| Línea 427... |
Línea 442... |
| 427 |
}
|
442 |
}
|
| 428 |
|
443 |
|
| Línea 490... |
Línea 505... |
| 490 |
|
505 |
|
| 491 |
if (!isset($moduleinfo->downloadcontent)) {
|
506 |
if (!isset($moduleinfo->downloadcontent)) {
|
| 492 |
$moduleinfo->downloadcontent = DOWNLOAD_COURSE_CONTENT_ENABLED;
|
507 |
$moduleinfo->downloadcontent = DOWNLOAD_COURSE_CONTENT_ENABLED;
|
| Línea -... |
Línea 508... |
| - |
|
508 |
}
|
| - |
|
509 |
|
| - |
|
510 |
// Module types with this flag set to false must always be in section number 0.
|
| - |
|
511 |
if (!course_modinfo::is_mod_type_visible_on_course($moduleinfo->modulename)) {
|
| - |
|
512 |
$moduleinfo->section = 0;
|
| 493 |
}
|
513 |
}
|
| 494 |
|
514 |
|
| Línea 495... |
Línea 515... |
| 495 |
return $moduleinfo;
|
515 |
return $moduleinfo;
|
| 496 |
}
|
516 |
}
|
| Línea 618... |
Línea 638... |
| 618 |
}
|
638 |
}
|
| 619 |
if (!empty($CFG->enableavailability)) {
|
639 |
if (!empty($CFG->enableavailability)) {
|
| 620 |
// This code is used both when submitting the form, which uses a long
|
640 |
// This code is used both when submitting the form, which uses a long
|
| 621 |
// name to avoid clashes, and by unit test code which uses the real
|
641 |
// name to avoid clashes, and by unit test code which uses the real
|
| 622 |
// name in the table.
|
642 |
// name in the table.
|
| - |
|
643 |
$newavailability = $cm->availability;
|
| 623 |
if (property_exists($moduleinfo, 'availabilityconditionsjson')) {
|
644 |
if (property_exists($moduleinfo, 'availabilityconditionsjson')) {
|
| 624 |
if ($moduleinfo->availabilityconditionsjson !== '') {
|
645 |
if ($moduleinfo->availabilityconditionsjson !== '') {
|
| 625 |
$cm->availability = $moduleinfo->availabilityconditionsjson;
|
646 |
$newavailability = $moduleinfo->availabilityconditionsjson;
|
| 626 |
} else {
|
647 |
} else {
|
| 627 |
$cm->availability = null;
|
648 |
$newavailability = null;
|
| 628 |
}
|
649 |
}
|
| 629 |
} else if (property_exists($moduleinfo, 'availability')) {
|
650 |
} else if (property_exists($moduleinfo, 'availability')) {
|
| 630 |
$cm->availability = $moduleinfo->availability;
|
651 |
$newavailability = $moduleinfo->availability;
|
| - |
|
652 |
}
|
| - |
|
653 |
if ($cm->availability != $newavailability) {
|
| - |
|
654 |
$cm->availability = $newavailability;
|
| 631 |
}
|
655 |
}
|
| 632 |
// If there is any availability data, verify it.
|
656 |
// If there is any availability data, verify it.
|
| 633 |
if ($cm->availability) {
|
657 |
if ($cm->availability) {
|
| 634 |
$tree = new \core_availability\tree(json_decode($cm->availability));
|
658 |
$tree = new \core_availability\tree(json_decode($cm->availability));
|
| 635 |
// Save time and database space by setting null if the only data
|
659 |
// Save time and database space by setting null if the only data
|
| Línea 870... |
Línea 894... |
| 870 |
* @param string $modulename module name
|
894 |
* @param string $modulename module name
|
| 871 |
* @param int $section section number
|
895 |
* @param int $section section number
|
| 872 |
* @param string $suffix the suffix to add to the name of the completion rules.
|
896 |
* @param string $suffix the suffix to add to the name of the completion rules.
|
| 873 |
* @return array module information about other required data
|
897 |
* @return array module information about other required data
|
| 874 |
* @since Moodle 3.2
|
898 |
* @since Moodle 3.2
|
| - |
|
899 |
* @throws coding_exception if you try to set a section other than 0 on a module type that has feature flag FEATURE_CAN_DISPLAY
|
| - |
|
900 |
* set to false.
|
| 875 |
*/
|
901 |
*/
|
| 876 |
function prepare_new_moduleinfo_data($course, $modulename, $section, string $suffix = '') {
|
902 |
function prepare_new_moduleinfo_data($course, $modulename, $section, string $suffix = '') {
|
| 877 |
global $CFG;
|
903 |
global $CFG;
|
| Línea -... |
Línea 904... |
| - |
|
904 |
|
| - |
|
905 |
// Module types with this flag set to false must always be in section number 0.
|
| - |
|
906 |
if ($section != 0 && !course_modinfo::is_mod_type_visible_on_course($modulename)) {
|
| - |
|
907 |
throw new coding_exception("Modules with feature flag FEATURE_CAN_DISPLAY set to false can only be in section 0");
|
| - |
|
908 |
}
|
| 878 |
|
909 |
|
| Línea 879... |
Línea 910... |
| 879 |
list($module, $context, $cw) = can_add_moduleinfo($course, $modulename, $section);
|
910 |
list($module, $context, $cw) = can_add_moduleinfo($course, $modulename, $section);
|
| Línea 880... |
Línea 911... |
| 880 |
|
911 |
|
| Línea 920... |
Línea 951... |
| 920 |
$formfield = 'advancedgradingmethod_'.$areaname;
|
951 |
$formfield = 'advancedgradingmethod_'.$areaname;
|
| 921 |
$data->{$formfield} = '';
|
952 |
$data->{$formfield} = '';
|
| 922 |
}
|
953 |
}
|
| 923 |
}
|
954 |
}
|
| Línea -... |
Línea 955... |
| - |
|
955 |
|
| - |
|
956 |
if (plugin_supports('mod', $data->modulename, FEATURE_QUICKCREATE)) {
|
| - |
|
957 |
if (get_string_manager()->string_exists('quickcreatename', "mod_{$data->modulename}")) {
|
| - |
|
958 |
$data->name = get_string("quickcreatename", "mod_{$data->modulename}");
|
| - |
|
959 |
}
|
| - |
|
960 |
}
|
| 924 |
|
961 |
|
| 925 |
return array($module, $context, $cw, $cm, $data);
|
962 |
return array($module, $context, $cw, $cm, $data);
|