/**
  *
  */
 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;
 }
Example #2
1
/**
 * Adds module specific settings to the settings block.
 *
 * @param settings_navigation $settings The settings navigation object
 * @param stdClass $context The node context
 */
function local_loginas_extends_settings_navigation(settings_navigation $settings, $context)
{
    global $DB, $CFG, $PAGE, $USER;
    // Course id and context.
    $courseid = !empty($PAGE->course->id) ? $PAGE->course->id : SITEID;
    $coursecontext = context_course::instance($courseid);
    // Must have the loginas capability.
    if (!has_capability('moodle/user:loginas', $coursecontext)) {
        return;
    }
    // Set the settings category.
    $loginas = $settings->add(get_string('loginas'));
    // Login as list by admin setting.
    if (is_siteadmin($USER)) {
        // Admin settings page.
        $url = new moodle_url('/admin/settings.php', array('section' => 'localsettingloginas'));
        $loginas->add(get_string('settings'), $url, $settings::TYPE_SETTING);
        // Users list.
        $loginasusers = array();
        // Since 2.6, use all the required fields.
        $ufields = 'id, ' . get_all_user_name_fields(true);
        // Get users by id.
        if ($configuserids = get_config('local_loginas', 'loginasusers')) {
            $userids = explode(',', $configuserids);
            if ($users = $DB->get_records_list('user', 'id', $userids, '', $ufields)) {
                $loginasusers = $users;
            }
        }
        // Get users by username.
        if ($configusernames = get_config('local_loginas', 'loginasusernames')) {
            $usernames = explode(',', $configusernames);
            if ($users = $DB->get_records_list('user', 'username', $usernames, '', $ufields)) {
                $loginasusers = $loginasusers + $users;
            }
        }
        // Add action links for specified users.
        if ($loginasusers) {
            $params = array('id' => $courseid, 'sesskey' => sesskey());
            foreach ($loginasusers as $userid => $lauser) {
                $url = new moodle_url('/course/loginas.php', $params);
                $url->param('user', $userid);
                $loginas->add(fullname($lauser, true), $url, $settings::TYPE_SETTING);
            }
        }
    }
    // Course users login as.
    if (!($configcourseusers = get_config('local_loginas', 'courseusers'))) {
        return;
    }
    $loggedinas = \core\session\manager::is_loggedinas();
    if (!$loggedinas) {
        // Ajax link.
        $node = $loginas->add(get_string('courseusers', 'local_loginas'), 'javascript:void();', $settings::TYPE_SETTING);
        $node->add_class('local_loginas_setting_link');
        local_loginas_require_js($PAGE);
    }
}
Example #3
0
 /**
  * Adds the item in course settings navigation to toggle modchooser
  *
  * Theme can overwrite as an empty function to exclude it (for example if theme does not
  * use modchooser at all)
  */
 protected function add_modchoosertoggle()
 {
     global $CFG;
     static $modchoosertoggleadded = false;
     // Add the module chooser toggle to the course page
     if ($modchoosertoggleadded || $this->page->state > moodle_page::STATE_PRINTING_HEADER || $this->page->course->id == SITEID || !$this->page->user_is_editing() || !($context = context_course::instance($this->page->course->id)) || !has_capability('moodle/course:update', $context) || !course_ajax_enabled($this->page->course) || !($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) || !$coursenode->get('editsettings')) {
         // too late or we are on site page or we could not find the course settings node
         // or we are not allowed to edit
         return;
     }
     $modchoosertoggleadded = true;
     if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
         // We are on the course page, retain the current page params e.g. section.
         $modchoosertoggleurl = clone $this->page->url;
     } else {
         // Edit on the main course page.
         $modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id, 'return' => $this->page->url->out_as_local_url(false)));
     }
     $modchoosertoggleurl->param('sesskey', sesskey());
     if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
         $modchoosertogglestring = get_string('modchooserdisable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'off');
     } else {
         $modchoosertogglestring = get_string('modchooserenable', 'moodle');
         $modchoosertoggleurl->param('modchooser', 'on');
     }
     $modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING);
     $coursenode->add_node($modchoosertoggle, 'editsettings');
     $modchoosertoggle->add_class('modchoosertoggle');
     $modchoosertoggle->add_class('visibleifjs');
     user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
 }
 /**
  * Run all the question tests for all variants of all questions belonging to
  * a given context.
  *
  * Does output as we go along.
  *
  * @param context $context the context to run the tests for.
  * @return array with two elements:
  *              bool true if all the tests passed, else false.
  *              array of messages relating to the questions with failures.
  */
 public function run_all_tests_for_context(context $context)
 {
     global $DB, $OUTPUT;
     // Load the necessary data.
     $categories = question_category_options(array($context));
     $categories = reset($categories);
     $questiontestsurl = new moodle_url('/question/type/stack/questiontestrun.php');
     if ($context->contextlevel == CONTEXT_COURSE) {
         $questiontestsurl->param('courseid', $context->instanceid);
     } else {
         if ($context->contextlevel == CONTEXT_MODULE) {
             $questiontestsurl->param('cmid', $context->instanceid);
         }
     }
     $allpassed = true;
     $failingtests = array();
     foreach ($categories as $key => $category) {
         list($categoryid) = explode(',', $key);
         echo $OUTPUT->heading($category, 3);
         $questionids = $DB->get_records_menu('question', array('category' => $categoryid, 'qtype' => 'stack'), 'name', 'id,name');
         if (!$questionids) {
             continue;
         }
         echo html_writer::tag('p', stack_string('replacedollarscount', count($questionids)));
         foreach ($questionids as $questionid => $name) {
             $tests = question_bank::get_qtype('stack')->load_question_tests($questionid);
             if (!$tests) {
                 echo $OUTPUT->heading(html_writer::link(new moodle_url($questiontestsurl, array('questionid' => $questionid)), format_string($name)), 4);
                 echo html_writer::tag('p', stack_string('bulktestnotests'));
                 continue;
             }
             $question = question_bank::load_question($questionid);
             $questionname = format_string($name);
             $previewurl = new moodle_url($questiontestsurl, array('questionid' => $questionid));
             if (empty($question->deployedseeds)) {
                 $questionnamelink = html_writer::link($previewurl, $questionname);
                 echo $OUTPUT->heading($questionnamelink, 4);
                 list($ok, $message) = $this->qtype_stack_test_question($question, $tests);
                 if (!$ok) {
                     $allpassed = false;
                     $failingtests[] = $questionnamelink . ': ' . $message;
                 }
             } else {
                 echo $OUTPUT->heading(format_string($name), 4);
                 foreach ($question->deployedseeds as $seed) {
                     $previewurl->param('seed', $seed);
                     $questionnamelink = html_writer::link($previewurl, stack_string('seedx', $seed));
                     echo $OUTPUT->heading($questionnamelink, 4);
                     list($ok, $message) = $this->qtype_stack_test_question($question, $tests, $seed);
                     if (!$ok) {
                         $allpassed = false;
                         $failingtests[] = $questionname . ' ' . $questionnamelink . ': ' . $message;
                     }
                 }
             }
         }
     }
     return array($allpassed, $failingtests);
 }
 /**
  * Get URL related to the action.
  *
  * @return \moodle_url
  */
 public function get_url()
 {
     $url = new \moodle_url("/mod/treasurehunt/view.php", array('id' => $this->contextinstanceid));
     if (!empty($this->other['groupid'])) {
         $url->param('groupid', $this->other['groupid']);
     } else {
         $url->param('userid', $this->userid);
     }
     return $url;
 }
