|
@@ -13,9 +13,11 @@ require_once __DIR__.'/../inc/global.inc.php';
|
|
|
$id_session = intval($_GET['id_session']);
|
|
|
SessionManager::protectSession($id_session);
|
|
|
$course_code = $_GET['course_code'];
|
|
|
+$course_info = api_get_course_info($_REQUEST['course_code']);
|
|
|
|
|
|
-$formSent = 0;
|
|
|
-$errorMsg = '';
|
|
|
+if (empty($course_info)) {
|
|
|
+ api_not_allowed(true);
|
|
|
+}
|
|
|
|
|
|
// Database Table Definitions
|
|
|
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
|
|
@@ -24,7 +26,6 @@ $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
|
|
|
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
|
|
|
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
|
|
|
|
|
|
-$course_info = api_get_course_info($_REQUEST['course_code']);
|
|
|
$courseId = $course_info['real_id'];
|
|
|
$tool_name = $course_info['name'];
|
|
|
$sql = "SELECT s.name, c.title
|
|
@@ -41,15 +42,18 @@ if (!list($session_name, $course_title) = Database::fetch_row($result)) {
|
|
|
exit();
|
|
|
}
|
|
|
|
|
|
-//$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin'));
|
|
|
$interbreadcrumb[] = array('url' => "session_list.php", "name" => get_lang("SessionList"));
|
|
|
-$interbreadcrumb[] = array('url' => "resume_session.php?id_session=".$id_session, "name" => get_lang('SessionOverview'));
|
|
|
-$interbreadcrumb[] = array('url' => "session_course_list.php?id_session=$id_session", "name" =>api_htmlentities($session_name, ENT_QUOTES, $charset));
|
|
|
+$interbreadcrumb[] = array(
|
|
|
+ 'url' => "resume_session.php?id_session=".$id_session,
|
|
|
+ "name" => get_lang('SessionOverview'),
|
|
|
+);
|
|
|
+$interbreadcrumb[] = array(
|
|
|
+ 'url' => "session_course_list.php?id_session=$id_session",
|
|
|
+ "name" => api_htmlentities($session_name, ENT_QUOTES, $charset),
|
|
|
+);
|
|
|
|
|
|
$arr_infos = array();
|
|
|
if (isset($_POST['formSent']) && $_POST['formSent']) {
|
|
|
- $formSent = 1;
|
|
|
-
|
|
|
// get all tutor by course_code in the session
|
|
|
$sql = "SELECT user_id
|
|
|
FROM $tbl_session_rel_course_rel_user
|
|
@@ -63,10 +67,8 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $id_coaches = $_POST['id_coach'];
|
|
|
-
|
|
|
+ $id_coaches = isset($_POST['id_coach']) ? $_POST['id_coach'] : [0];
|
|
|
if (is_array($id_coaches) && count($id_coaches) > 0) {
|
|
|
-
|
|
|
foreach ($id_coaches as $id_coach) {
|
|
|
$id_coach = intval($id_coach);
|
|
|
$rs1 = SessionManager::set_coach_to_course_session(
|
|
@@ -87,7 +89,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
|
|
|
true
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
+ Display::addFlash(Display::return_message(get_lang('Updated')));
|
|
|
header('Location: '.Security::remove_XSS($_GET['page']).'?id_session='.$id_session);
|
|
|
exit();
|
|
|
}
|
|
@@ -142,54 +144,25 @@ Display::display_header($tool_name);
|
|
|
$tool_name = get_lang('ModifySessionCourse');
|
|
|
api_display_tool_title($tool_name);
|
|
|
|
|
|
-?>
|
|
|
-<div class="session-course-edit">
|
|
|
-
|
|
|
-<form method="post" action="<?php echo api_get_self(); ?>?id_session=<?php echo $id_session; ?>&course_code=<?php echo urlencode($course_code); ?>&page=<?php echo Security::remove_XSS($_GET['page']) ?>" style="margin:0px;">
|
|
|
-<input type="hidden" name="formSent" value="1">
|
|
|
-
|
|
|
-<div class="row">
|
|
|
- <div class="col-md-12">
|
|
|
- <div class="title"></div>
|
|
|
- <?php
|
|
|
- if (!empty($errorMsg)) {
|
|
|
- echo Display::return_message($errorMsg);
|
|
|
- }
|
|
|
- ?>
|
|
|
- </div>
|
|
|
-</div>
|
|
|
-<div class="row">
|
|
|
- <div class="col-md-2">
|
|
|
- <?php echo get_lang("CoachName") ?>
|
|
|
- </div>
|
|
|
- <div class="col-md-8">
|
|
|
-
|
|
|
- <select name="id_coach[]" class="form-control" multiple>
|
|
|
- <option value="0">----- <?php echo get_lang("Choose") ?> -----</option>
|
|
|
- <option value="0" <?php if (count($arr_infos) == 0) echo 'selected="selected"'; ?>>
|
|
|
- <?php echo get_lang('None') ?>
|
|
|
- </option>
|
|
|
- <?php
|
|
|
- foreach ($coaches as $enreg) {
|
|
|
- ?>
|
|
|
- <option value="<?php echo $enreg['user_id']; ?>" <?php if (((is_array($arr_infos) && in_array($enreg['user_id'], $arr_infos)))) echo 'selected="selected"'; ?>>
|
|
|
- <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')'; ?>
|
|
|
- </option>
|
|
|
- <?php
|
|
|
- }
|
|
|
- unset($coaches);
|
|
|
- ?>
|
|
|
- </select>
|
|
|
- <div class="control">
|
|
|
- <button class="btn btn-success" type="submit" name="name" value="<?php echo get_lang('AssignCoach') ?>">
|
|
|
- <em class="fa fa-plus"></em>
|
|
|
- <?php echo get_lang('AssignCoach') ?>
|
|
|
- </button>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div class="col-md-2"></div>
|
|
|
-</div>
|
|
|
-</form>
|
|
|
-</div>
|
|
|
-<?php
|
|
|
+$form = new FormValidator(
|
|
|
+ 'form',
|
|
|
+ 'post',
|
|
|
+ api_get_self().'?id_session='.$id_session.'&course_code='.$course_code.'&page='.Security::remove_XSS($_GET['page'])
|
|
|
+);
|
|
|
+
|
|
|
+$options = [];
|
|
|
+$selected = [];
|
|
|
+foreach ($coaches as $enreg) {
|
|
|
+ $options[$enreg['user_id']] = api_get_person_name($enreg['firstname'], $enreg['lastname']).' ('.$enreg['username'].')';
|
|
|
+ if (in_array($enreg['user_id'], $arr_infos)) {
|
|
|
+ $selected[] = $enreg['user_id'];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+$form->addSelect('id_coach', get_lang('CoachName'), $options, ['multiple' => 'multiple']);
|
|
|
+$form->addHidden('formSent', 1);
|
|
|
+$form->addButtonSave(get_lang('AssignCoach'));
|
|
|
+$form->setDefaults(['id_coach' => $selected]);
|
|
|
+$form->display();
|
|
|
+
|
|
|
Display::display_footer();
|