/**
  *
  */
 public function get_replacements(array $patterns, $entry = null, array $options = array())
 {
     global $CFG, $OUTPUT;
     $replacements = parent::get_replacements($patterns, $entry, $options);
     $view = $this->_view;
     $df = $view->get_df();
     $filter = $view->get_filter();
     $baseurl = new moodle_url($view->get_baseurl());
     $baseurl->param('sesskey', sesskey());
     foreach ($patterns as $pattern) {
         switch ($pattern) {
             case '##exportall##':
                 $actionurl = new moodle_url($baseurl, array('pdfexportall' => true));
                 $label = html_writer::tag('span', get_string('exportall', 'dataformview_pdf'));
                 $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportall'));
                 break;
             case '##exportpage##':
                 $actionurl = new moodle_url($baseurl, array('pdfexportpage' => true));
                 $label = html_writer::tag('span', get_string('exportpage', 'dataformview_pdf'));
                 $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportpage'));
                 break;
             case '##pagebreak##':
                 $replacements[$pattern] = $view::PAGE_BREAK;
                 break;
         }
     }
     return $replacements;
 }
 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));
 }
Exemple #3
0
 public static function h($tag, $text = null, $options = array(), $escape_text = false) {
     $tag = htmlentities($tag);
     if(!empty($text) && $escape_text) {
             $text = htmlentities($text);
         }
     return html_writer::tag($tag, $text, $options);
 }
 public function subquestion(question_attempt $qa, question_display_options $options, qtype_combined_combinable_base $subq, $placeno)
 {
     $question = $subq->question;
     $place = $placeno + 1;
     $group = $question->places[$place];
     $fieldname = $subq->step_data_name($question->field($place));
     $value = $qa->get_last_qt_var($fieldname);
     $attributes = array('id' => str_replace(':', '_', $qa->get_qt_field_name($fieldname)));
     if ($options->readonly) {
         $attributes['disabled'] = 'disabled';
     }
     $orderedchoices = $question->get_ordered_choices($group);
     $selectoptions = array();
     foreach ($orderedchoices as $orderedchoicevalue => $orderedchoice) {
         $selectoptions[$orderedchoicevalue] = $orderedchoice->text;
     }
     $feedbackimage = '';
     if ($options->correctness) {
         $response = $qa->get_last_qt_data();
         if (array_key_exists($fieldname, $response)) {
             $fraction = (int) ($response[$fieldname] == $question->get_right_choice_for($place));
             $attributes['class'] = $this->feedback_class($fraction);
             $feedbackimage = $this->feedback_image($fraction);
         }
     }
     $selecthtml = html_writer::select($selectoptions, $qa->get_qt_field_name($fieldname), $value, get_string('choosedots'), $attributes) . ' ' . $feedbackimage;
     return html_writer::tag('span', $selecthtml, array('class' => 'control'));
 }
    function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0) {
        global $DB, $CFG;

        require_once("{$CFG->libdir}/completionlib.php");

        $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

        $info = new completion_info($course);

        // Is course complete?
        $coursecomplete = $info->is_course_complete($row->id);

        // Load course completion.
        $params = array(
            'userid' => $row->id,
            'course' => $course->id
        );
        $ccompletion = new completion_completion($params);

        // Has this user completed any criteria?
        $criteriacomplete = $info->count_course_user_data($row->id);

        $content = "";
        if ($coursecomplete) {
            $content .= get_string('complete');
        } else if (!$criteriacomplete && !$ccompletion->timestarted) {
            $content .= html_writer::tag('i', get_string('notyetstarted', 'completion'));
        } else {
            $content .= html_writer::tag('i', get_string('inprogress', 'completion'));
        }
        return $content;
    }
 protected function definition_inner($mform)
 {
     global $PAGE, $CFG;
     $PAGE->requires->js('/question/type/jme/jme_script.js');
     $PAGE->requires->css('/question/type/jme/styles.css');
     $mform->addElement('hidden', 'usecase', 1);
     $mform->setType('usecase', PARAM_INT);
     $optionscript = 'onClick = "setJSMEoptions()"';
     $label = get_string('jmeoptions', 'qtype_jme');
     $editoroptions[] = $mform->createElement('text', 'jmeoptions', '', array('size' => 50));
     $editoroptions[] = $mform->createElement('button', 'setoptions', get_string('setoptions', 'qtype_jme'), $optionscript);
     $mform->addElement('group', 'editoroptions', $label, $editoroptions, null, false);
     $mform->setDefault('jmeoptions', $CFG->qtype_jme_options);
     $mform->setType('jmeoptions', PARAM_RAW);
     $mform->addHelpButton('editoroptions', 'jmeoptions', 'qtype_jme');
     $mform->addElement('text', 'width', get_string('width', 'qtype_jme'), array('size' => 6));
     $mform->setDefault('width', QTYPE_JME_APPLET_WIDTH);
     $mform->setType('width', PARAM_INT);
     $mform->addElement('text', 'height', get_string('height', 'qtype_jme'), array('size' => 6));
     $mform->setDefault('height', QTYPE_JME_APPLET_HEIGHT);
     $mform->setType('height', PARAM_INT);
     $mform->addElement('static', 'answersinstruct', get_string('correctanswers', 'qtype_jme'), get_string('filloutoneanswer', 'qtype_jme'));
     $mform->addElement('html', html_writer::tag('div', get_string('enablejavascript', 'qtype_jme'), array('class' => 'jme_applet', 'code' => 'JME.class', 'id' => 'jme1', 'name' => 'JME1', 'archive' => 'JME.jar', 'width' => '360', 'height' => '315', 'style' => 'margin: 1.5em auto')));
     $mform->closeHeaderBefore('answersinstruct');
     $this->add_per_answer_fields($mform, get_string('answerno', 'qtype_jme', '{no}'), question_bank::fraction_options());
     $this->add_interactive_settings();
     // Include JSME loader script as an html tag.
     $jsmescript = $CFG->wwwroot . '/question/type/jme/jsme/jsme.nocache.js';
     $mform->addElement('html', html_writer::tag('script', '', array('src' => $jsmescript)));
 }
 /**
  * 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;
 }
Exemple #8
0
 /**
  * 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;
 }
Exemple #9
0
 /**
  * Generates the default entry template for a new view instance or when reseting an existing instance.
  *
  * @return void
  */
 public function set_default_entry_template($content = null)
 {
     // Get all the fields.
     if (!($fields = $this->df->field_manager->get_fields())) {
         return;
     }
     if ($content === null) {
         // Set content.
         $table = new html_table();
         $table->attributes['align'] = 'center';
         $table->attributes['cellpadding'] = '2';
         // Fields.
         foreach ($fields as $field) {
             if ($field->id > 0) {
                 $name = new html_table_cell($field->name . ':');
                 $name->style = 'text-align:right;';
                 $content = new html_table_cell("[[{$field->name}]]");
                 $row = new html_table_row();
                 $row->cells = array($name, $content);
                 $table->data[] = $row;
             }
         }
         // Actions.
         $row = new html_table_row();
         $entryactions = get_string('fieldname', 'dataformfield_entryactions');
         $actions = new html_table_cell("[[{$entryactions}:edit]]  [[{$entryactions}:delete]]");
         $actions->colspan = 2;
         $row->cells = array($actions);
         $table->data[] = $row;
         // Construct the table.
         $entrydefault = html_writer::table($table);
         $content = html_writer::tag('div', $entrydefault, array('class' => 'entry'));
     }
     $this->param2 = $content;
 }
 function get_content()
 {
     global $CFG, $USER, $DB, $OUTPUT;
     // shortcut -  only for logged in users!
     if (!isloggedin() || isguestuser()) {
         return false;
     }
     // according to start_jump_session,
     // remote users can't on-jump
     // so don't show this block to them
     if (is_mnet_remote_user($USER)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_localusersonly', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!is_enabled_auth('mnet')) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_authmnetneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
         if (debugging() and !empty($CFG->debugdisplay)) {
             $this->content = new stdClass();
             $this->content->footer = html_writer::tag('span', get_string('error_roamcapabilityneeded', 'block_mnet_hosts'), array('class' => 'error'));
             return $this->content;
         } else {
             return '';
         }
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     // TODO: Test this query - it's appropriate? It works?
     // get the hosts and whether we are doing SSO with them
     $sql = "\n             SELECT DISTINCT\n                 h.id,\n                 h.name,\n                 h.wwwroot,\n                 a.name as application,\n                 a.display_name\n             FROM\n                 {mnet_host} h,\n                 {mnet_application} a,\n                 {mnet_host2service} h2s_IDP,\n                 {mnet_service} s_IDP,\n                 {mnet_host2service} h2s_SP,\n                 {mnet_service} s_SP\n             WHERE\n                 h.id <> ? AND\n                 h.id <> ? AND\n                 h.id = h2s_IDP.hostid AND\n                 h.deleted = 0 AND\n                 h.applicationid = a.id AND\n                 h2s_IDP.serviceid = s_IDP.id AND\n                 s_IDP.name = 'sso_idp' AND\n                 h2s_IDP.publish = '1' AND\n                 h.id = h2s_SP.hostid AND\n                 h2s_SP.serviceid = s_SP.id AND\n                 s_SP.name = 'sso_idp' AND\n                 h2s_SP.publish = '1'\n             ORDER BY\n                 a.display_name,\n                 h.name";
     $hosts = $DB->get_records_sql($sql, array($CFG->mnet_localhost_id, $CFG->mnet_all_hosts_id));
     $this->content = new stdClass();
     $this->content->items = array();
     $this->content->icons = array();
     $this->content->footer = '';
     if ($hosts) {
         foreach ($hosts as $host) {
             $icon = '<img src="' . $OUTPUT->pix_url('i/' . $host->application . '_host') . '"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />&nbsp;';
             if ($host->id == $USER->mnethostid) {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . $icon . s($host->name) . "</a>";
             } else {
                 $this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . $icon . s($host->name) . "</a>";
             }
         }
     }
     return $this->content;
 }
Exemple #11
0
 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;
 }
 /**
  * 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');
     }
 }
 /**
  * Method to ensure that all names within the module
  * are outputted in the same manner
  * @global object $CFG Moodle config object
  * @param string $firstname First name
  * @param string $lastname Last name
  * @param string $username Username (where applicable)
  * @param string $company Name of company/institution (where applicable)
  * @param int $userId If user ID is present, usernames will become profile links
  * @param string $phoneNumber Phone number (where applicable)
  * @return string Formatted display string
  * @version 2012100401
  * @since 2011011401
  */
 public static final function formatNameForDisplay($firstname, $lastname, $username = null, $company = null, $userId = 0, $phoneNumber = null)
 {
     global $CFG;
     if ($firstname == '') {
         $firstname = get_string('fragunknownname', 'block_moodletxt');
     }
     if ($lastname == '') {
         $lastname = get_string('fragunknownname', 'block_moodletxt');
     }
     $displayName = $lastname . ', ' . $firstname;
     if ($company !== null) {
         $displayName .= ' (' . $company . ')';
     }
     if ($phoneNumber !== null) {
         $displayName .= ' (' . $phoneNumber . ')';
     }
     if ($username !== null) {
         if ($userId > 0) {
             $displayName .= ' ' . html_writer::tag('a', '(' . $username . ')', array('href' => $CFG->wwwroot . '/user/view.php?id=' . $userId));
         } else {
             $displayName .= ' (' . $username . ')';
         }
     }
     return $displayName;
 }
    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;
    }
