Пример #1
0
function report_stats_mode_menu($course, $mode, $time, $url)
{
    global $CFG, $OUTPUT;
    /*        
    $reportoptions = stats_get_report_options($course->id, $mode);
    $timeoptions = report_stats_timeoptions($mode);
    if (empty($timeoptions)) {
        print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
    }
    */
    $options = array();
    $options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
    $options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
    if (has_capability('coursereport/stats:view', get_context_instance(CONTEXT_SYSTEM))) {
        $options[STATS_MODE_RANKED] = get_string('reports');
    }
    $popupurl = $url . "?course={$course->id}&time={$time}";
    $select = html_select::make_popup_form($popupurl, 'mode', $options, 'switchmode', $mode);
    $select->nothinglabel = false;
    return $OUTPUT->select($select);
}
Пример #2
0
/**
 * @global object
 * @global object
 * @param object $cm
 * @param object $glossary
 * @param string $hook
 * @param object $category
 */
function glossary_print_categories_menu($cm, $glossary, $hook, $category)
{
    global $CFG, $DB, $OUTPUT;
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    echo '<table border="0" width="100%">';
    echo '<tr>';
    echo '<td align="center" style="width:20%">';
    if (has_capability('mod/glossary:managecategories', $context)) {
        $options['id'] = $cm->id;
        $options['mode'] = 'cat';
        $options['hook'] = $hook;
        echo $OUTPUT->button(html_form::make_button("editcategories.php", $options, get_string("editcategories", "glossary"), "get"));
    }
    echo '</td>';
    echo '<td align="center" style="width:60%">';
    echo '<b>';
    $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories", "glossary");
    $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised", "glossary");
    $categories = $DB->get_records("glossary_categories", array("glossaryid" => $glossary->id), "name ASC");
    $selected = '';
    if ($categories) {
        foreach ($categories as $currentcategory) {
            $url = $currentcategory->id;
            if ($category) {
                if ($currentcategory->id == $category->id) {
                    $selected = $url;
                }
            }
            $menu[$url] = clean_text($currentcategory->name);
            //Only clean, not filters
        }
    }
    if (!$selected) {
        $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
    }
    if ($category) {
        echo format_text($category->name, FORMAT_PLAIN);
    } else {
        if ($hook == GLOSSARY_SHOW_NOT_CATEGORISED) {
            echo get_string("entrieswithoutcategory", "glossary");
            $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
        } elseif ($hook == GLOSSARY_SHOW_ALL_CATEGORIES) {
            echo get_string("allcategories", "glossary");
            $selected = GLOSSARY_SHOW_ALL_CATEGORIES;
        }
    }
    echo '</b></td>';
    echo '<td align="center" style="width:20%">';
    $select = html_select::make_popup_form("{$CFG->wwwroot}/mod/glossary/view.php?id={$cm->id}&mode=cat", 'hook', $menu, "catmenu", $selected);
    $select->nothinglabel = false;
    echo $OUTPUT->select($select);
    echo '</td>';
    echo '</tr>';
    echo '</table>';
}
Пример #3
0
function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings)
{
    global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames;
    $row = array();
    $filter = $filterinfo->filter;
    // Filter name
    if (!empty($filternames[$filter])) {
        $row[] = $filternames[$filter];
    } else {
        $row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>';
    }
    // Disable/off/on
    $select = html_select::make_popup_form(action_url($filter, 'setstate'), 'newstate', $activechoices, 'active' . basename($filter), $filterinfo->active);
    $select->nothinglabel = false;
    $select->form->button->text = get_string('save', 'admin');
    $row[] = $OUTPUT->select($select);
    // Re-order
    $updown = '';
    $spacer = '<img src="' . $OUTPUT->old_icon_url('spacer') . '" class="iconsmall" alt="" /> ';
    if ($filterinfo->active != TEXTFILTER_DISABLED) {
        if (!$isfirstrow) {
            $updown .= action_icon(action_url($filter, 'up'), 'up', get_string('up'));
        } else {
            $updown .= $spacer;
        }
        if (!$islastactive) {
            $updown .= action_icon(action_url($filter, 'down'), 'down', get_string('down'));
        } else {
            $updown .= $spacer;
        }
    }
    $row[] = $updown;
    // Apply to strings.
    $select = html_select::make_popup_form(action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, 'applyto' . basename($filter), $applytostrings);
    $select->nothinglabel = false;
    $select->disabled = $filterinfo->active == TEXTFILTER_DISABLED;
    $select->form->button->text = get_string('save', 'admin');
    $row[] = $OUTPUT->select($select);
    // Settings link, if required
    if (filter_has_global_settings($filter)) {
        $row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . str_replace('/', '', $filter) . '">' . get_string('settings') . '</a>';
    } else {
        $row[] = '';
    }
    // Delete
    if (substr($filter, 0, 4) != 'mod/') {
        $row[] = '<a href="' . action_url($filter, 'delete') . '">' . get_string('delete') . '</a>';
    } else {
        $row[] = '';
    }
    return $row;
}
Пример #4
0
/**
 * Print grading plugin selection popup form.
 *
 * @param array   $plugin_info An array of plugins containing information for the selector
 * @param boolean $return return as string
 *
 * @return nothing or string if $return true
 */
function print_grade_plugin_selector($plugin_info, $return = false)
{
    global $CFG, $OUTPUT, $PAGE;
    $menu = array();
    $count = 0;
    $active = '';
    foreach ($plugin_info as $plugin_type => $plugins) {
        if ($plugin_type == 'strings') {
            continue;
        }
        $first_plugin = reset($plugins);
        $menu[$first_plugin->link . '&'] = '--' . $plugin_info['strings'][$plugin_type];
        if (empty($plugins->id)) {
            foreach ($plugins as $plugin) {
                $menu[$plugin->link] = $plugin->string;
                $count++;
            }
        }
    }
    // finally print/return the popup form
    if ($count > 1) {
        $select = html_select::make_popup_form('', '', $menu, 'choosepluginreport', '');
        $select->override_option_values($menu);
        if ($return) {
            return $OUTPUT->select($select);
        } else {
            echo $OUTPUT->select($select);
        }
    } else {
        // only one option - no plugin selector needed
        return '';
    }
}
Пример #5
0
        print_string('savechanges');
        ?>
" />
        <input type="submit" name="cancel" value="<?php 
        print_string('cancel');
        ?>
" />
    </div>
