예제 #1
0
 /**
  * Print HTML to display the "Also show old questions" checkbox
  */
 public function display_options_adv()
 {
     echo \html_writer::start_div();
     echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'showhidden', 'value' => '0', 'id' => 'showhidden_off'));
     echo \html_writer::checkbox('showhidden', '1', !$this->hide, get_string('showhidden', 'question'), array('id' => 'showhidden_on', 'class' => 'searchoptions'));
     echo \html_writer::end_div() . "\n";
 }
예제 #2
0
    /**
     * Render the edit page
     *
     * @param \quiz $quizobj object containing all the quiz settings information.
     * @param structure $structure object containing the structure of the quiz.
     * @param \question_edit_contexts $contexts the relevant question bank contexts.
     * @param \moodle_url $pageurl the canonical URL of this page.
     * @param array $pagevars the variables from {@link question_edit_setup()}.
     * @return string HTML to output.
     */
    public function edit_page(\quiz $quizobj, structure $structure,
            \question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars) {
        $output = '';

        // Page title.
        $output .= $this->heading_with_help(get_string('editingquizx', 'quiz',
                format_string($quizobj->get_quiz_name())), 'editingquiz', 'quiz', '',
                get_string('basicideasofquiz', 'quiz'), 2);

        // Information at the top.
        $output .= $this->quiz_state_warnings($structure);
        $output .= $this->quiz_information($structure);
        $output .= $this->maximum_grade_input($structure, $pageurl);
        $output .= $this->repaginate_button($structure, $pageurl);
        $output .= $this->total_marks($quizobj->get_quiz());

        // Show the questions organised into sections and pages.
        $output .= $this->start_section_list($structure);

        foreach ($structure->get_sections() as $section) {
            $output .= $this->start_section($structure, $section);
            $output .= $this->questions_in_section($structure, $section, $contexts, $pagevars, $pageurl);

            if ($structure->is_last_section($section)) {
                $output .= \html_writer::start_div('last-add-menu');
                $output .= html_writer::tag('span', $this->add_menu_actions($structure, 0,
                        $pageurl, $contexts, $pagevars), array('class' => 'add-menu-outer'));
                $output .= \html_writer::end_div();
            }

            $output .= $this->end_section();
        }

        $output .= $this->end_section_list();

        // Initialise the JavaScript.
        $this->initialise_editing_javascript($structure, $contexts, $pagevars, $pageurl);

        // Include the contents of any other popups required.
        if ($structure->can_be_edited()) {
            $popups = '';

            $popups .= $this->question_bank_loading();
            $this->page->requires->yui_module('moodle-mod_quiz-quizquestionbank',
                    'M.mod_quiz.quizquestionbank.init',
                    array('class' => 'questionbank', 'cmid' => $structure->get_cmid()));

            $popups .= $this->random_question_form($pageurl, $contexts, $pagevars);
            $this->page->requires->yui_module('moodle-mod_quiz-randomquestion',
                    'M.mod_quiz.randomquestion.init');

            $output .= html_writer::div($popups, 'mod_quiz_edit_forms');

            // Include the question chooser.
            $output .= $this->question_chooser();
            $this->page->requires->yui_module('moodle-mod_quiz-questionchooser', 'M.mod_quiz.init_questionchooser');
        }

        return $output;
    }
