Parcourir la source

Student view fixes see BT# 11694

jmontoyaa il y a 8 ans
Parent
commit
2731fea34b
4 fichiers modifiés avec 19 ajouts et 10 suppressions
  1. 8 7
      main/inc/lib/banner.lib.php
  2. 3 3
      main/lp/lp_controller.php
  3. 7 0
      main/session/index.php
  4. 1 0
      user_portal.php

+ 8 - 7
main/inc/lib/banner.lib.php

@@ -1,13 +1,14 @@
 <?php
 /* For licensing terms, see /license.txt */
+
+use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
+
 /**
  * Code
  * @todo use globals or parameters or add this file in the template
  * @package chamilo.include
  */
 
-use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
-
 /**
  * Determines the possible tabs (=sections) that are available.
  * This function is used when creating the tabs in the third header line and
@@ -465,9 +466,7 @@ function menuArray()
                         );
                     }
                 }
-
             } else {
-
                 $list = split("\n", $open);
                 foreach ($list as $link) {
                     $matches = array();
@@ -674,13 +673,13 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
         }
     }
 
-
     $html = '';
 
     /* Part 4 . Show the teacher view/student view button at the right of the breadcrumb */
     $view_as_student_link = null;
     if ($user_id && isset($course_id)) {
-        if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true' && api_get_course_info()) {
+        if ((api_is_course_admin() || api_is_platform_admin() || api_is_coach(null, null, false)) &&
+            api_get_setting('student_view_enabled') === 'true' && api_get_course_info()) {
             $view_as_student_link = api_display_tool_view_option();
         }
     }
@@ -743,7 +742,9 @@ function getOnlineUsersCount($cacheEnabled = false)
     if ($cacheEnabled) {
         $apc = apcu_cache_info(true);
         $apc_end = $apc['start_time'] + $apc['ttl'];
-        if (apcu_exists('my_campus_whoisonline_count_simple') AND (time() < $apc_end) AND apcu_fetch('my_campus_whoisonline_count_simple') > 0 ) {
+        if (apcu_exists('my_campus_whoisonline_count_simple') && (time() < $apc_end) &&
+            apcu_fetch('my_campus_whoisonline_count_simple') > 0
+        ) {
             $number = apcu_fetch('my_campus_whoisonline_count_simple');
         } else {
             $number = who_is_online_count(api_get_setting('time_limit_whosonline'));

+ 3 - 3
main/lp/lp_controller.php

@@ -328,11 +328,12 @@ if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
 
 if (isset($_SESSION['oLP'])) {
-    $_SESSION['oLP']->update_queue = array(); // Reinitialises array used by javascript to update items in the TOC.
+    $_SESSION['oLP']->update_queue = array();
+    // Reinitialises array used by javascript to update items in the TOC.
 }
 
 if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
-    if ($_REQUEST['action'] != 'list' && $_REQUEST['action'] != 'view') {
+    if (isset($_REQUEST['action']) && !in_array($_REQUEST['action'], ['list', 'view'])) {
         if (!empty($_REQUEST['lp_id'])) {
             $_REQUEST['action'] = 'view';
         } else {
@@ -344,7 +345,6 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'view' && !isset($_REQUEST['exeId'])) {
             $_REQUEST['action'] = 'build';
         }
-        //$_SESSION['studentview'] = null;
     }
 }
 

+ 7 - 0
main/session/index.php

@@ -667,4 +667,11 @@ echo Display::tabs(
     $tabs
 );
 
+// Deleting the objects
+Session::erase('_gid');
+Session::erase('oLP');
+Session::erase('lpobject');
+
+api_remove_in_gradebook();
+
 Display::display_footer();

+ 1 - 0
user_portal.php

@@ -237,4 +237,5 @@ $controller->tpl->display_two_col_template();
 
 // Deleting the session_id.
 Session::erase('session_id');
+Session::erase('studentview');
 api_remove_in_gradebook('in_gradebook');