Example #1
1
 /**
  * Constructor for the base resource class
  *
  * Constructor for the base resource class.
  * If cmid is set create the cm, course, resource objects.
  * and do some checks to make sure people can be here, and so on.
  *
  * @param cmid   integer, the current course module id - not set for new resources
  */
 function resource_base($cmid = 0)
 {
     global $CFG, $COURSE;
     $this->navlinks = array();
     if ($cmid) {
         if (!($this->cm = get_coursemodule_from_id('resource', $cmid))) {
             error("Course Module ID was incorrect");
         }
         if (!($this->course = get_record("course", "id", $this->cm->course))) {
             error("Course is misconfigured");
         }
         if (!($this->resource = get_record("resource", "id", $this->cm->instance))) {
             error("Resource ID was incorrect");
         }
         $this->strresource = get_string("modulename", "resource");
         $this->strresources = get_string("modulenameplural", "resource");
         if (!$this->cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $this->cm->id))) {
             $pagetitle = strip_tags($this->course->shortname . ': ' . $this->strresource);
             $navigation = build_navigation($this->navlinks, $this->cm);
             print_header($pagetitle, $this->course->fullname, $navigation, "", "", true, '', navmenu($this->course, $this->cm));
             notice(get_string("activityiscurrentlyhidden"), "{$CFG->wwwroot}/course/view.php?id={$this->course->id}");
         }
     } else {
         $this->course = $COURSE;
     }
 }
 function print_header($title, $morenavlinks = NULL, $bodytags = '', $meta = '', $extrabuttons = '')
 {
     global $USER, $CFG;
     $this->init_full();
     $replacements = array('%fullname%' => format_string($this->activityrecord->name));
     foreach ($replacements as $search => $replace) {
         $title = str_replace($search, $replace, $title);
     }
     if (empty($morenavlinks) && $this->user_allowed_editing()) {
         // mmmm, tables
         $buttons = '<table><tr>';
         $buttons .= '<td>' . $extrabuttons . '</td>';
         $buttons .= '<td>' . update_module_button(optional_param('clone', $this->modulerecord->id, PARAM_INT), $this->courserecord->id, get_string('modulename', $this->activityname)) . '</td>';
         if (!empty($CFG->showblocksonmodpages)) {
             $clonething = optional_param('clone', 0, PARAM_INT);
             $clonething = $clonething ? '<input type="hidden" name="clone" value="' . $clonething . '" />' : '';
             $buttons .= '<td><form ' . $CFG->frametarget . ' method="get" action="view.php"><div>' . '<input type="hidden" name="id" value="' . $this->modulerecord->id . '" />' . $clonething . '<input type="hidden" name="edit" value="' . ($this->user_is_editing() ? 'off' : 'on') . '" />' . '<input type="submit" value="' . get_string($this->user_is_editing() ? 'blockseditoff' : 'blocksediton') . '" /></div></form></td>';
         }
         $buttons .= '</tr></table>';
     } else {
         $buttons = $extrabuttons ? $extrabuttons : '&nbsp;';
     }
     if (empty($morenavlinks)) {
         $morenavlinks = array();
     }
     $navigation = build_navigation($morenavlinks, $this->modulerecord);
     print_header($title, $this->courserecord->fullname, $navigation, '', $meta, true, $buttons, navmenu($this->courserecord, $this->modulerecord), false, $bodytags);
 }
Example #3
0
 function print_entry($course)
 {
     global $CFG, $USER;
     $strloginto = get_string("loginto", "", $course->shortname);
     $strcourses = get_string("courses");
     $teacher = get_teacher($course->id);
     if ((double) $course->cost < 0) {
         $cost = (double) $CFG->enrol_cost;
     } else {
         $cost = (double) $course->cost;
     }
     if (abs($cost) < 0.01) {
         // no cost, default to base class entry to course
         $manual = enrolment_factory::factory('manual');
         $manual->print_entry($course);
     } else {
         $navlinks = array();
         $navlinks[] = array('name' => $strcourses, 'link' => "{$CFG->wwwroot}/course", 'type' => 'misc');
         $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
         $navigation = build_navigation($navlinks);
         print_header($strloginto, $course->fullname, $navigation);
         print_course($course, "80%");
         if ($course->password) {
             // Presenting two options
             print_heading(get_string('costorkey', 'enrol_paypal'), 'center');
         }
         print_simple_box_start("center");
         if ($USER->username == 'guest') {
             // force login only for guest user, not real users with guest role
             if (empty($CFG->loginhttps)) {
                 $wwwroot = $CFG->wwwroot;
             } else {
                 // This actually is not so secure ;-), 'cause we're
                 // in unencrypted connection...
                 $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
             }
             echo '<div align="center"><p>' . get_string('paymentrequired') . '</p>';
             echo '<p><b>' . get_string('cost') . ": {$CFG->enrol_currency} {$cost}" . '</b></p>';
             echo '<p><a href="' . $wwwroot . '/login/">' . get_string('loginsite') . '</a></p>';
             echo '</div>';
         } else {
             //Sanitise some fields before building the PayPal form
             $coursefullname = $course->fullname;
             $courseshortname = $course->shortname;
             $userfullname = fullname($USER);
             $userfirstname = $USER->firstname;
             $userlastname = $USER->lastname;
             $useraddress = $USER->address;
             $usercity = $USER->city;
             include $CFG->dirroot . '/enrol/paypal/enrol.html';
         }
         print_simple_box_end();
         if ($course->password) {
             // Second option
             $password = '';
             include $CFG->dirroot . '/enrol/manual/enrol.html';
         }
         print_footer();
     }
 }
Example #4
0
/**
 * Print url header.
 * @param object $url
 * @param object $cm
 * @param object $course
 * @return void
 */
