public function definition() { global $CFG; $mform =& $this->_form; // get a list of courses that are learning path templates $courses = tao_get_learning_path_templates(); if (empty($courses)) { error("No templates available"); } foreach ($courses as $course) { $options[$course->id] = $course->fullname; } $mform->addElement('header', 'enrolhdr', get_string('general')); $mform->addElement('html', '<p>The following options should be the Translated names of the Learning Stations within your Learning Path as used on the legacy TAO system - the English versions are displayed for your reference</p>'); $mform->addElement('text', 'legacyid21', '21 - About the Learning Path'); $mform->addElement('text', 'legacyid26', '26 - How will it be relevant to me?'); $mform->addElement('text', 'legacyid23', '23 - How will it work in the classroom?'); $mform->addElement('text', 'legacyid24', '24 - Resource Requirements'); $mform->addElement('text', 'legacyid25', '25 - How will the learning path be evaluated and developed?'); $mform->addElement('select', 'course_template', get_string('choosetemplate', 'local'), $options); $mform->setDefault('legacyid21', '1 '); $mform->setDefault('legacyid26', '2 '); $mform->setDefault('legacyid23', '3 '); $mform->setDefault('legacyid24', '4 '); $mform->setDefault('legacyid25', '5 '); $mform->addRule('legacyid21', null, 'required', null, 'client'); $mform->addRule('legacyid26', null, 'required', null, 'client'); $mform->addRule('legacyid23', null, 'required', null, 'client'); $mform->addRule('legacyid24', null, 'required', null, 'client'); $mform->addRule('legacyid25', null, 'required', null, 'client'); // submit buttons $this->add_action_buttons(true, get_string('create')); }
/** Prints the learning path templates on the system. Learning path 'templates' are simply courses in the templates directory. This print out: 1. gives easy access to these without digging through the category navigation. 2. avoids us having to give rights in the admin block to template editors. **/ function tao_print_templates() { global $CFG, $USER; // get learning paths in the template directory $courses = tao_get_learning_path_templates(); echo '<h2>' . get_string('lptemplates', 'local') . '</h2>'; if (!empty($courses)) { $html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">'; $html .= '<tr><th align="left">' . get_string('lptemplates', 'local') . '</th><th align="left">' . get_string('assignedtotemplate', 'local') . '</th><th></th>'; foreach ($courses as $course) { // get a list of current editors on the course $editors = tao_get_templateeditors(get_context_instance(CONTEXT_COURSE, $course->id)); $editorlist = ''; if (!empty($editors)) { foreach ($editors as $editor) { if (!empty($editorlist)) { $editorlist .= ', '; } $editorlist .= $editor->firstname . ' ' . $editor->lastname; } } $areeditor = 0; if (isset($editors[$USER->id])) { $areeditor = 1; } $html .= '<tr>'; $html .= '<td><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $course->fullname . '</a></td>'; $html .= '<td><font size="1">' . $editorlist . '</font></td>'; $html .= '<td align="right">'; if (!$areeditor && has_capability('moodle/local:canselfassigntemplateeditor', get_context_instance(CONTEXT_COURSE, SITEID))) { $html .= '<a href="' . $CFG->wwwroot . '/local/lp/selfassigntemplate.php?id=' . $course->id . '">' . get_string('editlearningpath', 'local') . '</a>'; } $html .= '</td>'; $html .= '</tr>'; } $html .= '</table>'; } else { $html = '<p>' . get_string('nolearningpaths', 'local') . '</p>'; } //$CFG->lptemplatescategory //print_object($CFG); $html .= '<p><a href="' . $CFG->wwwroot . '/course/addlearningpath.php?category=' . $CFG->lptemplatescategory . '&ct=1">' . get_string('createnewtemplate', 'local') . '...</a></p>'; echo $html; }
function definition() { global $CFG; $mform =& $this->_form; $createtemplate = $this->_customdata['createtemplate']; $category = $this->_customdata['category']; if (!$category) { error('No category provided'); } $categorycontext = get_context_instance(CONTEXT_COURSECAT, $category->id); /* display standard/rafl or both modes. * for standard check: has capability moodle/course:create * local/standardcourse:create * for rafl check: has capability moodle/course:create * rafl mode is on */ // select learning path authoring mode $modes = get_records('learning_path_mode'); //print_object($modes); foreach ($modes as $mode) { if ($mode->id == LEARNING_PATH_MODE_STANDARD) { if (!has_capability('moodle/local:createstandardlp', get_context_instance(CONTEXT_COURSE, SITEID))) { // not allowed standard mode continue; } } if ($mode->id == LEARNING_PATH_MODE_RAFL) { if (!tao_rafl_mode_enabled()) { continue; } } $moptions[$mode->id] = $mode->name; } if (empty($moptions)) { error('No authoring modes available'); } // get a list of courses that are learning path templates $courses = tao_get_learning_path_templates(); if (empty($courses)) { error("No templates available"); } foreach ($courses as $course) { $options[$course->id] = $course->fullname; } $mform->addElement('header', 'enrolhdr', get_string('general')); $mform->addElement('select', 'learning_path_mode', get_string('chooseauthoringmode', 'local'), $moptions); $mform->addElement('select', 'course_template', get_string('choosetemplate', 'local'), $options); //must have create course capability in both categories in order to move course if (has_capability('moodle/course:create', get_context_instance(CONTEXT_COURSE, SITEID))) { $list[$category->id] = $category->name; $mform->addElement('select', 'category', get_string('category'), $list); } else { $mform->addElement('hidden', 'category', null); } $mform->setHelpButton('category', array('coursecategory', get_string('category'))); $mform->setDefault('category', $category->id); $mform->setType('category', PARAM_INT); // name fields $mform->addElement('text', 'fullname', get_string('fullname'), 'maxlength="254" size="50"'); $mform->setHelpButton('fullname', array('coursefullname', get_string('fullname')), true); $mform->setDefault('fullname', get_string('defaultlearningpathfullname', 'local')); $mform->addRule('fullname', get_string('missingfullname'), 'required', null, 'client'); $mform->setType('fullname', PARAM_MULTILANG); $mform->addElement('text', 'shortname', get_string('shortname'), 'maxlength="100" size="20"'); $mform->setHelpButton('shortname', array('courseshortname', get_string('shortname')), true); $mform->setDefault('shortname', get_string('defaultlearningpathshortname', 'local')); $mform->addRule('shortname', get_string('missingshortname'), 'required', null, 'client'); $mform->setType('shortname', PARAM_MULTILANG); $mform->addElement('htmleditor', 'summary', get_string('summary'), array('rows' => '10', 'cols' => '65')); $mform->setHelpButton('summary', array('text', get_string('helptext')), true); $mform->setType('summary', PARAM_RAW); $mform->addElement('hidden', 'defaultrole', $CFG->defaultcourseroleid); $mform->addElement('hidden', 'format', 'learning'); $mform->addElement('hidden', 'guest', 1); $mform->addElement('hidden', 'groupmode', 1); $mform->addElement('hidden', 'ct', $createtemplate); // submit buttons $this->add_action_buttons(true, get_string('create')); }