/** * Function that can be used in various parts of the quiz code. * @param object $quiz * @param integer $cmid * @param object $question * @param string $returnurl url to return to after action is done. * @return string html for a number of icons linked to action pages for a * question - preview and edit / view icons depending on user capabilities. */ function qcreate_question_action_icons($cmid, $question, $returnurl) { global $CFG, $COURSE; static $stredit = null; static $strview = null; static $strpreview = null; static $strdelete = null; if ($stredit === null) { $stredit = get_string('edit'); $strview = get_string('view'); $strpreview = get_string('preview', 'quiz'); $strdelete = get_string("delete"); } $html = ''; if ($question->qtype != 'random') { if (question_has_capability_on($question, 'use', $question->cid)) { $html .= link_to_popup_window('/question/preview.php?id=' . $question->id . '&courseid=' . $COURSE->id, 'questionpreview', "<img src=\"{$CFG->pixpath}/t/preview.gif\" class=\"iconsmall\" alt=\"{$strpreview}\" />", 0, 0, $strpreview, QUESTION_PREVIEW_POPUP_OPTIONS, true); } } $questionparams = array('returnurl' => $returnurl, 'cmid' => $cmid, 'id' => $question->id); $questionurl = new moodle_url("{$CFG->wwwroot}/question/question.php", $questionparams); if (question_has_capability_on($question, 'edit', $question->cid) || question_has_capability_on($question, 'move', $question->cid)) { $html .= "<a title=\"{$stredit}\" href=\"" . $questionurl->out() . "\">" . "<img src=\"{$CFG->pixpath}/t/edit.gif\" class=\"iconsmall\" alt=\"{$stredit}\" />" . "</a>"; } elseif (question_has_capability_on($question, 'view', $question->cid)) { $html .= "<a title=\"{$strview}\" href=\"" . $questionurl->out(false, array('id' => $question->id)) . "\">" . "<img src=\"{$CFG->pixpath}/i/info.gif\" alt=\"{$strview}\" />" . "</a>"; } if (question_has_capability_on($question, 'edit', $question->cid)) { $html .= "<a title=\"{$strdelete}\" href=\"" . $returnurl . "&delete={$question->id}\">" . "<img src=\"{$CFG->pixpath}/t/delete.gif\" alt=\"{$strdelete}\" /></a>"; } return $html; }
function build_editform($item, $feedback, $cm) { global $DB; $editurl = new moodle_url('/mod/feedback/edit.php', array('id' => $cm->id)); //ther are no settings for recaptcha if (isset($item->id) and $item->id > 0) { notice(get_string('there_are_no_settings_for_recaptcha', 'feedback'), $editurl->out()); exit; } //only one recaptcha can be in a feedback if ($DB->record_exists('feedback_item', array('feedback' => $feedback->id, 'typ' => $this->type))) { notice(get_string('only_one_captcha_allowed', 'feedback'), $editurl->out()); exit; } $this->item = $item; $this->feedback = $feedback; $this->item_form = true; //dummy $lastposition = $DB->count_records('feedback_item', array('feedback' => $feedback->id)); $this->item->feedback = $feedback->id; $this->item->template = 0; $this->item->name = get_string('captcha', 'feedback'); $this->item->label = get_string('captcha', 'feedback'); $this->item->presentation = ''; $this->item->typ = $this->type; $this->item->hasvalue = $this->get_hasvalue(); $this->item->position = $lastposition + 1; $this->item->required = 1; $this->item->dependitem = 0; $this->item->dependvalue = ''; $this->item->options = ''; }
public function definition() { global $USER, $OUTPUT, $CFG; $mform = $this->_form; $instance = $this->_customdata; $this->instance = $instance; $plugin = enrol_get_plugin('boleto'); $heading = $plugin->get_instance_name($instance); $mform->addElement('header', 'boletoheader', $heading); if ($instance->password) { // Change the id of boleto enrolment key input as there can be multiple boleto enrolment methods. $mform->addElement('passwordunmask', 'enrolpassword', get_string('password', 'enrol_boleto'), array('id' => 'enrolpassword_' . $instance->id)); $context = context_course::instance($this->instance->courseid); $keyholders = get_users_by_capability($context, 'enrol/boleto:holdkey', user_picture::fields('u')); $keyholdercount = 0; foreach ($keyholders as $keyholder) { $keyholdercount++; if ($keyholdercount === 1) { $mform->addElement('static', 'keyholder', '', get_string('keyholder', 'enrol_boleto')); } $keyholdercontext = context_user::instance($keyholder->id); if ($USER->id == $keyholder->id || has_capability('moodle/user:viewdetails', context_system::instance()) || has_coursecontact_role($keyholder->id)) { $profilelink = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $keyholder->id . '&course=' . $this->instance->courseid . '">' . fullname($keyholder) . '</a>'; } else { $profilelink = fullname($keyholder); } $profilepic = $OUTPUT->user_picture($keyholder, array('size' => 35, 'courseid' => $this->instance->courseid)); $mform->addElement('static', 'keyholder' . $keyholdercount, '', $profilepic . $profilelink); } } $boletourl = new moodle_url('/enrol/boleto/boleto.php', array('instanceid' => $this->instance->id)); $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfo', 'enrol_boleto')); // customint8 == avista. if ($this->instance->customint8) { $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfodirectlinks', 'enrol_boleto', $boletourl->out(false))); } else { $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink0', 'enrol_boleto', $boletourl->out(false))); $boletourl->param('parcela', 1); $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink1', 'enrol_boleto', $boletourl->out(false))); $boletourl->param('parcela', 2); $mform->addElement('static', 'info', '', get_string('boletoprintandpayinfoparceladolink2', 'enrol_boleto', $boletourl->out(false))); } $this->add_action_buttons(false, get_string('enrolme', 'enrol_boleto')); $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->setDefault('id', $instance->courseid); $mform->addElement('hidden', 'instance'); $mform->setType('instance', PARAM_INT); $mform->setDefault('instance', $instance->id); }
/** * Get the path to a JavaScript library. * @param $libname - the name of the library whose path we need. * @return string */ function ajax_get_lib($libname) { global $CFG, $HTTPSPAGEREQUIRED; $libpath = ''; $translatelist = array('yui_yahoo' => '/lib/yui/yahoo/yahoo-min.js', 'yui_animation' => '/lib/yui/animation/animation-min.js', 'yui_autocomplete' => '/lib/yui/autocomplete/autocomplete-min.js', 'yui_button' => '/lib/yui/button/button-min.js', 'yui_calendar' => '/lib/yui/calendar/calendar-min.js', 'yui_charts' => '/lib/yui/charts/charts-experimental-min.js', 'yui_colorpicker' => '/lib/yui/colorpicker/colorpicker-min.js', 'yui_connection' => '/lib/yui/connection/connection-min.js', 'yui_container' => '/lib/yui/container/container-min.js', 'yui_cookie' => '/lib/yui/cookie/cookie-min.js', 'yui_datasource' => '/lib/yui/datasource/datasource-min.js', 'yui_datatable' => '/lib/yui/datatable/datatable-min.js', 'yui_dom' => '/lib/yui/dom/dom-min.js', 'yui_dom-event' => '/lib/yui/yahoo-dom-event/yahoo-dom-event.js', 'yui_dragdrop' => '/lib/yui/dragdrop/dragdrop-min.js', 'yui_editor' => '/lib/yui/editor/editor-min.js', 'yui_element' => '/lib/yui/element/element-beta-min.js', 'yui_event' => '/lib/yui/event/event-min.js', 'yui_get' => '/lib/yui/get/get-min.js', 'yui_history' => '/lib/yui/history/history-min.js', 'yui_imagecropper' => '/lib/yui/imagecropper/imagecropper-beta-min.js', 'yui_imageloader' => '/lib/yui/imageloader/imageloader-min.js', 'yui_json' => '/lib/yui/json/json-min.js', 'yui_layout' => '/lib/yui/layout/layout-min.js', 'yui_logger' => '/lib/yui/logger/logger-min.js', 'yui_menu' => '/lib/yui/menu/menu-min.js', 'yui_profiler' => '/lib/yui/profiler/profiler-min.js', 'yui_profilerviewer' => '/lib/yui/profilerviewer/profilerviewer-beta-min.js', 'yui_resize' => '/lib/yui/resize/resize-min.js', 'yui_selector' => '/lib/yui/selector/selector-beta-min.js', 'yui_simpleeditor' => '/lib/yui/editor/simpleeditor-min.js', 'yui_slider' => '/lib/yui/slider/slider-min.js', 'yui_tabview' => '/lib/yui/tabview/tabview-min.js', 'yui_treeview' => '/lib/yui/treeview/treeview-min.js', 'yui_uploader' => '/lib/yui/uploader/uploader-experimental-min.js', 'yui_utilities' => '/lib/yui/utilities/utilities.js', 'yui_yuiloader' => '/lib/yui/yuiloader/yuiloader-min.js', 'yui_yuitest' => '/lib/yui/yuitest/yuitest-min.js', 'ajaxcourse_blocks' => '/lib/ajax/block_classes.js', 'ajaxcourse_sections' => '/lib/ajax/section_classes.js', 'ajaxcourse' => '/lib/ajax/ajaxcourse.js'); if (!empty($HTTPSPAGEREQUIRED)) { $wwwroot = $CFG->httpswwwroot; } else { $wwwroot = $CFG->wwwroot; } if (array_key_exists($libname, $translatelist)) { $libpath = $wwwroot . $translatelist[$libname]; } else { $libpath = $libname; } // query strings break file_exists so remove it $url = new moodle_url($libpath); $modifiedlibpath = $url->out(true); $testpath = str_replace($wwwroot, $CFG->dirroot, $modifiedlibpath); if (stripos($libpath, $CFG->wwwroot) === false && stripos($libpath, $CFG->dirroot) === false) { // offsite so just link it } elseif (!file_exists($testpath)) { error('require_js: ' . $libpath . ' - file not found.'); } return $libpath; }
/** * Add autocomplete to a form text field * * @param MoodleQuickForm $mform Moodle form * @param array|moodle_url $options Array of autocomplete options, if $hiddenfieldname is * passed, array indexes are considered record IDs * @param string $textfieldname The text field's name * @param string $hiddenfieldname The hidden field's name. If passed, * the option index will be set to this hidden * value when its option value is selected in * the text field * @param string $width The pixel width of the text field (Due to YUI, must * use width instead of size) * @return void * @link http://developer.yahoo.com/yui/examples/autocomplete/ac_basic_array.html What you get with no $hiddenfieldname * @link http://developer.yahoo.com/yui/examples/autocomplete/ac_itemselect.html What you get with $hiddenfieldname */ public function mform_autocomplete($mform, $options, $textfieldname, $hiddenfieldname = '', $width = '300') { global $PAGE; $url = NULL; $data = NULL; // Generate data source if ($options instanceof moodle_url) { $url = $options->out(false); } else { $data = array(); foreach ($options as $optionid => $option) { if (empty($hiddenfieldname)) { $data[] = $option; } else { $data[] = (object) array('text' => $option, 'id' => $optionid); } } } $fields = array('text'); if (!empty($hiddenfieldname)) { $fields[] = 'id'; } $module = array('name' => 'local_mr_framework', 'fullpath' => '/local/mr/framework/assets/javascript.js', 'requires' => array('yui2-yahoo', 'yui2-dom', 'yui2-event', 'yui2-datasource', 'yui2-json', 'yui2-connection', 'yui2-get', 'yui2-animation', 'yui2-autocomplete')); $arguments = array((object) array('fieldname' => $textfieldname, 'hiddenfieldname' => $hiddenfieldname, 'width' => $width, 'url' => $url, 'data' => $data, 'fields' => $fields)); $PAGE->requires->js_init_call('M.local_mr.init_mr_html_autocomplete', $arguments, true, $module); // $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/autocomplete-core.css'); // $PAGE->requires->css('/lib/yui/2.8.1/build/autocomplete/assets/skins/sam/autocomplete.css'); // Update form - need to force some attributes and add the javascript $mform->updateElementAttr($textfieldname, array('autocomplete' => 'off', 'style' => "width: {$width}px;")); // Add ID to hidden field so javascript can find it if (!empty($hiddenfieldname)) { $mform->updateElementAttr($hiddenfieldname, array('id' => "id_{$hiddenfieldname}")); } }
/** * 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; }
function get_content() { global $CFG, $OUTPUT; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; if (!defined('FEEDBACK_BLOCK_LIB_IS_OK')) { $this->content->items = array(get_string('missing_feedback_module', 'block_feedback')); return $this->content; } $courseid = $this->page->course->id; if ($courseid <= 0) { $courseid = SITEID; } $icon = '<img src="' . $OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" />'; if (empty($this->instance->pageid)) { $this->instance->pageid = SITEID; } if ($feedbacks = feedback_get_feedbacks_from_sitecourse_map($courseid)) { $baseurl = new moodle_url('/mod/feedback/view.php'); foreach ($feedbacks as $feedback) { $url = new moodle_url($baseurl); $url->params(array('id' => $feedback->cmid, 'courseid' => $courseid)); $this->content->items[] = '<a href="' . $url->out() . '">' . $icon . $feedback->name . '</a>'; } } return $this->content; }
/** * Constructor. * @param Command $command The Command to link to the form. * @param int $mode The form mode. */ public function __construct(Command $command, $mode) { // Checking command. if (is_null($command)) { throw new Command_Exception('commandformnotlinked'); } // Linking the command and her category. $this->command = $command; // Setting configuration. $this->mode = $mode; // Setting form action. switch ($mode) { case self::MODE_COMMAND_CHOICE: $url = new moodle_url('/local/vmoodle/view.php', array('view' => 'sadmin', 'what' => 'validateassistedcommand')); break; case self::MODE_RETRIEVE_PLATFORM: $url = new moodle_url('/local/vmoodle/view.php', array('view' => 'sadmin', 'what' => 'gettargetbyvalue')); break; case self::MODE_DISPLAY_COMMAND: $url = new moodle_url('/local/vmoodle/view.php', array('view' => 'targetchoice')); break; default: throw new Command_Exception('badformmode'); break; } // Calling parent's constructor. parent::__construct($url->out()); }
function display() { $search = trim(optional_param('search', '', PARAM_TEXT)); $alpha = optional_param('alpha', '', PARAM_ALPHA); // TODO: with a little more work, we could keep the previously selected sort here $params = $_GET; unset($params['page']); // We want to go back to the first page unset($params['search']); // And clear the search $target = $this->page->get_new_page($params); echo "<table class=\"searchbox\" style=\"margin-left:auto;margin-right:auto\" cellpadding=\"10\"><tr><td>"; echo "<form action=\"" . $target->get_url() . "\" method=\"post\">"; echo "<fieldset class=\"invisiblefieldset\">"; echo "<input type=\"text\" name=\"search\" value=\"" . s($search, true) . "\" size=\"20\" />"; echo '<input type="submit" value="' . get_string('search') . '" />'; //remove the "bare" parameter to prevent from loading only part of the page $moodleurl = new moodle_url($target->get_url()); $moodleurl->remove_params('mode'); if ($search) { echo "<input type=\"button\" onclick=\"document.location='" . $moodleurl->out() . "';\" " . "value=\"Show all items\" />"; } echo "</fieldset></form>"; echo "</td></tr></table>"; }
/** * form_start * * @param xxx $hotpotscriptname * @param xxx $params * @param xxx $attributes (optional, default=array) * @return xxx */ function form_start($hotpotscriptname, $params, $attributes = array()) { $output = ''; if (empty($attributes['method'])) { $attributes['method'] = 'post'; } if (empty($attributes['action'])) { $url = new moodle_url('/mod/hotpot/' . $hotpotscriptname); $attributes['action'] = $url->out(); } $output .= html_writer::start_tag('form', $attributes) . "\n"; $hiddenfields = ''; foreach ($params as $name => $value) { $hiddenfields .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $name, 'value' => $value)) . "\n"; } if ($hiddenfields) { // xhtml strict requires a container for the hidden input elements $output .= html_writer::start_tag('fieldset', array('style' => 'display:none')) . "\n"; $output .= $hiddenfields; $output .= html_writer::end_tag('fieldset') . "\n"; } // xhtml strict requires a container for the contents of the <form> $output .= html_writer::start_tag('div') . "\n"; return $output; }
/** * Render the badge element (message count) * * @param null $userid * @return string */ public function badge($userid = null) { global $USER, $DB, $COURSE, $PAGE; // Only for logged in folks and when we are enabled. if (!isset($USER->message_badge_disabled)) { if (mr_off('badge', 'message') or !isloggedin() or isguestuser()) { $USER->message_badge_disabled = true; } else { $USER->message_badge_disabled = $DB->record_exists('message_processors', array('name' => 'badge', 'enabled' => 0)); } } if ($USER->message_badge_disabled) { return ''; } if ($this->is_mobile()) { return $this->mobile($userid); } $repo = new message_output_badge_repository_message(); $forwardurl = new moodle_url('/message/output/badge/view.php', array('action' => 'forward', 'courseid' => $COURSE->id)); $total = $repo->count_user_unread_messages($userid); $PAGE->requires->js_init_call('M.snap_message_badge.init_badge', array($forwardurl->out(false), $COURSE->id), false, $this->get_js_module()); if (!empty($total)) { $countdiv = html_writer::tag('span', $total, array('id' => html_writer::random_id(), 'class' => 'message_badge_count')); } else { $countdiv = ''; } return $countdiv; }
/** * Constructor of dropbox plugin * * @param int $repositoryid * @param stdClass $context * @param array $options */ public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) { global $CFG; $options['page'] = optional_param('p', 1, PARAM_INT); parent::__construct($repositoryid, $context, $options); $this->setting = 'dropbox_'; $this->dropbox_key = $this->get_option('dropbox_key'); $this->dropbox_secret = $this->get_option('dropbox_secret'); // one day $this->cachedfilettl = 60 * 60 * 24; if (isset($options['access_key'])) { $this->access_key = $options['access_key']; } else { $this->access_key = get_user_preferences($this->setting . '_access_key', ''); } if (isset($options['access_secret'])) { $this->access_secret = $options['access_secret']; } else { $this->access_secret = get_user_preferences($this->setting . '_access_secret', ''); } if (!empty($this->access_key) && !empty($this->access_secret)) { $this->logged = true; } $callbackurl = new moodle_url($CFG->wwwroot . '/repository/repository_callback.php', array('callback' => 'yes', 'repo_id' => $repositoryid)); $args = array('oauth_consumer_key' => $this->dropbox_key, 'oauth_consumer_secret' => $this->dropbox_secret, 'oauth_callback' => $callbackurl->out(false), 'api_root' => 'https://www.dropbox.com/1/oauth'); $this->dropbox = new dropbox($args); }
/** * Set up the columns and headers and other properties of the table and then * call flexible_table::setup() method. * * @param moodle_url $reporturl the URL to redisplay this report. * @param object $question a question with a _stats field * @param bool $hassubqs */ public function question_setup($reporturl, $questiondata, offlinequiz_statistics_response_analyser $responsestats) { $this->questiondata = $questiondata; $this->define_baseurl($reporturl->out()); $this->collapsible(false); $this->set_attribute('class', 'generaltable generalbox boxaligncenter'); // Define the table columns. $columns = array(); $headers = array(); $columns[] = 'part'; $headers[] = ''; $columns[] = 'response'; $headers[] = get_string('response', 'offlinequiz_statistics'); $columns[] = 'fraction'; $headers[] = get_string('optiongrade', 'offlinequiz_statistics'); $columns[] = 'count'; $headers[] = get_string('count', 'offlinequiz_statistics'); $columns[] = 'frequency'; $headers[] = get_string('frequency', 'offlinequiz_statistics'); $this->define_columns($columns); $this->define_headers($headers); $this->sortable(false); $this->column_class('fraction', 'numcol'); $this->column_class('count', 'numcol'); $this->column_class('frequency', 'numcol'); $this->column_suppress('part'); $this->column_suppress('responseclass'); parent::setup(); }
/** * Determine output for the login column. * * @param stdClass $user The user row being worked on. * @return string The output to display. */ public function col_login($user) { if (isset($user->password)) { $pageurl = new \moodle_url('/mod/webexactivity/admin_users.php', array('action' => 'login', 'webexid' => $user->webexid)); return '<a href="' . $pageurl->out(false) . '" target=_blank>Login</a>'; } return ''; }
public function list_boletos($boletos, $course) { $boletourl = new moodle_url('/enrol/boleto/boleto.php'); $content = html_writer::tag('h2', get_string('viewboleto', 'enrol_boleto')); $content .= html_writer::tag('p', get_string('viewandprintinfo', 'enrol_boleto')); if (count($boletos) > 1) { foreach ($boletos as $boleto) { $boletourl->param('id', $boleto->id); $content .= html_writer::tag('p', get_string('boletoprintandpayinfoparceladolink' . $boleto->parcela, 'enrol_boleto', $boletourl->out(false))); } } else { $boleto = array_pop($boletos); $boletourl->param('id', $boleto->id); $content .= html_writer::tag('p', get_string('boletoprintandpayinfodirectlink', 'enrol_boleto', $boletourl->out(false))); } return $content; }
/** * Prints the respective type icon * * @global object * @return string */ function image() { global $OUTPUT; $params = array('d' => $this->data->id, 'fid' => $this->field->id, 'mode' => 'display', 'sesskey' => sesskey()); $link = new moodle_url('/mod/data/field.php', $params); $str = '<a href="' . $link->out() . '">'; $str .= '<img src="' . $OUTPUT->pix_url('linkedradiobutton', 'datafield_linkedradiobutton') . '" '; $str .= 'height="' . $this->iconheight . '" width="' . $this->iconwidth . '" alt="' . $this->type . '" title="' . $this->type . '" /></a>'; return $str; }
/** * Setup the columns and headers and other properties of the table and then * call flexible_table::setup() method. * * @param moodle_url $reporturl the URL to redisplay this report. * @param object $question a question with a _stats field * @param bool $hassubqs */ public function setup($reporturl, $questiondata, quiz_statistics_response_analyser $responesstats) { $this->questiondata = $questiondata; $this->define_baseurl($reporturl->out()); $this->collapsible(false); $this->set_attribute('class', 'generaltable generalbox boxaligncenter'); // Define table columns $columns = array(); $headers = array(); if ($responesstats->has_subparts()) { $columns[] = 'part'; $headers[] = 'Part of question'; } if ($responesstats->has_response_classes()) { $columns[] = 'responseclass'; $headers[] = get_string('modelresponse', 'quiz_statistics'); if ($responesstats->has_actual_responses()) { $columns[] = 'response'; $headers[] = get_string('actualresponse', 'quiz_statistics'); } } else { $columns[] = 'response'; $headers[] = get_string('response', 'quiz_statistics'); } $columns[] = 'fraction'; $headers[] = get_string('optiongrade', 'quiz_statistics'); $columns[] = 'count'; $headers[] = get_string('count', 'quiz_statistics'); $columns[] = 'frequency'; $headers[] = get_string('frequency', 'quiz_statistics'); $this->define_columns($columns); $this->define_headers($headers); $this->sortable(false); $this->column_class('fraction', 'numcol'); $this->column_class('count', 'numcol'); $this->column_class('frequency', 'numcol'); $this->column_suppress('part'); $this->column_suppress('responseclass'); parent::setup(); }
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) { parent::__construct($repositoryid, $context, $options); $returnurl = new moodle_url('/repository/repository_callback.php', array('callback' => 'yes', 'repo_id' =>$this->id)); $clientid = get_config('picasa', 'clientid'); $secret = get_config('picasa', 'secret'); $this->googleoauth = new google_oauth($clientid, $secret, $returnurl->out(false), google_picasa::REALM); $this->check_login(); }
/** * * @param string $selected is the selected tab * @param array $params url parameters to be encoded */ function forumng_feature_deleted_print_tabs($selected, $params) { global $CFG; $tabrow = array(); $listurl = new moodle_url('/mod/forumng/feature/deletedposts/list.php', $params); $deletedpostslisturl = new moodle_url('/mod/forumng/feature/deletedposts/deletedpostslist.php', $params); $tabrow[] = new tabobject('list', $listurl->out(), get_string('deleteddiscussions', 'forumngfeature_deletedposts')); $tabrow[] = new tabobject('deletedpostslist', $deletedpostslisturl->out(), get_string('deletedposts', 'forumngfeature_deletedposts')); $tabs = array(); $tabs[] = $tabrow; print_tabs($tabs, $selected, array(''), array('')); print '<div id="forumng_belowtabs">'; }
public function render_navigation() { global $USER; $conversations = local_simple_message_conversation::find_conversations_for_user($USER->id); $output = ''; foreach ($conversations as $conversation) { $url = new moodle_url('/local/simple_message/index.php', array('conversation' => $conversation->id)); $unreadcount = $conversation->get_unread_count($USER->id); $unreadinfo = $unreadcount > 0 ? " <span class='sm-unread-count'>" . $unreadcount . "</span></a></li>" : ""; $output .= "<li><a data-conversation-id='" . $conversation->id . "' href='" . $url->out(true) . "'>" . $conversation->get_name() . $unreadinfo . "\n"; } return "<nav id='sm-navigation'>\n <h5>Messages</h5>\n <h6>Direct <a href='newconversation.php'>new message</a></h6>\n <ol>\n {$output}\n </ol>\n <h6>Course <a href='#sm-conversation'>new message</a></h6>\n <ol>\n <li>Course title <span class='sm-unread-count'>3</span></li>\n <li>Course title <span class='sm-unread-count'>1</span></li>\n <li>Course title </li>\n </ol>\n <h6>Group <a href='#sm-conversation'>new message</a></h6>\n <ol>\n <li>Group title <span class='sm-unread-count'>5</span></li>\n <li>Group title </li>\n <li>Group title </li>\n </ol>\n </nav>"; }
/** * Set up columns and column names and other table settings. * * @param moodle_url $reporturl * @param object $questiondata * @param integer $s number of attempts on this question. * @param \core_question\statistics\responses\analysis_for_question $responseanalysis */ public function question_setup($reporturl, $questiondata, $s, $responseanalysis) { $this->questiondata = $questiondata; $this->s = $s; $this->define_baseurl($reporturl->out()); $this->collapsible(false); $this->set_attribute('class', 'generaltable generalbox boxaligncenter quizresponseanalysis'); // Define the table columns. $columns = array(); $headers = array(); if ($responseanalysis->has_subparts()) { $columns[] = 'part'; $headers[] = get_string('partofquestion', 'quiz_statistics'); } if ($responseanalysis->has_multiple_response_classes()) { $columns[] = 'responseclass'; $headers[] = get_string('modelresponse', 'quiz_statistics'); if ($responseanalysis->has_actual_responses()) { $columns[] = 'response'; $headers[] = get_string('actualresponse', 'quiz_statistics'); } } else { $columns[] = 'response'; $headers[] = get_string('response', 'quiz_statistics'); } $columns[] = 'fraction'; $headers[] = get_string('optiongrade', 'quiz_statistics'); if (!$responseanalysis->has_multiple_tries_data()) { $columns[] = 'totalcount'; $headers[] = get_string('count', 'quiz_statistics'); } else { $countcolumns = range(1, $responseanalysis->get_maximum_tries()); foreach ($countcolumns as $countcolumn) { $columns[] = 'trycount' . $countcolumn; $headers[] = get_string('counttryno', 'quiz_statistics', $countcolumn); } } $columns[] = 'frequency'; $headers[] = get_string('frequency', 'quiz_statistics'); $this->define_columns($columns); $this->define_headers($headers); $this->sortable(false); $this->column_class('fraction', 'numcol'); $this->column_class('count', 'numcol'); $this->column_class('frequency', 'numcol'); $this->column_suppress('part'); $this->column_suppress('responseclass'); parent::setup(); }
/** * Defines the index page layout * * @return string */ public function index_page() { if (is_null($this->installer)) { throw new coding_exception('Installer instance has not been set.'); } $permcheckurl = new moodle_url('/admin/tool/installaddon/permcheck.php'); $this->page->requires->yui_module('moodle-tool_installaddon-permcheck', 'M.tool_installaddon.permcheck.init', array(array('permcheckurl' => $permcheckurl->out()))); $this->page->requires->strings_for_js(array('permcheckprogress', 'permcheckresultno', 'permcheckresultyes', 'permcheckerror', 'permcheckrepeat'), 'tool_installaddon'); $out = $this->output->header(); $out .= $this->index_page_heading(); $out .= $this->index_page_repository(); $out .= $this->index_page_upload(); $out .= $this->output->footer(); return $out; }
protected function require_js($toreplaceid, question_attempt $qa, $readonly, $correctness) { global $PAGE; $jsmodule = array('name' => 'qtype_jme', 'fullpath' => '/question/type/jme/module.js', 'requires' => array(), 'strings' => array(array('enablejavascript', 'qtype_jme'))); $topnode = 'div.que.jme#q' . $qa->get_slot(); $appleturl = new moodle_url('/question/type/jme/jme/JME.jar'); $question = $qa->get_question(); // They will be converted to strings later. $width = $question->width; $height = $question->height; $appletoptions = $question->jmeoptions; if ($correctness) { $feedbackimage = $this->feedback_image($this->fraction_for_last_response($qa)); } else { $feedbackimage = ''; } $name = 'JME' . $qa->get_slot(); $appletid = 'jme' . $qa->get_slot(); $PAGE->requires->js_init_call('M.qtype_jme.insert_applet', array($toreplaceid, $name, $appletid, $topnode, $appleturl->out(), $feedbackimage, $readonly, "{$width}", "{$height}", $appletoptions), false, $jsmodule); }
/** * Generates code required to embed the player. * * The url contained in $urls must be a local file. * * Unlike other core_media_players, the $urls array should only contain * a single url and the $options array is ignored. * * On failure, the function returns an empty string * * @see core_media_player::embed * @param array $urls URL of media file * @param string $name Display name; '' to use default * @param int $width Optional width; 0 to use default * @param int $height Optional height; 0 to use default * @param array $options Options array * @return string HTML code for embed */ public function embed($urls, $name, $width, $height, $options) { global $CFG; // don't expect alternative urls if (count($urls) !== 1) { return ''; } $file_url = new moodle_url($urls[0]); $viewerjs_player_url = new moodle_url('/filter/viewerjs/lib/viewerjs'); // we assume the filter/viewerjs/lib/viewerjs directory will be four directories away from the initial public directory $viewerjs_player_url->set_anchor('../../../..' . $file_url->out_as_local_url()); if (!$width) { $width = '100%'; } if (!$height) { $height = 500; } $output = html_writer::tag('iframe', '', array('src' => $viewerjs_player_url->out(), 'width' => $width, 'height' => $height, 'webkitallowfullscreen' => 'webkitallowfullscreen', 'mozallowfullscreen' => 'mozallowfullscreen', 'allowfullscreen' => 'allowfullscreen')); return $output; }
static function process_attachments($context, $email, $table, $id) { $attachments = ''; $filename = ''; if (empty($email->attachment)) { return $attachments; } $fs = get_file_storage(); $tree = $fs->get_area_tree($context->id, 'block_quickmail', 'attachment_' . $table, $id, 'id'); $base_url = "/{$context->id}/block_quickmail/attachment_{$table}/{$id}"; /** * @param string $filename name of the file for which we are generating a download link * @param string $text optional param sets the link text; if not given, filename is used * @param bool $plain if itrue, we will output a clean url for plain text email users * */ $gen_link = function ($filename, $text = '', $plain = false) use($base_url) { if (empty($text)) { $text = $filename; } $url = new moodle_url('/pluginfile.php', array('forcedownload' => 1, 'file' => "/{$base_url}/{$filename}")); //to prevent double encoding of ampersands in urls for our plaintext users, //we use the out() method of moodle_url //@see http://phpdocs.moodle.org/HEAD/moodlecore/moodle_url.html if ($plain) { return $url->out(false); } return html_writer::link($url, $text); }; $link = $gen_link("{$email->time}_attachments.zip", self::_s('download_all')); //get a plain text version of the link //by calling gen_link with @param $plain set to true $tlink = $gen_link("{$email->time}_attachments.zip", '', true); $attachments .= "\n<br/>-------\n<br/>"; $attachments .= self::_s('moodle_attachments', $link); $attachments .= "\n<br/>" . $tlink; $attachments .= "\n<br/>-------\n<br/>"; $attachments .= self::_s('qm_contents') . "\n<br />"; return $attachments . self::flatten_subdirs($tree, $gen_link); }
function get_content() { global $CFG, $OUTPUT, $USER; $coursecontext = context::instance_by_id($this->instance->parentcontextid); if (!has_capability('moodle/community:add', $coursecontext) or $this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; if (!isloggedin()) { return $this->content; } $icon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/group'), 'class' => 'icon', 'alt' => "")); $addcourseurl = new moodle_url('/blocks/community/communitycourse.php', array('add' => true, 'courseid' => $this->page->course->id)); $searchlink = html_writer::tag('a', $icon . get_string('addcourse', 'block_community'), array('href' => $addcourseurl->out(false))); $this->content->items[] = $searchlink; require_once $CFG->dirroot . '/blocks/community/locallib.php'; $communitymanager = new block_community_manager(); $courses = $communitymanager->block_community_get_courses($USER->id); if ($courses) { $this->content->items[] = html_writer::empty_tag('hr'); $this->content->icons[] = ''; $this->content->items[] = get_string('mycommunities', 'block_community'); $this->content->icons[] = ''; foreach ($courses as $course) { //delete link $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/delete'), 'alt' => get_string('removecommunitycourse', 'block_community'))); $deleteurl = new moodle_url('/blocks/community/communitycourse.php', array('remove' => true, 'courseid' => $this->page->course->id, 'communityid' => $course->id, 'sesskey' => sesskey())); $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl)); $courselink = html_writer::tag('a', $course->coursename, array('href' => $course->courseurl)); $this->content->items[] = $courselink . ' ' . $deleteatag; $this->content->icons[] = ''; } } return $this->content; }
/** * Constructor * * @param array $options * @param string $wsdl - just here to match base class. */ public function __construct(array $options = array(), $wsdl = null) { $logger = new loggerdb(); $this->setLogger($logger); $config = get_config('collaborate'); if (empty($config)) { print_error('error:noconfiguration', 'mod_collaborate'); } // Set wsdl to local version. $wsdlurl = new \moodle_url('/mod/collaborate/wsdl.xml'); $wsdl = $wsdlurl->out(false); // Set service end point if populated. if (!empty($config->server)) { $options['location'] = $config->server; } if (empty($config->username) || empty($config->password) || empty($options['location'])) { $this->configured = false; $this->usable = false; return; } $options['login'] = $config->username; $options['password'] = $config->password; if (!empty($config->wsdebug)) { ini_set('soap.wsdl_cache_enabled', '0'); ini_set('soap.wsdl_cache_ttl', '0'); $options['trace'] = 1; } $serviceok = $this->quick_test_service($options['location']); if (!$serviceok) { $this->usable = false; return; } try { parent::__construct($options, $wsdl); } catch (\Exception $e) { $this->usable = false; } }
function get_content() { global $CFG, $USER, $DB, $OUTPUT; require_once $CFG->dirroot . '/mod/elluminate/lib.php'; if ($this->content !== NULL) { return $this->content; } $this->content = new stdClass(); $this->content->items = array(); $this->content->icons = array(); $this->content->footer = ''; if (!isloggedin() || empty($this->instance)) { return $this->content; } if ($recordings = elluminate_recent_recordings()) { $this->content->items[] = '<b>' . get_string('recentrecordings', 'block_elluminate') . ':</b>'; $this->content->icons[] = ''; $baseurl = new moodle_url('/mod/elluminate/view.php'); foreach ($recordings as $recording) { $elluminate = $DB->get_record('elluminate', array('meetingid' => $recording->meetingid)); $url = new moodle_url($baseurl); $url->params(array('a' => $elluminate->id, 'group' => $elluminate->groupid)); $icon = '<img src="' . $OUTPUT->pix_url('icon', 'feedback') . '" class="icon" alt="" /> '; $this->content->text = ' <a href="' . $url->out() . '">' . $recording->name . '</a>'; } } return $this->content; }
/** * Allow a gallery to be viewed just by knowing its idnumber. * This is a helper function to jump to a gallery without going throught * the course page, simulating the case where the user knows the URL but * can't go through the course (ispublic flag is set). * * @Given /^I view the lightboxgallery with idnumber "(?P<lightboxgallery_idnumber>(?:[^"]|\\")*)"$/ * @param string $idnumber */ public function i_view_the_lightboxgallery_with_idnumber($idnumber) { global $DB; $sql = "SELECT cm.id\n FROM {course_modules} cm\n JOIN {modules} m ON m.id = cm.module\n WHERE m.name = 'lightboxgallery' AND cm.idnumber = ?"; $cm = $DB->get_record_sql($sql, [$idnumber]); $href = new moodle_url('/mod/lightboxgallery/view.php', ['id' => $cm->id]); $this->getSession()->visit($href->out()); }
/** * 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); }