Exemple #15
0
 /**
  * Either returns the parent version of the header bar, or a version with the logo replacing the header.
  *
  * @since Moodle 2.9
  * @param array $headerinfo An array of header information, dependant on what type of header is being displayed. The following
  *                          array example is user specific.
  *                          heading => Override the page heading.
  *                          user => User object.
  *                          usercontext => user context.
  * @param int $headinglevel What level the 'h' tag will be.
  * @return string HTML for the header bar.
  */
 public function context_header($headerinfo = null, $headinglevel = 1)
 {
     if ($headinglevel == 1 && !empty($this->page->theme->settings->logo)) {
         return html_writer::tag('div', '', array('class' => 'logo'));
     }
     return parent::context_header($headerinfo, $headinglevel);
 }
Exemple #16
0
 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;
      }
Exemple #17
0
/**
 *
 * Sends message to administrator listing all updated
 * duplicate custom fields
 * @param array $data
 */
function facetoface_send_admin_upgrade_msg($data)
{
    global $SITE;
    // No data - no need to send email.
    if (empty($data)) {
        return;
    }
    $table = new html_table();
    $table->head = array('Custom field ID', 'Custom field original shortname', 'Custom field new shortname');
    $table->data = $data;
    $table->align = array('center', 'center', 'center');
    $title = "{$SITE->fullname}: Face to Face upgrade info";
    $note = 'During the last site upgrade the face-to-face module has been modified. It now
requires session custom fields to have unique shortnames. Since some of your
custom fields had duplicate shortnames, they have been renamed to remove
duplicates (see table below). This could impact on your email messages if you
reference those custom fields in the message templates.';
    $message = html_writer::start_tag('html');
    $message .= html_writer::start_tag('head') . html_writer::tag('title', $title) . html_writer::end_tag('head');
    $message .= html_writer::start_tag('body');
    $message .= html_writer::tag('p', $note) . html_writer::table($table, true);
    $message .= html_writer::end_tag('body');
    $message .= html_writer::end_tag('html');
    $admin = get_admin();
    email_to_user($admin, $admin, $title, '', $message);
}
 /**
  * Search a list of modules.
  *
  * @param $modulecode
  * @return array [string]
  * @throws \invalid_parameter_exception
  */
 public static function get_submission_status($submissionid)
 {
     global $DB, $USER;
     $params = self::validate_parameters(self::get_submission_status_parameters(), array('submissionid' => $submissionid));
     $submissionid = $params['submissionid'];
     $submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $submissionid));
     if (!$submission) {
         return array('status' => 'error');
     }
     // Grab more data.
     $turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $submission->turnitintooltwoid));
     list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
     // Check this is our submission.
     if ($USER->id !== $submission->userid && !has_capability('mod/turnitintooltwo:grade', \context_module::instance($cm->id))) {
         return array('status' => 'nopermission');
     }
     // What is the status?
     $status = $DB->get_record('turnitintooltwo_sub_status', array('submissionid' => $submissionid));
     if (!$status) {
         return array('status' => 'queued');
     }
     // Decode the receipt.
     $digitalreceipt = (array) json_decode($status->receipt);
     // Woo!
     if ($status->status == \mod_turnitintooltwo\task\submit_assignment::STATUS_SUCCESS) {
         $turnitintooltwoview = new \turnitintooltwo_view();
         $digitalreceipt = $turnitintooltwoview->show_digital_receipt($digitalreceipt);
         $digitalreceipt = \html_writer::tag("div", $digitalreceipt, array("id" => "box_receipt"));
         return array('status' => 'success', 'message' => $digitalreceipt);
     }
     return array('status' => 'failed', 'message' => \html_writer::tag("div", $digitalreceipt["message"], array("class" => "alert alert-danger")));
 }
 /**
  * Generate the display of a question in a particular state, and with certain
  * display options. Normally you do not call this method directly. Intsead
  * you call {@link question_usage_by_activity::render_question()} which will
  * call this method with appropriate arguments.
  *
  * @param question_attempt $qa the question attempt to display.
  * @param qbehaviour_renderer $behaviouroutput the renderer to output the behaviour
  *      specific parts.
  * @param qtype_renderer $qtoutput the renderer to output the question type
  *      specific parts.
  * @param question_display_options $options controls what should and should not be displayed.
  * @param string|null $number The question number to display. 'i' is a special
  *      value that gets displayed as Information. Null means no number is displayed.
  * @return string HTML representation of the question.
  */
 public function question(question_attempt $qa, qbehaviour_renderer $behaviouroutput, qtype_renderer $qtoutput, question_display_options $options, $number)
 {
     //start a new output buffer
     $output = '';
     //add the quesiton number (TODO: style?)
     //$output .= '<strong>' . $number .'.</strong>&nbsp; &nbsp;';
     $output .= html_writer::start_tag('table', array('style' => 'width: 100%; padding-bottom: 4px;'));
     $output .= html_writer::start_tag('tr', array());
     $output .= html_writer::tag('td', $number . '.', array('valign' => 'top', 'width' => '10%', 'style' => 'padding-right: 10px;'));
     $output .= html_writer::start_tag('td', array('width' => '90%'));
     //get the question from the attempt object
     $question = $qa->get_question();
     $pragmas = self::extract_pragmas($question->format_questiontext($qa));
     //add the question's formulation
     $output .= $this->formulation($qa, $behaviouroutput, $qtoutput, $options);
     //an indication of output, if appropriate
     $output .= $this->outcome($qa, $behaviouroutput, $qtoutput, $options);
     //any manual comments, if appropriate
     $output .= $this->manual_comment($qa, $behaviouroutput, $qtoutput, $options);
     //the user's response history, if appropriate
     $output .= $this->response_history($qa, $behaviouroutput, $qtoutput, $options);
     $output .= html_writer::end_tag('td');
     $output .= html_writer::end_tag('tr');
     $output .= html_writer::end_tag('table');
     //if a pragma exists specifying the space after a given quesiton, use it; otherwise, assume 5px
     //$space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : '5px';
     $space_after = array_key_exists('space_after', $pragmas) ? $pragmas['space_after'] : 0;
     //and add a spacer after the given question
     if ($space_after !== 0) {
         $output .= html_writer::tag('div', '&nbsp;', array('style' => 'height: ' . $space_after . ';'));
     }
     //return the contents of the output buffer
     return $output;
 }
