MDL-35568 course dndupload - resources created with the same visibility as the section they are dragged onto
This commit is contained in:
@@ -728,6 +728,9 @@ M.course_dndupload = {
|
||||
resel.icon.src = result.icon;
|
||||
resel.a.href = result.link;
|
||||
resel.namespan.innerHTML = result.name;
|
||||
if (!parseInt(result.visible, 10)) {
|
||||
resel.a.className = 'dimmed';
|
||||
}
|
||||
|
||||
if (result.groupingname) {
|
||||
resel.groupingspan.innerHTML = '(' + result.groupingname + ')';
|
||||
@@ -915,6 +918,9 @@ M.course_dndupload = {
|
||||
resel.icon.src = result.icon;
|
||||
resel.a.href = result.link;
|
||||
resel.namespan.innerHTML = result.name;
|
||||
if (!parseInt(result.visible, 10)) {
|
||||
resel.a.className = 'dimmed';
|
||||
}
|
||||
|
||||
if (result.groupingname) {
|
||||
resel.groupingspan.innerHTML = '(' + result.groupingname + ')';
|
||||
|
||||
@@ -620,12 +620,18 @@ class dndupload_ajax_processor {
|
||||
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
|
||||
}
|
||||
|
||||
// Note the section visibility
|
||||
$visible = get_fast_modinfo($this->course)->get_section_info($this->section)->visible;
|
||||
|
||||
$DB->set_field('course_modules', 'instance', $instanceid, array('id' => $this->cm->id));
|
||||
|
||||
$sectionid = add_mod_to_section($this->cm);
|
||||
$DB->set_field('course_modules', 'section', $sectionid, array('id' => $this->cm->id));
|
||||
|
||||
set_coursemodule_visible($this->cm->id, true);
|
||||
set_coursemodule_visible($this->cm->id, $visible);
|
||||
if (!$visible) {
|
||||
$DB->set_field('course_modules', 'visibleold', 1, array('id' => $this->cm->id));
|
||||
}
|
||||
|
||||
// Rebuild the course cache and retrieve the final info about this module.
|
||||
rebuild_course_cache($this->course->id, true);
|
||||
@@ -636,7 +642,7 @@ class dndupload_ajax_processor {
|
||||
delete_course_module($this->cm->id);
|
||||
throw new moodle_exception('errorcreatingactivity', 'moodle', '', $this->module->name);
|
||||
}
|
||||
$mod = $info->cms[$this->cm->id];
|
||||
$mod = $info->get_cm($this->cm->id);
|
||||
$mod->groupmodelink = $this->cm->groupmodelink;
|
||||
$mod->groupmode = $this->cm->groupmode;
|
||||
|
||||
@@ -675,6 +681,7 @@ class dndupload_ajax_processor {
|
||||
$resp->elementid = 'module-'.$mod->id;
|
||||
$resp->commands = make_editing_buttons($mod, true, true, 0, $mod->sectionnum);
|
||||
$resp->onclick = $mod->get_on_click();
|
||||
$resp->visible = $mod->visible;
|
||||
|
||||
// if using groupings, then display grouping name
|
||||
if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', $this->context)) {
|
||||
|
||||
Reference in New Issue
Block a user