예제 #3
0
 protected function detail_pair($key, $value, $class = '')
 {
     $html = html_writer::start_div('detail-pair row ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class));
     $html .= html_writer::div(html_writer::span($key), 'pair-key col-sm-3');
     $html .= html_writer::div(html_writer::span($value), 'pair-value col-sm-9');
     $html .= html_writer::end_div();
     return $html;
 }
 /**
  * Renderers a key value pair of information for display.
  *
  * @param string $key
  * @param string $value
  * @param string $class
  * @return string
  */
 protected function detail_pair($key, $value, $class = '')
 {
     $html = html_writer::start_div('detail-pair row yui3-g ' . preg_replace('#[^a-zA-Z0-9_\\-]#', '-', $class));
     $html .= html_writer::div(html_writer::span($key), 'pair-key span4 yui3-u-1-4');
     $html .= html_writer::div(html_writer::span($value), 'pair-value span8 yui3-u-3-4');
     $html .= html_writer::end_div();
     return $html;
 }
예제 #5
0
 /**
  * The backup and restore pages may display a log (if any) in a scrolling box.
  *
  * @param string $loghtml Log content in HTML format
  * @return string HTML content that shows the log
  */
 public function log_display($loghtml)
 {
     global $OUTPUT;
     $out = html_writer::start_div('backup_log');
     $out .= $OUTPUT->heading(get_string('backuplog', 'backup'));
     $out .= html_writer::start_div('backup_log_contents');
     $out .= $loghtml;
     $out .= html_writer::end_div();
     $out .= html_writer::end_div();
     return $out;
 }
예제 #6
0
 public function render_library_content($config, $id)
 {
     $this->page->requires->js('/blocks/library/module.js');
     $html = html_writer::start_div('library-block');
     // Build the Header.
     $headerimage = html_writer::empty_tag('img', array('src' => '/blocks/library/pix/library-banner.jpg'));
     $header = html_writer::link(get_string('universityhomelink', 'block_library'), $headerimage, array('target' => '_blank'));
     $header .= html_writer::link(get_string('libraryloginlink', 'block_library'), get_string('librarylogin', 'block_library'), array('class' => 'my-account', 'target' => '_blank'));
     // Library search.
     if (empty($config) || $config->enablesearch == 1) {
         $search = '';
         $search .= html_writer::start_tag('form', array('onsubmit' => 'return M.block_library.ebscoHostSearchGo(this);', 'id' => 'ebscohostCustomSearchBox', 'class' => 'searcher', 'name' => 'ebscoSearch', 'method' => 'post'));
         $search .= html_writer::tag('input', '', array('id' => 'ebscohostwindow', 'name' => 'ebscohostwindow', 'type' => 'hidden', 'value' => '0'));
         $search .= html_writer::tag('input', '', array('id' => 'ebscohosturl', 'name' => 'ebscohosturl', 'type' => 'hidden', 'value' => get_string('ebscohosturl', 'block_library')));
         $search .= html_writer::tag('input', '', array('id' => 'ebscohostsearchsrc', 'name' => 'ebscohostsearchsrc', 'type' => 'hidden', 'value' => 'db'));
         $search .= html_writer::tag('input', '', array('id' => 'ebscohostsearchmode', 'name' => 'ebscohostsearchmode', 'type' => 'hidden', 'value' => '+'));
         $search .= html_writer::tag('input', '', array('id' => 'ebscohostkeywords', 'name' => 'ebscohostkeywords', 'type' => 'hidden'));
         $search .= html_writer::tag('input', '', array('id' => 'oversizeNiceInput', 'name' => 'ebscohostsearchtext', 'type' => 'text', 'class' => 'oversize input-text front', 'title' => get_string('searchtip', 'block_library'), 'placeholder' => get_string('findbooks', 'block_library')));
         $search .= html_writer::tag('button', get_string('searchbuttontext', 'block_library'), array('type' => 'submit', 'value' => 'Search', 'class' => 'lib_button mleft', 'onclick' => '_gaq.push([\'_trackEvent\', \'eds\', \'clicked\'])'));
         $search .= html_writer::end_tag('form');
     }
     $html .= $header;
     $html .= $search;
     //  Library Links.
     if (empty($config) || $config->enablelibrarylinks == 1) {
         $llinks = '';
         $llinks .= html_writer::tag('div', get_string('library_links', 'block_library'), array('class' => 'library-links'));
         $html .= $llinks;
     }
     // Course links.
     if (!empty($config->enablecourselinks) && $config->enablecourselinks == 1 && !empty($config->rawhtml['text'])) {
         $clinks = '';
         $clinks .= html_writer::start_tag('div');
         $clinks .= html_writer::tag('p', get_string('librarycourse', 'block_library'), array('class' => 'library-coursetitle'));
         $clinks .= $config->rawhtml['text'];
         $clinks .= html_writer::end_tag('div');
         $html .= $clinks;
     }
     // Build the footer content.
     $listitems = array();
     $askcontent = '';
     if (empty($config) || $config->enableaskbubble == 1) {
         $listitems[] = html_writer::link(get_string('asklibrarystafflink', 'block_library'), get_string('asklibrarystaff', 'block_library'), array('class' => 'ask-main', 'target' => '_blank'));
         $listitems[] = html_writer::link(get_string('asklibrarystafflink', 'block_library'), get_string('textstaff', 'block_library'), array('target' => '_blank'));
         $listitems[] = html_writer::link(get_string('chatwithstafflink', 'block_library'), get_string('chatwithstaff', 'block_library'), array('target' => '_blank'));
         $listitems[] = html_writer::link(get_string('emailstafflink', 'block_library'), get_string('emailstaff', 'block_library'), array('target' => '_blank'));
         $listitems[] = html_writer::link(get_string('asklibrarystafflink', 'block_library'), get_string('phonestaff', 'block_library'), array('class' => 'last', 'target' => '_blank'));
         $askcontent = html_writer::alist($listitems, array('class' => 'ask'));
     }
     $footer = html_writer::tag('div', $askcontent, array('class' => 'library-bottom'));
     $html .= $footer;
     $html .= html_writer::end_div();
     return $html;
 }
예제 #7
0
 public function full_header()
 {
     $html = html_writer::start_tag('header', array('id' => 'page-header', 'class' => 'clearfix'));
     $html .= html_writer::start_div('clearfix', array('id' => 'page-navbar'));
     $html .= html_writer::tag('nav', $this->navbar(), array('class' => 'breadcrumb-nav'));
     $html .= html_writer::div($this->page_heading_button(), 'breadcrumb-button');
     $html .= html_writer::end_div();
     $html .= html_writer::tag('div', $this->course_header(), array('id' => 'course-header'));
     $html .= html_writer::end_tag('header');
     return $html;
 }
 public function search_form(moodle_url $formtarget, $searchvalue)
 {
     $content = html_writer::start_tag('form', array('class' => 'adminsearchform', 'method' => 'get', 'action' => $formtarget, 'role' => 'search'));
     $content .= html_writer::start_div('input-group');
     $content .= html_writer::empty_tag('input', array('id' => 'adminsearchquery', 'type' => 'text', 'name' => 'query', 'class' => 'form-control', 'placeholder' => s(get_string('searchinsettings', 'admin')), 'value' => s($searchvalue)));
     $content .= html_writer::start_span('input-group-btn');
     $content .= html_writer::tag('button', s(get_string('go')), array('type' => 'button', 'class' => 'btn btn-default'));
     $content .= html_writer::end_span();
     $content .= html_writer::end_div();
     $content .= html_writer::end_tag('form');
     return $content;
 }
 public function eclass_header($columns)
 {
     global $CFG, $SITE;
     $output = html_writer::start_tag('header', array("role" => "banner", "class" => "navbar navbar-fixed-top moodle-has-zindex"));
     $output .= html_writer::start_tag('nav', array("role" => "navigation", "class" => "navbar-inner"));
     $output .= html_writer::start_div("container-fluid");
     $output .= html_writer::tag('img', '', array("src" => $this->pix_url('ua-logo', 'theme'), "class" => "uofa-logo", "height" => "40px"));
     $output .= html_writer::link($CFG->wwwroot, $SITE->shortname, array("class" => "brand"));
     $output .= html_writer::end_div();
     $output .= html_writer::end_tag('nav');
     $output .= html_writer::end_tag('header');
     return $output;
 }
 /**
  * Render the edit page
  *
  * @param \offlinequiz $offlinequizobj object containing all the offlinequiz settings information.
  * @param structure $structure object containing the structure of the offlinequiz.
  * @param \question_edit_contexts $contexts the relevant question bank contexts.
  * @param \moodle_url $pageurl the canonical URL of this page.
  * @param array $pagevars the variables from {@link question_edit_setup()}.
  * @return string HTML to output.
  */
 public function edit_page(\offlinequiz $offlinequizobj, structure $structure, \question_edit_contexts $contexts, \moodle_url $pageurl, array $pagevars, array $groupletters)
 {
     $offlinequiz = $offlinequizobj->get_offlinequiz();
     $output = '';
     // Page title.
     $output .= $this->heading_with_help(get_string('editingofflinequizx', 'offlinequiz', format_string($offlinequizobj->get_offlinequiz_name())) . ' (' . get_string('group', 'offlinequiz') . ' ' . $groupletters[$offlinequiz->groupnumber] . ') ', 'editingofflinequiz', 'offlinequiz', '', get_string('basicideasofofflinequiz', 'offlinequiz'), 2);
     // Information at the top.
     $output .= $this->offlinequiz_group_selector($offlinequiz, $pageurl);
     $output .= $this->offlinequiz_information($structure);
     $output .= $this->maximum_grade_input($offlinequiz, $this->page->url);
     $output .= $this->offlinequiz_state_warnings($structure);
     $output .= $this->repaginate_button($structure, $pageurl, $offlinequiz);
     $output .= $this->total_marks($offlinequiz);
     // Start form for question checkboxes
     $output .= $this->start_add_to_group_form($offlinequiz, $pageurl);
     // Add buttons for adding selected to another group and for removing selected.
     $output .= $this->add_to_group_button($structure, $offlinequiz, $pageurl);
     $output .= $this->remove_selected_button($structure, $offlinequiz, $pageurl);
     $output .= $this->select_all_links($structure);
     // Show the questions organised into sections and pages.
     $output .= $this->start_section_list();
     $sections = $structure->get_offlinequiz_sections();
     $lastsection = end($sections);
     foreach ($sections as $section) {
         $output .= $this->start_section($section);
         $output .= $this->questions_in_section($structure, $section, $contexts, $pagevars, $pageurl);
         if ($section === $lastsection) {
             $output .= \html_writer::start_div('last-add-menu');
             $output .= html_writer::tag('span', $this->add_menu_actions($structure, 0, $pageurl, $contexts, $pagevars), array('class' => 'add-menu-outer'));
             $output .= \html_writer::end_div();
         }
         $output .= $this->end_section();
     }
     $output .= $this->end_section_list();
     $output .= $this->end_add_to_group_form();
     // Inialise the JavaScript.
     $this->initialise_editing_javascript($offlinequizobj->get_course(), $offlinequizobj->get_offlinequiz(), $structure, $contexts, $pagevars, $pageurl);
     // Include the contents of any other popups required.
     if ($structure->can_be_edited()) {
         $popups = '';
         $popups .= $this->question_bank_loading();
         $this->page->requires->yui_module('moodle-mod_offlinequiz-offlinequizquestionbank', 'M.mod_offlinequiz.offlinequizquestionbank.init', array('class' => 'questionbank', 'cmid' => $structure->get_cmid()));
         $popups .= $this->random_question_form($pageurl, $contexts, $pagevars);
         $this->page->requires->yui_module('moodle-mod_offlinequiz-randomquestion', 'M.mod_offlinequiz.randomquestion.init');
         $output .= html_writer::div($popups, 'mod_offlinequiz_edit_forms');
         // Include the question chooser.
         $output .= $this->question_chooser();
         $this->page->requires->yui_module('moodle-mod_offlinequiz-questionchooser', 'M.mod_offlinequiz.init_questionchooser');
     }
     return $output;
 }
 public function eclass_header($columns)
 {
     global $CFG, $SITE;
     $output = html_writer::start_tag('header', array("role" => "banner", "class" => "navbar navbar-fixed-top moodle-has-zindex"));
     $output .= html_writer::start_tag('nav', array("role" => "navigation", "class" => "navbar-inner"));
     $output .= html_writer::start_div("container-fluid");
     $output .= html_writer::tag('img', '', array("src" => $this->pix_url('ua-logo', 'theme'), "class" => "uofa-logo", "height" => "40px"));
     $output .= html_writer::div(html_writer::link($CFG->wwwroot, $SITE->shortname, array("class" => "brand")), 'nav-brand');
     $output .= html_writer::start_div("pull-right");
     $output .= $this->custom_menu();
     $headingmenu = $this->page_heading_menu();
     $output .= html_writer::alist(array($headingmenu), array("class" => "nav pull-right"));
     $output .= html_writer::div(html_writer::span('', "glyphicons collapse_top"), "scroll-top pull-right", array("title" => "Scroll to top"));
     $output .= $this->login_info();
     $output .= html_writer::end_div();
     $output .= html_writer::end_div();
     $output .= html_writer::end_tag('nav');
     // Mobile stuff.
     $toggleleft = '<li><label class="toggle toggle-navigation"   for="toggle-left" onclick>' . '<div class="mobile-nav-icon glyphicons list"></div><span>Navigation</span></label></li>';
     $togglecenter = '<li><label class="toggle toggle-content" for="toggle-center" onclick>' . '<div class="mobile-nav-icon glyphicons book"></div><span>Content</span></label></li>';
     $toggleright = '';
     if ($this->page->blocks->region_has_content('side-post', $this)) {
         $toggleright = '<li><label class="toggle toggle-blocks"  for="toggle-right" onclick>' . '<div class="mobile-nav-icon glyphicons show_big_thumbnails"></div><span>Blocks</span></label></li>';
     }
     $toggleprofile = '<li><label class="toggle toggle-profile"  for="toggle-profile" onclick>' . '<div class="mobile-nav-icon glyphicons user"></div><span>Profile</span></label></li>';
     switch ($columns) {
         default:
         case 1:
             $togglelist = $togglecenter . $toggleprofile;
             break;
         case 2:
             $togglelist = $toggleleft . $togglecenter . $toggleprofile;
             break;
         case 3:
             $togglelist = $toggleleft . $togglecenter . $toggleright . $toggleprofile;
             break;
     }
     $togglelist .= html_writer::div('', 'active-indicator');
     $output .= html_writer::start_tag('nav', array("class" => "mobile-nav"));
     $output .= html_writer::tag('ul', $togglelist, array("class" => "view-selector"));
     $output .= html_writer::end_tag('nav');
     $output .= html_writer::end_tag('header');
     return $output;
 }
예제 #12
0
 /**
  * Returns XHTML select field and wrapping div(s)
  *
  * @see output_select_html()
  *
  * @param string $data the option to show as selected
  * @param string $query
  * @return string XHTML field and wrapping div
  */
 public function output_html($data, $query = '')
 {
     $html = '';
     $baseid = $this->get_id();
     $inputname = $this->get_full_name();
     foreach ($this->flowtypes as $flowtype) {
         $html .= \html_writer::start_div();
         $flowtypeid = $baseid . '_' . $flowtype;
         $radioattrs = ['type' => 'radio', 'name' => $inputname, 'id' => $flowtypeid, 'value' => $flowtype];
         if ($data === $flowtype || empty($data) && $flowtype === $this->get_defaultsetting()) {
             $radioattrs['checked'] = 'checked';
         }
         $typename = get_string('cfg_loginflow_' . $flowtype, 'auth_oidc');
         $typedesc = get_string('cfg_loginflow_' . $flowtype . '_desc', 'auth_oidc');
         $html .= \html_writer::empty_tag('input', $radioattrs);
         $html .= \html_writer::label($typename, $flowtypeid, false);
         $html .= '<br />';
         $html .= \html_writer::span($typedesc);
         $html .= '<br /><br />';
         $html .= \html_writer::end_div();
     }
     return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', null, $query);
 }
예제 #13
0
파일: lib.php 프로젝트: elie89/moodle
 /**
  * Create the html code of the grade publishing feature.
  *
  * @return string $output html code of the grade publishing.
  */
 public function get_grade_publishing_url()
 {
     $url = $this->get_export_url();
     $output = html_writer::start_div();
     $output .= html_writer::tag('p', get_string('gradepublishinglink', 'grades', html_writer::link($url, $url)));
     $output .= html_writer::end_div();
     return $output;
 }
예제 #14
0
function displaydir($wdir, $files)
{
    //  $wdir == / or /a or /a/b/c/d  etc
    @ini_set('memory_limit', '1024M');
    global $courseid, $DB, $OUTPUT;
    global $USER, $CFG, $COURSE;
    global $choose;
    global $deptstr, $userstr;
    require_once $CFG->dirroot . '/blocks/morsle/constants.php';
    $course = $COURSE;
    $user = $USER;
    // Get the sort parameter if there is one
    $sort = optional_param('sort', 1, PARAM_INT);
    $dirlist = array();
    $filelist = array();
    $dirhref = array();
    $filehref = array();
    $courseid = $course->id;
    $coursecontext = context_course::instance($COURSE->id);
    // separate all the files list into directories and files
    foreach ($files as $name => $file) {
        if (is_folder($file)) {
            $dirlist[$name] = $file;
        } else {
            $filelist[$name] = $file;
        }
    }
    // setup variables and strings
    $strname = get_string("name", 'block_morsle');
    $strsize = get_string("size");
    $strmodified = get_string("modified");
    $straction = get_string("action");
    $strmakeafolder = get_string("morslemakecollection", 'block_morsle');
    $struploadafile = get_string("uploadafile");
    $strselectall = get_string("selectall");
    $strselectnone = get_string("deselectall");
    $strwithchosenfiles = get_string("withchosenfiles");
    $strmovetoanotherfolder = get_string("movetoanotherfolder");
    $strlinktocourse = get_string("linktocourse", 'block_morsle');
    $strmovefilestohere = get_string("movefilestohere");
    $strdeletefromcollection = get_string("deletefromcollection", 'block_morsle');
    $strcreateziparchive = get_string("createziparchive");
    $strrename = get_string("rename");
    $stredit = get_string("edit");
    $strunzip = get_string("unzip");
    $strlist = get_string("list");
    $strrestore = get_string("restore");
    $strchoose = get_string("choose");
    $strfolder = get_string("folder");
    $strfile = get_string("file");
    $strdownload = get_string("strdownload", 'block_morsle');
    $struploadthisfile = get_string("uploadthisfile");
    $struploadandlinkthisfile = get_string("uploadandlinkthisfile", 'block_morsle');
    $filesize = 'Varies as to type of document';
    $strmaxsize = get_string("maxsize", "", $filesize);
    $strcancel = get_string("cancel");
    $strmodified = get_string("strmodified", 'block_morsle');
    //CLAMP #289 set color and background-color to transparent
    //Kevin Wiliarty 2011-03-08
    $padrename = get_string("rename");
    $padedit = $padunzip = $padlist = $padrestore = $padchoose = $padfolder = $padfile = $padlink = '';
    $attsArr = array($padedit => $stredit, $padunzip => $strunzip, $padlist => $strlist, $padrestore => $strrestore, $padchoose => $strchoose, $padfolder => $strfolder, $padfile => $strfile, $padlink => $strlinktocourse);
    foreach ($attsArr as $key => $value) {
        $key = html_writer::div($value . '&nbsp', '', array('style' => 'color:transparent; background-color:transparent; display:inline;'));
    }
    /*
       $padedit = html_writer::div($stredit . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline'));
       $padunzip = html_writer::div($strunzip . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline'));
       $padlist = html_writer::div($strlist . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline'));
       $padrestore = html_writer::div($strrestore . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline'));
       $padchoose = html_writer::div($strchoose . '&nbsp','', array('style'=>'color: transparent; background-color:transparent; display:inline'));
       $padfolder = html_writer::div($strfolder . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline;'));
       $padfile = html_writer::div($strfile . '&nbsp','', array('style'=>'color:transparent; background-color; transparent; display:inline;'));
       $padlink = html_writer::div($strlinktocourse . '&nbsp','', array('style'=>'color:transparent; background-color:transparent; display:inline;'));
    */
    $gdocsstr = 'Google-Docs-Storage-for-';
    // Set sort arguments so that clicking on a column that is already sorted reverses the sort order
    $sortvalues = array(1, 2, 3);
    foreach ($sortvalues as &$sortvalue) {
        if ($sortvalue == $sort) {
            $sortvalue = -$sortvalue;
        }
    }
    $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
    // beginning of with selected files portion
    echo html_writer::start_tag('table', array('border' => '0', 'cellspacing' => '2', 'cellpadding' => '2', 'style' => 'min-width: 900px; margin-left:auto; margin-right:auto', 'class' => 'files'));
    if ($wdir !== '') {
        echo html_writer::start_tag('tr');
        //html_writer::table($table);
        if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) {
            echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'center'));
            // move files to other folder form
            echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get'));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'paste'));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey));
            echo html_writer::tag('input', '', array('align' => 'center', 'type' => 'submit', 'value' => $strmovefilestohere));
            //echo "<span> --> <b>$wdir</b></span><br />";
            echo html_writer::start_span() . '-->' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::end_tag('br');
            echo html_writer::end_tag('td');
            echo html_writer::start_tag('td');
            echo html_writer::end_tag('form');
            // cancel moving form
            echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left'));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
            echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel'));
            echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'style' => 'color:red; margin-left:10px'));
            echo html_writer::end_tag('form');
            echo html_writer::end_tag('td');
        } else {
            if (has_capability('moodle/course:update', $coursecontext) || strpos($wdir, '-write')) {
                echo html_writer::start_tag('tr', array('style' => 'background-color: #ffddbb;'));
                echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'left', 'style' => 'background-color:#ffddbb; padding-left:5px;'));
                // file upload form
                // TODO: what if we're in the user or departmental dir?
                echo html_writer::start_tag('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => 'morslefiles.php'));
                echo html_writer::start_span() . '&nbsp' . $struploadafile . '&nbsp(' . $strmaxsize . ')&nbsp' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::tag('br', '');
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'upload'));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey));
                if (!isset($coursebytes)) {
                    $coursebytes = 0;
                }
                if (!isset($modbytes)) {
                    $modbytes = 0;
                }
                $maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursebytes, $modbytes);
                $str = html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => $maxbytes)) . "\n";
                $name = 'userfile';
                $str .= html_writer::tag('input', '', array('type' => 'file', 'size' => '50', 'name' => $name, 'alt' => $name, 'style' => 'margin-left: 5px;')) . html_writer::end_tag('br') . "\n";
                echo $str;
                echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'save', 'value' => $struploadthisfile, 'style' => 'color:green; padding-left:5px;'));
                echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'savelink', 'value' => $struploadandlinkthisfile, 'style' => 'color:blue; padding-left:5px;'));
                echo html_writer::end_tag('form');
                echo html_writer::end_tag('td');
                echo html_writer::end_tag('tr');
                // cancel button div only if not in root morsle directory
                echo html_writer::start_tag('tr');
                echo html_writer::tag('td', '', array('colspan' => '2', 'style' => 'background-color:#ffddbb;'));
                echo html_writer::start_tag('td', array('style' => 'background-color:#ffddbb; padding-left:5px;', 'colspan' => '1', 'align' => 'right'));
                echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left'));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
                echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel'));
                echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'align' => 'left', 'style' => 'color:red;'));
                echo html_writer::end_tag('form');
                echo html_writer::end_tag('td');
                echo html_writer::end_tag('tr');
                echo html_writer::end_tag('tr');
                echo html_writer::start_tag('tr');
                echo html_writer::start_tag('tr') . html_writer::tag('td', '<br>', array('colspace' => '4')) . html_writer::end_tag('tr');
                echo html_writer::start_tag('td', array('style' => 'max-width:50px; white-space:nowrap;', 'colspan' => '2', 'align' => 'left'));
                //dummy form - alignment only
                echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get'));
                echo html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset'));
                echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectall, 'onclick' => 'checkall();', 'style' => 'color:green;'));
                echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectnone, 'onclick' => 'checknone();', 'style' => 'color:red;'));
                echo html_writer::end_tag('fieldset');
                echo html_writer::end_tag('form');
                echo html_writer::end_tag('td');
                echo html_writer::start_tag('td', array('align' => 'center', 'colspan' => '2'));
                // makedir form
                // TODO: program to allow this in user and departmental directory
                if (strpos($wdir, $deptstr) === false && strpos($wdir, $userstr) === false) {
                    // not a user or departmental folder
                    echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get'));
                    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
                    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
                    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
                    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'makedir'));
                    echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strmakeafolder));
                    echo html_writer::end_tag('form');
                }
                echo html_writer::end_tag('td');
                echo html_writer::end_tag('tr');
            }
        }
    }
    echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'post', 'id' => 'dirform'));
    echo html_writer::start_div();
    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
    echo html_writer::start_tag('tr');
    echo html_writer::start_tag('th', array('class' => 'header', 'scope' => 'col', 'style' => 'max-width:40px;'));
    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid));
    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose));
    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir));
    echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey));
    //      $options = array ("delete" => "$strdeletefromcollection");
    // only editing teachers can link items to course page
    if (has_capability('moodle/course:update', $coursecontext)) {
        $options['link'] = "{$strlinktocourse}";
    }
    if (!empty($filelist) || !empty($dirlist)) {
        //        echo html_writer::tag('label', "$strwithchosenfiles...", array('for'=>'formactionid'));
        //    	  echo html_writer::select($options, "$strwithchosenfiles...", '', array(1 => "$strwithchosenfiles..."));
        echo html_writer::start_div('', array('id' => 'noscriptgo', 'style' => 'display:inline;'));
        echo html_writer::tag('input', '', array('type' => 'submit', 'value' => get_string('go')));
        echo html_writer::script('document.getElementById("noscriptgo").style.display="none"');
        echo html_writer::end_div();
    }
    echo html_writer::end_tag('th');
    echo html_writer::start_tag('th', array('style' => 'padding-right:120px;', 'class' => 'header name', 'scope' => 'col')) . html_writer::link(qualified_me(), $strname, array('&sort' => '{' . $sortvalues[0] . '}')) . html_writer::end_tag('th');
    echo html_writer::start_tag('th', array('class' => 'header date', 'scope' => 'col')) . html_writer::link(qualified_me(), $strmodified, array('&sort' => '{' . $sortvalues[2] . '}')) . html_writer::end_tag('th');
    echo html_writer::tag('th', $straction, array('class' => 'header commands', 'scope' => 'col'));
    echo html_writer::end_tag('tr') . "\n";
    // Sort parameter indicates column to sort by, and parity gives the direction
    switch ($sort) {
        case 1:
            $sortcmp = 'return strcasecmp($a[0],$b[0]);';
            break;
        case -1:
            $sortcmp = 'return strcasecmp($b[0],$a[0]);';
            break;
        case 2:
            $sortcmp = 'return ($a[1] - $b[1]);';
            break;
        case -2:
            $sortcmp = 'return ($b[1] - $a[1]);';
            break;
        case 3:
            $sortcmp = 'return ($a[2] - $b[2]);';
            break;
        case -3:
            $sortcmp = 'return ($b[2] - $a[2]);';
            break;
    }
    // Create a 2D array of directories and sort
    $dirdetails = array();
    foreach ($dirlist as $name => $dir) {
        $dirdetails[$name] = new stdClass();
        $dirdetails[$name]->updated = docdate($dir);
        $dirdetails[$name]->link = $dir->alternateLink;
        //        usort($dirdetails, create_function('$a,$b', $sortcmp));
    }
    // TODO: change to handle cross-listed courses
    // TODO: this needs to change if we eliminate morsle table
    if ($wdir === '') {
        $shortname = is_number(substr($course->shortname, 0, 5)) ? substr($course->shortname, 6) : $course->shortname;
        // SPLIT INTO DEPARTMENTAL CODES
        $dept = explode("-", $shortname);
        $deptpart = defined($dept[0]) ? CONSTANT($dept[0]) : null;
        $deptstr = $deptpart . $deptstr;
        $deptaccount = strtolower($deptstr);
        // only show the user collection if we're in the base folder
        $dirdetails[$userstr] = new stdClass();
        $dirdetails[$userstr]->updated = date('Y-m-d');
        $dirdetails[$userstr]->link = 'https://drive.google.com';
        // always include departmental directory if exists
        // check to see if we even have a departmental account for this department but don't show the departmental collection if we're already in it indicated by $wdir
        if ($is_morsle_dept = $DB->get_record('morsle_active', array('shortname' => $deptaccount)) && has_capability('moodle/course:update', $coursecontext)) {
            $dirdetails[$deptstr] = new stdClass();
            $dirdetails[$deptstr]->updated = date('Y-m-d');
        }
    }
    // Create a 2D array of files and sort
    $filedetails = array();
    $filetitles = array();
    foreach ($filelist as $name => $file) {
        $filedetails[$name] = new stdClass();
        $filedetails[$name]->updated = docdate($file);
        $filedetails[$name]->link = $file->alternateLink;
        //        $row = array($filename, $filedate);
        //		array_push($filedetails, $row);
        //		usort($filedetails, create_function('$a,$b', $sortcmp));
    }
    // TODO: fix this hack so we're back to being able to sort
    //    ksort($filedetails); // sets the locked in sorting to name
    // need this in order to look up the link for the file based on doc title (key)
    /*
        if (sizeof($filelist) > 0) {
                $filevalues = array_values($filelist);
                $filelist = array_combine($filetitles, $filevalues);
        }
    */
    //    $count = 0;
    //    $countdir = 0;
    $edittext = $padchoose . $padedit . $padunzip . $padlist . $padrestore;
    if ($wdir !== '') {
        $pathparts = explode('/', $wdir);
        array_pop($pathparts);
        $wdir = implode('/', $pathparts);
        echo "<tr class=\"folder\">";
        print_cell();
        print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&amp;wdir=' . $wdir . '&amp;choose=' . $choose . '&amp;name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" />&nbsp;' . get_string('parentfolder') . '</a>', 'name');
        //        print_cell('left', '<a  style="padding-left:0px" href="morslefiles.php?courseid='.$courseid.'&amp;wdir='.$wdir.'/&amp;choose='.$choose.'">&nbsp;'.get_string('parentfolder').'</a>', 'parent');
        echo "</tr>";
    }
    if (!empty($dirdetails)) {
        foreach ($dirdetails as $name => $dir) {
            echo html_writer::start_tag('tr', array('class' => 'folder'));
            $filedate = $dir->updated;
            $filesafe = rawurlencode($name);
            $filename = $name;
            $fileurl = $dir->link;
            //           	$countdir++;
            // TODO: fix the parent directory
            if ($name == '..') {
                //                $fileurl = rawurlencode(dirname($wdir));
                print_cell();
                // alt attribute intentionally empty to prevent repetition in screen reader
                //CLAMP #289 change padding-left from 10 to 0px
                //Kevin Wiliarty 2011-03-08
                print_cell('left', '<a  style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&amp;wdir=' . $wdir . '/' . $fileurl . '&amp;choose=' . $choose . '"><img src="' . $OUTPUT->pix_url('f/parent.gif') . '" class="icon" alt="" />&nbsp;' . get_string('parentfolder') . '</a>', 'name');
                print_cell();
                print_cell();
                print_cell();
                /*
                            } else if ($name === $userstr) { // if departmental account or user collection
                            	// TODO: need to determine what $wdir is if we're coming in from one of the course subcollections
                                // don't know where this fits in
                		$branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false  || $wdir === '' ? $filesafe : "$wdir/$filesafe";
                                 print_cell();
                                // alt attribute intentionally empty to prevent repetition in screen reader
                				//CLAMP #289 change padding-left from 10 to 0px
                				//Kevin Wiliarty 2011-03-08
                                print_cell('left', '<a  style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&amp;wdir=' . $wdir . '&amp;choose=' . $choose .'&amp;name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" />&nbsp;'. $name .'</a>', 'name');
                //                print_cell('left', '<a  style="padding-left:0px" href="' . $fileurl . '" target="_blank"><img src="'. $OUTPUT->pix_url("f/folder") .'" class="icon" alt="" />&nbsp;'. $filename .'</a>');
                                print_cell("right", $filedate, 'date');
                //                print_cell();
                                print_cell();
                //              print_cell();
                            } else if ($name === $deptstr){
                            	// TODO: need to determine what $wdir is if we're coming in from one of the course subcollections
                		$branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false  || $wdir === '' ? $filesafe : "$wdir/$filesafe";
                            	print_cell("center", "<input type=\"checkbox\" name=\"dir$countdir\" value=\"$filename\" />", 'checkbox');
                                // alt attribute intentionally empty to prevent repetition in screen reader
                				//CLAMP #289 change padding-left from 10 to 0px
                				//Kevin Wiliarty 2011-03-08
                                print_cell('left', '<a  style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&amp;wdir=' . $branchdir . '&amp;choose=' . $choose . '&amp;name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" />&nbsp;'. $name .'</a>', 'name');
                                print_cell("right", $filedate, 'date');
                //                print_cell();
                				if (has_capability('moodle/course:update', $coursecontext)) {
                	                print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&amp;wdir=$branchdir&amp;file=$filename&amp;action=link&amp;type=dir&amp;choose=$choose\">$strlinktocourse</a>", 'commands');
                				}
                //              print_cell();
                */
            } else {
                // not a user or departmental folder
                print_cell();
                //               	print_cell("center", "<input type=\"checkbox\" name=\"$name\" value=\"$filename\" />", 'checkbox');
                //                print_cell("left", "<a href=\"morslefiles.php?courseid=$courseid&amp;wdir=$wdir/$filesafe&amp;choose=$choose\"><img src=\"$OUTPUT->pix_url('f/folder')\" class=\"icon\" alt=\"$strfolder\" />&nbsp;".$filename."</a>", 'name');
                $branchdir = "{$wdir}/{$filesafe}";
                //                $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false  || $wdir === '' ? $filesafe : "$wdir/$filesafe";
                print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&amp;wdir=' . $branchdir . '&amp;choose=' . $choose . '&amp;name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" />&nbsp;' . $filename . '</a>', 'name');
                print_cell("right", $filedate, 'date');
                //                print_cell();
                if (has_capability('moodle/course:update', $coursecontext)) {
                    print_cell("left", "{$edittext}<a href=\"morslefiles.php?courseid={$courseid}&amp;wdir={$branchdir}&amp;file={$filename}&amp;action=link&amp;type=dir&amp;choose={$choose}\">{$strlinktocourse}</a>", 'commands');
                    //                    print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&amp;wdir=$wdir&amp;file=$filename&amp;action=link&amp;type=dir&amp;choose=$choose\">$strlinktocourse</a>", 'commands');
                }
            }
            echo html_writer::end_tag('tr');
        }
    }
    $iconchoices = array('excel' => 'download/spreadsheets', 'powerpoint' => 'download/presentations', 'word' => 'download/documents', 'pdf' => 'application/pdf');
    if (!empty($filedetails)) {
        foreach ($filedetails as $name => $file) {
            if (isset($filelist[$name]->exportLinks)) {
                $links = array();
                $links = array_values($filelist[$name]->exportLinks);
                $exportlink = $links[0];
            } else {
                $exportlink = $filelist[$name]->alternateLink;
            }
            // positively identify the correct icon regardless of filename extension
            $icon = $filelist[$name]->iconLink;
            $filename = $name;
            $fileurl = $file->link;
            $embedlink = $filelist[$name]->embedLink;
            $embedsafe = rawurlencode($embedlink);
            $fileurlsafe = rawurlencode($fileurl);
            $filedate = $file->updated;
            $fileid = $filelist[$name]->id;
            $selectfile = trim($fileurl, "/");
            //            echo html_writer::start_tag('td', array('class'=>'file'));
            //            echo html_writer::end_tag('td');
            print_cell("center", "<input type=\"checkbox\" name=\"file\" value=\"{$filename}\" />", 'checkbox');
            //CLAMP #289 change padding-left from 10 to 0px
            //Kevin Wiliarty 2011-03-08
            //            echo html_writer::start_tag('td', array('align'=>'left','style'=>'white-space:nowrap; padding-left:0px;','class'=>'name'));
            print_cell('left', '<a href="' . $fileurl . '" class="morslefile" target="_blank">
            		<img src="' . $icon . '" class="icon" alt="' . $strfile . '" /> ' . $filename . '</a>', 'name');
            //            $echovar = '<a href="' . $fileurl . '" target="_blank">
            //            		<img src="' . $OUTPUT->pix_url("f/$icon") . '" class="icon" alt="' . $strfile . '" />&nbsp;' . htmlspecialchars($filename) . '</a>';
            //            echo $echovar;
            //html_writer::link(qualified_me(), $strname, array('&sort'=>'{'.$sortvalues[0].'}'))
            //$echovar = html_writer::tag('a', $fileurl, array('target'=>'_blank')) . html_writer::img($OUTPUT->pix_url("f/$icon"), $strfile, array('class'=>'icon')) . '&nbsp;'.htmlspecialchars($filename) . html_writer::end_tag('a');
            //echo $echovar;
            //            echo html_writer::end_tag('td');
            print_cell("right", $filedate, 'date');
            if (has_capability('moodle/course:update', $coursecontext)) {
                if (strpos($wdir, $gdocsstr) === 1) {
                    print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&amp;wdir={$wdir}/{$fileid}&amp;file={$filename}&amp;name={$filename}&amp;filelink={$fileurl}&amp;action=link&amp;type=file&amp;choose={$choose}\">{$strlinktocourse}</a>", 'commands');
                } else {
                    print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&amp;wdir={$wdir}&amp;file={$filename}&amp;action=link&amp;type=file&amp;choose={$choose}\">{$strlinktocourse}</a>", 'commands');
                }
                //                print_cell('left', '&nbsp&nbsp<a title="' . $name . '" href="embeddoc.php?courseid=$courseid&amp;embedlink=' . $embedsafe . '&amp;name=' . $filename . '"> Embed </a>','embed');
            }
            //            print_cell('left', '&nbsp&nbsp<a title="' . strip_tags($strdownload) . ': ' . $name . '" href="' .$CFG->wwwroot
            //                    . '/blocks/morsle/docs_export.php?exportlink=' . s($exportlink) . '&shortname=' . $course->shortname . '&title=' . $filename . '" target="_blank"> Download </a>','commands');
            print_cell();
            print_cell('left', '&nbsp&nbsp<a title="' . $name . '" href="' . s($exportlink) . '" target="_blank"> Download </a>', 'commands');
            //print_cell('left', '&nbsp&nbsp<a title="' . $name . '" href="embeddoc.php?"' . s($embedlink) . '" target="_blank"> Embed in a Page resource </a>','commands');
            echo html_writer::end_tag('tr');
        }
    }
    echo html_writer::end_div();
    echo html_writer::end_tag('form');
    echo html_writer::end_tag('table');
}
예제 #15
0
파일: view.php 프로젝트: sikeze/emarking
function emarking_show_export_buttons($issupervisor, $rubriccriteria, $cm, $emarking, $numdraftsgrading)
{
    global $OUTPUT;
    echo html_writer::start_div('exportbuttons');
    // Show export to Excel button if supervisor and there are students to export.
    if ($issupervisor && $rubriccriteria) {
        if ($emarking->type == EMARKING_TYPE_ON_SCREEN_MARKING) {
            echo "<table><tr><td>";
            $csvurl = new moodle_url('view.php', array('id' => $cm->id, 'exportcsv' => 'grades'));
            echo $OUTPUT->single_button($csvurl, get_string('exportgrades', 'mod_emarking'));
            echo "</td><td>";
            $csvurl = new moodle_url('view.php', array('id' => $cm->id, 'enrolment' => 'true'));
            echo $OUTPUT->single_button($csvurl, get_string('showunenrolled', 'mod_emarking'), 'GET');
            echo "</td></tr><table>";
        }
    }
    // Show export to Excel button if supervisor and there are students to export.
    if ($issupervisor && $emarking->type == EMARKING_TYPE_PEER_REVIEW && $numdraftsgrading == 0) {
        $csvurl = new moodle_url('view.php', array('id' => $cm->id, 'reassignpeers' => 'true'));
        echo $OUTPUT->single_button($csvurl, get_string('reassignpeers', 'mod_emarking'));
    }
    if ($numdraftsgrading > 1) {
        echo html_writer::tag("input", null, array("id" => "searchInput", 'value' => get_string("filter")));
    }
    echo html_writer::end_div();
}
예제 #16
0
    public function mail($message, $reply = false, $offset = 0) {
        global $CFG, $USER;

        $totalusers = 0;
        $output = '';

        if (!$reply) {
            $output .= html_writer::empty_tag('input', array(
                    'type' => 'hidden',
                    'name' => 'm',
                    'value' => $message->id(),
            ));

            $output .= html_writer::empty_tag('input', array(
                    'type' => 'hidden',
                    'name' => 'offset',
                    'value' => $offset,
            ));
        }

        $output .= $this->output->container_start('mail_header');
        $output .= $this->output->container_start('left');
        $output .= $this->output->user_picture($message->sender());
        $output .= $this->output->container_end();
        $output .= $this->output->container_start('mail_info');
        $output .= html_writer::link(new moodle_url('/user/view.php',
                                            array(
                                                'id' => $message->sender()->id,
                                                'course' => $message->course()->id
                                            )),
                                    fullname($message->sender()),
                                    array('class' => 'user_from'));
        $output .= $this->date($message, true);
        if (!$reply) {
            $output .= $this->output->container_start('mail_recipients');
            foreach (array('to', 'cc', 'bcc') as $role) {
                $recipients = $message->recipients($role);
                if (!empty($recipients)) {
                    if ($role == 'bcc' and $message->sender()->id !== $USER->id) {
                        continue;
                    }
                    $output .= html_writer::start_tag('div');
                    $output .= html_writer::tag('span', get_string($role, 'local_mail'), array('class' => 'mail_role'));
                    $numusers = count($recipients);
                    $totalusers += $numusers;
                    $cont = 1;
                    foreach ($recipients as $user) {
                        $output .= html_writer::link(new moodle_url('/user/view.php',
                                            array(
                                                'id' => $user->id,
                                                'course' => $message->course()->id
                                            )),
                                            fullname($user));
                        if ($cont < $numusers) {
                            $output .= ', ';
                        }
                        $cont += 1;
                    }
                    $output .= ' ';
                    $output .= html_writer::end_tag('div');
                }
            }
            $output .= $this->output->container_end();
        } else {
            $output .= html_writer::tag('div', '', array('class' => 'mail_recipients'));
        }
        $output .= $this->output->container_end();
        $output .= $this->output->container_end();

        $output .= $this->output->container_start('mail_body');
        $output .= $this->output->container_start('mail_content');
        $output .= local_mail_format_content($message);
        $attachments = local_mail_attachments($message);
        if ($attachments) {
            $output .= $this->output->container_start('mail_attachments');
            if (count($attachments) > 1) {
                $text = get_string('attachnumber', 'local_mail', count($attachments));
                $output .= html_writer::tag('span', $text, array('class' => 'mail_attachment_text'));
                $downloadurl = new moodle_url($this->page->url, array('downloadall' => '1'));
                $iconimage = $this->output->pix_icon('a/download_all', get_string('downloadall', 'local_mail'), 'moodle', array('class' => 'icon'));
                $output .= html_writer::start_div('mail_attachment_downloadall');
                $output .= html_writer::link($downloadurl, $iconimage);
                $output .= html_writer::link($downloadurl, get_string('downloadall', 'local_mail'), array('class' => 'mail_downloadall_text'));
                $output .= html_writer::end_div();
            }
            foreach ($attachments as $attach) {
                $filename = $attach->get_filename();
                $filepath = $attach->get_filepath();
                $mimetype = $attach->get_mimetype();
                $iconimage = $this->output->pix_icon(file_file_icon($attach), get_mimetype_description($attach), 'moodle', array('class' => 'icon'));
                $path = '/'.$attach->get_contextid().'/local_mail/message/'.$attach->get_itemid().$filepath.$filename;
                $fullurl = moodle_url::make_file_url('/pluginfile.php', $path, true);
                $output .= html_writer::start_tag('div', array('class' => 'mail_attachment'));
                $output .= html_writer::link($fullurl, $iconimage);
                $output .= html_writer::link($fullurl, s($filename));
                $output .= html_writer::tag('span', display_size($attach->get_filesize()), array('class' => 'mail_attachment_size'));
                $output .= html_writer::end_tag('div');
            }
            $output .= $this->output->container_end();
        }
        $output .= $this->output->container_end();
        $output .= $this->newlabelform();
        if (!$reply) {
            if ($message->sender()->id !== $USER->id) {
                $output .= $this->toolbar('reply', $message->course()->id, array('replyall' => ($totalusers > 1)));
            } else {
                $output .= $this->toolbar('forward', $message->course()->id);
            }
        }
        $output .= $this->output->container_end();
        return $output;
    }
 public function course_search_form($value = '', $format = 'plain')
 {
     static $count = 0;
     $formid = 'coursesearch';
     if (++$count > 1) {
         $formid .= $count;
     }
     $inputid = 'coursesearchbox';
     $inputsize = 30;
     if ($format === 'navbar') {
         $formid = 'coursesearchnavbar';
         $inputid = 'navsearchbox';
     }
     $strsearchcourses = get_string("searchcourses");
     $searchurl = new moodle_url('/course/search.php');
     $form = array('id' => $formid, 'action' => $searchurl, 'method' => 'get', 'class' => "form-inline", 'role' => 'form');
     $output = html_writer::start_tag('form', $form);
     $output .= html_writer::start_div('input-group');
     $output .= html_writer::tag('label', $strsearchcourses, array('for' => $inputid, 'class' => 'sr-only'));
     $search = array('type' => 'text', 'id' => $inputid, 'size' => $inputsize, 'name' => 'search', 'class' => 'form-control', 'value' => s($value), 'placeholder' => $strsearchcourses);
     $output .= html_writer::empty_tag('input', $search);
     $button = array('type' => 'submit', 'class' => 'btn btn-default');
     $output .= html_writer::start_span('input-group-btn');
     $output .= html_writer::tag('button', get_string('go'), $button);
     $output .= html_writer::end_span();
     $output .= html_writer::end_div();
     // Close form-group.
     $output .= html_writer::end_tag('form');
     return $output;
 }