Example #6
0
 /**
  * Constructor
  *
  * @param int $repositoryid
  * @param stdClass $context
  * @param array $options
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $clientid = get_config('boxnet', 'clientid');
     $clientsecret = get_config('boxnet', 'clientsecret');
     $returnurl = new moodle_url('/repository/repository_callback.php');
     $returnurl->param('callback', 'yes');
     $returnurl->param('repo_id', $this->id);
     $returnurl->param('sesskey', sesskey());
     $this->boxnetclient = new boxnet_client($clientid, $clientsecret, $returnurl, '');
 }
Example #7
0
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $returnurl = new moodle_url('/repository/repository_callback.php');
     $returnurl->param('callback', 'yes');
     $returnurl->param('repo_id', $this->id);
     $returnurl->param('sesskey', sesskey());
     $clientid = get_config('googledocs', 'clientid');
     $secret = get_config('googledocs', 'secret');
     $this->googleoauth = new google_oauth($clientid, $secret, $returnurl, google_docs::REALM);
     $this->check_login();
 }
Example #8
0
 /**
  * Constructor
  *
  * @param int $repositoryid repository instance id.
  * @param int|stdClass $context a context id or context object.
  * @param array $options repository options.
  */
 public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array())
 {
     parent::__construct($repositoryid, $context, $options);
     $clientid = get_config('skydrive', 'clientid');
     $secret = get_config('skydrive', 'secret');
     $returnurl = new moodle_url('/repository/repository_callback.php');
     $returnurl->param('callback', 'yes');
     $returnurl->param('repo_id', $this->id);
     $returnurl->param('sesskey', sesskey());
     $this->skydrive = new microsoft_skydrive($clientid, $secret, $returnurl);
     $this->check_login();
 }
 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 . '&amp;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);
 }
Example #10
0
 /**
  * Returns HTML to display a "Turn editing on/off" button in a form.
  *
  * @param moodle_url $url The URL + params to send through when clicking the button
  * @return string HTML the button
  * Written by G J Barnard
  */
 public function edit_button(moodle_url $url)
 {
     $url->param('sesskey', sesskey());
     if ($this->page->user_is_editing()) {
         $url->param('edit', 'off');
         $btn = 'btn-danger';
         $title = get_string('turneditingoff');
         $icon = 'fa-power-off';
     } else {
         $url->param('edit', 'on');
         $btn = 'btn-success';
         $title = get_string('turneditingon');
         $icon = 'fa-edit';
     }
     return html_writer::tag('a', html_writer::start_tag('i', array('class' => $icon . ' fa fa-fw')) . html_writer::end_tag('i') . $title, array('href' => $url, 'class' => 'btn ' . $btn, 'title' => $title));
 }
