* Network Operations Center, University of Athens, * Panepistimiopolis Ilissia, 15784, Athens, Greece * e-mail: info@openeclass.org * ======================================================================== */ $require_current_course = true; $require_course_admin = true; require_once '../../include/baseTheme.php'; require_once 'include/lib/fileManageLib.inc.php'; require_once 'archive_functions.php'; $toolName = $langCourseInfo; $pageName = $langArchiveCourse; $navigation[] = array('url' => "index.php?course=$course_code", 'name' => $langCourseInfo); if (!isset($_GET['token']) || !validate_csrf_token($_GET['token'])) csrf_token_error(); doArchive($course_id, $course_code); $tool_content .= " <div class='alert alert-info'> <ol> <li>$langBUCourseDataOfMainBase $course_code</li> <li>$langBackupOfDataBase $course_code</li> </ol> </div> <div class='alert alert-success'>$langBackupSuccesfull</div>" . action_bar(array( array('title' => $langDownloadIt, 'url' => $urlAppend . "courses/archive/$course_code/$course_code-" . date('Ymd') . ".zip", 'icon' => 'fa-download',
/** * @brief display attendance users * @global type $tool_content * @global type $course_id * @global type $course_code * @global type $actID * @global type $langName * @global type $langSurname * @global type $langRegistrationDateShort * @global type $langAttendanceAbsences * @global type $langAm * @global type $langAttendanceEdit * @global type $langAttendanceBooking * @global type $langID * @param type $attendance_id */ function register_user_presences($attendance_id, $actID) { global $tool_content, $course_id, $course_code, $langAttendanceAutoBook, $langName, $langSurname, $langRegistrationDateShort, $langAttendanceAbsences, $langAm, $langAttendanceBooking, $langID, $langAttendanceEdit, $langCancel; $result = Database::get()->querySingle("SELECT * FROM attendance_activities WHERE id = ?d", $actID); $act_type = $result->auto; // type of activity $tool_content .= "<div class='alert alert-info'>" . $result->title . "</div>"; //record booking if(isset($_POST['bookUsersToAct'])) { if (!isset($_POST['token']) || !validate_csrf_token($_POST['token'])) csrf_token_error(); //get all the active users $activeUsers = Database::get()->queryArray("SELECT uid as userID FROM attendance_users WHERE attendance_id = ?d", $attendance_id); if ($activeUsers){ foreach ($activeUsers as $result) { $userInp = intval(@$_POST[$result->userID]); //get the record from the teacher (input name is the user id) // //check if there is record for the user for this activity $checkForBook = Database::get()->querySingle("SELECT COUNT(id) as count, id FROM attendance_book WHERE attendance_activity_id = ?d AND uid = ?d", $actID, $result->userID); if($checkForBook->count) { //update Database::get()->query("UPDATE attendance_book SET attend = ?d WHERE id = ?d ", $userInp, $checkForBook->id); } else { //insert Database::get()->query("INSERT INTO attendance_book SET uid = ?d, attendance_activity_id = ?d, attend = ?d, comments = ?s", $result->userID, $actID, $userInp, ''); } } Session::Messages($langAttendanceEdit,"alert-success"); redirect_to_home_page("modules/attendance/index.php"); } } //display users $resultUsers = Database::get()->queryArray("SELECT attendance_users.id AS recID, attendance_users.uid AS userID, user.surname AS surname, user.givenname AS name, user.am AS am, course_user.reg_date AS reg_date FROM attendance_users, user, course_user WHERE attendance_id = ?d AND attendance_users.uid = user.id AND `user`.id = `course_user`.`user_id` AND `course_user`.`course_id` = ?d ", $attendance_id, $course_id); if ($resultUsers) { //table to display the users $tool_content .= "<div class='form-wrapper'> <form class='form-horizontal' id='user_attendances_form' method='post' action='$_SERVER[SCRIPT_NAME]?course=$course_code&attendance_id=$attendance_id&ins=" . getIndirectReference($actID) . "'> <table id='users_table{$course_id}' class='table-default custom_list_order'> <thead> <tr> <th class='text-center' width='5%'>$langID</th> <th class='text-left'>$langName $langSurname</th> <th>$langAm</th> <th class='text-center'>$langRegistrationDateShort</th> <th class='text-center'>$langAttendanceAbsences</th> </tr> </thead> <tbody>"; $cnt = 0; foreach ($resultUsers as $resultUser) { $cnt++; $tool_content .= "<tr> <td class='text-center'>$cnt</td> <td> " . display_user($resultUser->userID). "</td> <td>$resultUser->am</td> <td class='text-center'>" . nice_format($resultUser->reg_date, true, true) . "</td> <td class='text-center'><input type='checkbox' value='1' name='userspresence[$resultUser->userID]'"; //check if the user has attendace for this activity already OR if it should be automatically inserted here $q = Database::get()->querySingle("SELECT attend FROM attendance_book WHERE attendance_activity_id = ?d AND uid = ?d", $actID, $resultUser->userID); if(isset($q->attend) && $q->attend == 1) { $tool_content .= " checked"; } $tool_content .= "><input type='hidden' value='" . getIndirectReference($actID) . "' name='actID'></td>"; $tool_content .= "</tr>"; } $tool_content .= "</tbody></table>"; $tool_content .= "<div class='form-group'>"; $tool_content .= "<div class='col-xs-12'>" . form_buttons(array( array( 'text' => $langAttendanceBooking, 'name' => 'bookUsersToAct', 'value'=> $langAttendanceBooking ))). "<a href='index.php?course=$course_code&attendance_id=" . $attendance_id . "' class='btn btn-default'>$langCancel</a>"; // if ($act_type == 1) { // $tool_content .= form_buttons(array( // array( // 'text' => $langAttendanceAutoBook, // 'name' => 'updateUsersToAct', // 'value'=> $langAttendanceAutoBook // ))); // } $tool_content .= "</div></div>"; $tool_content .= generate_csrf_token_form_field() ."</form></div>"; $tool_content .= "</tbody></table>"; } }