예제 #18
0
 /**
  * displays the full report
  * @param \stdClass $scorm full SCORM object
  * @param \stdClass $cm - full course_module object
  * @param \stdClass $course - full course object
  * @param string $download - type of download being requested
  */
 public function display($scorm, $cm, $course, $download)
 {
     global $CFG, $DB, $OUTPUT, $PAGE;
     $contextmodule = \context_module::instance($cm->id);
     $action = optional_param('action', '', PARAM_ALPHA);
     $attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
     $attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
     $PAGE->set_url(new \moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
     if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
         if (scorm_delete_responses($attemptids, $scorm)) {
             // Delete responses.
             echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
         }
     }
     // Find out current groups mode.
     $currentgroup = groups_get_activity_group($cm, true);
     // Detailed report.
     $mform = new \mod_scorm_report_objectives_settings($PAGE->url, compact('currentgroup'));
     if ($fromform = $mform->get_data()) {
         $pagesize = $fromform->pagesize;
         $showobjectivescore = $fromform->objectivescore;
         set_user_preference('scorm_report_pagesize', $pagesize);
         set_user_preference('scorm_report_objectives_score', $showobjectivescore);
     } else {
         $pagesize = get_user_preferences('scorm_report_pagesize', 0);
         $showobjectivescore = get_user_preferences('scorm_report_objectives_score', 0);
     }
     if ($pagesize < 1) {
         $pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
     }
     // Select group menu.
     $displayoptions = array();
     $displayoptions['attemptsmode'] = $attemptsmode;
     $displayoptions['objectivescore'] = $showobjectivescore;
     $mform->set_data($displayoptions + array('pagesize' => $pagesize));
     if ($groupmode = groups_get_activity_groupmode($cm)) {
         // Groups are being used.
         if (!$download) {
             groups_print_activity_menu($cm, new \moodle_url($PAGE->url, $displayoptions));
         }
     }
     $formattextoptions = array('context' => \context_course::instance($course->id));
     // We only want to show the checkbox to delete attempts
     // if the user has permissions and if the report mode is showing attempts.
     $candelete = has_capability('mod/scorm:deleteresponses', $contextmodule) && $attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO;
     // Select the students.
     $nostudents = false;
     if (empty($currentgroup)) {
         // All users who can attempt scoes.
         if (!($students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', '', '', false))) {
             echo $OUTPUT->notification(get_string('nostudentsyet'));
             $nostudents = true;
             $allowedlist = '';
         } else {
             $allowedlist = array_keys($students);
         }
         unset($students);
     } else {
         // All users who can attempt scoes and who are in the currently selected group.
         $groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false);
         if (!$groupstudents) {
             echo $OUTPUT->notification(get_string('nostudentsingroup'));
             $nostudents = true;
             $groupstudents = array();
         }
         $allowedlist = array_keys($groupstudents);
         unset($groupstudents);
     }
     if (!$nostudents) {
         // Now check if asked download of data.
         $coursecontext = \context_course::instance($course->id);
         if ($download) {
             $filename = clean_filename("{$course->shortname} " . format_string($scorm->name, true, $formattextoptions));
         }
         // Define table columns.
         $columns = array();
         $headers = array();
         if (!$download && $candelete) {
             $columns[] = 'checkbox';
             $headers[] = null;
         }
         if (!$download && $CFG->grade_report_showuserimage) {
             $columns[] = 'picture';
             $headers[] = '';
         }
         $columns[] = 'fullname';
         $headers[] = get_string('name');
         $extrafields = get_extra_user_fields($coursecontext);
         foreach ($extrafields as $field) {
             $columns[] = $field;
             $headers[] = get_user_field_name($field);
         }
         $columns[] = 'attempt';
         $headers[] = get_string('attempt', 'scorm');
         $columns[] = 'start';
         $headers[] = get_string('started', 'scorm');
         $columns[] = 'finish';
         $headers[] = get_string('last', 'scorm');
         $columns[] = 'score';
         $headers[] = get_string('score', 'scorm');
         $scoes = $DB->get_records('scorm_scoes', array("scorm" => $scorm->id), 'sortorder, id');
         foreach ($scoes as $sco) {
             if ($sco->launch != '') {
                 $columns[] = 'scograde' . $sco->id;
                 $headers[] = format_string($sco->title, '', $formattextoptions);
             }
         }
         $params = array();
         list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED);
         // Construct the SQL.
         $select = 'SELECT DISTINCT ' . $DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)') . ' AS uniqueid, ';
         $select .= 'st.scormid AS scormid, st.attempt AS attempt, ' . \user_picture::fields('u', array('idnumber'), 'userid') . get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
         // This part is the same for all cases - join users and scorm_scoes_track tables.
         $from = 'FROM {user} u ';
         $from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = ' . $scorm->id;
         switch ($attemptsmode) {
             case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
                 // Show only students with attempts.
                 $where = ' WHERE u.id ' . $usql . ' AND st.userid IS NOT NULL';
                 break;
             case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
                 // Show only students without attempts.
                 $where = ' WHERE u.id ' . $usql . ' AND st.userid IS NULL';
                 break;
             case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
                 // Show all students with or without attempts.
                 $where = ' WHERE u.id ' . $usql . ' AND (st.userid IS NOT NULL OR st.userid IS NULL)';
                 break;
         }
         $countsql = 'SELECT COUNT(DISTINCT(' . $DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)') . ')) AS nbresults, ';
         $countsql .= 'COUNT(DISTINCT(' . $DB->sql_concat('u.id', '\'#\'', 'st.attempt') . ')) AS nbattempts, ';
         $countsql .= 'COUNT(DISTINCT(u.id)) AS nbusers ';
         $countsql .= $from . $where;
         $nbmaincolumns = count($columns);
         // Get number of main columns used.
         $objectives = get_scorm_objectives($scorm->id);
         $nosort = array();
         foreach ($objectives as $scoid => $sco) {
             foreach ($sco as $id => $objectivename) {
                 $colid = $scoid . 'objectivestatus' . $id;
                 $columns[] = $colid;
                 $nosort[] = $colid;
                 if (!$displayoptions['objectivescore']) {
                     // Display the objective name only.
                     $headers[] = $objectivename;
                 } else {
                     // Display the objective status header with a "status" suffix to avoid confusion.
                     $headers[] = $objectivename . ' ' . get_string('status', 'scormreport_objectives');
                     // Now print objective score headers.
                     $colid = $scoid . 'objectivescore' . $id;
                     $columns[] = $colid;
                     $nosort[] = $colid;
                     $headers[] = $objectivename . ' ' . get_string('score', 'scormreport_objectives');
                 }
             }
         }
         $emptycell = '';
         // Used when an empty cell is being printed - in html we add a space.
         if (!$download) {
             $emptycell = '&nbsp;';
             $table = new \flexible_table('mod-scorm-report');
             $table->define_columns($columns);
             $table->define_headers($headers);
             $table->define_baseurl($PAGE->url);
             $table->sortable(true);
             $table->collapsible(true);
             // This is done to prevent redundant data, when a user has multiple attempts.
             $table->column_suppress('picture');
             $table->column_suppress('fullname');
             foreach ($extrafields as $field) {
                 $table->column_suppress($field);
             }
             foreach ($nosort as $field) {
                 $table->no_sorting($field);
             }
             $table->no_sorting('start');
             $table->no_sorting('finish');
             $table->no_sorting('score');
             $table->no_sorting('checkbox');
             $table->no_sorting('picture');
             foreach ($scoes as $sco) {
                 if ($sco->launch != '') {
                     $table->no_sorting('scograde' . $sco->id);
                 }
             }
             $table->column_class('picture', 'picture');
             $table->column_class('fullname', 'bold');
             $table->column_class('score', 'bold');
             $table->set_attribute('cellspacing', '0');
             $table->set_attribute('id', 'attempts');
             $table->set_attribute('class', 'generaltable generalbox');
             // Start working -- this is necessary as soon as the niceties are over.
             $table->setup();
         } else {
             if ($download == 'ODS') {
                 require_once "{$CFG->libdir}/odslib.class.php";
                 $filename .= ".ods";
                 // Creating a workbook.
                 $workbook = new \MoodleODSWorkbook("-");
                 // Sending HTTP headers.
                 $workbook->send($filename);
                 // Creating the first worksheet.
                 $sheettitle = get_string('report', 'scorm');
                 $myxls = $workbook->add_worksheet($sheettitle);
                 // Format types.
                 $format = $workbook->add_format();
                 $format->set_bold(0);
                 $formatbc = $workbook->add_format();
                 $formatbc->set_bold(1);
                 $formatbc->set_align('center');
                 $formatb = $workbook->add_format();
                 $formatb->set_bold(1);
                 $formaty = $workbook->add_format();
                 $formaty->set_bg_color('yellow');
                 $formatc = $workbook->add_format();
                 $formatc->set_align('center');
                 $formatr = $workbook->add_format();
                 $formatr->set_bold(1);
                 $formatr->set_color('red');
                 $formatr->set_align('center');
                 $formatg = $workbook->add_format();
                 $formatg->set_bold(1);
                 $formatg->set_color('green');
                 $formatg->set_align('center');
                 // Here starts workshhet headers.
                 $colnum = 0;
                 foreach ($headers as $item) {
                     $myxls->write(0, $colnum, $item, $formatbc);
                     $colnum++;
                 }
                 $rownum = 1;
             } else {
                 if ($download == 'Excel') {
                     require_once "{$CFG->libdir}/excellib.class.php";
                     $filename .= ".xls";
                     // Creating a workbook.
                     $workbook = new \MoodleExcelWorkbook("-");
                     // Sending HTTP headers.
                     $workbook->send($filename);
                     // Creating the first worksheet.
                     $sheettitle = get_string('report', 'scorm');
                     $myxls = $workbook->add_worksheet($sheettitle);
                     // Format types.
                     $format = $workbook->add_format();
                     $format->set_bold(0);
                     $formatbc = $workbook->add_format();
                     $formatbc->set_bold(1);
                     $formatbc->set_align('center');
                     $formatb = $workbook->add_format();
                     $formatb->set_bold(1);
                     $formaty = $workbook->add_format();
                     $formaty->set_bg_color('yellow');
                     $formatc = $workbook->add_format();
                     $formatc->set_align('center');
                     $formatr = $workbook->add_format();
                     $formatr->set_bold(1);
                     $formatr->set_color('red');
                     $formatr->set_align('center');
                     $formatg = $workbook->add_format();
                     $formatg->set_bold(1);
                     $formatg->set_color('green');
                     $formatg->set_align('center');
                     $colnum = 0;
                     foreach ($headers as $item) {
                         $myxls->write(0, $colnum, $item, $formatbc);
                         $colnum++;
                     }
                     $rownum = 1;
                 } else {
                     if ($download == 'CSV') {
                         $csvexport = new \csv_export_writer("tab");
                         $csvexport->set_filename($filename, ".txt");
                         $csvexport->add_data($headers);
                     }
                 }
             }
         }
         if (!$download) {
             $sort = $table->get_sql_sort();
         } else {
             $sort = '';
         }
         // Fix some wired sorting.
         if (empty($sort)) {
             $sort = ' ORDER BY uniqueid';
         } else {
             $sort = ' ORDER BY ' . $sort;
         }
         if (!$download) {
             // Add extra limits due to initials bar.
             list($twhere, $tparams) = $table->get_sql_where();
             if ($twhere) {
                 $where .= ' AND ' . $twhere;
                 // Initial bar.
                 $params = array_merge($params, $tparams);
             }
             if (!empty($countsql)) {
                 $count = $DB->get_record_sql($countsql, $params);
                 $totalinitials = $count->nbresults;
                 if ($twhere) {
                     $countsql .= ' AND ' . $twhere;
                 }
                 $count = $DB->get_record_sql($countsql, $params);
                 $total = $count->nbresults;
             }
             $table->pagesize($pagesize, $total);
             echo \html_writer::start_div('scormattemptcounts');
             if ($count->nbresults == $count->nbattempts) {
                 echo get_string('reportcountattempts', 'scorm', $count);
             } else {
                 if ($count->nbattempts > 0) {
                     echo get_string('reportcountallattempts', 'scorm', $count);
                 } else {
                     echo $count->nbusers . ' ' . get_string('users');
                 }
             }
             echo \html_writer::end_div();
         }
         // Fetch the attempts.
         if (!$download) {
             $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params, $table->get_page_start(), $table->get_page_size());
             echo \html_writer::start_div('', array('id' => 'scormtablecontainer'));
             if ($candelete) {
                 // Start form.
                 $strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
                 echo \html_writer::start_tag('form', array('id' => 'attemptsform', 'method' => 'post', 'action' => $PAGE->url->out(false), 'onsubmit' => 'return confirm("' . $strreallydel . '");'));
                 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'delete'));
                 echo \html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
                 echo \html_writer::start_div('', array('style' => 'display: none;'));
                 echo \html_writer::input_hidden_params($PAGE->url);
                 echo \html_writer::end_div();
                 echo \html_writer::start_div();
             }
             $table->initialbars($totalinitials > 20);
             // Build table rows.
         } else {
             $attempts = $DB->get_records_sql($select . $from . $where . $sort, $params);
         }
         if ($attempts) {
             foreach ($attempts as $scouser) {
                 $row = array();
                 if (!empty($scouser->attempt)) {
                     $timetracks = scorm_get_sco_runtime($scorm->id, false, $scouser->userid, $scouser->attempt);
                 } else {
                     $timetracks = '';
                 }
                 if (in_array('checkbox', $columns)) {
                     if ($candelete && !empty($timetracks->start)) {
                         $row[] = \html_writer::checkbox('attemptid[]', $scouser->userid . ':' . $scouser->attempt, false);
                     } else {
                         if ($candelete) {
                             $row[] = '';
                         }
                     }
                 }
                 if (in_array('picture', $columns)) {
                     $user = new \stdClass();
                     $additionalfields = explode(',', \user_picture::fields());
                     $user = username_load_fields_from_object($user, $scouser, null, $additionalfields);
                     $user->id = $scouser->userid;
                     $row[] = $OUTPUT->user_picture($user, array('courseid' => $course->id));
                 }
                 if (!$download) {
                     $url = new \moodle_url('/user/view.php', array('id' => $scouser->userid, 'course' => $course->id));
                     $row[] = \html_writer::link($url, fullname($scouser));
                 } else {
                     $row[] = fullname($scouser);
                 }
                 foreach ($extrafields as $field) {
                     $row[] = s($scouser->{$field});
                 }
                 if (empty($timetracks->start)) {
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                     $row[] = '-';
                 } else {
                     if (!$download) {
                         $url = new \moodle_url('/mod/scorm/report/userreport.php', array('id' => $cm->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
                         $row[] = \html_writer::link($url, $scouser->attempt);
                     } else {
                         $row[] = $scouser->attempt;
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->start, get_string("strftimedatetime", "langconfig"));
                     } else {
                         $row[] = userdate($timetracks->start);
                     }
                     if ($download == 'ODS' || $download == 'Excel') {
                         $row[] = userdate($timetracks->finish, get_string('strftimedatetime', 'langconfig'));
                     } else {
                         $row[] = userdate($timetracks->finish);
                     }
                     $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $scouser->attempt);
                 }
                 // Print out all scores of attempt.
                 foreach ($scoes as $sco) {
                     if ($sco->launch != '') {
                         if ($trackdata = scorm_get_tracks($sco->id, $scouser->userid, $scouser->attempt)) {
                             if ($trackdata->status == '') {
                                 $trackdata->status = 'notattempted';
                             }
                             $strstatus = get_string($trackdata->status, 'scorm');
                             if ($trackdata->score_raw != '') {
                                 // If raw score exists, print it.
                                 $score = $trackdata->score_raw;
                                 // Add max score if it exists.
                                 if (isset($trackdata->score_max)) {
                                     $score .= '/' . $trackdata->score_max;
                                 }
                             } else {
                                 // ...else print out status.
                                 $score = $strstatus;
                             }
                             if (!$download) {
                                 $url = new \moodle_url('/mod/scorm/report/userreporttracks.php', array('id' => $cm->id, 'scoid' => $sco->id, 'user' => $scouser->userid, 'attempt' => $scouser->attempt));
                                 $row[] = \html_writer::img($OUTPUT->pix_url($trackdata->status, 'scorm'), $strstatus, array('title' => $strstatus)) . \html_writer::empty_tag('br') . \html_writer::link($url, $score, array('title' => get_string('details', 'scorm')));
                             } else {
                                 $row[] = $score;
                             }
                             // Iterate over tracks and match objective id against values.
                             $scorm2004 = false;
                             if (scorm_version_check($scorm->version, SCORM_13)) {
                                 $scorm2004 = true;
                                 $objectiveprefix = "cmi.objectives.";
                             } else {
                                 $objectiveprefix = "cmi.objectives_";
                             }
                             $keywords = array(".id", $objectiveprefix);
                             $objectivestatus = array();
                             $objectivescore = array();
                             foreach ($trackdata as $name => $value) {
                                 if (strpos($name, $objectiveprefix) === 0 && strrpos($name, '.id') !== false) {
                                     $num = trim(str_ireplace($keywords, '', $name));
                                     if (is_numeric($num)) {
                                         if ($scorm2004) {
                                             $element = $objectiveprefix . $num . '.completion_status';
                                         } else {
                                             $element = $objectiveprefix . $num . '.status';
                                         }
                                         if (isset($trackdata->{$element})) {
                                             $objectivestatus[$value] = $trackdata->{$element};
                                         } else {
                                             $objectivestatus[$value] = '';
                                         }
                                         if ($displayoptions['objectivescore']) {
                                             $element = $objectiveprefix . $num . '.score.raw';
                                             if (isset($trackdata->{$element})) {
                                                 $objectivescore[$value] = $trackdata->{$element};
                                             } else {
                                                 $objectivescore[$value] = '';
                                             }
                                         }
                                     }
                                 }
                             }
                             // Interaction data.
                             if (!empty($objectives[$trackdata->scoid])) {
                                 foreach ($objectives[$trackdata->scoid] as $name) {
                                     if (isset($objectivestatus[$name])) {
                                         $row[] = s($objectivestatus[$name]);
                                     } else {
                                         $row[] = $emptycell;
                                     }
                                     if ($displayoptions['objectivescore']) {
                                         if (isset($objectivescore[$name])) {
                                             $row[] = s($objectivescore[$name]);
                                         } else {
                                             $row[] = $emptycell;
                                         }
                                     }
                                 }
                             }
                             // End of interaction data.
                         } else {
                             // If we don't have track data, we haven't attempted yet.
                             $strstatus = get_string('notattempted', 'scorm');
                             if (!$download) {
                                 $row[] = \html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), $strstatus, array('title' => $strstatus)) . \html_writer::empty_tag('br') . $strstatus;
                             } else {
                                 $row[] = $strstatus;
                             }
                             // Complete the empty cells.
                             for ($i = 0; $i < count($columns) - $nbmaincolumns; $i++) {
                                 $row[] = $emptycell;
                             }
                         }
                     }
                 }
                 if (!$download) {
                     $table->add_data($row);
                 } else {
                     if ($download == 'Excel' or $download == 'ODS') {
                         $colnum = 0;
                         foreach ($row as $item) {
                             $myxls->write($rownum, $colnum, $item, $format);
                             $colnum++;
                         }
                         $rownum++;
                     } else {
                         if ($download == 'CSV') {
                             $csvexport->add_data($row);
                         }
                     }
                 }
             }
             if (!$download) {
                 $table->finish_output();
                 if ($candelete) {
                     echo \html_writer::start_tag('table', array('id' => 'commands'));
                     echo \html_writer::start_tag('tr') . \html_writer::start_tag('td');
                     echo \html_writer::link('javascript:select_all_in(\'DIV\', null, \'scormtablecontainer\');', get_string('selectall', 'scorm')) . ' / ';
                     echo \html_writer::link('javascript:deselect_all_in(\'DIV\', null, \'scormtablecontainer\');', get_string('selectnone', 'scorm'));
                     echo '&nbsp;&nbsp;';
                     echo \html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('deleteselected', 'scorm'), 'class' => 'btn btn-secondary'));
                     echo \html_writer::end_tag('td') . \html_writer::end_tag('tr') . \html_writer::end_tag('table');
                     // Close form.
                     echo \html_writer::end_tag('div');
                     echo \html_writer::end_tag('form');
                 }
                 echo \html_writer::end_div();
                 if (!empty($attempts)) {
                     echo \html_writer::start_tag('table', array('class' => 'boxaligncenter')) . \html_writer::start_tag('tr');
                     echo \html_writer::start_tag('td');
                     echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'ODS') + $displayoptions), get_string('downloadods'), 'post', ['class' => 'm-t-1']);
                     echo \html_writer::end_tag('td');
                     echo \html_writer::start_tag('td');
                     echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'Excel') + $displayoptions), get_string('downloadexcel'), 'post', ['class' => 'm-t-1']);
                     echo \html_writer::end_tag('td');
                     echo \html_writer::start_tag('td');
                     echo $OUTPUT->single_button(new \moodle_url($PAGE->url, array('download' => 'CSV') + $displayoptions), get_string('downloadtext'), 'post', ['class' => 'm-t-1']);
                     echo \html_writer::end_tag('td');
                     echo \html_writer::start_tag('td');
                     echo \html_writer::end_tag('td');
                     echo \html_writer::end_tag('tr') . \html_writer::end_tag('table');
                 }
             }
         } else {
             if ($candelete && !$download) {
                 echo \html_writer::end_div();
                 echo \html_writer::end_tag('form');
                 $table->finish_output();
             }
             echo \html_writer::end_div();
         }
         // Show preferences form irrespective of attempts are there to report or not.
         if (!$download) {
             $mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode'));
             $mform->display();
         }
         if ($download == 'Excel' or $download == 'ODS') {
             $workbook->close();
             exit;
         } else {
             if ($download == 'CSV') {
                 $csvexport->download_file();
                 exit;
             }
         }
     } else {
         echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
     }
 }
 /**
  *  get content
  */
 public function get_content()
 {
     global $OUTPUT, $CFG;
     if ($this->content !== null) {
         return $this->content;
     }
     $this->content = new stdClass();
     $this->content->text = '';
     // get courses list in wich logged user was enrolled
     $courses = block_resources_get_all_resources();
     if (!$courses) {
         $this->content->text .= 'There are no courses';
         return $this->content;
     }
     // --------- cycle by courses
     foreach ($courses as $course) {
         if ($course->resources || $course->videoresources) {
             // render corse box
             $this->content->text .= $OUTPUT->box_start('coursebox', "course-{$course->id}") . html_writer::start_tag('div', array('class' => 'course_title'));
             $attributes = array('title' => $course->fullname);
             if ($course->id > 0) {
                 if (empty($course->visible)) {
                     $attributes['class'] = 'dimmed';
                 }
                 $courseurl = new moodle_url('/course/view.php', array('id' => $course->id));
                 $coursefullname = format_string(get_course_display_name_for_list($course), true, $course->id);
                 $link = html_writer::link($courseurl, $coursefullname, $attributes);
                 $this->content->text .= $OUTPUT->heading($link, 2, 'title');
             } else {
                 $this->content->text .= $this->output->heading(html_writer::link(new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id=' . $course->remoteid)), format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
             }
             // render resources
             foreach ($course->resources as $resource) {
                 /// --- Render one resource item
                 $this->content->text .= html_writer::start_div('resource_item') . html_writer::start_div('resource_body') . html_writer::start_div('resource_title') . html_writer::link($resource->url, $resource->title, array('target' => '_blank', 'class' => 'resourcelink', 'data-objectid' => $resource->id));
                 $this->content->text .= html_writer::end_div();
                 // end of resource_title
                 // render Author and source
                 if (!empty($resource->author)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'Author') . ': ' . $resource->author . html_writer::end_div();
                 }
                 if (!empty($resource->source)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'Source') . ': ' . $resource->source . html_writer::end_div();
                 }
                 if (!empty($resource->avgrate)) {
                     $this->content->text .= html_writer::start_div('resource_metadata') . html_writer::tag('strong', 'AVG rating') . ': ' . $resource->avgrate . html_writer::end_div();
                 }
                 //echo html_writer::div($resource->description, 'resource_description');
                 $this->content->text .= html_writer::end_div();
                 // end of Resource body ---
                 $this->content->text .= html_writer::end_div();
                 // end of Resource Item ---
             }
             // render videoresources
             foreach ($course->videoresources as $videoresource) {
                 /// --- Render one resource item
                 $url = new moodle_url("{$CFG->wwwroot}/mod/videoresource/view.php", array('id' => $videoresource->id));
                 $this->content->text .= html_writer::start_div('resource_item') . html_writer::start_div('resource_body') . html_writer::start_div('resource_title') . html_writer::link($url->out(false), $videoresource->name, array('target' => '_blank', 'class' => 'resourcelink', 'data-objectid' => $videoresource->id));
                 $this->content->text .= html_writer::end_div();
                 // end of resource_title
                 //echo html_writer::div($resource->description, 'resource_description');
                 $this->content->text .= html_writer::end_div();
                 // end of Resource body ---
                 $this->content->text .= html_writer::end_div();
                 // end of Resource Item ---
             }
             //$this->content->text .= $OUTPUT->box('', 'flush');
             $this->content->text .= html_writer::end_tag('div');
             $this->content->text .= $OUTPUT->box_end();
         }
     }
     if (!empty($this->content->text)) {
         $this->content->text .= html_writer::link($CFG->wwwroot . '/blocks/resources/tocsv.php', 'Download list (CSV)');
     } else {
         $this->content->text .= 'There are no resources';
         //$this->content->text .= $OUTPUT->notification(get_string('no_resources', 'resourcelib'), 'redirectmessage');
     }
     return $this->content;
 }
 /**
  * display all the bookings of the whole moodle site
  * sorted by course
  * @param booking_options $bookingoptions
  * @return string rendered html
  */
 public function render_bookings(booking_options $bookingoptions)
 {
     $output = '';
     $output .= html_writer::start_div();
     $header = html_writer::tag('h3', $bookingoptions->booking->name);
     $url = new moodle_url('/mod/booking/view.php', array('id' => $bookingoptions->cm->id));
     $output .= html_writer::link($url, $header);
     foreach ($bookingoptions->options as $optionid => $bookingoption) {
         if (!empty($bookingoptions->allbookedusers[$optionid])) {
             $waitinglist = array();
             $output .= html_writer::tag('h4', $bookingoption->text);
             $output .= html_writer::start_div('mod-booking-regular');
             $output .= html_writer::div(get_string('bookedusers', 'booking'));
             $table = new html_table();
             $table->cellpadding = 1;
             $table->cellspacing = 0;
             $table->tablealign = 'left';
             $table->data = array();
             foreach ($bookingoptions->allbookedusers[$optionid] as $user) {
                 if ($user->status[$optionid]->bookingvisible && $user->status[$optionid]->booked == 'booked') {
                     $table->data[] = array($this->output->user_picture($user, array('courseid' => $bookingoptions->booking->course)), fullname($user) . "<br />" . $user->email);
                 } else {
                     if ($user->status[$optionid]->bookingvisible) {
                         $waitinglist[] = $user;
                     }
                 }
             }
             $output .= html_writer::table($table);
             $output .= html_writer::end_div();
         }
         if (!empty($waitinglist)) {
             $output .= html_writer::start_div('mod-booking-waiting');
             $output .= html_writer::div(get_string('waitinglistusers', 'booking'));
             $table = new html_table();
             $table->cellpadding = 1;
             $table->cellspacing = 0;
             $table->tablealign = 'left';
             $table->data = array();
             foreach ($waitinglist as $user) {
                 if ($user->status[$optionid]->bookingvisible) {
                     $table->data[] = array($this->output->user_picture($user, array('courseid' => $bookingoptions->booking->course)), fullname($user) . "<br />" . $user->email);
                 }
             }
             $output .= html_writer::table($table);
             $output .= html_writer::end_div();
         }
     }
     $output .= html_writer::end_div();
     return $output;
 }
 public function generate_turforlag_subtabcontent_html($structure, $sectionid)
 {
     $html = '';
     foreach ($structure[$sectionid]['parts'] as $subtabid => $subtab) {
         if (isset($structure[$sectionid]['parts'][$subtabid]['modules'])) {
             $html .= html_writer::start_div('turforlag_cf_subcontent', array('id' => "subtabs-{$sectionid}-{$subtabid}"));
             $html .= html_writer::start_tag('ul');
             if (isset($structure[$sectionid]['parts'][$subtabid]['modules'])) {
                 foreach ($structure[$sectionid]['parts'][$subtabid]['modules'] as $moduleid => $module) {
                     $url = new moodle_url("/mod/{$module['type']}/view.php", array('id' => $moduleid));
                     $link = html_writer::link($url, $module['name']);
                     $html .= html_writer::tag('li', $link, array('class' => 'turforlag_status_' . $module['status']));
                 }
             }
             $html .= html_writer::end_tag('ul');
             $html .= html_writer::end_div();
         }
     }
     return $html;
 }
