function __construct($userid) { $this->name = get_string('admin_academic', 'block_student_gradeviewer'); $this->userid = $userid; $this->type = 'academics'; $this->debug = get_config('', 'block_student_gradeviewer_debug'); $this->input_fields = array('year', 'college', 'major'); // Assign the path here $values = array_map(array($this, 'na_or_empty'), $this->input_fields); //Pull this the categories from a form submission rather the url params if ($data = data_submitted()) { $p = isset($data->path) ? $data->path : $this->year . '/' . $this->college . '/' . $this->major; } else { $p = optional_param('path', 'NA'); } if ($p != 'NA') { $this->path = $p; $fields = explode('/', $p); foreach ($this->input_fields as $index => $field) { $this->{$field} = $fields[$index]; } } else { if (array_reduce($values, 'empty_reduce_check', true)) { $this->path = 'NA'; } else { $this->path = implode('/', $values); } } $this->capabilities = array('block/student_gradeviewer:academicadmin'); }
/** * get_field * * @param xxx $fieldname * @param xxx $advanced * @return xxx */ function get_field($fieldname, $advanced) { // hotpot version of standard function $default = get_user_preferences('hotpot_' . $fieldname, ''); $rawdata = data_submitted(); if ($rawdata && isset($rawdata->{$fieldname}) && !is_array($rawdata->{$fieldname})) { $default = optional_param($fieldname, $default, PARAM_ALPHANUM); } unset($rawdata); switch ($fieldname) { case 'group': case 'grouping': return new hotpot_filter_group($fieldname, $advanced, $default); case 'grade': $label = get_string('grade'); return new hotpot_filter_grade($fieldname, $label, $advanced, $default); case 'timemodified': $label = get_string('time', 'quiz'); return new user_filter_date($fieldname, $label, $advanced, $fieldname); case 'status': return new hotpot_filter_status($fieldname, $advanced, $default); case 'duration': $label = get_string('duration', 'mod_hotpot'); return new hotpot_filter_duration($fieldname, $label, $advanced, $default); case 'penalties': $label = get_string('penalties', 'mod_hotpot'); return new hotpot_filter_number($fieldname, $label, $advanced, $default); case 'score': $label = get_string('score', 'quiz'); return new hotpot_filter_number($fieldname, $label, $advanced, $default); default: // other fields (e.g. from user record) return parent::get_field($fieldname, $advanced); } }
function process_feedback($formdata=null) { global $CFG, $USER, $DB; require_once($CFG->libdir.'/gradelib.php'); if (!$feedback = data_submitted() or !confirm_sesskey()) { // No incoming data? return false; } ///For save and next, we need to know the userid to save, and the userid to go ///We use a new hidden field in the form, and set it to -1. If it's set, we use this ///as the userid to store if ((int)$feedback->saveuserid !== -1){ $feedback->userid = $feedback->saveuserid; } if (!empty($feedback->cancel)) { // User hit cancel button return false; } $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $feedback->userid); // store outcomes if needed $this->process_outcomes($feedback->userid); $submission = $this->get_submission($feedback->userid, true); // Get or make one if (!$grading_info->items[0]->grades[$feedback->userid]->locked and !$grading_info->items[0]->grades[$feedback->userid]->overridden) { $submission->grade = $feedback->xgrade; $submission->submissioncomment = $feedback->submissioncomment_editor['text']; $submission->teacher = $USER->id; $mailinfo = get_user_preferences('assignment_mailinfo', 0); if (!$mailinfo) { $submission->mailed = 1; // treat as already mailed } else { $submission->mailed = 0; // Make sure mail goes out (again, even) } $submission->timemarked = time(); unset($submission->data1); // Don't need to update this. unset($submission->data2); // Don't need to update this. if (empty($submission->timemodified)) { // eg for offline assignments $submission->timemodified = time(); } $DB->update_record('assignment_submissions', $submission); // trigger grade event $this->update_grade($submission); add_to_log($this->course->id, 'assignment', 'update grades', 'submissions.php?id='.$this->assignment->id.'&user='.$feedback->userid, $feedback->userid, $this->cm->id); } return $submission; }
function process_feedback($formdata = null) { if (!($feedback = data_submitted()) or !confirm_sesskey()) { // No incoming data? return false; } $userid = required_param('userid', PARAM_INT); $offset = required_param('offset', PARAM_INT); $mform = $this->display_submission($offset, $userid, false); parent::process_feedback($mform); }
/** * Provides a hook into the login page. * * @param object &$frm Form object. * @param object &$user User object. */ public function loginpage_hook(&$frm, &$user) { global $DB; if (empty($frm)) { $frm = data_submitted(); } if (empty($frm)) { return true; } $autoappend = get_config('auth_oidc', 'autoappend'); if (empty($autoappend)) { // If we're not doing autoappend, just let things flow naturally. return true; } $username = $frm->username; $password = $frm->password; $auth = 'oidc'; $existinguser = $DB->get_record('user', ['username' => $username]); if (!empty($existinguser)) { // We don't want to prevent access to existing accounts. return true; } $username .= $autoappend; $success = $this->user_login($username, $password); if ($success !== true) { // No o365 user, continue normally. return false; } $existinguser = $DB->get_record('user', ['username' => $username]); if (!empty($existinguser)) { $user = $existinguser; return true; } // The user is authenticated but user creation may be disabled. if (!empty($CFG->authpreventaccountcreation)) { $failurereason = AUTH_LOGIN_UNAUTHORISED; // Trigger login failed event. $event = \core\event\user_login_failed::create(array('other' => array('username' => $username, 'reason' => $failurereason))); $event->trigger(); error_log('[client ' . getremoteaddr() . "] {$CFG->wwwroot} Unknown user, can not create new accounts: {$username} " . $_SERVER['HTTP_USER_AGENT']); return false; } $user = create_user_record($username, $password, $auth); return true; }
function process_feedback() { global $USER; if (!($feedback = data_submitted())) { // No incoming data? return false; } ///For save and next, we need to know the userid to save, and the userid to go ///We use a new hidden field in the form, and set it to -1. If it's set, we use this ///as the userid to store if ((int) $feedback->saveuserid !== -1) { $feedback->userid = $feedback->saveuserid; } if (!empty($feedback->cancel)) { // User hit cancel button return false; } $submission = $this->get_submission($feedback->userid, true); // Get or make one $submission->grade = $feedback->grade; $submission->submissioncomment = $feedback->submissioncomment; $submission->format = $feedback->format; $submission->teacher = $USER->id; $submission->mailed = 0; // Make sure mail goes out (again, even) $submission->timemarked = time(); unset($submission->data1); // Don't need to update this. unset($submission->data2); // Don't need to update this. if (empty($submission->timemodified)) { // eg for offline assignments $submission->timemodified = time(); } if (!update_record('assignment_submissions', $submission)) { return false; } add_to_log($this->course->id, 'assignment', 'update grades', 'submissions.php?id=' . $this->assignment->id . '&user=' . $feedback->userid, $feedback->userid, $this->cm->id); return $submission; }
/** * Invoke method, every class will have its own * returns true/false on completion, setting both * errormsg and output as necessary */ function invoke() { parent::invoke(); $result = true; /// Set own core attributes $this->does_generate = ACTION_NONE; //$this->does_generate = ACTION_GENERATE_HTML; /// These are always here global $CFG, $XMLDB; /// Do the job, setting result as needed if (!data_submitted()) { ///Basic prevention print_error('wrongcall', 'error'); } /// Get parameters $dirpath = required_param('dir', PARAM_PATH); $dirpath = $CFG->dirroot . $dirpath; $comment = required_param('comment', PARAM_CLEAN); $comment = $comment; /// Set comment and recalculate hash $editeddir =& $XMLDB->editeddirs[$dirpath]; $structure =& $editeddir->xml_file->getStructure(); $structure->setComment($comment); $structure->calculateHash(true); /// If the hash has changed from the original one, change the version /// and mark the structure as changed $origdir =& $XMLDB->dbdirs[$dirpath]; $origstructure =& $origdir->xml_file->getStructure(); if ($structure->getHash() != $origstructure->getHash()) { $structure->setVersion(userdate(time(), '%Y%m%d', 99, false)); $structure->setChanged(true); } /// Launch postaction if exists (leave this here!) if ($this->getPostAction() && $result) { return $this->launch($this->getPostAction()); } /// Return ok if arrived here return $result; }
} $PAGE->set_title($data->name); $PAGE->set_heading($course->fullname); /// Check to see if groups are being used here $currentgroup = groups_get_activity_group($cm); $groupmode = groups_get_activity_groupmode($cm); if ($currentgroup) { $groupselect = " AND groupid = '{$currentgroup}'"; $groupparam = "&groupid={$currentgroup}"; } else { $groupselect = ""; $groupparam = ""; $currentgroup = 0; } /// Process incoming data for adding/updating records if ($datarecord = data_submitted() and confirm_sesskey()) { $ignorenames = array('MAX_FILE_SIZE', 'sesskey', 'd', 'rid', 'saveandview', 'cancel'); // strings to be ignored in input data if ($rid) { /// Update some records /// All student edits are marked unapproved by default $record = $DB->get_record('data_records', array('id' => $rid)); /// reset approved flag after student edit if (!has_capability('mod/data:approve', $context)) { $record->approved = 0; } $record->groupid = $currentgroup; $record->timemodified = time(); $DB->update_record('data_records', $record); /// Update all content $field = NULL;
exit; } if ($id) { if (!($view = get_record('block_exabeporview', 'id', $id, 'userid', $USER->id))) { print_error("wrongviewid", "block_exabis_eportfolio"); } } else { $view = null; } $returnurl = $CFG->wwwroot . '/blocks/exabis_eportfolio/views_list.php?courseid=' . $courseid; // delete item if ($action == 'delete') { if (!$view) { print_error("bookmarknotfound", "block_exabis_eportfolio"); } if (data_submitted() && $confirm && confirm_sesskey()) { delete_records('block_exabeporviewblock', 'viewid', $view->id); $status = delete_records('block_exabeporview', 'id', $view->id); add_to_log(SITEID, 'blog', 'delete', 'views_mod.php?courseid=' . $courseid . '&id=' . $view->id . '&action=delete&confirm=1', $view->name); if (!$status) { print_error('deleteposterror', 'block_exabis_eportfolio', $returnurl); } redirect($returnurl); } else { $optionsyes = array('id' => $id, 'action' => 'delete', 'confirm' => 1, 'sesskey' => sesskey(), 'courseid' => $courseid); $optionsno = array('courseid' => $courseid); block_exabis_eportfolio_print_header('views'); echo '<br />'; notice_yesno(get_string("deleteconfirm", "block_exabis_eportfolio"), 'views_mod.php', 'views_list.php', $optionsyes, $optionsno, 'post', 'get'); print_footer(); die;
grade_report_grader::process_action($target, $action); } $reportname = get_string('pluginname', 'gradereport_grader'); /// Print header print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons); //Initialise the grader report object that produces the table //the class grade_report_grader_ajax was removed as part of MDL-21562 $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid); // make sure separate group does not prevent view if ($report->currentgroup == -2) { echo $OUTPUT->heading(get_string("notingroup")); echo $OUTPUT->footer(); exit; } /// processing posted grades & feedback here if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) { $warnings = $report->process_data($data); } else { $warnings = array(); } // final grades MUST be loaded after the processing $report->load_users(); $numusers = $report->get_numusers(); $report->load_final_grades(); echo $report->group_selector; echo '<div class="clearer"></div>'; // echo $report->get_toggles_html(); //show warnings if any foreach ($warnings as $warning) { echo $OUTPUT->notification($warning); }
if ($action == 'delchoice' and confirm_sesskey() and is_enrolled($context, NULL, 'mod/choice:choose') and $choice->allowupdate and $choiceavailable) { $answercount = $DB->count_records('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id)); if ($answercount > 0) { $DB->delete_records('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id)); // Update completion state $completion = new completion_info($course); if ($completion->is_enabled($cm) && $choice->completionsubmit) { $completion->update_state($cm, COMPLETION_INCOMPLETE); } redirect("view.php?id={$cm->id}"); } } $PAGE->set_title($choice->name); $PAGE->set_heading($course->fullname); /// Submit any new data if there is any if (data_submitted() && is_enrolled($context, NULL, 'mod/choice:choose') && confirm_sesskey()) { $timenow = time(); if (has_capability('mod/choice:deleteresponses', $context) && $action == 'delete') { //some responses need to be deleted choice_delete_responses($attemptids, $choice, $cm, $course); //delete responses. redirect("view.php?id={$cm->id}"); } // Redirection after all POSTs breaks block editing, we need to be more specific! if ($choice->allowmultiple) { $answer = optional_param_array('answer', array(), PARAM_INT); } else { $answer = optional_param('answer', '', PARAM_INT); } if (!$choiceavailable) { $reason = current(array_keys($warnings));
print_header_simple(format_string($elluminate->name), '', $navigation, '', '', true, $buttontext, navmenu($course, $cm)); /// Delete a preload file for this meeting. if (!empty($delete)) { if (!empty($elluminate->meetingid)) { if ($preload = elluminate_list_meeting_preloads($elluminate->meetingid)) { if ($preload->presentationid == $delete) { /// Delete the preload from the meeting. if (!elluminate_delete_preload($preload->presentationid, $elluminate->meetingid)) { error(get_string('preloaddeleteerror', 'elluminate')); } redirect($CFG->wwwroot . '/mod/elluminate/view.php?id=' . $cm->id, get_string('preloaddeletesuccess', 'elluminate'), 5); } } } } if (($data = data_submitted($CFG->wwwroot . '/mod/elluminate/preload.php')) && confirm_sesskey()) { if (!empty($_FILES['whiteboard'])) { $filepath = $_FILES['whiteboard']['tmp_name']; $filesize = $_FILES['whiteboard']['size']; //This was put in to handle apostrophes in the filename when magic quotes is no turned on. $actual_filename = $data->userfilename; $search = array("<", ">", "&", "#", "%", "\"", "\\", "|", "'"); $replace = ''; $filename = str_replace($search, $replace, $actual_filename); /// Make sure the file uses a valid whiteboard preload file extension. if (!eregi('\\.([a-zA-Z0-9]+)$', $filename, $match)) { error(get_string('preloadnofileextension', 'elluminate')); } if (!isset($match[1])) { error(get_string('preloadnofileextension', 'elluminate')); }
* @package feedback */ require_once "../../config.php"; require_once "lib.php"; $id = required_param('id', PARAM_INT); $completedid = optional_param('completedid', false, PARAM_INT); $preservevalues = optional_param('preservevalues', 0, PARAM_INT); $courseid = optional_param('courseid', false, PARAM_INT); $gopage = optional_param('gopage', -1, PARAM_INT); $lastpage = optional_param('lastpage', false, PARAM_INT); $startitempos = optional_param('startitempos', 0, PARAM_INT); $lastitempos = optional_param('lastitempos', 0, PARAM_INT); $anonymous_response = optional_param('anonymous_response', 0, PARAM_INT); //arb $highlightrequired = false; if ($formdata = data_submitted('nomatch') and !confirm_sesskey()) { error('no sesskey defined'); } //if the use hit enter into a textfield so the form should not submit if (isset($formdata->sesskey) and !isset($formdata->savevalues) and !isset($formdata->gonextpage) and !isset($formdata->gopreviouspage)) { $gopage = $formdata->lastpage; } if (isset($formdata->savevalues)) { $savevalues = true; } else { $savevalues = false; } if ($gopage < 0 and !$savevalues) { if (isset($formdata->gonextpage)) { $gopage = $lastpage + 1; $gonextpage = true;
if ($edit) { $settings = array(); $settings['name'] = $fromform->name; if (!$instance->readonly) { foreach ($configs as $config) { if (isset($fromform->{$config})) { $settings[$config] = $fromform->{$config}; } else { $settings[$config] = null; } } } $success = $instance->set_option($settings); } else { $success = repository::static_function($plugin, 'create', $plugin, 0, $context, $fromform); $data = data_submitted(); } if ($success) { redirect($parenturl); } else { print_error('instancenotsaved', 'repository', $parenturl); } exit; } else { echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('configplugin', 'repository_' . $plugin)); echo $OUTPUT->box_start(); $mform->display(); echo $OUTPUT->box_end(); $return = false; }
<?php // $Id: index.php,v 1.16.4.1 2008/02/01 05:48:43 moodler Exp $ require '../config.php'; if ($form = data_submitted('nomatch')) { // form submitted, do not check referer (original page unknown)! /// Only deal with real users if (!isloggedin()) { redirect($CFG->wwwroot); } /// Work out who to send the message to if (!($admin = get_admin())) { error('Could not find an admin user!'); } $supportuser = new object(); $supportuser->email = $CFG->supportemail ? $CFG->supportemail : $admin->email; $supportuser->firstname = $CFG->supportname ? $CFG->supportname : $admin->firstname; $supportuser->lastname = $CFG->supportname ? '' : $admin->lastname; $supportuser->maildisplay = true; /// Send the email and redirect email_to_user($supportuser, $USER, 'Error: ' . $form->referer . ' -> ' . $form->requested, $form->text); redirect($CFG->wwwroot . '/course/', 'Message sent, thanks', 3); exit; } $site = get_site(); $redirecturl = empty($_SERVER['REDIRECT_URL']) ? '' : $_SERVER['REDIRECT_URL']; $httpreferer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; $requesturi = empty($_SERVER['REQUEST_URI']) ? '' : $_SERVER['REQUEST_URI']; header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); print_header($site->fullname . ':Error', $site->fullname . ': Error 404', 'Error 404 - File not Found', '');
$mnet = get_mnet_environment(); if (!extension_loaded('openssl')) { echo $OUTPUT->header(); set_config('mnet_dispatcher_mode', 'off'); print_error('requiresopenssl', 'mnet'); } if (!function_exists('curl_init')) { echo $OUTPUT->header(); set_config('mnet_dispatcher_mode', 'off'); print_error('nocurl', 'mnet'); } if (!isset($CFG->mnet_dispatcher_mode)) { set_config('mnet_dispatcher_mode', 'off'); } /// If data submitted, process and store if (($form = data_submitted()) && confirm_sesskey()) { if (!empty($form->submit) && $form->submit == get_string('savechanges')) { if (in_array($form->mode, array("off", "strict", "dangerous"))) { if (set_config('mnet_dispatcher_mode', $form->mode)) { redirect('index.php', get_string('changessaved')); } else { print_error('invalidaction', '', 'index.php'); } } } elseif (!empty($form->submit) && $form->submit == get_string('delete')) { $mnet->get_private_key(); $SESSION->mnet_confirm_delete_key = md5(sha1($mnet->keypair['keypair_PEM'])) . ':' . time(); $formcontinue = new single_button(new moodle_url('index.php', array('confirm' => md5($mnet->public_key))), get_string('yes')); $formcancel = new single_button(new moodle_url('index.php', array()), get_string('no')); echo $OUTPUT->confirm(get_string("deletekeycheck", "mnet"), $formcontinue, $formcancel); exit;
echo '<input type="hidden" name="sesskey" value="' . $sesskey . '" />'; echo '<input type="submit" value="' . $strcontinue . '" /></fieldset></form>'; echo '<form action="preset.php" method="post">'; echo '<div>'; echo '<input type="hidden" name="name" value="' . $name . '" />'; echo '<input type="hidden" name="action" value="save3" />'; echo '<input type="hidden" name="d" value="' . $data->id . '" />'; echo '<input type="hidden" name="sesskey" value="' . $sesskey . '" />'; echo '<input type="submit" value="' . $stroverwrite . '" /></div></form>'; echo '</div>'; print_footer($course); exit; break; } case 'save3': if (!data_submitted() or !confirm_sesskey()) { error("Invalid request"); } $name = optional_param('name', $data->name, PARAM_FILE); $presetdirectory = "/data/preset/{$USER->id}/{$name}"; make_upload_directory($presetdirectory); clean_preset($CFG->dataroot . $presetdirectory); $file = data_presets_export($course, $cm, $data); if (!unzip_file($file, $CFG->dataroot . $presetdirectory, false)) { error("Can't unzip to the preset directory"); } notify(get_string('savesuccess', 'data'), 'notifysuccess'); break; } $presets = data_get_available_presets($context); $strimport = get_string('import');
function game_sudoku_check_glossaryentries($id, $game, $attempt, $sudoku, $finishattempt, $course) { global $QTYPES, $DB; $responses = data_submitted(); //this function returns offsetentries, numbers, correctquestions $offsetentries = game_sudoku_compute_offsetquestions($game->sourcemodule, $attempt, $numbers, $correctquestions); $entrieslist = game_sudoku_getquestionlist($offsetentries); // Load the glossary entries if (!($entries = $DB->get_records_select('glossary_entries', "id IN ({$entrieslist})"))) { print_error(get_string('noglossaryentriesfound', 'game')); } foreach ($entries as $entry) { $answerundefined = optional_param('resp' . $entry->id, 'undefined', PARAM_TEXT); if ($answerundefined == 'undefined') { continue; } $answer = optional_param('resp' . $entry->id, '', PARAM_TEXT); if ($answer == '') { continue; } if (game_upper($entry->concept) != game_upper($answer)) { continue; } //correct answer $select = "attemptid={$attempt->id}"; $select .= " AND glossaryentryid={$entry->id} AND col>0"; $select .= " AND questiontext is null"; // check the student guesses not source glossary entry. $query = new stdClass(); if (($query->id = $DB->get_field_select('game_queries', 'id', $select)) == 0) { echo "not found {$select}<br>"; continue; } game_update_queries($game, $attempt, $query, 1, $answer); } game_sudoku_check_last($id, $game, $attempt, $sudoku, $finishattempt, $course); return true; }
if (!($choice = choice_get_choice($cm->instance))) { error("Course module is incorrect"); } $strchoice = get_string('modulename', 'choice'); $strchoices = get_string('modulenameplural', 'choice'); if (!($context = get_context_instance(CONTEXT_MODULE, $cm->id))) { print_error('badcontext'); } if ($action == 'delchoice') { if ($answer = get_record('choice_answers', 'choiceid', $choice->id, 'userid', $USER->id)) { //print_object($answer); delete_records('choice_answers', 'id', $answer->id); } } /// Submit any new data if there is any if ($form = data_submitted() && has_capability('mod/choice:choose', $context)) { $timenow = time(); if (has_capability('mod/choice:deleteresponses', $context)) { if ($action == 'delete') { //some responses need to be deleted choice_delete_responses($attemptids); //delete responses. redirect("view.php?id={$cm->id}"); } } $answer = optional_param('answer', '', PARAM_INT); if (empty($answer)) { redirect("view.php?id={$cm->id}", get_string('mustchooseone', 'choice')); } else { choice_user_submit_response($answer, $choice, $USER->id, $course->id, $cm); }
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('NO_OUTPUT_BUFFERING', true); require_once '../../../config.php'; require_once $CFG->libdir . '/adminlib.php'; admin_externalpage_setup('toolinnodb'); $confirm = optional_param('confirm', 0, PARAM_BOOL); require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); echo $OUTPUT->header(); echo $OUTPUT->heading('Convert all MySQL tables from MYISAM to InnoDB'); if ($DB->get_dbfamily() != 'mysql') { notice('This function is for MySQL databases only!', new moodle_url('/admin/')); } if (data_submitted() and $confirm and confirm_sesskey()) { echo $OUTPUT->notification('Please be patient and wait for this to complete...', 'notifysuccess'); if ($tables = $DB->get_tables()) { $DB->set_debug(true); foreach ($tables as $table) { $fulltable = $DB->get_prefix() . $table; $DB->change_database_structure("ALTER TABLE {$fulltable} ENGINE=INNODB"); } $DB->set_debug(false); } echo $OUTPUT->notification('... done.', 'notifysuccess'); echo $OUTPUT->continue_button(new moodle_url('/admin/')); echo $OUTPUT->footer(); } else { $optionsyes = array('confirm' => '1', 'sesskey' => sesskey()); $formcontinue = new single_button(new moodle_url('/admin/tool/innodb/index.php', $optionsyes), get_string('yes'));
$context = context_module::instance($cm->id); require_capability('mod/choice:readresponses', $context); if (!($choice = choice_get_choice($cm->instance))) { print_error('invalidcoursemodule'); } $strchoice = get_string("modulename", "choice"); $strchoices = get_string("modulenameplural", "choice"); $strresponses = get_string("responses", "choice"); $eventdata = array(); $eventdata['objectid'] = $choice->id; $eventdata['context'] = $context; $eventdata['courseid'] = $course->id; $eventdata['other']['content'] = 'choicereportcontentviewed'; $event = \mod_choice\event\report_viewed::create($eventdata); $event->trigger(); if (data_submitted() && $action == 'delete' && has_capability('mod/choice:deleteresponses', $context) && confirm_sesskey()) { choice_delete_responses($attemptids, $choice, $cm, $course); //delete responses. redirect("report.php?id={$cm->id}"); } if (!$download) { $PAGE->navbar->add($strresponses); $PAGE->set_title(format_string($choice->name) . ": {$strresponses}"); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); echo $OUTPUT->heading($choice->name, 2, null); /// Check to see if groups are being used in this choice $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { groups_get_activity_group($cm, true); groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/choice/report.php?id=' . $id);
} redirect($redirect); break; case 'deletecategory': $id = required_param('id', PARAM_INT); if (confirm_sesskey()) { profile_delete_category($id); } redirect($redirect, get_string('deleted')); break; case 'deletefield': $id = required_param('id', PARAM_INT); $confirm = optional_param('confirm', 0, PARAM_BOOL); // If no userdata for profile than don't show confirmation. $datacount = $DB->count_records('user_info_data', array('fieldid' => $id)); if ((data_submitted() and $confirm or $datacount === 0) and confirm_sesskey()) { profile_delete_field($id); redirect($redirect, get_string('deleted')); } // Ask for confirmation, as there is user data available for field. $fieldname = $DB->get_field('user_info_field', 'name', array('id' => $id)); $optionsyes = array('id' => $id, 'confirm' => 1, 'action' => 'deletefield', 'sesskey' => sesskey()); $strheading = get_string('profiledeletefield', 'admin', $fieldname); $PAGE->navbar->add($strheading); echo $OUTPUT->header(); echo $OUTPUT->heading($strheading); $formcontinue = new single_button(new moodle_url($redirect, $optionsyes), get_string('yes'), 'post'); $formcancel = new single_button(new moodle_url($redirect), get_string('no'), 'get'); echo $OUTPUT->confirm(get_string('profileconfirmfielddeletion', 'admin', $datacount), $formcontinue, $formcancel); echo $OUTPUT->footer(); die;
$id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', '', PARAM_ALPHA); $link = optional_param('link', 0, PARAM_INT); list($cm, $course, $lesson) = lesson_get_basics($id); require_login($course->id, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); switch ($mode) { case 'add': // Ensure that we came from view.php if (!confirm_sesskey() or !data_submitted()) { print_error('invalidformdata'); } break; case 'save': if (confirm_sesskey() and $form = data_submitted($CFG->wwwroot . '/mod/lesson/view.php')) { $name = trim(optional_param('name', '', PARAM_CLEAN)); // Make sure it is not empty if (empty($name)) { lesson_set_message(get_string('missingname', 'lesson')); $mode = 'add'; break; } // Check for censored words $filterwords = explode(',', get_string('censorbadwords')); foreach ($filterwords as $filterword) { if (strstr($name, $filterword)) { lesson_set_message(get_string('namereject', 'lesson')); $mode = 'add'; break; }
// $Id$ /** * prints the form to import items from xml-file * * @version $Id$ * @author Andreas Grabs * @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @package feedback */ require_once "../../config.php"; require_once "lib.php"; // get parameters $id = required_param('id', PARAM_INT); $choosefile = optional_param('choosefile', false, PARAM_PATH); $action = optional_param('action', false, PARAM_ALPHA); if ($formdata = data_submitted() and !confirm_sesskey()) { print_error('invalidsesskey'); } if ($id) { 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)))) { print_error('invalidcoursemodule'); } } $capabilities = feedback_load_capabilities($cm->id); require_login($course->id, true, $cm);
if (quiz_has_question_use($questionid)) { quiz_remove_question($quiz, $questionid); } } quiz_delete_previews($quiz); quiz_update_sumgrades($quiz); redirect($afteractionurl); } if (optional_param('savechanges', false, PARAM_BOOL) && confirm_sesskey()) { $deletepreviews = false; $recomputesummarks = false; $oldquestions = explode(',', $quiz->questions); // The questions in the old order. $questions = array(); // For questions in the new order. $rawdata = (array) data_submitted(); $moveonpagequestions = array(); $moveselectedonpage = optional_param('moveselectedonpagetop', 0, PARAM_INT); if (!$moveselectedonpage) { $moveselectedonpage = optional_param('moveselectedonpagebottom', 0, PARAM_INT); } foreach ($rawdata as $key => $value) { if (preg_match('!^g([0-9]+)$!', $key, $matches)) { // Parse input for question -> grades. $questionid = $matches[1]; $quiz->grades[$questionid] = unformat_float($value); quiz_update_question_instance($quiz->grades[$questionid], $questionid, $quiz); $deletepreviews = true; $recomputesummarks = true; } else { if (preg_match('!^o(pg)?([0-9]+)$!', $key, $matches)) {
// test the session actually works by redirecting to self $SESSION->wantsurl = $urltogo; redirect(new moodle_url(get_login_url(), array('testsession' => $USER->id))); } else { if (empty($errormsg)) { if ($errorcode == AUTH_LOGIN_UNAUTHORISED) { $errormsg = get_string("unauthorisedlogin", "", $frm->username); } else { $errormsg = get_string("invalidlogin"); $errorcode = 3; } } } } /// Detect problems with timedout sessions if ($session_has_timed_out and !data_submitted()) { $errormsg = get_string('sessionerroruser', 'error'); $errorcode = 4; } /// First, let's remember where the user was trying to get to before they got here if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = null; $referer = get_local_referer(false); if ($referer && $referer != $CFG->wwwroot && $referer != $CFG->wwwroot . '/' && $referer != $CFG->httpswwwroot . '/login/' && strpos($referer, $CFG->httpswwwroot . '/login/?') !== 0 && strpos($referer, $CFG->httpswwwroot . '/login/index.php') !== 0) { // There might be some extra params such as ?lang=. $SESSION->wantsurl = $referer; } } /// Redirect to alternative login URL if needed if (!empty($CFG->alternateloginurl)) { $loginurl = $CFG->alternateloginurl;
admin_externalpage_setup('assignroles', '', array('contextid' => $contextid, 'roleid' => $roleid)); admin_externalpage_print_header(''); } else { if ($context->contextlevel == CONTEXT_COURSE and $context->instanceid == SITEID) { admin_externalpage_setup('frontpageroles', '', array('contextid' => $contextid, 'roleid' => $roleid)); admin_externalpage_print_header(''); $currenttab = 'assign'; include_once 'tabs.php'; } else { $currenttab = 'assign'; include_once 'tabs.php'; } } } /// Process incoming role assignment if ($frm = data_submitted()) { if ($add and !empty($frm->addselect) and confirm_sesskey()) { foreach ($frm->addselect as $adduser) { if (!($adduser = clean_param($adduser, PARAM_INT))) { continue; } $allow = true; if ($inmeta) { if (has_capability('moodle/course:managemetacourse', $context, $adduser)) { //ok } else { $managerroles = get_roles_with_capability('moodle/course:managemetacourse', CAP_ALLOW, $context); if (!empty($managerroles) and !array_key_exists($roleid, $managerroles)) { $erruser = get_record('user', 'id', $adduser, '', '', '', '', 'id, firstname, lastname'); $errors[] = get_string('metaassignerror', 'role', fullname($erruser)); $allow = false;
function process_outcomes($userid) { global $CFG, $USER; if (empty($CFG->enableoutcomes)) { return; } require_once($CFG->libdir.'/gradelib.php'); if (!$formdata = data_submitted() or !confirm_sesskey()) { return; } $data = array(); $grading_info = grade_get_grades($this->course->id, 'mod', 'assignment', $this->assignment->id, $userid); if (!empty($grading_info->outcomes)) { foreach($grading_info->outcomes as $n=>$old) { $name = 'outcome_'.$n; if (isset($formdata->{$name}[$userid]) and $old->grades[$userid]->grade != $formdata->{$name}[$userid]) { $data[$n] = $formdata->{$name}[$userid]; } } } if (count($data) > 0) { grade_update_outcomes('mod/assignment', $this->course->id, 'mod', 'assignment', $this->assignment->id, $userid, $data); } }
$goc->courseid = $courseid; $goc->outcomeid = $oid; $DB->insert_record('grade_outcomes_courses', $goc); } } } } // find all unused standard course outcomes - candidates for removal foreach ($standardoutcomes as $oid => $outcome) { if (in_array($oid, $courseused)) { $co_standard_notused[$oid] = $standardoutcomes[$oid]; unset($standardoutcomes[$oid]); } } /// form processing if ($data = data_submitted()) { require_capability('moodle/grade:manageoutcomes', $context); if (!empty($data->add) && !empty($data->addoutcomes)) { /// add all selected to course list foreach ($data->addoutcomes as $add) { $add = clean_param($add, PARAM_INT); if (!array_key_exists($add, $standardoutcomes)) { continue; } $goc = new object(); $goc->courseid = $courseid; $goc->outcomeid = $add; $DB->insert_record('grade_outcomes_courses', $goc); } } else { if (!empty($data->remove) && !empty($data->removeoutcomes)) {
$frm->enable = array(); } if (empty($frm->default)) { $frm->default = ''; } if ($frm->default && $frm->default != 'manual' && !in_array($frm->default, $frm->enable)) { $frm->enable[] = $frm->default; } asort($frm->enable); $frm->enable = array_merge(array('manual'), $frm->enable); // make sure manual plugin is called first set_config('enrol_plugins_enabled', implode(',', $frm->enable)); set_config('enrol', $frm->default); redirect("enrol.php", get_string("changessaved"), 1); } else { if ($frm = data_submitted() and $savesettings) { if (!confirm_sesskey()) { print_error('confirmsesskeybad', 'error'); } set_config('sendcoursewelcomemessage', required_param('sendcoursewelcomemessage', PARAM_BOOL)); } } /// Print the form $str = get_strings(array('enrolmentplugins', 'users', 'administration', 'settings', 'edit')); admin_externalpage_print_header(); $modules = get_list_of_plugins("enrol"); $options = array(); foreach ($modules as $module) { $options[$module] = get_string("enrolname", "enrol_{$module}"); } asort($options);