function url_print_header($url, $cm, $course)
{
    global $PAGE, $OUTPUT;
    $PAGE->set_title($course->shortname . ': ' . $url->name);
    $PAGE->set_heading($course->fullname);
    $PAGE->set_activity_record($url);
    $PAGE->set_button(update_module_button($cm->id, '', get_string('modulename', 'url')));
    echo $OUTPUT->header(build_navigation('', $cm), navmenu($course, $cm));
}
Example #5
0
 /**
  * Prints the page header.
  */
 function print_header()
 {
     global $CFG, $USER, $PAGE;
     require_once $CFG->libdir . '/blocklib.php';
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/my/pagelib.php';
     /// My Moodle arguments:
     $edit = optional_param('edit', -1, PARAM_BOOL);
     $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
     $mymoodlestr = get_string('mymoodle', 'my');
     if (isguest()) {
         $wwwroot = $CFG->wwwroot . '/login/index.php';
         if (!empty($CFG->loginhttps)) {
             $wwwroot = str_replace('http:', 'https:', $wwwroot);
         }
         print_header($mymoodlestr);
         notice_yesno(get_string('noguest', 'my') . '<br /><br />' . get_string('liketologin'), $wwwroot, $CFG->wwwroot);
         print_footer();
         die;
     }
     /// Add curriculum stylesheets...
     if (file_exists($CFG->dirroot . '/curriculum/styles.css')) {
         $CFG->stylesheets[] = $CFG->wwwroot . '/curriculum/styles.css';
     }
     /// Fool the page library into thinking we're in My Moodle.
     $CFG->pagepath = $CFG->wwwroot . '/my/index.php';
     $PAGE = page_create_instance($USER->id);
     if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
         $PAGE->section = $section;
     }
     $this->pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
     /// Make sure that the curriculum block is actually on this
     /// user's My Moodle page instance.
     if ($cablockid = get_field('block', 'id', 'name', 'curr_admin')) {
         if (!record_exists('block_pinned', 'blockid', $cablockid, 'pagetype', 'my-index')) {
             blocks_execute_action($PAGE, $this->pageblocks, 'add', (int) $cablockid, true, false);
         }
     }
     if ($edit != -1 and $PAGE->user_allowed_editing()) {
         $USER->editing = $edit;
     }
     //$PAGE->print_header($mymoodlestr);
     $title = $this->get_title();
     print_header($title, $title, build_navigation($this->get_navigation()));
     echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
     echo '<tr valign="top">';
     $blocks_preferred_width = bounded_number(180, blocks_preferred_width($this->pageblocks[BLOCK_POS_LEFT]), 210);
     if (blocks_have_content($this->pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
         echo '<td style="vertical-align: top; width: ' . $blocks_preferred_width . 'px;" id="left-column">';
         blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_LEFT);
         echo '</td>';
     }
     echo '<td valign="top" id="middle-column">';
     if (blocks_have_content($this->pageblocks, BLOCK_POS_CENTRE) || $PAGE->user_is_editing()) {
         blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_CENTRE);
     }
 }
 function display()
 {
     global $CFG;
     $formatoptions = new object();
     $formatoptions->noclean = true;
     /// Are we displaying the course blocks?
     if ($this->resource->options == 'showblocks') {
         parent::display_course_blocks_start();
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$this->resource}->id");
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
             $player_url = $CFG->wwwroot . '/mod/kaltura/kswfdoc.php?context=' . $this->course->id . '&entry_id=' . $resource->alltext;
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if ($resource->alltext) {
                 echo '<input style="margin-top:20px;" type="button" value="View video presentation" onclick="kalturaInitModalBox(\'' . $player_url . '\', {width:780, height:400});">';
             }
             //            echo embed_kaltura($resource->alltext,get_width($entry),get_height($entry),$entry->entry_type);
         }
         parent::display_course_blocks_end();
     } else {
         /// Set up generic stuff first, including checking for access
         parent::display();
         /// Set up some shorthand variables
         $cm = $this->cm;
         $course = $this->course;
         $resource = $this->resource;
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$resource->id}");
         $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
         $inpopup = optional_param('inpopup', '', PARAM_BOOL);
         add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
         }
         $formatoptions = new object();
         $formatoptions->noclean = true;
         print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
         if (trim(strip_tags($this->resource->alltext))) {
             $player_url = $CFG->wwwroot . '/mod/kaltura/kswfdoc.php?context=' . $this->course->id . '&entry_id=' . $resource->alltext;
             if ($resource->alltext) {
                 echo '<input type="button" style="margin-top:20px;"  value="View video presentation" onclick="kalturaInitModalBox(\'' . $player_url . '\', {width:780, height:400});">';
             }
             //          echo embed_kaltura($resource->alltext,get_width($entry),get_height($entry),$entry->entry_type);
         }
         /*       print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id),
                         "center", "", "", "20");
         */
         $strlastmodified = get_string("lastmodified");
         echo "<div class=\"modified\">{$strlastmodified}: " . userdate($resource->timemodified) . "</div>";
         print_footer($course);
     }
 }
/**
 * Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and
 * (optional) navigation tabs for any gradebook page. All gradebook pages MUST use these functions
 * in favour of the usual print_header(), print_header_simple(), print_heading() etc.
 * !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at
 * the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN).
 *
 * @param int $courseid
 * @param string $active_type The type of the current page (report, settings, import, export, scales, outcomes, letters)
 * @param string $active_plugin The plugin of the current page (grader, fullview etc...)
 * @param string $heading The heading of the page. Tries to guess if none is given
 * @param boolean $return Whether to return (true) or echo (false) the HTML generated by this function
 * @param string $bodytags Additional attributes that will be added to the <body> tag
 * @param string $buttons Additional buttons to display on the page
 *
 * @return string HTML code or nothing if $return == false
 */
