/** * Return the left arrow with text ('previous'), and optionally embedded in a link. * See function above, check_theme_arrows. * @param string $text HTML/plain text label (set to blank only for breadcrumb separator cases). * @param string $url An optional link to use in a surrounding HTML anchor. * @param bool $accesshide True if text should be hidden (for screen readers only). * @param string $addclass Additional class names for the link, or the arrow character. * @return string HTML string. */ function link_arrow_left($text, $url = '', $accesshide = false, $addclass = '') { global $THEME; check_theme_arrows(); $arrowclass = 'arrow '; if (!$url) { $arrowclass .= $addclass; } $arrow = '<span class="' . $arrowclass . '">' . $THEME->larrow . '</span>'; $htmltext = ''; if ($text) { $htmltext = ' <span class="arrow_text">' . $text . '</span>'; if ($accesshide) { $htmltext = get_accesshide($htmltext); } } if ($url) { $class = 'arrow_link'; if ($addclass) { $class .= ' ' . $addclass; } return '<a class="' . $class . '" href="' . $url . '" title="' . preg_replace('/<.*?>/', '', $text) . '">' . $arrow . $htmltext . '</a>'; } return $arrow . $htmltext; }
/// add all selected to course list foreach ($data->addoutcomes as $add) { $add = clean_param($add, PARAM_INT); if (!array_key_exists($add, $standardoutcomes)) { continue; } $goc = new object(); $goc->courseid = $courseid; $goc->outcomeid = $add; $DB->insert_record('grade_outcomes_courses', $goc); } } else { if (!empty($data->remove) && !empty($data->removeoutcomes)) { /// remove all selected from course outcomes list foreach ($data->removeoutcomes as $remove) { $remove = clean_param($remove, PARAM_INT); if (!array_key_exists($remove, $co_standard_notused)) { continue; } $DB->delete_records('grade_outcomes_courses', array('courseid' => $courseid, 'outcomeid' => $remove)); } } } redirect('course.php?id=' . $courseid); // we must redirect to get fresh data } /// Print header print_grade_page_head($COURSE->id, 'outcome', 'course'); check_theme_arrows(); require 'course_form.html'; print_footer($course);
/** * Print a given random question in quiz for the edit tab of edit.php. * Meant to be used from quiz_print_question_list() * * @param object $question A question object from the database questions table * @param object $questionurl The url of the question editing page as a moodle_url object * @param object $quiz The quiz in the context of which the question is being displayed * @param boolean $quiz_qbanktool Indicate to this function if the question bank window open */ function quiz_print_randomquestion(&$question, &$pageurl, &$quiz, $quiz_qbanktool) { global $DB, $QTYPES, $THEME; check_theme_arrows(); echo '<div class="quiz_randomquestion">'; if (!($category = $DB->get_record('question_categories', array('id' => $question->category)))) { notify('Random question category not found!'); return; } echo '<div class="randomquestionfromcategory">'; print_question_icon($question); print_random_option_icon($question); echo ' ' . get_string('randomfromcategory', 'quiz') . '</div>'; $a = new stdClass(); $a->arrow = $THEME->rarrow; $strshowcategorycontents = get_string('showcategorycontents', 'quiz', $a); $openqbankurl = $pageurl->out(false, array('qbanktool' => 1, 'cat' => $category->id . ',' . $category->contextid)); $linkcategorycontents = ' <a href="' . $openqbankurl . '">' . $strshowcategorycontents . '</a>'; echo '<div class="randomquestioncategory">'; echo '<a href="' . $openqbankurl . '" title="' . $strshowcategorycontents . '">' . $category->name . '</a>'; echo '<span class="questionpreview">' . quiz_question_preview_button($quiz, $question, true) . '</span>'; echo '</div>'; $questionids = $QTYPES['random']->get_usable_questions_from_category($category->id, $question->questiontext == '1', '0'); $questioncount = count($questionids); echo '<div class="randomquestionqlist">'; if ($questioncount == 0) { // No questions in category, give an error plus instructions echo '<span class="error">'; print_string('noquestionsnotinuse', 'quiz'); echo '</span>'; echo '<br />'; // Embed the link into the string with instructions $a = new stdClass(); $a->catname = '<strong>' . $category->name . '</strong>'; $a->link = $linkcategorycontents; echo get_string('addnewquestionsqbank', 'quiz', $a); } else { // Category has questions // Get a sample from the database, $toshow = array_slice($questionids, 0, NUM_QS_TO_SHOW_IN_RANDOM); $questionidstoshow = array(); foreach ($toshow as $a) { $questionidstoshow[] = $a->id; } $questionstoshow = $DB->get_records_list('question', 'id', $questionidstoshow, '', 'id,qtype,name,questiontext,questiontextformat'); // list them, echo '<ul>'; foreach ($questionstoshow as $question) { echo '<li>' . quiz_question_tostring($question, true) . '</li>'; } // and then display the total number. echo '<li class="totalquestionsinrandomqcategory">'; if ($questioncount > NUM_QS_TO_SHOW_IN_RANDOM) { echo '... '; } print_string('totalquestionsinrandomqcategory', 'quiz', $questioncount); echo ' ' . $linkcategorycontents; echo '</li>'; echo '</ul>'; } echo '</div>'; echo '<div class="randomquestioncategorycount">'; echo '</div>'; echo '</div>'; }