//If all the courses are assigned to the plan, Disable the button. if ($moduleid) echo $OUTPUT->box(get_string('noteforassignmodule', 'local_curriculum')); else echo $OUTPUT->box(get_string('noteforassigndept', 'local_curriculum')); if ($departmentid) { $ccourses = $DB->get_records('local_cobaltcourses', array('departmentid' => $departmentid, 'visible' => 1)); $cobaltcourses = array(); foreach ($ccourses as $ccourse) { $cobaltcourses[$ccourse->id] = format_string($ccourse->fullname); } } else { $cobaltcourses = $hierarchy->get_courses_module($moduleid, $none = true); } if (empty($cobaltcourses)) { //Display message if no courses are available in the selected module. if ($moduleid) $record = $DB->get_field('local_module', 'fullname', array('id' => $moduleid)); if ($departmentid) $record = $DB->get_field('local_department', 'fullname', array('id' => $departmentid)); $linkurl=$CFG->wwwroot.'/local/modules/assigncourse.php?moduleid='.$moduleid; $linkname=get_string('assigncoursetomodule', 'local_curriculum'); echo $OUTPUT->box($hierarchy->cobalt_navigation_msg(get_string('nocoursesmodule', 'local_curriculum', $record)." Click here to ",$linkname,$linkurl)); }else { $table = new html_table(); $heading = '<a id="selectall" style="cursor:pointer;">' . get_string('selectall') . '</a>';
/** * @method assign_modules * @todo Assigns all the courses under the module to the plan * @param int $planid Curriculm plan ID * @param int $moveto Curriculum id * @param int $module Module ID. * */ function assign_modules($planid, $moveto, $module) { global $DB, $CFG; $hierarchy = new hierarchy(); $cobaltcourses = $hierarchy->get_courses_module($module, $none = true); $crs = array(); foreach ($cobaltcourses as $courseid => $coursename) { $params = array('courseid' => $courseid); if ($planid) { $params['planid'] = $planid; } else { $params['curriculumid'] = $moveto; } if (!$DB->record_exists('local_curriculum_plancourses', $params)) $crs[] = $courseid; } return $this->assign_courses($planid, $crs, $moveto, $module); }