function local_obu_forms_extend_navigation($navigation) { global $CFG, $USER, $PAGE; if (!isloggedin() || isguestuser()) { return; } $context = context_system::instance(); $staff_manager = has_capability('local/obu_forms:manage_pg', $context) || has_capability('local/obu_forms:manage_ump_staff', $context); $students_manager = has_capability('local/obu_forms:manage_pg', $context) || has_capability('local/obu_forms:manage_ump_students', $context); $manager = $staff_manager || $students_manager; $staff = is_staff($USER->username); // Has a 'p' number? $student = is_student($USER->id); // Enrolled on a PIP-based course (programme)? // Add the 'My Forms' option if ($manager || $staff || $student || !empty(get_form_data($USER->id))) { // Find the 'myprofile' node $nodeParent = $navigation->find('myprofile', navigation_node::TYPE_UNKNOWN); // Add the option to list their completed forms if ($nodeParent) { $node = $nodeParent->add(get_string('myforms', 'local_obu_forms'), '/local/obu_forms/index.php?userid=' . $USER->id); } } if (!$manager && !$staff && !$student) { // Move on now please, nothing more to see here... return; } // Find the 'forms' node $nodeParent = $navigation->find(get_string('forms', 'local_obu_forms'), navigation_node::TYPE_SYSTEM); // If necessary, add the 'forms' node to 'home' if (!$nodeParent) { $nodeHome = $navigation->children->get('1')->parent; if ($nodeHome) { $nodeParent = $nodeHome->add(get_string('forms', 'local_obu_forms'), null, navigation_node::TYPE_SYSTEM); } } if ($nodeParent) { // For form managers, add the privileged maintenance and enquiry options if ($manager) { $node = $nodeParent->add(get_string('settings_nav', 'local_obu_forms'), '/local/obu_forms/forms.php'); $node = $nodeParent->add(get_string('template_nav', 'local_obu_forms'), '/local/obu_forms/template.php'); $node = $nodeParent->add(get_string('auths_nav', 'local_obu_forms'), '/local/obu_forms/auths.php'); $node = $nodeParent->add(get_string('sc_auths', 'local_obu_forms'), '/local/obu_forms/auths.php?authoriser=csa'); $node = $nodeParent->add(get_string('list_users_forms', 'local_obu_forms'), '/local/obu_forms/list.php'); $node = $nodeParent->add(get_string('formslist', 'local_obu_forms'), '/local/obu_forms/formslist.php'); } else { // For other users, add the option(s) to list all the relevant forms if ($staff) { $node = $nodeParent->add(get_string('staff_forms', 'local_obu_forms'), '/local/obu_forms/formslist.php?type=staff'); } $node = $nodeParent->add(get_string('student_forms', 'local_obu_forms'), '/local/obu_forms/formslist.php?type=student'); // Both staff and students can view student forms if ($staff) { $node = $nodeParent->add(get_string('list_users_forms', 'local_obu_forms'), '/local/obu_forms/list.php'); } } } }
/** * Print the student individual ranking points * * @return string */ function block_ranking_print_individual_ranking() { global $USER, $COURSE; if (!is_student($USER->id)) { return ''; } $weekstart = strtotime(date('d-m-Y', strtotime('-' . date('w') . ' days'))); $lastweekpoints = block_ranking_get_student_points_by_date($USER->id, $weekstart, time()); $lastweekpoints = $lastweekpoints->points != null ? $lastweekpoints->points : '0'; $lastweekpoints = $lastweekpoints . " " . strtolower(get_string('table_points', 'block_ranking')); $monthstart = strtotime(date('Y-m-01')); $lastmonthpoints = block_ranking_get_student_points_by_date($USER->id, $monthstart, time()); $lastmonthpoints = $lastmonthpoints->points != null ? $lastmonthpoints->points : '0'; $lastmonthpoints = $lastmonthpoints . " " . strtolower(get_string('table_points', 'block_ranking')); $totalpoints = block_ranking_get_student_points($USER->id); $totalpoints = $totalpoints->points != null ? $totalpoints->points : '0'; $totalpoints = $totalpoints . " " . strtolower(get_string('table_points', 'block_ranking')); $table = new html_table(); $table->attributes = array("class" => "rankingTable table table-striped generaltable"); $table->head = array(get_string('weekly', 'block_ranking'), get_string('monthly', 'block_ranking'), get_string('general', 'block_ranking')); $row = new html_table_row(); $row->cells = array($lastweekpoints, $lastmonthpoints, $totalpoints); $table->data[] = $row; $individualranking = html_writer::table($table); return "<h4>" . get_string('your_score', 'block_ranking') . ":</h4>" . $individualranking; }
$firstname = escape_string($_POST['firstname']); if (!isset($_POST['surname']) or $_POST['surname'] == "") { cust_die("You must submit the parents's last name."); } $surname = escape_string($_POST['surname']); if (!isset($_POST['gender']) or $_POST['gender'] == "") { cust_die("You must submit the parents's gender."); } elseif ($_POST['gender'] != "m" and $_POST['gender'] != "f") { cust_die("That is not a valid gender..."); } $gender = escape_string($_POST['gender']); if (!isset($_POST['studentid']) or $_POST['studentid'] == "" or is_numeric($_POST['studentid']) == FALSE) { cust_die("You must submit the student's ID. This probably shouldn't come up; perhaps you should submit a bug report."); } $studentID = escape_string($_POST['studentid']); if (is_student($studentID) == FALSE) { cust_die("Invalid student ID."); } if (!isset($_POST['email']) or $_POST['email'] == "") { $email = ""; } else { $email = escape_string($_POST['email']); if (is_valid_email($email) == FALSE) { cust_die("The e-mail address was not in the correct format."); } } // if they haven't entered a username, generate one using the person's name if (!isset($_POST['username']) or $_POST['username'] == "") { $username = $firstname . $surname; $username = str_replace(" ", "", $username); $username = strtolower($username);
if ($type == 'staff') { $heading = get_string('staff_forms', 'local_obu_forms'); } else { if ($type == 'student') { $heading = get_string('student_forms', 'local_obu_forms'); } else { $heading = get_string('formslist', 'local_obu_forms'); } } $PAGE->set_title($heading); $PAGE->set_heading($heading); $staff_forms = substr($USER->username, 0, 1) == 'p' && is_numeric(substr($USER->username, 1)); // Can view staff forms $pg_forms = $staff_forms || is_student($USER->id, 'PG'); // Can view PG student forms $ump_forms = $staff_forms || is_student($USER->id, 'UMP'); // Can view UMP student forms if ($type == 'student') { // Exclude staff forms $staff_forms = false; } if ($type == 'staff') { // Exclude student forms $pg_forms = false; $ump_forms = false; } // The page contents echo $OUTPUT->header(); echo $OUTPUT->heading($heading); $forms = get_forms(is_manager(), $staff_forms, $pg_forms, $ump_forms); $url = new moodle_url('/local/obu_forms/form.php');