function local_catalog_get_section_courses($section_id) { global $DB; $all = local_catalog_get_courses("id"); $res = $DB->get_records('local_catalog_section_course', array('catalog_section_id' => $section_id), 'sequence'); $return = array(); $i = 0; foreach ($res as $r) { $key = $i; $return[$key] = $all[$r->catalog_id]; $return[$key]['local_catalog_section_course_id'] = $r->id; $i++; } return $return; }
public function definition() { $mform = $this->_form; // Don't forget the underscore! if (isset($this->_customdata['record']) && is_object($this->_customdata['record'])) { $data = $this->_customdata['record']; } $catalog_raw = local_catalog_get_courses(); $catalog = array(); foreach ($catalog_raw as $c) { $catalog[$c['id']] = $c['name']; } $mform->addElement('select', 'catalog_id', get_string('course'), $catalog, array('style' => 'width: 100%')); $mform->addRule('catalog_id', get_string('required'), 'required', null, 'client'); $this->add_action_buttons(); }
$catalog_id = required_param('catalog_id', PARAM_INT); $pageid = required_param('pageid', PARAM_INT); confirm_sesskey(); local_catalog_move_course_page("up", $pageid, $catalog_id); $displayindex = false; $displayedit = true; } if ($displayindex) { $data = new stdClass(); $data->returnurl = new moodle_url($returnurl); $data->sesskey = sesskey(); $data->deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('delete'), 'class' => 'iconsmall')); $data->editicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/edit'), 'alt' => get_string('edit'), 'class' => 'iconsmall')); $addform = new local_catalog_addcourse(new moodle_url($returnurl, array('action' => $addcourse))); $data->addform = $addform->render(); $data->courselist = local_catalog_get_courses(); if (count($data->courselist) > 0) { $data->has_courses = true; } $data->header = $OUTPUT->header(); $data->heading = $OUTPUT->heading(get_string('coursesetup', 'local_catalog')); $data->footer = $OUTPUT->footer(); echo $OUTPUT->render_from_template('local_catalog/courses_add', $data); } if ($displayedit) { local_catalog_get_all_microcredentials(); if (isset($catalog_id)) { $id = $catalog_id; } else { $id = required_param('id', PARAM_INT); }