Exemple #20
0
 /**
  * Form element definition
  */
 public function definition()
 {
     $form = $this->_form;
     $form->addElement('hidden', 'areaid');
     $form->setType('areaid', PARAM_INT);
     $form->addElement('hidden', 'returnurl');
     $form->setType('returnurl', PARAM_LOCALURL);
     // name
     $form->addElement('text', 'name', get_string('name', 'gradingform_rubric'), array('size' => 52, 'aria-required' => 'true'));
     $form->addRule('name', get_string('required'), 'required', null, 'client');
     $form->setType('name', PARAM_TEXT);
     // description
     $options = gradingform_rubric_controller::description_form_field_options($this->_customdata['context']);
     $form->addElement('editor', 'description_editor', get_string('description', 'gradingform_rubric'), null, $options);
     $form->setType('description_editor', PARAM_RAW);
     // rubric completion status
     $choices = array();
     $choices[gradingform_controller::DEFINITION_STATUS_DRAFT] = html_writer::tag('span', get_string('statusdraft', 'core_grading'), array('class' => 'status draft'));
     $choices[gradingform_controller::DEFINITION_STATUS_READY] = html_writer::tag('span', get_string('statusready', 'core_grading'), array('class' => 'status ready'));
     $form->addElement('select', 'status', get_string('rubricstatus', 'gradingform_rubric'), $choices)->freeze();
     // rubric editor
     $element = $form->addElement('rubriceditor', 'rubric', get_string('rubric', 'gradingform_rubric'));
     $form->setType('rubric', PARAM_RAW);
     $buttonarray = array();
     $buttonarray[] =& $form->createElement('submit', 'saverubric', get_string('saverubric', 'gradingform_rubric'));
     if ($this->_customdata['allowdraft']) {
         $buttonarray[] =& $form->createElement('submit', 'saverubricdraft', get_string('saverubricdraft', 'gradingform_rubric'));
     }
     $editbutton =& $form->createElement('submit', 'editrubric', ' ');
     $editbutton->freeze();
     $buttonarray[] =& $editbutton;
     $buttonarray[] =& $form->createElement('cancel');
     $form->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $form->closeHeaderBefore('buttonar');
 }
