/** * This is function verifies that the user has basic access to this page. More detailed checks * may be performed later depending on the action. * * @param int $requesttype The type of the ajax request. * */ public function verify_access($requesttype) { // Whether or not to output JSON depends on the type of request (view mail just outputs directly). $outputjson = $requesttype == 'view' ? false : true; $this->courseid = required_param('courseid', PARAM_INT); // Require users to be logged in, but do not redirect to login page -> we'll tell the user manually. try { require_login($this->courseid, false, null, false, true); } catch (Exception $e) { if ($outputjson === true) { echo json_encode(array('result' => 'false', 'text' => get_string('mailnologin', BLOCK_CM_LANG_TABLE))); } else { echo '<p>' . get_string('mailnologin', BLOCK_CM_LANG_TABLE) . '</p>'; } return false; } if (!confirm_sesskey(required_param("sesskey", PARAM_TEXT))) { if ($outputjson === true) { echo json_encode(array('result' => 'false', 'text' => get_string('mailbadsesskey', BLOCK_CM_LANG_TABLE))); } else { echo '<p>' . get_string('mailbadsesskey', BLOCK_CM_LANG_TABLE) . '</p>'; } return false; } return true; }
/** * This function checks for a user's access to a particular form/page. The main check * is requiring a user to be logged into a particular course. Optionally, it will check * for a capability and check the user's sesskey. * * @param string $capability Verify the user has this capability. * @param bool $checksesskey T/F indicating whether sesskey should be checked. * @return bool T/F indicating if access is permitted. * */ function blocks_skills_group_verify_access($capability = null, $checksesskey = false) { $courseid = required_param('courseid', PARAM_INT); try { require_login($courseid, false); } catch (Exception $e) { echo get_string('nologin', BLOCK_SG_LANG_TABLE); return false; } if ($capability != null) { if (!has_capability($capability, context_course::instance($courseid))) { echo get_string('noaccess', BLOCK_SG_LANG_TABLE); return false; } } try { if ($checksesskey != false) { if (!confirm_sesskey()) { echo get_string('badsesskey', BLOCK_SG_LANG_TABLE); return false; } } } catch (Exception $e) { echo get_string('badsesskey', BLOCK_SG_LANG_TABLE); return false; } return true; }
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); }
/** * This is function verifies that the user has basic access to this page. More detailed checks * may be performed later depending on the action. * * @param int $requesttype The type of the ajax request. * */ public function verify_access($requesttype) { $this->courseid = required_param('courseid', PARAM_INT); // Require users to be logged in, but do not redirect to login page -> we'll tell the user manually. try { require_login($this->courseid, false, null, false, true); } catch (Exception $e) { echo json_encode(array('result' => 'false', 'text' => get_string('nologin', BLOCK_SG_LANG_TABLE))); return false; } if (!confirm_sesskey(required_param("sesskey", PARAM_TEXT))) { echo json_encode(array('result' => 'false', 'text' => get_string('badsesskey', BLOCK_SG_LANG_TABLE))); return false; } return true; }
/** * process any view specific actions. * * @return void */ public function process_data() { global $CFG; // Proces csv export request. $exportcsv = optional_param('exportcsv', '', PARAM_ALPHA); if ($exportcsv and $this->param4 and confirm_sesskey()) { $this->process_export($exportcsv); return; } // Proces csv import request. $importcsv = optional_param('importcsv', 0, PARAM_INT); if ($importcsv and $this->param5 and confirm_sesskey()) { $this->process_import(); return; } parent::process_data(); }
echo '<div align="center">'; echo $OUTPUT->box($message); echo '<br/>'; echo $OUTPUT->continue_button($returnurl); echo '</div>'; } else { $yesurl = new moodle_url('/local/scheduleexam/edit.php', array('id' => $id, 'delete' => 1, 'confirm' => 1, 'sesskey' => sesskey())); $message = get_string('delconfirm', 'local_scheduleexam'); echo $OUTPUT->confirm($message, $yesurl, $returnurl); } echo $OUTPUT->footer(); die; } //to hide or unhide if ($visible != -1 and $id and confirm_sesskey()) { $result = $DB->set_field('local_scheduledexams', 'visible', $visible, array('id' => $id)); $data->visible = $DB->get_field('local_scheduledexams', 'visible', array('id' => $id)); if ($data->visible == 1) { $data->visible = 'Activated'; } else { $data->visible = 'Inactivated'; } if ($result) { $message = get_string('success', 'local_scheduleexam', $data); $style = array('style' => 'notifysuccess'); } else { $message = get_string('failure', 'local_scheduleexam', $data); $style = array('style' => 'notifyproblem'); } $hierarchy->set_confirmation($message, $returnurl, $style);
//update the registration $function = 'hub_update_site_info'; $siteinfo = $registrationmanager->get_site_info($huburl); $params = array('siteinfo' => $siteinfo); $serverurl = $huburl . "/local/hub/webservice/webservices.php"; require_once $CFG->dirroot . "/webservice/xmlrpc/lib.php"; $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $registeredhub->token); try { $result = $xmlrpcclient->call($function, $params); } catch (Exception $e) { $error = $OUTPUT->notification(get_string('errorregistration', 'hub', $e->getMessage())); } } /////// FORM REGISTRATION ACTION ////// if (!empty($fromform) and empty($update) and confirm_sesskey()) { if (!empty($fromform) and confirm_sesskey()) { // if the register button has been clicked $params = (array) $fromform; //we are using the form input as the redirection parameters (token, url and name) $unconfirmedhub = $registrationmanager->get_unconfirmedhub($huburl); if (empty($unconfirmedhub)) { //we save the token into the communication table in order to have a reference $unconfirmedhub = new stdClass(); $unconfirmedhub->token = $registrationmanager->get_site_secret_for_hub($huburl); $unconfirmedhub->secret = $unconfirmedhub->token; $unconfirmedhub->huburl = $huburl; $unconfirmedhub->hubname = $hubname; $unconfirmedhub->confirmed = 0; $unconfirmedhub->id = $registrationmanager->add_registeredhub($unconfirmedhub); } $params['token'] = $unconfirmedhub->token;
} $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;
break; } if ($extendperiod > 0) { $timeend = $timestart + $extendperiod; } else { $timeend = 0; } if (!role_assign($roleid, $adduser, 0, $context->id, $timestart, $timeend, $hidden)) { $errors[] = "Could not add user with id {$adduser} to this role!"; } } } $rolename = get_field('role', 'name', 'id', $roleid); add_to_log($course->id, 'role', 'assign', 'admin/roles/assign.php?contextid=' . $context->id . '&roleid=' . $roleid, $rolename, '', $USER->id); } else { if ($remove and !empty($frm->removeselect) and confirm_sesskey()) { $sitecontext = get_context_instance(CONTEXT_SYSTEM); $topleveladmin = false; // we only worry about this if the role has doanything capability at site level if ($context->id == $sitecontext->id && ($adminroles = get_roles_with_capability('moodle/site:doanything', CAP_ALLOW, $sitecontext))) { foreach ($adminroles as $adminrole) { if ($adminrole->id == $roleid) { $topleveladmin = true; } } } foreach ($frm->removeselect as $removeuser) { $removeuser = clean_param($removeuser, PARAM_INT); if ($topleveladmin && $removeuser == $USER->id) { // Prevent unassigning oneself from being admin continue;
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;
if ($tempcat->visible == 1) { course_category_hide($tempcat); } } } else { if ($show and confirm_sesskey()) { if ($tempcat = $DB->get_record('course_categories', array('id' => $show))) { require_capability('moodle/category:manage', get_category_or_system_context($tempcat->parent)); if ($tempcat->visible == 0) { course_category_show($tempcat); } } } } /// Move a category up or down if ((!empty($moveup) or !empty($movedown)) and confirm_sesskey()) { fix_course_sortorder(); $swapcategory = NULL; if (!empty($moveup)) { require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $moveup)); if ($movecategory = $DB->get_record('course_categories', array('id' => $moveup))) { if ($swapcategory = $DB->get_records_select('course_categories', "sortorder<? AND parent=?", array($movecategory->sortorder, $movecategory->parent), 'sortorder DESC', '*', 0, 1)) { $swapcategory = reset($swapcategory); } } } else { require_capability('moodle/category:manage', get_context_instance(CONTEXT_COURSECAT, $movedown)); if ($movecategory = $DB->get_record('course_categories', array('id' => $movedown))) { if ($swapcategory = $DB->get_records_select('course_categories', "sortorder>? AND parent=?", array($movecategory->sortorder, $movecategory->parent), 'sortorder ASC', '*', 0, 1)) { $swapcategory = reset($swapcategory); }
$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; }
if ($answer) { choice_user_submit_response($answer, $choice, $USER->id, $course, $cm); redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'choicesaved', 'sesskey' => sesskey()))); } else { if (empty($answer) and $action === 'makechoice') { // We cannot use the 'makechoice' alone because there might be some legacy renderers without it, // outdated renderers will not get the 'mustchoose' message - bad luck. redirect(new moodle_url('/mod/choice/view.php', array('id' => $cm->id, 'notify' => 'mustchooseone', 'sesskey' => sesskey()))); } } } // Completion and trigger events. choice_view($choice, $course, $cm, $context); echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($choice->name), 2, null); if ($notify and confirm_sesskey()) { if ($notify === 'choicesaved') { echo $OUTPUT->notification(get_string('choicesaved', 'choice'), 'notifysuccess'); } else { if ($notify === 'mustchooseone') { echo $OUTPUT->notification(get_string('mustchooseone', 'choice'), 'notifyproblem'); } } } /// Display the choice and possibly results $eventdata = array(); $eventdata['objectid'] = $choice->id; $eventdata['context'] = $context; /// Check to see if groups are being used in this choice $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) {
$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);
require_capability('moodle/role:assign', $context, NULL, false); $roles = get_user_roles($context, $userid, false); // verify user may unassign all roles at course context foreach ($roles as $role) { if (!user_can_assign($context, $role->roleid)) { print_error('cannotunassignrolefrom', '', '', $role->roleid); } } } else { // Unenrol yourself require_capability('moodle/role:unassignself', $context, NULL, false); } if (!empty($USER->access['rsw'][$context->path])) { print_error('cantunenrollinthisrole', '', $CFG->wwwroot . '/course/view.php?id=' . $course->id); } if ($confirm and confirm_sesskey()) { if ($userid) { if (!role_unassign(0, $userid, 0, $context->id)) { print_error("unenrolerror"); } add_to_log($course->id, 'course', 'unenrol', "view.php?id={$course->id}", $course->id); redirect($CFG->wwwroot . '/user/index.php?id=' . $course->id); } else { if (!role_unassign(0, $USER->id, 0, $context->id)) { print_error("unenrolerror"); } // force a refresh of mycourses unset($USER->mycourses); add_to_log($course->id, 'course', 'unenrol', "view.php?id={$course->id}", $course->id); redirect($CFG->wwwroot); }
quiz_remove_question($quiz, $remove); quiz_delete_previews($quiz); quiz_update_sumgrades($quiz); redirect($afteractionurl); } if (optional_param('quizdeleteselected', false, PARAM_BOOL) && !empty($selectedquestionids) && confirm_sesskey()) { foreach ($selectedquestionids as $questionid) { 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.
if ($forumidcompare and $forumtypecheck) { $url = "/mod/forum/discuss.php?d={$discussion->id}&move={$forumcm->instance}&sesskey=" . sesskey(); $forummenu[$section][$sectionname][$url] = format_string($forumcm->name); } } if (!empty($forummenu)) { echo '<div class="movediscussionoption">'; $select = new url_select($forummenu, '', array('' => get_string("movethisdiscussionto", "forum")), 'forummenu', get_string('move')); echo $OUTPUT->render($select); echo "</div>"; } } echo "</div>"; } echo '<div class="clearfloat"> </div>'; echo "</div>"; if (!empty($forum->blockafter) && !empty($forum->blockperiod)) { $a = new stdClass(); $a->blockafter = $forum->blockafter; $a->blockperiod = get_string('secondstotime' . $forum->blockperiod); echo $OUTPUT->notification(get_string('thisforumisthrottled', 'forum', $a)); } if ($forum->type == 'qanda' && !has_capability('mod/forum:viewqandawithoutposting', $modcontext) && !forum_user_has_posted($forum->id, $discussion->id, $USER->id)) { echo $OUTPUT->notification(get_string('qandanotify', 'forum')); } if ($move == -1 and confirm_sesskey()) { echo $OUTPUT->notification(get_string('discussionmoved', 'forum', format_string($forum->name, true))); } $canrate = has_capability('mod/forum:rate', $modcontext); forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate); echo $OUTPUT->footer();
$record->comentario_alumno = $fromform->comentario; if (!$DB->update_record('reservasalas_reservas', $record)) { print_error(var_dump($record)); } $action = 'ver'; } else { if (!confirm_sesskey()) { print_error("sesskey incorrecta"); } } } //Implementacion del action Cancelar // se refiere a cancelar la reserva previamente realizada } else { if ($action == 'cancelar') { if (confirm_sesskey()) { // actualiza la reserva a estado no activa $idreserva = required_param('idreserva', PARAM_INT); $data = new stdClass(); $data->id = $idreserva; $data->activa = 0; $DB->update_record('reservasalas_reservas', $data); //$DB->delete_records('reservasalas_reservas', array('id' => $idreserva)); $action = 'ver'; } else { print_error('ERROR'); } } } // Implementacion del action ver // muestra todas las reservas del usuario, las atrasadas, las confirmadas y las canceladas
$table = new course_enrolment_users_table($manager, $PAGE); // The URL of the enrolled users page for the course. $usersurl = new moodle_url('/enrol/users.php', array('id' => $course->id)); // The URl to return the user too after this screen. $returnurl = new moodle_url($usersurl, $manager->get_url_params() + $table->get_url_params()); // The URL of this page $url = new moodle_url('/enrol/globalclassroom/unenroluser.php', $returnurl->params()); $url->param('ue', $ueid); $PAGE->set_url($url); $PAGE->set_pagelayout('admin'); navigation_node::override_active_url($usersurl); list($instance, $plugin) = $manager->get_user_enrolment_components($ue); if (!$plugin->allow_unenrol($instance) || $instance->enrol != 'globalclassroom' || !$plugin instanceof enrol_globalclassroom_plugin) { print_error('erroreditenrolment', 'enrol'); } // If the unenrolment has been confirmed and the sesskey is valid unenrol the user. if ($confirm && confirm_sesskey() && $manager->unenrol_user($ue)) { redirect($returnurl); } $yesurl = new moodle_url($PAGE->url, array('confirm' => 1, 'sesskey' => sesskey())); $message = get_string('unenroluser', 'enrol_globalclassroom', array('user' => fullname($user, true), 'course' => format_string($course->fullname))); $fullname = fullname($user); $title = get_string('unenrol', 'enrol_globalclassroom'); $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->navbar->add($title); $PAGE->navbar->add($fullname); echo $OUTPUT->header(); echo $OUTPUT->heading($fullname); echo $OUTPUT->confirm($message, $yesurl, $returnurl); echo $OUTPUT->footer();
// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Remove records from database. * * @package block_eexcess * @copyright bit media e-solutions GmbH <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; $systemcontext = context_system::instance(); $id = required_param('catid', PARAM_INT); if ($id && isloggedin() && has_capability('block/eexcess:myaddinstance', $systemcontext) && confirm_sesskey()) { $tablename = "block_eexcess_interests"; $changedid = $DB->get_record($tablename, array("id" => $id), $fields = '*', $strictness = IGNORE_MISSING); $useriddb = $changedid->userid; $userid = $USER->id; if ($useriddb === $userid) { $DB->delete_records($tablename, array("id" => $id)); echo json_encode(array("success" => true)); } else { echo json_encode(array("success" => false)); } } else { $msg = get_string('interest_could_not_delete', 'block_eexcess'); echo json_encode(array("success" => false, "msg" => $msg)); }
/** * Helper function to handle edit actions * * @param object $pagemenu Page menu instance * @param string $action Action that is being performed * @return boolean If return true, then a redirect will occure (in edit.php at least) **/ function pagemenu_handle_edit_action($pagemenu, $action = NULL) { global $CFG; if (!confirm_sesskey()) { error(get_string('confirmsesskeybad', 'error')); } $linkid = required_param('linkid', PARAM_INT); if ($action === NULL) { $action = required_param('action', PARAM_ALPHA); } switch ($action) { case 'edit': case 'move': return false; break; case 'movehere': $after = required_param('after', PARAM_INT); pagemenu_move_link($pagemenu, $linkid, $after); pagemenu_set_message(get_string('linkmoved', 'pagemenu'), 'notifysuccess'); break; case 'delete': pagemenu_delete_link($linkid); pagemenu_set_message(get_string('linkdeleted', 'pagemenu'), 'notifysuccess'); break; default: error('Inavlid action: ' . $action); break; } return true; }
list($context, $course, $cm) = get_context_info_array($contextid); if ($contextid == SYSCONTEXTID) { $course = $SITE; } $PAGE->set_url('/comment/comment_ajax.php'); // Allow anonymous user to view comments providing forcelogin now enabled require_course_login($course, true, $cm); $PAGE->set_context($context); if (!empty($cm)) { $PAGE->set_cm($cm, $course); } else { if (!empty($course)) { $PAGE->set_course($course); } } if (!confirm_sesskey()) { $error = array('error' => get_string('invalidsesskey', 'error')); die(json_encode($error)); } $client_id = required_param('client_id', PARAM_ALPHANUM); $area = optional_param('area', '', PARAM_AREA); $commentid = optional_param('commentid', -1, PARAM_INT); $content = optional_param('content', '', PARAM_RAW); $itemid = optional_param('itemid', '', PARAM_INT); $page = optional_param('page', 0, PARAM_INT); $component = optional_param('component', '', PARAM_COMPONENT); // initilising comment object $args = new stdClass(); $args->context = $context; $args->course = $course; $args->cm = $cm;
} else { if ($modchooser == 0 && confirm_sesskey()) { set_user_preference('usemodchooser', $modchooser); } } if (has_capability('moodle/course:update', $context)) { if ($hide && confirm_sesskey()) { set_section_visible($course->id, $hide, '0'); redirect($PAGE->url); } if ($show && confirm_sesskey()) { set_section_visible($course->id, $show, '1'); redirect($PAGE->url); } if (!empty($section)) { if (!empty($move) and confirm_sesskey()) { if (move_section($course, $section, $move)) { if ($course->id == SITEID) { redirect($CFG->wwwroot . '/?redirect=0'); } else { redirect(course_get_url($course)); } } else { echo $OUTPUT->notification('An error occurred while moving a section'); } } } } } else { $USER->editing = 0; }
require_once $CFG->libdir . '/adminlib.php'; require_once $CFG->dirroot . '/message/lib.php'; require_once 'user_message_form.php'; $msg = optional_param('msg', '', PARAM_CLEAN); $confirm = optional_param('confirm', 0, PARAM_BOOL); admin_externalpage_setup('userbulk'); require_capability('moodle/site:readallmessages', get_context_instance(CONTEXT_SYSTEM)); $return = $CFG->wwwroot . '/' . $CFG->admin . '/user/user_bulk.php'; if (empty($SESSION->bulk_users)) { redirect($return); } if (empty($CFG->messaging)) { print_error('messagingdisable', 'error'); } //TODO: add support for large number of users if ($confirm and !empty($msg) and confirm_sesskey()) { $in = implode(',', $SESSION->bulk_users); if ($rs = $DB->get_recordset_select('user', "id IN ({$in})", null)) { foreach ($rs as $user) { message_post_message($USER, $user, $msg, FORMAT_HTML, 'direct'); } $rs->close(); } redirect($return); } // disable html editor if not enabled in preferences if (!get_user_preferences('message_usehtmleditor', 0)) { $CFG->htmleditor = ''; } $msgform = new user_message_form('user_bulk_message.php'); if ($msgform->is_cancelled()) {
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); }
// foreach ($userstoassign as $adduser) { $batches->assign_existing_userto_batches_from_assignuser_interface($userstoassign,$cohort->id); // cohort_add_member($cohort->id, $adduser->id); // } //$batches->enrol_course(); $potentialuserselector->invalidate_selected_users(); $existinguserselector->invalidate_selected_users(); } } // Process removing user assignments to the cohort if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { $userstoremove = $existinguserselector->get_selected_users(); if (!empty($userstoremove)) { foreach ($userstoremove as $removeuser) { cohort_remove_member($cohort->id, $removeuser->id); // $batches->unenrol_user($removeuser->id); } $potentialuserselector->invalidate_selected_users(); $existinguserselector->invalidate_selected_users(); } } // Print the form. ?> <form id="assignform" method="post" action="<?php echo $PAGE->url ?>"><div> <input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
if ($record or $mode == 'single') { $currenttab = 'single'; } elseif ($mode == 'asearch') { $currenttab = 'asearch'; } else { $currenttab = 'list'; } include 'tabs.php'; if ($mode == 'asearch') { $maxcount = 0; } else { /// Approve any requested records $params = array(); // named params array $approvecap = has_capability('mod/data:approve', $context); if ($approve && confirm_sesskey() && $approvecap) { if ($approverecord = $DB->get_record('data_records', array('id' => $approve))) { // Need to check this is valid if ($approverecord->dataid == $data->id) { // Must be from this database $newrecord = new stdClass(); $newrecord->id = $approverecord->id; $newrecord->approved = 1; $DB->update_record('data_records', $newrecord); echo $OUTPUT->notification(get_string('recordapproved', 'data'), 'notifysuccess'); } } } $numentries = data_numentries($data); /// Check the number of entries required against the number of entries already made (doesn't apply to teachers) if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $context)) {
public function display($quiz, $cm, $course) { global $CFG, $COURSE, $DB, $OUTPUT; $this->context = get_context_instance(CONTEXT_MODULE, $cm->id); $download = optional_param('download', '', PARAM_ALPHA); list($currentgroup, $students, $groupstudents, $allowed) = $this->load_relevant_students($cm); $pageoptions = array(); $pageoptions['id'] = $cm->id; $pageoptions['mode'] = 'overview'; $reporturl = new moodle_url('/mod/quiz/report.php', $pageoptions); $qmsubselect = quiz_report_qm_filter_select($quiz); $mform = new mod_quiz_report_overview_settings($reporturl, array('qmsubselect' => $qmsubselect, 'quiz' => $quiz, 'currentgroup' => $currentgroup, 'context' => $this->context)); if ($fromform = $mform->get_data()) { $regradeall = false; $regradealldry = false; $regradealldrydo = false; $attemptsmode = $fromform->attemptsmode; if ($qmsubselect) { $qmfilter = $fromform->qmfilter; } else { $qmfilter = 0; } $regradefilter = !empty($fromform->regradefilter); set_user_preference('quiz_report_overview_detailedmarks', $fromform->detailedmarks); set_user_preference('quiz_report_pagesize', $fromform->pagesize); $detailedmarks = $fromform->detailedmarks; $pagesize = $fromform->pagesize; } else { $regradeall = optional_param('regradeall', 0, PARAM_BOOL); $regradealldry = optional_param('regradealldry', 0, PARAM_BOOL); $regradealldrydo = optional_param('regradealldrydo', 0, PARAM_BOOL); $attemptsmode = optional_param('attemptsmode', null, PARAM_INT); if ($qmsubselect) { $qmfilter = optional_param('qmfilter', 0, PARAM_INT); } else { $qmfilter = 0; } $regradefilter = optional_param('regradefilter', 0, PARAM_INT); $detailedmarks = get_user_preferences('quiz_report_overview_detailedmarks', 1); $pagesize = get_user_preferences('quiz_report_pagesize', 0); } $this->validate_common_options($attemptsmode, $pagesize, $course, $currentgroup); $displayoptions = array(); $displayoptions['attemptsmode'] = $attemptsmode; $displayoptions['qmfilter'] = $qmfilter; $displayoptions['regradefilter'] = $regradefilter; $mform->set_data($displayoptions + array('detailedmarks' => $detailedmarks, 'pagesize' => $pagesize)); if (!$this->should_show_grades($quiz)) { $detailedmarks = 0; } // We only want to show the checkbox to delete attempts // if the user has permissions and if the report mode is showing attempts. $candelete = has_capability('mod/quiz:deleteattempts', $this->context) && $attemptsmode != QUIZ_REPORT_ATTEMPTS_STUDENTS_WITH_NO; if ($attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL) { // This option is only available to users who can access all groups in // groups mode, so setting allowed to empty (which means all quiz attempts // are accessible, is not a security porblem. $allowed = array(); } $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id); $courseshortname = format_string($course->shortname, true, array('context' => $coursecontext)); $displaycoursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id); $displaycourseshortname = format_string($COURSE->shortname, true, array('context' => $displaycoursecontext)); // Load the required questions. $questions = quiz_report_get_significant_questions($quiz); $table = new quiz_report_overview_table($quiz, $this->context, $qmsubselect, $groupstudents, $students, $detailedmarks, $questions, $candelete, $reporturl, $displayoptions); $filename = quiz_report_download_filename(get_string('overviewfilename', 'quiz_overview'), $courseshortname, $quiz->name); $table->is_downloading($download, $filename, $displaycourseshortname . ' ' . format_string($quiz->name, true)); if ($table->is_downloading()) { raise_memory_limit(MEMORY_EXTRA); } // Process actions. if (empty($currentgroup) || $groupstudents) { if (optional_param('delete', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { require_capability('mod/quiz:deleteattempts', $this->context); $this->delete_selected_attempts($quiz, $cm, $attemptids, $allowed); redirect($reporturl->out(false, $displayoptions)); } } else { if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) { if ($attemptids = optional_param('attemptid', array(), PARAM_INT)) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, false, $groupstudents, $attemptids); redirect($reporturl->out(false, $displayoptions)); } } } } if ($regradeall && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, false, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } else { if ($regradealldry && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts($quiz, true, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } else { if ($regradealldrydo && confirm_sesskey()) { require_capability('mod/quiz:regrade', $this->context); $this->regrade_attempts_needing_it($quiz, $groupstudents); redirect($reporturl->out(false, $displayoptions), '', 5); } } } // Start output. if (!$table->is_downloading()) { // Only print headers if not asked to download data $this->print_header_and_tabs($cm, $course, $quiz, 'overview'); } if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used if (!$table->is_downloading()) { groups_print_activity_menu($cm, $reporturl->out(true, $displayoptions)); } } // Print information on the number of existing attempts if (!$table->is_downloading()) { //do not print notices when downloading if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm, true, $currentgroup)) { echo '<div class="quizattemptcounts">' . $strattemptnum . '</div>'; } } $hasquestions = quiz_questions_in_quiz($quiz->questions); if (!$table->is_downloading()) { if (!$hasquestions) { echo quiz_no_questions_message($quiz, $cm, $this->context); } else { if (!$students) { echo $OUTPUT->notification(get_string('nostudentsyet')); } else { if ($currentgroup && !$groupstudents) { echo $OUTPUT->notification(get_string('nostudentsingroup')); } } } // Print display options $mform->display(); } $hasstudents = $students && (!$currentgroup || $groupstudents); if ($hasquestions && ($hasstudents || $attemptsmode == QUIZ_REPORT_ATTEMPTS_ALL)) { // Construct the SQL $fields = $DB->sql_concat('u.id', "'#'", 'COALESCE(quiza.attempt, 0)') . ' AS uniqueid, '; if ($qmsubselect) { $fields .= "(CASE " . " WHEN {$qmsubselect} THEN 1" . " ELSE 0 " . "END) AS gradedattempt, "; } list($fields, $from, $where, $params) = $this->base_sql($quiz, $qmsubselect, $qmfilter, $attemptsmode, $allowed); $table->set_count_sql("SELECT COUNT(1) FROM {$from} WHERE {$where}", $params); // Test to see if there are any regraded attempts to be listed. $fields .= ", COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) AS regraded"; if ($regradefilter) { $where .= " AND COALESCE((\n SELECT MAX(qqr.regraded)\n FROM {quiz_overview_regrades} qqr\n WHERE qqr.questionusageid = quiza.uniqueid\n ), -1) <> -1"; } $table->set_sql($fields, $from, $where, $params); if (!$table->is_downloading()) { // Regrade buttons if (has_capability('mod/quiz:regrade', $this->context)) { $regradesneeded = $this->count_question_attempts_needing_regrade($quiz, $groupstudents); if ($currentgroup) { $a = new stdClass(); $a->groupname = groups_get_group_name($currentgroup); $a->coursestudents = get_string('participants'); $a->countregradeneeded = $regradesneeded; $regradealldrydolabel = get_string('regradealldrydogroup', 'quiz_overview', $a); $regradealldrylabel = get_string('regradealldrygroup', 'quiz_overview', $a); $regradealllabel = get_string('regradeallgroup', 'quiz_overview', $a); } else { $regradealldrydolabel = get_string('regradealldrydo', 'quiz_overview', $regradesneeded); $regradealldrylabel = get_string('regradealldry', 'quiz_overview'); $regradealllabel = get_string('regradeall', 'quiz_overview'); } $displayurl = new moodle_url($reporturl, $displayoptions + array('sesskey' => sesskey())); echo '<div class="mdl-align">'; echo '<form action="' . $displayurl->out_omit_querystring() . '">'; echo '<div>'; echo html_writer::input_hidden_params($displayurl); echo '<input type="submit" name="regradeall" value="' . $regradealllabel . '"/>'; echo '<input type="submit" name="regradealldry" value="' . $regradealldrylabel . '"/>'; if ($regradesneeded) { echo '<input type="submit" name="regradealldrydo" value="' . $regradealldrydolabel . '"/>'; } echo '</div>'; echo '</form>'; echo '</div>'; } // Print information on the grading method if ($strattempthighlight = quiz_report_highlighting_grading_method($quiz, $qmsubselect, $qmfilter)) { echo '<div class="quizattemptcounts">' . $strattempthighlight . '</div>'; } } // Define table columns $columns = array(); $headers = array(); if (!$table->is_downloading() && $candelete) { $columns[] = 'checkbox'; $headers[] = null; } $this->add_user_columns($table, $columns, $headers); $this->add_time_columns($columns, $headers); if ($detailedmarks) { foreach ($questions as $slot => $question) { // Ignore questions of zero length $columns[] = 'qsgrade' . $slot; $header = get_string('qbrief', 'quiz', $question->number); if (!$table->is_downloading()) { $header .= '<br />'; } else { $header .= ' '; } $header .= '/' . quiz_rescale_grade($question->maxmark, $quiz, 'question'); $headers[] = $header; } } if (!$table->is_downloading() && has_capability('mod/quiz:regrade', $this->context) && $this->has_regraded_questions($from, $where, $params)) { $columns[] = 'regraded'; $headers[] = get_string('regrade', 'quiz_overview'); } $this->add_grade_columns($quiz, $columns, $headers); $this->set_up_table_columns($table, $columns, $headers, $reporturl, $displayoptions, false); $table->set_attribute('class', 'generaltable generalbox grades'); $table->out($pagesize, true); } if (!$table->is_downloading() && $this->should_show_grades($quiz)) { if ($currentgroup && $groupstudents) { list($usql, $params) = $DB->get_in_or_equal($groupstudents); $params[] = $quiz->id; if ($DB->record_exists_select('quiz_grades', "userid {$usql} AND quiz = ?", $params)) { $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id, 'groupid' => $currentgroup)); $graphname = get_string('overviewreportgraphgroup', 'quiz_overview', groups_get_group_name($currentgroup)); echo $OUTPUT->heading($graphname); echo html_writer::tag('div', html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $graphname)), array('class' => 'graph')); } } if ($DB->record_exists('quiz_grades', array('quiz' => $quiz->id))) { $graphname = get_string('overviewreportgraph', 'quiz_overview'); $imageurl = new moodle_url('/mod/quiz/report/overview/overviewgraph.php', array('id' => $quiz->id)); echo $OUTPUT->heading($graphname); echo html_writer::tag('div', html_writer::empty_tag('img', array('src' => $imageurl, 'alt' => $graphname)), array('class' => 'graph')); } } return true; }
echo format_text(get_string('choosereadme', 'theme_' . $theme->name), FORMAT_MOODLE); echo $OUTPUT->box_end(); echo $OUTPUT->continue_button($CFG->wwwroot . '/theme/index.php'); echo $OUTPUT->footer(); exit; } else { if ($choose && $device && !theme_is_device_locked($device) && !$unsettheme && confirm_sesskey()) { // Load the theme to make sure it is valid. $theme = theme_config::load($choose); // Get the config argument for the chosen device. $themename = core_useragent::get_device_type_cfg_var_name($device); set_config($themename, $theme->name); $urlconfirm = new moodle_url('/theme/index.php', array('confirmation' => 1, 'choose' => $choose)); redirect($urlconfirm); } else { if ($device && !theme_is_device_locked($device) && $unsettheme && confirm_sesskey() && $device != 'default') { // Unset the theme and continue. unset_config(core_useragent::get_device_type_cfg_var_name($device)); $device = ''; } } } } // Otherwise, show either a list of devices, or is enabledevicedetection set to no or a // device is specified show a list of themes. $table = new html_table(); $table->data = array(); $heading = ''; if (!empty($CFG->enabledevicedetection) && empty($device)) { $heading = get_string('selectdevice', 'admin'); // Display a list of devices that a user can select a theme for.