function send_single_user_to_mumie($mumie_user) { global $CFG; global $COURSE; global $USER; //user: $newuser = new object(); $newuser->syncid = 'moodle-' . $CFG->prefix . 'user-' . $mumie_user->id; $newuser->loginname = $mumie_user->username; $newuser->passwordencrypted = $mumie_user->password; $newuser->firstname = $mumie_user->firstname; $newuser->surname = $mumie_user->lastname; $newuser->matrnumber = 'X'; insert_user_for_mumie($newuser); }
/** * Function to insert all neccesarry information out of a new MUMIE-module into MUMIE * * @param object $insert - big object with all information */ function insert_all_for_mumie($insert) { global $CFG; global $COURSE; $js = new JapsSynchronise(); //first we insert the new semester if MUMIE does not know it yet $semesterexists = check_semester($insert->semester); if (!$semesterexists) { insert_semester_for_mumie($insert->semester, $js); } //now we insert the new class $newclass = new object(); $newclass->syncid = $insert->syncid; $newclass->name = $insert->name; $newclass->description = $insert->description; $newclass->semester = $insert->semester->syncid; $newclass->lecturers = ''; //let's be sure to have all lecturers as users in the MUMIE DB if ($insert->lecturers) { foreach ($insert->lecturers as $lecturer) { //perhaps the lecturer is already in the MUMIE $lecturerexists = check_lecturer($lecturer); if (!$lecturerexists) { insert_user_for_mumie($lecturer, $js); } $newclass->lecturers .= $lecturer->syncid . ' '; } } $newclass->mumie_course_id = $insert->mumie_course_id; insert_class_for_mumie($newclass, $js); //next is the tutorials if ($insert->tutorials) { foreach ($insert->tutorials as $tutorial) { //we should make sure that the tutor is a user in the Mumie DB if ($tutorial->tutor) { //perhaps the tutor is already in the MUMIE $tutorexists = check_tutor($tutorial->tutor); $tutor_is_lecturer = check_lecturer($tutorial->tutor); if (!$tutorexists && !$tutor_is_lecturer) { insert_user_for_mumie($tutorial->tutor, $js); } $tutorial->tutor = $tutorial->tutor->syncid; } else { //no tutor => insert dummy $tutorial->tutor = 'moodle-dummy_tutor'; } $tutorial->classid = $insert->syncid; insert_tutorial_for_mumie($tutorial, $js); if ($tutorial->students) { foreach ($tutorial->students as $student) { //perhaps MUMIE already knows this student so we first check $studentexists = check_student($student); if (!$studentexists) { insert_user_for_mumie($student, $js); } add_user_to_mumie_tutorial($student->syncid, $tutorial->syncid, $js); } } } } }