예제 #22
0
 public function test_end_div()
 {
     $this->assertSame('</div>', html_writer::end_div());
 }
예제 #23
0
 /**
  * Generate the HTML for the table preferences reset button.
  *
  * @return string HTML fragment, empty string if no need to reset
  */
 protected function render_reset_button()
 {
     if (!$this->can_be_reset()) {
         return '';
     }
     $url = $this->baseurl->out(false, array($this->request[TABLE_VAR_RESET] => 1));
     $html = html_writer::start_div('resettable mdl-right');
     $html .= html_writer::link($url, get_string('resettable'));
     $html .= html_writer::end_div();
     return $html;
 }
예제 #24
0
 /**
  * Helper method to render the information about the available plugin update
  *
  * @param core_plugin_manager $pluginman plugin manager instance
  * @param \core\update\info $updateinfo information about the available update for the plugin
  */
 protected function plugin_available_update_info(core_plugin_manager $pluginman, \core\update\info $updateinfo)
 {
     $boxclasses = 'pluginupdateinfo';
     $info = array();
     if (isset($updateinfo->release)) {
         $info[] = html_writer::div(get_string('updateavailable_release', 'core_plugin', $updateinfo->release), 'info release');
     }
     if (isset($updateinfo->maturity)) {
         $info[] = html_writer::div(get_string('maturity' . $updateinfo->maturity, 'core_admin'), 'info maturity');
         $boxclasses .= ' maturity' . $updateinfo->maturity;
     }
     if (isset($updateinfo->download)) {
         $info[] = html_writer::div(html_writer::link($updateinfo->download, get_string('download')), 'info download');
     }
     if (isset($updateinfo->url)) {
         $info[] = html_writer::div(html_writer::link($updateinfo->url, get_string('updateavailable_moreinfo', 'core_plugin')), 'info more');
     }
     $box = html_writer::start_div($boxclasses);
     $box .= html_writer::div(get_string('updateavailable', 'core_plugin', $updateinfo->version), 'version');
     $box .= html_writer::div(implode(html_writer::span(' ', 'separator'), $info), 'infos');
     if ($pluginman->is_remote_plugin_installable($updateinfo->component, $updateinfo->version, $reason)) {
         $box .= $this->output->single_button(new moodle_url($this->page->url, array('installupdate' => $updateinfo->component, 'installupdateversion' => $updateinfo->version)), get_string('updateavailableinstall', 'core_admin'), 'post', array('class' => 'singlebutton updateavailableinstall'));
     } else {
         $reasonhelp = $this->info_remote_plugin_not_installable($reason);
         if ($reasonhelp) {
             $box .= html_writer::div($reasonhelp, 'reasonhelp updateavailableinstall');
         }
     }
     $box .= html_writer::end_div();
     return $box;
 }
