/** * returns extra button html for the passed in course * * @param object $course course record * * @return text */ function local_course_buttons($course) { global $USER, $CFG; $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); if ($course->learning_path_mode == LEARNING_PATH_MODE_RAFL && (has_capability('moodle/local:canviewraflmod', $coursecontext, NULL, false) or has_capability('moodle/local:canassignselftorafl', get_context_instance(CONTEXT_COURSE, SITEID)))) { tao_set_user_rafl_mode($course); if ($USER->raflmode == 1) { $string = get_string('standardview', 'local'); $raflmode = '0'; } else { $string = get_string('raflview', 'local'); $raflmode = '1'; } return '<form method="get" action="' . $CFG->wwwroot . '/course/view.php">' . '<div>' . '<input type="hidden" name="id" value="' . $course->id . '" />' . '<input type="hidden" name="rafl" value="' . $raflmode . '" />' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="submit" value="' . $string . '" />' . '</div></form>'; } }
// create the 'my learning path' specific links $mypaths_link = ""; if (!tao_is_my_learning_path($course->id) && !isguest() && !($course->category == '7')) { // && !($course->category == '7') added to make sure it is not displayed when in Yesumiy Lemida course (nadavkav) $mypaths_link = '<a href="' . course_enrol_uri($overview_page, $course) . '">' . get_string('addtomylearningpaths', 'format_learning') . '</a>'; } $completion_page = '/local/lp/completion.php?id=' . $course->id; $completion_link = '<a href="' . $CFG->wwwroot . $completion_page . '" onclick="this.target=\'completion\'; return openpopup(\'' . $completion_page . '\', \'completion\', \'menubar=0,location=0,scrollbars,status,resizable,width=700,height=500\', 0);">' . get_string('completion', 'format_learning') . '</a>'; // print control row for the course echo '<table id="learning-path-header">'; echo '<tr><td><h1>' . $course->fullname . '</h1></td><td align="right">' . $mypaths_link . '</td></tr>'; echo '</table>'; // start the main layout table echo "\n<!-- start layout table -->\n"; echo '<table id="layout-table" class="' . $class . '" cellspacing="0" summary="' . get_string('layouttable') . '">'; tao_set_user_rafl_mode($course); if (isset($USER->raflmode) && $USER->raflmode) { // check wheter i have rights on this learning path $canviewrafl = false; $notifymessage = ''; if (has_capability('moodle/local:canviewraflmod', $context, NULL, false)) { $canviewrafl = true; } else { if (has_capability('moodle/local:canassignselftorafl', get_context_instance(CONTEXT_COURSE, SITEID))) { $roleid = get_field('role', 'id', 'shortname', ROLE_LPCONTRIBUTOR); if (!user_has_role_assignment($USER->id, $roleid, $context->id)) { //if isn't already a contributor, assign as one role_assign($roleid, $USER->id, 0, $context->id); local_role_processing($course, $roleid); $notifymessage = get_string('raflautoaddcontrib', 'rafl'); }