Beispiel #1
1
function survey_print_multi($question)
{
    global $USER, $db, $qnum, $checklist;
    $stripreferthat = get_string("ipreferthat", "survey");
    $strifoundthat = get_string("ifoundthat", "survey");
    $strdefault = get_string('default');
    $strresponses = get_string('responses', 'survey');
    print_heading($question->text, null, 3, 'questiontext');
    echo "\n<table width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\">";
    $options = explode(",", $question->options);
    $numoptions = count($options);
    $oneanswer = $question->type == 1 || $question->type == 2 ? true : false;
    if ($question->type == 2) {
        $P = "P";
    } else {
        $P = "";
    }
    echo "<tr class=\"smalltext\"><th scope=\"row\">{$strresponses}</th>";
    while (list($key, $val) = each($options)) {
        echo "<th scope=\"col\" class=\"hresponse\">{$val}</th>\n";
    }
    echo "<th>&nbsp;</th></tr>\n";
    if ($oneanswer) {
        echo "<tr><th scope=\"col\" colspan=\"6\">{$question->intro}</th></tr>\n";
    } else {
        echo "<tr><th scope=\"col\" colspan=\"7\">{$question->intro}</th></tr>\n";
    }
    $subquestions = get_records_list("survey_questions", "id", $question->multi);
    foreach ($subquestions as $q) {
        $qnum++;
        $rowclass = survey_question_rowclass($qnum);
        if ($q->text) {
            $q->text = get_string($q->text, "survey");
        }
        echo "<tr class=\"{$rowclass} rblock\">";
        if ($oneanswer) {
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">{$qnum}</b> &nbsp; ";
            echo $q->text . "</th>\n";
            for ($i = 1; $i <= $numoptions; $i++) {
                $hiddentext = get_accesshide($options[$i - 1]);
                $id = "q{$P}" . $q->id . "_{$i}";
                echo "<td><label for=\"{$id}\"><input type=\"radio\" name=\"q{$P}{$q->id}\" id=\"{$id}\" value=\"{$i}\" />{$hiddentext}</label></td>";
            }
            $default = get_accesshide($strdefault, 'label', '', "for=\"q{$P}{$q->id}\"");
            echo "<td class=\"whitecell\"><input type=\"radio\" name=\"q{$P}{$q->id}\" id=\"q{$P}" . $q->id . "_D\" value=\"0\" checked=\"checked\" />{$default}</td>";
            $checklist["q{$P}{$q->id}"] = $numoptions;
        } else {
            // yu : fix for MDL-7501, possibly need to use user flag as this is quite ugly.
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">{$qnum}</b> &nbsp; ";
            $qnum++;
            echo "<span class=\"preferthat smalltext\">{$stripreferthat}</span> &nbsp; ";
            echo "<span class=\"option\">{$q->text}</span></th>\n";
            for ($i = 1; $i <= $numoptions; $i++) {
                $hiddentext = get_accesshide($options[$i - 1]);
                $id = "qP" . $q->id . "_{$i}";
                echo "<td><label for=\"{$id}\"><input type=\"radio\" name=\"qP{$q->id}\" id=\"{$id}\" value=\"{$i}\" />{$hiddentext}</label></td>";
            }
            $default = get_accesshide($strdefault, 'label', '', "for=\"qP{$q->id}\"");
            echo "<td><input type=\"radio\" name=\"qP{$q->id}\" id=\"qP{$q->id}\" value=\"0\" checked=\"checked\" />{$default}</td>";
            echo "</tr>";
            echo "<tr class=\"{$rowclass} rblock\">";
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">{$qnum}</b> &nbsp; ";
            echo "<span class=\"foundthat smalltext\">{$strifoundthat}</span> &nbsp; ";
            echo "<span class=\"option\">{$q->text}</span></th>\n";
            for ($i = 1; $i <= $numoptions; $i++) {
                $hiddentext = get_accesshide($options[$i - 1]);
                $id = "q" . $q->id . "_{$i}";
                echo "<td><label for=\"{$id}\"><input type=\"radio\" name=\"q{$q->id}\" id=\"{$id}\" value=\"{$i}\" />{$hiddentext}</label></td>";
            }
            $default = get_accesshide($strdefault, 'label', '', "for=\"q{$q->id}\"");
            echo "<td class=\"buttoncell\"><input type=\"radio\" name=\"q{$q->id}\" id=\"q{$q->id}\" value=\"0\" checked=\"checked\" />{$default}</td>";
            $checklist["qP{$q->id}"] = $numoptions;
            $checklist["q{$q->id}"] = $numoptions;
        }
        echo "</tr>\n";
    }
    echo "</table>";
}
 /**
  * Generate the content to displayed on the left part of a section
  * before course modules are included
  *
  * @param stdClass $section The course_section entry from DB
  * @param stdClass $course The course entry from DB
  * @param bool $onsectionpage true if being printed on a section page
  * @return string HTML to output.
  */
 protected function section_left_content($section, $course, $onsectionpage)
 {
     $o = $this->output->spacer();
     if ($section->section != 0) {
         // Only in the non-general sections.
         if (course_get_format($course)->is_section_current($section)) {
             $o .= get_accesshide(get_string('currentsection', 'format_' . $course->format));
         }
     }
     return $o;
 }