Example #11
0
function update_questionbank()
{
    global $USER, $FULLME;
    $myurl = new moodle_url($FULLME);
    $myurl->param('first', 'second');
    //print_object($myurl->get_query_string());
    //notice('die please');
    $qid = optional_param('qid', null);
    $theQuestion = optional_param('question', null);
    if (empty($theQuestion)) {
        return;
    }
    $question = get_record('memorybank_bank', 'id', $qid);
    print_object($question);
    $question->question = optional_param('question', null);
    $question->answer = optional_param('answer', null);
    $question->reference = optional_param('reference', null);
    $question->initialgrade = optional_param('initialgrade', 4);
    $question->category = optional_param('category', 0);
    $question->visible = optional_param('visible', 0);
    $initviewtime = optional_param('initviewtime', 0);
    $question->initviewtime = make_timestamp($initviewtime['year'], $initviewtime['month'], $initviewtime['day'], $initviewtime['hour'], $initviewtime['minute']);
    $question->modifiedby = $USER->id;
    $question->timemodified = time();
    print_object($question);
    update_record('memorybank_bank', $question);
}
 /**
  * Get URL related to the action
  *
  * @return \moodle_url
  */
 public function get_url()
 {
     $url = new \moodle_url('/mod/twf/user.php', array('id' => $this->relateduserid, 'mode' => $this->other['reportmode']));
     if ($this->courseid != SITEID) {
         $url->param('course', $this->courseid);
     }
     return $url;
 }
Example #13
0
 /**
  * Add question-type specific form fields.
  *
  * @param object $mform the form being built.
  */
 function definition_inner($mform)
 {
     global $CFG;
     //redirct to the new ordering question type
     $orderingurl = new moodle_url($CFG->wwwroot . '/question/question.php', $_GET);
     $orderingurl->param('qtype', 'ordering');
     redirect($orderingurl, 'This question type is deprecated. Redirection to new question ordering', 3);
 }
 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;
 }