Exemple #21
0
/**
 * Prints the 'All A B C ...' alphabetical filter bar.
 *
 * @param object $moodle_url the moodle url object for the alpha/letter links
 * @param string $pname      the parameter name to be appended to the moodle_url
 *                           i.e. 'pname=alpha'
 * @param string $label      optional label - defaults to none
 */
function pmalphabox($moodle_url, $pname = 'alpha', $label = null)
{
    $alpha = optional_param($pname, null, PARAM_ALPHA);
    $alphabet = explode(',', get_string('alphabet', 'langconfig'));
    $strall = get_string('all');
    echo html_writer::start_tag('div', array('style' => 'text-align:center'));
    if (!empty($label)) {
        echo $label, ' ';
        // TBD: html_writer::???
    }
    if ($alpha) {
        $url = clone $moodle_url;
        // TBD
        $url->remove_params($pname);
        echo html_writer::link($url, $strall);
    } else {
        echo html_writer::tag('b', $strall);
    }
    foreach ($alphabet as $letter) {
        if ($letter == $alpha) {
            echo ' ', html_writer::tag('b', $letter);
        } else {
            $url = clone $moodle_url;
            // TBD
            // Set current page to 0
            $url->params(array($pname => $letter, 'page' => 0));
            echo ' ', html_writer::link($url, $letter);
        }
    }
    echo html_writer::end_tag('div');
}
 public function apply($discussion, $all, $selected, $formdata)
 {
     global $COURSE, $USER, $CFG, $PAGE;
     $d = $discussion->get_id();
     $forum = $discussion->get_forum();
     $PAGE->set_pagelayout('embedded');
     $out = mod_forumng_utils::get_renderer();
     print $out->header();
     $backlink = new moodle_url('/mod/forumng/discuss.php', $discussion->get_link_params_array());
     print html_writer::start_tag('div', array('class' => 'forumng-printable-header'));
     print html_writer::tag('div', link_arrow_left($discussion->get_subject(), $backlink), array('class' => 'forumng-printable-backlink'));
     print html_writer::tag('div', get_string('printedat', 'forumngfeature_print', userdate(time())), array('class' => 'forumng-printable-date'));
     print html_writer::tag('div', '', array('class' => 'clearer'));
     print "\n";
     print $out->box(get_string('back', 'forumngfeature_print', $backlink->out()), 'generalbox forumng-donotprint');
     print html_writer::start_tag('div', array('class' => 'forumng-showprintable'));
     if ($all) {
         print $out->render_discussion($discussion, array(mod_forumng_post::OPTION_NO_COMMANDS => true, mod_forumng_post::OPTION_CHILDREN_EXPANDED => true, mod_forumng_post::OPTION_PRINTABLE_VERSION => true));
     } else {
         $allhtml = '';
         $alltext = '';
         $discussion->build_selected_posts_email($selected, $alltext, $allhtml, array(mod_forumng_post::OPTION_PRINTABLE_VERSION));
         print $allhtml;
     }
     print html_writer::end_tag('div');
     $forum->print_js(0, false);
     print $out->footer();
 }