Beispiel #3
0
 function print_header($title)
 {
     global $USER, $CFG;
     $replacements = array('%fullname%' => get_string('mymoodle', 'my'));
     foreach ($replacements as $search => $replace) {
         $title = str_replace($search, $replace, $title);
     }
     $site = get_site();
     $button = update_mymoodle_icon($USER->id);
     $nav = get_string('mymoodle', 'my');
     $header = $site->shortname . ': ' . $nav;
     $navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc'));
     $navigation = build_navigation($navlinks);
     $loggedinas = user_login_string($site);
     if (empty($CFG->langmenu)) {
         $langmenu = '';
     } else {
         $currlang = current_language();
         $langs = get_list_of_languages();
         $langlabel = get_accesshide(get_string('language'));
         $langmenu = popup_form($CFG->wwwroot . '/my/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
     }
     print_header($title, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
 }
Beispiel #4
0
/**
 * Generates the HTML for a miniature calendar
 *
 * @param array $courses list of course to list events from
 * @param array $groups list of group
 * @param array $users user's info
 * @param int|bool $calmonth calendar month in numeric, default is set to false
 * @param int|bool $calyear calendar month in numeric, default is set to false
 * @param string|bool $placement the place/page the calendar is set to appear - passed on the the controls function
 * @param int|bool $courseid id of the course the calendar is displayed on - passed on the the controls function
 * @param int $time the unixtimestamp representing the date we want to view, this is used instead of $calmonth
 *     and $calyear to support multiple calendars
 * @return string $content return html table for mini calendar
 */
function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyear = false, $placement = false, $courseid = false, $time = 0)
{
    global $CFG, $OUTPUT;
    // Get the calendar type we are using.
    $calendartype = \core_calendar\type_factory::get_calendar_instance();
    $display = new stdClass();
    // Assume we are not displaying this month for now.
    $display->thismonth = false;
    $content = '';
    // Do this check for backwards compatibility. The core should be passing a timestamp rather than month and year.
    // If a month and year are passed they will be in Gregorian.
    if (!empty($calmonth) && !empty($calyear)) {
        // Ensure it is a valid date, else we will just set it to the current timestamp.
        if (checkdate($calmonth, 1, $calyear)) {
            $time = make_timestamp($calyear, $calmonth, 1);
        } else {
            $time = time();
        }
        $date = usergetdate($time);
        if ($calmonth == $date['mon'] && $calyear == $date['year']) {
            $display->thismonth = true;
        }
        // We can overwrite date now with the date used by the calendar type, if it is not Gregorian, otherwise
        // there is no need as it is already in Gregorian.
        if ($calendartype->get_name() != 'gregorian') {
            $date = $calendartype->timestamp_to_date_array($time);
        }
    } else {
        if (!empty($time)) {
            // Get the specified date in the calendar type being used.
            $date = $calendartype->timestamp_to_date_array($time);
            $thisdate = $calendartype->timestamp_to_date_array(time());
            if ($date['month'] == $thisdate['month'] && $date['year'] == $thisdate['year']) {
                $display->thismonth = true;
                // If we are the current month we want to set the date to the current date, not the start of the month.
                $date = $thisdate;
            }
        } else {
            // Get the current date in the calendar type being used.
            $time = time();
            $date = $calendartype->timestamp_to_date_array($time);
            $display->thismonth = true;
        }
    }
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display.
    // Get Gregorian date for the start of the month.
    $gregoriandate = $calendartype->convert_to_gregorian($date['year'], $date['mon'], 1);
    // Store the gregorian date values to be used later.
    list($gy, $gm, $gd, $gh, $gmin) = array($gregoriandate['year'], $gregoriandate['month'], $gregoriandate['day'], $gregoriandate['hour'], $gregoriandate['minute']);
    // Get the max number of days in this month for this calendar type.
    $display->maxdays = calendar_days_in_month($m, $y);
    // Get the starting week day for this month.
    $startwday = dayofweek(1, $m, $y);
    // Get the days in a week.
    $daynames = calendar_get_days();
    // Store the number of days in a week.
    $numberofdaysinweek = $calendartype->get_num_weekdays();
    // Set the min and max weekday.
    $display->minwday = calendar_get_starting_weekday();
    $display->maxwday = $display->minwday + ($numberofdaysinweek - 1);
    // These are used for DB queries, so we want unixtime, so we need to use Gregorian dates.
    $display->tstart = make_timestamp($gy, $gm, $gd, $gh, $gmin, 0);
    $display->tend = $display->tstart + $display->maxdays * DAYSECS - 1;
    // Align the starting weekday to fall in our display range
    // This is simple, not foolproof.
    if ($startwday < $display->minwday) {
        $startwday += $numberofdaysinweek;
    }
    // Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
    $events = calendar_get_events($display->tstart, $display->tend, $users, $groups, $courses);
    // Set event course class for course events
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
    // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
    // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
    // arguments to this function.
    $hrefparams = array();
    if (!empty($courses)) {
        $courses = array_diff($courses, array(SITEID));
        if (count($courses) == 1) {
            $hrefparams['course'] = reset($courses);
        }
    }
    // We want to have easy access by day, since the display is on a per-day basis.
    calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
    // Accessibility: added summary and <abbr> elements.
    $summary = get_string('calendarheading', 'calendar', userdate($display->tstart, get_string('strftimemonthyear')));
    $content .= '<table class="minicalendar calendartable" summary="' . $summary . '">';
    // Begin table.
    if ($placement !== false && $courseid !== false) {
        $content .= '<caption>' . calendar_top_controls($placement, array('id' => $courseid, 'time' => $time)) . '</caption>';
    }
    $content .= '<tr class="weekdays">';
    // Header row: day names
    // Print out the names of the weekdays.
    for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
        $pos = $i % $numberofdaysinweek;
        $content .= '<th scope="col"><abbr title="' . $daynames[$pos]['fullname'] . '">' . $daynames[$pos]['shortname'] . "</abbr></th>\n";
    }
    $content .= '</tr><tr>';
    // End of day names; prepare for day numbers
    // For the table display. $week is the row; $dayweek is the column.
    $dayweek = $startwday;
    // Paddding (the first week may have blank days in the beginning)
    for ($i = $display->minwday; $i < $startwday; ++$i) {
        $content .= '<td class="dayblank">&nbsp;</td>' . "\n";
    }
    $weekend = CALENDAR_DEFAULT_WEEKEND;
    if (isset($CFG->calendar_weekend)) {
        $weekend = intval($CFG->calendar_weekend);
    }
    // Now display all the calendar
    $daytime = $display->tstart - DAYSECS;
    for ($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
        $daytime += DAYSECS;
        if ($dayweek > $display->maxwday) {
            // We need to change week (table row)
            $content .= '</tr><tr>';
            $dayweek = $display->minwday;
        }
        // Reset vars.
        if ($weekend & 1 << $dayweek % $numberofdaysinweek) {
            // Weekend. This is true no matter what the exact range is.
            $class = 'weekend day';
        } else {
            // Normal working day.
            $class = 'day';
        }
        // Special visual fx if an event is defined
        if (isset($eventsbyday[$day])) {
            $class .= ' hasevent';
            $hrefparams['view'] = 'day';
            $dayhref = calendar_get_link_href(new moodle_url(CALENDAR_URL . 'view.php', $hrefparams), 0, 0, 0, $daytime);
            $popupcontent = '';
            foreach ($eventsbyday[$day] as $eventid) {
                if (!isset($events[$eventid])) {
                    continue;
                }
                $event = new calendar_event($events[$eventid]);
                $popupalt = '';
                $component = 'moodle';
                if (!empty($event->modulename)) {
                    $popupicon = 'icon';
                    $popupalt = $event->modulename;
                    $component = $event->modulename;
                } else {
                    if ($event->courseid == SITEID) {
                        // Site event.
                        $popupicon = 'i/siteevent';
                    } else {
                        if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
                            // Course event.
                            $popupicon = 'i/courseevent';
                        } else {
                            if ($event->groupid) {
                                // Group event.
                                $popupicon = 'i/groupevent';
                            } else {
                                // Must be a user event.
                                $popupicon = 'i/userevent';
                            }
                        }
                    }
                }
                $dayhref->set_anchor('event_' . $event->id);
                $popupcontent .= html_writer::start_tag('div');
                $popupcontent .= $OUTPUT->pix_icon($popupicon, $popupalt, $component);
                $name = format_string($event->name, true);
                // Show ical source if needed.
                if (!empty($event->subscription) && $CFG->calendar_showicalsource) {
                    $a = new stdClass();
                    $a->name = $name;
                    $a->source = $event->subscription->name;
                    $name = get_string('namewithsource', 'calendar', $a);
                }
                $popupcontent .= html_writer::link($dayhref, $name);
                $popupcontent .= html_writer::end_tag('div');
            }
            //Accessibility: functionality moved to calendar_get_popup.
            if ($display->thismonth && $day == $d) {
                $popupid = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent);
            } else {
                $popupid = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent);
            }
            // Class and cell content
            if (isset($typesbyday[$day]['startglobal'])) {
                $class .= ' calendar_event_global';
            } else {
                if (isset($typesbyday[$day]['startcourse'])) {
                    $class .= ' calendar_event_course';
                } else {
                    if (isset($typesbyday[$day]['startgroup'])) {
                        $class .= ' calendar_event_group';
                    } else {
                        if (isset($typesbyday[$day]['startuser'])) {
                            $class .= ' calendar_event_user';
                        }
                    }
                }
            }
            $cell = html_writer::link($dayhref, $day, array('id' => $popupid));
        } else {
            $cell = $day;
        }
        $durationclass = false;
        if (isset($typesbyday[$day]['durationglobal'])) {
            $durationclass = ' duration_global';
        } else {
            if (isset($typesbyday[$day]['durationcourse'])) {
                $durationclass = ' duration_course';
            } else {
                if (isset($typesbyday[$day]['durationgroup'])) {
                    $durationclass = ' duration_group';
                } else {
                    if (isset($typesbyday[$day]['durationuser'])) {
                        $durationclass = ' duration_user';
                    }
                }
            }
        }
        if ($durationclass) {
            $class .= ' duration ' . $durationclass;
        }
        // If event has a class set then add it to the table day <td> tag
        // Note: only one colour for minicalendar
        if (isset($eventsbyday[$day])) {
            foreach ($eventsbyday[$day] as $eventid) {
                if (!isset($events[$eventid])) {
                    continue;
                }
                $event = $events[$eventid];
                if (!empty($event->class)) {
                    $class .= ' ' . $event->class;
                }
                break;
            }
        }
        // Special visual fx for today
        //Accessibility: hidden text for today, and popup.
        if ($display->thismonth && $day == $d) {
            $class .= ' today';
            $today = get_string('today', 'calendar') . ' ' . userdate(time(), get_string('strftimedayshort'));
            if (!isset($eventsbyday[$day])) {
                $class .= ' eventnone';
                $popupid = calendar_get_popup(true, false);
                $cell = html_writer::link('#', $day, array('id' => $popupid));
            }
            $cell = get_accesshide($today . ' ') . $cell;
        }
        // Just display it
        if (!empty($class)) {
            $class = ' class="' . $class . '"';
        }
        $content .= '<td' . $class . '>' . $cell . "</td>\n";
    }
    // Paddding (the last week may have blank days at the end)
    for ($i = $dayweek; $i <= $display->maxwday; ++$i) {
        $content .= '<td class="dayblank">&nbsp;</td>';
    }
    $content .= '</tr>';
    // Last row ends
    $content .= '</table>';
    // Tabular display of days ends
    return $content;
}
Beispiel #5
0
     if ($showsection) {
         $sectionmenu['week=' . $section] = s("{$strweek} {$section} |     {$weekday} - {$endweekday}");
     }
     $section++;
     $weekdate = $nextweekdate;
     continue;
 }
 if ($showsection) {
     $currentweek = $weekdate <= $timenow && $timenow < $nextweekdate;
     $currenttext = '';
     if (!$thissection->visible) {
         $sectionstyle = ' hidden';
     } else {
         if ($currentweek) {
             $sectionstyle = ' current';
             $currenttext = get_accesshide(get_string('currentweek', 'access'));
         } else {
             $sectionstyle = '';
         }
     }
     echo '<tr id="section-' . $section . '" class="section main' . $sectionstyle . '">';
     echo '<td class="left side">&nbsp;' . $currenttext . '</td>';
     $weekperiod = $weekday . ' - ' . $endweekday;
     echo '<td class="content">';
     if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {
         // Hidden for students
         print_heading($weekperiod . ' (' . get_string('notavailable') . ')', null, 3, 'weekdates');
     } else {
         print_heading($weekperiod, null, 3, 'weekdates');
         echo '<div class="summary">';
         $summaryformatoptions->noclean = true;
Beispiel #6
0
     if ($showsection) {
         $sectionmenu[$section] = get_section_name($course, $thissection);
     }
     $section++;
     continue;
 }
 if ($showsection) {
     //what is course marker?
     $currenttopic = $course->marker == $section;
     $currenttext = '';
     if (!$thissection->visible) {
         $sectionstyle = ' hidden';
     } else {
         if ($currenttopic) {
             $sectionstyle = ' current';
             $currenttext = get_accesshide(get_string('currenttopic', 'format_bootstraptabs'));
         } else {
             $sectionstyle = '';
         }
     }
     //the default action is to set the name of each topic to null.
     $secname = $thissection->name;
     //this will set the name of undefined sections to a number.
     if ($secname == null) {
         $secname = $secname . $num;
         $num++;
     }
     if (has_capability('moodle/course:viewhiddensections', $context) || $thissection->visible) {
         if ($section == 1) {
             echo '<div role="tabpanel" class="tab-pane fade in active" id="section-' . $section . '">';
         } else {
Beispiel #7
0
    if (count($data) > 1) {
        // Chart only works if more than 1 record.
        $PAGE->requires->yui_module('moodle-forumngfeature_usage-usagegraph', 'M.mod_forumng.forumngfeature_usage_chart.output', array($data, $axes, $options));
    }
    $usageoutput .= html_writer::start_div('forumng_usage_usagechart');
    $help = $OUTPUT->help_icon('usagechartpoststot', 'forumngfeature_usage');
    $usageoutput .= $OUTPUT->heading(get_string('usagechartpoststotal', 'forumngfeature_usage', $postcount) . $help, 4);
    $usageoutput .= $dateform->render();
    // Accessible table of chart.
    $charttable = new html_table();
    $charttable->head = array($datelabel, $postslabel, $totallabel);
    $charttable->data = $data;
    $charttable->summary = get_string('usagechartpoststable', 'forumngfeature_usage');
    if (count($data) > 1) {
        // Show table hidden for screenreaders (also keyboard focus toggled by css).
        $usageoutput .= get_accesshide(html_writer::table($charttable), 'div', 'skip', 'tabindex = 0');
        $usageoutput .= html_writer::div('', 'forumng_usage_chart', array('id' => 'usagechart'));
    } else {
        // Show table instead of chart.
        $usageoutput .= html_writer::table($charttable);
    }
    $usageoutput .= html_writer::end_div();
}
if ($forum->can_view_subscribers()) {
    // View subscriber info.
    $subs = $forum->get_subscribers($groupid);
    $discussioncount = 0;
    $groupcount = 0;
    $wholecount = 0;
    foreach ($subs as $subscriber) {
        if (!empty($subscriber->wholeforum)) {
/**
 * Prints a section full of activity modules
 * @Overrides course/lib.php=>print_section
 */
function ss_print_section($course, $section, $mods, $modnamesused, $absolute=false, $width="100%", $hidecompletion=false) {
	#print_r($mods);
	
	global $CFG, $USER, $DB, $PAGE, $OUTPUT;

    static $initialised;

    static $groupbuttons;
    static $groupbuttonslink;
    static $isediting;
    static $ismoving;
    static $strmovehere;
    static $strmovefull;
    static $strunreadpostsone;
    static $usetracking;
    static $groupings;

    if (!isset($initialised)) {
        $groupbuttons     = ($course->groupmode or (!$course->groupmodeforce));
        $groupbuttonslink = (!$course->groupmodeforce);
        $isediting        = $PAGE->user_is_editing();
        $ismoving         = $isediting && ismoving($course->id);
        if ($ismoving) {
            $strmovehere  = get_string("movehere");
            $strmovefull  = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
        }
        include_once($CFG->dirroot.'/mod/forum/lib.php');
        if ($usetracking = forum_tp_can_track_forums()) {
            $strunreadpostsone = get_string('unreadpostsone', 'forum');
        }
        $initialised = true;
    }

    $labelformatoptions = new stdClass();
    $labelformatoptions->noclean = true;
    $labelformatoptions->overflowdiv = true;

/// Casting $course->modinfo to string prevents one notice when the field is null
    $modinfo = get_fast_modinfo($course);
    $completioninfo = new completion_info($course);

    //Accessibility: replace table with list <ul>, but don't output empty list.
    if (!empty($section->sequence)) {

        // Fix bug #5027, don't want style=\"width:$width\".
        echo "<ul class=\"section img-text\">\n";
        $sectionmods = explode(",", $section->sequence);

        foreach ($sectionmods as $modnumber) {
            if (empty($mods[$modnumber])) {
                continue;
            }

            $mod = $mods[$modnumber];
            
            if ($ismoving and $mod->id == $USER->activitycopy) {
                // do not display moving mod
                continue;
            }

            if (isset($modinfo->cms[$modnumber])) {
                // We can continue (because it will not be displayed at all)
                // if:
                // 1) The activity is not visible to users
                // and
                // 2a) The 'showavailability' option is not set (if that is set,
                //     we need to display the activity so we can show
                //     availability info)
                // or
                // 2b) The 'availableinfo' is empty, i.e. the activity was
                //     hidden in a way that leaves no info, such as using the
                //     eye icon.
                if (!$modinfo->cms[$modnumber]->uservisible &&
                    (empty($modinfo->cms[$modnumber]->showavailability) ||
                      empty($modinfo->cms[$modnumber]->availableinfo))) {
                    // visibility shortcut
                    continue;
                }
            } else {
                if (!file_exists("$CFG->dirroot/mod/$mod->modname/lib.php")) {
                    // module not installed
                    continue;
                }
                if (!coursemodule_visible_for_user($mod) &&
                    empty($mod->showavailability)) {
                    // full visibility check
                    continue;
                }
            }

            // In some cases the activity is visible to user, but it is
            // dimmed. This is done if viewhiddenactivities is true and if:
            // 1. the activity is not visible, or
            // 2. the activity has dates set which do not include current, or
            // 3. the activity has any other conditions set (regardless of whether
            //    current user meets them)
            $canviewhidden = has_capability(
                'moodle/course:viewhiddenactivities',
                get_context_instance(CONTEXT_MODULE, $mod->id));
            $accessiblebutdim = false;
            if ($canviewhidden) {
                $accessiblebutdim = !$mod->visible;
                if (!empty($CFG->enableavailability)) {
                    $accessiblebutdim = $accessiblebutdim ||
                        $mod->availablefrom > time() ||
                        ($mod->availableuntil && $mod->availableuntil < time()) ||
                        count($mod->conditionsgrade) > 0 ||
                        count($mod->conditionscompletion) > 0;
                }
            }

            $liclasses = array();
            $liclasses[] = 'activity';
            $liclasses[] = $mod->modname;
            $liclasses[] = 'modtype_'.$mod->modname;
            
            
            echo html_writer::start_tag('li', array('class'=>join(' ', $liclasses), 'id'=>'module-'.$modnumber));
            if ($ismoving) {
                echo '<a title="'.$strmovefull.'"'.
                     ' href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&amp;sesskey='.sesskey().'">'.
                     '<img class="movetarget" src="'.$OUTPUT->pix_url('movehere') . '" '.
                     ' alt="'.$strmovehere.'" /></a><br />
                     ';
            }

            $classes = array('mod-indent');
            if (!empty($mod->indent)) {
                $classes[] = 'mod-indent-'.$mod->indent;
                if ($mod->indent > 15) {
                    $classes[] = 'mod-indent-huge';
                }
            }
            echo html_writer::start_tag('div', array('class'=>join(' ', $classes)));

            $extra = '';
            if (!empty($modinfo->cms[$modnumber]->extra)) {
                $extra = $modinfo->cms[$modnumber]->extra;
            }
            
            if ($mod->modname == "label") {
                if ($accessiblebutdim || !$mod->uservisible) {
                    echo '<div class="dimmed_text"><span class="accesshide">'.
                        get_string('hiddenfromstudents').'</span>';
                } else {
                    echo '<div>';
                }
                echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                echo "</div>";
                if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>';
                }

            } else { // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true,  $course->id);
              #  echo format_string($modinfo->cms[$modnumber]->intro, true,  $course->id);
              #  echo format_string($modinfo->cms[$modnumber]->name, true,  $course->id);
              #  print_r($modinfo->cms[$modnumber]);

                $customicon = $modinfo->cms[$modnumber]->icon;
                if (!empty($customicon)) {
                    if (substr($customicon, 0, 4) === 'mod/') {
                        list($modname, $iconname) = explode('/', substr($customicon, 4), 2);
                        $icon = $OUTPUT->pix_url($iconname, $modname);
                    } else {
                        $icon = $OUTPUT->pix_url($customicon);
                    }
                } else {
                    $icon = $OUTPUT->pix_url('icon', $mod->modname);
                }

                //Accessibility: for files get description via icon, this is very ugly hack!
                $altname = '';
                $altname = $mod->modfullname;
                if (!empty($customicon)) {
                    $archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
                    if ($archetype == MOD_ARCHETYPE_RESOURCE) {
                        $mimetype = mimeinfo_from_icon('type', $customicon);
                        $altname = get_mimetype_description($mimetype);
                    }
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' '.$altname);
                }

                // We may be displaying this just in order to show information
                // about visibility, without the actual link
                if ($mod->uservisible) {
                    // Display normal module link
                    if (!$accessiblebutdim) {
                        $linkcss = '';
                        $accesstext  ='';
                    } else {
                        $linkcss = ' class="dimmed" ';
                        $accesstext = '<span class="accesshide">'.
                            get_string('hiddenfromstudents').': </span>';
                    }

                    echo '<a '.$linkcss.' '.$extra.
                         ' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.
                         '<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename',$mod->modname).'" /> '.
                         $accesstext.'<span class="instancename">'.$instancename.$altname.'</span></a>';

                    if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                        if (!isset($groupings)) {
                            $groupings = groups_get_all_groupings($course->id);
                        }
                        echo " <span class=\"groupinglabel\">(".format_string($groupings[$mod->groupingid]->name).')</span>';
                    }
                } else {
                    // Display greyed-out text of link
                    echo '<span class="dimmed_text" '.$extra.' ><span class="accesshide">'.
                        get_string('notavailableyet','condition').': </span>'.
                        '<img src="'.$icon.'" class="activityicon" alt="'.get_string('modulename', $mod->modname).'" /> <span>'.
                        $instancename.$altname.'</span></span>';
                }
            }
            if ($usetracking && $mod->modname == 'forum') {
                if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
                    echo '<span class="unread"> <a href="'.$CFG->wwwroot.'/mod/forum/view.php?id='.$mod->id.'">';
                    if ($unread == 1) {
                        echo $strunreadpostsone;
                    } else {
                        print_string('unreadpostsnumber', 'forum', $unread);
                    }
                    echo '</a></span>';
                }
            }

            if ($isediting) {
                if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
                    if (! $mod->groupmodelink = $groupbuttonslink) {
                        $mod->groupmode = $course->groupmode;
                    }

                } else {
                    $mod->groupmode = false;
                }
                echo '&nbsp;&nbsp;';
                echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
                hook_make_edit_icon_button($mod, $OUTPUT);
                
            }

            // Completion
            $completion = $hidecompletion
                ? COMPLETION_TRACKING_NONE
                : $completioninfo->is_enabled($mod);
            if ($completion!=COMPLETION_TRACKING_NONE && isloggedin() &&
                !isguestuser() && $mod->uservisible) {
                $completiondata = $completioninfo->get_data($mod,true);
                $completionicon = '';
                if ($isediting) {
                    switch ($completion) {
                        case COMPLETION_TRACKING_MANUAL :
                            $completionicon = 'manual-enabled'; break;
                        case COMPLETION_TRACKING_AUTOMATIC :
                            $completionicon = 'auto-enabled'; break;
                        default: // wtf
                    }
                } else if ($completion==COMPLETION_TRACKING_MANUAL) {
                    switch($completiondata->completionstate) {
                        case COMPLETION_INCOMPLETE:
                            $completionicon = 'manual-n'; break;
                        case COMPLETION_COMPLETE:
                            $completionicon = 'manual-y'; break;
                    }
                } else { // Automatic
                    switch($completiondata->completionstate) {
                        case COMPLETION_INCOMPLETE:
                            $completionicon = 'auto-n'; break;
                        case COMPLETION_COMPLETE:
                            $completionicon = 'auto-y'; break;
                        case COMPLETION_COMPLETE_PASS:
                            $completionicon = 'auto-pass'; break;
                        case COMPLETION_COMPLETE_FAIL:
                            $completionicon = 'auto-fail'; break;
                    }
                }
                if ($completionicon) {
                    $imgsrc = $OUTPUT->pix_url('i/completion-'.$completionicon);
                    $imgalt = s(get_string('completion-alt-'.$completionicon, 'completion'));
                    if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
                        $imgtitle = s(get_string('completion-title-'.$completionicon, 'completion'));
                        $newstate =
                            $completiondata->completionstate==COMPLETION_COMPLETE
                            ? COMPLETION_INCOMPLETE
                            : COMPLETION_COMPLETE;
                        // In manual mode the icon is a toggle form...

                        // If this completion state is used by the
                        // conditional activities system, we need to turn
                        // off the JS.
                        if (!empty($CFG->enableavailability) &&
                            condition_info::completion_value_used_as_condition($course, $mod)) {
                            $extraclass = ' preventjs';
                        } else {
                            $extraclass = '';
                        }
                        echo "
<form class='togglecompletion$extraclass' method='post' action='togglecompletion.php'><div>
<input type='hidden' name='id' value='{$mod->id}' />
<input type='hidden' name='sesskey' value='".sesskey()."' />
<input type='hidden' name='completionstate' value='$newstate' />
<input type='image' src='$imgsrc' alt='$imgalt' title='$imgtitle' />
</div></form>";
                    } else {
                        // In auto mode, or when editing, the icon is just an image
                        echo "<span class='autocompletion'>";
                        echo "<img src='$imgsrc' alt='$imgalt' title='$imgalt' /></span>";
                    }
                }
            }

            // Show availability information (for someone who isn't allowed to
            // see the activity itself, or for staff)
            if (!$mod->uservisible) {
                echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
            } else if ($canviewhidden && !empty($CFG->enableavailability)) {
                $ci = new condition_info($mod);
                $fullinfo = $ci->get_full_information();
                if($fullinfo) {
                    echo '<div class="availabilityinfo">'.get_string($mod->showavailability
                        ? 'userrestriction_visible'
                        : 'userrestriction_hidden','condition',
                        $fullinfo).'</div>';
                }
            }

            echo hook_show_activity_intro($mod);
            echo html_writer::end_tag('div');
            echo html_writer::end_tag('li')."\n";
        }

    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }

    if ($ismoving) {
        echo '<li><a title="'.$strmovefull.'"'.
             ' href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&amp;sesskey='.sesskey().'">'.
             '<img class="movetarget" src="'.$OUTPUT->pix_url('movehere') . '" '.
             ' alt="'.$strmovehere.'" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
 /**
  * This function is not part of the public api.
  */
 function print_headers()
 {
     global $CFG, $OUTPUT;
     echo '<tr>';
     foreach ($this->columns as $column => $index) {
         $icon_hide = '';
         $icon_sort = '';
         if ($this->is_collapsible) {
             if (!empty($this->sess->collapse[$column])) {
                 // some headers contain < br/> tags, do not include in title
                 $icon_hide = ' <a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SHOW] . '=' . $column . '"><img src="' . $OUTPUT->pix_url('t/switch_plus') . '" title="' . get_string('show') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('show') . '" /></a>';
             } else {
                 if ($this->headers[$index] !== NULL) {
                     // some headers contain < br/> tags, do not include in title
                     $icon_hide = ' <a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_HIDE] . '=' . $column . '"><img src="' . $OUTPUT->pix_url('t/switch_minus') . '" title="' . get_string('hide') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('hide') . '" /></a>';
                 }
             }
         }
         $primary_sort_column = '';
         $primary_sort_order = '';
         if (reset($this->sess->sortby)) {
             $primary_sort_column = key($this->sess->sortby);
             $primary_sort_order = current($this->sess->sortby);
         }
         switch ($column) {
             case 'fullname':
                 if ($this->is_sortable($column)) {
                     $icon_sort_first = $icon_sort_last = '';
                     if ($primary_sort_column == 'firstname') {
                         $lsortorder = get_string('asc');
                         if ($primary_sort_order == SORT_ASC) {
                             $icon_sort_first = ' <img src="' . $OUTPUT->pix_url('t/down') . '" alt="' . get_string('asc') . '" />';
                             $fsortorder = get_string('asc');
                         } else {
                             $icon_sort_first = ' <img src="' . $OUTPUT->pix_url('t/up') . '" alt="' . get_string('desc') . '" />';
                             $fsortorder = get_string('desc');
                         }
                     } else {
                         if ($primary_sort_column == 'lastname') {
                             $fsortorder = get_string('asc');
                             if ($primary_sort_order == SORT_ASC) {
                                 $icon_sort_last = ' <img src="' . $OUTPUT->pix_url('t/down') . '" alt="' . get_string('asc') . '" />';
                                 $lsortorder = get_string('asc');
                             } else {
                                 $icon_sort_last = ' <img src="' . $OUTPUT->pix_url('t/up') . '" alt="' . get_string('desc') . '" />';
                                 $lsortorder = get_string('desc');
                             }
                         } else {
                             $fsortorder = get_string('asc');
                             $lsortorder = get_string('asc');
                         }
                     }
                     $override = new object();
                     $override->firstname = 'firstname';
                     $override->lastname = 'lastname';
                     $fullnamelanguage = get_string('fullnamedisplay', '', $override);
                     if ($CFG->fullnamedisplay == 'firstname lastname' or $CFG->fullnamedisplay == 'firstname' or $CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'firstname lastname') {
                         $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SORT] . '=firstname">' . get_string('firstname') . get_accesshide(get_string('sortby') . ' ' . get_string('firstname') . ' ' . $fsortorder) . '</a> ' . $icon_sort_first . ' / ' . '<a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SORT] . '=lastname">' . get_string('lastname') . get_accesshide(get_string('sortby') . ' ' . get_string('lastname') . ' ' . $lsortorder) . '</a> ' . $icon_sort_last;
                     } else {
                         $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SORT] . '=lastname">' . get_string('lastname') . get_accesshide(get_string('sortby') . ' ' . get_string('lastname') . ' ' . $lsortorder) . '</a> ' . $icon_sort_last . ' / ' . '<a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SORT] . '=firstname">' . get_string('firstname') . get_accesshide(get_string('sortby') . ' ' . get_string('firstname') . ' ' . $fsortorder) . '</a> ' . $icon_sort_first;
                     }
                 }
                 break;
             case 'userpic':
                 // do nothing, do not display sortable links
                 break;
             default:
                 if ($this->is_sortable($column)) {
                     if ($primary_sort_column == $column) {
                         if ($primary_sort_order == SORT_ASC) {
                             $icon_sort = ' <img src="' . $OUTPUT->pix_url('t/down') . '" alt="' . get_string('asc') . '" />';
                             $localsortorder = get_string('asc');
                         } else {
                             $icon_sort = ' <img src="' . $OUTPUT->pix_url('t/up') . '" alt="' . get_string('desc') . '" />';
                             $localsortorder = get_string('desc');
                         }
                     } else {
                         $localsortorder = get_string('asc');
                     }
                     $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[ILP_TABLE_VAR_SORT] . '=' . $column . '">' . $this->headers[$index] . get_accesshide(get_string('sortby') . ' ' . $this->headers[$index] . ' ' . $localsortorder) . '</a>';
                 }
         }
         if ($this->headers[$index] === NULL) {
             echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col">&nbsp;</th>';
         } else {
             if (!empty($this->sess->collapse[$column])) {
                 echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col">' . $icon_hide . '</th>';
             } else {
                 // took out nowrap for accessibility, might need replacement
                 if (!is_array($this->column_style[$column])) {
                     // $usestyles = array('white-space:nowrap');
                     $usestyles = '';
                 } else {
                     // $usestyles = $this->column_style[$column]+array('white-space'=>'nowrap');
                     $usestyles = $this->column_style[$column];
                 }
                 echo '<th class="header c' . $index . $this->column_class[$column] . '" ' . $this->make_styles_string($usestyles) . ' scope="col">' . $this->headers[$index] . $icon_sort . '<div class="commands">' . $icon_hide . '</div></th>';
             }
         }
     }
     echo '</tr>';
 }
