/** * Get criteria details for displaying to users * * @return string */ public function get_details($short = '') { global $DB, $OUTPUT; $output = array(); foreach ($this->params as $p) { $coursename = $DB->get_field('course', 'fullname', array('id' => $p['course'])); if (!$coursename) { $str = $OUTPUT->error_text(get_string('error:nosuchcourse', 'badges')); } else { $str = html_writer::tag('b', '"' . $coursename . '"'); if (isset($p['bydate'])) { $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig'))); } if (isset($p['grade'])) { $str .= get_string('criteria_descr_grade', 'badges', $p['grade']); } } $output[] = $str; } if ($short) { return implode(', ', $output); } else { return html_writer::alist($output, array(), 'ul'); } }
/** * Return the toolbar * * @param bool $show_new whether show "New round" button * return alist of links */ public function toolbar($show_new = true) { $output = ''; $toolbuttons = array(); // Print next/prev round bar if ($this->hotquestion->get_prev_round() != null) { $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $this->hotquestion->get_prev_round()->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed_rtl', get_string('previousround', 'hotquestion')), array('class' => 'toolbutton')); } else { $toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty_rtl', ''), array('class' => 'dis_toolbutton')); } if ($this->hotquestion->get_next_round() != null) { $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id, 'round' => $this->hotquestion->get_next_round()->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/collapsed', get_string('nextround', 'hotquestion')), array('class' => 'toolbutton')); } else { $toolbuttons[] = html_writer::tag('span', $this->pix_icon('t/collapsed_empty', ''), array('class' => 'dis_toolbutton')); } // Print new round bar if ($show_new) { $options = array(); $options['id'] = $this->hotquestion->cm->id; $options['action'] = 'newround'; $url = new moodle_url('/mod/hotquestion/view.php', $options); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/add', get_string('newround', 'hotquestion')), array('class' => 'toolbutton')); } // Print refresh button $url = new moodle_url('/mod/hotquestion/view.php', array('id' => $this->hotquestion->cm->id)); $toolbuttons[] = html_writer::link($url, $this->pix_icon('t/reload', get_string('reload')), array('class' => 'toolbutton')); // return all available toolbuttons $output .= html_writer::alist($toolbuttons, array('id' => 'toolbar')); return $output; }
function get_content() { if ($this->content !== NULL) { return $this->content; } $context = context_system::instance(); $this->content = new stdClass(); $this->content->footer = ''; $this->content->text = ''; $content = array(); $canview = has_capability('block/enrol_token_manager:viewtokens', $context) === true; $cancreate = has_capability('block/enrol_token_manager:createtokens', $context) === true; $canrevoke = has_capability('block/enrol_token_manager:revoketokens', $context) === true; // view tokens link if ($canview) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextViewTokens', 'block_enrol_token_manager')); } // create tokens link if ($cancreate) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/create_tokens.php'), get_string('linkTextCreateTokens', 'block_enrol_token_manager')); } // revoke tokens link if ($canrevoke) { $content[] = html_writer::link(new moodle_url('/blocks/enrol_token_manager/viewrevoke_tokens.php'), get_string('linkTextRevokeTokens', 'block_enrol_token_manager')); } if ($cancreate || $canrevoke || $canview) { $this->content->text = html_writer::alist($content); } return $this->content; }
/** * Display message about the benefits of registering on Moodle.org * * @return string */ public function moodleorg_registration_message() { $moodleorgstatslink = html_writer::link('http://moodle.net/stats', get_string('statsmoodleorg', 'admin'), array('target' => '_blank')); $moodleorgregmsg = get_string('registermoodleorg', 'admin'); $items = array(get_string('registermoodleorgli1', 'admin'), get_string('registermoodleorgli2', 'admin', $moodleorgstatslink)); $moodleorgregmsg .= html_writer::alist($items); return $moodleorgregmsg; }
/** * Display Moodle.org registration message about benefit to register on Moodle.org * * @return string */ public function moodleorg_registration_message() { $moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org'); $moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin')); $moochurl = html_writer::link(HUB_MOODLEORGHUBURL, get_string('moodleorghubname', 'admin')); $moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl); $items = array(get_string('registermoodleorgli1', 'admin'), get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl), get_string('registermoodleorgli3', 'admin', $moochurl)); $moodleorgregmsg .= html_writer::alist($items); return $moodleorgregmsg; }
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; }
/** * Output array of list_items * @param array $content * @param string $stringname - name of string to use for title and no content * @param bool $heading - include a heading with help? * @return string */ public function render_usage_list($content, $stringname, $heading = true) { $toreturn = ''; if ($heading) { $toreturn .= $this->render_usage_list_heading($stringname); } if (!empty($content)) { $toreturn .= html_writer::alist($content, array('class' => 'forumng_usage_list'), 'ol'); } else { $toreturn .= html_writer::tag('p', get_string($stringname . '_none', 'forumngfeature_usage')); } return $toreturn; }
function get_content() { // Check if we've already generated content if (!empty($this->content)) { return $this->content; } // Prep the content $this->content = new stdClass(); /** * Prepare the content for this block */ $options = blog_get_all_options($this->page); if (count($options) == 0) { // Don't display menu block if block is set at site level, and user is not logged in $this->content->text = ''; if ($this->page->user_is_editing()) { // If editing is enabled show an informative message $this->content->text = get_string('blogdisable', 'blog'); } return $this->content; } // Iterate the option types $menulist = array(); foreach ($options as $types) { foreach ($types as $link) { $menulist[] = html_writer::link($link['link'], $link['string']); } $menulist[] = '<hr />'; } // Remove the last element (will be an HR) array_pop($menulist); // Display the content as a list $this->content->text = html_writer::alist($menulist, array('class' => 'list')); /** * Prepare the footer for this block */ if (has_capability('moodle/blog:search', get_context_instance(CONTEXT_SYSTEM))) { // Full-text search field $form = html_writer::tag('label', get_string('search', 'admin'), array('for' => 'blogsearchquery', 'class' => 'accesshide')); $form .= html_writer::empty_tag('input', array('id' => 'blogsearchquery', 'type' => 'text', 'name' => 'search')); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search'))); $this->content->footer = html_writer::tag('form', html_writer::tag('div', $form), array('class' => 'blogsearchform', 'method' => 'get', 'action' => new moodle_url('/blog/index.php'))); } else { // No footer to display $this->content->footer = ''; } // Return the content object return $this->content; }
/** * Prints the summary of the made insertions. */ function print_success_summary() { echo html_writer::start_tag('h4'); echo get_string('success', 'block_mycourse_recommendations'); echo html_writer::end_tag('h4'); echo html_writer::start_tag('hr'); echo 'Summary of importation:'; echo html_writer::start_tag('br'); $insertedcourses = \block_mycourse_recommendations\csv_importer::get_lastinsertedcourses(); $insertedcourses = get_string('importedcourses', 'block_mycourse_recommendations') . $insertedcourses; $insertedusers = \block_mycourse_recommendations\csv_importer::get_lastinsertedusers(); $insertedusers = get_string('importedusers', 'block_mycourse_recommendations') . $insertedusers; $insertedlogs = \block_mycourse_recommendations\csv_importer::get_lastinsertedlogs(); $insertedlogs = get_string('importedlogs', 'block_mycourse_recommendations') . $insertedlogs; echo html_writer::alist(array($insertedcourses, $insertedusers, $insertedlogs)); }
public function choose_export_method() { global $PAGE; $output = $this->box_start(); $output .= html_writer::tag('p', '准备将成绩导出到教务处成绩管理系统。'); $output .= html_writer::tag('p', '导出后的成绩只是“保存”在教务处网站,您还有机会审核、修正,然后再提交。'); $output .= html_writer::tag('p', '请选择导出方式:'); $links = array(); $url = $PAGE->url; $url->params(array('action' => 'totalonly')); $links[] = html_writer::link($url, '只导出总分'); $url->params(array('action' => 'all')); $links[] = html_writer::link($url, '导出分项成绩和总分'); $output .= html_writer::alist($links); $output .= $this->box_end(); return $output; }
public function render_databasebookmarks($bookmarks) { $output = ''; $bookmarkslinks = array(); foreach ($bookmarks as $bookmark) { $bookmarkmarkup = ''; $url = new moodle_url("/mod/data/view.php", array('d' => $bookmark->instanceid, 'rid' => $bookmark->recordid)); $label = $bookmark->bookmarkname; $bookmarklink = html_writer::link($url, $label); $bookmarkmarkup .= html_writer::span($bookmarklink, 'bookmarklink'); $iconenrolremove = $this->output->pix_url('t/delete'); $iconimg = html_writer::img($iconenrolremove, get_string('delete')); $deletelink = html_writer::link('#', $iconimg, array('data-rid' => $bookmark->recordid, 'data-action' => 'delete', 'class' => 'data_deletebookmark_link')); $bookmarkmarkup .= html_writer::span($deletelink, 'deletelink'); $bookmarkslinks[] = $bookmarkmarkup; } $output .= html_writer::alist($bookmarkslinks, array('class' => 'block_databasebookmarks_bookmarklist')); return $output; }
/** * Get criteria description for displaying to users * * @return string */ public function get_details($short = '') { global $DB, $OUTPUT; $output = array(); foreach ($this->params as $p) { $mod = self::get_mod_instance($p['module']); if (!$mod) { $str = $OUTPUT->error_text(get_string('error:nosuchmod', 'badges')); } else { $str = html_writer::tag('b', '"' . ucfirst($mod->modname) . ' - ' . $mod->name . '"'); if (isset($p['bydate'])) { $str .= get_string('criteria_descr_bydate', 'badges', userdate($p['bydate'], get_string('strftimedate', 'core_langconfig'))); } } $output[] = $str; } if ($short) { return implode(', ', $output); } else { return html_writer::alist($output, array(), 'ul'); } }
function get_content() { global $CFG, $USER, $DB; if ($this->content !== NULL) { return $this->content; } if (!isset($this->config->roleid) || empty($this->config->roleid)) { $this->content->text = get_string('needsconfig', 'block_children'); } else { // get all the mentees, i.e. users you have a direct assignment to $contextparams = array($USER->id, CONTEXT_USER, $this->config->roleid); if ($usercontexts = $DB->get_records_sql("SELECT c.instanceid, c.instanceid, u.firstname, u.lastname\n FROM {role_assignments} ra, {context} c, {user} u\n WHERE ra.userid = ?\n AND ra.contextid = c.id\n AND c.instanceid = u.id\n AND c.contextlevel = ?\n AND ra.roleid = ?\n ORDER BY u.lastname", $contextparams)) { $users = array(); foreach ($usercontexts as $usercontext) { $userurl = new moodle_url('/user/view.php', array('id' => $usercontext->instanceid, 'course' => SITEID)); $users[] = html_writer::link($userurl, fullname($usercontext)); } $this->content->text = html_writer::alist($users); } } $this->content->footer = ''; return $this->content; }
function review_list($courseswithreviews) { $output = ''; foreach ($courseswithreviews as $session) { if (!empty($session->courses)) { $output .= $this->output->heading($session->name, 3); $courselinks = array(); foreach ($session->courses as $course) { if ($course->reviewtype == PROGRESSREVIEW_SUBJECT) { $reviewurl = new moodle_url('/local/progressreview/subjectreview.php', array('sessionid' => $session->id, 'courseid' => $course->id)); } else { if ($course->reviewtype == PROGRESSREVIEW_TUTOR) { $reviewurl = new moodle_url('/local/progressreview/tutorreview.php', array('sessionid' => $session->id, 'courseid' => $course->id)); } else { throw new coding_exception('Each course must have a reviewtype set to either PROGRESSREVIEW_SUBJECT or PROGRESSREVIEW_TUTOR'); } } $courselinks[] = html_writer::link($reviewurl, $course->fullname); } $output .= html_writer::alist($courselinks); } } return $output; }
function get_content() { global $CFG; // detect if blog enabled if ($this->content !== NULL) { return $this->content; } if (empty($CFG->enableblogs)) { $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { $this->content->text = get_string('blogdisable', 'blog'); } return $this->content; } else { if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL and (!isloggedin() or isguestuser())) { $this->content = new stdClass(); $this->content->text = ''; return $this->content; } } // require necessary libs and get content require_once $CFG->dirroot . '/blog/lib.php'; // Prep the content $this->content = new stdClass(); $options = blog_get_all_options($this->page); if (count($options) == 0) { $this->content->text = ''; return $this->content; } // Iterate the option types $menulist = array(); foreach ($options as $types) { foreach ($types as $link) { $menulist[] = html_writer::link($link['link'], $link['string']); } $menulist[] = '<hr />'; } // Remove the last element (will be an HR) array_pop($menulist); // Display the content as a list $this->content->text = html_writer::alist($menulist, array('class' => 'list')); // Prepare the footer for this block if (has_capability('moodle/blog:search', context_system::instance())) { // Full-text search field $form = html_writer::tag('label', get_string('search', 'admin'), array('for' => 'blogsearchquery', 'class' => 'accesshide')); $form .= html_writer::empty_tag('input', array('id' => 'blogsearchquery', 'type' => 'text', 'name' => 'search')); $form .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('search'))); $this->content->footer = html_writer::tag('form', html_writer::tag('div', $form), array('class' => 'blogsearchform', 'method' => 'get', 'action' => new moodle_url('/blog/index.php'))); } else { // No footer to display $this->content->footer = ''; } // Return the content object return $this->content; }
/** * Output the table structures with headings for the Submission inbox, they will be populated via Ajax * * @global type $CFG * @global type $OUTPUT * @global type $USER * @param type $cm * @param type $turnitintooltwoassignment * @return type */ public function init_submission_inbox($cm, $turnitintooltwoassignment, $partdetails, $turnitintooltwouser) { global $CFG, $OUTPUT, $USER; $config = turnitintooltwo_admin_config(); $istutor = has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id)); // Output user role to hidden var for use in jQuery calls. $output = $OUTPUT->box($turnitintooltwouser->get_user_role(), '', 'user_role'); $output .= $OUTPUT->box($turnitintooltwoassignment->turnitintooltwo->id, '', 'assignment_id'); if ($turnitintooltwouser->get_user_role() == 'Learner') { $output .= html_writer::tag('noscript', get_string('noscriptsummary', 'turnitintooltwo'), array("class" => "warning")); } $origreportenabled = $turnitintooltwoassignment->turnitintooltwo->studentreports ? 1 : 0; $grademarkenabled = $config->usegrademark ? 1 : 0; // Do the table headers. $cells = array(); $cells["part"] = new html_table_cell('part'); $cells["checkbox"] = new html_table_cell($istutor ? html_writer::checkbox(false, false, false, '', array("class" => "select_all_checkbox")) : ' '); $cells["student"] = $istutor ? new html_table_cell(get_string('student', 'turnitintooltwo')) : new html_table_cell(); $cells["student"]->attributes['class'] = 'left'; $cells["title_raw"] = new html_table_cell(' '); $cells["title_raw"]->attributes['class'] = 'raw_data'; $cells["title"] = new html_table_cell(get_string('submissiontitle', 'turnitintooltwo')); $cells["title"]->attributes['class'] = 'left'; $cells["paper_id"] = new html_table_cell(get_string('objectid', 'turnitintooltwo')); $cells["paper_id"]->attributes['class'] = 'right'; $cells["submitted_date_raw"] = new html_table_cell(' '); $cells["submitted_date_raw"]->attributes['class'] = 'raw_data'; $cells["submitted_date"] = new html_table_cell(get_string('submitted', 'turnitintooltwo')); $cells["submitted_date"]->attributes['class'] = 'right'; if ($turnitintooltwouser->get_user_role() == 'Instructor' || $turnitintooltwouser->get_user_role() == 'Learner' && $origreportenabled) { $cells["report_raw"] = new html_table_cell(); $cells["report_raw"]->attributes['class'] = 'raw_data'; $cells["report"] = new html_table_cell(get_string('submissionorig', 'turnitintooltwo')); $cells["report"]->attributes['class'] = 'right'; } if ($grademarkenabled) { $cells["grade_raw"] = new html_table_cell(); $cells["grade_raw"]->attributes['class'] = 'raw_data'; $cells["grade"] = new html_table_cell(get_string('submissiongrade', 'turnitintooltwo')); $cells["grade"]->id = "grademark"; $cells["grade"]->attributes['class'] = 'right'; if (count($partdetails) > 1 || $turnitintooltwoassignment->turnitintooltwo->grade < 0) { $cells["overallgrade"] = new html_table_cell(get_string('overallgrade', 'turnitintooltwo')); $cells["overallgrade"]->attributes['class'] = 'right'; } } if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) { $cells["student_read"] = new html_table_cell(' '); } $cells["upload"] = new html_table_cell(' '); $cells["upload"]->attributes['class'] = "noscript_hide"; if (has_capability('mod/turnitintooltwo:grade', context_module::instance($cm->id))) { $cells["refresh"] = new html_table_cell(' '); } $cells["download"] = new html_table_cell(' '); $cells["delete"] = new html_table_cell(' '); $tableheaders = $cells; $tables = ""; $output .= $OUTPUT->box_start('', 'tabs'); $tabitems = array(); $i = 0; foreach ($partdetails as $partid => $partobject) { if (!empty($partid)) { $i++; $tabitems[$i] = html_writer::link("#tabs-" . $partid, $partobject->partname); $tables .= html_writer::tag('h2', $partobject->partname, array('class' => 'js_hide', 'data-submitted' => $partobject->submitted)); $tables .= $OUTPUT->box_start('part_table', 'tabs-' . $partid, array('data-submitted' => $partobject->submitted)); $downloadLinks = ""; if ($turnitintooltwouser->get_user_role() == 'Instructor') { if ($CFG->branch >= 27) { $origfileszipLang = "origfileszip"; $grademarkzipLang = "grademarkzip"; } else { $origfileszipLang = "downloadorigfileszip"; $grademarkzipLang = "downloadgrademarkzip"; } // Output icon to download zip file of selected submissions in original format. $exportorigfileszip = $OUTPUT->box(html_writer::tag('i', '', array('class' => 'fa fa-file-o', 'title' => get_string($origfileszipLang, 'turnitintooltwo'))) . ' ' . get_string($origfileszipLang, 'turnitintooltwo'), 'zip_open origchecked_zip_open', 'origchecked_zip_' . $partobject->id); // Put in div placeholder for launch form. $exportorigfileszip .= $OUTPUT->box('', 'launch_form', 'origchecked_zip_form_' . $partobject->id); // Output icon to download zip file of submissions in pdf format. $exportgrademarkzip = html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id . '&part=' . $partid . '&do=export_pdfs&view_context=box_solid', html_writer::tag('i', '', array('class' => 'fa fa-file-pdf-o', 'title' => get_string($grademarkzipLang, 'turnitintooltwo'))) . ' ' . get_string($grademarkzipLang, 'turnitintooltwo'), array("class" => "gmpdfzip_box", "id" => "gmpdf_zip_" . $partobject->id)); // Only Moodle versions 2.7+ came with bootstrap. if ($CFG->branch >= 27) { $downloadLinks = html_writer::tag('div', html_writer::link('#', get_string('download', 'turnitintooltwo'), array('class' => 'btn dropdown-toggle', 'data-toggle' => 'dropdown')) . html_writer::tag('ul', html_writer::tag('li', $exportorigfileszip) . html_writer::tag('li', $exportgrademarkzip), array('class' => 'dropdown-menu')), array('id' => 'download_links', 'class' => 'btn-group')); } else { $downloadLinks = $exportorigfileszip . $exportgrademarkzip; } } // Include download links and info table. $tables .= $OUTPUT->box($downloadLinks, 'zip_downloads', 'part_' . $partobject->id); $tables .= $this->get_submission_inbox_part_details($cm, $turnitintooltwoassignment, $partdetails, $partid); // Construct submissions table. $table = new html_table(); $table->id = $partid; $table->attributes['class'] = 'submissionsDataTable'; $table->head = $tableheaders; // Populate inbox if user is a student incase they do not have javascript enabled. if ($turnitintooltwouser->get_user_role() == 'Learner') { $submission = current($this->get_submission_inbox($cm, $turnitintooltwoassignment, $partdetails, $partid)); // If not logged in as a tutor then refresh submissions. $turnitintooltwoassignment->refresh_submissions($partobject); $j = 0; $cells = array(); foreach ($submission as $cell) { $cells[$j] = new html_table_cell($cell); if ($j == 2 || $j == 3 || $j == 4) { $cells[$j]->attributes['class'] = "left"; } else { if ($j == 5 || $j == 7) { $cells[$j]->attributes['class'] = "right"; } else { if ($j == 8 && $origreportenabled || $j == 8 && !$origreportenabled && $grademarkenabled || $j == 10 && $origreportenabled && $grademarkenabled) { $cells[$j]->attributes['class'] = "raw_data"; } else { $cells[$j]->attributes['class'] = "centered_cell"; } } } if (count($submission) == 16 && $j == 11 || count($submission) == 15 && $j == 10) { $cells[$j]->attributes['class'] = "noscript_hide"; } $j++; } $rows[0] = new html_table_row($cells); $table->data = $rows; } $tables .= html_writer::table($table); $tables .= $OUTPUT->box_end(true); // Link to open Turnitin Messages inbox. $messagesinbox = ''; if ($turnitintooltwouser->get_user_role() == 'Instructor') { $messagesinbox = html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id . '&user='******'&do=loadmessages&view_context=box', html_writer::tag('i', '', array('class' => 'fa fa-envelope-o fa-lg')) . ' ' . get_string('messagesinbox', 'turnitintooltwo') . ' (' . html_writer::tag('span', '', array('class' => 'messages_amount')) . html_writer::tag('span', $OUTPUT->pix_icon('loading', get_string('turnitinloading', 'turnitintooltwo'), 'mod_turnitintooltwo'), array('class' => 'messages_loading messages_loading_span')) . ')', array("class" => "messages_inbox")); } // Link to email nonsubmitters. $emailnonsubmitters = ''; if ($turnitintooltwouser->get_user_role() == 'Instructor') { $emailnonsubmitters = html_writer::link($CFG->wwwroot . '/mod/turnitintooltwo/view.php?id=' . $cm->id . '&part=' . $partid . '&do=emailnonsubmittersform&view_context=box_solid', html_writer::tag('i', '', array('class' => 'fa fa-reply-all fa-lg')) . ' ' . get_string('emailnonsubmitters', 'turnitintooltwo'), array("class" => "nonsubmitters_link", "id" => "nonsubmitters_" . $partid)); } // Link to refresh submissions with latest data from Turnitin. $refreshlink = html_writer::tag('div', html_writer::tag('i', '', array('class' => 'fa fa-refresh fa-lg', 'title' => get_string('turnitinrefreshingsubmissions', 'turnitintooltwo'))) . " " . get_string('turnitinrefreshsubmissions', 'turnitintooltwo'), array('class' => 'refresh_link', 'id' => 'refresh_' . $partid)); // Link which appears during the refresh of submissions. $refreshinglink = html_writer::tag('div', html_writer::tag('i', '', array('class' => 'fa fa-spinner fa-spin fa-lg', 'title' => get_string('turnitinrefreshingsubmissions', 'turnitintooltwo'))) . " " . get_string('turnitinrefreshingsubmissions', 'turnitintooltwo'), array('class' => 'refreshing_link', 'id' => 'refreshing_' . $partid)); //Output the links. $output .= $OUTPUT->box($messagesinbox . $emailnonsubmitters . $refreshlink . $refreshinglink, 'tii_table_functions', 'tii_table_functions_' . $partid); } } $output .= html_writer::alist($tabitems, array("id" => "part_tabs_menu")); $output .= $tables; $output .= $OUTPUT->box_end(true); return $output; }
public function moreactions() { $output = html_writer::start_tag('span', array('class' => 'mail_hidden singlebutton mail_button mail_more_actions')); $output .= html_writer::tag('span', get_string('moreactions', 'local_mail')); $url = $this->output->pix_url('t/expanded', 'moodle'); $output .= html_writer::empty_tag('img', array('src' => $url, 'alt' => 'expanded')); $output .= html_writer::end_tag('span'); // Menu options $output .= html_writer::start_tag('div', array('class' => 'mail_hidden mail_actselect')); $items = array( 'markasread' => get_string('markasread', 'local_mail'), 'markasunread' => get_string('markasunread', 'local_mail'), 'markasstarred' => get_string('markasstarred', 'local_mail'), 'markasunstarred' => get_string('markasunstarred', 'local_mail'), 'separator' => '', 'editlabel' => get_string('editlabel', 'local_mail'), 'removelabel' => get_string('removelabel', 'local_mail') ); foreach ($items as $key => $item) { $items[$key] = html_writer::link('#', $item, array('class' => 'mail_menu_action_' . $key)); } $output .= html_writer::alist($items, array('class' => 'mail_menu_actions')); $output .= html_writer::end_tag('div'); return $output; }
/** * Construct contents of course_overview_lite block * * @param array $courses list of courses in sorted order * @return string html to be displayed in course_overview block */ public function course_overview($courses, $overviews) { $editclass = $this->page->user_is_editing() ? 'ajax-edit' : ''; $html = html_writer::start_tag('div', array('id' => 'course_list_header')); $html .= html_writer::tag('span', get_string('currentcourses', 'block_course_overview_lite'), array('id' => 'course_overview_lite_legend', 'class' => 'currentcourse')); $tabs = array(html_writer::tag('div', get_string('tabsimple', 'block_course_overview_lite'), array('id' => 'course_overview_lite_hide_detailed', "class" => "selected")), html_writer::tag('div', get_string('tabdetailed', 'block_course_overview_lite'), array('id' => 'course_overview_lite_show_detailed'))); $html .= html_writer::alist($tabs, array("class" => "overview-tabs pull-left")); $html .= html_writer::end_tag('div'); $html .= html_writer::start_tag('div', array('id' => 'course_list', 'class' => $editclass)); $courseordernumber = 0; $maxcourses = count($courses); // Intialize string/icon etc if user is editing. $url = null; $hideurl = null; $moveicon = null; $hideicon = null; $showicon = null; $moveup[] = null; $movedown[] = null; if (empty($courses)) { $html .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $this->pix_url('i/loading')->out(false))), array('id' => 'ajaxcourse', 'class' => $editclass)); } else { if ($this->page->user_is_editing()) { $moveicon = html_writer::tag('div', html_writer::empty_tag('img', array('src' => $this->pix_url('i/move_2d')->out(false), 'alt' => get_string('move'), 'class' => 'cursor', 'title' => get_string('move'))), array('class' => 'move')); $hideicon = html_writer::empty_tag('img', array('src' => $this->pix_url('i/hide')->out(false), 'alt' => get_string('hide_icon_alt', 'block_course_overview_lite'), 'class' => 'hide_icon', 'align' => 'right', 'title' => get_string('hide_icon_alt', 'block_course_overview_lite'))); $showicon = html_writer::empty_tag('img', array('src' => $this->pix_url('i/show')->out(false), 'alt' => get_string('hide_icon_alt', 'block_course_overview_lite'), 'class' => 'hide_icon', 'align' => 'right', 'title' => get_string('hide_icon_alt', 'block_course_overview_lite'))); } } foreach ($courses as $key => $course) { // If the course is hidden, set its class to 'dimmed'. if ($course->userhidden) { if (!$this->page->user_is_editing()) { continue; } $classvisibility = " userhidden"; } else { $classvisibility = ""; } $class = $course->current ? 'coursebox currentcourse' : 'coursebox'; $class .= $classvisibility; $html .= $this->output->box_start($class, "course-{$course->id}"); $html .= html_writer::start_tag('div', array('class' => 'course_title')); // Ajax enabled then add moveicon html. if (!is_null($moveicon)) { $html .= $moveicon; } else { if (!is_null($url)) { // Add course id to move link. $url->param('source', $course->id); $html .= html_writer::start_tag('div', array('class' => 'moveicons')); // Add an arrow to move course up. if ($courseordernumber > 0) { $url->param('move', -1); $html .= html_writer::link($url, html_writer::empty_tag('img', array('src' => $moveup['icon'], 'class' => 'up', 'alt' => $moveup['str'])), array('title' => $moveup['str'], 'class' => 'moveup')); } else { // Add a spacer to keep keep down arrow icons at right position. $html .= html_writer::empty_tag('img', array('src' => $this->pix_url('spacer'), 'class' => 'movedownspacer')); } // Add an arrow to move course down. if ($courseordernumber <= $maxcourses - 2) { $url->param('move', 1); $html .= html_writer::link($url, html_writer::empty_tag('img', array('src' => $movedown['icon'], 'class' => 'down', 'alt' => $movedown['str'])), array('title' => $movedown['str'], 'class' => 'movedown')); } else { // Add a spacer to keep keep up arrow icons at right position. $html .= html_writer::empty_tag('img', array('src' => $this->pix_url('spacer'), 'class' => 'moveupspacer')); } $html .= html_writer::end_tag('div'); } } // Add hide icon to each course.. if ($this->page->user_is_editing()) { if ($course->userhidden) { $icon = $showicon; } else { $icon = $hideicon; } if (!is_null($icon)) { $html .= html_writer::start_tag('div', array("class" => "hide_course", "id" => $course->id)); if (is_null($hideurl)) { $html .= $icon; } else { $hideurl->param('toggle_hidden', $course->id); $html .= html_writer::link($hideurl, $icon); } $html .= html_writer::end_tag('div'); } } $attributes = array('title' => s($course->fullname)); if ($course->id > 0) { $coursefullname = format_string($course->fullname, true, $course->id); $course->hidden ? $attributes['class'] = 'dimmed_text' : false; $link = html_writer::link($course->url, $coursefullname, $attributes); $html .= $this->output->heading($link, 3, 'title'); } $html .= $this->output->box('', 'flush'); // Overview box. $html .= html_writer::start_tag('div', array('class' => 'activity_info hidden_overview', 'id' => "activity-overview-{$course->id}")); if (empty($overviews)) { $html .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $this->pix_url('i/loading_small')->out(false))), array('id' => 'ajaxoverview')); } else { if (!empty($overviews[$course->id])) { $output = ''; foreach (array_keys($overviews[$course->id]) as $module) { $output .= html_writer::start_tag('div', array('class' => 'activity_overview')); $output .= $overviews[$course->id][$module]; $output .= html_writer::end_tag('div'); } $html .= $output; } } $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('div'); $html .= $this->output->box('', 'flush'); $html .= $this->output->box_end(); $courseordernumber++; } $html .= html_writer::end_tag('div'); return $html; }
/** * render userbookings for the whole site sorted per user * @param array $userbookings * @return string rendered html */ public function render_bookings_per_user($userbookings) { $output = html_writer::div(' '); $items = array(); foreach ($userbookings as $userid => $options) { $items = array(); foreach ($options as $optionid => $user) { // if the user is visible in only one booking instance, than show the user otherwise do not show if ($user->status[$optionid]->bookingvisible) { $bookinginstanceurl = new moodle_url('/mod/booking/view.php', array('id' => $user->status[$optionid]->bookingcmid)); $bookingcourseurl = new moodle_url('/course/view.php', array('id' => $user->status[$optionid]->courseid)); $bookinglink = html_writer::link($bookinginstanceurl, $user->status[$optionid]->bookingtitle); $courselink = html_writer::link($bookingcourseurl, $user->status[$optionid]->coursename); $html = html_writer::span($user->status[$optionid]->bookingoptiontitle . " {$bookinglink}. {$courselink} " . get_string($user->status[$optionid]->booked, 'booking')); $items[] = $html; } } if (!empty($items)) { $user = reset($options); $output .= html_writer::tag('span', $this->output->user_picture($user) . " " . fullname($user)) . " "; $output .= html_writer::link('mailto:' . $user->email, $user->email); $output .= html_writer::alist($items); } } return $output; }
public function display_meeting_help($meetingdetail) { global $OUTPUT; $html = ''; $links = array(); if ($meetingdetail->ishost) { // Information and help links for adobe connect. if ($link1 = get_config('mod_adobeconnect', 'gettingstarted_host')) { $links[] = html_writer::link($link1, get_string('info_gettingstarted_host', 'adobeconnect')); } if ($link2 = get_config('mod_adobeconnect', 'troubleshooting_host')) { $links[] = html_writer::link($link2, get_string('info_troubleshooting_host', 'adobeconnect')); } if ($link3 = get_config('mod_adobeconnect', 'upcomingtraining_host')) { $links[] = html_writer::link($link3, get_string('info_upcomingtraining_host', 'adobeconnect')); } if ($link4 = get_config('mod_adobeconnect', 'outageschedule_host')) { $links[] = html_writer::link($link4, get_string('info_outageschedule_host', 'adobeconnect')); } } else { if ($meetingdetail->canjoin) { if ($link5 = get_config('mod_adobeconnect', 'gettingstarted_particpant')) { $links[] = html_writer::link($link5, get_string('info_gettingstarted_particpant', 'adobeconnect')); } if ($link6 = get_config('mod_adobeconnect', 'troubleshooting_particpant')) { $links[] = html_writer::link($link6, get_string('info_troubleshooting_particpant', 'adobeconnect')); } } } if (!empty($links)) { $html .= $OUTPUT->box_start('generalbox', 'links'); $html .= html_writer::tag('h3', get_string('info_hdr', 'adobeconnect')) . html_writer::alist($links); $html .= $OUTPUT->box_end(); } return $html; }
/** * Returns information about badge criteria in a list form. * * @param badge $badge Badge objects * @param string $short Indicates whether to print full info about this badge * @return string $output HTML string to output */ public function print_badge_criteria(badge $badge, $short = '') { $agg = $badge->get_aggregation_methods(); if (empty($badge->criteria)) { return get_string('nocriteria', 'badges'); } $overalldescr = ''; $overall = $badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]; if (!$short && !empty($overall->description)) { $overalldescr = $this->output->box(format_text($overall->description, $overall->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } // Get the condition string. if (count($badge->criteria) == 2) { $condition = ''; if (!$short) { $condition = get_string('criteria_descr', 'badges'); } } else { $condition = get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method()])); } unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); $items = array(); // If only one criterion left, make sure its description goe to the top. if (count($badge->criteria) == 1) { $c = reset($badge->criteria); if (!$short && !empty($c->description)) { $overalldescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $c->criteriatype, 'badges') . $c->get_details($short); } else { $items[] = get_string('criteria_descr_' . $short . $c->criteriatype, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($c->criteriatype)])) . $c->get_details($short); } } else { foreach ($badge->criteria as $type => $c) { $criteriadescr = ''; if (!$short && !empty($c->description)) { $criteriadescr = $this->output->box(format_text($c->description, $c->descriptionformat, array('context' => $badge->get_context())), 'criteria-description'); } if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short) . $criteriadescr; } else { $items[] = get_string('criteria_descr_' . $short . $type, 'badges', core_text::strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short) . $criteriadescr; } } } return $overalldescr . $condition . html_writer::alist($items, array(), 'ul'); }
/** * Get block content for unconnected users. * * @return string Block content. */ protected function get_content_notconnected() { $html = '<h5>' . get_string('notconnected', 'block_microsoft') . '</h5>'; $connecturl = new \moodle_url('/local/o365/ucp.php'); $connectstr = 'Connect to Office 365'; $items = [\html_writer::link($connecturl, $connectstr, ['class' => 'servicelink block_microsoft_connection']), $this->render_onenote()]; $html .= \html_writer::alist($items); return $html; }
/** * Get criteria details for displaying to users * * @return string */ public function get_details($short = '') { global $OUTPUT; $output = array(); foreach ($this->params as $p) { $str = self::get_role_name($p['role']); if (!$str) { $output[] = $OUTPUT->error_text(get_string('error:nosuchrole', 'badges')); } else { $output[] = $str; } } if ($short) { return implode(', ', $output); } else { return html_writer::alist($output, array(), 'ul'); } }
/** * Function to provide a display of how many open attempts have responded * * @param array $notresponded Array of the people who haven't responded * @param int $total * * @return string HTML fragment for the amount responded */ public function respondedbox($notresponded, $total) { $output = ''; $output .= html_writer::start_div(); $output .= html_writer::start_div('respondedbox', array('id' => 'respondedbox')); $output .= html_writer::tag('h3', get_string('notresponded', 'activequiz'), array('class' => 'inline')); $output .= html_writer::div(' ' . count($notresponded) . '/' . $total, 'inline'); $output .= html_writer::end_div(); // output the list of students, but only if we're not in anonymous mode if ($this->rtq->getRTQ()->anonymizeresponses == 0) { $output .= html_writer::start_div(); $output .= html_writer::alist($notresponded, array('id' => 'notrespondedlist')); $output .= html_writer::end_div(); } $output .= html_writer::end_div(); return $output; }
/** * entrywarnings * * @param xxx $hotpot * @return xxx */ public function entrywarnings($hotpot) { $warnings = array(); $canstart = true; if (!$hotpot->can_preview()) { if ($error = $hotpot->require_subnet()) { // IP-address is not in allowable range $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_isopen()) { // hotpot is not (yet) open $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_notclosed()) { // hotpot is (already) closed $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_entrycm()) { // minimum grade for previous activity not satisfied $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_delay('delay1')) { // delay1 has not expired yet $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_delay('delay2')) { // delay2 has not expired yet $warnings[] = $error; $canstart = false; } if ($error = $hotpot->require_moreattempts(true)) { // maximum number of attempts reached $warnings[] = $error; $canstart = false; } if ($canstart) { if ($error = $hotpot->require_password()) { // password not given yet $warnings[] = $error; $canstart = false; } } } // cache the boolean flags in case they are needed later - see $this->view_attempt_button() $hotpot->can_start($canstart); if (count($warnings)) { return $this->box(html_writer::alist($warnings), 'generalbox', 'hotpotwarnings'); } else { return ''; } }
/** * Render messages * * @param message_output_badge_model_message[] $messages * @return string */ public function messages(array $messages) { global $COURSE; $messagehtml = array(); foreach ($messages as $message) { $messagehtml[] = $this->render($message); } if ($this->is_mobile()) { if (empty($messages)) { return html_writer::link(new moodle_url('/course/view.php', array('id' => $COURSE->id)), get_string('nomorealerts', 'message_badge'), array('data-role' => 'button', 'data-icon' => 'home')); } if (!empty($this->page->theme->settings->mswatch)) { $showswatch = $this->page->theme->settings->mswatch; } else { $showswatch = ''; } if ($showswatch == 'lightblue') { $dtheme = 'b'; } else { if ($showswatch == 'darkgrey') { $dtheme = 'a'; } else { if ($showswatch == 'black') { $dtheme = 'a'; } else { if ($showswatch == 'lightgrey') { $dtheme = 'c'; } else { if ($showswatch == 'mediumgrey') { $dtheme = 'd'; } else { if ($showswatch == 'glassy') { $dtheme = 'j'; } else { if ($showswatch == 'yellow') { $dtheme = 'e'; } else { if ($showswatch == 'verydark') { $dtheme = 'a'; } else { if ($showswatch == 'mrooms') { $dtheme = 'm'; } else { $dtheme = 'm'; } } } } } } } } } return html_writer::alist($messagehtml, array('data-role' => 'listview', 'data-inset' => 'true', 'data-theme' => $dtheme, 'class' => 'message_badge_mobile_messages')); } if (!empty($messagehtml)) { $hide = ' message_badge_hidden'; } else { $hide = ''; } $messagehtml = implode('', $messagehtml); $messagehtml .= html_writer::tag('div', get_string('nomorealerts', 'message_badge'), array('class' => "message_badge_empty{$hide}")); $bddiv = html_writer::tag('div', $messagehtml, array('id' => html_writer::random_id(), 'class' => 'yui3-widget-bd message_badge_messages')); $ftdiv = html_writer::tag('div', '', array('id' => html_writer::random_id(), 'class' => 'yui3-widget-ft')); // GT MOD 2014-05-12 removed message_badge_hidden. $overlay = html_writer::tag('div', $bddiv . $ftdiv, array('id' => html_writer::random_id(), 'class' => 'message_badge_overlay')); return html_writer::tag('div', $overlay, array('id' => html_writer::random_id(), 'class' => 'message_badge_container')); }
/** * Returns a table showing which criteria were selected for printing, with confirmation buttons * * If any criteria have nothing selected, all reviews will be printed for that criterion * * @param array $sessions The sessions that were selected * @param array $students The students were selected * @param array $courses The courses that were selected * @param array $teachers The teachers that were selected * @param int $groupby The grouping mode selected * @return string The HTML for the form */ public function print_confirmation($sessions, $students, $courses, $teachers, $groupby) { $sessionnames = array(); $studentnames = array(); $coursenames = array(); $teachernames = array(); foreach ($sessions as $session) { $sessionnames[] = fullname($session); } foreach ($students as $student) { $studentnames[] = fullname($student); } foreach ($courses as $course) { $coursenames[] = fullname($course); } foreach ($teachers as $teacher) { $teachernames[] = fullname($teacher); } $table = new html_table(); $table->head = array(get_string('sessions', 'local_progressreview'), get_string('students', 'local_progressreview'), get_string('courses', 'local_progressreview'), get_string('teachers', 'local_progressreview'), get_string('groupby', 'local_progressreview')); $strall = get_string('all', 'local_progressreview'); if ($groupby === PROGRESSREVIEW_SUBJECT) { $strgroup = get_string('groupbysubject', 'local_progressreview'); } else { $strgroup = get_string('groupbystudent', 'local_progressreview'); } $table->data[] = new html_table_row(array(empty($sessionnames) ? $strall : html_writer::alist($sessionnames), empty($studentnames) ? $strall : html_writer::alist($studentnames), empty($coursenames) ? $strall : html_writer::alist($coursenames), empty($teachernames) ? $strall : html_writer::alist($teachernames), $strgroup)); $buttons = ''; $url = '/local/progressreview/print.php'; $backurl = new moodle_url($url); $confirmparams = array('sessions' => json_encode(array_keys($sessions)), 'students' => json_encode(array_keys($students)), 'courses' => json_encode(array_keys($courses)), 'teachers' => json_encode(array_keys($teachers)), 'groupby' => $groupby, 'generate' => true); $viewurl = new moodle_url($url, $confirmparams); $confirmparams['download'] = true; $downloadurl = new moodle_url($url, $confirmparams); $buttons .= $this->output->single_button($backurl, 'Back'); $generate = get_string('generateanddownload', 'local_progressreview'); $buttons .= $this->output->single_button($downloadurl, $generate, 'post'); $output = html_writer::table($table) . $buttons; return $output; }
/** * given an import code, commits all entries in buffer tables * (grade_import_value and grade_import_newitem) * If this function is called, we assume that all data collected * up to this point is fine and we can go ahead and commit * @param int courseid - id of the course * @param string importcode - import batch identifier * @param feedback print feedback and continue button * @return bool success */ function grade_import_commit($courseid, $importcode, $importfeedback = true, $verbose = true) { global $CFG, $USER, $DB, $OUTPUT; $failed = false; $executionerrors = false; $commitstart = time(); // start time in case we need to roll back $newitemids = array(); // array to hold new grade_item ids from grade_import_newitem table, mapping array /// first select distinct new grade_items with this batch $params = array($importcode, $USER->id); if ($newitems = $DB->get_records_sql("SELECT *\n FROM {grade_import_newitem}\n WHERE importcode = ? AND importer=?", $params)) { // instances of the new grade_items created, cached // in case grade_update fails, so that we can remove them $instances = array(); foreach ($newitems as $newitem) { // get all grades with this item $gradeimportparams = array('newgradeitem' => $newitem->id, 'importcode' => $importcode, 'importer' => $USER->id); if ($grades = $DB->get_records('grade_import_values', $gradeimportparams)) { /// create a new grade item for this - must use false as second param! /// TODO: we need some bounds here too $gradeitem = new grade_item(array('courseid' => $courseid, 'itemtype' => 'manual', 'itemname' => $newitem->itemname), false); $gradeitem->insert('import'); $instances[] = $gradeitem; // insert each individual grade to this new grade item foreach ($grades as $grade) { if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback, FORMAT_MOODLE)) { $failed = true; break 2; } } } } if ($failed) { foreach ($instances as $instance) { $gradeitem->delete('import'); } import_cleanup($importcode); return false; } } /// then find all existing items if ($gradeitems = $DB->get_records_sql("SELECT DISTINCT (itemid)\n FROM {grade_import_values}\n WHERE importcode = ? AND importer=? AND itemid > 0", array($importcode, $USER->id))) { $modifieditems = array(); foreach ($gradeitems as $itemid => $notused) { if (!($gradeitem = new grade_item(array('id' => $itemid)))) { // not supposed to happen, but just in case import_cleanup($importcode); return false; } // get all grades with this item $gradeimportparams = array('itemid' => $itemid, 'importcode' => $importcode, 'importer' => $USER->id); if ($grades = $DB->get_records('grade_import_values', $gradeimportparams)) { // make the grades array for update_grade foreach ($grades as $grade) { if (!$importfeedback) { $grade->feedback = false; // ignore it } if (!$gradeitem->update_final_grade($grade->userid, $grade->finalgrade, 'import', $grade->feedback)) { $errordata = new stdClass(); $errordata->itemname = $gradeitem->itemname; $errordata->userid = $grade->userid; $executionerrors[] = get_string('errorsettinggrade', 'grades', $errordata); $failed = true; break 2; } } //$itemdetails -> idnumber = $gradeitem->idnumber; $modifieditems[] = $itemid; } } if ($failed) { if ($executionerrors && $verbose) { echo $OUTPUT->notification(get_string('gradeimportfailed', 'grades')); foreach ($executionerrors as $errorstr) { echo $OUTPUT->notification($errorstr); } } import_cleanup($importcode); return false; } } if ($verbose) { echo $OUTPUT->notification(get_string('importsuccess', 'grades'), 'notifysuccess'); $unenrolledusers = get_unenrolled_users_in_import($importcode, $courseid); if ($unenrolledusers) { $list = array(); foreach ($unenrolledusers as $u) { $u->fullname = fullname($u); $list[] = get_string('usergrade', 'grades', $u); } echo $OUTPUT->notification(get_string('unenrolledusersinimport', 'grades', html_writer::alist($list)), 'notifysuccess'); } echo $OUTPUT->continue_button($CFG->wwwroot . '/grade/index.php?id=' . $courseid); } // clean up import_cleanup($importcode); return true; }
public function print_badge_criteria(badge $badge, $short = '') { $output = ""; $agg = $badge->get_aggregation_methods(); if (empty($badge->criteria)) { return get_string('nocriteria', 'badges'); } else { if (count($badge->criteria) == 2) { if (!$short) { $output .= get_string('criteria_descr', 'badges'); } } else { $output .= get_string('criteria_descr_' . $short . BADGE_CRITERIA_TYPE_OVERALL, 'badges', strtoupper($agg[$badge->get_aggregation_method()])); } } $items = array(); unset($badge->criteria[BADGE_CRITERIA_TYPE_OVERALL]); foreach ($badge->criteria as $type => $c) { if (count($c->params) == 1) { $items[] = get_string('criteria_descr_single_' . $short . $type, 'badges') . $c->get_details($short); } else { $items[] = get_string('criteria_descr_' . $short . $type, 'badges', strtoupper($agg[$badge->get_aggregation_method($type)])) . $c->get_details($short); } } $output .= html_writer::alist($items, array(), 'ul'); return $output; }
// Get all the users. $userlist = get_enrolled_users($coursecontext, '', $group, user_picture::fields('u', null, 0, 0, true)); // Get suspended users. $suspended = get_suspended_userids($coursecontext); $data = array(); foreach ($userlist as $user) { if (!in_array($user->id, $suspended)) { $item = $OUTPUT->user_picture($user, array('size' => 100, 'courseid' => $course->id)); $item .= html_writer::tag('span', fullname($user)); $data[] = $item; } } // Finish setting up page. $PAGE->set_title($course->shortname .': '. get_string('roster' , 'report_roster')); $PAGE->set_heading($course->fullname); $PAGE->requires->yui_module('moodle-report_roster-roster', 'M.report_roster.init'); $PAGE->requires->strings_for_js(array( 'learningmodeon', 'learningmodeoff', ), 'report_roster'); // Display the roster to the user. echo $OUTPUT->header(); echo html_writer::tag('button', get_string('learningmodeoff', 'report_roster'), array('id' => 'report-roster-toggle')); echo report_roster_output_action_buttons($id, $group, $mode, $PAGE->url); echo html_writer::alist($data, array('class' => 'report-roster')); echo $OUTPUT->footer();