예제 #25
0
            $groupby = ' GROUP BY r.postid';
        }
        $conditionsparams = array_merge($conditionsparams, $groupparams, $havingparams);
        $ratingsl = $DB->get_recordset_sql("SELECT {$counttype}, {$postid}\n                FROM {$from}\n                {$postjoin}\n                INNER JOIN  {forumng_discussions} fd ON fp.discussionid = fd.id\n                INNER JOIN  {forumng} f ON f.id = fd.forumngid\n                WHERE {$conditions}\n                AND fd.deleted = 0\n                AND fp.deleted = 0\n                AND fp.oldversion = 0\n                {$groupwhere}\n                {$groupby}\n                {$having}\n                ORDER BY rawgrade DESC\n                ", $conditionsparams, 0, 5);
        // Get the ratings.
        foreach ($ratingsl as $apost) {
            if ($gradingtype == mod_forumng::GRADING_AVERAGE) {
                $apost->rawgrade = round($apost->rawgrade, 2);
            }
            $post = mod_forumng_post::get_from_id($apost->postid, $cloneid, true, true);
            list($content, $user) = $renderer->render_usage_post_info($forum, $post->get_discussion(), $post);
            $ratingslist[] = $renderer->render_usage_list_item($forum, $apost->rawgrade, $user, $content);
        }
        // Print out ratings usage.
        $usageoutput .= $renderer->render_usage_ratings($ratingslist, $forum, $gradingstr, $gradingtype);
    }
}
if (!empty($usageoutput)) {
    echo html_writer::start_div('forumng_usage_section');
    echo $OUTPUT->heading(get_string('usage', 'forumngfeature_usage'), 4, 'forumng_usage_sectitle');
    echo $usageoutput;
    echo html_writer::start_div('clearer') . html_writer::end_div();
    echo html_writer::end_div();
}
echo $OUTPUT->footer();
// Log usage view.
$params = array('context' => $forum->get_context(), 'objectid' => $forum->get_id(), 'other' => array('url' => $thisurl->out_as_local_url()));
$event = \forumngfeature_usage\event\usage_viewed::create($params);
$event->add_record_snapshot('course_modules', $forum->get_course_module());
$event->add_record_snapshot('course', $forum->get_course());
$event->trigger();
 /**
  * Renderers a search result course list item.
  *
  * This function will be called for every course being displayed by course_listing.
  *
  * @param course_in_list $course The course to produce HTML for.
  * @param int $selectedcourse The id of the currently selected course.
  * @return string
  */
 public function search_listitem(course_in_list $course, $selectedcourse)
 {
     $text = $course->get_formatted_name();
     $attributes = array('class' => 'listitem listitem-course', 'data-id' => $course->id, 'data-selected' => $selectedcourse == $course->id ? '1' : '0', 'data-visible' => $course->visible ? '1' : '0');
     $bulkcourseinput = array('type' => 'checkbox', 'name' => 'bc[]', 'value' => $course->id, 'class' => 'bulk-action-checkbox');
     $viewcourseurl = new moodle_url($this->page->url, array('courseid' => $course->id));
     $categoryname = coursecat::get($course->category)->get_formatted_name();
     $html = html_writer::start_tag('li', $attributes);
     $html .= html_writer::start_div('clearfix');
     $html .= html_writer::start_div('float-left');
     $html .= html_writer::empty_tag('input', $bulkcourseinput) . '&nbsp;';
     $html .= html_writer::end_div();
     $html .= html_writer::link($viewcourseurl, $text, array('class' => 'float-left coursename'));
     $html .= html_writer::tag('span', $categoryname, array('class' => 'float-left categoryname'));
     $html .= html_writer::start_div('float-right');
     $html .= $this->search_listitem_actions($course);
     $html .= html_writer::tag('span', s($course->idnumber), array('class' => 'dimmed idnumber'));
     $html .= html_writer::end_div();
     $html .= html_writer::end_div();
     $html .= html_writer::end_tag('li');
     return $html;
 }