Beispiel #10
0
             $strsummary = ' - ' . substr($strsummary, 0, 60) . '...';
         }
         $sectionmenu['topic=' . $section] = s($section . $strsummary);
     }
     $section++;
     continue;
 }
 if ($showsection) {
     $currenttopic = $course->marker == $section;
     $currenttext = '';
     if (!$thissection->visible) {
         $sectionstyle = ' hidden';
     } else {
         if ($currenttopic) {
             $sectionstyle = ' current';
             $currenttext = get_accesshide(get_string('currenttopic', 'access'));
         } else {
             $sectionstyle = '';
         }
     }
     echo '<tr id="section-' . $section . '" class="section main' . $sectionstyle . '">';
     echo '<td class="left side">&nbsp;' . $currenttext . '</td>';
     echo '<td class="content">';
     if (!has_capability('moodle/course:viewhiddensections', $context) and !$thissection->visible) {
         // Hidden for students
         echo get_string('notavailable');
     } else {
         echo '<div class="summary">';
         $summaryformatoptions->noclean = true;
         echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
         if (isediting($course->id) && has_capability('moodle/course:update', $course->id)) {
Beispiel #11
0
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     global $PAGE;
     $modinfo = get_fast_modinfo($course);
     $course = course_get_format($course)->get_course();
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     //We want to save the last section, for adding a new one
     $lastsection = 0;
     // Now the list of sections..
     echo $this->start_section_list();
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         if ($section == 0) {
             // 0-section is displayed a little different then the others
             if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
                 echo $this->section_header($thissection, $course, false, 0);
                 echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
                 echo $this->courserenderer->course_section_add_cm_control($course, 0, 0);
                 echo $this->section_footer();
             }
             continue;
         }
         // Show the section if the user is permitted to access it, OR if it's not available
         // but showavailability is turned on (and there is some available info text).
         $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability && !empty($thissection->availableinfo);
         if (!$showsection) {
             // Hidden section message is overridden by 'unavailable' control
             // (showavailability option).
             if (!$course->hiddensections && $thissection->available) {
                 echo $this->section_hidden($section);
             }
             continue;
         }
         if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
             // Display section summary only.
             echo $this->section_summary($thissection, $course, null);
         } else {
             echo $this->section_header($thissection, $course, false, 0);
             if ($thissection->uservisible) {
                 echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
                 echo $this->courserenderer->course_section_add_cm_control($course, $section, 0);
             }
             echo $this->section_footer();
         }
         $lastsection = $section;
     }
     if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // this is not stealth section or it is empty
                 continue;
             }
             echo $this->stealth_section_header($section);
             echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = 'Ajouter une section';
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         $url = new moodle_url('changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey(), 'sectionid' => $lastsection + 1));
         echo html_writer::span($straddsection . " ");
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         echo '<br/>';
         // Add an activity (section with name activity, not visible)
         /*$url = new moodle_url('changenumsections.php',
               array('courseid' => $course->id,
                     'increase' => true,
                     'sesskey' => sesskey(),
                     'sectionid' => $lastsection+1,
                     'activity' => true ));
           $straddactivity = 'Ajouter une &eacute;valuation';
           $icon = $this->output->pix_icon('t/switch_plus', $straddactivity);
           echo html_writer::span($straddactivity." ");
           echo html_writer::link($url, $icon.get_accesshide($straddactivity), array('class' => 'increase-sections'));
           */
         echo html_writer::end_tag('div');
     } else {
         echo $this->end_section_list();
     }
 }
function print_section_newsroom($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%")
{
    /// Prints a section full of activity modules
    global $CFG, $USER;
    static $initialised;
    static $groupbuttons;
    static $groupbuttonslink;
    static $isediting;
    static $ismoving;
    static $strmovehere;
    static $strmovefull;
    static $strunreadpostsone;
    static $usetracking;
    static $groupings;
    if (!isset($initialised)) {
        $groupbuttons = ($course->groupmode or !$course->groupmodeforce);
        $groupbuttonslink = !$course->groupmodeforce;
        $isediting = isediting($course->id);
        $ismoving = $isediting && ismoving($course->id);
        if ($ismoving) {
            $strmovehere = get_string("movehere");
            $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'"));
        }
        include_once $CFG->dirroot . '/mod/forum/lib.php';
        if ($usetracking = forum_tp_can_track_forums()) {
            $strunreadpostsone = get_string('unreadpostsone', 'forum');
        }
        $initialised = true;
    }
    $labelformatoptions = new object();
    $labelformatoptions->noclean = true;
    /// Casting $course->modinfo to string prevents one notice when the field is null
    $modinfo = get_fast_modinfo($course);
    //Acccessibility: replace table with list <ul>, but don't output empty list.
    if (!empty($section->sequence)) {
        // Fix bug #5027, don't want style=\"width:$width\".
        echo "<ul class=\"section img-text\">\n";
        $sectionmods = explode(",", $section->sequence);
        foreach ($sectionmods as $modnumber) {
            if (empty($mods[$modnumber])) {
                continue;
            }
            $mod = $mods[$modnumber];
            if ($ismoving and $mod->id == $USER->activitycopy) {
                // do not display moving mod
                continue;
            }
            if (isset($modinfo->cms[$modnumber])) {
                if (!$modinfo->cms[$modnumber]->uservisible) {
                    // visibility shortcut
                    continue;
                }
            } else {
                if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) {
                    // module not installed
                    continue;
                }
                if (!coursemodule_visible_for_user($mod)) {
                    // full visibility check
                    continue;
                }
            }
            // The magic! ... if indent == 1 then ... hide module
            if ($mod->indent == 1) {
                $hiddemodule = 'hidden';
            } else {
                $hiddemodule = '';
            }
            echo '<li class="activity ' . $mod->modname . ' ' . $hiddemodule . '" id="module-' . $modnumber . '">';
            // Unique ID
            if ($ismoving) {
                echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a><br />
                     ';
            }
            if ($mod->indent) {
                print_spacer(12, 20 * $mod->indent, false);
            }
            $extra = '';
            if (!empty($modinfo->cms[$modnumber]->extra)) {
                $extra = $modinfo->cms[$modnumber]->extra;
            }
            if ($mod->modname == "label") {
                echo "<span class=\"";
                if (!$mod->visible) {
                    echo 'dimmed_text';
                } else {
                    echo 'label';
                }
                echo '">';
                echo format_text($extra, FORMAT_HTML, $labelformatoptions);
                echo "</span>";
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            } else {
                // Normal activity
                $instancename = format_string($modinfo->cms[$modnumber]->name, true, $course->id);
                if (!empty($modinfo->cms[$modnumber]->icon)) {
                    $icon = "{$CFG->pixpath}/" . $modinfo->cms[$modnumber]->icon;
                } else {
                    $icon = "{$CFG->modpixpath}/{$mod->modname}/icon.gif";
                }
                //Accessibility: for files get description via icon.
                $altname = '';
                if ('resource' == $mod->modname) {
                    if (!empty($modinfo->cms[$modnumber]->icon)) {
                        $possaltname = $modinfo->cms[$modnumber]->icon;
                        $mimetype = mimeinfo_from_icon('type', $possaltname);
                        $altname = get_mimetype_description($mimetype);
                    } else {
                        $altname = $mod->modfullname;
                    }
                } else {
                    $altname = $mod->modfullname;
                }
                // Avoid unnecessary duplication.
                if (false !== stripos($instancename, $altname)) {
                    $altname = '';
                }
                // File type after name, for alphabetic lists (screen reader).
                if ($altname) {
                    $altname = get_accesshide(' ' . $altname);
                }
                $linkcss = $mod->visible ? "" : " class=\"dimmed\" ";
                echo '<a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . $instancename . $altname . '</span></a>';
                //echo " $mod->modname ";
                // Special NEWSPAPER magic ... show summry from resource and blog's 200 chars from each post OUBlog (nadavkav)
                if ($mod->modname == 'resource') {
                    $article = get_record('resource', 'id', $mod->instance);
                    //print_r($article );
                    echo "{$article->summary}";
                }
                if ($mod->modname == 'oublog') {
                    require_once $CFG->dirroot . '/mod/oublog/locallib.php';
                    $oublog = get_record('oublog', 'id', $mod->instance);
                    if (!($oublogcm = get_coursemodule_from_instance('oublog', $oublog->id))) {
                        //error("Course module ID was incorrect");
                    }
                    $oublogcontext = get_context_instance(CONTEXT_MODULE, $oublogcm->id);
                    //oublog_check_view_permissions($oublog, $oublogcontext, $oublogcm);
                    $currentgroup = oublog_get_activity_group($oublogcm, true);
                    echo '<br/>';
                    /// Get Posts
                    list($posts, $recordcount) = oublog_get_posts($oublog, $oublogcontext, 0, $oublogcm, $currentgroup);
                    //, -1, $oubloguser->id, $tag, $canaudit);
                    $i = 0;
                    foreach ($posts as $post) {
                        if ($i < 3) {
                            echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>';
                            $summaryformatoptions->noclean = false;
                            echo mb_substr(format_text($post->message, FORMAT_HTML, $summaryformatoptions), 1, 600) . "<hr/>";
                        }
                        if ($i > 2 and $i < 6) {
                            echo '<a href="' . $CFG->wwwroot . '/mod/oublog/viewpost.php?blog=' . $oublog->id . '&post=' . $post->id . '">' . $post->title . '</a><br/>';
                        }
                        $i++;
                    }
                    //print_r($article );
                    //echo "$article->summary";
                    echo '<br/><a ' . $linkcss . ' ' . $extra . ' href="' . $CFG->wwwroot . '/mod/' . $mod->modname . '/view.php?id=' . $mod->id . '">' . '<img src="' . $icon . '" class="activityicon" alt="" /> <span>' . get_string('more', 'format_newsroom') . '</span></a>';
                }
                if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            }
            if ($usetracking && $mod->modname == 'forum') {
                if ($unread = forum_tp_count_forum_unread_posts($mod, $course)) {
                    echo '<span class="unread"> <a href="' . $CFG->wwwroot . '/mod/forum/view.php?id=' . $mod->id . '">';
                    if ($unread == 1) {
                        echo $strunreadpostsone;
                    } else {
                        print_string('unreadpostsnumber', 'forum', $unread);
                    }
                    echo '</a></span>';
                }
            }
            if ($isediting) {
                // TODO: we must define this as mod property!
                if ($groupbuttons and $mod->modname != 'label' and $mod->modname != 'resource' and $mod->modname != 'glossary') {
                    if (!($mod->groupmodelink = $groupbuttonslink)) {
                        $mod->groupmode = $course->groupmode;
                    }
                } else {
                    $mod->groupmode = false;
                }
                echo '&nbsp;&nbsp;';
                echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
            }
            echo "</li>\n";
        }
    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }
    if ($ismoving) {
        echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&amp;sesskey=' . $USER->sesskey . '">' . '<img class="movetarget" src="' . $CFG->pixpath . '/movehere.gif" ' . ' alt="' . $strmovehere . '" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
Beispiel #13
0
 /**
  * Renders html to display the module content on the course page (i.e. text of the labels)
  *
  * @param cm_info $mod
  * @param array $displayoptions
  * @return string
  */
 public function course_section_cm_text(cm_info $mod, $displayoptions = array())
 {
     $output = '';
     if (!$mod->uservisible && (empty($mod->showavailability) || empty($mod->availableinfo))) {
         // nothing to be displayed to the user
         return $output;
     }
     $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
     $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
     $accessiblebutdim = !$mod->visible || $conditionalhidden;
     $textclasses = '';
     $accesstext = '';
     if ($accessiblebutdim) {
         $textclasses .= ' dimmed_text';
         if ($conditionalhidden) {
             $textclasses .= ' conditionalhidden';
         }
         if ($mod->uservisible) {
             // show accessibility note only if user can access the module himself
             $accesstext = get_accesshide(get_string('hiddenfromstudents') . ': ');
         }
     }
     if ($mod->get_url()) {
         if ($content) {
             // If specified, display extra content after link.
             $output = html_writer::tag('div', $content, array('class' => trim('contentafterlink ' . $textclasses)));
         }
     } else {
         // No link, so display only content.
         $output = html_writer::tag('div', $accesstext . $content, array('class' => $textclasses));
     }
     return $output;
 }
Beispiel #14
0
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     global $PAGE, $SESSION, $DB, $USER;
     $updateposition = get_string('updateposition', 'format_gps');
     $loadinggps = html_writer::div(get_string('loadinggps', 'format_gps'), 'loadinggps');
     echo $loadinggps;
     $modaldiv = html_writer::div($updateposition, 'updateposition hide', array('id' => 'updatepositionclick'));
     echo $modaldiv;
     // Module form with map.
     $viewcourse = new moodle_url('/course/view.php', array('id' => $course->id));
     $link = html_writer::link($viewcourse, get_string('update'), array('class' => 'gps-continue'));
     $innerdiv = html_writer::div($link, 'innerdiv', array('id' => 'innerdiv'));
     $updatecourseviewlink = html_writer::div($innerdiv, 'buttonbubble', array('id' => 'outerdiv'));
     $map = html_writer::div('', 'googlemap', array('id' => 'map'));
     $mapcontainer = html_writer::div($map . $updatecourseviewlink, 'mapcontainer', array('id' => 'mapcontainer'));
     $modalform = html_writer::div($mapcontainer, 'popupgeo', array('id' => 'popupgeo'));
     echo $modalform;
     $modinfo = get_fast_modinfo($course);
     $course = course_get_format($course)->get_course();
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     // Now the list of sections..
     echo $this->start_section_list();
     $location = $this->gps_get_user_location($USER->id);
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         if ($section == 0) {
             // 0-section is displayed a little different then the others.
             if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
                 echo $this->section_header($thissection, $course, false, 0);
                 $courserenderer = $PAGE->get_renderer('core', 'course');
                 echo $courserenderer->course_section_cm_list($course, $thissection, 0);
                 if ($PAGE->user_is_editing()) {
                     echo $courserenderer->course_section_add_cm_control($course, 0, 0);
                 }
                 echo $this->section_footer();
             }
             continue;
         }
         if ($section > $course->numsections) {
             // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
             continue;
         }
         // Show the section if the user is permitted to access it, OR if it's not available.
         // but showavailability is turned on (and there is some available info text).
         $proximity = new stdClass();
         if ($thissection->format_gps_restricted == FORMAT_GPS_RESTRICTED) {
             if ($location) {
                 $proximity = format_gps_check_proximity($thissection, $location);
             } else {
                 $proximity->status = 'notallowed';
             }
         } else {
             $proximity->status = 'ok';
         }
         $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability && !empty($thissection->availableinfo);
         if (!$showsection || $proximity->status == 'toofar' || $proximity->status == 'notallowed') {
             if ($PAGE->user_is_editing() && has_capability('moodle/course:update', $context)) {
                 // Do nothing.
             } else {
                 $thissection->visible = false;
                 // Hidden section message is overridden by 'unavailable' control
                 // (showavailability option).
                 if ($proximity->status == 'toofar') {
                     if (!$course->hiddensections && $thissection->available) {
                         echo $this->gps_section_hidden($section);
                     }
                 } else {
                     if ($proximity->status == 'notallowed') {
                         if (!$course->hiddensections && $thissection->available) {
                             echo $this->gps_section_notallowed($section);
                         }
                     } else {
                         if (!$course->hiddensections && $thissection->available) {
                             echo $this->section_hidden($section);
                         }
                     }
                 }
                 continue;
             }
         }
         if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
             // Display section summary only.
             echo $this->section_summary($thissection, $course, null);
         } else {
             echo $this->section_header($thissection, $course, false, 0);
             if ($thissection->uservisible) {
                 $courserenderer = $PAGE->get_renderer('core', 'course');
                 echo $courserenderer->course_section_cm_list($course, $thissection, 0);
                 if ($PAGE->user_is_editing()) {
                     echo $courserenderer->course_section_add_cm_control($course, $section, 0);
                 }
             }
             echo $this->section_footer();
         }
     }
     if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // This is not stealth section or it is empty.
                 continue;
             }
             echo $this->stealth_section_header($section);
             $courserenderer = $PAGE->get_renderer('core', 'course');
             echo $courserenderer->course_section_cm_list($course, $thissection, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = get_string('increasesections', 'moodle');
         $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         if ($course->numsections > 0) {
             // Reduce number of sections sections.
             $strremovesection = get_string('reducesections', 'moodle');
             $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
             $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
             echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
         }
         echo html_writer::end_tag('div');
     } else {
         echo $this->end_section_list();
     }
 }