</div></form>

            <?php 
        echo $OUTPUT->box_end();
    }
    /// Print a form to swap roles, and a link back to the all roles list.
    echo '<div class="backlink">';
    $select = html_select::make_popup_form($baseurl, 'roleid', $nameswithcounts, 'switchrole', $roleid);
    $select->set_label(get_string('overrideanotherrole', 'role'));
    $select->nothinglabel = false;
    echo $OUTPUT->select($select);
    echo '<p><a href="' . $baseurl . '">' . get_string('backtoallroles', 'role') . '</a></p>';
    echo '</div>';
} else {
    if (empty($overridableroles)) {
        /// Print a message that there are no roles that can me assigned here.
        echo $OUTPUT->heading(get_string('notabletooverrideroleshere', 'role'), 3, 'mdl-align');
    } else {
        /// Show UI for choosing a role to assign.
        $table = new html_table();
        $table->tablealign = 'center';
        $table->width = '60%';
        $table->head = array(get_string('role'), get_string('description'), get_string('overrides', 'role'));
Пример #6
0
    $string = get_string('updatemymoodleon');
    $edit = '1';
}
$form = new html_form();
$form->url = new moodle_url("{$CFG->wwwroot}/my/index.php", array('edit' => $edit));
$form->button->text = $string;
$button = $OUTPUT->button($form);
$header = $SITE->shortname . ': ' . $strmymoodle;
$navigation = build_navigation($strmymoodle);
$loggedinas = user_login_string();
if (empty($CFG->langmenu)) {
    $langmenu = '';
} else {
    $currlang = current_language();
    $langs = get_list_of_languages();
    $select = html_select::make_popup_form($CFG->wwwroot . '/my/index.php', 'lang', $langs, 'chooselang', $currlang);
    $select->nothinglabel = false;
    $select->set_label(get_accesshide(get_string('language')));
    $langmenu = $OUTPUT->select($select);
}
print_header($strmymoodle, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
/// The main overview in the middle of the page
// limits the number of courses showing up
$courses_limit = 21;
if (!empty($CFG->mycoursesperpage)) {
    $courses_limit = $CFG->mycoursesperpage;
}
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, $courses_limit);
$site = get_site();
$course = $site;
//just in case we need the old global $course hack
Пример #7
0
/**
 * authorize_print_orders
 *
 */
function authorize_print_orders($courseid, $userid)
{
    global $course;
    global $CFG, $USER, $SITE, $DB, $OUTPUT, $PAGE;
    global $strs, $authstrs;
    require_once $CFG->libdir . '/tablelib.php';
    $perpage = optional_param('perpage', 10, PARAM_INT);
    $showonlymy = optional_param('showonlymy', 0, PARAM_BOOL);
    $searchquery = optional_param('searchquery', '0', PARAM_INT);
    $searchtype = optional_param('searchtype', 'orderid', PARAM_ALPHA);
    $status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
    $searchmenu = array('orderid' => $authstrs->orderid, 'transid' => $authstrs->transid, 'cclastfour' => $authstrs->cclastfour);
    $buttons = "<form method='post' action='index.php' autocomplete='off'><div>";
    $select = html_select::make($searchmenu, 'searchtype', $searchtype, false);
    $select->nothingvalue = '';
    $buttons .= $OUTPUT->select($select);
    $buttons .= "<input type='text' size='16' name='searchquery' value='' />";
    $buttons .= "<input type='submit' value='{$strs->search}' />";
    $buttons .= "</div></form>";
    if (has_capability('enrol/authorize:uploadcsv', get_context_instance(CONTEXT_USER, $USER->id))) {
        $buttons .= "<form method='get' action='uploadcsv.php'><div><input type='submit' value='" . get_string('uploadcsv', 'enrol_authorize') . "' /></div></form>";
    }
    $canmanagepayments = has_capability('enrol/authorize:managepayments', get_context_instance(CONTEXT_COURSE, $courseid));
    if ($showonlymy || !$canmanagepayments) {
        $userid = $USER->id;
    }
    $baseurl = $CFG->wwwroot . '/enrol/authorize/index.php?user='******'userid' => $userid);
    $sql = "SELECT c.id, c.fullname FROM {course} c JOIN {enrol_authorize} e ON c.id = e.courseid ";
    $sql .= $userid > 0 ? "WHERE (e.userid=:userid) " : '';
    $sql .= "ORDER BY c.sortorder, c.fullname";
    if ($popupcrs = $DB->get_records_sql_menu($sql, $params)) {
        $popupcrs = array($SITE->id => $SITE->fullname) + $popupcrs;
    }
    $popupmenu = empty($popupcrs) ? '' : $OUTPUT->select(html_select::make_popup_form($baseurl . '&status=' . $status, 'course', $popupcrs, 'coursesmenu', $courseid));
    $popupmenu .= '<br />';
    $statusmenu = array(AN_STATUS_NONE => $strs->all, AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW => $authstrs->allpendingorders, AN_STATUS_AUTH => $authstrs->authorizedpendingcapture, AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured, AN_STATUS_CREDIT => $authstrs->refunded, AN_STATUS_VOID => $authstrs->cancelled, AN_STATUS_EXPIRE => $authstrs->expired, AN_STATUS_UNDERREVIEW => $authstrs->underreview, AN_STATUS_APPROVEDREVIEW => $authstrs->approvedreview, AN_STATUS_REVIEWFAILED => $authstrs->reviewfailed, AN_STATUS_TEST => $authstrs->tested);
    $popupmenu .= $OUTPUT->select(html_select::make_popup_form($baseurl . '&course=' . $courseid, 'status', $statusmenu, 'statusmenu', $status));
    if ($canmanagepayments) {
        $popupmenu .= '<br />';
        $checkbox = html_select_option::make_checkbox(1, $userid == $USER->id, get_string('mypaymentsonly', 'enrol_authorize'));
        $PAGE->requires->js('enrol/authorize/authorize.js');
        $checkbox->add_action('click', 'authorize_jump_to_mypayments', array('userid' => $USER->id, 'status' => $status));
        $popupmenu .= $OUTPUT->checkbox($checkbox, 'showonlymy');
    }
    $navlinks = array();
    if (SITEID != $courseid) {
        $navlinks[] = array('name' => $course->shortname, 'link' => "{$CFG->wwwroot}/course/view.php?id=" . $course->id, 'type' => 'misc');
    }
    $navlinks[] = array('name' => $authstrs->paymentmanagement, 'link' => 'index.php', 'type' => 'misc');
    $navigation = build_navigation($navlinks);
    print_header("{$course->shortname}: {$authstrs->paymentmanagement}", $authstrs->paymentmanagement, $navigation, '', '', false, $buttons, $popupmenu);
    $table = new flexible_table('enrol-authorize');
    $table->set_attribute('width', '100%');
    $table->set_attribute('cellspacing', '0');
    $table->set_attribute('cellpadding', '3');
    $table->set_attribute('id', 'orders');
    $table->set_attribute('class', 'generaltable generalbox');
    if ($perpage > 100) {
        $perpage = 100;
    }
    $perpagemenus = array(5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
    $perpagemenu = $OUTPUT->select(html_select::make_popup_form($baseurl . '&status=' . $status . '&course=' . $courseid, 'perpage', $perpagemenus, 'perpagemenu', $perpage));
    $table->define_columns(array('id', 'userid', 'timecreated', 'status', 'action'));
    $table->define_headers(array($authstrs->orderid, $authstrs->shopper, $strs->time, $strs->status, $perpagemenu));
    $table->define_baseurl($baseurl . "&amp;status={$status}&amp;course={$courseid}&amp;perpage={$perpage}");
    $table->no_sorting('action');
    $table->sortable(true, 'id', SORT_DESC);
    $table->pageable(true);
    $table->setup();
    $select = "SELECT e.id, e.paymentmethod, e.refundinfo, e.transid, e.courseid, e.userid, e.status, e.ccname, e.timecreated, e.settletime ";
    $from = "FROM {enrol_authorize} e ";
    $where = "WHERE (1=1) ";
    $params = array();
    if (!empty($searchquery)) {
        switch ($searchtype) {
            case 'orderid':
                $where = "WHERE (e.id = :searchquery) ";
                $params['searchquery'] = $searchquery;
                break;
            case 'transid':
                $where = "WHERE (e.transid = :searchquery) ";
                $params['searchquery'] = $searchquery;
                break;
            case 'cclastfour':
                $searchquery = sprintf("%04d", $searchquery);
                $where = "WHERE (e.refundinfo = :searchquery) AND (e.paymentmethod=:method) ";
                $params['searchquery'] = $searchquery;
                $params['method'] = AN_METHOD_CC;
                break;
        }
    } else {
        switch ($status) {
            case AN_STATUS_NONE:
                if (empty($CFG->an_test)) {
                    $where .= "AND (e.status != :status) ";
                    $params['status'] = AN_STATUS_NONE;
                }
                break;
            case AN_STATUS_TEST:
                $newordertime = time() - 120;
                // -2 minutes. Order may be still in process.
                $where .= "AND (e.status = :status) AND (e.transid = '0') AND (e.timecreated < :newordertime) ";
                $params['status'] = AN_STATUS_NONE;
                $params['newordertime'] = $newordertime;
                break;
            case AN_STATUS_AUTH | AN_STATUS_UNDERREVIEW | AN_STATUS_APPROVEDREVIEW:
                $where .= 'AND (e.status IN(:status1,:status2,:status3)) ';
                $params['status1'] = AN_STATUS_AUTH;
                $params['status2'] = AN_STATUS_UNDERREVIEW;
                $params['status3'] = AN_STATUS_APPROVEDREVIEW;
                break;
            case AN_STATUS_CREDIT:
                $from .= "INNER JOIN {enrol_authorize_refunds} r ON e.id = r.orderid ";
                $where .= "AND (e.status = :status) ";
                $params['status'] = AN_STATUS_AUTHCAPTURE;
                break;
            default:
                $where .= "AND (e.status = :status) ";
                $params['status'] = $status;
                break;
        }
        if (SITEID != $courseid) {
            $where .= "AND (e.courseid = :courseid) ";
            $params['courseid'] = $courseid;
        }
    }
    // This must be always LAST where!!!
    if ($userid > 0) {
        $where .= "AND (e.userid = :userid) ";
        $params['userid'] = $userid;
    }
    if ($sort = $table->get_sql_sort()) {
        $sort = ' ORDER BY ' . $sort;
    }
    $totalcount = $DB->count_records_sql('SELECT COUNT(*) ' . $from . $where, $params);
    $table->initialbars($totalcount > $perpage);
    $table->pagesize($perpage, $totalcount);
    if ($records = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size())) {
        foreach ($records as $record) {
            $actionstatus = authorize_get_status_action($record);
            $color = authorize_get_status_color($actionstatus->status);
            $actions = '';
            if (empty($actionstatus->actions)) {
                $actions .= $strs->none;
            } else {
                foreach ($actionstatus->actions as $val) {
                    $actions .= authorize_print_action_button($record->id, $val);
                }
            }
            $table->add_data(array("<a href='index.php?order={$record->id}'>{$record->id}</a>", $record->ccname, userdate($record->timecreated), "<font style='color:{$color}'>" . $authstrs->{$actionstatus->status} . "</font>", $actions));
        }
    }
    $table->print_html();
    echo $OUTPUT->footer();
}
Пример #8
0
/**
 * Returns a little popup menu for switching roles
 *
 * @global object
 * @global object
 * @uses CONTEXT_COURSE
 * @param int $courseid The course  to update by id as found in 'course' table
 * @return string
 */
