Пример #1
0
/**
 * Prints a nice side block with an optional header.  The content can either
 * be a block of HTML or a list of text with optional icons.
 *
 * @param string $heading HTML for the heading. Can include full HTML or just
 *   plain text - plain text will automatically be enclosed in the appropriate
 *   heading tags.
 * @param string $content HTML for the content
 * @param array $list an alternative to $content, it you want a list of things with optional icons.
 * @param array $icons optional icons for the things in $list.
 * @param string $footer Extra HTML content that gets output at the end, inside a <div class="footer">
 * @param array $attributes an array of attribute => value pairs that are put on the
 * outer div of this block. If there is a class attribute ' sideblock' gets appended to it. If there isn't
 * already a class, class='sideblock' is used.
 * @param string $title Plain text title, as embedded in the $heading.
 * @todo Finish documenting this function. Show example of various attributes, etc.
 */
function print_side_block($heading = '', $content = '', $list = NULL, $icons = NULL, $footer = '', $attributes = array(), $title = '')
{
    //Accessibility: skip block link, with title-text (or $block_id) to differentiate links.
    static $block_id = 0;
    $block_id++;
    if (empty($heading)) {
        $skip_text = get_string('skipblock', 'access') . ' ' . $block_id;
    } else {
        $skip_text = get_string('skipa', 'access', strip_tags($title));
    }
    $skip_link = '<a href="#sb-' . $block_id . '" class="skip-block">' . $skip_text . '</a>';
    $skip_dest = '<span id="sb-' . $block_id . '" class="skip-block-to"></span>';
    if (!empty($heading)) {
        echo $skip_link;
    }
    //ELSE: a single link on a page "Skip block 4" is too confusing - ignore.
    print_side_block_start($heading, $attributes);
    // The content.
    if ($content) {
        echo $content;
    } else {
        if ($list) {
            $row = 0;
            //Accessibility: replaced unnecessary table with list, see themes/standard/styles_layout.css
            echo "\n<ul class='list'>\n";
            foreach ($list as $key => $string) {
                echo '<li class="r' . $row . '">';
                if ($icons) {
                    echo '<div class="icon column c0">' . $icons[$key] . '</div>';
                }
                echo '<div class="column c1">' . $string . '</div>';
                echo "</li>\n";
                $row = $row ? 0 : 1;
            }
            echo "</ul>\n";
        }
    }
    // Footer, if any.
    if ($footer) {
        echo '<div class="footer">' . $footer . '</div>';
    }
    print_side_block_end($attributes, $title);
    echo $skip_dest;
}
Пример #2
0
} else {
    $bankclass = 'collapsed';
    $quizcontentsclass = 'quizwhenbankcollapsed';
}
print_side_block_start(get_string('questionbankcontents', 'quiz') . ' <a href="' . $thispageurl->out(false, array('qbanktool' => '1')) . '" id="showbankcmd">[' . get_string('show') . ']</a>
       <a href="' . $thispageurl->out(false, array('qbanktool' => '0')) . '" id="hidebankcmd">[' . get_string('hide') . ']</a>
       ', array('class' => 'questionbankwindow ' . $bankclass));
echo '<span id="questionbank"></span>';
echo '<div class="container">';
echo '<div id="module" class="module">';
echo '<div class="bd">';
$questionbank->display('editq', $pagevars['qpage'], $pagevars['qperpage'], $pagevars['qsortorder'], $pagevars['qsortorderdecoded'], $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['showquestiontext']);
echo '</div>';
echo '</div>';
echo '</div>';
print_side_block_end();
echo '<div class="quizcontents ' . $quizcontentsclass . '" id="quizcontentsblock">';
if ($quiz->shufflequestions) {
    $repaginatingdisabledhtml = 'disabled="disabled"';
    $repaginatingdisabled = true;
    $quiz->questions = quiz_repaginate($quiz->questions, $quiz->questionsperpage);
} else {
    $repaginatingdisabledhtml = '';
    $repaginatingdisabled = false;
}
if ($quiz_reordertool) {
    echo '<div class="repaginatecommand"><button id="repaginatecommand" ' . $repaginatingdisabledhtml . '>' . get_string('repaginatecommand', 'quiz') . '...</button>';
    echo '</div>';
}
print_heading($pagetitle . ": " . $quiz->name, 'left', 2);
helpbutton('editconcepts', get_string('basicideasofquiz', 'quiz'), 'quiz', true, get_string('basicideasofquiz', 'quiz'));
/**
 * This function prints blocks.
 *
 * @uses $CGF, $USER
 * @param int $userid User ID
 * @param int $courseid Course ID
 * @param boolean $printsearchblock Print search block
 * @return NULL
 * @todo Finish documenting this function
 **/
function email_printblocks($userid, $courseid, $printsearchblock = true)
{
    global $CFG, $USER;
    $strcourse = get_string('course');
    $strcourses = get_string('mailboxs', 'block_email_list');
    $strsearch = get_string('search');
    $strmail = get_string('name', 'block_email_list');
    // For title blocks
    $startdivtitle = '<div class="title">';
    $enddivtitle = '</div>';
    $list = array();
    $icons = array();
    if ($printsearchblock) {
        // Print search block
        $form = email_get_search_form($courseid);
        print_side_block_start($startdivtitle . $strsearch . $enddivtitle);
        echo $form;
        print_side_block_end();
    }
    // Print my folders
    email_print_tree_myfolders($userid, $courseid);
    // Remove old fields
    unset($list);
    unset($icons);
    // Get my course
    $mycourses = get_my_courses($USER->id, NULL, 'id, fullname, visible');
    $list = array();
    $icons = array();
    // Get courses
    foreach ($mycourses as $mycourse) {
        $context = get_context_instance(CONTEXT_COURSE, $mycourse->id);
        //Get the number of unread mails
        $numberunreadmails = email_count_unreaded_mails($USER->id, $mycourse->id);
        $unreadmails = '';
        // Only show if has unreaded mails
        if ($numberunreadmails > 0) {
            $unreadmails = '<b>(' . $numberunreadmails . ')</b>';
            // Define default path of icon for course
            $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/openicon.gif" height="16" width="16" alt="' . $strcourse . '" />';
        } else {
            // Define default path of icon for course
            $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/icon.gif" height="16" width="16" alt="' . $strcourse . '" />';
        }
        $linkcss = $mycourse->visible ? '' : ' class="dimmed" ';
        if (!$mycourse->visible and !has_capability('moodle/legacy:student', $context, $USER->id, false) or !has_capability('moodle/legacy:student', $context, $USER->id, false) or has_capability('moodle/legacy:student', $context, $USER->id, false) and $mycourse->visible) {
            $list[] = '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $mycourse->id . '" ' . $linkcss . '>' . $mycourse->fullname . ' ' . $unreadmails . '</a>';
            $icons[] = $icon;
        }
    }
    // Print block of my courses
    print_side_block($startdivtitle . $strcourses . $enddivtitle, '', $list, $icons);
}
Пример #4
0
/**
 * This function prints blocks.
 *
 * @uses $CGF, $USER, $OUTPUT
 * @param int $userid User ID
 * @param int $courseid Course ID
 * @param boolean $printsearchblock Print search block
 * @return NULL
 * @todo Finish documenting this function
 **/
function email_printblocks($userid, $courseid, $printsearchblock = true)
{
    global $CFG, $USER, $OUTPUT;
    $strcourse = get_string('course');
    $strcourses = get_string('mailboxs', 'block_email_list');
    $strsearch = get_string('search');
    $strmail = get_string('name', 'block_email_list');
    // For title blocks
    $startdivtitle = '<div class="title">';
    $enddivtitle = '</div>';
    $list = array();
    $icons = array();
    if ($printsearchblock) {
        // Print search block
        $form = email_get_search_form($courseid);
        print_side_block_start($startdivtitle . $strsearch . $enddivtitle);
        echo $form;
        print_side_block_end();
    }
    // Print my folders
    email_print_tree_myfolders($userid, $courseid);
    // Remove old fields
    unset($list);
    unset($icons);
    // Get my course
    $mycourses = get_my_courses($USER->id, NULL, 'id, fullname, shortname, visible', false, $CFG->email_max_number_courses);
    // Limit
    $list = array();
    $icons = array();
    $number = 0;
    // Get courses
    foreach ($mycourses as $mycourse) {
        ++$number;
        // increment for first course
        if ($number > $CFG->email_max_number_courses && !empty($CFG->email_max_number_courses)) {
            continue;
        }
        $context = get_context_instance(CONTEXT_COURSE, $mycourse->id);
        //Get the number of unread mails
        $numberunreadmails = email_count_unreaded_mails($USER->id, $mycourse->id);
        $unreadmails = '';
        // Only show if has unreaded mails
        if ($numberunreadmails > 0) {
            $unreadmails = '<b>(' . $numberunreadmails . ')</b>';
            // Define default path of icon for course
            $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/openicon.gif" height="16" width="16" alt="' . $strcourse . '" />';
        } else {
            // Define default path of icon for course
            $icon = '<img src="' . $CFG->wwwroot . '/blocks/email_list/email/icon.gif" height="16" width="16" alt="' . $strcourse . '" />';
        }
        $linkcss = $mycourse->visible ? '' : ' class="dimmed" ';
        $coursename = $CFG->email_display_course_fullname ? $mycourse->fullname : $mycourse->shortname;
        // If I'm student
        if (has_capability('moodle/course:viewhiddencourses', $context)) {
            // Thanks Tim
            // If course visible
            if ($mycourse->visible) {
                $list[] = '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $mycourse->id . '" ' . $linkcss . '>' . $coursename . ' ' . $unreadmails . '</a>';
                $icons[] = $icon;
            }
        } else {
            $list[] = '<a href="' . $CFG->wwwroot . '/blocks/email_list/email/index.php?id=' . $mycourse->id . '" ' . $linkcss . '>' . $coursename . ' ' . $unreadmails . '</a>';
            $icons[] = $icon;
        }
    }
    // Print block of my courses
    print_side_block($startdivtitle . $strcourses . $enddivtitle, '', $list, $icons);
}