Beispiel #15
0
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     $modinfo = get_fast_modinfo($course);
     $course = course_get_format($course)->get_course();
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     $sections = $modinfo->get_section_info_all();
     // Remove general section.
     unset($sections[0]);
     // Now the list of sections..
     echo $this->start_section_list();
     $sections = $modinfo->get_section_info_all();
     $thissection = $sections[0];
     unset($sections[0]);
     if ($this->userisediting) {
         echo $this->start_section_list();
         // General section when editing or YUI D&D gets confused!
         echo $this->section_header($thissection, $course, false, 0);
         echo $this->section_footer();
     }
     // Tabs.
     if (!$this->userisediting) {
         echo html_writer::start_tag('ul', array('class' => 'nav nav-pills nav-wizard', 'role' => 'tablist'));
         foreach ($sections as $section => $thissection) {
             $first = false;
             $last = false;
             if ($section > $course->numsections) {
                 // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
                 continue;
             }
             if ($section == $course->numsections) {
                 $last = true;
             }
             if ($section == 1) {
                 $first = true;
             }
             /* Show the section if the user is permitted to access it, OR if it's not available
                but there is some available info text which explains the reason & should display. */
             $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo);
             if (!$showsection) {
                 continue;
             }
             $tabattributes = array('role' => 'presentation', 'id' => 'navtab' . $section, 'class' => 'tabbednavtab');
             if (!$this->activesection) {
                 $this->activesection = $thissection->section;
                 $tabattributes['class'] = 'tabbednavtab active';
             }
             echo html_writer::start_tag('li', $tabattributes);
             if (!$first) {
                 echo html_writer::tag('div', '', array('class' => 'nav-wedge'));
             }
             echo html_writer::tag('a', $this->courseformat->get_section_name($thissection), array('href' => '#section-' . $thissection->section, 'data-toggle' => 'tab', 'role' => 'tab', 'aria-controls' => 'section-' . $thissection->section));
             if (!$last) {
                 echo html_writer::tag('div', '', array('class' => 'nav-arrow'));
             }
             echo html_writer::end_tag('li');
         }
         echo html_writer::end_tag('ul');
         echo html_writer::start_tag('div', array('id' => 'tabbedcontent', 'class' => 'tab-content'));
     }
     // Tabbed.
     foreach ($sections as $section => $thissection) {
         if ($section > $course->numsections) {
             // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
             continue;
         }
         /* Show the section if the user is permitted to access it, OR if it's not available
            but there is some available info text which explains the reason & should display. */
         $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo);
         if (!$showsection) {
             /* If the hiddensections option is set to 'show hidden sections in collapsed
                form', then display the hidden section message - UNLESS the section is
                hidden by the availability system, which is set to hide the reason. */
             if (!$course->hiddensections && $thissection->available) {
                 echo $this->section_hidden($section, $course->id);
             }
             continue;
         }
         echo $this->section_header($thissection, $course, false, 0);
         if ($thissection->uservisible) {
             echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
             echo $this->courserenderer->course_section_add_cm_control($course, $section, 0);
             $sectionnavlinks = $this->get_nav_links($course, $modinfo->get_section_info_all(), $section);
             $navlinks = html_writer::start_tag('div', array('class' => 'section-navigation navigationtitle'));
             $navlinks .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'pull-left'));
             $navlinks .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'pull-right'));
             $navlinks .= html_writer::end_tag('div');
             echo $navlinks;
         }
         echo $this->section_footer();
     }
     if ($this->userisediting and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // This is not stealth section or it is empty.
                 continue;
             }
             echo $this->stealth_section_header($section);
             echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = get_string('increasesections', 'moodle');
         $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         if ($course->numsections > 0) {
             // Reduce number of sections sections.
             $strremovesection = get_string('reducesections', 'moodle');
             $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
             $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
             echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
         }
         echo html_writer::end_tag('div');
     } else {
         if ($this->userisediting) {
             echo $this->end_section_list();
         } else {
             echo html_writer::end_tag('div');
         }
     }
 }
Beispiel #16
0
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     global $PAGE;
     $modinfo = get_fast_modinfo($course);
     $course = course_get_format($course)->get_course();
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     echo "<style>\n            .left {display:none;} \n            h3 {line-height:none;} \n            .right {float:right;}\n            .section-modchooser {\n                width: 20px;\n                height: 20px;\n                background-color: red;\n                border-radius: 50%;\n                text-align: center;\n                float: right;\n                }\n            .section-modchooser-link img.smallicon {\n                padding-bottom: 3px;\n            }\n            .block, #page #page-content #region-main, #page #page-content div[role=\"main\"], .pagelayout-redirect #page-content #region-main, .pagelayout-redirect #page-content div[role=\"main\"] {\n                border: none;\n                border-radius: none;\n                padding: 0px;\n            }\n            .coursetitle {text-transform: uppercase; padding-bottom: 5px;}\n            .bor {display:none;}\n            </style>";
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     echo html_writer::start_div("tabbable tabs-left");
     echo html_writer::start_tag("ul", array("class" => "nav nav-tabs", "role" => "tablist"));
     // Show navigation tabs (bootstrap like)
     $tabshtml = "";
     $section0html = "";
     $currentfound = false;
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         $a = html_writer::tag("a", get_section_name($course, $thissection), array("href" => "#section-" . $section, "aria-controls" => "profile", "role" => "tab", "data-toggle" => "tab"));
         $style = "";
         if (course_get_format($course)->is_section_current($section)) {
             $style = "active";
             $currentfound = true;
         }
         if ($section == 0) {
             $section0html = $a;
         } else {
             $tabshtml .= html_writer::tag("li", $a, array("role" => "presentation", "class" => $style));
         }
     }
     $style = $currentfound ? "" : "active";
     echo html_writer::tag("li", $section0html, array("role" => "presentation", "class" => $style)) . $tabshtml;
     echo html_writer::end_tag("ul");
     // Now the list of sections..
     echo $this->start_section_list();
     $cmlist = "";
     $firstsection = "";
     $firstsectionhead = "";
     $firstsectionheadactive = "";
     $currentfound = false;
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         if (course_get_format($course)->is_section_current($section)) {
             $currentfound = true;
         }
         if ($section == 0) {
             // 0-section is displayed a little different then the others
             if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
                 $firstsectionhead = $this->section_header($thissection, $course, false, 0, false);
                 $firstsectionheadactive = $this->section_header($thissection, $course, false, 0, true);
                 $firstsection .= $this->courserenderer->course_section_cm_list($course, $thissection, 0);
                 $firstsection .= $this->courserenderer->course_section_add_cm_control($course, 0, 0);
                 $firstsection .= $this->section_footer();
             }
             continue;
         }
         if ($section > $course->numsections) {
             // activities inside this section are 'orphaned', this section will be printed as 'stealth' below
             continue;
         }
         // Show the section if the user is permitted to access it, OR if it's not available
         // but there is some available info text which explains the reason & should display.
         $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo);
         if (!$showsection) {
             // If the hiddensections option is set to 'show hidden sections in collapsed
             // form', then display the hidden section message - UNLESS the section is
             // hidden by the availability system, which is set to hide the reason.
             if (!$course->hiddensections && $thissection->available) {
                 $cmlist .= $this->section_hidden($section, $course->id);
             }
             continue;
         }
         if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
             // Display section summary only.
             $cmlist .= $this->section_summary($thissection, $course, null);
         } else {
             $cmlist .= $this->section_header($thissection, $course, false, 0);
             if ($thissection->uservisible) {
                 $cmlist .= $this->courserenderer->course_section_cm_list($course, $thissection, 0);
                 $cmlist .= $this->courserenderer->course_section_add_cm_control($course, $section, 0);
             }
             $cmlist .= $this->section_footer();
         }
     }
     if (!$currentfound) {
         $firstsection = $firstsectionheadactive . $firstsection;
     } else {
         $firstsection = $firstsectionhead . $firstsection;
     }
     echo $firstsection . $cmlist;
     if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // this is not stealth section or it is empty
                 continue;
             }
             echo $this->stealth_section_header($section);
             echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::end_div();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = get_string('increasesections', 'moodle');
         $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         if ($course->numsections > 0) {
             // Reduce number of sections sections.
             $strremovesection = get_string('reducesections', 'moodle');
             $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
             $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
             echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
         }
         echo html_writer::end_tag('div');
     } else {
         echo $this->end_section_list();
     }
 }
 /**
  * Generate the HTML for the sort link. This is a helper method used by {@link print_headers()}.
  * @param string $text the text for the link.
  * @param string $column the column name, may be a fake column like 'firstname' or a real one.
  * @param bool $isprimary whether the is column is the current primary sort column.
  * @param int $order SORT_ASC or SORT_DESC
  * @return string HTML fragment.
  */
 protected function sort_link($text, $column, $isprimary, $order)
 {
     return html_writer::link($this->baseurl->out(false, array($this->request[TABLE_VAR_SORT] => $column)), $text . get_accesshide(get_string('sortby') . ' ' . $text . ' ' . $this->sort_order_name($isprimary, $order))) . ' ' . $this->sort_icon($isprimary, $order);
 }
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     global $PAGE;
     $modinfo = get_fast_modinfo($course);
     $course = course_get_format($course)->get_course();
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     // Now the list of sections..
     echo $this->start_section_list();
     foreach ($modinfo->get_section_info_all() as $section => $thissection) {
         if ($section == 0) {
             // 0-section is displayed a little different then the others
             if ($thissection->summary or !empty($modinfo->sections[0]) or $PAGE->user_is_editing()) {
                 echo $this->section_header($thissection, $course, false, 0);
                 print_section($course, $thissection, null, null, true, "100%", false, 0);
                 if ($PAGE->user_is_editing()) {
                     print_section_add_menus($course, 0, null, false, false, 0);
                 }
                 echo $this->section_footer();
             }
             continue;
         }
         if ($section > $course->numsections) {
             // activities inside this section are 'orphaned', this section will be printed as 'stealth' below
             continue;
         }
         // Show the section if the user is permitted to access it, OR if it's not available
         // but showavailability is turned on
         $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && $thissection->showavailability;
         if (!$showsection) {
             // Hidden section message is overridden by 'unavailable' control
             // (showavailability option).
             if (!$course->hiddensections && $thissection->available) {
                 if ($course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
                     echo $this->section_summary($thissection, $course, $mods);
                 } else {
                     echo $this->section_hidden($section);
                 }
             }
             continue;
         }
         if (!$PAGE->user_is_editing() && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
             // Display section summary only.
             echo $this->section_summary($thissection, $course, null);
         } else {
             echo $this->section_header($thissection, $course, false, 0);
             if ($thissection->uservisible) {
                 print_section($course, $thissection, null, null, true, "100%", false, 0);
                 if ($PAGE->user_is_editing()) {
                     print_section_add_menus($course, $section, null, false, false, 0);
                 }
             }
             echo $this->section_footer();
         }
     }
     if ($PAGE->user_is_editing() and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // this is not stealth section or it is empty
                 continue;
             }
             echo $this->stealth_section_header($section);
             print_section($course, $thissection, null, null, true, "100%", false, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = get_string('increasesections', 'moodle');
         $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         if ($course->numsections > 0) {
             // Reduce number of sections sections.
             $strremovesection = get_string('reducesections', 'moodle');
             $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
             $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
             echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
         }
         echo html_writer::end_tag('div');
     } else {
         echo $this->end_section_list();
     }
 }