function print_grade_page_head_local($courseid, $active_type, $active_plugin = null, $heading = false, $return = false, $bodytags = '', $buttons = false, $extracss = array())
{
    global $CFG, $COURSE;
    $strgrades = get_string('grades');
    $plugin_info = grade_get_plugin_info($courseid, $active_type, $active_plugin);
    // Determine the string of the active plugin
    $stractive_plugin = $active_plugin ? $plugin_info['strings']['active_plugin_str'] : $heading;
    $stractive_type = $plugin_info['strings'][$active_type];
    $navlinks = array();
    $first_link = '';
    if ($active_type == 'settings' && $active_plugin != 'coursesettings') {
        $first_link = $plugin_info['report'][$active_plugin]['link'];
    } elseif ($active_type != 'report') {
        $first_link = $CFG->wwwroot . '/grade/index.php?id=' . $COURSE->id;
    }
    if ($active_type == 'preferences') {
        $CFG->stylesheets[] = $CFG->wwwroot . '/grade/report/styles.css';
    }
    foreach ($extracss as $css_url) {
        $CFG->stylesheets[] = $css_url;
    }
    $navlinks[] = array('name' => $strgrades, 'link' => $first_link, 'type' => 'misc');
    $active_type_link = '';
    if (!empty($plugin_info[$active_type]['link']) && $plugin_info[$active_type]['link'] != qualified_me()) {
        $active_type_link = $plugin_info[$active_type]['link'];
    }
    if (!empty($plugin_info[$active_type]['parent']['link'])) {
        $active_type_link = $plugin_info[$active_type]['parent']['link'];
        $navlinks[] = array('name' => $stractive_type, 'link' => $active_type_link, 'type' => 'misc');
    }
    if (empty($plugin_info[$active_type]['id'])) {
        $navlinks[] = array('name' => $stractive_type, 'link' => $active_type_link, 'type' => 'misc');
    }
    $navlinks[] = array('name' => $stractive_plugin, 'link' => null, 'type' => 'misc');
    $navigation = build_navigation($navlinks);
    $title = ': ' . $stractive_plugin;
    if (empty($plugin_info[$active_type]['id']) || !empty($plugin_info[$active_type]['parent'])) {
        $title = ': ' . $stractive_type . ': ' . $stractive_plugin;
    }
    $returnval = print_header_simple($strgrades . ': ' . $stractive_type, $title, $navigation, '', $bodytags, true, $buttons, navmenu($COURSE), false, '', $return);
    // Guess heading if not given explicitly
    if (!$heading) {
        $heading = $stractive_plugin;
    }
    if ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_DROPDOWN) {
        $returnval .= print_grade_plugin_selector($plugin_info, $return);
    }
    $returnval .= print_heading($heading);
    if ($CFG->grade_navmethod == GRADE_NAVMETHOD_COMBO || $CFG->grade_navmethod == GRADE_NAVMETHOD_TABS) {
        $returnval .= grade_print_tabs($active_type, $active_plugin, $plugin_info, $return);
    }
    if ($return) {
        return $returnval;
    }
}
 function display()
 {
     global $CFG;
     $formatoptions = new object();
     $formatoptions->noclean = true;
     /// Are we displaying the course blocks?
     if ($this->resource->options == 'showblocks') {
         parent::display_course_blocks_start();
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$this->resource}->id");
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
             $context = get_context_instance(CONTEXT_COURSE, $this->course->id);
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if (has_capability('moodle/course:manageactivities', $context)) {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), $entry->entry_type, $entry->design, true);
             } else {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $entry->design, true);
             }
         }
         parent::display_course_blocks_end();
     } else {
         /// Set up generic stuff first, including checking for access
         parent::display();
         /// Set up some shorthand variables
         $cm = $this->cm;
         $course = $this->course;
         $resource = $this->resource;
         $entry = get_record('kaltura_entries', 'context', "R_" . "{$resource->id}");
         $pagetitle = strip_tags($course->shortname . ': ' . format_string($resource->name));
         $inpopup = optional_param('inpopup', '', PARAM_BOOL);
         add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
         $navigation = build_navigation($this->navlinks, $cm);
         print_header($pagetitle, $course->fullname, $navigation, "", "", true, update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
         if (trim(strip_tags($this->resource->alltext))) {
             echo $entry->title;
             $context = get_context_instance(CONTEXT_COURSE, $this->course->id);
             $formatoptions = new object();
             $formatoptions->noclean = true;
             print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $this->course->id), "center");
             if (has_capability('moodle/course:manageactivities', $context)) {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), $entry->entry_type, $entry->design, true);
             } else {
                 echo embed_kaltura($resource->alltext, get_width($entry), get_height($entry), KalturaEntryType::MEDIA_CLIP, $entry->design, true);
             }
         }
         /*       print_simple_box(format_text($resource->alltext, $resource->reference, $formatoptions, $course->id),
                         "center", "", "", "20");
         */
         $strlastmodified = get_string("lastmodified");
         echo "<div class=\"modified\">{$strlastmodified}: " . userdate($resource->timemodified) . "</div>";
         print_footer($course);
     }
 }
 function print_header($title)
 {
     global $USER, $CFG;
     $replacements = array('%fullname%' => get_string('mycollaboration', 'local'));
     foreach ($replacements as $search => $replace) {
         $title = str_replace($search, $replace, $title);
     }
     $site = get_site();
     $nav = get_string('mycollaboration', 'local');
     $header = $site->shortname . ': ' . $nav;
     $navlinks = array(array('name' => $nav, 'link' => '', 'type' => 'misc'));
     $navigation = build_navigation($navlinks);
     print_header($title, $header, $navigation, '', '', true);
 }
Example #10
0
 function print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview", $meta = "")
 {
     global $CFG;
     /// Define some strings
     $strquizzes = get_string("modulenameplural", "quiz");
     $strquiz = get_string("modulename", "quiz");
     /// Print the page header
     $navigation = build_navigation('', $cm);
     print_header_simple(format_string($quiz->name), "", $navigation, '', $meta, true, update_module_button($cm->id, $course->id, $strquiz), user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm));
     /// Print the tabs
     $currenttab = 'reports';
     $mode = $reportmode;
     require $CFG->dirroot . '/mod/quiz/tabs.php';
 }
Example #11
0
 function print_header()
 {
     global $USER, $CFG;
     $tagname = tag_display_name($this->tag_object);
     $navlinks = array();
     $navlinks[] = array('name' => get_string('tags', 'tag'), 'link' => "{$CFG->wwwroot}/tag/search.php", 'type' => '');
     $navlinks[] = array('name' => $tagname, 'link' => '', 'type' => '');
     $navigation = build_navigation($navlinks);
     $title = get_string('tag', 'tag') . ' - ' . $tagname;
     $button = '';
     if ($this->user_allowed_editing()) {
         $button = update_tag_button($this->id);
     }
     print_header_simple($title, '', $navigation, '', '', '', $button);
 }
Example #12
0
 /**
 * Prints the entry form/page for this enrolment
 *
 * This is only called from course/enrol.php
 * Most plugins will probably override this to print payment
 * forms etc, or even just a notice to say that manual enrolment
 * is disabled
 *
 * @param    course  current course object
 */
 function print_entry($course)
 {
     global $CFG, $USER, $SESSION, $THEME;
     $strloginto = get_string('loginto', '', $course->shortname);
     $strcourses = get_string('courses');
     $context = context_system::get_context();
     $navlinks = array();
     $navlinks[] = array('name' => $strcourses, 'link' => ".", 'type' => 'misc');
     $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
     $navigation = build_navigation($navlinks);
     // if we get here we are going to display the BUY COURSE message
     print_header($strloginto, $course->fullname, $navigation, "form.password");
     include "{$CFG->dirroot}/enrol/joomdle/enrol.html";
     print_footer();
 }
 public static function printHeader($title = '', $course_id = SITEID, $cache = false)
 {
     $navlinks = array();
     if ($course_id != SITEID) {
         $navlinks[] = array('name' => get_field('course', 'shortname', 'id', $course_id), 'link' => $GLOBALS['CFG']->wwwroot . '/course/view.php?id=' . $course_id, 'type' => 'title');
     }
     $navlinks[] = array('name' => $title, 'link' => '', 'type' => 'title');
     print_header_simple($title, '', build_navigation($navlinks), '', '', $cache);
     echo '<div style="float:right;">';
     /*		helpbutton('repository', sharing_cart_plugins::get_string('title', 'repository'),
     				'block_sharing_cart/plugins/repository', true, false, '', false);*/
     echo '</div>';
     echo '<div style="clear:both;"><!-- clear float --></div>';
     print_heading($title);
 }
Example #14
0
 function print_header($title)
 {
     global $USER;
     $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);
     print_header($title, $header, $navigation, '', '', true, $button, $loggedinas);
 }
