//student if ($returned === false) { // no data selected for this UserNotices::display_notice($string['warning'], $string['ltinotconfigured'], '../artwork/access_denied.png', $title_color = '#C00000'); echo "\n</body>\n</html>\n"; exit; } else { //valid data list($c_internal_id, $upd) = $lti->lookup_lti_context(); $session = date_utils::get_current_academic_year(); if (is_null($c_internal_id)) { // $lti_i::invalid_module_code($c_internal_id, $data, 'no returned data'); } $data = $lti_i::module_code_translate($c_internal_id); foreach ($data as $v) { $returned_check = module_utils::get_full_details_by_name($v[1], $mysqli); if (!UserUtils::is_user_on_module_by_name($userObject->get_user_ID(), $v[1], $session, $mysqli) and $returned_check !== false and $lti_i::allow_module_self_reg($v)) { if ($returned_check['active'] == 1 and $returned_check['selfenroll'] == 1 and !UserUtils::is_user_on_module_by_name($userObject->get_user_ID(), $v[1], $session, $mysqli)) { // Insert new module enrollment UserUtils::add_student_to_module_by_name($userObject->get_user_ID(), $v[1], 1, $session, $mysqli); } } } $_SESSION['lti']['paperlink'] = $returned[0]; header("location: ../paper/user_index.php?id=" . $returned[0]); echo "Please click <a href='../paper/user_index.php?id=" . $returned[0] . ".>here</a> to continue"; exit; } } else { //staff if ($returned !== false) {
/** * Update any part of a modules DB record. * * @param integer $orig_moduleid - the code of the module to update * @param type $updateData - an array of key value pairs to update e.g 'fullname'=>'New full Name' * @param object $db - MySQLi database connection. * @return boolean */ public function update_module_by_code($orig_moduleid, $updateData, $db) { global $string; if ($orig_moduleid == '') { return false; } $orig_modinfo = $modinfo = module_utils::get_full_details_by_name($orig_moduleid, $db); if ($modinfo === false) { // The module must exist to update it! return false; } $orig_school_name = $modinfo['school']; $orig_school_id = $modinfo['schoolid']; $changed = false; foreach ($updateData as $key => $val) { $key = strtolower($key); if ($key == 'idmod') { //never change the id :-) continue; } if ($modinfo[$key] != $val) { $modinfo[$key] = $val; $changed = true; } } if (!$changed) { // Nothing has changed return return true; } // Check mandatory fields if ($modinfo['moduleid'] == '' and $modinfo['fullname'] == '') { return false; } if ($orig_school_name != $modinfo['school']) { // We have updated the school so we need to get the new id from the schools table if ($orig_school_id != $modinfo['schoolid']) { // Do nothing as the id has already been updated } else { // Lookup the schoolID $modinfo['schoolid'] = SchoolUtils::get_school_id_by_name($modinfo['school'], $db); if ($modinfo['schoolid'] === false) { // School not found ERROR return false; } } } $sql = "UPDATE modules SET \n moduleid = ?,\n fullname = ?,\n active = ?, \n vle_api = ?, \n checklist = ?, \n sms = ?, \n selfenroll = ?, \n schoolid = ?, \n neg_marking = ?, \n ebel_grid_template = ?, \n timed_exams = ?, \n exam_q_feedback = ?, \n add_team_members = ?,\n map_level = ?,\n academic_year_start = ?\n WHERE \n id = ?\n LIMIT 1\n "; $result = $db->prepare($sql); $result->bind_param('ssisssiiiiiiiisi', $modinfo['moduleid'], $modinfo['fullname'], $modinfo['active'], $modinfo['vle_api'], $modinfo['checklist'], $modinfo['sms'], $modinfo['selfenroll'], $modinfo['schoolid'], $modinfo['neg_marking'], $modinfo['ebel_grid_template'], $modinfo['timed_exams'], $modinfo['exam_q_feedback'], $modinfo['add_team_members'], $modinfo['map_level'], $modinfo['academic_year_start'], $modinfo['idMod']); $res = $result->execute(); // An array to convert DB fields to lang strings argghhh!!!! $lang_mappings = array('moduleid' => 'moduleid', 'fullname' => 'name', 'schoolid' => 'school', 'active' => 'active', 'vle_api' => 'objapi', 'checklist' => 'summativechecklist', 'sms' => 'smsapi', 'selfenroll' => 'allowselfenrol', 'neg_marking' => 'negativemarking', 'ebel_grid_template' => 'ebelgrid', 'timed_exams' => 'timedexams', 'exam_q_feedback' => 'questionbasedfeedback', 'add_team_members' => 'addteammembers', 'map_level' => 'map_level', 'academic_year_start' => 'academicyearstart'); if ($res === true) { // Log any changes $logger = new Logger($db); $userObject = UserObject::get_instance(); foreach ($modinfo as $key => $val) { $key = strtolower($key); if ($key == 'idmod') { continue; } if ($orig_modinfo[$key] != $val) { $logger->track_change('Module', $modinfo['idMod'], $userObject->get_user_ID(), $orig_modinfo[$key], $modinfo[$key], $string[$lang_mappings[$key]]); } } } return true; }