Beispiel #19
0
    /**
     * Returns lang menu or '', this method also checks forcing of languages in courses.
     *
     * This function calls {@link core_renderer::render_single_select()} to actually display the language menu.
     *
     * @return string The lang menu HTML or empty string
     */
    public function lang_menu() {
        global $CFG;

        if (empty($CFG->langmenu)) {
            return '';
        }

        if ($this->page->course != SITEID and !empty($this->page->course->lang)) {
            // do not show lang menu if language forced
            return '';
        }

        $currlang = current_language();
        $langs = get_string_manager()->get_list_of_translations();

        if (count($langs) < 2) {
            return '';
        }

        $s = new single_select($this->page->url, 'lang', $langs, $currlang, null);
        $s->label = get_accesshide(get_string('language'));
        $s->class = 'langmenu';
        return $this->render($s);
    }
Beispiel #20
0
function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_year = false)
{
    global $CFG, $USER;
    $display = new stdClass();
    $display->minwday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY);
    $display->maxwday = $display->minwday + 6;
    $content = '';
    if (!empty($cal_month) && !empty($cal_year)) {
        $thisdate = usergetdate(time());
        // Date and time the user sees at his location
        if ($cal_month == $thisdate['mon'] && $cal_year == $thisdate['year']) {
            // Navigated to this month
            $date = $thisdate;
            $display->thismonth = true;
        } else {
            // Navigated to other month, let's do a nice trick and save us a lot of work...
            if (!checkdate($cal_month, 1, $cal_year)) {
                $date = array('mday' => 1, 'mon' => $thisdate['mon'], 'year' => $thisdate['year']);
                $display->thismonth = true;
            } else {
                $date = array('mday' => 1, 'mon' => $cal_month, 'year' => $cal_year);
                $display->thismonth = false;
            }
        }
    } else {
        $date = usergetdate(time());
        // Date and time the user sees at his location
        $display->thismonth = true;
    }
    // Fill in the variables we 're going to use, nice and tidy
    list($d, $m, $y) = array($date['mday'], $date['mon'], $date['year']);
    // This is what we want to display
    $display->maxdays = calendar_days_in_month($m, $y);
    if (get_user_timezone_offset() < 99) {
        // We 'll keep these values as GMT here, and offset them when the time comes to query the db
        $display->tstart = gmmktime(0, 0, 0, $m, 1, $y);
        // This is GMT
        $display->tend = gmmktime(23, 59, 59, $m, $display->maxdays, $y);
        // GMT
    } else {
        // no timezone info specified
        $display->tstart = mktime(0, 0, 0, $m, 1, $y);
        $display->tend = mktime(23, 59, 59, $m, $display->maxdays, $y);
    }
    $startwday = dayofweek(1, $m, $y);
    // Align the starting weekday to fall in our display range
    // This is simple, not foolproof.
    if ($startwday < $display->minwday) {
        $startwday += 7;
    }
    // TODO: THIS IS TEMPORARY CODE!
    // [pj] I was just reading through this and realized that I when writing this code I was probably
    // asking for trouble, as all these time manipulations seem to be unnecessary and a simple
    // make_timestamp would accomplish the same thing. So here goes a test:
    //$test_start = make_timestamp($y, $m, 1);
    //$test_end   = make_timestamp($y, $m, $display->maxdays, 23, 59, 59);
    //if($test_start != usertime($display->tstart) - dst_offset_on($display->tstart)) {
    //notify('Failed assertion in calendar/lib.php line 126; display->tstart = '.$display->tstart.', dst_offset = '.dst_offset_on($display->tstart).', usertime = '.usertime($display->tstart).', make_t = '.$test_start);
    //}
    //if($test_end != usertime($display->tend) - dst_offset_on($display->tend)) {
    //notify('Failed assertion in calendar/lib.php line 130; display->tend = '.$display->tend.', dst_offset = '.dst_offset_on($display->tend).', usertime = '.usertime($display->tend).', make_t = '.$test_end);
    //}
    // Get the events matching our criteria. Don't forget to offset the timestamps for the user's TZ!
    $events = calendar_get_events(usertime($display->tstart) - dst_offset_on($display->tstart), usertime($display->tend) - dst_offset_on($display->tend), $users, $groups, $courses);
    // Set event course class for course events
    if (!empty($events)) {
        foreach ($events as $eventid => $event) {
            if (!empty($event->modulename)) {
                $cm = get_coursemodule_from_instance($event->modulename, $event->instance);
                if (!groups_course_module_visible($cm)) {
                    unset($events[$eventid]);
                }
            }
        }
    }
    // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
    // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
    // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
    // arguments to this function.
    $morehref = '';
    if (!empty($courses)) {
        $courses = array_diff($courses, array(SITEID));
        if (count($courses) == 1) {
            $morehref = '&amp;course=' . reset($courses);
        }
    }
    // We want to have easy access by day, since the display is on a per-day basis.
    // Arguments passed by reference.
    //calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
    calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday, $courses);
    //Accessibility: added summary and <abbr> elements.
    ///global $CALENDARDAYS; appears to be broken.
    $days_title = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
    $summary = get_string('calendarheading', 'calendar', userdate(make_timestamp($y, $m), get_string('strftimemonthyear')));
    $summary = get_string('tabledata', 'access', $summary);
    $content .= '<table class="minicalendar" summary="' . $summary . '">';
    // Begin table
    $content .= '<tr class="weekdays">';
    // Header row: day names
    // Print out the names of the weekdays
    $days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
    for ($i = $display->minwday; $i <= $display->maxwday; ++$i) {
        // This uses the % operator to get the correct weekday no matter what shift we have
        // applied to the $display->minwday : $display->maxwday range from the default 0 : 6
        $content .= '<th scope="col"><abbr title="' . get_string($days_title[$i % 7], 'calendar') . '">' . get_string($days[$i % 7], 'calendar') . "</abbr></th>\n";
    }
    $content .= '</tr><tr>';
    // End of day names; prepare for day numbers
    // For the table display. $week is the row; $dayweek is the column.
    $dayweek = $startwday;
    // Paddding (the first week may have blank days in the beginning)
    for ($i = $display->minwday; $i < $startwday; ++$i) {
        $content .= '<td class="dayblank">&nbsp;</td>' . "\n";
    }
    // Now display all the calendar
    for ($day = 1; $day <= $display->maxdays; ++$day, ++$dayweek) {
        if ($dayweek > $display->maxwday) {
            // We need to change week (table row)
            $content .= '</tr><tr>';
            $dayweek = $display->minwday;
        }
        // Reset vars
        $cell = '';
        if (CALENDAR_WEEKEND & 1 << $dayweek % 7) {
            // Weekend. This is true no matter what the exact range is.
            $class = 'weekend day';
        } else {
            // Normal working day.
            $class = 'day';
        }
        // Special visual fx if an event is defined
        if (isset($eventsbyday[$day])) {
            $dayhref = calendar_get_link_href(CALENDAR_URL . 'view.php?view=day' . $morehref . '&amp;', $day, $m, $y);
            // OverLib popup
            $popupcontent = '';
            foreach ($eventsbyday[$day] as $eventid) {
                if (!isset($events[$eventid])) {
                    continue;
                }
                $event = $events[$eventid];
                if (!empty($event->modulename)) {
                    $popupicon = $CFG->modpixpath . '/' . $event->modulename . '/icon.gif';
                    $popupalt = $event->modulename;
                } else {
                    if ($event->courseid == SITEID) {
                        // Site event
                        $popupicon = $CFG->pixpath . '/c/site.gif';
                        $popupalt = '';
                    } else {
                        if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
                            // Course event
                            $popupicon = $CFG->pixpath . '/c/course.gif';
                            $popupalt = '';
                        } else {
                            if ($event->groupid) {
                                // Group event
                                $popupicon = $CFG->pixpath . '/c/group.gif';
                                $popupalt = '';
                            } else {
                                if ($event->userid) {
                                    // User event
                                    $popupicon = $CFG->pixpath . '/c/user.gif';
                                    $popupalt = '';
                                }
                            }
                        }
                    }
                }
                $popupcontent .= '<div><img class="icon" src="' . $popupicon . '" alt="' . $popupalt . '" /><a href="' . $dayhref . '#event_' . $event->id . '">' . format_string($event->name, true) . '</a></div>';
            }
            //Accessibility: functionality moved to calendar_get_popup.
            if ($display->thismonth && $day == $d) {
                $popup = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent);
            } else {
                $popup = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent);
            }
            // Class and cell content
            if (isset($typesbyday[$day]['startglobal'])) {
                $class .= ' event_global';
            } else {
                if (isset($typesbyday[$day]['startcourse'])) {
                    $class .= ' event_course';
                } else {
                    if (isset($typesbyday[$day]['startgroup'])) {
                        $class .= ' event_group';
                    } else {
                        if (isset($typesbyday[$day]['startuser'])) {
                            $class .= ' event_user';
                        }
                    }
                }
            }
            $cell = '<a href="' . $dayhref . '" ' . $popup . '>' . $day . '</a>';
        } else {
            $cell = $day;
        }
        if (isset($typesbyday[$day]['durationglobal'])) {
            $class .= ' duration_global';
        } else {
            if (isset($typesbyday[$day]['durationcourse'])) {
                $class .= ' duration_course';
            } else {
                if (isset($typesbyday[$day]['durationgroup'])) {
                    $class .= ' duration_group';
                } else {
                    if (isset($typesbyday[$day]['durationuser'])) {
                        $class .= ' duration_user';
                    }
                }
            }
        }
        // If event has a class set then add it to the table day <td> tag
        // Note: only one colour for minicalendar
        if (isset($eventsbyday[$day])) {
            foreach ($eventsbyday[$day] as $eventid) {
                if (!isset($events[$eventid])) {
                    continue;
                }
                $event = $events[$eventid];
                if (!empty($event->class)) {
                    $class .= ' ' . $event->class;
                }
                break;
            }
        }
        // Special visual fx for today
        //Accessibility: hidden text for today, and popup.
        if ($display->thismonth && $day == $d) {
            $class .= ' today';
            $today = get_string('today', 'calendar') . ' ' . userdate(time(), get_string('strftimedayshort'));
            if (!isset($eventsbyday[$day])) {
                $class .= ' eventnone';
                $popup = calendar_get_popup(true, false);
                $cell = '<a href="#" ' . $popup . '>' . $day . '</a>';
            }
            $cell = get_accesshide($today . ' ') . $cell;
        }
        // Just display it
        if (!empty($class)) {
            $class = ' class="' . $class . '"';
        }
        $content .= '<td' . $class . '>' . $cell . "</td>\n";
    }
    // Paddding (the last week may have blank days at the end)
    for ($i = $dayweek; $i <= $display->maxwday; ++$i) {
        $content .= '<td class="dayblank">&nbsp;</td>';
    }
    $content .= '</tr>';
    // Last row ends
    $content .= '</table>';
    // Tabular display of days ends
    return $content;
}
Beispiel #21
0
/**
 * Prints a section full of activity modules
 */
