Skip to content
Permalink
Browse files

MDL-35568 course dndupload - resources created with the same visibili…

…ty as the section they are dragged onto
  • Loading branch information...
davosmith committed Jan 4, 2013
1 parent 9da506c commit 0470a094e2c9998f0134e2c2ce5711dcf946fc21
Showing with 15 additions and 2 deletions.
  1. +6 −0 course/dndupload.js
  2. +9 −2 course/dnduploadlib.php
@@ -729,6 +729,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 + ')';
@@ -916,6 +919,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 + ')';
@@ -611,14 +611,20 @@ protected function finish_setup_course_module($instanceid) {
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));
// Rebuild the course cache after update action
rebuild_course_cache($this->course->id, true);
$this->course->modinfo = null; // Otherwise we will just get the old version back again.
$sectionid = course_add_cm_to_section($this->course, $this->cm->id, $this->section);
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));
}
// retrieve the final info about this module.
$info = get_fast_modinfo($this->course);
@@ -627,7 +633,7 @@ protected function finish_setup_course_module($instanceid) {
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;
@@ -666,6 +672,7 @@ protected function send_response($mod) {
$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)) {

0 comments on commit 0470a09

Please sign in to comment.
You can’t perform that action at this time.