Example #15
0
 /**
  * Prepare permanent link for the given filter data
  *
  * @param moodle_url $baseurl
  * @param stdClass $fdata as returned by {@see self::get_data()}
  * @return moodle_url $permalink
  */
 public function set_permalink(moodle_url $baseurl, stdClass $fdata)
 {
     $this->permalink = new moodle_url($baseurl, array('t' => time()));
     $this->permalink->param('v', implode(',', $fdata->version));
     // list of languages or '*' if all are selected
     $all = mlang_tools::list_languages(false);
     foreach ($fdata->language as $selected) {
         unset($all[$selected]);
     }
     if (empty($all)) {
         $this->permalink->param('l', '*');
     } else {
         $this->permalink->param('l', implode(',', $fdata->language));
     }
     unset($all);
     // list of components or '*' if all are selected
     $all = mlang_tools::list_components();
     foreach ($fdata->component as $selected) {
         unset($all[$selected]);
     }
     if (empty($all)) {
         $this->permalink->param('c', '*');
     } else {
         $this->permalink->param('c', implode(',', $fdata->component));
     }
     unset($all);
     // substring and stringid
     $this->permalink->param('s', $fdata->substring);
     $this->permalink->param('d', $fdata->stringid);
     // checkboxes
     if ($fdata->missing) {
         $this->permalink->param('m', 1);
     }
     if ($fdata->helps) {
         $this->permalink->param('h', 1);
     }
     if ($fdata->substringregex) {
         $this->permalink->param('r', 1);
     }
     if ($fdata->substringcs) {
         $this->permalink->param('i', 1);
     }
     if ($fdata->stringidpartial) {
         $this->permalink->param('p', 1);
     }
     if ($fdata->stagedonly) {
         $this->permalink->param('g', 1);
     }
     if ($fdata->greylistedonly) {
         $this->permalink->param('o', 1);
     }
     if ($fdata->withoutgreylisted) {
         $this->permalink->param('w', 1);
     }
     return $this->permalink;
 }
 /**
  * Form definition
  *
  * @uses $CFG
  */
 public function definition()
 {
     // if there are no rows in the table, return.
     // (won't be rows if both olduser and newuser are NULL in session stdClass)
     if (empty($this->urt->data)) {
         return '';
     }
     $mform =& $this->_form;
     // header
     $mform->addElement('header', 'reviewusers', get_string('userreviewtable_legend', 'tool_mergeusers'));
     // table content
     $mform->addElement('static', 'reviewuserslist', '', html_writer::table($this->urt));
     // buttons
     // set up url here so the same url can be used more than once
     $mergeurl = new moodle_url('/admin/tool/mergeusers/index.php');
     $buttonarray = array();
     if ($this->review_step) {
         $mergeurl->param('option', 'mergeusers');
         $mergeusersbutton = new single_button($mergeurl, get_string('mergeusers', 'tool_mergeusers'));
         $mergeusersbutton->add_confirm_action(get_string('mergeusers_confirm', 'tool_mergeusers'));
         $buttonarray[0][] = $this->output->render($mergeusersbutton);
     } else {
         if (count($this->urt->data) === 2) {
             $mergeurl->param('option', 'continueselection');
             $mergeusersbutton = new single_button($mergeurl, get_string('saveselection_submit', 'tool_mergeusers'));
             $buttonarray[0][] = $this->output->render($mergeusersbutton);
         }
     }
     $mergeurl->param('option', 'clearselection');
     $mergeusersbutton = new single_button($mergeurl, get_string('clear_selection', 'tool_mergeusers'));
     $buttonarray[0][] = $this->output->render($mergeusersbutton);
     if ($this->review_step) {
         $mergeurl->param('option', 'searchusers');
         $mergeusersbutton = new single_button($mergeurl, get_string('cancel'));
         $buttonarray[0][] = $this->output->render($mergeusersbutton);
     }
     $htmltable = new html_table();
     $htmltable->attributes['class'] = 'clearfix';
     $htmltable->data = $buttonarray;
     $mform->addElement('static', 'buttonar', '', html_writer::table($htmltable));
     $mform->closeHeaderBefore('buttonar');
 }
 /**
  * set up the class for the view page
  *
  * @param string $baseurl the base url of the page
  */
 public function setup_page($baseurl)
 {
     global $PAGE, $CFG, $DB;
     $this->pagevars = array();
     $this->pageurl = new \moodle_url($baseurl);
     $this->pageurl->remove_all_params();
     $id = optional_param('id', false, PARAM_INT);
     $quizid = optional_param('quizid', false, PARAM_INT);
     // get necessary records from the DB
     if ($id) {
         $cm = get_coursemodule_from_id('activequiz', $id, 0, false, MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
         $quiz = $DB->get_record('activequiz', array('id' => $cm->instance), '*', MUST_EXIST);
     } else {
         $quiz = $DB->get_record('activequiz', array('id' => $quizid), '*', MUST_EXIST);
         $course = $DB->get_record('course', array('id' => $quiz->course), '*', MUST_EXIST);
         $cm = get_coursemodule_from_instance('activequiz', $quiz->id, $course->id, false, MUST_EXIST);
     }
     $this->get_parameters();
     // get the rest of the parameters and set them in the class
     require_login($course->id, false, $cm);
     $this->pageurl->param('id', $cm->id);
     $this->pageurl->param('quizid', $quiz->id);
     $this->pageurl->params($this->pagevars);
     // add the page vars variable to the url
     $this->pagevars['pageurl'] = $this->pageurl;
     $this->RTQ = new \mod_activequiz\activequiz($cm, $course, $quiz, $this->pagevars);
     $this->RTQ->require_capability('mod/activequiz:viewownattempts');
     // set up renderer
     $this->RTQ->get_renderer()->init($this->RTQ, $this->pageurl, $this->pagevars);
     $PAGE->set_pagelayout('popup');
     $PAGE->set_context($this->RTQ->getContext());
     $PAGE->set_title(strip_tags($course->shortname . ': ' . get_string("modulename", "activequiz") . ': ' . format_string($quiz->name, true)));
     $PAGE->set_heading($course->fullname);
     $PAGE->set_url($this->pageurl);
 }
 public function wrap_html_start()
 {
     global $PAGE;
     if ($this->is_downloading() || !$this->candelete) {
         return;
     }
     // Start form
     $url = new moodle_url($this->reporturl, $this->displayoptions);
     $url->param('sesskey', sesskey());
     echo '<div id="tablecontainer">';
     echo '<form id="attemptsform" method="post" action="' . $url->out_omit_querystring() . '>';
     echo html_writer::input_hidden_params($url);
     echo '<div>';
     $PAGE->requires->event_handler('#attemptsform', 'submit', 'M.util.show_confirm_dialog', array('message' => get_string('deleteattemptcheck', 'quiz')));
 }
 /**
  * Constructor
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-collections-table';
     $this->head = array(get_string('name'), get_string('component', 'tag'), get_string('tagareas', 'tag'), get_string('searchable', 'tag') . $OUTPUT->help_icon('searchable', 'tag'), '');
     $this->data = array();
     $tagcolls = core_tag_collection::get_collections();
     $idx = 0;
     foreach ($tagcolls as $tagcoll) {
         $actions = '';
         $name = core_tag_collection::display_name($tagcoll);
         $url = new moodle_url($pageurl, array('sesskey' => sesskey(), 'tc' => $tagcoll->id));
         if (!$tagcoll->isdefault) {
             // Move up.
             if ($idx > 1) {
                 $url->param('action', 'collmoveup');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')), null, array('class' => 'action-icon action_moveup'));
             }
             // Move down.
             if ($idx < count($tagcolls) - 1) {
                 $url->param('action', 'collmovedown');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')), null, array('class' => 'action-icon action_movedown'));
             }
         }
         if (!$tagcoll->isdefault && empty($tagcoll->component)) {
             // Delete.
             $url->param('action', 'colldelete');
             $actions .= $OUTPUT->action_icon('#', new pix_icon('t/delete', get_string('delete')), null, array('data-url' => $url->out(false), 'data-collname' => $name, 'class' => 'action-icon action_delete'));
         }
         $component = '';
         if ($tagcoll->component) {
             $component = $tagcoll->component === 'core' || preg_match('/^core_/', $tagcoll->component) ? get_string('coresystem') : get_string('pluginname', $tagcoll->component);
         }
         $allareas = core_tag_collection::get_areas_names(null, false);
         $validareas = core_tag_collection::get_areas_names($tagcoll->id);
         $areaslist = array_map(function ($key) use($allareas, $validareas) {
             return "<li data-areaid=\"{$key}\" " . (array_key_exists($key, $validareas) ? "" : "style=\"display:none;\"") . ">{$allareas[$key]}</li>";
         }, array_keys($allareas));
         $displayname = new \core_tag\output\tagcollname($tagcoll);
         $searchable = new \core_tag\output\tagcollsearchable($tagcoll);
         $this->data[] = array($displayname->render($OUTPUT), $component, "<ul data-collectionid=\"{$tagcoll->id}\">" . join('', $areaslist) . '</ul>', $searchable->render($OUTPUT), $actions);
         $idx++;
     }
 }
function vmoodle_get_jump_link_url($vmoodleid, $wantsurl = '')
{
    global $DB, $CFG;
    $vmoodle = $DB->get_record('local_vmoodle', array('id' => $vmoodleid));
    if ($vmoodle->mnet > -1 && $vmoodle->vhostname != $CFG->wwwroot) {
        $url = new moodle_url('/auth/mnet/jump.php', array('hostwwwroot' => $vmoodle->vhostname));
        if (!empty($wantsurl)) {
            $url->param('wantsurl', $wantsurl);
        }
    } else {
        // if not mnet
        $url = $vmoodle->vhostname;
        if (!empty($wantsurl)) {
            $url .= '?wantsurl=' . $wantsurl;
        }
    }
    return $url;
}
Example #21
0
 /**
  * Constructor
  * @param string|moodle_url $pageurl
  */
 public function __construct($pageurl)
 {
     global $OUTPUT;
     parent::__construct();
     $this->attributes['class'] = 'generaltable tag-collections-table';
     $this->head = array(get_string('name'), get_string('component', 'tag'), get_string('tagareas', 'tag'), get_string('searchable', 'tag') . $OUTPUT->help_icon('searchable', 'tag'), '');
     $this->data = array();
     $tagcolls = core_tag_collection::get_collections();
     $idx = 0;
     foreach ($tagcolls as $tagcoll) {
         $actions = '';
         $name = core_tag_collection::display_name($tagcoll);
         $url = new moodle_url($pageurl, array('sesskey' => sesskey(), 'tc' => $tagcoll->id));
         if (!$tagcoll->isdefault) {
             // Move up.
             if ($idx > 1) {
                 $url->param('action', 'collmoveup');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/up', get_string('moveup')));
             }
             // Move down.
             if ($idx < count($tagcolls) - 1) {
                 $url->param('action', 'collmovedown');
                 $actions .= $OUTPUT->action_icon($url, new pix_icon('t/down', get_string('movedown')));
             }
         }
         if (empty($tagcoll->component)) {
             // Edit.
             $url->param('action', 'colledit');
             $actions .= $OUTPUT->action_icon($url, new pix_icon('t/edit', get_string('edittagcoll', 'tag', $name)));
         }
         if (!$tagcoll->isdefault && empty($tagcoll->component)) {
             // Delete.
             $url->param('action', 'colldelete');
             $actions .= $OUTPUT->action_icon($url, new pix_icon('t/delete', get_string('delete')));
         }
         $manageurl = new moodle_url('/tag/manage.php', array('tc' => $tagcoll->id));
         $component = '';
         if ($tagcoll->component) {
             $component = $tagcoll->component === 'core' || preg_match('/^core_/', $tagcoll->component) ? get_string('coresystem') : get_string('pluginname', $tagcoll->component);
         }
         $this->data[] = array(html_writer::link($manageurl, $name), $component, join(', ', core_tag_collection::get_areas_names($tagcoll->id)), $tagcoll->searchable ? get_string('yes') : '-', $actions);
         $idx++;
     }
 }
Example #22
0
 /**
  *
  */
 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) {
         list($expimp, $label) = explode(':', trim($pattern, '#') . '::');
         switch ($expimp) {
             case 'exportall':
                 if ($view->param4) {
                     $actionurl = new moodle_url($baseurl, array('exportcsv' => $view::EXPORT_ALL));
                     $label = $label ? $label : html_writer::tag('span', get_string('exportall', 'dataformview_csv'));
                     $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportall'));
                 } else {
                     $replacements[$pattern] = '';
                 }
                 break;
             case 'exportpage':
                 if ($view->param4) {
                     $actionurl = new moodle_url($baseurl, array('exportcsv' => $view::EXPORT_PAGE));
                     $label = $label ? $label : html_writer::tag('span', get_string('exportpage', 'dataformview_csv'));
                     $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink exportpage'));
                 } else {
                     $replacements[$pattern] = '';
                 }
                 break;
             case 'import':
                 if ($view->param5) {
                     $actionurl = new moodle_url($baseurl, array('importcsv' => 1));
                     $label = $label ? $label : html_writer::tag('span', get_string('import'));
                     $replacements[$pattern] = html_writer::link($actionurl, $label, array('class' => 'actionlink import'));
                 } else {
                     $replacements[$pattern] = '';
                 }
                 break;
         }
     }
     return $replacements;
 }
 /**
  * Handles the page request
  *
  */
 public function handle_request()
 {
     global $DB;
     switch ($this->pagevars['action']) {
         case 'regradeall':
             $this->RTQ->get_grader()->save_all_grades();
             $this->RTQ->get_renderer()->setMessage('success', get_string('successregrade', 'activequiz'));
             $sessions = $this->RTQ->get_sessions();
             $this->RTQ->get_renderer()->responses_header();
             $this->RTQ->get_renderer()->select_session($sessions);
             $this->RTQ->get_renderer()->report_home();
             $this->RTQ->get_renderer()->responses_footer();
             break;
         case 'viewsession':
             $sessionid = required_param('sessionid', PARAM_INT);
             if (empty($sessionid)) {
                 // if no session id just go to the home page
                 $this->pageurl->param('action', '');
                 redirect($this->pageurl, null, 0);
             }
             $session = $this->RTQ->get_session($sessionid);
             $this->pageurl->param('sessionid');
             $sessionattempts = new \mod_activequiz\tableviews\sessionattempts('sessionattempts', $this->RTQ, $session, $this->pageurl);
             $sessions = $this->RTQ->get_sessions();
             $this->RTQ->get_renderer()->responses_header();
             $this->RTQ->get_renderer()->select_session($sessions, $sessionid);
             $this->RTQ->get_renderer()->view_session_attempts($sessionattempts);
             $this->RTQ->get_renderer()->responses_footer();
             break;
         default:
             // default view is to show a report with the list of sessions
             // to select for showing the session's attempts
             $sessions = $this->RTQ->get_sessions();
             $this->RTQ->get_renderer()->responses_header();
             $this->RTQ->get_renderer()->select_session($sessions);
             $this->RTQ->get_renderer()->report_home();
             $this->RTQ->get_renderer()->responses_footer();
     }
 }