function print_section($course, $section, $mods, $modnamesused, $absolute = false, $width = "100%", $hidecompletion = false)
{
    global $CFG, $USER, $DB, $PAGE, $OUTPUT;
    static $initialised;
    static $groupbuttons;
    static $groupbuttonslink;
    static $isediting;
    static $ismoving;
    static $strmovehere;
    static $strmovefull;
    static $strunreadpostsone;
    static $groupings;
    static $modulenames;
    if (!isset($initialised)) {
        $groupbuttons = ($course->groupmode or !$course->groupmodeforce);
        $groupbuttonslink = !$course->groupmodeforce;
        $isediting = $PAGE->user_is_editing();
        $ismoving = $isediting && ismoving($course->id);
        if ($ismoving) {
            $strmovehere = get_string("movehere");
            $strmovefull = strip_tags(get_string("movefull", "", "'{$USER->activitycopyname}'"));
        }
        $modulenames = array();
        $initialised = true;
    }
    $modinfo = get_fast_modinfo($course);
    $completioninfo = new completion_info($course);
    //Accessibility: replace table with list <ul>, but don't output empty list.
    if (!empty($section->sequence)) {
        // Fix bug #5027, don't want style=\"width:$width\".
        echo "<ul class=\"section img-text\">\n";
        $sectionmods = explode(",", $section->sequence);
        foreach ($sectionmods as $modnumber) {
            if (empty($mods[$modnumber])) {
                continue;
            }
            /**
             * @var cm_info
             */
            $mod = $mods[$modnumber];
            if ($ismoving and $mod->id == $USER->activitycopy) {
                // do not display moving mod
                continue;
            }
            if (isset($modinfo->cms[$modnumber])) {
                // We can continue (because it will not be displayed at all)
                // if:
                // 1) The activity is not visible to users
                // and
                // 2a) The 'showavailability' option is not set (if that is set,
                //     we need to display the activity so we can show
                //     availability info)
                // or
                // 2b) The 'availableinfo' is empty, i.e. the activity was
                //     hidden in a way that leaves no info, such as using the
                //     eye icon.
                if (!$modinfo->cms[$modnumber]->uservisible && (empty($modinfo->cms[$modnumber]->showavailability) || empty($modinfo->cms[$modnumber]->availableinfo))) {
                    // visibility shortcut
                    continue;
                }
            } else {
                if (!file_exists("{$CFG->dirroot}/mod/{$mod->modname}/lib.php")) {
                    // module not installed
                    continue;
                }
                if (!coursemodule_visible_for_user($mod) && empty($mod->showavailability)) {
                    // full visibility check
                    continue;
                }
            }
            if (!isset($modulenames[$mod->modname])) {
                $modulenames[$mod->modname] = get_string('modulename', $mod->modname);
            }
            $modulename = $modulenames[$mod->modname];
            // In some cases the activity is visible to user, but it is
            // dimmed. This is done if viewhiddenactivities is true and if:
            // 1. the activity is not visible, or
            // 2. the activity has dates set which do not include current, or
            // 3. the activity has any other conditions set (regardless of whether
            //    current user meets them)
            $canviewhidden = has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $mod->id));
            $accessiblebutdim = false;
            if ($canviewhidden) {
                $accessiblebutdim = !$mod->visible;
                if (!empty($CFG->enableavailability)) {
                    $accessiblebutdim = $accessiblebutdim || $mod->availablefrom > time() || $mod->availableuntil && $mod->availableuntil < time() || count($mod->conditionsgrade) > 0 || count($mod->conditionscompletion) > 0;
                }
            }
            $liclasses = array();
            $liclasses[] = 'activity';
            $liclasses[] = $mod->modname;
            $liclasses[] = 'modtype_' . $mod->modname;
            $extraclasses = $mod->get_extra_classes();
            if ($extraclasses) {
                $liclasses = array_merge($liclasses, explode(' ', $extraclasses));
            }
            echo html_writer::start_tag('li', array('class' => join(' ', $liclasses), 'id' => 'module-' . $modnumber));
            if ($ismoving) {
                echo '<a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?moveto=' . $mod->id . '&amp;sesskey=' . sesskey() . '">' . '<img class="movetarget" src="' . $OUTPUT->pix_url('movehere') . '" ' . ' alt="' . $strmovehere . '" /></a><br />
                     ';
            }
            $classes = array('mod-indent');
            if (!empty($mod->indent)) {
                $classes[] = 'mod-indent-' . $mod->indent;
                if ($mod->indent > 15) {
                    $classes[] = 'mod-indent-huge';
                }
            }
            echo html_writer::start_tag('div', array('class' => join(' ', $classes)));
            // Get data about this course-module
            list($content, $instancename) = get_print_section_cm_text($modinfo->cms[$modnumber], $course);
            //Accessibility: for files get description via icon, this is very ugly hack!
            $altname = '';
            $altname = $mod->modfullname;
            if (!empty($customicon)) {
                $archetype = plugin_supports('mod', $mod->modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
                if ($archetype == MOD_ARCHETYPE_RESOURCE) {
                    $mimetype = mimeinfo_from_icon('type', $customicon);
                    $altname = get_mimetype_description($mimetype);
                }
            }
            // Avoid unnecessary duplication: if e.g. a forum name already
            // includes the word forum (or Forum, etc) then it is unhelpful
            // to include that in the accessible description that is added.
            if (false !== strpos(textlib::strtolower($instancename), textlib::strtolower($altname))) {
                $altname = '';
            }
            // File type after name, for alphabetic lists (screen reader).
            if ($altname) {
                $altname = get_accesshide(' ' . $altname);
            }
            // We may be displaying this just in order to show information
            // about visibility, without the actual link
            $contentpart = '';
            if ($mod->uservisible) {
                // Nope - in this case the link is fully working for user
                $linkclasses = '';
                $textclasses = '';
                if ($accessiblebutdim) {
                    $linkclasses .= ' dimmed';
                    $textclasses .= ' dimmed_text';
                    $accesstext = '<span class="accesshide">' . get_string('hiddenfromstudents') . ': </span>';
                } else {
                    $accesstext = '';
                }
                if ($linkclasses) {
                    $linkcss = 'class="' . trim($linkclasses) . '" ';
                } else {
                    $linkcss = '';
                }
                if ($textclasses) {
                    $textcss = 'class="' . trim($textclasses) . '" ';
                } else {
                    $textcss = '';
                }
                // Get on-click attribute value if specified
                $onclick = $mod->get_on_click();
                if ($onclick) {
                    $onclick = ' onclick="' . $onclick . '"';
                }
                if ($url = $mod->get_url()) {
                    // Display link itself
                    echo '<a ' . $linkcss . $mod->extra . $onclick . ' href="' . $url . '"><img src="' . $mod->get_icon_url() . '" class="activityicon" alt="' . $modulename . '" /> ' . $accesstext . '<span class="instancename">' . $instancename . $altname . '</span></a>';
                    // If specified, display extra content after link
                    if ($content) {
                        $contentpart = '<div class="' . trim('contentafterlink' . $textclasses) . '">' . $content . '</div>';
                    }
                } else {
                    // No link, so display only content
                    $contentpart = '<div ' . $textcss . $mod->extra . '>' . $accesstext . $content . '</div>';
                }
                if (!empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
                    if (!isset($groupings)) {
                        $groupings = groups_get_all_groupings($course->id);
                    }
                    echo " <span class=\"groupinglabel\">(" . format_string($groupings[$mod->groupingid]->name) . ')</span>';
                }
            } else {
                $textclasses = $extraclasses;
                $textclasses .= ' dimmed_text';
                if ($textclasses) {
                    $textcss = 'class="' . trim($textclasses) . '" ';
                } else {
                    $textcss = '';
                }
                $accesstext = '<span class="accesshide">' . get_string('notavailableyet', 'condition') . ': </span>';
                if ($url = $mod->get_url()) {
                    // Display greyed-out text of link
                    echo '<div ' . $textcss . $mod->extra . ' >' . '<img src="' . $mod->get_icon_url() . '" class="activityicon" alt="' . $modulename . '" /> <span>' . $instancename . $altname . '</span></div>';
                    // Do not display content after link when it is greyed out like this.
                } else {
                    // No link, so display only content (also greyed)
                    $contentpart = '<div ' . $textcss . $mod->extra . '>' . $accesstext . $content . '</div>';
                }
            }
            // Module can put text after the link (e.g. forum unread)
            echo $mod->get_after_link();
            // If there is content but NO link (eg label), then display the
            // content here (BEFORE any icons). In this case cons must be
            // displayed after the content so that it makes more sense visually
            // and for accessibility reasons, e.g. if you have a one-line label
            // it should work similarly (at least in terms of ordering) to an
            // activity.
            if (empty($url)) {
                echo $contentpart;
            }
            if ($isediting) {
                if ($groupbuttons and plugin_supports('mod', $mod->modname, FEATURE_GROUPS, 0)) {
                    if (!($mod->groupmodelink = $groupbuttonslink)) {
                        $mod->groupmode = $course->groupmode;
                    }
                } else {
                    $mod->groupmode = false;
                }
                echo '&nbsp;&nbsp;';
                echo make_editing_buttons($mod, $absolute, true, $mod->indent, $section->section);
                echo $mod->get_after_edit_icons();
            }
            // Completion
            $completion = $hidecompletion ? COMPLETION_TRACKING_NONE : $completioninfo->is_enabled($mod);
            if ($completion != COMPLETION_TRACKING_NONE && isloggedin() && !isguestuser() && $mod->uservisible) {
                $completiondata = $completioninfo->get_data($mod, true);
                $completionicon = '';
                if ($isediting) {
                    switch ($completion) {
                        case COMPLETION_TRACKING_MANUAL:
                            $completionicon = 'manual-enabled';
                            break;
                        case COMPLETION_TRACKING_AUTOMATIC:
                            $completionicon = 'auto-enabled';
                            break;
                        default:
                            // wtf
                    }
                } else {
                    if ($completion == COMPLETION_TRACKING_MANUAL) {
                        switch ($completiondata->completionstate) {
                            case COMPLETION_INCOMPLETE:
                                $completionicon = 'manual-n';
                                break;
                            case COMPLETION_COMPLETE:
                                $completionicon = 'manual-y';
                                break;
                        }
                    } else {
                        // Automatic
                        switch ($completiondata->completionstate) {
                            case COMPLETION_INCOMPLETE:
                                $completionicon = 'auto-n';
                                break;
                            case COMPLETION_COMPLETE:
                                $completionicon = 'auto-y';
                                break;
                            case COMPLETION_COMPLETE_PASS:
                                $completionicon = 'auto-pass';
                                break;
                            case COMPLETION_COMPLETE_FAIL:
                                $completionicon = 'auto-fail';
                                break;
                        }
                    }
                }
                if ($completionicon) {
                    $imgsrc = $OUTPUT->pix_url('i/completion-' . $completionicon);
                    $imgalt = s(get_string('completion-alt-' . $completionicon, 'completion', $mod->name));
                    if ($completion == COMPLETION_TRACKING_MANUAL && !$isediting) {
                        $imgtitle = s(get_string('completion-title-' . $completionicon, 'completion', $mod->name));
                        $newstate = $completiondata->completionstate == COMPLETION_COMPLETE ? COMPLETION_INCOMPLETE : COMPLETION_COMPLETE;
                        // In manual mode the icon is a toggle form...
                        // If this completion state is used by the
                        // conditional activities system, we need to turn
                        // off the JS.
                        if (!empty($CFG->enableavailability) && condition_info::completion_value_used_as_condition($course, $mod)) {
                            $extraclass = ' preventjs';
                        } else {
                            $extraclass = '';
                        }
                        echo "\n<form class='togglecompletion{$extraclass}' method='post' action='" . $CFG->wwwroot . "/course/togglecompletion.php'><div>\n<input type='hidden' name='id' value='{$mod->id}' />\n<input type='hidden' name='modulename' value='" . s($mod->name) . "' />\n<input type='hidden' name='sesskey' value='" . sesskey() . "' />\n<input type='hidden' name='completionstate' value='{$newstate}' />\n<input type='image' src='{$imgsrc}' alt='{$imgalt}' title='{$imgtitle}' />\n</div></form>";
                    } else {
                        // In auto mode, or when editing, the icon is just an image
                        echo "<span class='autocompletion'>";
                        echo "<img src='{$imgsrc}' alt='{$imgalt}' title='{$imgalt}' /></span>";
                    }
                }
            }
            // If there is content AND a link, then display the content here
            // (AFTER any icons). Otherwise it was displayed before
            if (!empty($url)) {
                echo $contentpart;
            }
            // Show availability information (for someone who isn't allowed to
            // see the activity itself, or for staff)
            if (!$mod->uservisible) {
                echo '<div class="availabilityinfo">' . $mod->availableinfo . '</div>';
            } else {
                if ($canviewhidden && !empty($CFG->enableavailability)) {
                    $ci = new condition_info($mod);
                    $fullinfo = $ci->get_full_information();
                    if ($fullinfo) {
                        echo '<div class="availabilityinfo">' . get_string($mod->showavailability ? 'userrestriction_visible' : 'userrestriction_hidden', 'condition', $fullinfo) . '</div>';
                    }
                }
            }
            echo html_writer::end_tag('div');
            echo html_writer::end_tag('li') . "\n";
        }
    } elseif ($ismoving) {
        echo "<ul class=\"section\">\n";
    }
    if ($ismoving) {
        echo '<li><a title="' . $strmovefull . '"' . ' href="' . $CFG->wwwroot . '/course/mod.php?movetosection=' . $section->id . '&amp;sesskey=' . sesskey() . '">' . '<img class="movetarget" src="' . $OUTPUT->pix_url('movehere') . '" ' . ' alt="' . $strmovehere . '" /></a></li>
             ';
    }
    if (!empty($section->sequence) || $ismoving) {
        echo "</ul><!--class='section'-->\n\n";
    }
}
Beispiel #22
0
/**
 * Return the left arrow with text ('previous'), and optionally embedded in a link.
 *
 * @global object
 * @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 $OUTPUT;
    // TODO: move to utput renderer
    $arrowclass = 'arrow ';
    if (!$url) {
        $arrowclass .= $addclass;
    }
    $arrow = '<span class="' . $arrowclass . '">' . $OUTPUT->larrow() . '</span>';
    $htmltext = '';
    if ($text) {
        $htmltext = '&nbsp;<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;
}
Beispiel #23
0
/**
 * @todo Check this function
 *
 * @global object
 * @global object
 * @global int
 * @global void This is never defined
 * @global object This is defined twice?
 * @param object $question
 */
function survey_print_multi($question) {
    global $USER, $DB, $qnum, $checklist, $DB, $OUTPUT; //TODO: this is sloppy globals abuse

    $stripreferthat = get_string("ipreferthat", "survey");
    $strifoundthat = get_string("ifoundthat", "survey");
    $strdefault    = get_string('notyetanswered', 'survey');
    $strresponses  = get_string('responses', 'survey');

    echo $OUTPUT->heading($question->text, 3, 'questiontext');
    echo "\n<table width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"surveytable\">";

    $options = explode( ",", $question->options);
    $numoptions = count($options);

    $oneanswer = ($question->type == 1 || $question->type == 2) ? true : false;

    echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
    echo "<th scope=\"col\" class=\"hresponse\">". get_string('notyetanswered', 'survey'). "</th>";
    while (list ($key, $val) = each ($options)) {
        echo "<th scope=\"col\" class=\"hresponse\">$val</th>\n";
    }
    echo "</tr>\n";

    if ($oneanswer) {
        echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
    } else {
        echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";
    }

    $subquestions = $DB->get_records_list("survey_questions", "id", explode(',', $question->multi));

    foreach ($subquestions as $q) {
        $qnum++;
        $rowclass = survey_question_rowclass($qnum);
        if ($q->text) {
            $q->text = get_string($q->text, "survey");
        }

        $oneanswer = ($q->type == 1 || $q->type == 2) ? true : false;
        if ($q->type == 2) {
            $P = "P";
        } else {
            $P = "";
        }

        echo "<tr class=\"$rowclass rblock\">";
        if ($oneanswer) {
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            echo $q->text ."</th>\n";

            $default = get_accesshide($strdefault);
            echo "<td class=\"whitecell\"><label for=\"q$P$q->id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_D\" value=\"0\" checked=\"checked\" />$default</label></td>";

            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "q$P" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }
            $checklist["q$P$q->id"] = 0;

        } else {
            // yu : fix for MDL-7501, possibly need to use user flag as this is quite ugly.
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            $qnum++;
            echo "<span class=\"preferthat smalltext\">$stripreferthat</span> &nbsp; ";
            echo "<span class=\"option\">$q->text</span></th>\n";

            $default = get_accesshide($strdefault);
            echo '<td class="whitecell"><label for="qP'. $P.$q->id .'"><input type="radio" name="qP'.$P.$q->id. '" id="qP'. $q->id .'" value="0" checked="checked" />'.$default.'</label></td>';


            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "qP" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"qP$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }
            echo "</tr>";

            echo "<tr class=\"$rowclass rblock\">";
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            echo "<span class=\"foundthat smalltext\">$strifoundthat</span> &nbsp; ";
            echo "<span class=\"option\">$q->text</span></th>\n";

            $default = get_accesshide($strdefault);
            echo '<td class="whitecell"><label for="q'. $q->id .'"><input type="radio" name="q'.$q->id. '" id="q'. $q->id .'" value="0" checked="checked" />'.$default.'</label></td>';

            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "q" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }

            $checklist["qP$q->id"] = 0;
            $checklist["q$q->id"] = 0;
        }
        echo "</tr>\n";
    }
    echo "</table>";
}
Beispiel #24
0
 /**
  * Render mr_html_table
  *
  * @param mr_html_table $table mr_html_table instance
  * @return string
  */
 protected function render_mr_html_table(mr_html_table $table)
 {
     $tag = new mr_html_tag();
     $rows = $table->get_rows();
     $columns = $table->get_columns(true);
     // Table setup
     $htmltable = new html_table();
     $htmltable->data = array();
     foreach ($table->get_attributes() as $name => $value) {
         if (property_exists($htmltable, $name)) {
             $htmltable->{$name} = $value;
         } else {
             $htmltable->attributes[$name] = $value;
         }
     }
     // Check if we have any column headings
     $haveheadings = false;
     foreach ($columns as $column) {
         if ($column->has_heading()) {
             $haveheadings = true;
             break;
         }
     }
     if ($haveheadings) {
         $htmltable->head = array();
         foreach ($columns as $column) {
             // Must set sortable to false if table is not sort enabled or if empty $rows
             if (!$table->get_sortenabled() or empty($rows)) {
                 $column->set_config('sortable', false);
             }
             $config = $column->get_config();
             // Figure out column sort controls
             if ($config->sortable) {
                 $icon = '';
                 $sortstr = get_string('asc');
                 $sortord = SORT_ASC;
                 if ($table->get_sort() == $column->get_name()) {
                     if ($table->get_order() == SORT_ASC) {
                         $icon = $tag->img()->src($this->output->pix_url('t/down'))->alt(get_string('asc'));
                         $sortstr = get_string('asc');
                         $sortord = SORT_DESC;
                     } else {
                         $icon = $tag->img()->src($this->output->pix_url('t/up'))->alt(get_string('desc'));
                     }
                 }
                 $url = $table->get_url()->out(false, array('tsort' => $config->name, 'torder' => $sortord));
                 $heading = get_string('sortby') . ' ' . $config->heading . ' ' . $sortstr;
                 $heading = $config->heading . get_accesshide($heading);
                 $heading = $tag->a($heading)->href($url) . $icon;
             } else {
                 $heading = $config->heading;
             }
             $cell = new html_table_cell($heading);
             $cell->attributes = array_merge($cell->attributes, $config->attributes);
             $htmltable->head[] = $cell;
         }
     }
     if (empty($rows)) {
         $cell = new html_table_cell($table->get_emptymessage());
         $cell->colspan = count($htmltable->head);
         $htmltable->data[] = new html_table_row(array($cell));
     } else {
         $htmltable->data = $this->convert_to_htmlrows($table);
     }
     return html_writer::tag('div', html_writer::table($htmltable), array('class' => 'mr_html_table'));
 }
Beispiel #25
0
/**
 * @todo Check this function
 *
 * @global object
 * @global object
 * @global int
 * @global void This is never defined
 * @global object This is defined twice?
 * @param object $question
 */