function switchroles_form($courseid)
{
    global $CFG, $USER, $OUTPUT;
    if (!($context = get_context_instance(CONTEXT_COURSE, $courseid))) {
        return '';
    }
    if (!empty($USER->access['rsw'][$context->path])) {
        // Just a button to return to normal
        $options = array();
        $options['id'] = $courseid;
        $options['sesskey'] = sesskey();
        $options['switchrole'] = 0;
        return $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/view.php', $options, get_string('switchrolereturn')));
    }
    if (has_capability('moodle/role:switchroles', $context)) {
        if (!($roles = get_switchable_roles($context))) {
            return '';
            // Nothing to show!
        }
        // unset default user role - it would not work
        unset($roles[$CFG->guestroleid]);
        $popupurl = $CFG->wwwroot . '/course/view.php?id=' . $courseid . '&sesskey=' . sesskey();
        $select = html_select::make_popup_form($popupurl, 'switchrole', $roles, 'switchrole', '');
        $select->nothinglabel = get_string('switchroleto');
        $select->set_help_icon('switchrole', get_string('switchroleto'));
        return $OUTPUT->select($select);
    }
    return '';
}
Пример #9
0
function calendar_course_filter_selector($getvars = '')
{
    global $USER, $SESSION, $OUTPUT;
    if (empty($USER->id) or isguest()) {
        return '';
    }
    if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM)) && !empty($CFG->calendar_adminseesall)) {
        $courses = get_courses('all', 'c.shortname', 'c.id,c.shortname');
    } else {
        $courses = get_my_courses($USER->id, 'shortname');
    }
    unset($courses[SITEID]);
    $courseoptions[SITEID] = get_string('fulllistofcourses');
    foreach ($courses as $course) {
        $courseoptions[$course->id] = format_string($course->shortname);
    }
    if (is_numeric($SESSION->cal_courses_shown)) {
        $selected = $SESSION->cal_courses_shown;
    } else {
        $selected = '';
    }
    $select = html_select::make_popup_form(CALENDAR_URL . 'set.php?var=setcourse&' . $getvars, 'id', $courseoptions, 'cal_courses_flt', $selected);
    $select->nothinglabel = false;
    return $OUTPUT->select($select);
}
Пример #10
0
/**
 * Prints the menus to add activities and resources.
 */
function print_section_add_menus($course, $section, $modnames, $vertical = false, $return = false)
{
    global $CFG, $OUTPUT;
    // check to see if user can add menus
    if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
        return false;
    }
    static $resources = false;
    static $activities = false;
    if ($resources === false) {
        $resources = array();
        $activities = array();
        foreach ($modnames as $modname => $modnamestr) {
            if (!course_allowed_module($course, $modname)) {
                continue;
            }
            $libfile = "{$CFG->dirroot}/mod/{$modname}/lib.php";
            if (!file_exists($libfile)) {
                continue;
            }
            include_once $libfile;
            $gettypesfunc = $modname . '_get_types';
            if (function_exists($gettypesfunc)) {
                $types = $gettypesfunc();
                foreach ($types as $type) {
                    $type->type = str_replace('&amp;', '&', $type->type);
                    if (!isset($type->modclass) or !isset($type->typestr)) {
                        debugging('Incorrect activity type in ' . $modname);
                        continue;
                    }
                    if ($type->modclass == MOD_CLASS_RESOURCE) {
                        $resources[$type->type] = $type->typestr;
                    } else {
                        $activities[$type->type] = $type->typestr;
                    }
                }
            } else {
                $archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
                if ($archetype == MOD_ARCHETYPE_RESOURCE) {
                    $resources[$modname] = $modnamestr;
                } else {
                    // all other archetypes are considered activity
                    $activities[$modname] = $modnamestr;
                }
            }
        }
    }
    $straddactivity = get_string('addactivity');
    $straddresource = get_string('addresource');
    $output = '<div class="section_add_menus">';
    if (!$vertical) {
        $output .= '<div class="horizontal">';
    }
    $popupurl = "{$CFG->wwwroot}/course/mod.php?id={$course->id}&section={$section}&sesskey=" . sesskey();
    if (!empty($resources)) {
        $select = html_select::make_popup_form($popupurl, 'add', $resources, "ressection{$section}", null);
        $select->nothinglabel = $straddresource;
        $select->set_help_icon('resource/types', $straddresource);
        $output .= $OUTPUT->select($select);
    }
    if (!empty($activities)) {
        $select = html_select::make_popup_form($popupurl, 'add', $activities, "section{$section}", null);
        $select->nothinglabel = $straddactivity;
        $select->set_help_icon('mods', $straddactivity);
        $output .= $OUTPUT->select($select);
    }
    if (!$vertical) {
        $output .= '</div>';
    }
    $output .= '</div>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Пример #11
0
        if (function_exists('role_get_name')) {
            $rolenames[$role->id] = strip_tags(role_get_name($role, $context));
            // Used in menus etc later on
        } else {
            $rolenames[$role->id] = strip_tags(format_string($role->name));
            // Used in menus etc later on
        }
    }
}
/// If there are multiple Roles in the course, then show a drop down menu for switching
if (count($rolenames) > 1) {
    echo '<div class="rolesform">';
    echo get_string('currentrole', 'role') . ': ';
    $rolenames = array(0 => get_string('all')) + $rolenames;
    $baseurl = "{$wwwroot}/blocks/email_list/email/participants.php?id={$courseid}&amp;group={$selgroup}&amp;page={$page}&amp;perpage={$perpage}&amp;search={$search}&amp;fname={$firstinitial}&amp;lname={$lastinitial}&amp;contextid={$context->id}";
    $select = html_select::make_popup_form($baseurl, 'roleid', $rolenames, 'rolesform', $roleid);
    echo $OUTPUT->select($select);
    echo '</div>';
}
// Prints group selector for users with a viewallgroups capability if course groupmode is separate
echo '<br />';
groups_print_course_menu($course, $wwwroot . '/blocks/email_list/email/participants.php?id=' . $course->id);
echo '<br /><br />';
echo '<div id="participants"></div>' . '<iframe id="idsearch" name="bssearch" src="get_users.php?id=' . $courseid . '&amp;roleid=' . $roleid . '&amp;group=' . $selgroup . '&amp;page=' . $page . '&amp;perpage=' . $perpage . '&amp;search=' . $search . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '" style="display:none;"></iframe>' . "\n\n";
echo $OUTPUT->spacer($spacer);
if ($perpage == '7') {
    echo '<div id="to_all_users" class="all_users"><img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/add.png" height="16" width="16" alt="' . get_string("course") . '" /> <a href="' . $wwwroot . '/blocks/email_list/email/participants.php?id=' . $courseid . '&amp;group=' . $selgroup . '&amp;perpage=99999&amp;search=' . $search . '&amp;roleid=' . $roleid . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '">' . get_string('showallusers') . '</a></div>';
} else {
    echo '<div id="to_all_users" class="all_users"><img src="' . $CFG->wwwroot . '/blocks/email_list/email/images/delete.png" height="16" width="16" alt="' . get_string("course") . '" /> <a href="' . $wwwroot . '/blocks/email_list/email/participants.php?id=' . $courseid . '&amp;group=' . $selgroup . '&amp;perpage=7&amp;search=' . $search . '&amp;roleid=' . $roleid . '&amp;fname=' . $firstinitial . '&amp;lname=' . $lastinitial . '">' . get_string('showperpage', '', 7) . '</a></div>';
}
// Print close button
Пример #12
0
/**
 * Print group menu selector for activity.
 *
 * @global object
 * @global object
 * @global object
 * @param object $cm course module object
 * @param string $urlroot return address that users get to if they choose an option;
 *   should include any parameters needed, e.g. 'view.php?id=34'
 * @param boolean $return return as string instead of printing
 * @param boolean $hideallparticipants If true, this prevents the 'All participants'
 *   option from appearing in cases where it normally would. This is intended for
 *   use only by activities that cannot display all groups together. (Note that
 *   selecting this option does not prevent groups_get_activity_group from
 *   returning 0; it will still do that if the user has chosen 'all participants'
 *   in another activity, or not chosen anything.)
 * @return mixed void or string depending on $return param
 */
