Should block global chat when taking an exercise see #5272

skala
Julio Montoya 14 years ago
parent 9d30f8b124
commit d1592f24b6
  1. 12
      main/exercice/exercise.lib.php
  2. 2
      main/exercice/exercise_result.php
  3. 6
      main/exercice/exercise_submit.php
  4. 6
      main/inc/ajax/chat.ajax.php
  5. 12
      main/inc/lib/chat.lib.php

@ -1921,3 +1921,15 @@ function displayGroupsForUser($in_separator, $in_userid) {
return $res;
}
function create_chat_exercise_session($exe_id) {
if (!isset($_SESSION['current_exercises'])) {
$_SESSION['current_exercises'] = array();
}
$_SESSION['current_exercises'][$exe_id] = true;
}
function delete_chat_exercise_session($exe_id) {
if (isset($_SESSION['current_exercises'])) {
$_SESSION['current_exercises'][$exe_id] = false;
}
}

@ -224,6 +224,8 @@ if (isset($session_control_key) && !exercise_time_control_is_valid($objExercise-
//Unset session for clock time
exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id);
delete_chat_exercise_session($exe_id);
if ($origin != 'learnpath') {
echo '<hr>';
echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-large'));

@ -55,6 +55,7 @@ if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
$htmlHeadXtra[] = api_get_js('jquery.highlight.js'); //highlight
}
//This library is necessary for the time control feature
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/stylesheet/jquery.epiclock.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/epiclock/renderers/minute/epiclock.minute.css');
@ -159,7 +160,7 @@ if ($time_control) {
//Get the expired time of the current exercice in track_e_exercices
$total_seconds = $objExercise->expired_time*60;
}
$objExercise->questionList;
$show_clock = true;
$user_id = api_get_user_id();
if ($objExercise->selectAttempts() > 0) {
@ -255,6 +256,9 @@ if (empty($exercise_stat_info)) {
if ($debug) error_log("5 exercise_stat_info[] exists getting exe_id $exe_id ");
}
//Array to check in order to block the chat
create_chat_exercise_session($exe_id);
if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
if (!empty($exercise_stat_info['questions_to_check'])) {

@ -31,6 +31,12 @@ if (!isset($_SESSION['openChatBoxes'])) {
$chat = new Chat();
if ($chat->is_chat_blocked_by_exercises()) {
//Desconnecting the user
$chat->set_user_status(0);
exit;
}
switch ($action) {
case 'chatheartbeat':
$chat->heartbeat();

@ -224,6 +224,7 @@ class Chat extends Model {
echo "1";
exit;
}
/**
* Filter chat messages to avoid XSS or other JS
* @param string Unfiltered message
@ -236,4 +237,15 @@ class Chat extends Model {
$text = str_replace("\n","<br>",$text);
return $text;
}
function is_chat_blocked_by_exercises() {
if (isset($_SESSION['current_exercises'])) {
foreach ($_SESSION['current_exercises'] as $attempt_status) {
if ($attempt_status == true) {
return true;
}
}
}
return false;
}
}

Loading…
Cancel
Save