Exemple #23
0
 /**
  * Render a series of section links.
  *
  * @param stdClass $course The course we are rendering for.
  * @param array $sections An array of section objects to render.
  * @param bool|int The section to provide a jump to link for.
  * @return string The HTML to display.
  */
 public function render_section_links(stdClass $course, array $sections, $jumptosection = false)
 {
     $html = html_writer::start_tag('ol', array('class' => 'inline-list'));
     foreach ($sections as $section) {
         $attributes = array();
         if (!$section->visible) {
             $attributes['class'] = 'dimmed';
         }
         $html .= html_writer::start_tag('li');
         $sectiontext = $section->section;
         if ($section->highlight) {
             $sectiontext = html_writer::tag('strong', $sectiontext);
         }
         $html .= html_writer::link(course_get_url($course, $section->section), $sectiontext, $attributes);
         $html .= html_writer::end_tag('li') . ' ';
     }
     $html .= html_writer::end_tag('ol');
     if ($jumptosection && isset($sections[$jumptosection])) {
         if ($course->format == 'weeks') {
             $linktext = new lang_string('jumptocurrentweek', 'block_section_links');
         } else {
             if ($course->format == 'topics') {
                 $linktext = new lang_string('jumptocurrenttopic', 'block_section_links');
             }
         }
         $attributes = array();
         if (!$sections[$jumptosection]->visible) {
             $attributes['class'] = 'dimmed';
         }
         $html .= html_writer::link(course_get_url($course, $jumptosection), $linktext, $attributes);
     }
     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;
 }
