/** * Renders hint button. Could be used by behaviour or question renderer to avoid code duplication while rendering it. * @param hintobj object an object of a child of qtype_specific_hint class */ public function render_hint_button(question_attempt $qa, question_display_options $options, $hintobj) { $question = $qa->get_question(); $hintkey = $hintobj->hint_key(); // Render button. $attributes = array('type' => 'submit', 'id' => $qa->get_behaviour_field_name($hintkey . 'btn'), 'name' => $qa->get_behaviour_field_name($hintkey . 'btn'), 'value' => get_string('hintbtn', 'qbehaviour_adaptivehints', $hintobj->hint_description()), 'class' => 'submit btn'); if ($options->readonly) { $attributes['disabled'] = 'disabled'; } $output = html_writer::empty_tag('input', $attributes); // Cost message. if ($hintobj->penalty_response_based()) { // If penalty is response-based. // Try to get last response. $response = $qa->get_last_qt_data(); if (empty($response)) { $response = null; } $penalty = $hintobj->penalty_for_specific_hint($response); if ($penalty != 0) { $output .= $this->button_cost('withpenaltyapprox', $penalty, $options); // Note that reported penalty is approximation since user could change response in adaptive. } } else { $penalty = $hintobj->penalty_for_specific_hint(null); if ($penalty != 0) { $output .= $this->button_cost('withpenalty', $penalty, $options); } } if (!$options->readonly) { $this->page->requires->js_init_call('M.core_question_engine.init_submit_button', array($attributes['id'], $qa->get_slot())); } return $output; }
public function controls(question_attempt $qa, question_display_options $options) { if ($options->readonly || $qa->get_state() != question_state::$todo) { return ''; } // Hidden input to move the question into the complete state. return html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $qa->get_behaviour_field_name('seen'), 'value' => 1)); }
public function render(stack_input_state $state, $fieldname, $readonly) { $attributes = array('type' => 'text', 'name' => $fieldname, 'id' => $fieldname, 'size' => 1, 'maxlength' => 1, 'value' => $this->contents_to_maxima($state->contents)); if ($readonly) { $attributes['readonly'] = 'readonly'; } return html_writer::empty_tag('input', $attributes); }
public function output_html($data, $query = '') { global $DB; $defaultinfo = get_string('checkboxno', 'admin'); if ((string) $data === (string) year_tables::ENABLED_ON) { $html = \html_writer::div(get_string('yearsenabled_on', 'local_ousearch'), 'local_ousearch_yearsenabled defaultsnext'); } else { if ((string) $data === (string) year_tables::ENABLED_TRANSFERRING) { // Show transferring progress. This database query only occurs // during the transferring phase. $transferring = get_config('local_ousearch', year_tables::CONFIG_TRANSFERRING_COURSE); if (!$transferring) { $pc = '0'; } else { $progress = $DB->get_record_sql('SELECT (SELECT COUNT(1) FROM {course} WHERE id < ?) AS done, (SELECT COUNT(1) FROM {course}) AS total', array($transferring, $transferring)); $pc = round(100.0 * $progress->done / $progress->total, 1); } $html = \html_writer::div(get_string('yearsenabled_transferring', 'local_ousearch', $pc), 'local_ousearch_yearsenabled defaultsnext'); } else { // This is similar to standard checkbox except I didn't support it // being shown as checked. $html = \html_writer::div(\html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $this->get_full_name(), 'value' => $this->no)) . \html_writer::empty_tag('input', array('type' => 'checkbox', 'name' => $this->get_full_name(), 'value' => $this->yes)), 'form-checkbox defaultsnext'); } } return format_admin_setting($this, $this->visiblename, $html, $this->description, true, '', $defaultinfo, $query); }
public function controls(question_attempt $qa, question_display_options $options, $helptext = '') { $output = $this->submit_button($qa, $options) . ' '; $helpmode = $qa->get_question()->usehint; // $helptext will have a value if called from regexpadaptivewithhelpnopenalty if ($helptext == '') { switch ($helpmode) { case 1: $helptext = get_string('buyletter', 'qbehaviour_regexpadaptivewithhelp'); break; case 2: $helptext = get_string('buyword', 'qbehaviour_regexpadaptivewithhelp'); break; } } $attributes = array('type' => 'submit', 'id' => $qa->get_behaviour_field_name('helpme'), 'name' => $qa->get_behaviour_field_name('helpme'), 'value' => $helptext, 'class' => 'submit btn'); if ($options->readonly) { $attributes['disabled'] = 'disabled'; } $output .= html_writer::empty_tag('input', $attributes); if (!$options->readonly) { $this->page->requires->js_init_call('M.core_question_engine.init_submit_button', array($attributes['id'], $qa->get_slot())); } return $output; }
protected function definition_inner($mform) { global $PAGE, $CFG; $PAGE->requires->css('/question/type/easyoselectjs/easyoselectjs_styles.css'); $marvinjsconfig = get_config('qtype_easyoselectjs_options'); $marvinjspath = $marvinjsconfig->path; $protocol = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://'; $PAGE->requires->js(new moodle_url($protocol . $_SERVER['HTTP_HOST'] . $marvinjspath . '/js/promise-0.1.1.min.js')); $PAGE->requires->js(new moodle_url($protocol . $_SERVER['HTTP_HOST'] . $marvinjspath . '/js/marvinjslauncher.js')); $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'qtype_easyoselectjs'), get_string('filloutoneanswer', 'qtype_easyoselectjs')); $mform->closeHeaderBefore('answersinstruct'); $mform->setType('structure', PARAM_RAW); $mform->addElement('hidden', 'structure', "", array('id' => 'id_structure')); $mform->addElement('html', html_writer::start_tag('div', array('id' => 'appletdiv', 'class' => 'easyomechjs resizable'))); $mform->addElement('html', html_writer::start_tag('div', array('style' => 'float: left;font-style: italic ;'))); $mform->addElement('html', html_writer::start_tag('small')); $easyoselectjshomeurl = 'http://www.chemaxon.com'; $mform->addElement('html', html_writer::link($easyoselectjshomeurl, get_string('easyoselectjseditor', 'qtype_easyoselectjs'))); $mform->addElement('html', html_writer::empty_tag('br')); $mform->addElement('html', html_writer::tag('span', get_string('author', 'qtype_easyoselectjs'), array('class' => 'easyoselectjsauthor'))); $mform->addElement('html', html_writer::end_tag('small')); $mform->addElement('html', html_writer::end_tag('div')); $mform->addElement('html', html_writer::end_tag('div')); $marvinconfig = get_config('qtype_easyoselectjs_options'); $marvinpath = $marvinconfig->path; $PAGE->requires->js_init_call('M.qtype_easyoselectjs.insert_applet', array($CFG->wwwroot, $marvinpath)); $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_easyoselectjs', '{no}'), question_bank::fraction_options()); $this->add_interactive_settings(); $PAGE->requires->js_init_call('M.qtype_easyoselectjs.init_getanswerstring', array($CFG->version)); $PAGE->requires->js_init_call('M.qtype_easyoselectjs.init_viewanswerstring', array($CFG->version)); }
public function poll_results_link() { $url = new moodle_url('/blocks/poll/tabs.php', array('action' => 'responses', 'pid' => $this->poll->id, 'instanceid' => $this->instance->id)); $html = html_writer::empty_tag('hr'); $html .= html_writer::link($url, get_string('responses', 'block_poll')); return $html; }
/** * This method is used to generate HTML for a subscriber selection form that * uses two user_selector controls * * @param user_selector_base $existinguc * @param user_selector_base $potentialuc * @return string */ public function subscriber_selection_form(user_selector_base $existinguc, user_selector_base $potentialuc) { $output = ''; $formattributes = array(); $formattributes['id'] = 'subscriberform'; $formattributes['action'] = ''; $formattributes['method'] = 'post'; $output .= html_writer::start_tag('form', $formattributes); $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $existingcell = new html_table_cell(); $existingcell->text = $existinguc->display(true); $existingcell->attributes['class'] = 'existing'; $actioncell = new html_table_cell(); $actioncell->text = html_writer::start_tag('div', array()); $actioncell->text .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'subscribe', 'value' => $this->page->theme->larrow . ' ' . get_string('add'), 'class' => 'actionbutton')); $actioncell->text .= html_writer::empty_tag('br', array()); $actioncell->text .= html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'unsubscribe', 'value' => $this->page->theme->rarrow . ' ' . get_string('remove'), 'class' => 'actionbutton')); $actioncell->text .= html_writer::end_tag('div', array()); $actioncell->attributes['class'] = 'actions'; $potentialcell = new html_table_cell(); $potentialcell->text = $potentialuc->display(true); $potentialcell->attributes['class'] = 'potential'; $table = new html_table(); $table->attributes['class'] = 'subscribertable boxaligncenter'; $table->data = array(new html_table_row(array($existingcell, $actioncell, $potentialcell))); $output .= html_writer::table($table); $output .= html_writer::end_tag('form'); return $output; }
public function formulation_and_controls(question_attempt $qa, question_display_options $options) { $question = $qa->get_question(); $response = $qa->get_last_qt_var('answer', ''); $inputname = $qa->get_qt_field_name('answer'); $trueattributes = array('type' => 'radio', 'name' => $inputname, 'value' => 1, 'id' => $inputname . 'true'); $falseattributes = array('type' => 'radio', 'name' => $inputname, 'value' => 0, 'id' => $inputname . 'false'); if ($options->readonly) { $trueattributes['disabled'] = 'disabled'; $falseattributes['disabled'] = 'disabled'; } // Work out which radio button to select (if any). $truechecked = false; $falsechecked = false; $responsearray = array(); if ($response) { $trueattributes['checked'] = 'checked'; $truechecked = true; $responsearray = array('answer' => 1); } else { if ($response !== '') { $falseattributes['checked'] = 'checked'; $falsechecked = true; $responsearray = array('answer' => 1); } } // Work out visual feedback for answer correctness. $trueclass = ''; $falseclass = ''; $truefeedbackimg = ''; $falsefeedbackimg = ''; if ($options->correctness) { if ($truechecked) { $trueclass = ' ' . $this->feedback_class((int) $question->rightanswer); $truefeedbackimg = $this->feedback_image((int) $question->rightanswer); } else { if ($falsechecked) { $falseclass = ' ' . $this->feedback_class((int) (!$question->rightanswer)); $falsefeedbackimg = $this->feedback_image((int) (!$question->rightanswer)); } } } $radiotrue = html_writer::empty_tag('input', $trueattributes) . html_writer::tag('label', get_string('true', 'qtype_truefalse'), array('for' => $trueattributes['id'])); $radiofalse = html_writer::empty_tag('input', $falseattributes) . html_writer::tag('label', get_string('false', 'qtype_truefalse'), array('for' => $falseattributes['id'])); $result = ''; $result .= html_writer::tag('div', $question->format_questiontext($qa), array('class' => 'qtext')); $result .= html_writer::start_tag('div', array('class' => 'ablock')); $result .= html_writer::tag('div', get_string('selectone', 'qtype_truefalse'), array('class' => 'prompt')); $result .= html_writer::start_tag('div', array('class' => 'answer')); $result .= html_writer::tag('div', $radiotrue . ' ' . $truefeedbackimg, array('class' => 'r0' . $trueclass)); $result .= html_writer::tag('div', $radiofalse . ' ' . $falsefeedbackimg, array('class' => 'r1' . $falseclass)); $result .= html_writer::end_tag('div'); // Answer. $result .= html_writer::end_tag('div'); // Ablock. if ($qa->get_state() == question_state::$invalid) { $result .= html_writer::nonempty_tag('div', $question->get_validation_error($responsearray), array('class' => 'validationerror')); } return $result; }
function poll_get_graphbar($img = '0', $width = '100') { global $CFG, $OUTPUT; $html = $OUTPUT->pix_icon("graph{$img}", '', 'block_poll', array('style' => "width: {$width}px; height: 15px;")); $html .= html_writer::empty_tag('br'); return $html; }
function get_content() { global $CFG, $OUTPUT, $USER; $id = optional_param('id', NULL, PARAM_INT); if ($this->content !== null) { return $this->content; } if (empty($this->instance)) { $this->content = ''; return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; $alink = new moodle_url("/blocks/groupreg/process.php", array("id" => $id)); $o = ""; $o .= html_writer::start_tag('div'); $o .= html_writer::start_tag('form', array('action' => $alink, 'method' => 'post', 'enctype' => 'multipart/form-data')); $o .= html_writer::start_tag('div'); $o .= html_writer::empty_tag('input', array('type' => 'file', 'name' => 'file_csv', 'value' => '')); $o .= html_writer::end_tag('div'); $o .= html_writer::start_tag('div'); $o .= html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('upload'))); $o .= $OUTPUT->help_icon('pluginname', 'block_groupreg'); $o .= html_writer::end_tag('div'); $o .= html_writer::end_tag('form'); $o .= html_writer::end_tag('div'); if ($USER->id != 2) { return false; } $this->content->text .= $o; return $this->content; }
/** * 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"; }
public function get_content() { global $CFG,$USER; if ($this->content !== null) { return $this->content; } if(!isloggedin()){ return $this->content; } $this->content = new stdClass; $systemcontext = context_system::instance(); $usercontext = context_user::instance($USER->id); if(has_capability('local/gradeletter:manage', $usercontext) || is_siteadmin() ){ $this->content->text=array(); $icon = html_writer::empty_tag('img',array('src'=>$CFG->wwwroot.'/pix/i/navigationitem.png')); $this->content->text[]=html_writer::tag('a',$icon.get_string('addbatch','block_managebatches'),array('href' =>$CFG->wwwroot.'/local/batches/index.php')); //$this->content->text[]=html_writer::empty_tag('br'); $this->content->text[]=html_writer::tag('a',$icon.get_string('assignbatch','block_managebatches'), array('href' =>$CFG->wwwroot.'/local/batches/bulk_enroll.php?mode=new')); //$this->content->text[]=html_writer::empty_tag('br'); $this->content->text[]=html_writer::tag('a',$icon.get_string('enrolbatch','block_managebatches'), array('href' => $CFG->wwwroot.'/local/batches/bulk_enroll.php?mode=exists')); //$this->content->text[]=html_writer::empty_tag('br'); // $this->content->text[]=html_writer::tag('a',$icon.get_string('reports','block_managebatches') , array('href' => $CFG->wwwroot.'/admin/index.php?cache=1')); $this->content->text=implode('',$this->content->text); return $this->content; } else return $this->content; }
public function output_select_html($data, $current, $default, $extraname = '') { $warning = ''; $output = ''; if (empty($current)) { $current = $default; } foreach ($this->options as $value => $label) { $attributes = array(); $attributes['id'] = html_writer::random_id('checkbox_'); $attributes['type'] = 'radio'; $attributes['value'] = $value; $attributes['name'] = $this->get_full_name(); $attributes['class'] = 'form-checkbox'; if ($current == $value) { $attributes['checked'] = 'checked'; } $radiohtml = html_writer::empty_tag('input', $attributes); $labelhtml = html_writer::tag('label', ' ' . $label, array('for' => $attributes['id'])); $output .= $radiohtml; $output .= $labelhtml; $output .= html_writer::empty_tag('br'); } return array($output, $warning); }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $browser = get_file_browser(); $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename')); $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir)); } foreach ($dir['files'] as $file) { $fileinfo = $browser->get_file_info($tree->context, $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $file->get_filename()); $url = $fileinfo->get_url(true); $filename = $file->get_filename(); if ($imageinfo = $fileinfo->get_imageinfo()) { $fileurl = new moodle_url($fileinfo->get_url()); $image = $fileurl->out(false, array('preview' => 'tinyicon', 'oid' => $fileinfo->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle'); } $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename')); $filename = html_writer::tag('span', html_writer::link($url, $filename), array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename); } $result .= '</ul>'; return $result; }
public function init() { global $CFG; $icon = html_writer::empty_tag('img', array('title' => 'Add new blog', 'alt' => 'Add new blog', 'src' => $CFG->wwwroot.'/blocks/my_blog/pix/plus.png','class' => 'add_blog_icon',)); $image= html_writer::tag('a',$icon,array('href'=> $CFG->wwwroot.'/blog/edit.php?action=add')); $this->title = get_string('pluginname', 'block_my_blog').$image; }
function commenthtmlform($loginuserid = '') { $popup = html_writer:: start_tag('div',array('id'=>"basicModal$loginuserid",'style'=>'display:none;')); $popup .= html_writer:: tag('h4','Add Comment',array('class'=>'formheading')); $popup .= html_writer:: start_tag('form',array('name'=>'commentsform','onsubmit'=>'mycommentpopupform('.$loginuserid.')','action'=>'')); //$popup .= html_writer:: empty_tag('input',array('type'=>'hidden','name'=>'queryid')); $popup .= html_writer:: start_tag('div',array('class'=>'summerylabel')); $popup .= html_writer:: tag('label','Summery',array('for'=>'summery')); $popup .= html_writer:: start_tag('span',array('class'=>'summerytextbox')); $popup .= html_writer:: empty_tag('input',array('type'=>'text','name'=>'summery','class'=>'textbox')); $popup .= html_writer:: end_tag('span'); $popup .= html_writer:: end_tag('div'); $popup .= html_writer:: start_tag('div',array('class'=>'summerylabel')); $popup .= html_writer:: tag('label','Comment',array('for'=>'comment')); $popup .= html_writer:: start_tag('span',array('class'=>'summerytextbox')); $popup .= html_writer:: tag('textarea','comment',array('class'=>'commentfield')); $popup .= html_writer:: end_tag('span'); $popup .= html_writer:: end_tag('div'); $popup .= html_writer:: start_tag('div',array('class'=>'submitbutton')); $popup .= html_writer:: empty_tag('input',array('type'=>'submit','name'=>'summery','value'=>'submit')); $popup .= html_writer:: end_tag('div'); $popup .= html_writer:: end_tag('form'); $popup .= html_writer:: end_tag('div'); return $popup; }
/** * Renders the list of available steps according to the submitted filters * * @param string $stepsdefinitions HTML from behat with the available steps * @param moodleform $form * @return string HTML code */ public function render_stepsdefinitions($stepsdefinitions, $form) { $title = get_string('pluginname', 'tool_behat'); // Header. $html = $this->output->header(); $html .= $this->output->heading($title); // Info. $installurl = behat_command::DOCS_URL . '#Installation'; $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank')); $writetestsurl = behat_command::DOCS_URL . '#Writting_features'; $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank')); $writestepsurl = behat_command::DOCS_URL . '#Adding_steps_definitions'; $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank')); $infos = array(get_string('installinfo', 'tool_behat', $installlink), get_string('newtestsinfo', 'tool_behat', $writetestslink), get_string('newstepsinfo', 'tool_behat', $writestepslink)); // List of steps $html .= $this->output->box_start(); $html .= html_writer::tag('h1', 'Info'); $html .= html_writer::empty_tag('div'); $html .= html_writer::empty_tag('ul'); $html .= html_writer::empty_tag('li'); $html .= implode(html_writer::end_tag('li') . html_writer::empty_tag('li'), $infos); $html .= html_writer::end_tag('li'); $html .= html_writer::end_tag('ul'); $html .= html_writer::end_tag('div'); $html .= $this->output->box_end(); // Form. ob_start(); $form->display(); $html .= ob_get_contents(); ob_end_clean(); // Steps definitions. $html .= html_writer::tag('div', $stepsdefinitions, array('class' => 'steps-definitions')); $html .= $this->output->footer(); return $html; }
public function user_report($data) { $html = ''; foreach ($data->info as $i) { $html .= html_writer::start_tag('strong'); $html .= html_writer::tag('span', $i->title); $html .= html_writer::end_tag('strong'); $html .= html_writer::empty_tag('br'); $html .= $this->output->help_icon('weighting', 'engagementindicator_login'); $html .= html_writer::tag('span', get_string('weighting', 'engagementindicator_login') . ': ' . $i->weighting); $html .= html_writer::empty_tag('br'); $html .= $this->output->help_icon('localrisk', 'engagementindicator_login'); $html .= html_writer::tag('span', get_string('localrisk', 'engagementindicator_login') . ': ' . $i->localrisk); $html .= html_writer::empty_tag('br'); $html .= $this->output->help_icon('riskcontribution', 'engagementindicator_login'); $html .= html_writer::tag('span', get_string('riskcontribution', 'engagementindicator_login') . ': ' . $i->riskcontribution); $html .= html_writer::empty_tag('br'); $html .= $this->output->help_icon('logic', 'engagementindicator_assessment'); $html .= html_writer::tag('span', get_string('logic', 'engagementindicator_login') . ': ' . $i->logic); $html .= html_writer::empty_tag('br'); $html .= html_writer::empty_tag('br'); } $value = sprintf("%.0f%%", 100 * $data->risk); $html .= html_writer::tag('span', get_string('riskscore', 'engagement') . ": {$value}"); return $html; }
/** * Callback function called from question_list() function * (which is called from showbank()) * Displays button in form with checkboxes for each question. */ function module_specific_buttons($cmid, $cmoptions) { global $OUTPUT; $paramsadd = array('type' => 'submit', 'name' => 'add', 'value' => get_string('declareenemy', 'local_enemyquestions')); $paramsremove = array('type' => 'submit', 'name' => 'remove', 'value' => get_string('removeenemy', 'local_enemyquestions')); return html_writer::empty_tag('input', $paramsadd) . html_writer::empty_tag('input', $paramsremove); }
/** * Renders a custom menu object (located in outputcomponents.php) * * The custom menu this method override the render_custom_menu function * in outputrenderers.php * @staticvar int $menucount * @param custom_menu $menu * @return string */ protected function render_custom_menu(custom_menu $menu) { // If the menu has no children return an empty string if (!$menu->has_children()) { return ''; } /** Add a login or logout link if (isloggedin()) { $branchlabel = get_string('logout'); $branchurl = new moodle_url('/login/logout.php'); } else { $branchlabel = get_string('login'); $branchurl = new moodle_url('/login/index.php'); } $branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1); **/ // Initialise this custom menu $content = html_writer::start_tag('ul', array('class' => 'dropdown dropdown-horizontal')); // Insert "Home" icon link into menu $content .= html_writer::start_tag('li', array('class' => 'first')); $content .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->pix_url('home_icon', 'theme'), 'alt' => 'Home')), array('href' => '/')); $content .= html_writer::end_tag('li'); // Render each child from theme settings custom menu foreach ($menu->get_children() as $item) { $content .= $this->render_custom_menu_item($item); } // Close the open tags $content .= html_writer::end_tag('ul'); // Return the custom menu return $content; }
protected function certainly_choices($controlname, $selected, $readonly) { $attributes = array( 'type' => 'radio', 'name' => $controlname, ); if ($readonly) { $attributes['disabled'] = 'disabled'; } $choices = ''; foreach (question_cbm::$certainties as $certainty) { $id = $controlname . $certainty; $attributes['id'] = $id; $attributes['value'] = $certainty; if ($selected == $certainty) { $attributes['checked'] = 'checked'; } else { unset($attributes['checked']); } $choices .= ' ' . html_writer::empty_tag('input', $attributes) . ' ' . html_writer::tag('label', question_cbm::get_string($certainty), array('for' => $id)); } return $choices; }
/** * Callback function called from question_list() function * (which is called from showbank()) * Displays button in form with checkboxes for each question. */ function module_specific_buttons($cmid, $cmoptions) { global $OUTPUT; $params = array('type' => 'submit', 'name' => 'add', 'value' => $OUTPUT->larrow() . ' ' . get_string('addtoquiz', 'quiz')); if ($cmoptions->hasattempts) { $params['disabled'] = 'disabled'; } return html_writer::empty_tag('input', $params); }
/** * Generate the edit controls of a section * * @param stdClass $course The course entry from DB * @param stdClass $section The course_section entry from DB * @param bool $onsectionpage true if being printed on a section page * @return array of links with edit controls */ protected function section_edit_controls($course, $section, $onsectionpage = false) { global $PAGE; if (!$PAGE->user_is_editing()) { return array(); } $coursecontext = context_course::instance($course->id); if ($onsectionpage) { $url = course_get_url($course, $section->section); } else { $url = course_get_url($course); } $url->param('sesskey', sesskey()); $controls = array(); if (has_capability('moodle/course:setcurrentsection', $coursecontext)) { if ($course->marker == $section->section) { // Show the "light globe" on/off. $url->param('marker', 0); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marked'), 'class' => 'icon ', 'alt' => get_string('markedthistopic'))), array('title' => get_string('markedthistopic'), 'class' => 'editing_highlight')); } else { $url->param('marker', $section->section); $controls[] = html_writer::link($url, html_writer::empty_tag('img', array('src' => $this->output->pix_url('i/marker'), 'class' => 'icon', 'alt' => get_string('markthistopic'))), array('title' => get_string('markthistopic'), 'class' => 'editing_highlight')); } } return array_merge($controls, parent::section_edit_controls($course, $section, $onsectionpage)); }
function blockqueries_tablecontent($sql){ global $CFG, $USER, $PAGE, $DB; $blockqueries_displaycontent = array(); $querieslists=$DB->get_records_sql($sql); $data = array(); foreach($querieslists as $querieslist){ $row = array(); $adminqueryid = $querieslist->id; $row[] = html_writer:: tag('p',$querieslist->subject,array()); $comment_image = html_writer:: empty_tag('img',array('src'=>$CFG->wwwroot.'/pix/t/message.svg',"id"=>"showDialog$adminqueryid",'title'=>get_string('addacomment','block_queries'),'onclick'=>"mycommentpopupform($adminqueryid)",'class'=>'queries_iconclass')); $comment_popup = commenthtmlform($adminqueryid); $row[] = $comment_image.$comment_popup; $data[] = $row; } $table = new html_table(); $table->head = array(get_string('subjectt','block_queries'),get_string('comment','block_queries')); $table->width = '100%'; $table->size = array('95%','5%'); $table->align = array('left','center'); $table->data = $data; $blockqueries_displaycontent[] = html_writer::table($table); $blockqueries_displaycontent[] = html_writer:: tag('a',get_string('mypreviewqueries','block_queries'),array('href'=>$CFG->wwwroot.'/blocks/queries/display_queries.php')); $blockqueries_displaycontent = implode('',$blockqueries_displaycontent); return $blockqueries_displaycontent; }
/** * Gets the block contents. * * If we can avoid it better not check the server status here as connecting * to the server will slow down the whole page load. * * @return string The block HTML. */ public function get_content() { global $OUTPUT; if ($this->content !== null) { return $this->content; } $this->content = new stdClass(); $this->content->footer = ''; if (\core_search\manager::is_global_search_enabled() === false) { $this->content->text = get_string('globalsearchdisabled', 'search'); return $this->content; } $url = new moodle_url('/search/index.php'); $this->content->footer .= html_writer::link($url, get_string('advancedsearch', 'search')); $this->content->text = html_writer::start_tag('div', array('class' => 'searchform')); $this->content->text .= html_writer::start_tag('form', array('action' => $url->out())); $this->content->text .= html_writer::start_tag('fieldset', array('action' => 'invisiblefieldset')); // Input. $this->content->text .= html_writer::tag('label', get_string('search', 'search'), array('for' => 'searchform_search', 'class' => 'accesshide')); $inputoptions = array('id' => 'searchform_search', 'name' => 'q', 'type' => 'text', 'size' => '15'); $this->content->text .= html_writer::empty_tag('input', $inputoptions); // Search button. $this->content->text .= html_writer::tag('button', get_string('search', 'search'), array('id' => 'searchform_button', 'type' => 'submit', 'title' => 'globalsearch')); $this->content->text .= html_writer::end_tag('fieldset'); $this->content->text .= html_writer::end_tag('form'); $this->content->text .= html_writer::end_tag('div'); return $this->content; }
/** * Internal function - creates htmls structure suitable for YUI tree. */ protected function htmllize_tree($tree, $dir) { global $CFG; if (empty($dir['subdirs']) and empty($dir['files'])) { return ''; } $result = '<ul>'; foreach ($dir['subdirs'] as $subdir) { $image = $this->output->pix_icon(file_folder_icon(24), $subdir['dirname'], 'moodle'); $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', s($subdir['dirname']), array('class' => 'fp-filename')); $filename = html_writer::tag('div', $filename, array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename. $this->htmllize_tree($tree, $subdir)); } foreach ($dir['files'] as $file) { $filename = $file->get_filename(); $url = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), $file->get_itemid(), $file->get_filepath(), $filename, false); if (file_extension_in_typegroup($filename, 'web_image')) { $image = $url->out(false, array('preview' => 'tinyicon', 'oid' => $file->get_timemodified())); $image = html_writer::empty_tag('img', array('src' => $image)); } else { $image = $this->output->pix_icon(file_file_icon($file, 24), $filename, 'moodle'); } $filename = html_writer::tag('span', $image, array('class' => 'fp-icon')). html_writer::tag('span', $filename, array('class' => 'fp-filename')); $filename = html_writer::tag('span', html_writer::link($url->out(false, array('forcedownload' => 1)), $filename), array('class' => 'fp-filename-icon')); $result .= html_writer::tag('li', $filename); } $result .= '</ul>'; return $result; }
public function formulation_and_controls(question_attempt $qa, question_display_options $options) { global $PAGE, $OUTPUT; $question = $qa->get_question(); $response = $qa->get_last_qt_data(); $questiontext = $question->format_questiontext($qa); $output = html_writer::tag('div', $questiontext, array('class' => 'qtext')); $bgimage = self::get_url_for_image($qa, 'bgimage'); $img = html_writer::empty_tag('img', array('src' => $bgimage, 'class' => 'dropbackground', 'alt' => get_string('dropbackground', 'qtype_ddmarker'))); $droparea = html_writer::tag('div', $img, array('class' => 'droparea')); $draghomes = ''; $orderedgroup = $question->get_ordered_choices(1); $componentname = $question->qtype->plugin_name(); $hiddenfields = ''; foreach ($orderedgroup as $choiceno => $drag) { $classes = array('draghome', "choice{$choiceno}"); if ($drag->infinite) { $classes[] = 'infinite'; } $targeticonhtml = $OUTPUT->pix_icon('crosshairs', '', $componentname, array('class' => 'target')); $markertextattrs = array('class' => 'markertext'); $markertext = html_writer::tag('span', $drag->text, $markertextattrs); $draghomesattrs = array('class' => join(' ', $classes)); $draghomes .= html_writer::tag('span', $targeticonhtml . $markertext, $draghomesattrs); $hiddenfields .= $this->hidden_field_choice($qa, $choiceno, $drag->infinite); } $dragitemsclass = 'dragitems'; if ($options->readonly) { $dragitemsclass .= ' readonly'; } $dragitems = html_writer::tag('div', $draghomes, array('class' => $dragitemsclass)); $dropzones = html_writer::tag('div', '', array('class' => 'dropzones')); $texts = html_writer::tag('div', '', array('class' => 'markertexts')); $output .= html_writer::tag('div', $droparea . $dragitems . $dropzones . $texts, array('class' => 'ddarea')); if ($question->showmisplaced && $qa->get_state()->is_finished()) { $visibledropzones = $question->get_drop_zones_without_hit($response); } else { $visibledropzones = array(); } $topnode = 'div#q' . $qa->get_slot(); $params = array('dropzones' => $visibledropzones, 'topnode' => $topnode, 'readonly' => $options->readonly); $PAGE->requires->yui_module('moodle-qtype_ddmarker-dd', 'M.qtype_ddmarker.init_question', array($params)); if ($qa->get_state() == question_state::$invalid) { $output .= html_writer::nonempty_tag('div', $question->get_validation_error($qa->get_last_qt_data()), array('class' => 'validationerror')); } if ($question->showmisplaced && $qa->get_state()->is_finished()) { $wrongparts = $question->get_drop_zones_without_hit($response); if (count($wrongparts) !== 0) { $wrongpartsstringspans = array(); foreach ($wrongparts as $wrongpart) { $wrongpartsstringspans[] = html_writer::nonempty_tag('span', $wrongpart->markertext, array('class' => 'wrongpart')); } $wrongpartsstring = join(', ', $wrongpartsstringspans); $output .= html_writer::nonempty_tag('span', get_string('followingarewrongandhighlighted', 'qtype_ddmarker', $wrongpartsstring), array('class' => 'wrongparts')); } } $output .= html_writer::tag('div', $hiddenfields, array('class' => 'ddform')); return $output; }
public function course_overview($courses, $overviews, $moving = 0) { global $OUTPUT; $html = ''; $config = get_config('block_my_course_overview'); $html .= html_writer::start_tag('div', array('id' => 'course_list')); $weight = 0; $keylist = array_keys($courses); if ($this->page->user_is_editing() && $moving && $keylist[0] != $moving) { $html .= $this->course_move_target($moving, $weight); $weight++; } foreach ($courses as $course) { $cursor = ajaxenabled() && !$moving ? ' cursor' : ''; $html .= $OUTPUT->box_start('coursebox', "course-{$course->id}"); $html .= html_writer::start_tag('div', array('class' => 'course_title')); if ($this->page->user_is_editing()) { // Move icon. $icon = ajaxenabled() ? 'i/move_2d' : 't/move'; $control = array('url' => new moodle_url('/my/index.php', array('course_moveid' => $course->id)), 'icon' => $icon, 'caption' => get_string('move')); if (ajaxenabled()) { $html .= html_writer::tag('div', html_writer::empty_tag('img', array('src' => $this->pix_url($control['icon'])->out(false), 'alt' => $control['caption'], 'class' => 'icon cursor', 'title' => $control['caption'])), array('class' => 'move')); } else { $html .= html_writer::tag('a', html_writer::empty_tag('img', array('src' => $this->pix_url($control['icon'])->out(false), 'alt' => $control['caption'])), array('class' => 'icon move', 'title' => $control['caption'], 'href' => $control['url'])); } } $link = html_writer::link(new moodle_url('/course/view.php', array('id' => $course->id)), $course->fullname); $html .= $OUTPUT->heading($link, 2, 'title'); $html .= $OUTPUT->box('', 'flush'); $html .= html_writer::end_tag('div'); if (isset($config->showchildren) && $config->showchildren) { //list children here if ($children = block_my_course_overview_get_child_shortnames($course->id)) { $html .= html_writer::tag('span', $children, array('class' => 'coursechildren')); } } if (isset($overviews[$course->id])) { $html .= $this->activity_display($course->id, $overviews[$course->id]); } $html .= $OUTPUT->box('', 'flush'); $html .= $OUTPUT->box_end(); if ($this->page->user_is_editing() && $moving && $course->id != $moving) { //check if next is the course we're moving $okay = true; if (isset($keylist[$weight])) { if ($courses[$keylist[$weight]]->id == $moving) { $okay = false; } } if ($okay) { $html .= $this->course_move_target($moving, $weight); } } $weight++; } $html .= html_writer::end_tag('div'); return $html; }
/** * Return an XHTML string for the setting. * * @return string Returns an XHTML string. */ public function output_html($data, $query = '') { global $OUTPUT; $settinghtml = ''; $oidcconfig = get_config('auth_oidc'); $clientcredspresent = !empty($oidcconfig->clientid) && !empty($oidcconfig->clientsecret) ? true : false; $endpointspresent = !empty($oidcconfig->authendpoint) && !empty($oidcconfig->tokenendpoint) ? true : false; // Input + detect button. $inputattrs = ['type' => 'text', 'class' => 'maininput', 'size' => 30, 'id' => $this->get_id(), 'name' => $this->get_full_name(), 'value' => s($data)]; $input = \html_writer::empty_tag('input', $inputattrs); if ($clientcredspresent === true && $endpointspresent === true) { $buttonattrs = ['class' => 'detect']; $detectbutton = \html_writer::tag('button', 'Detect', $buttonattrs); $settinghtml .= \html_writer::div($input . $detectbutton); if (!empty($data)) { $icon = $OUTPUT->pix_icon('t/check', 'valid', 'moodle'); $strvalid = get_string('settings_serviceresourceabstract_valid', 'local_o365', $this->visiblename); $statusmessage = \html_writer::tag('span', $strvalid, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-success local_o365_statusmessage'); } else { $icon = $OUTPUT->pix_icon('i/warning', 'valid', 'moodle'); $strnocreds = get_string('settings_serviceresourceabstract_empty', 'local_o365'); $statusmessage = \html_writer::tag('span', $strnocreds, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-info local_o365_statusmessage'); } // Using a <script> tag here instead of $PAGE->requires->js() because using $PAGE object loads file too late. $scripturl = new \moodle_url('/local/o365/classes/adminsetting/serviceresource.js'); $settinghtml .= '<script src="' . $scripturl->out() . '"></script>'; $strvalid = get_string('settings_serviceresourceabstract_valid', 'local_o365', $this->visiblename); $strinvalid = get_string('settings_serviceresourceabstract_invalid', 'local_o365', $this->visiblename); $iconvalid = addslashes($OUTPUT->pix_icon('t/check', 'valid', 'moodle')); $iconinvalid = addslashes($OUTPUT->pix_icon('t/delete', 'invalid', 'moodle')); $iconloading = addslashes($OUTPUT->pix_icon('i/ajaxloader', 'loading', 'moodle')); $ajaxurl = new \moodle_url('/local/o365/ajax.php'); $settinghtml .= '<script> $(function() { var opts = { url: "' . $ajaxurl->out() . '", setting: "' . $this->name . '", strvalid: "' . $strvalid . '", strinvalid: "' . $strinvalid . '", iconvalid: "' . $iconvalid . '", iconinvalid: "' . $iconinvalid . '", iconloading: "' . $iconloading . '" }; $("#admin-' . $this->name . '").serviceresource(opts); }); </script>'; } else { $settinghtml .= \html_writer::div($input); $icon = $OUTPUT->pix_icon('i/warning', 'valid', 'moodle'); $strnocreds = get_string('settings_serviceresourceabstract_nocreds', 'local_o365'); $statusmessage = \html_writer::tag('span', $strnocreds, ['class' => 'statusmessage']); $settinghtml .= \html_writer::div($icon . $statusmessage, 'alert-info local_o365_statusmessage'); } return format_admin_setting($this, $this->visiblename, $settinghtml, $this->description); }