implemented rol course tutor for students, course tutor can see reporting about all students inside course - partial BT#871

skala
cfasanando 16 years ago
parent cfc5294631
commit 84a0f4321f
  1. 8
      main/inc/lib/course_home.lib.php
  2. 37
      main/inc/lib/usermanager.lib.php
  3. 2
      main/mySpace/lp_tracking.php
  4. 2
      main/mySpace/myStudents.php
  5. 183
      main/user/userInfo.php

@ -24,7 +24,7 @@ class CourseHome {
case 'Basic' :
$condition_display_tools = ' WHERE a.link=t.link AND t.position="basic" ';
if (api_is_coach()) {
if (api_is_coach() || api_is_course_tutor()) {
$condition_display_tools = ' WHERE a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
}
@ -137,7 +137,7 @@ class CourseHome {
$tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img'];
// VISIBLE
if (($tool['visibility'] || (api_is_coach() && $tool['name'] == TOOL_TRACKING)) || $cat == 'courseAdmin' || $cat == 'platformAdmin') {
if (($tool['visibility'] || ((api_is_coach() || api_is_course_tutor()) && $tool['name'] == TOOL_TRACKING)) || $cat == 'courseAdmin' || $cat == 'platformAdmin') {
if (strpos($tool['name'], 'visio_') !== false) {
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . $tool['link'].$link_annex . '\',\'window_visio'.$_SESSION['_cid'].'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $tool['target'] . '"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
@ -224,7 +224,7 @@ class CourseHome {
case TOOL_PUBLIC:
$condition_display_tools = ' WHERE visibility = 1 ';
if (api_is_coach()) {
if (api_is_coach() || api_is_course_tutor()) {
$condition_display_tools = ' WHERE visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'") ';
}
@ -438,7 +438,7 @@ class CourseHome {
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$condition_display_tools = ' WHERE visibility = 1 AND (category = "authoring" OR category = "interaction") ';
if (api_is_coach()) {
if (api_is_coach() || api_is_course_tutor()) {
$condition_display_tools = ' WHERE (visibility = 1 AND (category = "authoring" OR category = "interaction") OR (name = "'.TOOL_TRACKING.'") ) ';
}
$sql = "SELECT * FROM $course_tool_table $condition_display_tools $condition_session ORDER BY id";

@ -3000,7 +3000,7 @@ class UserManager
* @param string The course id
* @return int The user id
*/
function get_user_id_of_course_admin_or_session_admin ($course_id) {
public function get_user_id_of_course_admin_or_session_admin ($course_id) {
$session=api_get_session_id();
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -3036,7 +3036,7 @@ class UserManager
* @param int The user id
* @return boolean
*/
function is_user_certified($cat_id,$user_id) {
public function is_user_certified($cat_id,$user_id) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql='SELECT path_certificate FROM '.$table_certificate.' WHERE cat_id="'.Database::escape_string($cat_id).'" AND user_id="'.Database::escape_string($user_id).'" ';
$rs=Database::query($sql,__FILE__,__LINE__);
@ -3054,7 +3054,7 @@ class UserManager
* @param int The user id
* @return array if there is not information return false
*/
function get_info_gradebook_certificate($course_code,$user_id) {
public function get_info_gradebook_certificate($course_code,$user_id) {
$tbl_grade_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$tbl_grade_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql='SELECT * FROM '.$tbl_grade_certificate.' WHERE cat_id= (SELECT id FROM '.$tbl_grade_category.' WHERE course_code = "'.Database::escape_string($course_code).'" ) AND user_id="'.Database::escape_string($user_id).'" ';
@ -3071,7 +3071,7 @@ class UserManager
* @param int The user id
* @return array containing path_certificate and cat_id
*/
function get_user_path_certificate($user_id) {
public function get_user_path_certificate($user_id) {
$my_certificate = array();
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_gradebook_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
@ -3096,4 +3096,33 @@ class UserManager
}
/**
* This function check if the user is a coach inside session course
* @param int User id
* @param string Course code
* @param int Session id
* @return bool True if the user is a coach
*
*/
public function is_session_course_coach($user_id, $course_code, $session_id) {
$tbl_session_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// protect data
$user_id = intval($user_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$result = false;
$sql = "SELECT id_session FROM $tbl_session_course_rel_user WHERE id_session=$session_id AND course_code='$course_code' AND id_user = $user_id AND status=2 ";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$result = true;
}
return $result;
}
}

@ -41,7 +41,7 @@ if (isset($_GET['course'])) {
$user_infos = UserManager :: get_user_info_by_id($user_id);
$name = api_get_person_name($user_infos['firstname'], $user_infos['lastname']);
if (!api_is_platform_admin(true) && !CourseManager :: is_course_teacher($_user['user_id'], $cidReq) && !Tracking :: is_allowed_to_coach_student($_user['user_id'],$_GET['student_id']) && !api_is_drh()) {
if (!api_is_platform_admin(true) && !CourseManager :: is_course_teacher($_user['user_id'], $cidReq) && !Tracking :: is_allowed_to_coach_student($_user['user_id'],$_GET['student_id']) && !api_is_drh() && !api_is_course_tutor()) {
Display::display_header('');
api_not_allowed();
Display::display_footer();

@ -158,7 +158,7 @@ if (isset ($_GET['details'])) {
api_block_anonymous_users();
if (!api_is_allowed_to_edit() && !api_is_coach() && !api_is_drh() && $_user['status'] != SESSIONADMIN && !api_is_platform_admin(true)) {
if (!api_is_allowed_to_edit() && !api_is_coach() && !api_is_drh() && !api_is_course_tutor() && $_user['status'] != SESSIONADMIN && !api_is_platform_admin(true)) {
api_not_allowed(true);
}

@ -23,6 +23,7 @@ $language_file = array ('registration', 'userInfo');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
$htmlHeadXtra[] = '<script type="text/javascript">
@ -65,7 +66,7 @@ else
}
$currentCourse = $currentCourseID;
$current_session_id = api_get_session_id();
// api_display_tool_title(get_lang("Users"));
/*
@ -208,23 +209,29 @@ if ($allowedToEditDef)
//get information about one user - task #3009
if(!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']){
$userProperties['status'] = 1;
}else{
$userProperties['status'] = 5;
}
if(!empty($_POST['promoteTutor']) && $_POST['promoteTutor']){
$userProperties['tutor'] = 1;
}else{
$userProperties['tutor'] = 0;
}
$userProperties['role'] = $_POST['role'];
if ($current_session_id) {
update_user_course_properties($userIdViewed, $courseCode, $userProperties);
$nocoach = isset($_POST['promoteTutor'])?false:true;
$res = SessionManager::set_coach_to_course_session($userIdViewed, $current_session_id, $courseCode, $nocoach);
$displayMode = "viewContentList";
} else {
if (!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']){
$userProperties['status'] = 1;
} else{
$userProperties['status'] = 5;
}
if (!empty($_POST['promoteTutor']) && $_POST['promoteTutor']){
$userProperties['tutor'] = 1;
} else{
$userProperties['tutor'] = 0;
}
$userProperties['role'] = $_POST['role'];
update_user_course_properties($userIdViewed, $courseCode, $userProperties);
}
$displayMode = "viewContentList";
}
}
@ -275,7 +282,9 @@ if (api_is_allowed_to_edit()) {
}
}
// get information about user id viewed
$user_info_viewed = api_get_user_info($userIdViewed);
$is_session_course_coach = UserManager::is_session_course_coach($userIdViewed, $_course['sysCode'], $current_session_id);
if ($displayMode == "viewDefEdit")
{
@ -369,9 +378,14 @@ elseif ($displayMode == "viewMainInfoEdit")
if ($mainUserInfo)
{
($mainUserInfo['status'] == 1) ? $courseAdminChecked = "checked" : $courseAdminChecked = "";
($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = "";
($mainUserInfo['status'] == COURSEMANAGER) ? $courseAdminChecked = "checked" : $courseAdminChecked = "";
if ($current_session_id) {
($is_session_course_coach)? $tutorChecked = "checked" : $tutorChecked = "";
} else {
($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = "";
}
$image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true);
// get the path,width and height from original picture
$big_image = $image_array['dir'].'big_'.$image_array['file'];
@ -392,25 +406,52 @@ elseif ($displayMode == "viewMainInfoEdit")
"<table width=\"80%\" border=\"0\">",
"<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
"<td align=\"left\">", get_lang('Name'), "</td>\n",
"<td width=\"100px\" align=\"left\">", get_lang('Description'), "</td>\n",
//"<td>", get_lang('Tutor'), "</td>\n",
"<td>", get_lang('CourseManager'), "</td>\n",
"</tr>\n",
"<td width=\"100px\" align=\"left\">", get_lang('Description'), "</td>\n";
if ($current_session_id) {
if ($user_info_viewed['status'] == COURSEMANAGER) {
echo "<td>", get_lang('Tutor'), "</td>\n";
}
} else {
if ($user_info_viewed['status'] == STUDENT) {
echo "<td>", get_lang('Tutor'), "</td>\n";
} else {
echo "<td>", get_lang('CourseManager'), "</td>\n";
}
}
echo "</tr>\n",
"<tr align=\"center\">",
"<td align=\"left\"><b>", htmlize(api_get_person_name($mainUserInfo['firstName'], $mainUserInfo['lastName'])), "</b></td>\n",
"<td align=\"left\"><input type=\"text\" name =\"role\" value=\"", $mainUserInfo['role'], "\" maxlength=\"40\" /></td>";
//"<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteTutor\" value=\"1\" ", $tutorChecked, " /></td>";
if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed))
{
echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteCourseAdmin\" value=\"1\"", $courseAdminChecked, " /></td>\n";
}
else
{
//aca
if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) {
if ($current_session_id) {
if ($user_info_viewed['status'] == COURSEMANAGER) {
echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteTutor\" value=\"1\" ", $tutorChecked, " /></td>";
}
} else {
if ($user_info_viewed['status'] == STUDENT) {
echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteTutor\" value=\"1\" ", $tutorChecked, " /></td>";
} else {
echo "<td><input class=\"checkbox\" type=\"checkbox\" name=\"promoteCourseAdmin\" value=\"1\"", $courseAdminChecked, " /></td>\n";
}
}
} else {
echo "<td>", get_lang('CourseManager'), "</td>\n";
}
echo "<td><button class=\"save\" type=\"submit\" name=\"submit\">".get_lang('SaveChanges')."</button></td>\n", "</tr>", "</table>", "</form>\n";
echo "<p>".Display :: encrypted_mailto_link($mainUserInfo['email'], $mainUserInfo['email'])."</p>";
@ -483,12 +524,23 @@ elseif ($displayMode == "viewContentList") // default display
echo "<table width=\"80%\" border=\"0\">",
"<tr align=\"center\" bgcolor=\"#E6E6E6\">\n",
"<td align=\"left\">",get_lang('Name'),"</td>\n",
"<td width=\"20%\" align=\"left\">",get_lang('Description'),"</td>\n",
//"<td>",get_lang('Tutor'),"</td>\n",
"<td>",get_lang('CourseManager'),"</td>\n",
($allowedToEditDef?"<td>".get_lang('Edit')."</td>\n":""),
($is_allowedToTrack?"<td>".get_lang('Tracking')."</td>\n":""),
"<td align=\"left\">".get_lang('Name')."</td>\n",
"<td width=\"20%\" align=\"left\">".get_lang('Description')."</td>\n";
if ($current_session_id) {
if ($user_info_viewed['status'] == COURSEMANAGER) {
echo "<td>".get_lang('Tutor')."</td>\n";
}
} else {
if ($user_info_viewed['status'] == STUDENT) {
echo "<td>".get_lang('Tutor')."</td>\n";
} else {
echo "<td>".get_lang('CourseManager')."</td>\n";
}
}
echo ($allowedToEditDef?"<td>".get_lang('Edit')."</td>\n":""),
($is_allowedToTrack?"<td>".get_lang('Tracking')."</td>\n":""),
"</tr>\n",
"<tr align=\"center\">\n",
@ -498,36 +550,38 @@ elseif ($displayMode == "viewContentList") // default display
//DISPLAY TABLE CONTENT
if ($current_session_id) {
if ($user_info_viewed['status'] == COURSEMANAGER) {
if ($is_session_course_coach) {
echo "<td>",get_lang('Tutor'),"</td>\n";
} else {
echo "<td> - </td>\n";
}
}
} else {
if ($user_info_viewed['status'] == STUDENT) {
if ($mainUserInfo['tutor_id'] == 1) {
echo "<td>",get_lang('Tutor'),"</td>\n";
} else {
echo "<td> - </td>\n";
}
} else {
if ($mainUserInfo['status'] == 1) {
echo "<td>",get_lang('CourseManager'),"</td>";
} else {
echo "<td> - </td>\n";
}
}
}
// deprecated feature
if ($mainUserInfo['tutor_id'] == 1)
{
//echo "<td>",get_lang('Tutor'),"</td>\n";
}
else
{
//echo "<td> - </td>\n";
}
if ($mainUserInfo['status'] == 1)
{
echo "<td>",get_lang('CourseManager'),"</td>";
}
else
{
echo "<td> - </td>\n";
}
if ($allowedToEditDef)
{
if ($allowedToEditDef) {
echo "<td>",
"<a href=\"".api_get_self()."?".api_get_cidreq()."&editMainUserInfo=$userIdViewed\">",
"<img border=\"0\" alt=\"\" src=\"../img/edit.gif\" />",
"</a>",
"</td>";
}
if ($is_allowedToTrack)
{
if ($is_allowedToTrack) {
echo "<td>",
"<a href=\"../mySpace/myStudents.php?".api_get_cidreq()."&origin=user_course&student=$userIdViewed&details=true&course=".$_course['id']."\">",
"<img border=\"0\" alt=\"".get_lang('Tracking')." : $userIdViewed\" src=\"../img/statistics.gif\" />",
@ -538,20 +592,15 @@ elseif ($displayMode == "viewContentList") // default display
"</table>";
//"<p><a href=\"mailto:",$mainUserInfo['email'],"\">",$mainUserInfo['email'],"</a>",
if (api_get_setting("show_email_addresses") == "true")
{
if (api_get_setting("show_email_addresses") == "true") {
echo "<p>". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "</p>";
}
else
{
if (api_is_allowed_to_edit())
{
} else {
if (api_is_allowed_to_edit()) {
echo "<p>". Display::encrypted_mailto_link($mainUserInfo['email'],$mainUserInfo['email']). "</p>";
}
}
if (api_get_setting('extended_profile') == 'true')
{
if (api_get_setting('extended_profile') == 'true') {
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyCompetences').'</strong></div><div>'.$mainUserInfo['competences'].'</div>';
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyDiplomas').'</strong></div><div>'.$mainUserInfo['diplomas'].'</div>';
echo '<div style="margin-top:10px;" class="actions-message"><strong>'.get_lang('MyTeach').'</strong></div><div>'.$mainUserInfo['teach'].'</div>';

Loading…
Cancel
Save