/** * Form definition * * @uses $CFG */ public function definition() { // if there are no rows in the table, return. // (won't be rows if both olduser and newuser are NULL in session stdClass) if (empty($this->urt->data)) { return ''; } $mform =& $this->_form; // header $mform->addElement('header', 'reviewusers', get_string('userreviewtable_legend', 'tool_mergeusers')); // table content $mform->addElement('static', 'reviewuserslist', '', html_writer::table($this->urt)); // buttons // set up url here so the same url can be used more than once $mergeurl = new moodle_url('/admin/tool/mergeusers/index.php'); $buttonarray = array(); if ($this->review_step) { $mergeurl->param('option', 'mergeusers'); $mergeusersbutton = new single_button($mergeurl, get_string('mergeusers', 'tool_mergeusers')); $mergeusersbutton->add_confirm_action(get_string('mergeusers_confirm', 'tool_mergeusers')); $buttonarray[0][] = $this->output->render($mergeusersbutton); } else { if (count($this->urt->data) === 2) { $mergeurl->param('option', 'continueselection'); $mergeusersbutton = new single_button($mergeurl, get_string('saveselection_submit', 'tool_mergeusers')); $buttonarray[0][] = $this->output->render($mergeusersbutton); } } $mergeurl->param('option', 'clearselection'); $mergeusersbutton = new single_button($mergeurl, get_string('clear_selection', 'tool_mergeusers')); $buttonarray[0][] = $this->output->render($mergeusersbutton); if ($this->review_step) { $mergeurl->param('option', 'searchusers'); $mergeusersbutton = new single_button($mergeurl, get_string('cancel')); $buttonarray[0][] = $this->output->render($mergeusersbutton); } $htmltable = new html_table(); $htmltable->attributes['class'] = 'clearfix'; $htmltable->data = $buttonarray; $mform->addElement('static', 'buttonar', '', html_writer::table($htmltable)); $mform->closeHeaderBefore('buttonar'); }
} if (has_capability('mod/workshop:overridegrades', $workshop->context)) { print_collapsible_region_start('', 'workshop-viewlet-cleargrades', get_string('toolbox', 'workshop'), false, true); echo $output->box_start('generalbox toolbox'); // Clear aggregated grades $url = new moodle_url($workshop->toolbox_url('clearaggregatedgrades')); $btn = new single_button($url, get_string('clearaggregatedgrades', 'workshop'), 'post'); $btn->add_confirm_action(get_string('clearaggregatedgradesconfirm', 'workshop')); echo $output->container_start('toolboxaction'); echo $output->render($btn); echo $output->help_icon('clearaggregatedgrades', 'workshop'); echo $output->container_end(); // Clear assessments $url = new moodle_url($workshop->toolbox_url('clearassessments')); $btn = new single_button($url, get_string('clearassessments', 'workshop'), 'post'); $btn->add_confirm_action(get_string('clearassessmentsconfirm', 'workshop')); echo $output->container_start('toolboxaction'); echo $output->render($btn); echo $output->help_icon('clearassessments', 'workshop'); echo html_writer::empty_tag('img', array('src' => $output->pix_url('i/risk_dataloss'), 'title' => get_string('riskdatalossshort', 'admin'), 'alt' => get_string('riskdatalossshort', 'admin'), 'class' => 'workshop-risk-dataloss')); echo $output->container_end(); echo $output->box_end(); print_collapsible_region_end(); } if (has_capability('mod/workshop:submit', $PAGE->context)) { print_collapsible_region_start('', 'workshop-viewlet-ownsubmission', get_string('yoursubmission', 'workshop')); echo $output->box_start('generalbox ownsubmission'); if ($submission = $workshop->get_submission_by_author($USER->id)) { echo $output->render($workshop->prepare_submission_summary($submission, true)); } else { echo $output->container(get_string('noyoursubmission', 'workshop'));
echo $OUTPUT->confirm('This is the message', $continueurl, $cancelurl); echo html_writer::tag('p', 'A confirm form with continue/cancel options (with custom buttons):'); $continueurl = new moodle_url('index.php'); $cancelurl = new moodle_url('index.php'); $continuebutton = new single_button($continueurl, 'Custom Button text', 'post'); $cancelbutton = new single_button($cancelurl, 'Something else', 'get'); echo $OUTPUT->confirm('This is another message', $continuebutton, $cancelbutton); echo html_writer::tag('p', 'A standalone single button. This is still wrapped in a form so you can submit it. There are a couple of ways to generate, via a function call:'); echo $OUTPUT->single_button($continueurl, 'A disabled button', 'post', array('disabled' => true)); echo html_writer::tag('p', 'Or manually create object then render. Note this uses a confirm dialog, try pressing to see popup (needs styling)'); // render directly $button = new single_button($continueurl, 'Manually rendered button', 'post'); $button->tooltip = 'This is the tooltip'; $button->formid = 'canbeset'; $button->class = 'classonbutton'; $button->add_confirm_action('This message appears to confirm when you push the button'); echo $OUTPUT->render($button); echo html_writer::tag('p', 'A single select form. Quick way using a function:'); $url = new moodle_url('index.php', array('urlparams' => 'become', 'hidden' => 'fields')); $options = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four'); echo $OUTPUT->single_select($url, 'youpicked', $options, '', array('' => 'choose'), 'formid'); echo html_writer::tag('p', 'A single select form. Manually rendered:'); $select = new single_select($url, 'youpicked', $options); $select->set_label('This is a label for the select'); $select->tooltip = 'This is the tooltip'; //this doesn't seem to work - moodle bug? //$select->add_confirm_action('Confirm you want to do this'); $select->set_help_icon('activities', 'moodle'); echo $OUTPUT->render($select); echo html_writer::tag('p', 'A url select form. Typically used for navigation.'); $urls = array('/admin/tool/elementlibrary/' => 'Index', '/admin/tool/elementlibrary/common.php' => 'Common elements', '/admin/tool/elementlibrary/mform.php' => 'Moodle form elements', '/admin/tool/elementlibrary/tables.php' => 'Tables', '/admin/tool/elementlibrary/tabs.php' => 'Tabs');
/** * Creates any controls a the page should have. * * @param quiz_attempt $attemptobj */ public function summary_page_controls($attemptobj) { $output = ''; // countdown timer $output .= $this->countdown_timer(); // Finish attempt button. $output .= $this->container_start('submitbtns mdl-align'); $options = array( 'attempt' => $attemptobj->get_attemptid(), 'finishattempt' => 1, 'timeup' => 0, 'slots' => '', 'sesskey' => sesskey(), ); $button = new single_button( new moodle_url($attemptobj->processattempt_url(), $options), get_string('submitallandfinish', 'quiz')); $button->id = 'responseform'; $button->add_confirm_action(get_string('confirmclose', 'quiz')); $output .= $this->container_start('controls'); $output .= $this->render($button); $output .= $this->container_end(); $output .= $this->container_end(); return $output; }
public function print_start_attempt_button($canpreview, $buttontext, $unfinished) { global $OUTPUT; $url = $this->_quizobj->start_attempt_url(); $button = new single_button($url, $buttontext); $button->class .= ' quizstartbuttondiv'; if (!$unfinished) { $strconfirmstartattempt = $this->confirm_start_attempt_message(); if ($strconfirmstartattempt) { $button->add_confirm_action($strconfirmstartattempt); } } $warning = ''; if ($this->securewindow_required($canpreview)) { $button->class .= ' quizsecuremoderequired'; $button->add_action(new popup_action('click', $url, 'quizpopup', securewindow_access_rule::$popupoptions)); $warning = html_writer::tag('noscript', $OUTPUT->heading(get_string('noscript', 'quiz'))); } return $OUTPUT->render($button) . $warning; }
foreach ($attemptobj->get_question_iterator() as $number => $question) { if ($question->length == 0) { continue; } $flag = ''; if ($attemptobj->is_question_flagged($question->id)) { $flag = ' <img src="' . $OUTPUT->pix_url('i/flagged') . '" alt="' . get_string('flagged', 'question') . '" class="questionflag" />'; } $row = array('<a href="' . s($attemptobj->attempt_url($question->id)) . '">' . $number . $flag . '</a>', get_string($attemptobj->get_question_status($question->id), 'quiz')); if ($scorescolumn) { $row[] = $attemptobj->get_question_score($question->id); } $table->data[] = $row; } /// Print the summary table. echo html_writer::table($table); /// countdown timer echo $attemptobj->get_timer_html(); /// Finish attempt button. echo $OUTPUT->container_start('submitbtns mdl-align'); $options = array('attempt' => $attemptobj->get_attemptid(), 'finishattempt' => 1, 'timeup' => 0, 'questionids' => '', 'sesskey' => sesskey()); $button = new single_button(new moodle_url($attemptobj->processattempt_url(), $options), get_string('submitallandfinish', 'quiz')); $button->id = 'responseform'; $button->add_confirm_action(get_string('confirmclose', 'quiz')); echo $OUTPUT->container_start('controls'); echo $OUTPUT->render($button); echo $OUTPUT->container_end(); echo $OUTPUT->container_end(); /// Finish the page $accessmanager->show_attempt_timer_if_needed($attemptobj->get_attempt(), time()); echo $OUTPUT->footer();