function survey_print_multi($question) {
    global $USER, $DB, $qnum, $checklist, $DB, $OUTPUT; //TODO: this is sloppy globals abuse

    $stripreferthat = get_string("ipreferthat", "survey");
    $strifoundthat = get_string("ifoundthat", "survey");
    $strdefault    = get_string('notyetanswered', 'survey');
    $strresponses  = get_string('responses', 'survey');

    echo $OUTPUT->heading($question->text, 3);
    echo "\n<table width=\"90%\" cellpadding=\"4\" cellspacing=\"1\" border=\"0\" class=\"surveytable\">";

    $options = explode( ",", $question->options);
    $numoptions = count($options);

    // COLLES Actual (which is having questions of type 1) and COLLES Preferred (type 2)
    // expect just one answer per question. COLLES Actual and Preferred (type 3) expects
    // two answers per question. ATTLS (having a single question of type 1) expects one
    // answer per question. CIQ is not using multiquestions (i.e. a question with subquestions).
    // Note that the type of subquestions does not really matter, it's the type of the
    // question itself that determines everything.
    $oneanswer = ($question->type == 1 || $question->type == 2) ? true : false;

    // COLLES Preferred (having questions of type 2) will use the radio elements with the name
    // like qP1, qP2 etc. COLLES Actual and ATTLS have radios like q1, q2 etc.
    if ($question->type == 2) {
        $P = "P";
    } else {
        $P = "";
    }

    echo "<tr class=\"smalltext\"><th scope=\"row\">$strresponses</th>";
    echo "<th scope=\"col\" class=\"hresponse\">". get_string('notyetanswered', 'survey'). "</th>";
    while (list ($key, $val) = each ($options)) {
        echo "<th scope=\"col\" class=\"hresponse\">$val</th>\n";
    }
    echo "</tr>\n";

    echo "<tr><th scope=\"col\" colspan=\"7\">$question->intro</th></tr>\n";

    $subquestions = survey_get_subquestions($question);

    foreach ($subquestions as $q) {
        $qnum++;
        if ($oneanswer) {
            $rowclass = survey_question_rowclass($qnum);
        } else {
            $rowclass = survey_question_rowclass(round($qnum / 2));
        }
        if ($q->text) {
            $q->text = get_string($q->text, "survey");
        }

        echo "<tr class=\"$rowclass rblock\">";
        if ($oneanswer) {
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            echo $q->text ."</th>\n";

            $default = get_accesshide($strdefault);
            echo "<td class=\"whitecell\"><label for=\"q$P$q->id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"q$P" . $q->id . "_D\" value=\"0\" checked=\"checked\" />$default</label></td>";

            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "q$P" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$P$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }
            $checklist["q$P$q->id"] = 0;

        } else {
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            $qnum++;
            echo "<span class=\"preferthat\">$stripreferthat</span> &nbsp; ";
            echo "<span class=\"option\">$q->text</span></th>\n";

            $default = get_accesshide($strdefault);
            echo '<td class="whitecell"><label for="qP'.$q->id.'"><input type="radio" name="qP'.$q->id.'" id="qP'.$q->id.'" value="0" checked="checked" />'.$default.'</label></td>';


            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "qP" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"qP$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }
            echo "</tr>";

            echo "<tr class=\"$rowclass rblock\">";
            echo "<th scope=\"row\" class=\"optioncell\">";
            echo "<b class=\"qnumtopcell\">$qnum</b> &nbsp; ";
            echo "<span class=\"foundthat\">$strifoundthat</span> &nbsp; ";
            echo "<span class=\"option\">$q->text</span></th>\n";

            $default = get_accesshide($strdefault);
            echo '<td class="whitecell"><label for="q'. $q->id .'"><input type="radio" name="q'.$q->id. '" id="q'. $q->id .'" value="0" checked="checked" />'.$default.'</label></td>';

            for ($i=1;$i<=$numoptions;$i++) {
                $hiddentext = get_accesshide($options[$i-1]);
                $id = "q" . $q->id . "_$i";
                echo "<td><label for=\"$id\"><input type=\"radio\" name=\"q$q->id\" id=\"$id\" value=\"$i\" />$hiddentext</label></td>";
            }

            $checklist["qP$q->id"] = 0;
            $checklist["q$q->id"] = 0;
        }
        echo "</tr>\n";
    }
    echo "</table>";
}
Beispiel #26
0
 /**
  * Renders html to display the module content on the course page (i.e. text of the labels)
  *
  * @param cm_info $mod
  * @param array $displayoptions
  * @return string
  */
 public function course_section_cm_text(cm_info $mod, $displayoptions = array())
 {
     $output = '';
     if (!$mod->uservisible && empty($mod->availableinfo)) {
         // nothing to be displayed to the user
         return $output;
     }
     $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true));
     $accesstext = '';
     $textclasses = '';
     if ($mod->uservisible) {
         $conditionalhidden = $this->is_cm_conditionally_hidden($mod);
         $accessiblebutdim = (!$mod->visible || $conditionalhidden) && has_capability('moodle/course:viewhiddenactivities', $mod->context);
         if ($accessiblebutdim) {
             $textclasses .= ' dimmed_text';
             if ($conditionalhidden) {
                 $textclasses .= ' conditionalhidden';
             }
             // Show accessibility note only if user can access the module himself.
             $accesstext = get_accesshide(get_string('hiddenfromstudents') . ':' . $mod->modfullname);
         }
     } else {
         $textclasses .= ' dimmed_text';
     }
     if ($mod->url) {
         if ($content) {
             // If specified, display extra content after link.
             $output = html_writer::tag('div', $content, array('class' => trim('contentafterlink ' . $textclasses)));
         }
     } else {
         $groupinglabel = $mod->get_grouping_label($textclasses);
         // No link, so display only content.
         $output = html_writer::tag('div', $accesstext . $content . $groupinglabel, array('class' => 'contentwithoutlink ' . $textclasses));
     }
     return $output;
 }
 /**
  * Output the html for a multiple section page
  *
  * @param stdClass $course The course entry from DB
  * @param array $sections (argument not used)
  * @param array $mods (argument not used)
  * @param array $modnames (argument not used)
  * @param array $modnamesused (argument not used)
  */
 public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused)
 {
     $modinfo = get_fast_modinfo($course);
     $course = $this->courseformat->get_course();
     if (empty($this->tcsettings)) {
         $this->tcsettings = $this->courseformat->get_settings();
     }
     $context = context_course::instance($course->id);
     // Title with completion help icon.
     $completioninfo = new completion_info($course);
     echo $completioninfo->display_help_icon();
     echo $this->output->heading($this->page_title(), 2, 'accesshide');
     // Copy activity clipboard..
     echo $this->course_activity_clipboard($course, 0);
     // Now the list of sections..
     $this->tccolumnwidth = 100;
     // Reset to default.
     echo $this->start_section_list();
     $sections = $modinfo->get_section_info_all();
     // General section if non-empty.
     $thissection = $sections[0];
     unset($sections[0]);
     if ($thissection->summary or !empty($modinfo->sections[0]) or $this->userisediting) {
         echo $this->section_header($thissection, $course, false, 0);
         echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
         echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0, 0);
         echo $this->section_footer();
     }
     if ($course->numsections > 0) {
         if ($course->numsections > 1) {
             if ($this->userisediting || $course->coursedisplay != COURSE_DISPLAY_MULTIPAGE) {
                 // Collapsed Topics all toggles.
                 echo $this->toggle_all();
                 if ($this->tcsettings['displayinstructions'] == 2) {
                     // Collapsed Topics instructions.
                     echo $this->display_instructions();
                 }
             }
         }
         $currentsectionfirst = false;
         if ($this->tcsettings['layoutstructure'] == 4) {
             $currentsectionfirst = true;
         }
         if ($this->tcsettings['layoutstructure'] != 3 || $this->userisediting) {
             $section = 1;
         } else {
             $timenow = time();
             $weekofseconds = 604800;
             $course->enddate = $course->startdate + $weekofseconds * $course->numsections;
             $section = $course->numsections;
             $weekdate = $course->enddate;
             // This should be 0:00 Monday of that week.
             $weekdate -= 7200;
             // Subtract two hours to avoid possible DST problems.
         }
         $numsections = $course->numsections;
         // Because we want to manipulate this for column breakpoints.
         if ($this->tcsettings['layoutstructure'] == 3 && $this->userisediting == false) {
             $loopsection = 1;
             $numsections = 0;
             while ($loopsection <= $course->numsections) {
                 $nextweekdate = $weekdate - $weekofseconds;
                 if ((($thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo)) && $nextweekdate <= $timenow) == true) {
                     $numsections++;
                     // Section not shown so do not count in columns calculation.
                 }
                 $weekdate = $nextweekdate;
                 $section--;
                 $loopsection++;
             }
             // Reset.
             $section = $course->numsections;
             $weekdate = $course->enddate;
             // This should be 0:00 Monday of that week.
             $weekdate -= 7200;
             // Subtract two hours to avoid possible DST problems.
         }
         if ($numsections < $this->tcsettings['layoutcolumns']) {
             $this->tcsettings['layoutcolumns'] = $numsections;
             // Help to ensure a reasonable display.
         }
         if ($this->tcsettings['layoutcolumns'] > 1 && $this->mobiletheme === false) {
             if ($this->tcsettings['layoutcolumns'] > 4) {
                 // Default in config.php (and reset in database) or database has been changed incorrectly.
                 $this->tcsettings['layoutcolumns'] = 4;
                 // Update....
                 $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']);
             }
             if ($this->tablettheme === true && $this->tcsettings['layoutcolumns'] > 2) {
                 // Use a maximum of 2 for tablets.
                 $this->tcsettings['layoutcolumns'] = 2;
             }
             $this->tccolumnwidth = 100 / $this->tcsettings['layoutcolumns'];
             if ($this->tcsettings['layoutcolumnorientation'] == 2) {
                 // Horizontal column layout.
                 $this->tccolumnwidth -= 1;
             } else {
                 $this->tccolumnwidth -= 0.2;
             }
             $this->tccolumnpadding = 0;
             // In 'px'.
         } else {
             if ($this->tcsettings['layoutcolumns'] < 1) {
                 // Distributed default in plugin settings (and reset in database) or database has been changed incorrectly.
                 $this->tcsettings['layoutcolumns'] = 1;
                 // Update....
                 $this->courseformat->update_topcoll_columns_setting($this->tcsettings['layoutcolumns']);
             }
         }
         echo $this->end_section_list();
         echo $this->start_toggle_section_list();
         $loopsection = 1;
         $canbreak = false;
         // Once the first section is shown we can decide if we break on another column.
         $columncount = 1;
         $columnbreakpoint = 0;
         $shownsectioncount = 0;
         if ($this->userpreference != null) {
             $this->isoldtogglepreference = $this->togglelib->is_old_preference($this->userpreference);
             if ($this->isoldtogglepreference == true) {
                 $ts1 = base_convert(substr($this->userpreference, 0, 6), 36, 2);
                 $ts2 = base_convert(substr($this->userpreference, 6, 12), 36, 2);
                 $thesparezeros = "00000000000000000000000000";
                 if (strlen($ts1) < 26) {
                     // Need to PAD.
                     $ts1 = substr($thesparezeros, 0, 26 - strlen($ts1)) . $ts1;
                 }
                 if (strlen($ts2) < 27) {
                     // Need to PAD.
                     $ts2 = substr($thesparezeros, 0, 27 - strlen($ts2)) . $ts2;
                 }
                 $tb = $ts1 . $ts2;
             } else {
                 // Check we have enough digits for the number of toggles in case this has increased.
                 $numdigits = $this->togglelib->get_required_digits($course->numsections);
                 if ($numdigits > strlen($this->userpreference)) {
                     if ($this->defaultuserpreference == 0) {
                         $dchar = $this->togglelib->get_min_digit();
                     } else {
                         $dchar = $this->togglelib->get_max_digit();
                     }
                     for ($i = strlen($this->userpreference); $i < $numdigits; $i++) {
                         $this->userpreference .= $dchar;
                     }
                 }
                 $this->togglelib->set_toggles($this->userpreference);
             }
         } else {
             $numdigits = $this->togglelib->get_required_digits($course->numsections);
             if ($this->defaultuserpreference == 0) {
                 $dchar = $this->togglelib->get_min_digit();
             } else {
                 $dchar = $this->togglelib->get_max_digit();
             }
             $this->userpreference = '';
             for ($i = 0; $i < $numdigits; $i++) {
                 $this->userpreference .= $dchar;
             }
             $this->togglelib->set_toggles($this->userpreference);
         }
         while ($loopsection <= $course->numsections) {
             if ($this->tcsettings['layoutstructure'] == 3 && $this->userisediting == false) {
                 $nextweekdate = $weekdate - $weekofseconds;
             }
             $thissection = $modinfo->get_section_info($section);
             /* Show the section if the user is permitted to access it, OR if it's not available
                but there is some available info text which explains the reason & should display. */
             if ($this->tcsettings['layoutstructure'] != 3 || $this->userisediting) {
                 $showsection = $thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo);
             } else {
                 $showsection = ($thissection->uservisible || $thissection->visible && !$thissection->available && !empty($thissection->availableinfo)) && $nextweekdate <= $timenow;
             }
             if ($currentsectionfirst == true && $showsection == true) {
                 // Show  the section if we were meant to and it is the current section:....
                 $showsection = $course->marker == $section;
             } else {
                 if ($this->tcsettings['layoutstructure'] == 4 && $course->marker == $section) {
                     $showsection = false;
                     // Do not reshow current section.
                 }
             }
             if (!$showsection) {
                 // Hidden section message is overridden by 'unavailable' control.
                 if ($this->tcsettings['layoutstructure'] != 4) {
                     if ($this->tcsettings['layoutstructure'] != 3 || $this->userisediting) {
                         if (!$course->hiddensections && $thissection->available) {
                             $shownsectioncount++;
                             echo $this->section_hidden($thissection);
                         }
                     }
                 }
             } else {
                 $shownsectioncount++;
                 if (!$this->userisediting && $course->coursedisplay == COURSE_DISPLAY_MULTIPAGE) {
                     // Display section summary only.
                     echo $this->section_summary($thissection, $course, null);
                 } else {
                     if ($this->isoldtogglepreference == true) {
                         $togglestate = substr($tb, $section, 1);
                         if ($togglestate == '1') {
                             $thissection->toggle = true;
                         } else {
                             $thissection->toggle = false;
                         }
                     } else {
                         $thissection->toggle = $this->togglelib->get_toggle_state($thissection->section);
                     }
                     echo $this->section_header($thissection, $course, false, 0);
                     if ($thissection->uservisible) {
                         echo $this->courserenderer->course_section_cm_list($course, $thissection, 0);
                         echo $this->courserenderer->course_section_add_cm_control($course, $thissection->section, 0);
                     }
                     echo html_writer::end_tag('div');
                     echo $this->section_footer();
                 }
             }
             if ($currentsectionfirst == false) {
                 /* Only need to do this on the iteration when $currentsectionfirst is not true as this iteration will always
                    happen.  Otherwise you get duplicate entries in course_sections in the DB. */
                 unset($sections[$section]);
             }
             if ($this->tcsettings['layoutstructure'] != 3 || $this->userisediting) {
                 $section++;
             } else {
                 $section--;
                 if ($this->tcsettings['layoutstructure'] == 3 && $this->userisediting == false) {
                     $weekdate = $nextweekdate;
                 }
             }
             if ($this->mobiletheme === false) {
                 // Only break in non-mobile themes.
                 if ($this->tcsettings['layoutcolumnorientation'] == 1) {
                     // Only break columns in vertical mode.
                     if ($canbreak == false && $currentsectionfirst == false && $showsection == true) {
                         $canbreak = true;
                         $columnbreakpoint = $shownsectioncount + $numsections / $this->tcsettings['layoutcolumns'] - 1;
                         if ($this->tcsettings['layoutstructure'] == 4) {
                             $columnbreakpoint -= 1;
                         }
                     }
                     if ($currentsectionfirst == false && $canbreak == true && $shownsectioncount >= $columnbreakpoint && $columncount < $this->tcsettings['layoutcolumns']) {
                         echo $this->end_section_list();
                         echo $this->start_toggle_section_list();
                         $columncount++;
                         // Next breakpoint is...
                         $columnbreakpoint += $numsections / $this->tcsettings['layoutcolumns'];
                     }
                 }
             }
             $loopsection++;
             if ($currentsectionfirst == true && $loopsection > $course->numsections) {
                 // Now show the rest.
                 $currentsectionfirst = false;
                 $loopsection = 1;
                 $section = 1;
             }
             if ($section > $course->numsections) {
                 // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below.
                 break;
             }
         }
     }
     if ($this->userisediting and has_capability('moodle/course:update', $context)) {
         // Print stealth sections if present.
         foreach ($modinfo->get_section_info_all() as $section => $thissection) {
             if ($section <= $course->numsections or empty($modinfo->sections[$section])) {
                 // This is not stealth section or it is empty.
                 continue;
             }
             echo $this->stealth_section_header($section);
             echo $this->courserenderer->course_section_cm_list($course, $thissection->section, 0);
             echo $this->stealth_section_footer();
         }
         echo $this->end_section_list();
         echo html_writer::start_tag('div', array('id' => 'changenumsections', 'class' => 'mdl-right'));
         // Increase number of sections.
         $straddsection = get_string('increasesections', 'moodle');
         $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => true, 'sesskey' => sesskey()));
         $icon = $this->output->pix_icon('t/switch_plus', $straddsection);
         echo html_writer::link($url, $icon . get_accesshide($straddsection), array('class' => 'increase-sections'));
         if ($course->numsections > 0) {
             // Reduce number of sections sections.
             $strremovesection = get_string('reducesections', 'moodle');
             $url = new moodle_url('/course/changenumsections.php', array('courseid' => $course->id, 'increase' => false, 'sesskey' => sesskey()));
             $icon = $this->output->pix_icon('t/switch_minus', $strremovesection);
             echo html_writer::link($url, $icon . get_accesshide($strremovesection), array('class' => 'reduce-sections'));
         }
         echo html_writer::end_tag('div');
     } else {
         echo $this->end_section_list();
     }
 }