예제 #27
0
 /**
  * Displays the general information about a backup file with unknown format
  *
  * @param moodle_url $nextstageurl URL to send user to
  * @return string HTML code to display
  */
 public function backup_details_unknown(moodle_url $nextstageurl)
 {
     $html = html_writer::start_div('unknownformat');
     $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2);
     $html .= $this->output->notification(get_string('errorinvalidformatinfo', 'backup'), 'notifyproblem');
     $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post');
     $html .= html_writer::end_div();
     return $html;
 }
예제 #28
0
파일: display.php 프로젝트: evltuma/moodle
 /**
  * Finishes output. (Progress can begin again later if there are more
  * calls to update_progress.)
  *
  * Automatically called from update_progress when progress finishes.
  */
 public function end_html()
 {
     // Finish progress bar.
     $this->bar->update_full(100, '');
     $this->bar = null;
     // End wibbler div.
     echo \html_writer::end_div();
 }
예제 #29
0
파일: lib.php 프로젝트: rezaies/moodle
/**
 * Outputs the forum post indicated by $activity.
 *
 * @param object $activity      the activity object the forum resides in
 * @param int    $courseid      the id of the course the forum resides in
 * @param bool   $detail        not used, but required for compatibilty with other modules
 * @param int    $modnames      not used, but required for compatibilty with other modules
 * @param bool   $viewfullnames not used, but required for compatibilty with other modules
 */