Exemple #25
0
    /**
     * Either returns the parent version of the header bar, or a version with the logo replacing the header.
     *
     * @since Moodle 2.9
     * @param array $headerinfo An array of header information, dependant on what type of header is being displayed. The following
     *                          array example is user specific.
     *                          heading => Override the page heading.
     *                          user => User object.
     *                          usercontext => user context.
     * @param int $headinglevel What level the 'h' tag will be.
     * @return string HTML for the header bar.
     */
    public function context_header($headerinfo = null, $headinglevel = 1) {

        if ($this->should_render_logo($headinglevel)) {
            return html_writer::tag('div', '', array('class' => 'logo'));
        }
        return parent::context_header($headerinfo, $headinglevel);
    }
Exemple #26
0
    /**
     * Display the listing of registered on hub
     */
    public function registeredonhublisting($hubs) {
        global $CFG;
        $table = new html_table();
        $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
        $table->size = array('80%', '20%');

        foreach ($hubs as $hub) {
            if ($hub->huburl == HUB_MOODLEORGHUBURL) {
                $hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
            }
            $hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
            $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));

            $unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
                            array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
                                'unregistration' => 1));
            $unregisterbutton = new single_button($unregisterhuburl,
                            get_string('unregister', 'hub'));
            $unregisterbutton->class = 'centeredbutton';
            $unregisterbuttonhtml = $this->output->render($unregisterbutton);

            //add button cells
            $cells = array($hublinkcell, $unregisterbuttonhtml);
            $row = new html_table_row($cells);
            $table->data[] = $row;
        }

        return html_writer::table($table);
    }