Example #15
0
 function print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview", $meta = "")
 {
     global $CFG;
     /// Define some strings
     $strquizzes = get_string("modulenameplural", "quiz");
     $strquiz = get_string("modulename", "quiz");
     /// Print the page header
     $navlinks = array();
     $navlinks[] = array('name' => $strquizzes, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
     $navlinks[] = array('name' => format_string($quiz->name), 'link' => '', 'type' => 'activityinstance');
     $navigation = build_navigation($navlinks);
     print_header_simple(format_string($quiz->name), "", $navigation, '', $meta, true, update_module_button($cm->id, $course->id, $strquiz), navmenu($course, $cm));
     /// Print the tabs
     $currenttab = 'reports';
     $mode = $reportmode;
     require $CFG->dirroot . '/mod/quiz/tabs.php';
 }
function webquestscorm_print_header($name, $currenttab = '', $course = NULL, $cm = NULL, $cmid = 0)
{
    global $CFG;
    if ($cmid) {
        if (!isset($cm)) {
            if (!($cm = get_coursemodule_from_id('webquestscorm', $cmid))) {
                error('Course Module ID was incorrect');
            }
        }
        if (!isset($course)) {
            if (!($course = get_record('course', 'id', $this->cm->course))) {
                error('Course is misconfigured');
            }
        }
        if (!isset($name)) {
            if (!($webquestscorm = get_record('webquestscorm', 'id', $this->cm->instance))) {
                error('webquestscorm ID was incorrect');
            }
            $name = $webquestscorm->name;
        }
    } else {
        if (!isset($cm)) {
            error('Course Module ID was incorrect');
        }
        if (!isset($course)) {
            error('Course is misconfigured');
        }
        if (!isset($name)) {
            error('webquestscorm name was incorrect');
        }
    }
    $strwebquestscorms = get_string('modulenameplural', 'webquestscorm');
    $strwebquestscorm = get_string('modulename', 'webquestscorm');
    $strname = format_string($name);
    $button = update_module_button($cm->id, $course->id, $strwebquestscorm);
    $meta = '';
    if ($CFG->version < 2007101500) {
        print_header_simple(format_string($strname), "", "<a href=\"index.php?id={$course->id}\">{$strwebquestscorms}</a> -> " . format_string($name), "", "", true, update_module_button($cm->id, $course->id, $strwebquestscorm), navmenu($course, $cm));
    } else {
        $navigation = build_navigation('', $cm);
        print_header($course->shortname . ':' . $strname, $course->fullname, $navigation, '', $meta, true, $button, navmenu($course, $cm));
    }
    print_heading(format_string($name, true));
    require_once "tabs.php";
}
Example #17
0
 function print_header_and_tabs($cm, $course, $quiz, $reportmode = "overview")
 {
     global $CFG;
     /// Define some strings
     $strquizzes = get_string("modulenameplural", "quiz");
     $strquiz = get_string("modulename", "quiz");
     /// Print the page header
     $navigation = build_navigation('', $cm);
     print_header_simple(format_string($quiz->name), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $strquiz), navmenu($course, $cm));
     /// Print the tabs
     $currenttab = 'reports';
     $mode = $reportmode;
     require $CFG->dirroot . '/mod/quiz/tabs.php';
     $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
     if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
         echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">' . get_string('seeallcoursegrades', 'grades') . '</a></div>';
     }
 }
 function print_header_and_tabs($cm, $course, $game, $reportmode = "overview", $meta = "")
 {
     global $CFG;
     /// Define some strings
     $strgames = get_string("modulenameplural", "game");
     $strgame = get_string("modulename", "game");
     /// Print the page header
     if (function_exists('build_navigation')) {
         $navigation = build_navigation('', $cm);
         print_header($course->shortname, $course->shortname, $navigation);
     } else {
         print_header_simple(format_string($game->name), "", "<a href=\"index.php?id={$course->id}\">{$strgames}</a>\n                      -> " . format_string($game->name), '', $meta, true, update_module_button($cm->id, $course->id, $strgame), navmenu($course, $cm));
     }
     /// Print the tabs
     $currenttab = 'reports';
     $mode = $reportmode;
     include 'tabs.php';
 }
 function print_header($title, $morebreadcrumbs = NULL)
 {
     global $USER, $CFG, $WS;
     $this->init_full();
     if ($this->user_allowed_editing()) {
         $buttons = wiki_table_start('', true);
         $buttons .= update_module_button($this->modulerecord->id, $this->courserecord->id, get_string('modulename', 'wiki'));
         if (!empty($CFG->showblocksonmodpages)) {
             $buttons .= wiki_change_column('', true);
             $prop = null;
             $prop->method = "get";
             $prop->action = "view.php";
             $prop->events = 'onsubmit="this.target=\'_top\'; return true"';
             $buttons .= wiki_form_start($prop, true);
             $buttons .= wiki_div_start('', true);
             $prop = null;
             $prop->name = "id";
             $prop->value = $this->modulerecord->id;
             $buttons .= wiki_input_hidden($prop, true);
             $prop = null;
             $prop->name = "edit";
             $prop->value = $this->user_is_editing() ? 'off' : 'on';
             $buttons .= wiki_input_hidden($prop, true);
             $prop = null;
             $prop->value = get_string($this->user_is_editing() ? 'blockseditoff' : 'blocksediton');
             $buttons .= wiki_input_submit($prop, true);
             $buttons .= wiki_div_end(true);
             $buttons .= wiki_form_end(true);
         }
         $buttons .= wiki_table_end('', true);
     } else {
         $buttons = '&nbsp;';
     }
     //        print_header($title, $this->courserecord->fullname, $crumbtext, '', '', true, $buttons, navmenu($this->courserecord, $this->modulerecord));
     /// Print header.
     $navlinks = array();
     $navlinks[] = array('name' => get_string('modulenameplural', 'wiki'), 'link' => $CFG->wwwroot . '/mod/wiki/index.php?id=' . $this->courserecord->id, 'type' => 'activity');
     $navlinks[] = array('name' => format_string($this->activityrecord->name), 'link' => "view.php", 'type' => 'activityinstance');
     $navigation = build_navigation($navlinks);
     print_header_simple(format_string($this->activityrecord->name), "", $navigation, "", "", true, $buttons, navmenu($this->courserecord, $WS->cm));
 }
Example #20
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);
 }
Example #21
0
 /**
 * Prints the entry form/page for this enrolment
 *
 * This is only called from course/enrol.php
 * Most plugins will probably override this to print payment
 * forms etc, or even just a notice to say that manual enrolment
 * is disabled
 *
 * @param    course  current course object
 */
 function print_entry($course)
 {
     global $CFG, $USER, $SESSION, $THEME;
     $strloginto = get_string('loginto', '', $course->shortname);
     $strcourses = get_string('courses');
     /// Automatically enrol into courses without password
     $context = get_context_instance(CONTEXT_SYSTEM);
     $navlinks = array();
     $navlinks[] = array('name' => $strcourses, 'link' => ".", 'type' => 'misc');
     $navlinks[] = array('name' => $strloginto, 'link' => null, 'type' => 'misc');
     $navigation = build_navigation($navlinks);
     if ($course->password == '') {
         // no password, so enrol
         if (has_capability('moodle/legacy:guest', $context, $USER->id, false)) {
             add_to_log($course->id, 'course', 'guest', 'view.php?id=' . $course->id, getremoteaddr());
         } else {
             if (empty($_GET['confirm']) && empty($_GET['cancel'])) {
                 print_header($strloginto, $course->fullname, $navigation);
                 echo '<br />';
                 notice_yesno(get_string('enrolmentconfirmation'), "enrol.php?id={$course->id}&amp;confirm=1", "enrol.php?id={$course->id}&amp;cancel=1");
                 print_footer();
                 exit;
             } else {
                 if (!empty($_GET['confirm'])) {
                     if (!enrol_into_course($course, $USER, 'manual')) {
                         print_error('couldnotassignrole');
                     }
                     // force a refresh of mycourses
                     unset($USER->mycourses);
                     if (!empty($SESSION->wantsurl)) {
                         $destination = $SESSION->wantsurl;
                         unset($SESSION->wantsurl);
                     } else {
                         $destination = "{$CFG->wwwroot}/course/view.php?id={$course->id}";
                     }
                     redirect($destination);
                 } else {
                     if (!empty($_GET['cancel'])) {
                         unset($SESSION->wantsurl);
                         if (!empty($SESSION->enrolcancel)) {
                             $destination = $SESSION->enrolcancel;
                             unset($SESSION->enrolcancel);
                         } else {
                             $destination = $CFG->wwwroot;
                         }
                         redirect($destination);
                     }
                 }
             }
         }
     }
     // if we get here we are going to display the form asking for the enrolment key
     // and (hopefully) provide information about who to ask for it.
     if (!isset($password)) {
         $password = '';
     }
     print_header($strloginto, $course->fullname, $navigation, "form.password");
     print_course($course, "80%");
     include "{$CFG->dirroot}/enrol/manual/enrol.html";
     print_footer();
 }