function forum_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames)
{
    global $OUTPUT;
    $content = $activity->content;
    if ($content->parent) {
        $class = 'reply';
    } else {
        $class = 'discussion';
    }
    $tableoptions = ['border' => '0', 'cellpadding' => '3', 'cellspacing' => '0', 'class' => 'forum-recent'];
    $output = html_writer::start_tag('table', $tableoptions);
    $output .= html_writer::start_tag('tr');
    $post = (object) ['parent' => $content->parent];
    $forum = (object) ['type' => $content->forumtype];
    $authorhidden = forum_is_author_hidden($post, $forum);
    // Show user picture if author should not be hidden.
    if (!$authorhidden) {
        $pictureoptions = ['courseid' => $courseid, 'link' => $authorhidden, 'alttext' => $authorhidden];
        $picture = $OUTPUT->user_picture($activity->user, $pictureoptions);
        $output .= html_writer::tag('td', $picture, ['class' => 'userpicture', 'valign' => 'top']);
    }
    // Discussion title and author.
    $output .= html_writer::start_tag('td', ['class' => $class]);
    if ($content->parent) {
        $class = 'title';
    } else {
        // Bold the title of new discussions so they stand out.
        $class = 'title bold';
    }
    $output .= html_writer::start_div($class);
    if ($detail) {
        $aname = s($activity->name);
        $output .= html_writer::img($OUTPUT->pix_url('icon', $activity->type), $aname, ['class' => 'icon']);
    }
    $discussionurl = new moodle_url('/mod/forum/discuss.php', ['d' => $content->discussion]);
    $discussionurl->set_anchor('p' . $activity->content->id);
    $output .= html_writer::link($discussionurl, $content->subject);
    $output .= html_writer::end_div();
    $timestamp = userdate($activity->timestamp);
    if ($authorhidden) {
        $authornamedate = $timestamp;
    } else {
        $fullname = fullname($activity->user, $viewfullnames);
        $userurl = new moodle_url('/user/view.php');
        $userurl->params(['id' => $activity->user->id, 'course' => $courseid]);
        $by = new stdClass();
        $by->name = html_writer::link($userurl, $fullname);
        $by->date = $timestamp;
        $authornamedate = get_string('bynameondate', 'forum', $by);
    }
    $output .= html_writer::div($authornamedate, 'user');
    $output .= html_writer::end_tag('td');
    $output .= html_writer::end_tag('tr');
    $output .= html_writer::end_tag('table');
    echo $output;
}
예제 #30
-1
파일: lib.php 프로젝트: ruddj/moodle
/**
 * writes overview info for course_overview block - displays upcoming scorm objects that have a due date
 *
 * @param object $type - type of log(aicc,scorm12,scorm13) used as prefix for filename
 * @param array $htmlarray
 * @return mixed
 */