Example #24
0
 /**
  * The URL to use for the specified course (with section)
  *
  * @param int|stdClass $section Section object from database or just field course_sections.section
  *     if omitted the course view page is returned
  * @param array $options options for view URL. At the moment core uses:
  *     'navigation' (bool) if true and section has no separate page, the function returns null
  *     'sr' (int) used by multipage formats to specify to which section to return
  * @return null|moodle_url
  */
 public function get_view_url($section, $options = array())
 {
     $url = new moodle_url('/course/view.php', array('id' => $this->courseid));
     $sectionno = $this->get_section_number($section);
     $section = $this->get_section($sectionno);
     if ($sectionno && (!$section->uservisible || !$this->is_section_real_available($section))) {
         return empty($options['navigation']) ? $url : null;
     }
     if (array_key_exists('sr', $options)) {
         // return to the page for section with number $sr
         $url->param('section', $options['sr']);
         if ($sectionno) {
             $url->set_anchor('section-' . $sectionno);
         }
     } else {
         if (!empty($options['navigation'])) {
             // this is called from navigation, create link only if this
             // section has separate page
             if ($section->collapsed == FORMAT_FLEXSECTIONS_COLLAPSED) {
                 $url->param('sectionid', $section->id);
             } else {
                 return null;
             }
         } else {
             if ($sectionno) {
                 // check if this section has separate page
                 if ($section->collapsed == FORMAT_FLEXSECTIONS_COLLAPSED) {
                     $url->param('sectionid', $section->id);
                     return $url;
                 }
                 // find the parent (or grandparent) page that is displayed on separate page
                 $url->param('sectionid', $this->find_collapsed_parent($section->parent, true));
                 $url->set_anchor('section-' . $sectionno);
                 return $url;
             }
         }
     }
     return $url;
 }
