/** * Form definition */ public function definition() { global $CFG, $DB, $PAGE; require_once $CFG->libdir . '/coursecatlib.php'; $PAGE->requires->js_call_amd('tool_cat/form', 'init', array()); $mform =& $this->_form; // Global update button. $mform->registerNoSubmitButton('updateform'); $mform->addElement('submit', 'updateform', 'Update Form', array('class' => 'hidden')); // Select a category. $mform->addElement('header', 'info', 'Category'); $catlist = \coursecat::make_categories_list('tool/cat:manage'); $categories = array(0 => 'Please select a category'); foreach ($catlist as $k => $v) { $categories[$k] = $v; } $mform->addElement('select', 'categoryid', 'Category', $categories); // Do we have a category? $category = optional_param('categoryid', false, PARAM_INT); if (!empty($category)) { $mform->setDefault('categoryid', $category); // Populate existing rules. $this->add_rule_fieldsets($category); // Print a blank rule-add row. $mform->addElement('header', 'rule_new', 'Add a new rule'); $mform->setExpanded('rule_new'); $this->add_rule_fieldset(); } $this->add_action_buttons(true, 'Save rules'); }
function category_selector($url) { global $OUTPUT; $str = ''; $choice = optional_param('category', 0, PARAM_INT); $categories = coursecat::make_categories_list(); $str .= $OUTPUT->single_select($url, 'category', $categories, $choice, array('' => get_string('all', 'enrol_delayedcohort'))); return $str; }
function definition() { global $CFG, $DB; $mform =& $this->_form; $category = $this->_customdata['category']; $editoroptions = $this->_customdata['editoroptions']; // get list of categories to use as parents, with site as the first one $options = array(); if (has_capability('moodle/category:manage', context_system::instance()) || $category->parent == 0) { $options[0] = get_string('top'); } if ($category->id) { // Editing an existing category. $options += coursecat::make_categories_list('moodle/category:manage', $category->id); if (empty($options[$category->parent])) { $options[$category->parent] = $DB->get_field('course_categories', 'name', array('id'=>$category->parent)); } $strsubmit = get_string('savechanges'); } else { // Making a new category $options += coursecat::make_categories_list('moodle/category:manage'); $strsubmit = get_string('createcategory'); } $mform->addElement('select', 'parent', get_string('parentcategory'), $options); $mform->addElement('text', 'name', get_string('categoryname'), array('size'=>'30')); $mform->addRule('name', get_string('required'), 'required', null); $mform->setType('name', PARAM_TEXT); $mform->addElement('text', 'idnumber', get_string('idnumbercoursecategory'),'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercoursecategory'); $mform->setType('idnumber', PARAM_RAW); $mform->addElement('editor', 'description_editor', get_string('description'), null, $editoroptions); $mform->setType('description_editor', PARAM_RAW); if (!empty($CFG->allowcategorythemes)) { $themes = array(''=>get_string('forceno')); $allthemes = get_list_of_themes(); foreach ($allthemes as $key=>$theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_'.$theme->name); } } $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $mform->addElement('hidden', 'id', 0); $mform->setType('id', PARAM_INT); $mform->setDefault('id', $category->id); $this->add_action_buttons(true, $strsubmit); }
protected function get_category_options($currentcontextid) { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; $displaylist = coursecat::make_categories_list('moodle/cohort:manage'); $options = array(); $syscontext = context_system::instance(); if (has_capability('moodle/cohort:manage', $syscontext)) { $options[$syscontext->id] = $syscontext->get_context_name(); } foreach ($displaylist as $cid => $name) { $context = context_coursecat::instance($cid); $options[$context->id] = $name; } // Always add current - this is not likely, but if the logic gets changed it might be a problem. if (!isset($options[$currentcontextid])) { $context = context::instance_by_id($currentcontextid, MUST_EXIST); $options[$context->id] = $syscontext->get_context_name(); } return $options; }
function definition() { global $CFG, $DB, $USER; $mform =& $this->_form; if ($pending = $DB->get_records('course_request', array('requester' => $USER->id))) { $mform->addElement('header', 'pendinglist', get_string('coursespending')); $list = array(); foreach ($pending as $cp) { $list[] = format_string($cp->fullname); } $list = implode(', ', $list); $mform->addElement('static', 'pendingcourses', get_string('courses'), $list); } $mform->addElement('header', 'coursedetails', get_string('courserequestdetails')); $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_TEXT); $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_TEXT); if (!empty($CFG->requestcategoryselection)) { $displaylist = coursecat::make_categories_list(); $mform->addElement('select', 'category', get_string('category'), $displaylist); $mform->setDefault('category', $CFG->defaultrequestcategory); $mform->addHelpButton('category', 'category'); } $mform->addElement('editor', 'summary_editor', get_string('summary'), null, course_request::summary_editor_options()); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); $mform->addElement('header', 'requestreason', get_string('courserequestreason')); $mform->addElement('textarea', 'reason', get_string('courserequestsupport'), array('rows' => '15', 'cols' => '50')); $mform->addRule('reason', get_string('missingreqreason'), 'required', null, 'client'); $mform->setType('reason', PARAM_TEXT); $this->add_action_buttons(true, get_string('requestcourse')); }
public function get_courses(&$mform) { global $DB, $CFG; require_once $CFG->dirroot . '/course/lib.php'; $buttonarray = array(); // Get courses with enabled completion. $courses = $DB->get_records('course', array('enablecompletion' => COMPLETION_ENABLED)); if (!empty($courses)) { require_once $CFG->libdir . '/coursecatlib.php'; $list = coursecat::make_categories_list(); $select = array(); $selected = array(); foreach ($courses as $c) { $select[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => context_course::instance($c->id))); } if ($this->id !== 0) { $selected = array_keys($this->params); } $settings = array('multiple' => 'multiple', 'size' => 20, 'style' => 'width:300px'); $mform->addElement('select', 'courses', get_string('addcourse', 'badges'), $select, $settings); $mform->addRule('courses', get_string('requiredcourse', 'badges'), 'required'); $mform->addHelpButton('courses', 'addcourse', 'badges'); $buttonarray[] =& $mform->createElement('submit', 'submitcourse', get_string('addcourse', 'badges')); $buttonarray[] =& $mform->createElement('submit', 'cancel', get_string('cancel')); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); $mform->addElement('hidden', 'addcourse', 'addcourse'); $mform->setType('addcourse', PARAM_TEXT); if ($this->id !== 0) { $mform->setDefault('courses', $selected); } $mform->setType('agg', PARAM_INT); } else { $mform->addElement('static', 'nocourses', '', get_string('error:nocourses', 'badges')); $buttonarray[] =& $mform->createElement('submit', 'cancel', get_string('continue')); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); } }
/** * Show form to create a new moodle course from the existing Turnitin Course * * @global type $CFG * @global type $OUTPUT * @return html the form object to create a new course */ function turnitintooltwo_show_browser_new_course_form() { global $OUTPUT, $CFG; $elements = array(); $elements[] = array('header', 'create_course_fieldset', get_string('createcourse', 'turnitintooltwo')); $displaylist = array(); $parentlist = array(); require_once $CFG->dirroot . "/course/lib.php"; if (file_exists($CFG->libdir . '/coursecatlib.php')) { require_once $CFG->libdir . '/coursecatlib.php'; $displaylist = coursecat::make_categories_list(''); } else { make_categories_list($displaylist, $parentlist, ''); } $elements[] = array('select', 'coursecategory', get_string('category'), '', $displaylist); $elements[] = array('text', 'coursename', get_string('coursetitle', 'turnitintooltwo'), ''); $elements[] = array('button', 'create_course', get_string('createcourse', 'turnitintooltwo')); $customdata["elements"] = $elements; $customdata["hide_submit"] = true; $customdata["disable_form_change_checker"] = true; $createcourseform = new turnitintooltwo_form('', $customdata); return $createcourseform->display(); }
/** * Returns full course categories trees to be used in html_writer::select() * * Calls {@link coursecat::make_categories_list()} to build the tree and * adds whitespace to denote nesting * * @return array array mapping coursecat id to the display name */ function make_categories_options() { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; $cats = coursecat::make_categories_list(); foreach ($cats as $key => $value) { $cats[$key] = str_repeat(' ', coursecat::get($key)->depth - 1) . $value; } return $cats; }
require_once $CFG->dirroot . '/course/lib.php'; require_once $CFG->libdir . '/coursecatlib.php'; $search = optional_param('search', '', PARAM_RAW); // search words $page = optional_param('page', 0, PARAM_INT); // which page to show $perpage = optional_param('perpage', '', PARAM_RAW); // how many per page, may be integer or 'all' $blocklist = optional_param('blocklist', 0, PARAM_INT); $modulelist = optional_param('modulelist', '', PARAM_PLUGIN); $tagid = optional_param('tagid', '', PARAM_INT); // searches for courses tagged with this tag id // List of minimum capabilities which user need to have for editing/moving course $capabilities = array('moodle/course:create', 'moodle/category:manage'); // Populate usercatlist with list of category id's with course:create and category:manage capabilities. $usercatlist = coursecat::make_categories_list($capabilities); $search = trim(strip_tags($search)); // trim & clean raw searched string $site = get_site(); $searchcriteria = array(); foreach (array('search', 'blocklist', 'modulelist', 'tagid') as $param) { if (!empty(${$param})) { $searchcriteria[$param] = ${$param}; } } $urlparams = array(); if ($perpage !== 'all' && !($perpage = (int) $perpage)) { // default number of courses per page $perpage = $CFG->coursesperpage; } else { $urlparams['perpage'] = $perpage;
/** * Renders HTML to display particular course category - list of it's subcategories and courses * * Invoked from /course/index.php * * @param int|stdClass|coursecat $category */ public function course_category($category) { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; $coursecat = coursecat::get(is_object($category) ? $category->id : $category); $site = get_site(); $output = ''; if (can_edit_in_category($coursecat->id)) { // Add 'Manage' button if user has permissions to edit this category. $managebutton = $this->single_button(new moodle_url('/course/management.php', array('categoryid' => $coursecat->id)), get_string('managecourses'), 'get'); $this->page->set_button($managebutton); } if (!$coursecat->id) { if (coursecat::count_all() == 1) { // There exists only one category in the system, do not display link to it $coursecat = coursecat::get_default(); $strfulllistofcourses = get_string('fulllistofcourses'); $this->page->set_title("{$site->shortname}: {$strfulllistofcourses}"); } else { $strcategories = get_string('categories'); $this->page->set_title("{$site->shortname}: {$strcategories}"); } } else { $this->page->set_title("{$site->shortname}: " . $coursecat->get_formatted_name()); // Print the category selector $output .= html_writer::start_tag('div', array('class' => 'categorypicker')); $select = new single_select(new moodle_url('/course/index.php'), 'categoryid', coursecat::make_categories_list(), $coursecat->id, null, 'switchcategory'); $select->set_label(get_string('categories') . ':'); $output .= $this->render($select); $output .= html_writer::end_tag('div'); // .categorypicker } // Print current category description $chelper = new coursecat_helper(); if ($description = $chelper->get_category_formatted_description($coursecat)) { $output .= $this->box($description, array('class' => 'generalbox info')); } // Prepare parameters for courses and categories lists in the tree $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_AUTO)->set_attributes(array('class' => 'category-browse category-browse-' . $coursecat->id)); $coursedisplayoptions = array(); $catdisplayoptions = array(); $browse = optional_param('browse', null, PARAM_ALPHA); $perpage = optional_param('perpage', $CFG->coursesperpage, PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $baseurl = new moodle_url('/course/index.php'); if ($coursecat->id) { $baseurl->param('categoryid', $coursecat->id); } if ($perpage != $CFG->coursesperpage) { $baseurl->param('perpage', $perpage); } $coursedisplayoptions['limit'] = $perpage; $catdisplayoptions['limit'] = $perpage; if ($browse === 'courses' || !$coursecat->has_children()) { $coursedisplayoptions['offset'] = $page * $perpage; $coursedisplayoptions['paginationurl'] = new moodle_url($baseurl, array('browse' => 'courses')); $catdisplayoptions['nodisplay'] = true; $catdisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'categories')); $catdisplayoptions['viewmoretext'] = new lang_string('viewallsubcategories'); } else { if ($browse === 'categories' || !$coursecat->has_courses()) { $coursedisplayoptions['nodisplay'] = true; $catdisplayoptions['offset'] = $page * $perpage; $catdisplayoptions['paginationurl'] = new moodle_url($baseurl, array('browse' => 'categories')); $coursedisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'courses')); $coursedisplayoptions['viewmoretext'] = new lang_string('viewallcourses'); } else { // we have a category that has both subcategories and courses, display pagination separately $coursedisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'courses', 'page' => 1)); $catdisplayoptions['viewmoreurl'] = new moodle_url($baseurl, array('browse' => 'categories', 'page' => 1)); } } $chelper->set_courses_display_options($coursedisplayoptions)->set_categories_display_options($catdisplayoptions); // Add course search form. $output .= $this->course_search_form(); // Display course category tree. $output .= $this->coursecat_tree($chelper, $coursecat); // Add action buttons $output .= $this->container_start('buttons'); $context = get_category_or_system_context($coursecat->id); if (has_capability('moodle/course:create', $context)) { // Print link to create a new course, for the 1st available category. if ($coursecat->id) { $url = new moodle_url('/course/edit.php', array('category' => $coursecat->id, 'returnto' => 'category')); } else { $url = new moodle_url('/course/edit.php', array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat')); } $output .= $this->single_button($url, get_string('addnewcourse'), 'get'); } ob_start(); if (coursecat::count_all() == 1) { print_course_request_buttons(context_system::instance()); } else { print_course_request_buttons($context); } $output .= ob_get_contents(); ob_end_clean(); $output .= $this->container_end(); return $output; }
/** * This function recursively travels the categories, building up a nice list * for display. It also makes an array that list all the parents for each * category. * * For example, if you have a tree of categories like: * Miscellaneous (id = 1) * Subcategory (id = 2) * Sub-subcategory (id = 4) * Other category (id = 3) * Then after calling this function you will have * $list = array(1 => 'Miscellaneous', 2 => 'Miscellaneous / Subcategory', * 4 => 'Miscellaneous / Subcategory / Sub-subcategory', * 3 => 'Other category'); * $parents = array(2 => array(1), 4 => array(1, 2)); * * If you specify $requiredcapability, then only categories where the current * user has that capability will be added to $list, although all categories * will still be added to $parents, and if you only have $requiredcapability * in a child category, not the parent, then the child catgegory will still be * included. * * If you specify the option $excluded, then that category, and all its children, * are omitted from the tree. This is useful when you are doing something like * moving categories, where you do not want to allow people to move a category * to be the child of itself. * * This function is deprecated! For list of categories use * coursecat::make_all_categories($requiredcapability, $excludeid, $separator) * For parents of one particular category use * coursecat::get($id)->get_parents() * * @deprecated since 2.5 * * @param array $list For output, accumulates an array categoryid => full category path name * @param array $parents For output, accumulates an array categoryid => list of parent category ids. * @param string/array $requiredcapability if given, only categories where the current * user has this capability will be added to $list. Can also be an array of capabilities, * in which case they are all required. * @param integer $excludeid Omit this category and its children from the lists built. * @param object $category Not used * @param string $path Not used */ function make_categories_list(&$list, &$parents, $requiredcapability = '', $excludeid = 0, $category = NULL, $path = "") { global $CFG, $DB; require_once $CFG->libdir . '/coursecatlib.php'; debugging('Global function make_categories_list() is deprecated. Please use ' . 'coursecat::make_categories_list() and coursecat::get_parents()', DEBUG_DEVELOPER); // For categories list use just this one function: if (empty($list)) { $list = array(); } $list += coursecat::make_categories_list($requiredcapability, $excludeid); // Building the list of all parents of all categories in the system is highly undesirable and hardly ever needed. // Usually user needs only parents for one particular category, in which case should be used: // coursecat::get($categoryid)->get_parents() if (empty($parents)) { $parents = array(); } $all = $DB->get_records_sql('SELECT id, parent FROM {course_categories} ORDER BY sortorder'); foreach ($all as $record) { if ($record->parent) { $parents[$record->id] = array_merge($parents[$record->parent], array($record->parent)); } else { $parents[$record->id] = array(); } } }
foreach ($all as $record) { if ($record->parent) { $catparentlist[$record->id] = array_merge($catparentlist[$record->parent], array($record->parent)); } else { $catparentlist[$record->id] = array(); } } // Populate usercatlist with list of category id's with required capabilities. $categories = cat_search_get_categories(); foreach ($categories as $category) { $context = context_coursecat::instance($category->id); if (has_all_capabilities($capabilities, $context)) { $usercatlist += coursecat::make_categories_list($capabilities, 0); } if (has_capability('local/contextadmin:viewcategories', $context)) { $usercatlist += coursecat::make_categories_list(array('local/contextadmin:viewcategories'), 0); } } $search = trim(strip_tags($search)); // Trim & clean raw searched string. if ($search) { $searchterms = explode(" ", $search); // Search for words independently. foreach ($searchterms as $key => $searchterm) { if (strlen($searchterm) < 2) { unset($searchterms[$key]); } } $search = trim(implode(" ", $searchterms)); } $site = get_site();
$output .= html_writer::tag('h2', get_string('restorationheader', 'turnitintooltwo')); $output .= html_writer::tag('p', get_string('coursebrowserdesc', 'turnitintooltwo')); $coursesearchform = html_writer::label(get_string('coursetitle', 'turnitintooltwo') . ': ', 'search_course_title'); $coursesearchform .= html_writer::empty_tag('input', array('type' => 'text', 'id' => 'search_course_title', 'name' => 'search_course_title')); $coursesearchform .= html_writer::label(get_string('integration', 'turnitintooltwo') . ': ', 'search_course_integration'); $coursesearchform .= html_writer::select($tiiintegrationids, 'search_course_integration', '', array('' => 'choosedots'), array('id' => 'search_course_integration')); $coursesearchform .= html_writer::label(get_string('ced', 'turnitintooltwo') . ': ', 'search_course_end_date'); $coursesearchform .= html_writer::empty_tag('input', array('type' => 'text', 'id' => 'search_course_end_date', 'name' => 'search_course_end_date')); $coursesearchform .= html_writer::tag('button', get_string('searchcourses', 'turnitintooltwo'), array("id" => "search_courses_button")); $output .= $OUTPUT->box($coursesearchform, 'generalbox', 'course_search_options'); $displaylist = array(); $parentlist = array(); require_once $CFG->dirroot . "/course/lib.php"; if (file_exists($CFG->libdir . '/coursecatlib.php')) { require_once $CFG->libdir . '/coursecatlib.php'; $displaylist = coursecat::make_categories_list(''); } else { make_categories_list($displaylist, $parentlist, ''); } $categoryselectlabel = html_writer::label(get_string('selectcoursecategory', 'turnitintooltwo'), 'create_course_category'); $categoryselect = html_writer::select($displaylist, 'create_course_category', '', array(), array('class' => 'create_course_category')); $createassigncheckbox = html_writer::checkbox('create_assign', 1, false, get_string('createmoodleassignments', 'turnitintooltwo'), array("class" => "create_assignment_checkbox")); $createassign = html_writer::tag('div', $createassigncheckbox, array("class" => "create_assign_checkbox_container")); $createbutton = html_writer::tag('button', get_string('createmoodlecourses', 'turnitintooltwo'), array("id" => "create_classes_button")); $output .= $OUTPUT->box($categoryselectlabel . " " . $categoryselect . $createassign . $createbutton, 'create_checkboxes navbar'); $table = new html_table(); $table->id = "courseBrowserTable"; $rows = array(); // Make up json array for drop down in table. $integrationidsjson = array(); foreach ($tiiintegrationids as $k => $v) {
/** * Form definition. */ function definition() { global $CFG, $PAGE; $mform = $this->_form; $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser', array(array('formid' => $mform->getAttribute('id')))); // recollim elements per configurar el formulari $course = $this->_customdata['course']; // this contains the data of this form $categorycontext = context_coursecat::instance(-1); //template if (!empty($course->id)) { $coursecontext = context_course::instance($course->id); $context = $coursecontext; } else { $coursecontext = null; $context = $categorycontext; } $this->course = $course; $this->context = $context; // Form definition --------------------------------- $mform->addElement('header', 'instance', get_string('general', 'form')); $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->setDefault('fullname', $course->fullname . date('YY')); //short name $mform->addElement('hidden', 'shortname', get_string('shortnamecourse')); //category //$mform->addElement('hidden', 'category', 1); // Verify permissions to change course category or keep current. if (empty($course->id)) { if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = coursecat::make_categories_list('moodle/course:create'); $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist); $mform->addHelpButton('category', 'coursecategory'); $mform->setDefault('category', $category->id); } else { $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $category->id); } } else { if (has_capability('moodle/course:changecategory', $coursecontext)) { $displaylist = coursecat::make_categories_list('moodle/course:create'); if (!isset($displaylist[$course->category])) { //always keep current $displaylist[$course->category] = coursecat::get($course->category, MUST_EXIST, true)->get_formatted_name(); } $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist); $mform->addHelpButton('category', 'coursecategory'); } else { //keep current $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $course->category); } } //start date $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->setDefault('startdate', time()); $days = count_course_days($course->id); //duration hint $mform->addHelpButton('duration', 'Rappelez-vous la durée des themes est de: ' . $days . ' jours'); //end date proposada $mform->addElement('date_selector', 'enddate', 'Date de finalisation'); $mform->setDefault('enddate', time() + $days * 24 * 3600); //make the course visible $mform->addElement('hidden', 'visible', 1); $this->add_action_buttons(); $mform->addElement('hidden', 'format', 'topics'); //we need to put an id, so we keep the old one, for the moment $mform->addElement('hidden', 'id', $course->id); $mform->setType('id', PARAM_INT); $this->set_data($course); }
function definition() { global $CFG; $mform =& $this->_form; $category = $this->_customdata['category']; $omega = new omega(); //con esto se obtienen las unidades academicas de Omega $unidadesAcademicas = $omega->listarUnidadesAcademicas(); $attributes = array('id' => 'unidad'); $mform->addElement('select', 'idOmega', 'Unidad Académica', $unidadesAcademicas, $attributes); //con esto se obtienen los periodos acad�micos de Omega $periodosAcademicos = $omega->listarPeriodosAcademicos(); $mform->addElement('select', 'idOmega', 'Periodo Académico', $periodosAcademicos); //lo siguiente permite desplegar una lista con todas las categorías de moodle anidadas $displaylist = coursecat::make_categories_list(); $mform->addElement('select', 'category', 'Categoría Moodle', $displaylist); //Y finalmente un select simple para designar si está o no activo. $mform->addElement('select', 'activo', 'Activo', array(0 => 'Desactivar', 1 => 'Activar')); //Select para configurar si el campo está activo o no $this->add_action_buttons(true, 'Crear'); }
/** * The standard form definiton. * @return void. */ public function definition() { global $CFG; $mform = $this->_form; $data = $this->_customdata['data']; $courseconfig = get_config('moodlecourse'); // Import options. $this->add_import_options(); // Course options. $mform->addElement('header', 'courseoptionshdr', get_string('courseprocess', 'tool_uploadcourse')); $mform->setExpanded('courseoptionshdr', true); $mform->addElement('text', 'options[shortnametemplate]', get_string('shortnametemplate', 'tool_uploadcourse'), 'maxlength="100" size="20"'); $mform->setType('options[shortnametemplate]', PARAM_RAW); $mform->addHelpButton('options[shortnametemplate]', 'shortnametemplate', 'tool_uploadcourse'); $mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE); $mform->disabledIf('options[shortnametemplate]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_UPDATE_ONLY); // Restore file is not in the array options on purpose, because formslib can't handle it! $contextid = $this->_customdata['contextid']; $mform->addElement('hidden', 'contextid', $contextid); $mform->setType('contextid', PARAM_INT); $mform->addElement('filepicker', 'restorefile', get_string('templatefile', 'tool_uploadcourse')); $mform->addHelpButton('restorefile', 'templatefile', 'tool_uploadcourse'); $mform->addElement('text', 'options[templatecourse]', get_string('coursetemplatename', 'tool_uploadcourse')); $mform->setType('options[templatecourse]', PARAM_TEXT); $mform->addHelpButton('options[templatecourse]', 'coursetemplatename', 'tool_uploadcourse'); $mform->addElement('selectyesno', 'options[reset]', get_string('reset', 'tool_uploadcourse')); $mform->setDefault('options[reset]', 0); $mform->disabledIf('options[reset]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_NEW); $mform->disabledIf('options[reset]', 'options[mode]', 'eq', tool_uploadcourse_processor::MODE_CREATE_ALL); $mform->disabledIf('options[reset]', 'options[allowresets]', 'eq', 0); $mform->addHelpButton('options[reset]', 'reset', 'tool_uploadcourse'); // Default values. $mform->addElement('header', 'defaultheader', get_string('defaultvalues', 'tool_uploadcourse')); $mform->setExpanded('defaultheader', true); $displaylist = coursecat::make_categories_list('moodle/course:create'); $mform->addElement('select', 'defaults[category]', get_string('coursecategory'), $displaylist); $mform->addHelpButton('defaults[category]', 'coursecategory'); $choices = array(); $choices['0'] = get_string('hide'); $choices['1'] = get_string('show'); $mform->addElement('select', 'defaults[visible]', get_string('visible'), $choices); $mform->addHelpButton('defaults[visible]', 'visible'); $mform->setDefault('defaults[visible]', $courseconfig->visible); $mform->addElement('date_selector', 'defaults[startdate]', get_string('startdate')); $mform->addHelpButton('defaults[startdate]', 'startdate'); $mform->setDefault('defaults[startdate]', time() + 3600 * 24); $mform->addElement('date_selector', 'defaults[enddate]', get_string('enddate'), array('optional' => true)); $mform->addHelpButton('defaults[enddate]', 'enddate'); $courseformats = get_sorted_course_formats(true); $formcourseformats = array(); foreach ($courseformats as $courseformat) { $formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}"); } $mform->addElement('select', 'defaults[format]', get_string('format'), $formcourseformats); $mform->addHelpButton('defaults[format]', 'format'); $mform->setDefault('defaults[format]', $courseconfig->format); if (!empty($CFG->allowcoursethemes)) { $themeobjects = get_list_of_themes(); $themes = array(); $themes[''] = get_string('forceno'); foreach ($themeobjects as $key => $theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_' . $theme->name); } } $mform->addElement('select', 'defaults[theme]', get_string('forcetheme'), $themes); } $languages = array(); $languages[''] = get_string('forceno'); $languages += get_string_manager()->get_list_of_translations(); $mform->addElement('select', 'defaults[lang]', get_string('forcelanguage'), $languages); $mform->setDefault('defaults[lang]', $courseconfig->lang); $options = range(0, 10); $mform->addElement('select', 'defaults[newsitems]', get_string('newsitemsnumber'), $options); $mform->addHelpButton('defaults[newsitems]', 'newsitemsnumber'); $mform->setDefault('defaults[newsitems]', $courseconfig->newsitems); $mform->addElement('selectyesno', 'defaults[showgrades]', get_string('showgrades')); $mform->addHelpButton('defaults[showgrades]', 'showgrades'); $mform->setDefault('defaults[showgrades]', $courseconfig->showgrades); $mform->addElement('selectyesno', 'defaults[showreports]', get_string('showreports')); $mform->addHelpButton('defaults[showreports]', 'showreports'); $mform->setDefault('defaults[showreports]', $courseconfig->showreports); if (!empty($CFG->legacyfilesinnewcourses)) { $mform->addElement('select', 'defaults[legacyfiles]', get_string('courselegacyfiles'), $choices); $mform->addHelpButton('defaults[legacyfiles]', 'courselegacyfiles'); if (!isset($courseconfig->legacyfiles)) { $courseconfig->legacyfiles = 0; } $mform->setDefault('defaults[legacyfiles]', $courseconfig->legacyfiles); } $choices = get_max_upload_sizes($CFG->maxbytes); $mform->addElement('select', 'defaults[maxbytes]', get_string('maximumupload'), $choices); $mform->addHelpButton('defaults[maxbytes]', 'maximumupload'); $mform->setDefault('defaults[maxbytes]', $courseconfig->maxbytes); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'defaults[groupmode]', get_string('groupmode', 'group'), $choices); $mform->addHelpButton('defaults[groupmode]', 'groupmode', 'group'); $mform->setDefault('defaults[groupmode]', $courseconfig->groupmode); $mform->addElement('selectyesno', 'defaults[groupmodeforce]', get_string('groupmodeforce', 'group')); $mform->addHelpButton('defaults[groupmodeforce]', 'groupmodeforce', 'group'); $mform->setDefault('defaults[groupmodeforce]', $courseconfig->groupmodeforce); // Hidden fields. $mform->addElement('hidden', 'importid'); $mform->setType('importid', PARAM_INT); $mform->addElement('hidden', 'previewrows'); $mform->setType('previewrows', PARAM_INT); $this->add_action_buttons(true, get_string('uploadcourses', 'tool_uploadcourse')); $this->set_data($data); }
$context = context_system::instance(); // Security. require_login(); $titlestr = get_string('newcourse', 'local_my'); // Start setting up the page. $params = array(); $PAGE->set_context($context); $PAGE->set_url('/local/my/create_course.php', $params); $PAGE->set_pagelayout('mydashboard'); $PAGE->set_pagetype('my-index'); $PAGE->set_title($titlestr); $PAGE->set_heading($titlestr); $PAGE->navbar->add(get_string('coursecreation', 'local_my')); $PAGE->navbar->add(get_string('standardcreation', 'local_my')); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('choosecategory', 'local_my')); $displaylist = coursecat::make_categories_list('moodle/course:create'); $table = new html_table(); $table->head = array(get_string('mycategories', 'local_my')); $table->align = array('left'); $table->width = '70%'; $table->size = array('100%'); foreach ($displaylist as $cid => $cat) { $linkurl = new moodle_url('/course/edit.php', array('category' => $cid, 'returnto' => 'category')); $link = '<a href="' . $linkurl . '">' . format_string($cat) . '</a>'; $table->data[] = array($link); } echo '<center>'; echo html_writer::table($table); echo '</center>'; echo $OUTPUT->footer();
$categories = coursecat::get_many($categoryids); } else { if ($for === 'selectedcategories') { // Bulk resort selected categories. $categoryids = optional_param_array('bcat', false, PARAM_INT); $sort = required_param('resortcategoriesby', PARAM_ALPHA); if ($categoryids === false) { break; } $categories = coursecat::get_many($categoryids); } else { if ($for === 'allcategories') { if ($sortcategoriesby && coursecat::get(0)->can_resort_subcategories()) { \core_course\management\helper::action_category_resort_subcategories(coursecat::get(0), $sortcategoriesby); } $categorieslist = coursecat::make_categories_list('moodle/category:manage'); $categoryids = array_keys($categorieslist); $categories = coursecat::get_many($categoryids); unset($categorieslist); } else { break; } } } foreach ($categories as $cat) { if ($sortcategoriesby && $cat->can_resort_subcategories()) { // Don't clean up here, we'll do it once we're all done. \core_course\management\helper::action_category_resort_subcategories($cat, $sortcategoriesby, false); } if ($sortcoursesby && $cat->can_resort_courses()) { \core_course\management\helper::action_category_resort_courses($cat, $sortcoursesby, false);
$temp->add($setting); if (get_config('theme_essential', 'enablecustomcategoryicon')) { // This is the descriptor for Custom Category Icons. $name = 'theme_essential/categoryiconinfo'; $heading = get_string('categoryiconinfo', 'theme_essential'); $information = get_string('categoryiconinfodesc', 'theme_essential'); $setting = new admin_setting_heading($name, $heading, $information); $temp->add($setting); // Get the default category icon. $defaultcategoryicon = get_config('theme_essential', 'defaultcategoryicon'); if (empty($defaultcategoryicon)) { $defaultcategoryicon = 'folder-open'; } // Get all category IDs and their pretty names. require_once $CFG->libdir . '/coursecatlib.php'; $coursecats = coursecat::make_categories_list(); // Go through all categories and create the necessary settings. foreach ($coursecats as $key => $value) { // Category Icons for each category. $name = 'theme_essential/categoryicon'; $title = $value; $description = get_string('categoryiconcategory', 'theme_essential', array('category' => $value)); $default = $defaultcategoryicon; $setting = new admin_setting_configtext($name . $key, $title, $description, $default); $setting->set_updatedcallback('theme_reset_all_caches'); $temp->add($setting); } unset($coursecats); } } $ADMIN->add('theme_essential', $temp);
/** * Renderers bulk actions that can be performed on courses in search returns * * @return string */ public function course_search_bulk_actions() { $html = html_writer::start_div('course-bulk-actions bulk-actions'); $html .= html_writer::div(get_string('coursebulkaction'), 'accesshide', array('tabindex' => '0')); $options = coursecat::make_categories_list('moodle/category:manage'); $select = html_writer::select($options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto')); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move')); $html .= $this->detail_pair(html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit)); $html .= html_writer::end_div(); return $html; }
/** * Form fields definition */ public function definition() { global $CFG, $DB, $COURSE; $mform = $this->_form; // General ------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('text', 'name', get_string('subcoursename', 'subcourse'), array('size' => '64')); if (!empty($CFG->formatstringstriptags)) { $mform->setType('name', PARAM_TEXT); } else { $mform->setType('name', PARAM_CLEANHTML); } $mform->addRule('name', null, 'required', null, 'client'); $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client'); if ($CFG->branch >= 29) { $this->standard_intro_elements(); } else { $this->add_intro_editor(); } // Referenced course --------------------------------------------------- $mform->addElement('header', 'section-refcourse', get_string('refcourse', 'subcourse')); $mform->setExpanded('section-refcourse'); $mform->addHelpButton('section-refcourse', 'refcourse', 'subcourse'); $mycourses = subcourse_available_courses(); $currentrefcourseid = isset($this->current->refcourse) ? $this->current->refcourse : null; $currentrefcoursename = null; $currentrefcourseavailable = false; if (!empty($currentrefcourseid)) { if ($currentrefcourseid == $COURSE->id) { // Invalid self-reference. $this->current->refcourse = 0; $includenoref = true; } else { $currentrefcoursename = $DB->get_field('course', 'fullname', array('id' => $currentrefcourseid), IGNORE_MISSING); } if ($currentrefcoursename === false) { // Reference to non-existing course. $this->current->refcourse = 0; $includenoref = true; } else { // Check if the currently set value is still available. foreach ($mycourses as $mycourse) { if ($mycourse->id == $currentrefcourseid) { $currentrefcourseavailable = true; break; } } } } if (!empty($currentrefcourseid) and !$currentrefcourseavailable) { // Currently referring to a course that is not available for us (e.g. the admin // has set up this Subcourse for the teacher or the teacher lost his role in the referred // course etc. Give them a chance to just keep such a reference. $mform->addElement('checkbox', 'refcoursecurrent', get_string('refcoursecurrent', 'subcourse'), format_string($currentrefcoursename)); $mform->setDefault('refcoursecurrent', 1); $includekeepref = true; } $options = array(); if (empty($mycourses)) { if (empty($includekeepref)) { $options = array(0 => get_string('nocoursesavailable', 'subcourse')); $mform->addElement('select', 'refcourse', get_string('refcourselabel', 'subcourse'), $options); } else { $mform->addElement('hidden', 'refcourse', 0); $mform->setType('refcourse', PARAM_INT); } } else { $catlist = coursecat::make_categories_list('', 0, ' / '); foreach ($mycourses as $mycourse) { if (empty($options[$catlist[$mycourse->category]])) { $options[$catlist[$mycourse->category]] = array(); } $courselabel = $mycourse->fullname . ' (' . $mycourse->shortname . ')'; $options[$catlist[$mycourse->category]][$mycourse->id] = $courselabel; if (empty($mycourse->visible)) { $hiddenlabel = ' ' . get_string('hiddencourse', 'subcourse'); $options[$catlist[$mycourse->category]][$mycourse->id] .= $hiddenlabel; } } if (!empty($includenoref)) { $options['---'] = array(0 => get_string('none')); } $mform->addElement('selectgroups', 'refcourse', get_string('refcourselabel', 'subcourse'), $options); if (!empty($includekeepref)) { $mform->disabledIf('refcourse', 'refcoursecurrent', 'checked'); } } $mform->addElement('checkbox', 'instantredirect', get_string('instantredirect', 'subcourse')); $mform->addHelpButton('instantredirect', 'instantredirect', 'subcourse'); // Common module settings ---------------------------------------------- $this->standard_coursemodule_elements(); // Common action buttons $this->add_action_buttons(); }
/** * Returns full course categories trees to be used in html_writer::select() * * Calls {@link coursecat::make_categories_list()} to build the tree and * adds whitespace to denote nesting * * @return array array mapping coursecat id to the display name */ function make_categories_options() { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; $cats = coursecat::make_categories_list('', 0, ' / '); foreach ($cats as $key => $value) { // Prefix the value with the number of spaces equal to category depth (number of separators in the value). $cats[$key] = str_repeat(' ', substr_count($value, ' / ')) . $value; } return $cats; }
/** * Recursive function to print all the categories ready for editing. * * @param html_table $table The table to add data to. * @param coursecat $category The category to render * @param int $depth The depth of the category. * @param bool $up True if this category can be moved up. * @param bool $down True if this category can be moved down. */ function print_category_edit(html_table $table, coursecat $category, $depth = -1, $up = false, $down = false) { global $OUTPUT; static $str = null; if (is_null($str)) { $str = new stdClass; $str->edit = new lang_string('edit'); $str->delete = new lang_string('delete'); $str->moveup = new lang_string('moveup'); $str->movedown = new lang_string('movedown'); $str->edit = new lang_string('editthiscategory'); $str->hide = new lang_string('hide'); $str->show = new lang_string('show'); $str->cohorts = new lang_string('cohorts', 'cohort'); $str->spacer = $OUTPUT->spacer().' '; } if ($category->id) { $categorycontext = context_coursecat::instance($category->id); $attributes = array(); $attributes['class'] = $category->visible ? '' : 'dimmed'; $attributes['title'] = $str->edit; $categoryurl = new moodle_url('/course/manage.php', array('categoryid' => $category->id, 'sesskey' => sesskey())); $categoryname = $category->get_formatted_name(); $categorypadding = str_repeat(' ', $depth); $categoryname = $categorypadding . html_writer::link($categoryurl, $categoryname, $attributes); $icons = array(); if (has_capability('moodle/category:manage', $categorycontext)) { // Edit category. $icons[] = $OUTPUT->action_icon( new moodle_url('/course/editcategory.php', array('id' => $category->id)), new pix_icon('t/edit', $str->edit, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->edit) ); // Delete category. $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('deletecat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->delete) ); // Change visibility. if (!empty($category->visible)) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('hidecat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/hide', $str->hide, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->hide) ); } else { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('showcat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/show', $str->show, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->show) ); } // Cohorts. if (has_any_capability(array('moodle/cohort:manage', 'moodle/cohort:view'), $categorycontext)) { $icons[] = $OUTPUT->action_icon( new moodle_url('/cohort/index.php', array('contextid' => $categorycontext->id)), new pix_icon('t/cohort', $str->cohorts, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->cohorts) ); } // Move up/down. if ($up) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('moveupcat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/up', $str->moveup, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->moveup) ); } else { $icons[] = $str->spacer; } if ($down) { $icons[] = $OUTPUT->action_icon( new moodle_url('/course/manage.php', array('movedowncat' => $category->id, 'sesskey' => sesskey())), new pix_icon('t/down', $str->movedown, 'moodle', array('class' => 'iconsmall')), null, array('title' => $str->movedown) ); } else { $icons[] = $str->spacer; } } $actions = ''; if (has_capability('moodle/category:manage', $categorycontext)) { $popupurl = new moodle_url('/course/manage.php', array('movecat' => $category->id, 'sesskey' => sesskey())); $tempdisplaylist = array(0 => get_string('top')) + coursecat::make_categories_list('moodle/category:manage', $category->id); $select = new single_select($popupurl, 'movetocat', $tempdisplaylist, $category->parent, null, "moveform$category->id"); $select->set_label(get_string('frontpagecategorynames'), array('class' => 'accesshide')); $actions = $OUTPUT->render($select); } $table->data[] = new html_table_row(array( // Category name. new html_table_cell($categoryname), // Course count. new html_table_cell($category->coursecount), // Icons. new html_table_cell(join(' ', $icons)), // Actions. new html_table_cell($actions) )); } if ($categories = $category->get_children()) { // Print all the children recursively. $countcats = count($categories); $count = 0; $first = true; $last = false; foreach ($categories as $cat) { $count++; if ($count == $countcats) { $last = true; } $up = $first ? false : true; $down = $last ? false : true; $first = false; print_category_edit($table, $cat, $depth+1, $up, $down); } } }
/** * Prints the "classical" "My Courses" area */ function local_my_print_authored_courses(&$excludedcourses, &$courseareacourses) { global $OUTPUT, $CFG, $DB; $debug = 0; $myauthcourses = local_get_my_authoring_courses(); // Post 2.5. include_once $CFG->dirroot . '/lib/coursecatlib.php'; $mycatlist = coursecat::make_categories_list('moodle/course:create'); if (!empty($excludedcourses)) { foreach (array_keys($excludedcourses) as $cid) { if ($debug) { echo "rejected authored {$cid} as excluded</br/>"; } unset($myauthcourses[$cid]); } } $str = ''; $hascontent = false; if (!empty($mycatlist) || !empty($myauthcourses)) { $str .= '<div class="block block_my_authored_courses">'; $str .= '<div class="header">'; $str .= '<div class="title">'; $str .= '<h2>' . get_string('myauthoringcourses', 'local_my') . '</h2>'; $str .= '</div>'; $str .= '</div>'; $str .= '<div class="content">'; $hascontent = true; } if (!empty($mycatlist)) { $levels = CONTEXT_COURSE . ',' . CONTEXT_COURSECAT; $cancreate = local_my_has_capability_somewhere('moodle/course:create', false, false, true, $levels); $catids = array_keys($mycatlist); $firstcatid = array_shift($catids); $button0 = ''; $button1 = ''; $button2 = ''; $button3 = ''; if ($cancreate) { $params = array('view' => 'courses', 'categoryid' => $firstcatid); $label = get_string('managemycourses', 'local_my'); $button0 = $OUTPUT->single_button(new moodle_url('/course/management.php', $params), $label); $label = get_string('newcourse', 'local_my'); $button1 = $OUTPUT->single_button(new moodle_url('/local/my/create_course.php'), $label); if (is_dir($CFG->dirroot . '/local/coursetemplates')) { $config = get_config('local_coursetemplates'); if ($config->enabled && $config->templatecategory) { $params = array('category' => $config->templatecategory, 'visible' => 1); if ($DB->count_records('course', $params)) { $buttonurl = new moodle_url('/local/coursetemplates/index.php'); $button2 = $OUTPUT->single_button($buttonurl, get_string('newcoursefromtemplate', 'local_my')); } } } // Need fetch a context where user has effective capability. $powercontext = local_get_one_of_my_power_contexts(); if ($powercontext) { $params = array('contextid' => $powercontext->id); $buttonurl = new moodle_url('/backup/restorefile.php', $params); $button3 = $OUTPUT->single_button($buttonurl, get_string('restorecourse', 'local_my')); } } $str .= '<div class="right-button course-creation-buttons">' . $button0 . ' ' . $button1 . ' ' . $button2 . ' ' . $button3 . '</div>'; } if (!empty($myauthcourses)) { $str .= '<table id="myauthoredcourselist" width="100%" class="generaltable courselist">'; $str .= '<tr valign="top"><td>'; if (count($myauthcourses) < 0 + @$config->maxoverviewedlistsize) { $str .= local_print_course_overview($myauthcourses, true, array('gaugewidth' => 0, 'gaugeheight' => 0)); } else { if (count($myauthcourses) < 0 + @$config->maxuncategorizedlistsize) { // Solve a performance issue for people having wide access to courses. $options = array('noheading' => true, 'withcats' => false, 'nocompletion' => true, 'gaugewidth' => 0, 'gaugeheight' => 0); } else { // Solve a performance issue for people having wide access to courses. $options = array('noheading' => true, 'withcats' => true, 'nocompletion' => true, 'gaugewidth' => 0, 'gaugeheight' => 0); } $str .= local_my_print_courses('myauthcourses', $myauthcourses, $options, true); } $str .= '</td></tr>'; $str .= '</table>'; if ($debug) { foreach ($myauthcourses as $ac) { echo "exclude authored {$ac->id} as authored <br/>"; } } $excludedcourses = $excludedcourses + $myauthcourses; } if ($hascontent) { $str .= '</div>'; $str .= '</div>'; } return $str; }
/** * Returns an array of course categories * @return array of course categories */ function get_course_categories() { global $CFG; require_once $CFG->libdir . '/coursecatlib.php'; return array(0 => get_string('anycategory', 'filters')) + coursecat::make_categories_list(); }
/** * Form definition. */ function definition() { global $CFG, $PAGE,$USER,$DB; $mform = $this->_form; $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser', array(array('formid' => $mform->getAttribute('id')))); $course = $this->_customdata['course']; // this contains the data of this form //print_object($course); $category = $this->_customdata['category']; $editoroptions = $this->_customdata['editoroptions']; $returnto = $this->_customdata['returnto']; $systemcontext = context_system::instance(); $categorycontext = context_coursecat::instance($category->id); if (!empty($course->id)) { $coursecontext = context_course::instance($course->id); $context = $coursecontext; } else { $coursecontext = null; $context = $categorycontext; } $courseconfig = get_config('moodlecourse'); $this->course = $course; $this->context = $context; // Form definition with new course defaults. $mform->addElement('header','general', get_string('general', 'form')); $mform->addElement('hidden', 'returnto', null); $mform->setType('returnto', PARAM_ALPHANUM); $mform->setConstant('returnto', $returnto); /* * EA_NK23-02-2015 * Added cost center field */ $is_manager = $DB->record_exists_sql("SELECT ra.userid FROM {role_assignments} as ra JOIN {role} as r ON ra.roleid=r.id WHERE r.archetype='manager' AND ra.userid={$USER->id}"); if(is_siteadmin()) { /*==================strated by raju.t for admin created courses goes to HR department on 9-11-2015=============*/ $admincostcenters=user_wise_department(); //print_object($admincostcenters); $mform->addElement('select', 'costcenter', get_string('pluginname', 'local_costcenter'), $admincostcenters); /*==================Ended by raju.t for admin created courses goes to HR department on 9-11-2015=============*/ }elseif(!is_siteadmin()){ $admincostcenters=user_wise_department(); $mform->addElement('select', 'costcenter', get_string('pluginname', 'local_costcenter'), $admincostcenters); } //$costcenter = $DB->get_records_sql_menu("SELECT cc.id,cc.fullname FROM mdl_local_userdata ud JOIN mdl_local_costcenter cc ON ud.costcenterid=cc.id WHERE ud.userid={$USER->id}"); //$mform->addElement('hidden','costcenter'); //$mform->setDefault('costcenter',$costcenter->id); //$mform->addElement('static', 'costcenterid', get_string('pluginname', 'local_costcenter'), $costcenter->fullname); $mform->setType('costcenter', PARAM_RAW); /* EA_NK23-02-2015 Customization ends here */ $mform->addElement('text','fullname', get_string('fullnamecourse'),'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) { $mform->hardFreeze('shortname'); $mform->setConstant('shortname', $course->shortname); } // Verify permissions to change course category or keep current. if (empty($course->id)) { if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = coursecat::make_categories_list('moodle/course:create'); /*======================Started By Raju.T for Disaply Course Categories based on training manager deparment on 9-11-2015============*/ if(is_siteadmin()){ $admincoursecategory=department_category_course(); $mform->addElement('select', 'category', get_string('coursecategory'), $admincoursecategory); /*==================Ended by raju.t for admin created courses goes to HR department on 9-11-2015=============*/ }else{ /*======================Ended By Raju.T for Disaply Course Categories based on training manager deparment on 9-11-2015============*/ $admincoursecategory=department_category_course(); $mform->addElement('select', 'category', get_string('coursecategory'), $admincoursecategory); $userdepartment_exist=$DB->record_exists('local_userdata',array('userid'=>$USER->id)); if($userdepartment_exist==1){ $userdepartment=$DB->get_record('local_userdata',array('userid'=>$USER->id)); if($userdepartment->lms_category=="AST" || $userdepartment->lms_category=="AST-EXT"){ $trainer_type_options=array(null=>'----Select to----',T=>'Trainer',SM=>'Sales Manager'); $mform->addElement('select', 'assignedto', get_string('assigne_to'), $trainer_type_options); //$mform->setConstant('category', $category->id); //$mform->setDefault('assignedto', $course->assignedto); } } /*==================strated by raju.t for admin created courses goes to HR department on 9-11-2015=============*/ } $mform->addHelpButton('category', 'coursecategory'); $mform->setDefault('category', $category->id); $mform->addElement('text','duration',get_string('course_duration'),'maxlength="100" size="10"'); if(!empty($course->assignedto)){ $mform->setDefault('duration', $course->duration); }else{ $mform->setDefault('duration','0'); } $mform->setType('duration', PARAM_RAW); $mform->addRule('duration', get_string('possitiveonly'), 'regex', '#^(0|[1-9][0-9]*)$#'); } else { $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $category->id); } } else { if (has_capability('moodle/course:changecategory', $coursecontext)) { $admincoursecategory=department_category_course(); $mform->addElement('select', 'category', get_string('coursecategory'), $admincoursecategory); } else { //keep current $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $course->category); } $userdepartment_exist=$DB->record_exists('local_userdata',array('userid'=>$USER->id)); if($userdepartment_exist==1){ $userdepartment=$DB->get_record('local_userdata',array('userid'=>$USER->id)); if($userdepartment->lms_category=="AST" || $userdepartment->lms_category=="AST-EXT"){ $trainer_type_options=array(null=>'----Select to----',T=>'Trainer',SM=>'Sales Manager'); $mform->addElement('select', 'assignedto', get_string('assigne_to'), $trainer_type_options); //$mform->setConstant('category', $category->id); //$mform->setDefault('assignedto', $course->assignedto); } } /*==================strated by raju.t for admin created courses goes to HR department on 9-11-2015=============*/ $mform->addElement('text','duration',get_string('course_duration'),'maxlength="100" size="10"'); if(!empty($course->assignedto)){ $mform->setDefault('duration', $course->duration); }else{ $mform->setDefault('duration','0'); } $mform->setType('duration', PARAM_RAW); $mform->addRule('duration', get_string('possitiveonly'), 'regex', '#^(0|[1-9][0-9]*)$#'); } $choices = array(); $choices['0'] = get_string('hide'); $choices['1'] = get_string('show'); $mform->addElement('select', 'visible', get_string('visible'), $choices); $mform->addHelpButton('visible', 'visible'); $mform->setDefault('visible', $courseconfig->visible); if (!empty($course->id)) { if (!has_capability('moodle/course:visibility', $coursecontext)) { $mform->hardFreeze('visible'); $mform->setConstant('visible', $course->visible); } } else { if (!guess_if_creator_will_have_course_capability('moodle/course:visibility', $categorycontext)) { $mform->hardFreeze('visible'); $mform->setConstant('visible', $courseconfig->visible); } } $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->addHelpButton('startdate', 'startdate'); $mform->setDefault('startdate', time() + 3600 * 24); $mform->addElement('text','idnumber', get_string('idnumbercourse'),'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercourse'); $mform->setType('idnumber', PARAM_RAW); if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) { $mform->hardFreeze('idnumber'); $mform->setConstants('idnumber', $course->idnumber); } // Description. $mform->addElement('header', 'descriptionhdr', get_string('description')); $mform->setExpanded('descriptionhdr'); $mform->addElement('editor','summary_editor', get_string('coursesummary'), null, $editoroptions); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); $summaryfields = 'summary_editor'; if ($overviewfilesoptions = course_overviewfiles_options($course)) { $mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions); $mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles'); $summaryfields .= ',overviewfiles_filemanager'; } if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) { // Remove the description header it does not contain anything any more. $mform->removeElement('descriptionhdr'); $mform->hardFreeze($summaryfields); } // Course format. $mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin')); $courseformats = get_sorted_course_formats(true); $formcourseformats = array(); foreach ($courseformats as $courseformat) { $formcourseformats[$courseformat] = get_string('pluginname', "format_$courseformat"); } if (isset($course->format)) { $course->format = course_get_format($course)->get_format(); // replace with default if not found if (!in_array($course->format, $courseformats)) { // this format is disabled. Still display it in the dropdown $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_'.$course->format)); } } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->addHelpButton('format', 'format'); $mform->setDefault('format', $courseconfig->format); // Button to update format-specific options on format change (will be hidden by JavaScript). $mform->registerNoSubmitButton('updatecourseformat'); $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate')); // Just a placeholder for the course format options. $mform->addElement('hidden', 'addcourseformatoptionshere'); $mform->setType('addcourseformatoptionshere', PARAM_BOOL); // Appearance. $mform->addElement('header', 'appearancehdr', get_string('appearance')); if (!empty($CFG->allowcoursethemes)) { $themeobjects = get_list_of_themes(); $themes=array(); $themes[''] = get_string('forceno'); foreach ($themeobjects as $key=>$theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_'.$theme->name); } } $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $languages=array(); $languages[''] = get_string('forceno'); $languages += get_string_manager()->get_list_of_translations(); $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); $mform->setDefault('lang', $courseconfig->lang); // Multi-Calendar Support - see MDL-18375. $calendartypes = \core_calendar\type_factory::get_list_of_calendar_types(); // We do not want to show this option unless there is more than one calendar type to display. if (count($calendartypes) > 1) { $calendars = array(); $calendars[''] = get_string('forceno'); $calendars += $calendartypes; $mform->addElement('select', 'calendartype', get_string('forcecalendartype', 'calendar'), $calendars); } $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $mform->addHelpButton('newsitems', 'newsitemsnumber'); $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->addHelpButton('showgrades', 'showgrades'); $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->addHelpButton('showreports', 'showreports'); $mform->setDefault('showreports', $courseconfig->showreports); // Files and uploads. $mform->addElement('header', 'filehdr', get_string('filesanduploads')); if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) { if (empty($course->legacyfiles)) { //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet $choices = array('0'=>get_string('no'), '2'=>get_string('yes')); } else { $choices = array('1'=>get_string('no'), '2'=>get_string('yes')); } $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices); $mform->addHelpButton('legacyfiles', 'courselegacyfiles'); if (!isset($courseconfig->legacyfiles)) { // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses $courseconfig->legacyfiles = 0; } $mform->setDefault('legacyfiles', $courseconfig->legacyfiles); } // Handle non-existing $course->maxbytes on course creation. $coursemaxbytes = !isset($course->maxbytes) ? null : $course->maxbytes; // Let's prepare the maxbytes popup. $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $coursemaxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->addHelpButton('maxbytes', 'maximumupload'); $mform->setDefault('maxbytes', $courseconfig->maxbytes); // Completion tracking. if (completion_info::is_enabled_for_site()) { $mform->addElement('header', 'completionhdr', get_string('completion', 'completion')); $mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion')); $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); $mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion'); } else { $mform->addElement('hidden', 'enablecompletion'); $mform->setType('enablecompletion', PARAM_INT); $mform->setDefault('enablecompletion', 0); } enrol_course_edit_form($mform, $course, $context); $mform->addElement('header','groups', get_string('groupsettingsheader', 'group')); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices); $mform->addHelpButton('groupmode', 'groupmode', 'group'); $mform->setDefault('groupmode', $courseconfig->groupmode); $mform->addElement('selectyesno', 'groupmodeforce', get_string('groupmodeforce', 'group')); $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group'); $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); //default groupings selector $options = array(); $options[0] = get_string('none'); $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); // Customizable role names in this course. $mform->addElement('header','rolerenaming', get_string('rolerenaming')); $mform->addHelpButton('rolerenaming', 'rolerenaming'); if ($roles = get_all_roles()) { $roles = role_fix_names($roles, null, ROLENAME_ORIGINAL); $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE); foreach ($roles as $role) { $mform->addElement('text', 'role_'.$role->id, get_string('yourwordforx', '', $role->localname)); $mform->setType('role_'.$role->id, PARAM_TEXT); } } $this->add_action_buttons(); $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); // Finally set the current form data $this->set_data($course); }
function definition() { global $USER, $CFG, $DB, $PAGE; $mform = $this->_form; $PAGE->requires->yui_module('moodle-course-formatchooser', 'M.course.init_formatchooser', array(array('formid' => $mform->getAttribute('id')))); $course = $this->_customdata['course']; // this contains the data of this form $category = $this->_customdata['category']; $editoroptions = $this->_customdata['editoroptions']; $returnto = $this->_customdata['returnto']; $systemcontext = context_system::instance(); $categorycontext = context_coursecat::instance($category->id); if (!empty($course->id)) { $coursecontext = context_course::instance($course->id); $context = $coursecontext; } else { $coursecontext = null; $context = $categorycontext; } $courseconfig = get_config('moodlecourse'); $this->course = $course; $this->context = $context; /// form definition with new course defaults //-------------------------------------------------------------------------------- $mform->addElement('header', 'general', get_string('general', 'form')); $mform->addElement('hidden', 'returnto', null); $mform->setType('returnto', PARAM_ALPHANUM); $mform->setConstant('returnto', $returnto); $mform->addElement('text', 'fullname', get_string('fullnamecourse'), 'maxlength="254" size="50"'); $mform->addHelpButton('fullname', 'fullnamecourse'); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changefullname', $coursecontext)) { $mform->hardFreeze('fullname'); $mform->setConstant('fullname', $course->fullname); } $mform->addElement('text', 'shortname', get_string('shortnamecourse'), 'maxlength="100" size="20"'); $mform->addHelpButton('shortname', 'shortnamecourse'); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_TEXT); if (!empty($course->id) and !has_capability('moodle/course:changeshortname', $coursecontext)) { $mform->hardFreeze('shortname'); $mform->setConstant('shortname', $course->shortname); } // Verify permissions to change course category or keep current. if (empty($course->id)) { if (has_capability('moodle/course:create', $categorycontext)) { $displaylist = coursecat::make_categories_list('moodle/course:create'); $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist); $mform->addHelpButton('category', 'coursecategory'); $mform->setDefault('category', $category->id); } else { $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $category->id); } } else { if (has_capability('moodle/course:changecategory', $coursecontext)) { $displaylist = coursecat::make_categories_list('moodle/course:create'); if (!isset($displaylist[$course->category])) { //always keep current $displaylist[$course->category] = coursecat::get($course->category)->get_formatted_name(); } $mform->addElement('select', 'category', get_string('coursecategory'), $displaylist); $mform->addHelpButton('category', 'coursecategory'); } else { //keep current $mform->addElement('hidden', 'category', null); $mform->setType('category', PARAM_INT); $mform->setConstant('category', $course->category); } } $choices = array(); $choices['0'] = get_string('hide'); $choices['1'] = get_string('show'); $mform->addElement('select', 'visible', get_string('visible'), $choices); $mform->addHelpButton('visible', 'visible'); $mform->setDefault('visible', $courseconfig->visible); if (!has_capability('moodle/course:visibility', $context)) { $mform->hardFreeze('visible'); if (!empty($course->id)) { $mform->setConstant('visible', $course->visible); } else { $mform->setConstant('visible', $courseconfig->visible); } } $mform->addElement('date_selector', 'startdate', get_string('startdate')); $mform->addHelpButton('startdate', 'startdate'); $mform->setDefault('startdate', time() + 3600 * 24); $mform->addElement('text', 'idnumber', get_string('idnumbercourse'), 'maxlength="100" size="10"'); $mform->addHelpButton('idnumber', 'idnumbercourse'); $mform->setType('idnumber', PARAM_RAW); if (!empty($course->id) and !has_capability('moodle/course:changeidnumber', $coursecontext)) { $mform->hardFreeze('idnumber'); $mform->setConstants('idnumber', $course->idnumber); } // Description. $mform->addElement('header', 'descriptionhdr', get_string('description')); $mform->setExpanded('descriptionhdr'); $mform->addElement('editor', 'summary_editor', get_string('coursesummary'), null, $editoroptions); $mform->addHelpButton('summary_editor', 'coursesummary'); $mform->setType('summary_editor', PARAM_RAW); $summaryfields = 'summary_editor'; if ($overviewfilesoptions = course_overviewfiles_options($course)) { $mform->addElement('filemanager', 'overviewfiles_filemanager', get_string('courseoverviewfiles'), null, $overviewfilesoptions); $mform->addHelpButton('overviewfiles_filemanager', 'courseoverviewfiles'); $summaryfields .= ',overviewfiles_filemanager'; } if (!empty($course->id) and !has_capability('moodle/course:changesummary', $coursecontext)) { // Remove the description header it does not contain anything any more. $mform->removeElement('descriptionhdr'); $mform->hardFreeze($summaryfields); } // Course format. $mform->addElement('header', 'courseformathdr', get_string('type_format', 'plugin')); $courseformats = get_sorted_course_formats(true); $formcourseformats = array(); foreach ($courseformats as $courseformat) { $formcourseformats[$courseformat] = get_string('pluginname', "format_{$courseformat}"); } if (isset($course->format)) { $course->format = course_get_format($course)->get_format(); // replace with default if not found if (!in_array($course->format, $courseformats)) { // this format is disabled. Still display it in the dropdown $formcourseformats[$course->format] = get_string('withdisablednote', 'moodle', get_string('pluginname', 'format_' . $course->format)); } } $mform->addElement('select', 'format', get_string('format'), $formcourseformats); $mform->addHelpButton('format', 'format'); $mform->setDefault('format', $courseconfig->format); // Button to update format-specific options on format change (will be hidden by JavaScript). $mform->registerNoSubmitButton('updatecourseformat'); $mform->addElement('submit', 'updatecourseformat', get_string('courseformatudpate')); // Just a placeholder for the course format options. $mform->addElement('hidden', 'addcourseformatoptionshere'); $mform->setType('addcourseformatoptionshere', PARAM_BOOL); // Appearance. $mform->addElement('header', 'appearancehdr', get_string('appearance')); if (!empty($CFG->allowcoursethemes)) { $themeobjects = get_list_of_themes(); $themes = array(); $themes[''] = get_string('forceno'); foreach ($themeobjects as $key => $theme) { if (empty($theme->hidefromselector)) { $themes[$key] = get_string('pluginname', 'theme_' . $theme->name); } } $mform->addElement('select', 'theme', get_string('forcetheme'), $themes); } $languages = array(); $languages[''] = get_string('forceno'); $languages += get_string_manager()->get_list_of_translations(); $mform->addElement('select', 'lang', get_string('forcelanguage'), $languages); $mform->setDefault('lang', $courseconfig->lang); $options = range(0, 10); $mform->addElement('select', 'newsitems', get_string('newsitemsnumber'), $options); $mform->addHelpButton('newsitems', 'newsitemsnumber'); $mform->setDefault('newsitems', $courseconfig->newsitems); $mform->addElement('selectyesno', 'showgrades', get_string('showgrades')); $mform->addHelpButton('showgrades', 'showgrades'); $mform->setDefault('showgrades', $courseconfig->showgrades); $mform->addElement('selectyesno', 'showreports', get_string('showreports')); $mform->addHelpButton('showreports', 'showreports'); $mform->setDefault('showreports', $courseconfig->showreports); // Files and uploads. $mform->addElement('header', 'filehdr', get_string('filesanduploads')); if (!empty($course->legacyfiles) or !empty($CFG->legacyfilesinnewcourses)) { if (empty($course->legacyfiles)) { //0 or missing means no legacy files ever used in this course - new course or nobody turned on legacy files yet $choices = array('0' => get_string('no'), '2' => get_string('yes')); } else { $choices = array('1' => get_string('no'), '2' => get_string('yes')); } $mform->addElement('select', 'legacyfiles', get_string('courselegacyfiles'), $choices); $mform->addHelpButton('legacyfiles', 'courselegacyfiles'); if (!isset($courseconfig->legacyfiles)) { // in case this was not initialised properly due to switching of $CFG->legacyfilesinnewcourses $courseconfig->legacyfiles = 0; } $mform->setDefault('legacyfiles', $courseconfig->legacyfiles); } // Handle non-existing $course->maxbytes on course creation. $coursemaxbytes = !isset($course->maxbytes) ? null : $course->maxbytes; // Let's prepare the maxbytes popup. $choices = get_max_upload_sizes($CFG->maxbytes, 0, 0, $coursemaxbytes); $mform->addElement('select', 'maxbytes', get_string('maximumupload'), $choices); $mform->addHelpButton('maxbytes', 'maximumupload'); $mform->setDefault('maxbytes', $courseconfig->maxbytes); // Completion tracking. if (completion_info::is_enabled_for_site()) { $mform->addElement('header', 'completionhdr', get_string('completion', 'completion')); $mform->addElement('selectyesno', 'enablecompletion', get_string('enablecompletion', 'completion')); $mform->setDefault('enablecompletion', $courseconfig->enablecompletion); $mform->addHelpButton('enablecompletion', 'enablecompletion', 'completion'); } else { $mform->addElement('hidden', 'enablecompletion'); $mform->setType('enablecompletion', PARAM_INT); $mform->setDefault('enablecompletion', 0); } //-------------------------------------------------------------------------------- enrol_course_edit_form($mform, $course, $context); //-------------------------------------------------------------------------------- $mform->addElement('header', 'groups', get_string('groups', 'group')); $choices = array(); $choices[NOGROUPS] = get_string('groupsnone', 'group'); $choices[SEPARATEGROUPS] = get_string('groupsseparate', 'group'); $choices[VISIBLEGROUPS] = get_string('groupsvisible', 'group'); $mform->addElement('select', 'groupmode', get_string('groupmode', 'group'), $choices); $mform->addHelpButton('groupmode', 'groupmode', 'group'); $mform->setDefault('groupmode', $courseconfig->groupmode); $mform->addElement('selectyesno', 'groupmodeforce', get_string('groupmodeforce', 'group')); $mform->addHelpButton('groupmodeforce', 'groupmodeforce', 'group'); $mform->setDefault('groupmodeforce', $courseconfig->groupmodeforce); //default groupings selector $options = array(); $options[0] = get_string('none'); $mform->addElement('select', 'defaultgroupingid', get_string('defaultgrouping', 'group'), $options); //-------------------------------------------------------------------------------- /// customizable role names in this course //-------------------------------------------------------------------------------- $mform->addElement('header', 'rolerenaming', get_string('rolerenaming')); $mform->addHelpButton('rolerenaming', 'rolerenaming'); if ($roles = get_all_roles()) { $roles = role_fix_names($roles, null, ROLENAME_ORIGINAL); $assignableroles = get_roles_for_contextlevels(CONTEXT_COURSE); foreach ($roles as $role) { $mform->addElement('text', 'role_' . $role->id, get_string('yourwordforx', '', $role->localname)); $mform->setType('role_' . $role->id, PARAM_TEXT); } } //-------------------------------------------------------------------------------- $this->add_action_buttons(); //-------------------------------------------------------------------------------- $mform->addElement('hidden', 'id', null); $mform->setType('id', PARAM_INT); /// finally set the current form data //-------------------------------------------------------------------------------- $this->set_data($course); }
public function storage_report($usagedata) { $size = $this->convert_size($usagedata['total']); $o = get_string('storagetotalusage', 'mediagallery', $size); $o .= html_writer::empty_tag('br'); $o .= html_writer::empty_tag('br'); $catlist = coursecat::make_categories_list(); $o .= html_writer::start_tag('ul'); foreach ($catlist as $catid => $catname) { if (empty($usagedata['category'][$catid])) { continue; } $o .= html_writer::start_tag('li'); $o .= $catname; $o .= html_writer::start_tag('ul'); foreach ($usagedata['category'][$catid] as $courseid) { $link = html_writer::link(new moodle_url('/course/view.php', array('id' => $courseid)), $usagedata['course'][$courseid]->fullname); $entry = $link . ' : ' . $this->convert_size($usagedata['course'][$courseid]->sum); $o .= html_writer::tag('li', $entry); } $o .= html_writer::end_tag('ul'); } $o .= html_writer::end_tag('ul'); return $o; }
/** * Renderers bulk actions that can be performed on courses. * * @param coursecat $category The currently selected category and the category in which courses that * are selectable belong. * @return string */ public function course_bulk_actions(coursecat $category) { $html = html_writer::start_div('course-bulk-actions bulk-actions'); if ($category->can_move_courses_out_of()) { $options = coursecat::make_categories_list('moodle/category:manage'); $select = html_writer::select($options, 'movecoursesto', '', array('' => 'choosedots'), array('aria-labelledby' => 'moveselectedcoursesto')); $submit = array('type' => 'submit', 'name' => 'bulkmovecourses', 'value' => get_string('move')); $html .= $this->detail_pair(html_writer::span(get_string('moveselectedcoursesto'), '', array('id' => 'moveselectedcoursesto')), $select . html_writer::empty_tag('input', $submit)); } $html .= html_writer::end_div(); return $html; }
function definition() { global $CFG; global $currentsess, $DB, $currentrecord; $mform =& $this->_form; // Don't forget the underscore! $mform->addElement('header', 'mainheader', '<span style="font-size:18px">' . get_string('modrequestfacility', 'block_cmanager') . '</span>'); $field1desc = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fielddesc1'), IGNORE_MULTIPLE); $field2desc = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fielddesc2'), IGNORE_MULTIPLE); // Get the field values $field1title = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fieldname1'), IGNORE_MULTIPLE); $field2title = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fieldname2'), IGNORE_MULTIPLE); $field3desc = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fielddesc3'), IGNORE_MULTIPLE); $field4title = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fieldname4'), IGNORE_MULTIPLE); $field4desc = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_fielddesc4'), IGNORE_MULTIPLE); //get field 3 status $field3status = $DB->get_field('block_cmanager_config', 'value', array('varname' => 'page1_field3status'), IGNORE_MULTIPLE); //get the value for autokey - the config variable that determines enrolment key auto or prompt $autoKey = $DB->get_field_select('block_cmanager_config', 'value', "varname = 'autoKey'"); $selfcat = $DB->get_field_select('block_cmanager_config', 'value', "varname = 'selfcat'"); // Page description text $mform->addElement('html', '<p></p>' . get_string('courserequestline1', 'block_cmanager')); $mform->addElement('html', '<p></p><div style="width:545px; text-align:left"><b>' . get_string('step1text', 'block_cmanager') . '</b></div><p></p><br>'); // Programme Code $attributes = array(); $attributes['value'] = $currentrecord->modcode; $mform->addElement('text', 'programmecode', $field1title, $attributes, ''); $mform->addRule('programmecode', get_string('request_rule1', 'block_cmanager'), 'required', null, 'server', false, false); $mform->addElement('static', 'description', '', $field1desc); $mform->addElement('html', '<p></p>'); $mform->setType('programmecode', PARAM_TEXT); // Programme Title $attributes = array(); $attributes['value'] = $currentrecord->modname; $mform->addElement('text', 'programmetitle', $field2title, $attributes); $mform->addRule('programmetitle', get_string('request_rule1', 'block_cmanager'), 'required', null, 'server', false, false); $mform->setType('programmetitle', PARAM_TEXT); $mform->addElement('static', 'description', '', $field2desc); $mform->addElement('html', '<p> <br>'); // Programme Mode if ($field3status == 'enabled') { $options = array(); $selectQuery = "varname = 'page1_field3value'"; $field3Items = $DB->get_recordset_select('block_cmanager_config', $select = $selectQuery); foreach ($field3Items as $item) { $value = $item->value; if ($value != '') { $options[$value] = $value; $options[$value] = $value; } } $mform->addElement('select', 'programmemode', $field3desc, $options); $mform->addRule('programmemode', get_string('request_rule2', 'block_cmanager'), 'required', null, 'server', false, false); $mform->setDefault('programmemode', $currentrecord->modmode); $mform->setType('programmemode', PARAM_TEXT); } // If enabled, give the user the option // to select a category location for the course. if ($selfcat == 'yes') { // $movetocategories = array(); $options = coursecat::make_categories_list(); $mform->addElement('select', 'menucategory', 'Category', $options); if ($_SESSION['editingmode'] == 'true') { $mform->setDefault('menucategory', $currentrecord->cate); } } if (!$autoKey) { // enrolment key $attributes = array(); $mform->addElement('html', '<br><br>'); $attributes['value'] = $currentrecord->modkey; $mform->addElement('text', 'enrolkey', $field4title, $attributes); $mform->addRule('enrolkey', get_string('request_rule3', 'block_cmanager'), 'required', null, 'server', false, false); $mform->setType('enrolkey', PARAM_TEXT); } // Hidden form element to pass the key if (isset($_GET['edit'])) { $mform->addElement('hidden', 'editingmode', $currentsess); $mform->setType('editingmode', PARAM_TEXT); } $mform->addElement('html', '<p></p> <p></p>'); $buttonarray = array(); $buttonarray[] =& $mform->createElement('submit', 'submitbutton', get_string('Continue', 'block_cmanager')); $buttonarray[] =& $mform->createElement('cancel', 'cancel', get_string('cancel', 'block_cmanager')); $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false); }