changed interface of course in session for a coach when is also a teacher - partial DT#5377

skala
Cristian Fasanando 15 years ago
parent 31b995f7fd
commit db4571c5bc
  1. 10
      main/course_home/2column.php
  2. 24
      main/course_home/3column.php
  3. 81
      main/course_home/activity.php
  4. 6
      main/course_home/btf_functions.php
  5. 25
      main/inc/lib/main_api.lib.php

@ -195,7 +195,7 @@ function show_tools($course_tool_category)
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
if ($toolsRow["visibility"] == '1')
{
@ -264,7 +264,7 @@ function show_tools($course_tool_category)
if ($toolsRow["added_tool"] == 1 &&
api_is_allowed_to_edit() && !$toolsRow["visibility"])
*/
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit() && !$toolsRow["visibility"]
if ($toolsRow["added_tool"] == 1 && api_is_allowed_to_edit(null,true) && !$toolsRow["visibility"]
&& $toolsRow['image'] != 'scormbuilder.gif' && $toolsRow['image'] != 'scormbuilder_na.gif')
echo "<a class=\"nobold\" href=\"" . api_get_path(WEB_PATH) .
'main/external_module/external_module.php' .
@ -300,7 +300,7 @@ function show_tools($course_tool_category)
Work with data post askable by admin of course (franglais, clean this)
-----------------------------------------------------------
*/
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true))
{
/* Work request */
@ -408,7 +408,7 @@ echo "</div>";
*/
// start of tools for CourseAdmins (teachers/tutors)
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
echo "<div class=\"courseadminview\">";
echo "<span class=\"viewcaption\">";
@ -444,7 +444,7 @@ if (api_is_allowed_to_edit())
-----------------------------------------------------------
*/
if (api_is_platform_admin() && api_is_allowed_to_edit())
if (api_is_platform_admin() && api_is_allowed_to_edit(null,true) && !api_is_coach())
{
?>
<div class="platformadminview">

@ -43,14 +43,12 @@ $restore = isset($_GET['restore']) && $_GET['restore'] == 'yes' ? 'yes' : null;
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
include('../../main/course_home/btf_functions.php'); // RH: extra ../
$is_AllowedToEdit = is_allowed_to_edit(); // RH: Allowed is not allowed...
$TABLE_TOOLS = Database::get_main_table(TABLE_MAIN_COURSE_MODULE);
$TBL_ACCUEIL = Database::get_course_table(TABLE_TOOL_LIST);
// WORK with data post askable by admin of course
if (is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true))
{
/* Work request */
@ -161,19 +159,14 @@ if (is_allowed_to_edit())
$image = $toolsRow[3];
echo "<tr>\n",
"<td colspan=\"4\">\n",
"<table>\n",
"<tr>\n",
"<td>\n",
"<form method=\"post\" action=\"".api_get_self()."\">\n",
"<input type=\"hidden\" name=\"id\" value=\"$id\">\n",
"Image : ".Display::return_icon($image)."\n",
"</td>\n",
"<td>\n",
"<select name=\"image\">\n",
"<option selected>",$image,"</option>\n";
@ -195,28 +188,21 @@ if (is_allowed_to_edit())
}
echo "</select>\n",
"</td>\n",
"</tr>\n",
"<tr>\n",
"<td>",get_lang('NameOfTheLink')," : </td>\n",
"<td><input type=\"text\" name=\"name\" value=\"",$name,"\"></td>\n",
"</tr>\n",
"<tr>\n",
"<td>Lien :</td>\n",
"<td><input type=\"text\" name=\"link\" value=\"",$link,"\"></td>\n",
"</tr>\n",
"<tr>\n",
"<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"",get_lang('Ok'),"\"></td>\n",
"</tr>\n",
"</form>\n",
"</table>\n",
"</td>\n",
"</tr>\n";
}
@ -225,14 +211,13 @@ if (is_allowed_to_edit())
// work with data post askable by admin of course
if ($is_platformAdmin and is_allowed_to_edit())
if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
{
// Show message to confirm that a tools must be hide from aivailable tools
// visibility 0,1->2
if($askDelete)
{
echo "<table align=\"center\"><tr>\n",
"<td colspan=\"4\">\n",
"<br><br>\n",
"<font color=\"#ff0000\">",
@ -245,7 +230,6 @@ if ($is_platformAdmin and is_allowed_to_edit())
"</font>\n",
"<br><br><br>\n",
"</td>\n",
"</tr>",
"</table>\n";
} // if remove
@ -279,7 +263,7 @@ echo "</td>\n</tr>\n";
PROF ONLY VIEW
==========================*/
if (is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true) && !api_is_coach())
{
echo "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n",
"<tr>\n","<td colspan=\"6\">\n",
@ -295,7 +279,7 @@ if (is_allowed_to_edit())
TOOLS FOR PLATFORM ADMIN ONLY
--------------------------------------*/
if ($is_platformAdmin and is_allowed_to_edit())
if ($is_platformAdmin && api_is_allowed_to_edit(null,true) && !api_is_coach())
{
echo "<tr>","<td colspan=\"6\">",
"<hr noshade size=\"1\" />",

@ -54,7 +54,7 @@ function get_tools_category($course_tool_category) {
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit();
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
$all_tools_list = array();
@ -65,31 +65,33 @@ function get_tools_category($course_tool_category) {
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$result = Database::query("SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') $condition_session ORDER BY id",__FILE__,__LINE__);
//$visibility_codition = !api_is_coach()?" visibility = '1' AND ":" ";
$sql = "SELECT * FROM $course_tool_table WHERE visibility = '1' AND (category = 'authoring' OR category = 'interaction') $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_AUTHORING:
$result = Database::query("SELECT * FROM $course_tool_table WHERE category = 'authoring' $condition_session ORDER BY id",__FILE__,__LINE__);
$sql = "SELECT * FROM $course_tool_table WHERE category = 'authoring' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_INTERACTION:
$result = Database::query("SELECT * FROM $course_tool_table WHERE category = 'interaction' $condition_session ORDER BY id",__FILE__,__LINE__);
$sql = "SELECT * FROM $course_tool_table WHERE category = 'interaction' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_VISIBLE:
$result = Database::query("SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' $condition_session ORDER BY id",__FILE__,__LINE__);
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' AND visibility ='1' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
case TOOL_ADMIN_PLATEFORM:
$result = Database::query("SELECT * FROM $course_tool_table WHERE category = 'admin' $condition_session ORDER BY id",__FILE__,__LINE__);
$sql = "SELECT * FROM $course_tool_table WHERE category = 'admin' $condition_session ORDER BY id";
$result = Database::query($sql,__FILE__,__LINE__);
$colLink ="##003399";
break;
@ -216,7 +218,7 @@ function show_tools_category($all_tools_list)
global $_user;
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit();
$is_allowed_to_edit = api_is_allowed_to_edit(null,true);
$is_platform_admin = api_is_platform_admin();
if (isset($all_tools_list)) {
@ -234,7 +236,8 @@ function show_tools_category($all_tools_list)
// These links are only visible by the course manager.
unset($lnk);
echo '<td width="50%">' . "\n";
if ($is_allowed_to_edit) {
if ($is_allowed_to_edit && !api_is_coach()) {
if ($toolsRow['visibility'] == '1' && $toolsRow['admin'] !='1') {
$link['name'] = Display::return_icon('visible.gif', get_lang('Deactivate'),array('id'=>'linktool_'.$toolsRow["id"]));
@ -377,9 +380,10 @@ function show_tools_category($all_tools_list)
-----------------------------------------------------------
*/
if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
if(api_is_allowed_to_edit()) {
//$session_id = api_get_session_id();
if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
if(api_is_allowed_to_edit(null,true)) {
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$tool_id = Security::remove_XSS($_GET["id"]);
$tool_info = api_get_tool_information($tool_id);
@ -396,7 +400,24 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
$requested_visible = ($tool_visibility == 0 ) ? 1 : 0;
//HIDE AND REACTIVATE TOOL
if ($_GET["id"]==strval(intval($_GET["id"]))) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select,__FILE__,__LINE__);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else $sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
*/
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
Database::query($sql,__FILE__,__LINE__);
}
/*
@ -436,7 +457,7 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
}
} else {
if(api_is_allowed_to_edit()) {
if(api_is_allowed_to_edit(null,true)) {
/*
-----------------------------------------------------------
HIDE
@ -444,7 +465,25 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
*/
if(!empty($_GET['hide'])) // visibility 1 -> 0
{
Database::query("UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'",__FILE__,__LINE__);
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
$rs = Database::query($sql,__FILE__,__LINE__);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."' AND session_id = '".intval($session_id)."'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select,__FILE__,__LINE__);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else {
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
}*/
$sql="UPDATE $tool_table SET visibility=0 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowHidden'));
}
@ -455,7 +494,8 @@ if (isset($_GET['sent_http_request']) && $_GET['sent_http_request']==1) {
*/
elseif(!empty($_GET['restore'])) // visibility 0,2 -> 1
{
Database::query("UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'",__FILE__,__LINE__);
$sql = "UPDATE $tool_table SET visibility=1 WHERE id='".intval($_GET["id"])."'";
Database::query($sql,__FILE__,__LINE__);
Display::display_confirmation_message(get_lang('ToolIsNowVisible'));
}
}
@ -555,7 +595,8 @@ function show_session_data($id_session) {
*/
// start of tools for CourseAdmins (teachers/tutors)
if(api_is_allowed_to_edit()) {
if(api_is_allowed_to_edit(null,true) && !api_is_coach()) {
$current_protocol = $_SERVER['SERVER_PROTOCOL'];
$current_host = $_SERVER['HTTP_HOST'];
$server_protocol = substr($current_protocol,0,strrpos($current_protocol,'/'));

@ -103,7 +103,7 @@ function showtools2($cat)
{
$tbl_link = Database :: get_course_table(TABLE_LINK);
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true))
{
$sql_links = "SELECT tl.*, tip.visibility
FROM $tbl_link tl
@ -195,7 +195,7 @@ function showtools2($cat)
// INVISIBLE
else
{
if (api_is_allowed_to_edit())
if (api_is_allowed_to_edit(null,true))
{
if(strpos($toolsRow['name'],'visio_')!==false)
{
@ -227,7 +227,7 @@ function showtools2($cat)
}
$lnk = array ();
if (api_is_allowed_to_edit() and $cat != "courseAdmin" && !strpos($toolsRow['link'], 'learnpath_handler.php?learnpath_id'))
if (api_is_allowed_to_edit(null,true) && $cat != "courseAdmin" && !strpos($toolsRow['link'], 'learnpath_handler.php?learnpath_id') && !api_is_coach())
{
if ($toolsRow["visibility"])
{

@ -1921,16 +1921,15 @@ function api_display_debug_info($debug_info) {
function api_is_allowed_to_edit($tutor=false,$coach=false,$session_coach = false) {
$my_session_id = api_get_session_id();
$is_allowed_coach_to_edit = api_is_coach();
$session_visibility = api_get_session_visibility($my_session_id);
$is_courseAdmin = api_is_course_admin() || api_is_platform_admin();
if (!$is_courseAdmin && $tutor == true) { //if we also want to check if the user is a tutor...
$is_courseAdmin = $is_courseAdmin || api_is_course_tutor();
}
if (!$is_courseAdmin && $coach == true) { //if we also want to check if the user is a coach...';
// check if session visibility is read only for coachs
$is_allowed_coach_to_edit = api_is_course_coach();
$my_session_id = api_get_session_id();
$session_visibility = api_get_session_visibility($my_session_id);
// check if session visibility is read only for coachs
if ($session_visibility==SESSION_VISIBLE_READ_ONLY) {
$is_allowed_coach_to_edit = false;
}
@ -1942,12 +1941,24 @@ function api_is_allowed_to_edit($tutor=false,$coach=false,$session_coach = false
}
}
if (!$is_courseAdmin && $session_coach == true) {
if (!$is_courseAdmin && $session_coach == true) {
$is_courseAdmin = $is_courseAdmin || api_is_coach();
}
if (api_get_setting('student_view_enabled') == 'true') { //check if the student_view is enabled, and if so, if it is activated
$is_allowed = $is_courseAdmin && $_SESSION['studentview'] != "studentview";
if (!empty($my_session_id)) {
// check if session visibility is read only for coachs
if ($session_visibility==SESSION_VISIBLE_READ_ONLY) {
$is_allowed_coach_to_edit = false;
}
if (api_get_setting('allow_coach_to_edit_course_session') == 'true') { // check if coach is allowed to edit a course
$is_allowed = $is_allowed_coach_to_edit;
} else {
$is_allowed = false;
}
} else {
$is_allowed = $is_courseAdmin && $_SESSION['studentview'] != "studentview";
}
return $is_allowed;
} else {
return $is_courseAdmin;

Loading…
Cancel
Save