Example #25
0
/**
 * Returns the list of all editing actions that current user can perform on the module
 *
 * @param cm_info $mod The module to produce editing buttons for
 * @param int $indent The current indenting (default -1 means no move left-right actions)
 * @param int $sr The section to link back to (used for creating the links)
 * @return array array of action_link or pix_icon objects
 */
function course_get_cm_edit_actions_reduced(cm_info $mod, $indent = -1, $sr = null)
{
    global $COURSE, $SITE;
    static $str;
    $coursecontext = context_course::instance($mod->course);
    $modcontext = context_module::instance($mod->id);
    $editcaps = array('moodle/course:manageactivities', 'moodle/course:activityvisibility', 'moodle/role:assign');
    $dupecaps = array('moodle/backup:backuptargetimport', 'moodle/restore:restoretargetimport');
    //No permission to edit anything.
    if (!has_any_capability($editcaps, $modcontext) and !has_all_capabilities($dupecaps, $coursecontext)) {
        return array();
    }
    $hasmanageactivities = has_capability('moodle/course:manageactivities', $modcontext);
    if (!isset($str)) {
        $str = get_strings(array('delete', 'move', 'moveright', 'moveleft', 'editsettings', 'duplicate', 'hide', 'show'), 'moodle');
        $str->assign = get_string('assignroles', 'role');
        $str->groupsnone = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsnone"));
        $str->groupsseparate = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsseparate"));
        $str->groupsvisible = get_string('clicktochangeinbrackets', 'moodle', get_string("groupsvisible"));
    }
    $baseurl = new moodle_url('/course/mod.php', array('sesskey' => sesskey()));
    if ($sr !== null) {
        $baseurl->param('sr', $sr);
    }
    $actions = array();
    // Duplicate (require both target import caps to be able to duplicate and backup2 support, see modduplicate.php)
    // Note that restoring on front page is never allowed.
    if ($mod->course != SITEID && has_all_capabilities($dupecaps, $coursecontext) && plugin_supports('mod', $mod->modname, FEATURE_BACKUP_MOODLE2)) {
        $actions['duplicate'] = new action_menu_link_secondary(new moodle_url($baseurl, array('duplicate' => $mod->id)), new pix_icon('t/copy', $str->duplicate, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->duplicate, array('class' => 'editing_duplicate', 'data-action' => 'duplicate', 'data-sr' => $sr));
    }
    // Delete.
    if ($hasmanageactivities) {
        $actions['delete'] = new action_menu_link_secondary(new moodle_url($baseurl, array('delete' => $mod->id)), new pix_icon('t/delete', $str->delete, 'moodle', array('class' => 'iconsmall', 'title' => '')), $str->delete, array('class' => 'editing_delete', 'data-action' => 'delete'));
    }
    return $actions;
}
Example #26
0
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package feedback
 */

require_once("../../config.php");
require_once("lib.php");
require_once('import_form.php');

// get parameters
$id = required_param('id', PARAM_INT);
$choosefile = optional_param('choosefile', false, PARAM_PATH);
$action = optional_param('action', false, PARAM_ALPHA);

$url = new moodle_url('/mod/feedback/import.php', array('id'=>$id));
if ($choosefile !== false) {
    $url->param('choosefile', $choosefile);
}
if ($action !== false) {
    $url->param('action', $action);
}
$PAGE->set_url($url);

if (! $cm = get_coursemodule_from_id('feedback', $id)) {
    print_error('invalidcoursemodule');
}

if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
    print_error('coursemisconf');
}