function groups_print_activity_menu($cm, $urlroot, $return = false, $hideallparticipants = false)
{
    global $CFG, $USER, $SESSION, $OUTPUT;
    // groupings are ignored when not enabled
    if (empty($CFG->enablegroupings)) {
        $cm->groupingid = 0;
    }
    if (!($groupmode = groups_get_activity_groupmode($cm))) {
        if ($return) {
            return '';
        } else {
            return;
        }
    }
    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
    if ($groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) {
        $allowedgroups = groups_get_all_groups($cm->course, 0, $cm->groupingid);
        // any group in grouping (all if groupings not used)
        // detect changes related to groups and fix active group
        if (!empty($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid])) {
            if (!array_key_exists($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid], $allowedgroups)) {
                // active group does not exist anymore
                unset($SESSION->activegroup[$cm->course][VISIBLEGROUPS][$cm->groupingid]);
            }
        }
        if (!empty($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid])) {
            if (!array_key_exists($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid], $allowedgroups)) {
                // active group does not exist anymore
                unset($SESSION->activegroup[$cm->course]['aag'][$cm->groupingid]);
            }
        }
    } else {
        $allowedgroups = groups_get_all_groups($cm->course, $USER->id, $cm->groupingid);
        // only assigned groups
        // detect changes related to groups and fix active group
        if (isset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid])) {
            if ($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid] == 0) {
                if ($allowedgroups) {
                    // somebody must have assigned at least one group, we can select it now - yay!
                    unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
                }
            } else {
                if (!array_key_exists($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid], $allowedgroups)) {
                    // active group not allowed or does not exist anymore
                    unset($SESSION->activegroup[$cm->course][SEPARATEGROUPS][$cm->groupingid]);
                }
            }
        }
    }
    $activegroup = groups_get_activity_group($cm, true);
    $groupsmenu = array();
    if ((!$allowedgroups or $groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) and !$hideallparticipants) {
        $groupsmenu[0] = get_string('allparticipants');
    }
    if ($allowedgroups) {
        foreach ($allowedgroups as $group) {
            $groupsmenu[$group->id] = format_string($group->name);
        }
    }
    if ($groupmode == VISIBLEGROUPS) {
        $grouplabel = get_string('groupsvisible');
    } else {
        $grouplabel = get_string('groupsseparate');
    }
    if (count($groupsmenu) == 1) {
        $groupname = reset($groupsmenu);
        $output = $grouplabel . ': ' . $groupname;
    } else {
        $select = html_select::make_popup_form($urlroot, 'group', $groupsmenu, 'selectgroup', $activegroup);
        $select->nothinglabel = false;
        $select->set_label($grouplabel);
        $output = $OUTPUT->select($select);
    }
    $output = '<div class="groupselector">' . $output . '</div>';
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Пример #13
0
     $table = new html_table();
     $table->head = array(get_string('fieldname', 'data'), get_string('type', 'data'), get_string('fielddescription', 'data'), get_string('action', 'data'));
     $table->align = array('left', 'left', 'left', 'center');
     $table->wrap = array(false, false, false, false);
     if ($fff = $DB->get_records('data_fields', array('dataid' => $data->id), 'id')) {
         foreach ($fff as $ff) {
             $field = data_get_field($ff, $data);
             $table->data[] = array('<a href="field.php?mode=display&amp;d=' . $data->id . '&amp;fid=' . $field->field->id . '&amp;sesskey=' . sesskey() . '">' . $field->field->name . '</a>', $field->image() . '&nbsp;' . get_string($field->type, 'data'), shorten_text($field->field->description, 30), '<a href="field.php?d=' . $data->id . '&amp;mode=display&amp;fid=' . $field->field->id . '&amp;sesskey=' . sesskey() . '">' . '<img src="' . $OUTPUT->old_icon_url('t/edit') . '" class="iconsmall" alt="' . get_string('edit') . '" title="' . get_string('edit') . '" /></a>' . '&nbsp;' . '<a href="field.php?d=' . $data->id . '&amp;mode=delete&amp;fid=' . $field->field->id . '&amp;sesskey=' . sesskey() . '">' . '<img src="' . $OUTPUT->old_icon_url('t/delete') . '" class="iconsmall" alt="' . get_string('delete') . '" title="' . get_string('delete') . '" /></a>');
         }
     }
     echo $OUTPUT->table($table);
 }
 echo '<div class="fieldadd">';
 echo '<label for="fieldform_jump">' . get_string('newfield', 'data') . '</label>';
 $popupurl = $CFG->wwwroot . '/mod/data/field.php?d=' . $data->id . '&mode=new&sesskey=' . sesskey();
 echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform"));
 echo $OUTPUT->help_icon(moodle_help_icon::make('fields', get_string('addafield', 'data'), 'data'));
 echo '</div>';
 echo '<div class="sortdefault">';
 echo '<form id="sortdefault" action="' . $CFG->wwwroot . '/mod/data/field.php" method="get">';
 echo '<div>';
 echo '<input type="hidden" name="d" value="' . $data->id . '" />';
 echo '<input type="hidden" name="mode" value="sort" />';
 echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
 echo '<label for="defaultsort">' . get_string('defaultsortfield', 'data') . '</label>';
 echo '<select id="defaultsort" name="defaultsort">';
 if ($fields = $DB->get_records('data_fields', array('dataid' => $data->id))) {
     echo '<optgroup label="' . get_string('fields', 'data') . '">';
     foreach ($fields as $field) {
         if ($data->defaultsort == $field->id) {
             echo '<option value="' . $field->id . '" selected="selected">' . $field->name . '</option>';
Пример #14
0
    $options[0] = get_string('all');
    foreach ($groupings as $grouping) {
        $options[$grouping->id] = strip_tags(format_string($grouping->name));
    }
    $popupurl = $rooturl . '&group=' . $groupid;
    $select = html_select::make_popup_form($popupurl, 'grouping', $options, 'selectgrouping', $groupingid);
    $select->set_label($strgrouping);
    echo $OUTPUT->select($select);
}
$options = array();
$options[0] = get_string('all');
foreach ($groups as $group) {
    $options[$group->id] = strip_tags(format_string($group->name));
}
$popupurl = $rooturl . '&grouping=' . $groupingid;
$select = html_select::make_popup_form($popupurl, 'group', $options, 'selectgroup', $groupid);
$select->set_label($strgroup);
echo $OUTPUT->select($select);
/// Print table
$printed = false;
foreach ($members as $gpgid => $groupdata) {
    if ($groupingid and $groupingid != $gpgid) {
        continue;
        // do not show
    }
    $table = new html_table();
    $table->head = array(get_string('groupscount', 'group', count($groupdata)), get_string('groupmembers', 'group'), get_string('usercount', 'group'));
    $table->size = array('20%', '70%', '10%');
    $table->align = array('left', 'left', 'center');
    $table->width = '90%';
    $table->data = array();
Пример #15
0
/**
 * Prints the page action buttons
 *
 * Move/Edit/Preview/Delete
 *
 * @uses $CFG
 * @param int $cmid Course Module ID
 * @param object $page Page record
 * @param boolean $printmove Flag to print the move button or not
 * @param boolean $printaddpage Flag to print the add page drop-down or not
 * @param boolean $return Return flag
 * @return mixed boolean/string
 **/
function lesson_print_page_actions($cmid, $page, $printmove, $printaddpage = false, $return = false)
{
    global $CFG, $OUTPUT;
    $context = get_context_instance(CONTEXT_MODULE, $cmid);
    $actions = array();
    if (has_capability('mod/lesson:edit', $context)) {
        if ($printmove) {
            $actions[] = "<a title=\"" . get_string('move') . "\" href=\"{$CFG->wwwroot}/mod/lesson/lesson.php?id={$cmid}&amp;action=move&amp;pageid={$page->id}\">\n                          <img src=\"" . $OUTPUT->old_icon_url('t/move') . "\" class=\"iconsmall\" alt=\"" . get_string('move') . "\" /></a>\n";
        }
        $actions[] = "<a title=\"" . get_string('update') . "\" href=\"{$CFG->wwwroot}/mod/lesson/lesson.php?id={$cmid}&amp;action=editpage&amp;pageid={$page->id}\">\n                      <img src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"" . get_string('update') . "\" /></a>\n";
        $actions[] = "<a title=\"" . get_string('preview') . "\" href=\"{$CFG->wwwroot}/mod/lesson/view.php?id={$cmid}&amp;pageid={$page->id}\">\n                      <img src=\"" . $OUTPUT->old_icon_url('t/preview') . "\" class=\"iconsmall\" alt=\"" . get_string('preview') . "\" /></a>\n";
        $actions[] = "<a title=\"" . get_string('delete') . "\" href=\"{$CFG->wwwroot}/mod/lesson/lesson.php?id={$cmid}&amp;sesskey=" . sesskey() . "&amp;action=confirmdelete&amp;pageid={$page->id}\">\n                      <img src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"" . get_string('delete') . "\" /></a>\n";
        if ($printaddpage) {
            // Add page drop-down
            $options = array();
            $options['addcluster&amp;sesskey=' . sesskey()] = get_string('clustertitle', 'lesson');
            $options['addendofcluster&amp;sesskey=' . sesskey()] = get_string('endofclustertitle', 'lesson');
            $options['addbranchtable'] = get_string('branchtable', 'lesson');
            $options['addendofbranch&amp;sesskey=' . sesskey()] = get_string('endofbranch', 'lesson');
            $options['addpage'] = get_string('question', 'lesson');
            // Base url
            $common = "{$CFG->wwwroot}/mod/lesson/lesson.php?id={$cmid}&pageid={$page->id}";
            $select = html_select::make_popup_form($common, 'action', $options, "addpage_{$page->id}");
            $select->nothinglabel = get_string('addpage', 'lesson') . '...';
            $actions[] = $OUTPUT->select($select);
        }
    }
    $actions = implode(' ', $actions);
    if ($return) {
        return $actions;
    } else {
        echo $actions;
        return false;
    }
}
Пример #16
0
/**
 * Implements a complete little form with a dropdown menu.
 *
 * @deprecated since Moodle 2.0
 *
 * When JavaScript is on selecting an option from the dropdown automatically
 * submits the form (while avoiding the usual acessibility problems with this appoach).
 * With JavaScript off, a 'Go' button is printed.
 *
 * @global object
 * @global object
 * @param string $baseurl The target URL up to the point of the variable that changes
 * @param array $options A list of value-label pairs for the popup list
 * @param string $formid id for the control. Must be unique on the page. Used in the HTML.
 * @param string $selected The option that is initially selected
 * @param string $nothing The label for the "no choice" option
 * @param string $help The name of a help page if help is required
 * @param string $helptext The name of the label for the help button
 * @param boolean $return Indicates whether the function should return the HTML
 *         as a string or echo it directly to the page being rendered
 * @param string $targetwindow The name of the target page to open the linked page in.
 * @param string $selectlabel Text to place in a [label] element - preferred for accessibility.
 * @param array $optionsextra an array with the same keys as $options. The values are added within the corresponding <option ...> tag.
 * @param string $submitvalue Optional label for the 'Go' button. Defaults to get_string('go').
 * @param boolean $disabled If true, the menu will be displayed disabled.
 * @param boolean $showbutton If true, the button will always be shown even if JavaScript is available
 * @return string|void If $return=true returns string, else echo's and returns void
 */
function popup_form($baseurl, $options, $formid, $selected = '', $nothing = 'choose', $help = '', $helptext = '', $return = false, $targetwindow = 'self', $selectlabel = '', $optionsextra = NULL, $submitvalue = '', $disabled = false, $showbutton = false)
{
    global $OUTPUT;
    debugging('popup_form() has been deprecated. Please change your code to use $OUTPUT->select($select).');
    if (empty($options)) {
        return '';
    }
    // Extract the last param in the baseurl
    $name = null;
    if (preg_match('/([a-zA-Z0-9\\-_]*)=$/', $baseurl, $matches)) {
        $name = $matches[1];
    }
    $baseurl = new moodle_url($baseurl);
    $select = html_select::make_popup_form($baseurl, $name, $options, $formid, $selected);
    $select->disabled = $disabled;
    if (!empty($submitvalue)) {
        $select->form->button->text = $submitvalue;
    }
    if (!empty($optionsextra)) {
        // debugging('The $optionsextra (11th) param to popup_form is not supported, please improve your code.', DEBUG_DEVELOPER);
    }
    if ($nothing == 'choose') {
        $select->nothinglabel = '';
    } else {
        $select->nothinglabel = $nothing;
    }
    $select->set_label($selectlabel);
    $select->set_help_icon($help, $helptext);
    $output = $OUTPUT->select($select);
    if ($return) {
        return $output;
    } else {
        echo $output;
    }
}
Пример #17
0
foreach ($authsequence as $authname) {
    $authplugin = get_auth_plugin($authname);
    $authplugin->loginpage_hook();
}
//HTTPS is potentially required in this page
httpsrequired();
/// Define variables used in page
if (!($site = get_site())) {
    print_error('siteisnotdefined', 'debug');
}
if (empty($CFG->langmenu)) {
    $langmenu = "";
} else {
    $currlang = current_language();
    $langs = get_list_of_languages();
    $select = html_select::make_popup_form("{$CFG->httpswwwroot}/login/index.php", 'lang', $langs, 'chooselang', $currlang);
    $select->nothinglabel = false;
    $select->set_label(get_accesshide(get_string('language')));
    $langmenu = $OUTPUT->select($select);
}
$loginsite = get_string("loginsite");
$navlinks = array(array('name' => $loginsite, 'link' => null, 'type' => 'misc'));
$navigation = build_navigation($navlinks);
if ($user !== false or $frm !== false) {
    // some auth plugin already supplied these
} else {
    if (!empty($SESSION->wantsurl) and strstr($SESSION->wantsurl, 'username=guest') or $loginguest) {
        /// Log in as guest automatically (idea from Zbigniew Fiedorowicz)
        $frm->username = '******';
        $frm->password = '******';
    } else {
Пример #18
0
/**
 * Displays actions which can be performed on the page
 *
 * @param object $wiki
 * @param int $cmid
 * @param int $userid
 * @param int $groupid
 * @param object $page
 * @param bool $noeditor
 * @param object $course
 */
function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $page, $noeditor, $course)
{
    global $OUTPUT;
    /// Create the URL
    $ewscript = 'admin.php?id=' . $cmid;
    if (isset($userid) && $userid != 0) {
        $ewscript .= '&userid=' . $userid;
    }
    if (isset($groupid) && $groupid != 0) {
        $ewscript .= '&groupid=' . $groupid;
    }
    if (isset($page)) {
        $ewscript .= '&page=' . $page;
    }
    /// Build that action array according to wiki flags.
    $action = array();
    $isteacher = wiki_is_teacher($wiki);
    if ($wiki->setpageflags or $isteacher) {
        $action['setpageflags'] = get_string('setpageflags', 'wiki');
    }
    if ($wiki->removepages or $isteacher) {
        $action['removepages'] = get_string('removepages', 'wiki');
    }
    if ($wiki->strippages or $isteacher) {
        $action['strippages'] = get_string('strippages', 'wiki');
    }
    if ($wiki->revertchanges or $isteacher) {
        $action['revertpages'] = get_string('revertpages', 'wiki');
    }
    if ($noeditor) {
        $action["checklinks"] = get_string("checklinks", "wiki");
    }
    $select = html_select::make_popup_form($ewscript, 'action', $action, 'wikiadministration');
    $select->nothinglabel = get_string("chooseadministration", "wiki");
    echo $OUTPUT->select($select);
}
Пример #19
0
                 $menufiles['extra'] = '------------';
                 $menufiles_coregrp = 0;
             }
         }
     }
     $menufiles[$item_key] = $item_label;
     if ($currentfile == $helpfile['filename']) {
         $origlocation = $helpfile['location'];
         $origplugin = $helpfile['plugin'];
     }
 }
 $selectionlabel = '<code class="path">';
 //$selectionlabel .= $strfilestoredin;
 $selectionlabel .= $uselocal ? "{$currentlang}_local" : $currentlang;
 $selectionlabel .= '/help/</code>';
 $select = html_select::make_popup_form("{$CFG->wwwroot}/{$CFG->admin}/lang.php?mode=helpfiles", 'currentfile', $menufiles, "choosefile", $currentfile);
 $select->nothinglabel = $strchoosefiletoedit;
 $select->set_label($selectionlabel);
 echo $OUTPUT->select($select);
 echo $OUTPUT->help_icon(moodle_help_icon::make('langswitchstorage', $strfilestoredinhelp));
 echo $OUTPUT->box_end();
 if (!empty($currentfile)) {
     if (!file_exists("{$saveto}/{$currentfile}")) {
         $dbg .= "File does not exist: {$saveto}/{$currentfile}\n";
         //check if directory exist
         if (!file_exists(dirname("{$saveto}/{$currentfile}"))) {
             if (!lang_make_directory(dirname("{$saveto}/{$currentfile}"))) {
                 echo 'Cannot create directory: ' . dirname("{$saveto}/{$currentfile}");
             }
         }
         //
Пример #20
0
            // Hidden for students
            echo $OUTPUT->heading($currenttext . $weekperiod . ' (' . get_string('notavailable') . ')', 3, 'weekdates');
        } else {
            echo $OUTPUT->heading($currenttext . $weekperiod, 3, 'weekdates');
            echo '<div class="summary">';
            $summaryformatoptions->noclean = true;
            echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
            if ($PAGE->user_is_editing() && has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $course->id))) {
                echo ' <a title="' . $streditsummary . '" href="editsection.php?id=' . $thissection->id . '">' . '<img src="' . $OUTPUT->old_icon_url('t/edit') . '" class="icon edit" alt="' . $streditsummary . '" /></a><br /><br />';
            }
            echo '</div>';
            print_section($course, $thissection, $mods, $modnamesused);
            if ($PAGE->user_is_editing()) {
                print_section_add_menus($course, $section, $modnames);
            }
        }
        echo '</div>';
        echo "</li>\n";
    }
    $section++;
    $weekdate = $nextweekdate;
}
echo "</ul>\n";
if (!empty($sectionmenu)) {
    echo '<div class="jumpmenu">';
    $popupurl = $CFG->wwwroot . '/course/view.php?id=' . $course->id;
    $select = html_select::make_popup_form($popupurl, 'week', $sectionmenu, 'sectionmenu');
    $select->set_label(get_string('jumpto'));
    echo $OUTPUT->select($select);
    echo '</div>';
}
Пример #21
0
    if ($user = $mform_signup->get_data()) {
        $user->confirmed = 0;
        $user->lang = current_language();
        $user->firstaccess = time();
        $user->mnethostid = $CFG->mnet_localhost_id;
        $user->secret = random_string(15);
        $user->auth = $CFG->registerauth;
        $authplugin->user_signup($user, true);
        // prints notice and link to login/index.php
        exit;
        //never reached
    }
}
$newaccount = get_string('newaccount');
$login = get_string('login');
if (empty($CFG->langmenu)) {
    $langmenu = '';
} else {
    $currlang = current_language();
    $langs = get_list_of_languages();
    $select = html_select::make_popup_form("{$CFG->wwwroot}/login/signup.php", 'lang', $langs, 'chooselang', $currlang);
    $select->nothinglabel = false;
    $langmenu = $OUTPUT->select($select);
}
$navlinks = array();
$navlinks[] = array('name' => $login, 'link' => "index.php", 'type' => 'misc');
$navlinks[] = array('name' => $newaccount, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($newaccount, $newaccount, $navigation, $mform_signup->focus(), "", true, "<div class=\"langmenu\">{$langmenu}</div>");
$mform_signup->display();
echo $OUTPUT->footer();
Пример #22
0
function print_category_edit($category, $displaylist, $parentslist, $depth = -1, $up = false, $down = false)
{
    /// Recursive function to print all the categories ready for editing
    global $CFG, $USER, $OUTPUT;
    static $str = NULL;
    if (is_null($str)) {
        $str = new stdClass();
        $str->edit = get_string('edit');
        $str->delete = get_string('delete');
        $str->moveup = get_string('moveup');
        $str->movedown = get_string('movedown');
        $str->edit = get_string('editthiscategory');
        $str->hide = get_string('hide');
        $str->show = get_string('show');
        $str->spacer = '<img src="' . $CFG->wwwroot . '/pix/spacer.gif" class="iconsmall" alt="" /> ';
    }
    if (!empty($category)) {
        if (!isset($category->context)) {
            $category->context = get_context_instance(CONTEXT_COURSECAT, $category->id);
        }
        echo '<tr><td align="left" class="name">';
        for ($i = 0; $i < $depth; $i++) {
            echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
        }
        $linkcss = $category->visible ? '' : ' class="dimmed" ';
        echo '<a ' . $linkcss . ' title="' . $str->edit . '" ' . ' href="category.php?id=' . $category->id . '&amp;categoryedit=on&amp;sesskey=' . sesskey() . '">' . format_string($category->name) . '</a>';
        echo '</td>';
        echo '<td class="count">' . $category->coursecount . '</td>';
        echo '<td class="icons">';
        /// Print little icons
        if (has_capability('moodle/category:manage', $category->context)) {
            echo '<a title="' . $str->edit . '" href="editcategory.php?id=' . $category->id . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/edit') . '" class="iconsmall" alt="' . $str->edit . '" /></a> ';
            echo '<a title="' . $str->delete . '" href="index.php?delete=' . $category->id . '&amp;sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/delete') . '" class="iconsmall" alt="' . $str->delete . '" /></a> ';
            if (!empty($category->visible)) {
                echo '<a title="' . $str->hide . '" href="index.php?hide=' . $category->id . '&amp;sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/hide') . '" class="iconsmall" alt="' . $str->hide . '" /></a> ';
            } else {
                echo '<a title="' . $str->show . '" href="index.php?show=' . $category->id . '&amp;sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/show') . '" class="iconsmall" alt="' . $str->show . '" /></a> ';
            }
            if ($up) {
                echo '<a title="' . $str->moveup . '" href="index.php?moveup=' . $category->id . '&amp;sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/up') . '" class="iconsmall" alt="' . $str->moveup . '" /></a> ';
            } else {
                echo $str->spacer;
            }
            if ($down) {
                echo '<a title="' . $str->movedown . '" href="index.php?movedown=' . $category->id . '&amp;sesskey=' . sesskey() . '"><img' . ' src="' . $OUTPUT->old_icon_url('t/down') . '" class="iconsmall" alt="' . $str->movedown . '" /></a> ';
            } else {
                echo $str->spacer;
            }
        }
        echo '</td>';
        echo '<td align="left">';
        if (has_capability('moodle/category:manage', $category->context)) {
            $tempdisplaylist = $displaylist;
            unset($tempdisplaylist[$category->id]);
            foreach ($parentslist as $key => $parents) {
                if (in_array($category->id, $parents)) {
                    unset($tempdisplaylist[$key]);
                }
            }
            $popupurl = "index.php?move={$category->id}&sesskey=" . sesskey();
            $select = html_select::make_popup_form($popupurl, 'moveto', $tempdisplaylist, "moveform{$category->id}", $category->parent);
            $select->nothinglabel = false;
            echo $OUTPUT->select($select);
        }
        echo '</td>';
        echo '</tr>';
    } else {
        $category->id = '0';
    }
    if ($categories = get_categories($category->id)) {
        // Print all the children recursively
        $countcats = count($categories);
        $count = 0;
        $first = true;
        $last = false;
        foreach ($categories as $cat) {
            $count++;
            if ($count == $countcats) {
                $last = true;
            }
            $up = $first ? false : true;
            $down = $last ? false : true;
            $first = false;
            print_category_edit($cat, $displaylist, $parentslist, $depth + 1, $up, $down);
        }
    }
}
Пример #23
0
    // Ensure that we are actually showing blocks etc for the cat context
    admin_externalpage_print_header();
} else {
    $navbaritem = print_course_search('', true, 'navbar');
    print_header("{$site->shortname}: {$category->name}", "{$site->fullname}: {$strcourses}", $navigation, '', '', true, $navbaritem);
}
/// Print link to roles
if (has_capability('moodle/role:assign', $context)) {
    echo '<div class="rolelink"><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/roles/assign.php?contextid=' . $context->id . '">' . get_string('assignroles', 'role') . '</a></div>';
}
/// Print the category selector
$displaylist = array();
$notused = array();
make_categories_list($displaylist, $notused);
echo '<div class="categorypicker">';
$select = html_select::make_popup_form('category.php', 'id', $displaylist, 'switchcategory', $category->id);
$select->set_label($strcategories . ':');
$select->nothinglabel = false;
echo $OUTPUT->select($select);
echo '</div>';
/// Print current category description
if (!$editingon && $category->description) {
    echo $OUTPUT->box_start();
    echo format_text($category->description);
    // for multilang filter
    echo $OUTPUT->box_end();
}
if ($editingon && has_capability('moodle/category:manage', $context)) {
    echo $OUTPUT->container_start('buttons');
    // Print button to update this category
    $options = array('id' => $category->id);
Пример #24
0
/**
 * Return a {@link block_contents} representing the add a new block UI, if
 * this user is allowed to see it.
 *
 * @return block_contents an appropriate block_contents, or null if the user
 * cannot add any blocks here.
 */
function block_add_block_ui($page, $output)
{
    global $CFG, $OUTPUT;
    if (!$page->user_is_editing() || !$page->user_can_edit_blocks()) {
        return null;
    }
    $bc = new block_contents();
    $bc->title = get_string('addblock');
    $bc->add_class('block_adminblock');
    $missingblocks = $page->blocks->get_addable_blocks();
    if (empty($missingblocks)) {
        $bc->content = get_string('noblockstoaddhere');
        return $bc;
    }
    $menu = array();
    foreach ($missingblocks as $block) {
        $blockobject = block_instance($block->name);
        if ($blockobject !== false && $blockobject->user_can_addto($page)) {
            $menu[$block->name] = $blockobject->get_title();
        }
    }
    asort($menu, SORT_LOCALE_STRING);
    $actionurl = $page->url->out_action();
    $select = html_select::make_popup_form($actionurl, 'bui_addblock', $menu, 'add_block');
    $select->nothinglabel = get_string('adddots');
    $bc->content = $OUTPUT->select($select);
    return $bc;
}
Пример #25
0
 /**
  * Displays the report.
  */
 function display($quiz, $cm, $course)
 {
     global $CFG, $QTYPES, $DB, $OUTPUT;
     $viewoptions = array('mode' => 'grading', 'q' => $quiz->id);
     if ($questionid = optional_param('questionid', 0, PARAM_INT)) {
         $viewoptions += array('questionid' => $questionid);
     }
     // grade question specific parameters
     if ($userid = optional_param('userid', 0, PARAM_INT)) {
         $viewoptions += array('userid' => $userid);
     }
     if ($attemptid = optional_param('attemptid', 0, PARAM_INT)) {
         $viewoptions += array('attemptid' => $attemptid);
     }
     if ($gradeall = optional_param('gradeall', 0, PARAM_INT)) {
         $viewoptions += array('gradeall' => $gradeall);
     }
     if ($gradeungraded = optional_param('gradeungraded', 0, PARAM_INT)) {
         $viewoptions += array('gradeungraded' => $gradeungraded);
     }
     if ($gradenextungraded = optional_param('gradenextungraded', 0, PARAM_INT)) {
         $viewoptions += array('gradenextungraded' => $gradenextungraded);
     }
     $this->cm = $cm;
     $this->print_header_and_tabs($cm, $course, $quiz, $reportmode = "grading");
     // Check permissions
     $this->context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (!has_capability('mod/quiz:grade', $this->context)) {
         echo $OUTPUT->notification(get_string('gradingnotallowed', 'quiz_grading'));
         return true;
     }
     $gradeableqs = quiz_report_load_questions($quiz);
     $questionsinuse = implode(',', array_keys($gradeableqs));
     foreach ($gradeableqs as $qid => $question) {
         if (!$QTYPES[$question->qtype]->is_question_manual_graded($question, $questionsinuse)) {
             unset($gradeableqs[$qid]);
         }
     }
     if (empty($gradeableqs)) {
         echo $OUTPUT->heading(get_string('noessayquestionsfound', 'quiz'));
         return true;
     } else {
         if (count($gradeableqs) == 1) {
             $questionid = array_shift(array_keys($gradeableqs));
         }
     }
     $currentgroup = groups_get_activity_group($this->cm, true);
     $this->users = get_users_by_capability($this->context, array('mod/quiz:reviewmyattempts', 'mod/quiz:attempt'), '', '', '', '', $currentgroup, '', false);
     if (!empty($questionid)) {
         if (!isset($gradeableqs[$questionid])) {
             print_error('invalidquestionid', 'quiz_grading', '', $questionid);
         } else {
             $question =& $gradeableqs[$questionid];
         }
         // Some of the questions code is optimised to work with several questions
         // at once so it wants the question to be in an array. The array key
         // must be the question id.
         $key = $question->id;
         $questions[$key] =& $question;
         // We need to add additional questiontype specific information to
         // the question objects.
         if (!get_question_options($questions)) {
             print_error('cannotloadquestioninfo', 'quiz_grading');
         }
         // This will have extended the question object so that it now holds
         // all the information about the questions that may be needed later.
     }
     add_to_log($course->id, "quiz", "manualgrading", "report.php?mode=grading&amp;q={$quiz->id}", "{$quiz->id}", "{$cm->id}");
     echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>';
     // for overlib
     if ($data = data_submitted()) {
         // post data submitted, process it
         if (confirm_sesskey() && $this->users) {
             // now go through all of the responses and save them.
             $allok = true;
             foreach ($data->manualgrades as $uniqueid => $response) {
                 // get our attempt
                 $uniqueid = clean_param($uniqueid, PARAM_INT);
                 list($usql, $params) = $DB->get_in_or_equal(array_keys($this->users));
                 if (!($attempt = $DB->get_record_sql("SELECT * FROM {quiz_attempts} " . "WHERE uniqueid = ? AND " . "userid {$usql} AND " . "quiz=?", array_merge(array($uniqueid), $params, array($quiz->id))))) {
                     print_error('invalidattemptid', 'quiz_grading');
                 }
                 // Load the state for this attempt (The questions array was created earlier)
                 $states = get_question_states($questions, $quiz, $attempt);
                 // The $states array is indexed by question id but because we are dealing
                 // with only one question there is only one entry in this array
                 $state =& $states[$question->id];
                 // the following will update the state and attempt
                 $error = question_process_comment($question, $state, $attempt, $response['comment'], $response['grade']);
                 if (is_string($error)) {
                     echo $OUTPUT->notification($error);
                     $allok = false;
                 } else {
                     if ($state->changed) {
                         // If the state has changed save it and update the quiz grade
                         save_question_session($question, $state);
                         quiz_save_best_grade($quiz, $attempt->userid);
                     }
                 }
             }
             if ($allok) {
                 echo $OUTPUT->notification(get_string('changessaved', 'quiz'), 'notifysuccess');
             } else {
                 echo $OUTPUT->notification(get_string('changessavedwitherrors', 'quiz'), 'notifysuccess');
             }
         }
     }
     $this->viewurl = new moodle_url($CFG->wwwroot . '/mod/quiz/report.php', $viewoptions);
     /// find out current groups mode
     if ($groupmode = groups_get_activity_groupmode($this->cm)) {
         // Groups are being used
         groups_print_activity_menu($this->cm, $this->viewurl->out(false, array('userid' => 0, 'attemptid' => 0)));
     }
     if (empty($this->users)) {
         if ($currentgroup) {
             echo $OUTPUT->notification(get_string('nostudentsingroup'));
         } else {
             echo $OUTPUT->notification(get_string('nostudentsyet'));
         }
         return true;
     }
     $qattempts = quiz_get_total_qas_graded_and_ungraded($quiz, array_keys($gradeableqs), array_keys($this->users));
     if (empty($qattempts)) {
         echo $OUTPUT->notification(get_string('noattemptstoshow', 'quiz'));
         return true;
     }
     $qmenu = array();
     foreach ($gradeableqs as $qid => $questionformenu) {
         $a = new object();
         $a->number = $gradeableqs[$qid]->number;
         $a->name = $gradeableqs[$qid]->name;
         $a->gradedattempts = $qattempts[$qid]->gradedattempts;
         $a->totalattempts = $qattempts[$qid]->totalattempts;
         $a->openspan = '';
         $a->closespan = '';
         $qmenu[$qid] = get_string('questiontitle', 'quiz_grading', $a);
     }
     if (count($gradeableqs) != 1) {
         $qurl = fullclone($this->viewurl);
         $qurl->remove_params('questionid', 'attemptid', 'gradeall', 'gradeungraded', 'gradenextungraded');
         $menu = $OUTPUT->select(html_select::make_popup_form($qurl->out(), 'questionid', $qmenu, 'questionid', $questionid));
         echo '<div class="mdl-align">' . $menu . '</div>';
     }
     if (!$questionid) {
         return true;
     }
     $a = new object();
     $a->number = $question->number;
     $a->name = $question->name;
     $a->gradedattempts = $qattempts[$question->id]->gradedattempts;
     $a->totalattempts = $qattempts[$question->id]->totalattempts;
     $a->openspan = '<span class="highlightgraded">';
     $a->closespan = '</span>';
     echo $OUTPUT->heading(get_string('questiontitle', 'quiz_grading', $a));
     // our 2 different views
     // the first view allows a user to select a question and
     // displays the users who have answered the essay question
     // and all of their attempts at answering the question
     // the second prints selected attempt answer(s) with a comment
     // and grade form underneath them
     $ungraded = $qattempts[$questionid]->totalattempts - $qattempts[$questionid]->gradedattempts;
     if ($gradenextungraded || $gradeungraded || $gradeall || $userid || $attemptid) {
         $this->print_questions_and_form($quiz, $question, $userid, $attemptid, $gradeungraded, $gradenextungraded, $ungraded);
     } else {
         $this->view_question($quiz, $question, $qattempts[$questionid]->totalattempts, $ungraded);
     }
     return true;
 }
Пример #26
0
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        /// If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        ///Iterate over each version, adding bigged than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
        /// Add 'upwards' to the last element
        $versions[$env_version] = $env_version . ' ' . $strupwards;
    } else {
        $versions = array('error' => $strerror);
    }
}
/// Print form and popup menu
echo '<div style="text-align:center">' . $strmoodleversion . ' ';
$select = html_select::make_popup_form("{$CFG->wwwroot}/{$CFG->admin}/environment.php", 'version', $versions, 'selectversion', $version);
$select->nothinglabel = false;
echo $OUTPUT->select($select);
echo '</div>';
/// End of main box
echo $OUTPUT->box_end();
/// Gather and show results
$status = check_moodle_environment($version, $environment_results);
/// Print footer
echo $OUTPUT->footer();
Пример #27
0
        foreach ($modinfo->instances['forum'] as $forumcm) {
            if (!$forumcm->uservisible || !has_capability('mod/forum:startdiscussion', get_context_instance(CONTEXT_MODULE, $forumcm->id))) {
                continue;
            }
            if (!empty($forumcm->sectionnum) and $section != $forumcm->sectionnum) {
                $forummenu[] = "-------------- {$strsection} {$forumcm->sectionnum} --------------";
            }
            $section = $forumcm->sectionnum;
            if ($forumcm->instance != $forum->id) {
                $url = $CFG->wwwroot . "/mod/forum/discuss.php?d={$discussion->id}&move={$forumcm->instance}&sesskey=" . sesskey();
                $forummenu[$url] = format_string($forumcm->name);
            }
        }
        if (!empty($forummenu)) {
            echo "<div style=\"float:right;\">";
            $select = html_select::make_popup_form('', '', $forummenu, 'forummenu');
            $select->nothinglabel = get_string("movethisdiscussionto", "forum");
            $select->form->button->text = get_string('move');
            $select->override_option_values($forummenu);
            echo $OUTPUT->select($select);
            echo "</div>";
        }
    }
}
echo "</td></tr></table>";
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
    $a = new object();
    $a->blockafter = $forum->blockafter;
    $a->blockperiod = get_string('secondstotime' . $forum->blockperiod);
    echo $OUTPUT->notification(get_string('thisforumisthrottled', 'forum', $a));
}
Пример #28
0
        }
    }
    echo $OUTPUT->heading(format_string($category->name) . ' ' . profile_category_icons($category));
    if (count($table->data)) {
        echo $OUTPUT->table($table);
    } else {
        echo $OUTPUT->notification($strnofields);
    }
}
/// End of $categories foreach
echo '<hr />';
echo '<div class="profileeditor">';
/// Create a new field link
$options = profile_list_datatypes();
$popupurl = $CFG->wwwroot . '/user/profile/index.php?id=0&action=editfield';
echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'datatype', $options, 'newfieldform', $strcreatefield));
/// Create a new category link
$options = array('action' => 'editcategory');
echo $OUTPUT->button(html_form::make_button('index.php', $options, get_string('profilecreatecategory', 'admin')));
echo '</div>';
echo $OUTPUT->footer();
die;
/***** Some functions relevant to this script *****/
/**
 * Create a string containing the editing icons for the user profile categories
 * @param   object   the category object
 * @return  string   the icon string
 */
