Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…ty as the section they are dragged onto
  • Loading branch information...
commit bdc678a4095e0a6cf97e7630af17bfdedf3fffe8 1 parent 3434298
@davosmith davosmith authored samhemelryk committed
Showing with 15 additions and 2 deletions.
  1. +6 −0 course/dndupload.js
  2. +9 −2 course/dnduploadlib.php
View
6 course/dndupload.js
@@ -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 + ')';
View
11 course/dnduploadlib.php
@@ -620,12 +620,18 @@ 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));
$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 @@ 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;
@@ -675,6 +681,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)) {
Please sign in to comment.
Something went wrong with that request. Please try again.