function scorm_print_overview($courses, &$htmlarray) {
    global $USER, $CFG;

    if (empty($courses) || !is_array($courses) || count($courses) == 0) {
        return array();
    }

    if (!$scorms = get_all_instances_in_courses('scorm', $courses)) {
        return;
    }

    $strscorm   = get_string('modulename', 'scorm');
    $strduedate = get_string('duedate', 'scorm');

    foreach ($scorms as $scorm) {
        $time = time();
        $showattemptstatus = false;
        if ($scorm->timeopen) {
            $isopen = ($scorm->timeopen <= $time && $time <= $scorm->timeclose);
        }
        if ($scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_ALL ||
                $scorm->displayattemptstatus == SCORM_DISPLAY_ATTEMPTSTATUS_MY) {
            $showattemptstatus = true;
        }
        if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
            $str = html_writer::start_div('scorm overview').html_writer::div($strscorm. ': '.
                    html_writer::link($CFG->wwwroot.'/mod/scorm/view.php?id='.$scorm->coursemodule, $scorm->name,
                                        array('title' => $strscorm, 'class' => $scorm->visible ? '' : 'dimmed')), 'name');
            if ($scorm->timeclose) {
                $str .= html_writer::div($strduedate.': '.userdate($scorm->timeclose), 'info');
            }
            if ($showattemptstatus) {
                require_once($CFG->dirroot.'/mod/scorm/locallib.php');
                $str .= html_writer::div(scorm_get_attempt_status($USER, $scorm), 'details');
            }
            $str .= html_writer::end_div();
            if (empty($htmlarray[$scorm->course]['scorm'])) {
                $htmlarray[$scorm->course]['scorm'] = $str;
            } else {
                $htmlarray[$scorm->course]['scorm'] .= $str;
            }
        }
    }
}