/**
 * Print the standard header for pagemenu module
 *
 * @uses $CFG
 * @uses $USER tabs.php requires it
 * @param object $cm Course module record object
 * @param object $course Couse record object
 * @param object $pagemenu pagemenu module record object
 * @param string $currenttab File location and tab to be selected
 * @param string $focus Focus
 * @param boolean $showtabs Display tabs yes/no
 * @return void
 **/
function pagemenu_print_header($cm, $course, $pagemenu, $currenttab = 'view', $focus = '', $showtabs = true)
{
    global $CFG, $USER;
    $strpagemenus = get_string('modulenameplural', 'pagemenu');
    $strpagemenu = get_string('modulename', 'pagemenu');
    $strname = format_string($pagemenu->name);
    /// Log it!
    add_to_log($course->id, 'pagemenu', $currenttab, "{$currenttab}.php?id={$cm->id}", $strname, $cm->id);
    /// Print header, heading, tabs and messages
    print_header_simple($strname, $strname, build_navigation('', $cm), $focus, '', true, update_module_button($cm->id, $course->id, $strpagemenu), navmenu($course, $cm));
    print_heading($strname);
    if ($showtabs) {
        pagemenu_print_tabs($cm, $currenttab);
    }
    pagemenu_print_messages();
}
Example #23
0
        if (!$ineditperiod || $USER->id != $fromdb->userid and !has_capability('mod/glossary:manageentries', $context)) {
            if ($USER->id != $fromdb->userid) {
                print_error('errcannoteditothers', 'glossary');
            } elseif (!$ineditperiod) {
                print_error('erredittimeexpired', 'glossary');
            }
            die;
        }
        if ($aliases = get_records_menu("glossary_alias", "entryid", $e, '', 'id, alias')) {
            $toform->aliases = implode("\n", $aliases) . "\n";
        }
        $mform->set_data($toform);
    }
}
$stredit = empty($e) ? get_string('addentry', 'glossary') : get_string("edit");
$navigation = build_navigation($stredit, $cm);
print_header_simple(format_string($glossary->name), "", $navigation, "", "", true, "", navmenu($course, $cm));
print_heading(format_string($glossary->name));
/// Info box
///if ( $glossary->intro ) {
///    print_simple_box(format_text($glossary->intro), 'center', '70%', '', 5, 'generalbox', 'intro');
///}
/// Tabbed browsing sections
///$tab = GLOSSARY_ADDENTRY_VIEW;
///include("tabs.php");
if (!$e) {
    require_capability('mod/glossary:write', $context);
}
$mform->display();
///glossary_print_tabbed_table_end();
print_footer($course);
$groupmode = groups_get_activity_groupmode($cm);
$currentgroup = groups_get_activity_group($cm, true);
if (empty($currentgroup)) {
    $currentgroup = 0;
}
if (empty($elluminate->meetingid) && $elluminate->groupmode != 0) {
    elluminate_group_instance_check($elluminate, $cm->id);
}
$baseurl = $CFG->wwwroot . '/mod/elluminate/preload.php?id=' . $elluminate->id;
/// Print the page header
$strelluminates = get_string('modulenameplural', 'elluminate');
$strelluminate = get_string('modulename', 'elluminate');
$straddpreload = get_string('addpreload', 'elluminate');
$strdelpreload = get_string('deletewhiteboardpreload', 'elluminate');
$buttontext = update_module_button($cm->id, $course->id, $strelluminate);
$navigation = build_navigation(empty($delete) ? $straddpreload : $strdelpreload, $cm);
print_header_simple(format_string($elluminate->name), '', $navigation, '', '', true, $buttontext, navmenu($course, $cm));
/// Delete a preload file for this meeting.
if (!empty($delete)) {
    if (!empty($elluminate->meetingid)) {
        if ($preload = elluminate_list_meeting_preloads($elluminate->meetingid)) {
            if ($preload->presentationid == $delete) {
                /// Delete the preload from the meeting.
                if (!elluminate_delete_preload($preload->presentationid, $elluminate->meetingid)) {
                    error(get_string('preloaddeleteerror', 'elluminate'));
                }
                redirect($CFG->wwwroot . '/mod/elluminate/view.php?id=' . $cm->id, get_string('preloaddeletesuccess', 'elluminate'), 5);
            }
        }
    }
}
Example #25
0
    $zipname = 'zip01';
}
$cb = fm_clean_checkbox_array();
if ($cb != NULL) {
    $USER->fm_cb = $cb;
}
if (!($course = get_record('course', 'id', $id))) {
    error("That's an invalid course id", "view.php?id={$id}&amp;rootdir={$rootdir}&groupid={$groupid}");
}
require_login($course->id);
// Ensures the user is able to view the fmanager
fm_check_access_rights($course->id);
$strtitle = get_string('zipfiles', 'block_file_manager');
$nav[] = array('name' => get_string('filemanager', 'block_file_manager'), 'link' => "view.php?id={$id}&groupid={$groupid}", 'type' => 'misc');
$nav[] = array('name' => $strtitle, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($nav);
print_header($strtitle, format_string($course->fullname), $navigation, '', '', false, "&nbsp;", "&nbsp;");
if ($action == 'zipsel') {
    $headingstr = get_string('zipfiles', 'block_file_manager');
} elseif ($action == 'unzip') {
    $headingstr = get_string('unzipfiles', 'block_file_manager');
}
print_heading($headingstr);
switch ($action) {
    case 'viewzip':
        if ($groupid == 0) {
            $list = fm_view_zipped(fm_get_user_link($zipid), $groupid);
        } else {
            $list = fm_view_zipped(fm_get_group_link($zipid, $groupid), $groupid);
        }
        print_simple_box_start('center', '375', '#C0C0C0');
Example #26
0
/**
 * This function checks to see whether local database customisations are up-to-date
 * by comparing $CFG->local_version to the variable $local_version defined in
 * local/version.php. If not, it looks for a function called 'xmldb_local_upgrade'
 * in a file called 'local/db/upgrade.php', and if it's there calls it with the
 * appropiate $oldversion parameter. Then it updates $CFG->local_version.
 * On success it prints a continue link. On failure it prints an error.
 *
 * @uses $CFG
 * @uses $db to do something really evil with the debug setting that should probably be eliminated. TODO!
 * @param string $continueto a URL passed to print_continue() if the local upgrades succeed.
 */
function upgrade_local_dbs($continueto)
{
    global $CFG, $db;
    $path = '/local';
    $pat = 'local';
    $status = true;
    $changed = false;
    $firstloop = true;
    while (is_dir($CFG->dirroot . $path)) {
        // if we don't have code version or a db upgrade file, check lower
        if (!file_exists($CFG->dirroot . "{$path}/version.php") || !file_exists($CFG->dirroot . "{$path}/db/upgrade.php")) {
            $path .= '/local';
            $pat .= 'local';
            continue;
        }
        require_once $CFG->dirroot . "{$path}/version.php";
        // Get code versions
        $cfgvarname = "{$pat}_version";
        if (empty($CFG->{$cfgvarname})) {
            // normally we'd install, but just replay all the upgrades.
            $CFG->{$cfgvarname} = 0;
        }
        $localversionvar = "{$pat}_version";
        // echo "($localversionvar) ".$$localversionvar." > ($cfgvarname) ".$CFG->{$cfgvarname}."<br/>";
        if (${$localversionvar} > $CFG->{$cfgvarname}) {
            // something upgrades!
            upgrade_log_start();
            /// Capabilities
            /// do this first *instead of* last , so that the installer has the chance to locally assign caps
            if (!update_capabilities($pat)) {
                error('Could not set up the capabilities for ' . $pat . '!');
            }
            if ($firstloop) {
                $strdatabaseupgrades = get_string('databaseupgrades');
                print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation(array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'))), '', upgrade_get_javascript());
                $firstloop = false;
            }
            $changed = true;
            require_once $CFG->dirroot . "{$path}/db/upgrade.php";
            $db->debug = true;
            $upgradefunc = "xmldb_{$pat}_upgrade";
            if ($upgradefunc($CFG->{$cfgvarname})) {
                $db->debug = false;
                if (set_config($localversionvar, ${$localversionvar})) {
                    notify(get_string('databasesuccess'), 'notifysuccess');
                    notify(get_string('databaseupgradelocal', '', $path . ' >> ' . ${$localversionvar}), 'notifysuccess');
                } else {
                    $status = false;
                    error('Upgrade of local database customisations failed in $path! (Could not update version in config table)');
                }
            } else {
                $db->debug = false;
                error("Upgrade failed!  See {$path}/version.php");
            }
            if (!events_update_definition($pat)) {
                error('Could not set up the events definitions for ' . $pat . '!');
            }
            upgrade_log_finish();
        } else {
            if (${$localversionvar} < $CFG->{$cfgvarname}) {
                notify("WARNING!!!  The local version you are using in {$path} is OLDER than the version that made these databases!");
            }
        }
        $path .= '/local';
        $pat .= 'local';
    }
    if ($changed) {
        print_continue($continueto);
        print_footer('none');
        exit;
    }
}
Example #27
0
        notice(get_string("activityiscurrentlyhidden"));
    }
    if ($timenow < $workshop->submissionstart) {
        $action = 'notavailable';
    } else {
        if (!$action) {
            if ($timenow < $workshop->assessmentend) {
                $action = 'studentsview';
            } else {
                $action = 'displayfinalgrade';
            }
        }
    }
}
// ...display header...
$navigation = build_navigation($action, $cm);
print_header_simple(format_string($workshop->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strworkshop), navmenu($course, $cm));
// ...log activity...
add_to_log($course->id, "workshop", "view", "view.php?id={$cm->id}", $workshop->id, $cm->id);
if ($action == 'studentsview' and !workshop_is_student($workshop)) {
    $action = 'showdescription';
}
/****************** display final grade (for students) ************************************/
if ($action == 'displayfinalgrade') {
    require_capability('mod/workshop:participate', $context);
    print_heading("<b><a href=\"view.php?id={$cm->id}&amp;action=showdescription\">" . get_string("showdescription", 'workshop') . "</a></b>");
    // show the final grades as stored in the tables...
    if ($submissions = workshop_get_user_submissions($workshop, $USER)) {
        // any submissions from user?
        print_heading(get_string("displayoffinalgrades", "workshop"));
        echo "<div class=\"boxaligncenter\"><table border=\"1\" width=\"90%\"><tr>";
Example #28
0
if ($context->contextlevel == CONTEXT_USER) {
    /// course header
    $navlinks = array();
    if ($courseid != SITEID) {
        if (has_capability('moodle/course:viewparticipants', get_context_instance(CONTEXT_COURSE, $course->id))) {
            $navlinks[] = array('name' => $strparticipants, 'link' => "{$CFG->wwwroot}/user/index.php?id={$course->id}", 'type' => 'misc');
        }
        $navlinks[] = array('name' => $fullname, 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}&amp;course={$courseid}", 'type' => 'misc');
        $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
        $navigation = build_navigation($navlinks);
        print_header("{$fullname}", "{$fullname}", $navigation, "", "", true, "&nbsp;", navmenu($course));
        /// site header
    } else {
        $navlinks[] = array('name' => $fullname, 'link' => "{$CFG->wwwroot}/user/view.php?id={$userid}&amp;course={$courseid}", 'type' => 'misc');
        $navlinks[] = array('name' => $straction, 'link' => null, 'type' => 'misc');
        $navigation = build_navigation($navlinks);
        print_header("{$course->fullname}: {$fullname}", $course->fullname, $navigation, "", "", true, "&nbsp;", navmenu($course));
    }
    $showroles = 1;
    $currenttab = 'assign';
    include_once $CFG->dirroot . '/user/tabs.php';
} else {
    if ($context->contextlevel == CONTEXT_SYSTEM) {
        admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
        admin_externalpage_print_header('');
    } else {
        if ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID) {
            admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid));
            admin_externalpage_print_header('');
            $currenttab = 'assign';
            include_once 'tabs.php';
Example #29
0
            $cm->id = 0;
            $cm->visible = 1;
            $cm->course = $course->id;
            $buttontext = "";
        }
    } else {
        error('Must specify a course module or a forum ID');
    }
}
if (!$buttontext) {
    $buttontext = forum_search_form($course, $search);
}
require_course_login($course, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Print header.
$navigation = build_navigation('', $cm);
print_header_simple(format_string($forum->name), "", $navigation, "", "", true, $buttontext, user_login_string($course) . '<hr style="width:95%">' . navmenu($course, $cm));
/// Some capability checks.
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
    notice(get_string("activityiscurrentlyhidden"));
}
if (!has_capability('mod/forum:viewdiscussion', $context)) {
    notice(get_string('noviewdiscussionspermission', 'forum'));
}
/// find out current groups mode
groups_print_activity_menu($cm, 'view.php?id=' . $cm->id);
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);
/// Okay, we can show the discussions. Log the forum view.
if ($cm->id) {
    add_to_log($course->id, "forum", "view forum", "view.php?id={$cm->id}", "{$forum->id}", $cm->id);
Example #30
0
 /**
  *  Display all the submissions ready for grading
  */
 function display_submissions($message = '')
 {
     global $CFG, $db, $USER;
     require_once $CFG->libdir . '/gradelib.php';
     /* first we check to see if the form has just been submitted
      * to request user_preference updates
      */
     if (isset($_POST['updatepref'])) {
         $perpage = optional_param('perpage', 10, PARAM_INT);
         $perpage = $perpage <= 0 ? 10 : $perpage;
         set_user_preference('assignment_perpage', $perpage);
         set_user_preference('assignment_quickgrade', optional_param('quickgrade', 0, PARAM_BOOL));
     }
     /* next we get perpage and quickgrade (allow quick grade) params
      * from database
      */
     $perpage = get_user_preferences('assignment_perpage', 10);
     $quickgrade = get_user_preferences('assignment_quickgrade', 0);
     $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id);
     if (!empty($CFG->enableoutcomes) and !empty($grading_info->outcomes)) {
         $uses_outcomes = true;
     } else {
         $uses_outcomes = false;
     }
     $teacherattempts = true;
     /// Temporary measure
     $page = optional_param('page', 0, PARAM_INT);
     $strsaveallfeedback = get_string('saveallfeedback', 'assignment');
     /// Some shortcuts to make the code read better
     $course = $this->course;
     $assignment = $this->assignment;
     $cm = $this->cm;
     $tabindex = 1;
     //tabindex for quick grading tabbing; Not working for dropdowns yet
     add_to_log($course->id, 'assignment', 'view submission', 'submissions.php?id=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
     $navlinks = array();
     $navlinks[] = array('name' => $this->strassignments, 'link' => "index.php?id={$course->id}", 'type' => 'activity');
     $navlinks[] = array('name' => format_string($this->assignment->name, true), 'link' => "view.php?a={$this->assignment->id}", 'type' => 'activityinstance');
     $navlinks[] = array('name' => $this->strsubmissions, 'link' => '', 'type' => 'title');
     $navigation = build_navigation($navlinks);
     print_header_simple(format_string($this->assignment->name, true), "", $navigation, '', '', true, update_module_button($cm->id, $course->id, $this->strassignment), navmenu($course, $cm));
     if (!empty($message)) {
         echo $message;
         // display messages here if any
     }
     $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     /// find out current groups mode
     $groupmode = groups_get_activity_groupmode($cm);
     $currentgroup = groups_get_activity_group($cm, true);
     groups_print_activity_menu($cm, 'submissions.php?id=' . $this->cm->id);
     /// Get all ppl that are allowed to submit assignments
     $users = get_users_by_capability($context, 'mod/assignment:submit', '', '', '', '', $currentgroup, '', false);
     $users = array_keys($users);
     if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) {
         $groupingusers = groups_get_grouping_members($cm->groupingid, 'u.id', 'u.id');
         $users = array_intersect($users, array_keys($groupingusers));
     }
     $tablecolumns = array('picture', 'fullname', 'grade', 'submissioncomment', 'timemodified', 'timemarked', 'status', 'finalgrade');
     if ($uses_outcomes) {
         $tablecolumns[] = 'outcome';
         // no sorting based on outcomes column
     }
     $tableheaders = array('', get_string('fullname'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified') . ' (' . $course->student . ')', get_string('lastmodified') . ' (' . $course->teacher . ')', get_string('status'), get_string('finalgrade', 'grades'));
     if ($uses_outcomes) {
         $tableheaders[] = get_string('outcome', 'grades');
     }
     require_once $CFG->libdir . '/tablelib.php';
     $table = new flexible_table('mod-assignment-submissions');
     $table->define_columns($tablecolumns);
     $table->define_headers($tableheaders);
     $table->define_baseurl($CFG->wwwroot . '/mod/assignment/submissions.php?id=' . $this->cm->id . '&amp;currentgroup=' . $currentgroup);
     $table->sortable(true, 'lastname');
     //sorted by lastname by default
     $table->collapsible(true);
     $table->initialbars(true);
     $table->column_suppress('picture');
     $table->column_suppress('fullname');
     $table->column_class('picture', 'picture');
     $table->column_class('fullname', 'fullname');
     $table->column_class('grade', 'grade');
     $table->column_class('submissioncomment', 'comment');
     $table->column_class('timemodified', 'timemodified');
     $table->column_class('timemarked', 'timemarked');
     $table->column_class('status', 'status');
     $table->column_class('finalgrade', 'finalgrade');
     if ($uses_outcomes) {
         $table->column_class('outcome', 'outcome');
     }
     $table->set_attribute('cellspacing', '0');
     $table->set_attribute('id', 'attempts');
     $table->set_attribute('class', 'submissions');
     $table->set_attribute('width', '90%');
     //$table->set_attribute('align', 'center');
     $table->no_sorting('finalgrade');
     $table->no_sorting('outcome');
     // Start working -- this is necessary as soon as the niceties are over
     $table->setup();
     /// Check to see if groups are being used in this assignment
     if (!$teacherattempts) {
         $teachers = get_course_teachers($course->id);
         if (!empty($teachers)) {
             $keys = array_keys($teachers);
         }
         foreach ($keys as $key) {
             unset($users[$key]);
         }
     }
     if (empty($users)) {
         print_heading(get_string('noattempts', 'assignment'));
         return true;
     }
     /// Construct the SQL
     if ($where = $table->get_sql_where()) {
         $where .= ' AND ';
     }
     if ($sort = $table->get_sql_sort()) {
         $sort = ' ORDER BY ' . $sort;
     }
     $select = 'SELECT u.id, u.firstname, u.lastname, u.picture,
                       s.id AS submissionid, s.grade, s.submissioncomment,
                       s.timemodified, s.timemarked,
                       COALESCE(SIGN(SIGN(s.timemarked) + SIGN(s.timemarked - s.timemodified)), 0) AS status ';
     $sql = 'FROM ' . $CFG->prefix . 'user u ' . 'LEFT JOIN ' . $CFG->prefix . 'assignment_submissions s ON u.id = s.userid
                                                               AND s.assignment = ' . $this->assignment->id . ' ' . 'WHERE ' . $where . 'u.id IN (' . implode(',', $users) . ') ';
     $table->pagesize($perpage, count($users));
     ///offset used to calculate index of student in that particular query, needed for the pop up to know who's next
     $offset = $page * $perpage;
     $strupdate = get_string('update');
     $strgrade = get_string('grade');
     $grademenu = make_grades_menu($this->assignment->grade);
     if (($ausers = get_records_sql($select . $sql . $sort, $table->get_page_start(), $table->get_page_size())) !== false) {
         $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, array_keys($ausers));
         foreach ($ausers as $auser) {
             $final_grade = $grading_info->items[0]->grades[$auser->id];
             /// Calculate user status
             $auser->status = $auser->timemarked > 0 && $auser->timemarked >= $auser->timemodified;
             $picture = print_user_picture($auser->id, $course->id, $auser->picture, false, true);
             if (empty($auser->submissionid)) {
                 $auser->grade = -1;
                 //no submission yet
             }
             if (!empty($auser->submissionid)) {
                 ///Prints student answer and student modified date
                 ///attach file or print link to student answer, depending on the type of the assignment.
                 ///Refer to print_student_answer in inherited classes.
                 if ($auser->timemodified > 0) {
                     $studentmodified = '<div id="ts' . $auser->id . '">' . $this->print_student_answer($auser->id) . userdate($auser->timemodified) . '</div>';
                 } else {
                     $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 }
                 ///Print grade, dropdown or text
                 if ($auser->timemarked > 0) {
                     $teachermodified = '<div id="tt' . $auser->id . '">' . userdate($auser->timemarked) . '</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 } else {
                     $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                     if ($final_grade->locked or $final_grade->overridden) {
                         $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                     } else {
                         if ($quickgrade) {
                             $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                             $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                         } else {
                             $grade = '<div id="g' . $auser->id . '">' . $this->display_grade($auser->grade) . '</div>';
                         }
                     }
                 }
                 ///Print Comment
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($final_grade->str_feedback), 15) . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">' . shorten_text(strip_tags($auser->submissioncomment), 15) . '</div>';
                     }
                 }
             } else {
                 $studentmodified = '<div id="ts' . $auser->id . '">&nbsp;</div>';
                 $teachermodified = '<div id="tt' . $auser->id . '">&nbsp;</div>';
                 $status = '<div id="st' . $auser->id . '">&nbsp;</div>';
                 if ($final_grade->locked or $final_grade->overridden) {
                     $grade = '<div id="g' . $auser->id . '">' . $final_grade->str_grade . '</div>';
                 } else {
                     if ($quickgrade) {
                         // allow editing
                         $menu = choose_from_menu(make_grades_menu($this->assignment->grade), 'menu[' . $auser->id . ']', $auser->grade, get_string('nograde'), '', -1, true, false, $tabindex++);
                         $grade = '<div id="g' . $auser->id . '">' . $menu . '</div>';
                     } else {
                         $grade = '<div id="g' . $auser->id . '">-</div>';
                     }
                 }
                 if ($final_grade->locked or $final_grade->overridden) {
                     $comment = '<div id="com' . $auser->id . '">' . $final_grade->str_feedback . '</div>';
                 } else {
                     if ($quickgrade) {
                         $comment = '<div id="com' . $auser->id . '">' . '<textarea tabindex="' . $tabindex++ . '" name="submissioncomment[' . $auser->id . ']" id="submissioncomment' . $auser->id . '" rows="2" cols="20">' . $auser->submissioncomment . '</textarea></div>';
                     } else {
                         $comment = '<div id="com' . $auser->id . '">&nbsp;</div>';
                     }
                 }
             }
             if (empty($auser->status)) {
                 /// Confirm we have exclusively 0 or 1
                 $auser->status = 0;
             } else {
                 $auser->status = 1;
             }
             $buttontext = $auser->status == 1 ? $strupdate : $strgrade;
             ///No more buttons, we use popups ;-).
             $popup_url = '/mod/assignment/submissions.php?id=' . $this->cm->id . '&amp;userid=' . $auser->id . '&amp;mode=single' . '&amp;offset=' . $offset++;
             $button = link_to_popup_window($popup_url, 'grade' . $auser->id, $buttontext, 600, 780, $buttontext, 'none', true, 'button' . $auser->id);
             $status = '<div id="up' . $auser->id . '" class="s' . $auser->status . '">' . $button . '</div>';
             $finalgrade = '<span id="finalgrade_' . $auser->id . '">' . $final_grade->str_grade . '</span>';
             $outcomes = '';
             if ($uses_outcomes) {
                 foreach ($grading_info->outcomes as $n => $outcome) {
                     $outcomes .= '<div class="outcome"><label>' . $outcome->name . '</label>';
                     $options = make_grades_menu(-$outcome->scaleid);
                     if ($outcome->grades[$auser->id]->locked or !$quickgrade) {
                         $options[0] = get_string('nooutcome', 'grades');
                         $outcomes .= ': <span id="outcome_' . $n . '_' . $auser->id . '">' . $options[$outcome->grades[$auser->id]->grade] . '</span>';
                     } else {
                         $outcomes .= ' ';
                         $outcomes .= choose_from_menu($options, 'outcome_' . $n . '[' . $auser->id . ']', $outcome->grades[$auser->id]->grade, get_string('nooutcome', 'grades'), '', 0, true, false, 0, 'outcome_' . $n . '_' . $auser->id);
                     }
                     $outcomes .= '</div>';
                 }
             }
             $row = array($picture, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status, $finalgrade);
             if ($uses_outcomes) {
                 $row[] = $outcomes;
             }
             $table->add_data($row);
         }
     }
     /// Print quickgrade form around the table
     if ($quickgrade) {
         echo '<form action="submissions.php" id="fastg" method="post">';
         echo '<div>';
         echo '<input type="hidden" name="id" value="' . $this->cm->id . '" />';
         echo '<input type="hidden" name="mode" value="fastgrade" />';
         echo '<input type="hidden" name="page" value="' . $page . '" />';
         echo '</div>';
         //echo '<div style="text-align:center"><input type="submit" name="fastg" value="'.get_string('saveallfeedback', 'assignment').'" /></div>';
     }
     $table->print_html();
     /// Print the whole table
     if ($quickgrade) {
         echo '<div style="text-align:center"><input type="submit" name="fastg" value="' . get_string('saveallfeedback', 'assignment') . '" /></div>';
         echo '</form>';
     }
     /// End of fast grading form
     /// Mini form for setting user preference
     echo '<br />';
     echo '<form id="options" action="submissions.php?id=' . $this->cm->id . '" method="post">';
     echo '<div>';
     echo '<input type="hidden" id="updatepref" name="updatepref" value="1" />';
     echo '<table id="optiontable" align="right">';
     echo '<tr align="right"><td>';
     echo '<label for="perpage">' . get_string('pagesize', 'assignment') . '</label>';
     echo ':</td>';
     echo '<td>';
     echo '<input type="text" id="perpage" name="perpage" size="1" value="' . $perpage . '" />';
     helpbutton('pagesize', get_string('pagesize', 'assignment'), 'assignment');
     echo '</td></tr>';
     echo '<tr align="right">';
     echo '<td>';
     print_string('quickgrade', 'assignment');
     echo ':</td>';
     echo '<td>';
     if ($quickgrade) {
         echo '<input type="checkbox" name="quickgrade" value="1" checked="checked" />';
     } else {
         echo '<input type="checkbox" name="quickgrade" value="1" />';
     }
     helpbutton('quickgrade', get_string('quickgrade', 'assignment'), 'assignment') . '</p></div>';
     echo '</td></tr>';
     echo '<tr>';
     echo '<td colspan="2" align="right">';
     echo '<input type="submit" value="' . get_string('savepreferences') . '" />';
     echo '</td></tr></table>';
     echo '</div>';
     echo '</form>';
     ///End of mini form
     print_footer($this->course);
 }