if (! $feedback = $DB->get_record("feedback", array("id"=>$cm->instance))) {
Example #27
0
}
if (!($course = $DB->get_record("course", array("id" => $questionnaire->course)))) {
    print_error('coursemisconf');
}
if (!($cm = get_coursemodule_from_instance("questionnaire", $questionnaire->id, $course->id))) {
    print_error('invalidcoursemodule');
}
// Check login and get context.
require_login($courseid);
$questionnaire = new questionnaire(0, $questionnaire, $course, $cm);
// If you can't view the questionnaire, or can't view a specified response, error out.
if (!($questionnaire->capabilities->view && ($rid == 0 || $questionnaire->can_view_response($rid)))) {
    // Should never happen, unless called directly by a snoop...
    print_error('nopermissions', 'moodle', $CFG->wwwroot . '/mod/questionnaire/view.php?id=' . $cm->id);
}
$blankquestionnaire = true;
if ($rid != 0) {
    $blankquestionnaire = false;
}
$url = new moodle_url($CFG->wwwroot . '/mod/questionnaire/print.php');
$url->param('qid', $qid);
$url->param('rid', $rid);
$url->param('courseid', $courseid);
$url->param('sec', $sec);
$PAGE->set_url($url);
$PAGE->set_title($questionnaire->survey->title);
$PAGE->set_pagelayout('popup');
echo $OUTPUT->header();
$questionnaire->survey_print_render($message = '', $referer = 'print', $courseid, $rid, $blankquestionnaire);
echo $OUTPUT->close_window_button();
echo $OUTPUT->footer();
 * @package calendar
 */