function profile_category_icons($category)
{
    global $CFG, $USER, $DB, $OUTPUT;
Пример #29
0
function scorm_get_toc($user, $scorm, $liststyle, $currentorg = '', $scoid = '', $mode = 'normal', $attempt = '', $play = false)
{
    global $CFG, $DB, $PAGE, $OUTPUT;
    $strexpand = get_string('expcoll', 'scorm');
    $modestr = '';
    if ($mode == 'browse') {
        $modestr = '&amp;mode=' . $mode;
    }
    $result = new stdClass();
    $result->toc = "<ul id='s0' class='{$liststyle}'>\n";
    $tocmenus = array();
    $result->prerequisites = true;
    $incomplete = false;
    //
    // Get the current organization infos
    //
    if (!empty($currentorg)) {
        if (($organizationtitle = $DB->get_field('scorm_scoes', 'title', array('scorm' => $scorm->id, 'identifier' => $currentorg))) != '') {
            $result->toc .= "\t<li>{$organizationtitle}</li>\n";
            $tocmenus[] = $organizationtitle;
        }
    }
    //
    // If not specified retrieve the last attempt number
    //
    if (empty($attempt)) {
        $attempt = scorm_get_last_attempt($scorm->id, $user->id);
    }
    $result->attemptleft = $scorm->maxattempt - $attempt;
    if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
        //
        // Retrieve user tracking data for each learning object
        //
        $usertracks = array();
        foreach ($scoes as $sco) {
            if (!empty($sco->launch)) {
                if ($usertrack = scorm_get_tracks($sco->id, $user->id, $attempt)) {
                    if ($usertrack->status == '') {
                        $usertrack->status = 'notattempted';
                    }
                    $usertracks[$sco->identifier] = $usertrack;
                }
            }
        }
        $level = 0;
        $sublist = 1;
        $previd = 0;
        $nextid = 0;
        $findnext = false;
        $parents[$level] = '/';
        foreach ($scoes as $pos => $sco) {
            $isvisible = false;
            $sco->title = $sco->title;
            if (!isset($sco->isvisible) || isset($sco->isvisible) && $sco->isvisible == 'true') {
                $isvisible = true;
            }
            if ($parents[$level] != $sco->parent) {
                if ($newlevel = array_search($sco->parent, $parents)) {
                    for ($i = 0; $i < $level - $newlevel; $i++) {
                        $result->toc .= "\t\t</ul></li>\n";
                    }
                    $level = $newlevel;
                } else {
                    $i = $level;
                    $closelist = '';
                    while ($i > 0 && $parents[$level] != $sco->parent) {
                        $closelist .= "\t\t</ul></li>\n";
                        $i--;
                    }
                    if ($i == 0 && $sco->parent != $currentorg) {
                        $style = '';
                        if (isset($_COOKIE['hide:SCORMitem' . $sco->id])) {
                            $style = ' style="display: none;"';
                        }
                        $result->toc .= "\t\t<li><ul id='s{$sublist}' class='{$liststyle}'{$style}>\n";
                        $level++;
                    } else {
                        $result->toc .= $closelist;
                        $level = $i;
                    }
                    $parents[$level] = $sco->parent;
                }
            }
            if (isset($scoes[$pos + 1])) {
                $nextsco = $scoes[$pos + 1];
            } else {
                $nextsco = false;
            }
            $nextisvisible = false;
            if (!isset($nextsco->isvisible) || isset($nextsco->isvisible) && $nextsco->isvisible == 'true') {
                $nextisvisible = true;
            }
            if ($nextisvisible && $nextsco !== false && $sco->parent != $nextsco->parent && ($level == 0 || $level > 0 && $nextsco->parent == $sco->identifier)) {
                $sublist++;
                $icon = 'minus';
                if (isset($_COOKIE['hide:SCORMitem' . $nextsco->id])) {
                    $icon = 'plus';
                }
                $result->toc .= "\t\t" . '<li><a href="javascript:expandCollide(\'img' . $sublist . '\',\'s' . $sublist . '\',' . $nextsco->id . ');">' . '<img id="img' . $sublist . '" src="' . $OUTPUT->mod_icon_url('pix/' . $icon, 'scorm') . '" alt="' . $strexpand . '" title="' . $strexpand . '"/></a>';
            } else {
                if ($isvisible) {
                    $result->toc .= "\t\t" . '<li><img src="' . $OUTPUT->mod_icon_url('pix/spacer', 'scorm') . '" alt="" />';
                }
            }
            if (empty($sco->title)) {
                $sco->title = $sco->identifier;
            }
            if (!empty($sco->launch)) {
                if ($isvisible) {
                    $startbold = '';
                    $endbold = '';
                    $score = '';
                    if (empty($scoid) && $mode != 'normal') {
                        $scoid = $sco->id;
                    }
                    if (isset($usertracks[$sco->identifier])) {
                        $usertrack = $usertracks[$sco->identifier];
                        $strstatus = get_string($usertrack->status, 'scorm');
                        if ($sco->scormtype == 'sco') {
                            $statusicon = '<img src="' . $OUTPUT->mod_icon_url('pix/' . $usertrack->status, 'scorm') . '" alt="' . $strstatus . '" title="' . $strstatus . '" />';
                        } else {
                            $statusicon = '<img src="' . $OUTPUT->mod_icon_url('pix/assetc', 'scorm') . '" alt="' . get_string('assetlaunched', 'scorm') . '" title="' . get_string('assetlaunched', 'scorm') . '" />';
                        }
                        if ($usertrack->status == 'notattempted' || $usertrack->status == 'incomplete' || $usertrack->status == 'browsed') {
                            $incomplete = true;
                            if ($play && empty($scoid)) {
                                $scoid = $sco->id;
                            }
                        }
                        if ($usertrack->score_raw != '') {
                            $score = '(' . get_string('score', 'scorm') . ':&nbsp;' . $usertrack->score_raw . ')';
                        }
                        $strsuspended = get_string('suspended', 'scorm');
                        if (isset($usertrack->{'cmi.core.exit'}) && $usertrack->{'cmi.core.exit'} == 'suspend') {
                            if ($usertrack->status != 'completed') {
                                $statusicon = '<img src="' . $OUTPUT->mod_icon_url('pix/suspend', 'scorm') . '" alt="' . $strstatus . ' - ' . $strsuspended . '" title="' . $strstatus . ' - ' . $strsuspended . '" />';
                            }
                        }
                    } else {
                        if ($play && empty($scoid)) {
                            $scoid = $sco->id;
                        }
                        if ($sco->scormtype == 'sco') {
                            $statusicon = '<img src="' . $OUTPUT->mod_icon_url('pix/notattempted', 'scorm') . '" alt="' . get_string('notattempted', 'scorm') . '" title="' . get_string('notattempted', 'scorm') . '" />';
                            $incomplete = true;
                        } else {
                            $statusicon = '<img src="' . $OUTPUT->mod_icon_url('pix/asset', 'scorm') . '" alt="' . get_string('asset', 'scorm') . '" title="' . get_string('asset', 'scorm') . '" />';
                        }
                    }
                    if ($sco->id == $scoid) {
                        $startbold = '<b>';
                        $endbold = '</b>';
                        $findnext = true;
                        $shownext = isset($sco->next) ? $sco->next : 0;
                        $showprev = isset($sco->prev) ? $sco->prev : 0;
                    }
                    if ($nextid == 0 && scorm_count_launchable($scorm->id, $currentorg) > 1 && $nextsco !== false && !$findnext) {
                        if (!empty($sco->launch)) {
                            $previd = $sco->id;
                        }
                    }
                    require_once 'sequencinglib.php';
                    if (scorm_seq_evaluate($sco->id, $usertracks)) {
                        if ($sco->id == $scoid) {
                            $result->prerequisites = true;
                        }
                        $url = $CFG->wwwroot . '/mod/scorm/player.php?a=' . $scorm->id . '&amp;currentorg=' . $currentorg . $modestr . '&amp;scoid=' . $sco->id;
                        $result->toc .= $statusicon . '&nbsp;' . $startbold . '<a href="' . $url . '">' . format_string($sco->title) . '</a>' . $score . $endbold . "</li>\n";
                        $tocmenus[$sco->id] = scorm_repeater('&minus;', $level) . '&gt;' . format_string($sco->title);
                    } else {
                        if ($sco->id == $scoid) {
                            $result->prerequisites = false;
                        }
                        $result->toc .= '&nbsp;' . format_string($sco->title) . "</li>\n";
                    }
                }
            } else {
                $result->toc .= '&nbsp;' . format_string($sco->title) . "</li>\n";
            }
            if ($nextsco !== false && $nextid == 0 && $findnext) {
                if (!empty($nextsco->launch)) {
                    $nextid = $nextsco->id;
                }
            }
        }
        for ($i = 0; $i < $level; $i++) {
            $result->toc .= "\t\t</ul></li>\n";
        }
        if ($play) {
            $sco = $DB->get_record('scorm_scoes', array('id' => $scoid));
            $sco->previd = $previd;
            $sco->nextid = $nextid;
            $result->sco = $sco;
            $result->incomplete = $incomplete;
        } else {
            $result->incomplete = $incomplete;
        }
    }
    $result->toc .= "\t</ul>\n";
    if ($scorm->hidetoc == 0) {
        $PAGE->requires->data_for_js('scormdata', array('plusicon' => $OUTPUT->mod_icon_url('pix/plus', 'scorm'), 'minusicon' => $OUTPUT->mod_icon_url('pix/minus', 'scorm')));
        $PAGE->requires->js('mod/scorm/datamodels/scorm_datamodels.js');
    }
    $url = $CFG->wwwroot . '/mod/scorm/player.php?a=' . $scorm->id . '&currentorg=' . $currentorg . $modestr;
    $select = html_select::make_popup_form($url, 'scoid', $tocmenus, "tocmenu", $sco->id);
    $select->nothinglabel = false;
    $result->tocmenu = $OUTPUT->select($select);
    return $result;
}
Пример #30
0
/**
 * Print the drop down that allows the user to select how they want to have
 * the discussion displayed.
 *
 * @param int $id forum id if $forumtype is 'single',
 *              discussion id for any other forum type
 * @param mixed $mode forum layout mode
 * @param string $forumtype optional
 */
function forum_print_mode_form($id, $mode, $forumtype = '')
{
    global $OUTPUT;
    $select = html_select::make_popup_form("view.php?f={$id}", 'mode', forum_get_layout_modes(), "mode", $mode);
    $select->nothinglabel = false;
    if ($forumtype == 'single') {
        echo '<div class="forummode">';
        echo $OUTPUT->select($select);
        echo '</div>';
    } else {
        echo $OUTPUT->select($select);
    }
}