Exemple #27
-1
    /**
     * 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;
    }
Exemple #28
-1
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;
}
Exemple #29
-1
 /**
  * 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;
 }
Exemple #30
-2
 function attendance_alerts($userid)
 {
     global $DB;
     $sessions_sql = "SELECT ff.*, fsd.*, ffs.id AS sessid\n                           FROM {facetoface} as ff\n                           JOIN {facetoface_sessions} as ffs\n                             ON ffs.facetoface = ff.id\n                           JOIN {facetoface_sessions_dates} as fsd\n                             ON fsd.sessionid = ffs.id\n                          WHERE ff.trainerid = :traineeid\n                            AND ffs.attendence_status = :status\n                          LIMIT 5\n                        ";
     $sessions = $DB->get_records_sql($sessions_sql, array('traineeid' => $userid, 'status' => 0));
     if (empty($sessions)) {
         return get_string('nosessions', 'block_attendance');
     } else {
         $table = new html_table();
         $table->id = 'trainerfeedbak_batches';
         $table->width = '100%';
         $table->head = array(get_string('sessiondetails', 'block_attendance'), '');
         foreach ($sessions as $session) {
             $row = array();
             $sess_data = html_writer::start_tag('ul');
             $sess_data .= html_writer::tag('li', $session->name);
             $session_date = date('d/m/y', $session->timestart) . ' - ' . date('d/m/y', $session->timefinish);
             $sess_data .= html_writer::tag('li', $session_date);
             $sess_data .= html_writer::end_tag('ul');
             $row[] = $sess_data;
             $session_url = new moodle_url('/mod/facetoface/attendence.php', array('s' => $session->sessid));
             $row[] = html_writer::link($session_url, get_string('view'));
             $table->data[] = $row;
         }
         return html_writer::table($table);
     }
 }