require_once '../config.php';
require_once $CFG->libdir . '/bennu/bennu.inc.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/calendar/lib.php';
require_once $CFG->dirroot . '/calendar/managesubscriptions_form.php';
// Required use.
$courseid = optional_param('course', SITEID, PARAM_INT);
// Used for processing subscription actions.
$subscriptionid = optional_param('id', 0, PARAM_INT);
$pollinterval = optional_param('pollinterval', 0, PARAM_INT);
$action = optional_param('action', '', PARAM_ALPHA);
$url = new moodle_url('/calendar/managesubscriptions.php');
if ($courseid != SITEID) {
    $url->param('course', $courseid);
}
navigation_node::override_active_url(new moodle_url('/calendar/view.php', array('view' => 'month')));
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
$PAGE->navbar->add(get_string('managesubscriptions', 'calendar'));
if ($courseid != SITEID && !empty($courseid)) {
    $course = $DB->get_record('course', array('id' => $courseid));
    $courses = array($course->id => $course);
} else {
    $course = get_site();
    $courses = calendar_get_default_courses();
}
require_course_login($course);
if (!calendar_user_can_add_event($course)) {
    print_error('errorcannotimport', 'calendar');
 /**
  * This function loads all of the front page settings into the settings navigation.
  * This function is called when the user is on the front page, or $COURSE==$SITE
  * @param bool $forceopen (optional)
  * @return navigation_node
  */
 protected function load_front_page_settings($forceopen = false)
 {
     global $SITE, $CFG;
     $course = clone $SITE;
     $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
     // Course context
     $frontpage = $this->add(get_string('frontpagesettings'), null, self::TYPE_SETTING, null, 'frontpage');
     if ($forceopen) {
         $frontpage->force_open();
     }
     $frontpage->id = 'frontpagesettings';
     if (has_capability('moodle/course:update', $coursecontext)) {
         // Add the turn on/off settings
         $url = new moodle_url('/course/view.php', array('id' => $course->id, 'sesskey' => sesskey()));
         if ($this->page->user_is_editing()) {
             $url->param('edit', 'off');
             $editstring = get_string('turneditingoff');
         } else {
             $url->param('edit', 'on');
             $editstring = get_string('turneditingon');
         }
         $frontpage->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
         // Add the course settings link
         $url = new moodle_url('/admin/settings.php', array('section' => 'frontpagesettings'));
         $frontpage->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/settings', ''));
     }
     // add enrol nodes
     enrol_add_course_navigation($frontpage, $course);
     // Manage filters
     if (has_capability('moodle/filter:manage', $coursecontext) && count(filter_get_available_in_context($coursecontext)) > 0) {
         $url = new moodle_url('/filter/manage.php', array('contextid' => $coursecontext->id));
         $frontpage->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/filter', ''));
     }
     // Backup this course
     if (has_capability('moodle/backup:backupcourse', $coursecontext)) {
         $url = new moodle_url('/backup/backup.php', array('id' => $course->id));
         $frontpage->add(get_string('backup'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/backup', ''));
     }
     // Restore to this course
     if (has_capability('moodle/restore:restorecourse', $coursecontext)) {
         $url = new moodle_url('/backup/restorefile.php', array('contextid' => $coursecontext->id));
         $frontpage->add(get_string('restore'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/restore', ''));
     }
     // Questions
     require_once $CFG->libdir . '/questionlib.php';
     question_extend_settings_navigation($frontpage, $coursecontext)->trim_if_empty();
     // Manage files
     if ($course->legacyfiles == 2 and has_capability('moodle/course:managefiles', $this->context)) {
         //hiden in new installs
         $url = new moodle_url('/files/index.php', array('contextid' => $coursecontext->id, 'itemid' => 0, 'component' => 'course', 'filearea' => 'legacy'));
         $frontpage->add(get_string('sitelegacyfiles'), $url, self::TYPE_SETTING, null, null, new pix_icon('i/files', ''));
     }
     return $frontpage;
 }
Example #30
0
require_once '../../config.php';
require_once 'lib.php';
require_once "{$CFG->libdir}/rsslib.php";
$id = optional_param('id', 0, PARAM_INT);
// course module id
$d = optional_param('d', 0, PARAM_INT);
// database id
$rid = optional_param('rid', 0, PARAM_INT);
//record id
$cancel = optional_param('cancel', '', PARAM_RAW);
// cancel an add
$mode = 'addtemplate';
//define the mode for this page, only 1 mode available
$url = new moodle_url('/mod/data/edit.php');
if ($rid !== 0) {
    $url->param('rid', $rid);
}
if ($cancel !== '') {
    $url->param('cancel', $cancel);
}
if ($id) {
    $url->param('id', $id);
    $PAGE->set_url($url);
    if (!($cm = get_coursemodule_from_id('data', $id))) {
        print_error('invalidcoursemodule');
    }
    if (!($course = $DB->get_record('course', array('id' => $cm->course)))) {
        print_error('coursemisconf');
    }
    if (!($data = $DB->get_record('data', array('id' => $cm->instance)))) {
        print_error('invalidcoursemodule');