Beispiel #28
0
/**
 * This function will build the navigation string to be used by print_header
 * and others.
 *
 * It automatically generates the site and course level (if appropriate) links.
 *
 * If you pass in a $cm object, the method will also generate the activity (e.g. 'Forums')
 * and activityinstances (e.g. 'General Developer Forum') navigation levels.
 *
 * If you want to add any further navigation links after the ones this function generates,
 * the pass an array of extra link arrays like this:
 * array(
 *     array('name' => $linktext1, 'link' => $url1, 'type' => $linktype1),
 *     array('name' => $linktext2, 'link' => $url2, 'type' => $linktype2)
 * )
 * The normal case is to just add one further link, for example 'Editing forum' after
 * 'General Developer Forum', with no link.
 * To do that, you need to pass
 * array(array('name' => $linktext, 'link' => '', 'type' => 'title'))
 * However, becuase this is a very common case, you can use a shortcut syntax, and just
 * pass the string 'Editing forum', instead of an array as $extranavlinks.
 *
 * At the moment, the link types only have limited significance. Type 'activity' is
 * recognised in order to implement the $CFG->hideactivitytypenavlink feature. Types
 * that are known to appear are 'home', 'course', 'activity', 'activityinstance' and 'title'.
 * This really needs to be documented better. In the mean time, try to be consistent, it will
 * enable people to customise the navigation more in future.
 *
 * When passing a $cm object, the fields used are $cm->modname, $cm->name and $cm->course.
 * If you get the $cm object using the function get_coursemodule_from_instance or
 * get_coursemodule_from_id (as recommended) then this will be done for you automatically.
 * If you don't have $cm->modname or $cm->name, this fuction will attempt to find them using
 * the $cm->module and $cm->instance fields, but this takes extra database queries, so a
 * warning is printed in developer debug mode.
 *
 * @uses $CFG
 * @uses $THEME
 *
 * @param mixed $extranavlinks - Normally an array of arrays, keys: name, link, type. If you
 *      only want one extra item with no link, you can pass a string instead. If you don't want
 *      any extra links, pass an empty string.
 * @param mixed $cm - optionally the $cm object, if you want this function to generate the
 *      activity and activityinstance levels of navigation too.
 *
 * @return $navigation as an object so it can be differentiated from old style
 *      navigation strings.
 */
function build_navigation($extranavlinks, $cm = null)
{
    global $CFG, $COURSE, $DB, $SITE;
    if (is_string($extranavlinks)) {
        if ($extranavlinks == '') {
            $extranavlinks = array();
        } else {
            $extranavlinks = array(array('name' => $extranavlinks, 'link' => '', 'type' => 'title'));
        }
    }
    $navlinks = array();
    //Site name
    if (!empty($SITE->shortname)) {
        $navlinks[] = array('name' => format_string($SITE->shortname), 'link' => "{$CFG->wwwroot}/", 'type' => 'home');
    }
    // Course name, if appropriate.
    if (isset($COURSE) && $COURSE->id != SITEID) {
        $navlinks[] = array('name' => format_string($COURSE->shortname), 'link' => "{$CFG->wwwroot}/course/view.php?id={$COURSE->id}", 'type' => 'course');
    }
    // Activity type and instance, if appropriate.
    if (is_object($cm)) {
        if (!isset($cm->modname)) {
            debugging('The field $cm->modname should be set if you call build_navigation with ' . 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or ' . 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
            if (!($cm->modname = $DB->get_field('modules', 'name', array('id' => $cm->module)))) {
                print_error('cannotmoduletype');
            }
        }
        if (!isset($cm->name)) {
            debugging('The field $cm->name should be set if you call build_navigation with ' . 'a $cm parameter. If you get $cm using get_coursemodule_from_instance or ' . 'get_coursemodule_from_id, this will be done automatically.', DEBUG_DEVELOPER);
            if (!($cm->name = $DB->get_field($cm->modname, 'name', array('id' => $cm->instance)))) {
                print_error('cannotmodulename');
            }
        }
        $navlinks[] = array('name' => get_string('modulenameplural', $cm->modname), 'link' => $CFG->wwwroot . '/mod/' . $cm->modname . '/index.php?id=' . $cm->course, 'type' => 'activity');
        $navlinks[] = array('name' => format_string($cm->name), 'link' => $CFG->wwwroot . '/mod/' . $cm->modname . '/view.php?id=' . $cm->id, 'type' => 'activityinstance');
    }
    //Merge in extra navigation links
    $navlinks = array_merge($navlinks, $extranavlinks);
    // Work out whether we should be showing the activity (e.g. Forums) link.
    // Note: build_navigation() is called from many places --
    // install & upgrade for example -- where we cannot count on the
    // roles infrastructure to be defined. Hence the $CFG->rolesactive check.
    if (!isset($CFG->hideactivitytypenavlink)) {
        $CFG->hideactivitytypenavlink = 0;
    }
    if ($CFG->hideactivitytypenavlink == 2) {
        $hideactivitylink = true;
    } else {
        if ($CFG->hideactivitytypenavlink == 1 && $CFG->rolesactive && !empty($COURSE->id) && $COURSE->id != SITEID) {
            if (!isset($COURSE->context)) {
                $COURSE->context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
            }
            $hideactivitylink = !has_capability('moodle/course:manageactivities', $COURSE->context);
        } else {
            $hideactivitylink = false;
        }
    }
    //Construct an unordered list from $navlinks
    //Accessibility: heading hidden from visual browsers by default.
    $navigation = get_accesshide(get_string('youarehere', 'access'), 'h2') . " <ul>\n";
    $lastindex = count($navlinks) - 1;
    $i = -1;
    // Used to count the times, so we know when we get to the last item.
    $first = true;
    foreach ($navlinks as $navlink) {
        $i++;
        $last = $i == $lastindex;
        if (!is_array($navlink)) {
            continue;
        }
        if (!empty($navlink['type']) && $navlink['type'] == 'activity' && !$last && $hideactivitylink) {
            continue;
        }
        $navigation .= '<li class="first">';
        if (!$first) {
            $navigation .= get_separator();
        }
        if (!empty($navlink['link']) && !$last) {
            $navigation .= "<a onclick=\"this.target='{$CFG->framename}'\" href=\"{$navlink['link']}\">";
        }
        $navigation .= "{$navlink['name']}";
        if (!empty($navlink['link']) && !$last) {
            $navigation .= "</a>";
        }
        $navigation .= "</li>";
        $first = false;
    }
    $navigation .= "</ul>";
    return array('newnav' => true, 'navlinks' => $navigation);
}
Beispiel #29
0
        redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
    }
}
if (get_moodle_cookie() == '') {
    set_moodle_cookie('nobody');
    // To help search for cookies on login page
}
if (!empty($USER->id)) {
    add_to_log(SITEID, 'course', 'view', 'view.php?id=' . SITEID, SITEID);
}
if (empty($CFG->langmenu)) {
    $langmenu = '';
} else {
    $currlang = current_language();
    $langs = get_list_of_languages();
    $langlabel = get_accesshide(get_string('language'));
    $langmenu = popup_form($CFG->wwwroot . '/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
}
$PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
$pageblocks = blocks_setup($PAGE);
$editing = $PAGE->user_is_editing();
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), BLOCK_L_MAX_WIDTH);
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), BLOCK_R_MAX_WIDTH);
print_header($SITE->fullname, $SITE->fullname, 'home', '', '<meta name="description" content="' . strip_tags(format_text($SITE->summary, FORMAT_HTML)) . '" />', true, '', user_login_string($SITE) . $langmenu);
?>


<table id="layout-table" summary="layout">
  <tr>
  <?php 
$lt = empty($THEME->layouttable) ? array('left', 'middle', 'right') : $THEME->layouttable;
Beispiel #30
0
 function print_html()
 {
     global $CFG;
     if (!$this->setup) {
         return false;
     }
     $colcount = count($this->columns);
     // Do we need to print initial bars?
     if ($this->use_initials && isset($this->columns['fullname'])) {
         $strall = get_string('all');
         $alpha = explode(',', get_string('alphabet'));
         // Bar of first initials
         echo '<div class="initialbar firstinitial">' . get_string('firstname') . ' : ';
         if (!empty($this->sess->i_first)) {
             echo '<a href="' . $this->baseurl . $this->request[TABLE_VAR_IFIRST] . '=">' . $strall . '</a>';
         } else {
             echo '<strong>' . $strall . '</strong>';
         }
         foreach ($alpha as $letter) {
             if ($letter == $this->sess->i_first) {
                 echo ' <strong>' . $letter . '</strong>';
             } else {
                 echo ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_IFIRST] . '=' . $letter . '">' . $letter . '</a>';
             }
         }
         echo '</div>';
         // Bar of last initials
         echo '<div class="initialbar lastinitial">' . get_string('lastname') . ' : ';
         if (!empty($this->sess->i_last)) {
             echo '<a href="' . $this->baseurl . $this->request[TABLE_VAR_ILAST] . '=">' . $strall . '</a>';
         } else {
             echo '<strong>' . $strall . '</strong>';
         }
         foreach ($alpha as $letter) {
             if ($letter == $this->sess->i_last) {
                 echo ' <strong>' . $letter . '</strong>';
             } else {
                 echo ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_ILAST] . '=' . $letter . '">' . $letter . '</a>';
             }
         }
         echo '</div>';
     }
     // End of initial bars code
     // Paging bar
     if ($this->use_pages) {
         print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]);
     }
     if (empty($this->data)) {
         print_heading(get_string('nothingtodisplay'));
         return true;
     }
     $suppress_enabled = array_sum($this->column_suppress);
     $suppress_lastrow = NULL;
     // Start of main data table
     echo '<table' . $this->make_attributes_string($this->attributes) . '>';
     echo '<tr>';
     foreach ($this->columns as $column => $index) {
         $icon_hide = '';
         $icon_sort = '';
         if ($this->is_collapsible) {
             if (!empty($this->sess->collapse[$column])) {
                 // some headers contain < br/> tags, do not include in title
                 $icon_hide = ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_SHOW] . '=' . $column . '"><img src="' . $CFG->pixpath . '/t/switch_plus.gif" title="' . get_string('show') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('show') . '" /></a>';
             } else {
                 if ($this->headers[$index] !== NULL) {
                     // some headers contain < br/> tags, do not include in title
                     $icon_hide = ' <a href="' . $this->baseurl . $this->request[TABLE_VAR_HIDE] . '=' . $column . '"><img src="' . $CFG->pixpath . '/t/switch_minus.gif" title="' . get_string('hide') . ' ' . strip_tags($this->headers[$index]) . '" alt="' . get_string('hide') . '" /></a>';
                 }
             }
         }
         $primary_sort_column = '';
         $primary_sort_order = '';
         if (reset($this->sess->sortby)) {
             $primary_sort_column = key($this->sess->sortby);
             $primary_sort_order = current($this->sess->sortby);
         }
         switch ($column) {
             case 'fullname':
                 if ($this->is_sortable($column)) {
                     $icon_sort_first = $icon_sort_last = '';
                     if ($primary_sort_column == 'firstname') {
                         $lsortorder = get_string('asc');
                         if ($primary_sort_order == SORT_ASC) {
                             $icon_sort_first = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />';
                             $fsortorder = get_string('asc');
                         } else {
                             $icon_sort_first = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />';
                             $fsortorder = get_string('desc');
                         }
                     } else {
                         if ($primary_sort_column == 'lastname') {
                             $fsortorder = get_string('asc');
                             if ($primary_sort_order == SORT_ASC) {
                                 $icon_sort_last = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />';
                                 $lsortorder = get_string('asc');
                             } else {
                                 $icon_sort_last = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />';
                                 $lsortorder = get_string('desc');
                             }
                         } else {
                             $fsortorder = get_string('asc');
                             $lsortorder = get_string('asc');
                         }
                     }
                     $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=firstname">' . get_string('firstname') . get_accesshide(get_string('sortby') . ' ' . get_string('firstname') . ' ' . $fsortorder) . '</a> ' . $icon_sort_first . ' / ' . '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=lastname">' . get_string('lastname') . get_accesshide(get_string('sortby') . ' ' . get_string('lastname') . ' ' . $lsortorder) . '</a> ' . $icon_sort_last;
                 }
                 break;
             case 'userpic':
                 // do nothing, do not display sortable links
                 break;
             default:
                 if ($this->is_sortable($column)) {
                     if ($primary_sort_column == $column) {
                         if ($primary_sort_order == SORT_ASC) {
                             $icon_sort = ' <img src="' . $CFG->pixpath . '/t/down.gif" alt="' . get_string('asc') . '" />';
                             $localsortorder = get_string('asc');
                         } else {
                             $icon_sort = ' <img src="' . $CFG->pixpath . '/t/up.gif" alt="' . get_string('desc') . '" />';
                             $localsortorder = get_string('desc');
                         }
                     } else {
                         $localsortorder = get_string('asc');
                     }
                     $this->headers[$index] = '<a href="' . $this->baseurl . $this->request[TABLE_VAR_SORT] . '=' . $column . '">' . $this->headers[$index] . get_accesshide(get_string('sortby') . ' ' . $this->headers[$index] . ' ' . $localsortorder) . '</a>';
                 }
         }
         if ($this->headers[$index] === NULL) {
             echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col">&nbsp;</th>';
         } else {
             if (!empty($this->sess->collapse[$column])) {
                 echo '<th class="header c' . $index . $this->column_class[$column] . '" scope="col">' . $icon_hide . '</th>';
             } else {
                 // took out nowrap for accessibility, might need replacement
                 if (!is_array($this->column_style[$column])) {
                     // $usestyles = array('white-space:nowrap');
                     $usestyles = '';
                 } else {
                     // $usestyles = $this->column_style[$column]+array('white-space'=>'nowrap');
                     $usestyles = $this->column_style[$column];
                 }
                 echo '<th class="header c' . $index . $this->column_class[$column] . '" ' . $this->make_styles_string($usestyles) . ' scope="col">' . $this->headers[$index] . $icon_sort . '<div class="commands">' . $icon_hide . '</div></th>';
             }
         }
     }
     echo '</tr>';
     if (!empty($this->data)) {
         $oddeven = 1;
         $colbyindex = array_flip($this->columns);
         foreach ($this->data as $row) {
             $oddeven = $oddeven ? 0 : 1;
             echo '<tr class="r' . $oddeven . '">';
             // If we have a separator, print it
             if ($row === NULL && $colcount) {
                 echo '<td colspan="' . $colcount . '"><div class="tabledivider"></div></td>';
             } else {
                 foreach ($row as $index => $data) {
                     if ($index >= $colcount) {
                         break;
                     }
                     $column = $colbyindex[$index];
                     echo '<td class="cell c' . $index . $this->column_class[$column] . '"' . $this->make_styles_string($this->column_style[$column]) . '>';
                     if (empty($this->sess->collapse[$column])) {
                         if ($this->column_suppress[$column] && $suppress_lastrow !== NULL && $suppress_lastrow[$index] === $data) {
                             echo '&nbsp;';
                         } else {
                             echo $data;
                         }
                     } else {
                         echo '&nbsp;';
                     }
                     echo '</td>';
                 }
             }
             echo '</tr>';
             if ($suppress_enabled) {
                 $suppress_lastrow = $row;
             }
         }
     }
     echo '</table>';
     // Paging bar
     if ($this->use_pages) {
         print_paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl, $this->request[TABLE_VAR_PAGE]);
     }
 }