Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
pull/2487/head
Scrutinizer Auto-Fixer 8 years ago
parent 1575f4e8fd
commit d05e2344ef
  1. 122
      main/admin/user_move_stats.php
  2. 30
      main/auth/courses_categories.php
  3. 2
      main/auth/external_login/login.ws.php
  4. 98
      main/exercise/hotspot_admin.inc.php
  5. 38
      main/exercise/multiple_answer.class.php
  6. 196
      main/gradebook/gradebook.php
  7. 42
      main/gradebook/lib/be/learnpathlink.class.php
  8. 2
      main/gradebook/lib/fe/evalform.class.php
  9. 2
      main/inc/lib/course_home.lib.php
  10. 110
      main/inc/lib/geometry.lib.php
  11. 170
      main/inc/lib/myspace.lib.php
  12. 4
      main/inc/lib/specific_fields_manager.lib.php
  13. 30
      main/inc/lib/userportal.lib.php
  14. 42
      main/lp/aicc.class.php
  15. 1102
      main/lp/learnpath.class.php
  16. 486
      main/lp/learnpathItem.class.php
  17. 74
      plugin/bbb/lib/bbb.lib.php

@ -8,11 +8,11 @@
$cidReset = true; $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$this_section=SECTION_PLATFORM_ADMIN; $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(); api_protect_admin_script();
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$debug = 0; $debug = 0;
function compare_data($result_message) { function compare_data($result_message) {
@ -31,7 +31,7 @@ function compare_data($result_message) {
if (is_array($data)) { if (is_array($data)) {
foreach ($data as $id => $item) { foreach ($data as $id => $item) {
if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP' ) { if ($table == 'TRACK_E_EXERCISES' || $table == 'TRACK_E_EXERCISES_IN_LP') {
echo "<br /><h3>".get_lang('Attempt')." #$id</h3>"; echo "<br /><h3>".get_lang('Attempt')." #$id</h3>";
echo '<h3>'; echo '<h3>';
echo get_lang('Exercise').' #'.$item['exe_exo_id']; echo get_lang('Exercise').' #'.$item['exe_exo_id'];
@ -42,17 +42,17 @@ function compare_data($result_message) {
echo '</h3>'; echo '</h3>';
} }
//Process data //Process data
$array = array('exe_date' =>get_lang('Date'), 'exe_result' =>get_lang('Score'),'exe_weighting'=>get_lang('Weighting')); $array = array('exe_date' =>get_lang('Date'), 'exe_result' =>get_lang('Score'), 'exe_weighting'=>get_lang('Weighting'));
foreach($item as $key=> $value) { foreach ($item as $key=> $value) {
if (in_array($key,array_keys($array))) { if (in_array($key, array_keys($array))) {
$key = $array[$key]; $key = $array[$key];
echo "$key = $value <br />"; echo "$key = $value <br />";
} }
} }
} else { } else {
echo "<br /><h3>".get_lang('Id')." #$id</h3>"; echo "<br /><h3>".get_lang('Id')." #$id</h3>";
//process data //process data
foreach($item as $key=> $value) { foreach ($item as $key=> $value) {
echo "$key = $value <br />"; echo "$key = $value <br />";
} }
} }
@ -77,7 +77,7 @@ if (isset($_REQUEST['load_ajax'])) {
$session = $em->find('ChamiloCoreBundle:Session', $new_session_id); $session = $em->find('ChamiloCoreBundle:Session', $new_session_id);
//if (!isset($_REQUEST['view_stat'])) { //if (!isset($_REQUEST['view_stat'])) {
if ($origin_session_id == $new_session_id ) { if ($origin_session_id == $new_session_id) {
echo get_lang('CantMoveToTheSameSession'); echo get_lang('CantMoveToTheSameSession');
exit; exit;
} }
@ -97,7 +97,7 @@ if (isset($_REQUEST['load_ajax'])) {
$result_message_compare = array(); $result_message_compare = array();
$update_database = true; $update_database = true;
if (isset($_REQUEST['view_stat']) && $_REQUEST['view_stat'] == 1 ) { if (isset($_REQUEST['view_stat']) && $_REQUEST['view_stat'] == 1) {
$update_database = false; $update_database = false;
} }
@ -109,7 +109,7 @@ if (isset($_REQUEST['load_ajax'])) {
if (empty($result) || !in_array($user_id, array_keys($result))) { if (empty($result) || !in_array($user_id, array_keys($result))) {
if ($debug) echo 'User added to the session'; if ($debug) echo 'User added to the session';
//Registering user to the new session //Registering user to the new session
SessionManager::subscribe_users_to_session($new_session_id,array($user_id),false); SessionManager::subscribe_users_to_session($new_session_id, array($user_id), false);
} }
//Begin with the import process //Begin with the import process
@ -124,7 +124,7 @@ if (isset($_REQUEST['load_ajax'])) {
$TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW);
$TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK); $TBL_NOTEBOOK = Database::get_course_table(TABLE_NOTEBOOK);
$TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $TBL_STUDENT_PUBLICATION = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $TBL_STUDENT_PUBLICATION_ASSIGNMENT = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
$TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TBL_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE); $TBL_DROPBOX_FILE = Database::get_course_table(TABLE_DROPBOX_FILE);
@ -138,8 +138,8 @@ if (isset($_REQUEST['load_ajax'])) {
WHERE c_id = $course_id AND session_id = $origin_session_id AND exe_user_id = $user_id "; WHERE c_id = $course_id AND session_id = $origin_session_id AND exe_user_id = $user_id ";
$res = Database::query($sql); $res = Database::query($sql);
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[$row['exe_id']]= $row; $list[$row['exe_id']] = $row;
} }
if (!empty($list)) if (!empty($list))
@ -149,7 +149,7 @@ if (isset($_REQUEST['load_ajax'])) {
$res = Database::query($sql); $res = Database::query($sql);
$result_message[$TABLETRACK_EXERCICES]++; $result_message[$TABLETRACK_EXERCICES]++;
} else { } else {
if(!empty($data['orig_lp_id']) && !empty($data['orig_lp_item_id'])) { if (!empty($data['orig_lp_id']) && !empty($data['orig_lp_item_id'])) {
$result_message['TRACK_E_EXERCISES'][$exe_id] = $data; $result_message['TRACK_E_EXERCISES'][$exe_id] = $data;
} else { } else {
$result_message['TRACK_E_EXERCISES_IN_LP'][$exe_id] = $data; $result_message['TRACK_E_EXERCISES_IN_LP'][$exe_id] = $data;
@ -165,8 +165,8 @@ if (isset($_REQUEST['load_ajax'])) {
WHERE c_id = $course_id AND session_id = $new_session_id AND exe_user_id = $user_id "; WHERE c_id = $course_id AND session_id = $new_session_id AND exe_user_id = $user_id ";
$res = Database::query($sql); $res = Database::query($sql);
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[$row['exe_id']]= $row; $list[$row['exe_id']] = $row;
} }
if (!empty($list)) if (!empty($list))
@ -176,7 +176,7 @@ if (isset($_REQUEST['load_ajax'])) {
$res = Database::query($sql); $res = Database::query($sql);
$result_message[$TABLETRACK_EXERCICES]++; $result_message[$TABLETRACK_EXERCICES]++;
} else { } else {
if(!empty($data['orig_lp_id']) && !empty($data['orig_lp_item_id'])) { if (!empty($data['orig_lp_id']) && !empty($data['orig_lp_item_id'])) {
$result_message_compare['TRACK_E_EXERCISES'][$exe_id] = $data; $result_message_compare['TRACK_E_EXERCISES'][$exe_id] = $data;
} else { } else {
$result_message_compare['TRACK_E_EXERCISES_IN_LP'][$exe_id] = $data; $result_message_compare['TRACK_E_EXERCISES_IN_LP'][$exe_id] = $data;
@ -193,7 +193,7 @@ if (isset($_REQUEST['load_ajax'])) {
WHERE c_id = $course_id AND session_id = $origin_session_id AND user_id = $user_id "; WHERE c_id = $course_id AND session_id = $origin_session_id AND user_id = $user_id ";
$res = Database::query($sql); $res = Database::query($sql);
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[$row['course_access_id']] = $row; $list[$row['course_access_id']] = $row;
} }
@ -216,7 +216,7 @@ if (isset($_REQUEST['load_ajax'])) {
AND access_user_id = $user_id "; AND access_user_id = $user_id ";
$res = Database::query($sql); $res = Database::query($sql);
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$list[] = $row['access_id']; $list[] = $row['access_id'];
} }
if (!empty($list)) if (!empty($list))
@ -242,7 +242,7 @@ if (isset($_REQUEST['load_ajax'])) {
$flat_list = $lp_list->get_flat_list(); $flat_list = $lp_list->get_flat_list();
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
//Checking if the LP exist in the new session //Checking if the LP exist in the new session
if (in_array($row['lp_id'], array_keys($flat_list))) { if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row; $list[$row['id']] = $row;
@ -259,8 +259,8 @@ if (isset($_REQUEST['load_ajax'])) {
$result_message[$TBL_LP_VIEW]++; $result_message[$TBL_LP_VIEW]++;
} else { } else {
//Getting all information of that lp_item_id //Getting all information of that lp_item_id
$score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']),$origin_session_id); $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id);
$progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']),$origin_session_id); $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $origin_session_id);
$result_message['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); $result_message['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress);
} }
} }
@ -276,7 +276,7 @@ if (isset($_REQUEST['load_ajax'])) {
$flat_list = $lp_list->get_flat_list(); $flat_list = $lp_list->get_flat_list();
$list = array(); $list = array();
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
//Checking if the LP exist in the new session //Checking if the LP exist in the new session
if (in_array($row['lp_id'], array_keys($flat_list))) { if (in_array($row['lp_id'], array_keys($flat_list))) {
$list[$row['id']] = $row; $list[$row['id']] = $row;
@ -285,8 +285,8 @@ if (isset($_REQUEST['load_ajax'])) {
if (!empty($list)) if (!empty($list))
foreach ($list as $id=>$data) { foreach ($list as $id=>$data) {
//Getting all information of that lp_item_id //Getting all information of that lp_item_id
$score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $score = Tracking::get_avg_student_score($user_id, $origin_course_code, array($data['lp_id']), $new_session_id);
$progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id); $progress = Tracking::get_avg_student_progress($user_id, $origin_course_code, array($data['lp_id']), $new_session_id);
$result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress); $result_message_compare['LP_VIEW'][$data['lp_id']] = array('score' => $score, 'progress' =>$progress);
} }
} }
@ -297,7 +297,7 @@ if (isset($_REQUEST['load_ajax'])) {
//calendar_event_attachment no problems no session_id //calendar_event_attachment no problems no session_id
$sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id "; $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'calendar_event' AND insert_user_id = $user_id AND c_id = $course_id ";
$res = Database::query($sql); $res = Database::query($sql);
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['ref']; $id = $row['ref'];
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_AGENDA SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id "; $sql = "UPDATE $TBL_AGENDA SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id ";
@ -317,24 +317,24 @@ if (isset($_REQUEST['load_ajax'])) {
$sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id"; $sql = "SELECT ref FROM $TBL_ITEM_PROPERTY WHERE tool = 'work' AND insert_user_id = $user_id AND c_id = $course_id";
if ($debug) echo $sql; if ($debug) echo $sql;
$res = Database::query($sql); $res = Database::query($sql);
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['ref']; $id = $row['ref'];
$sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $id AND session_id = $origin_session_id AND c_id = $course_id"; $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $id AND session_id = $origin_session_id AND c_id = $course_id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$sub_res = Database::query($sql); $sub_res = Database::query($sql);
if (Database::num_rows($sub_res) > 0 ) { if (Database::num_rows($sub_res) > 0) {
$data = Database::fetch_array($sub_res,'ASSOC'); $data = Database::fetch_array($sub_res, 'ASSOC');
if ($debug) var_dump($data); if ($debug) var_dump($data);
$parent_id = $data['parent_id']; $parent_id = $data['parent_id'];
if (isset($data['parent_id']) && !empty($data['parent_id'])) { if (isset($data['parent_id']) && !empty($data['parent_id'])) {
$sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id"; $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION WHERE id = $parent_id AND c_id = $course_id";
$select_res = Database::query($sql); $select_res = Database::query($sql);
$parent_data = Database::fetch_array($select_res,'ASSOC'); $parent_data = Database::fetch_array($select_res, 'ASSOC');
if ($debug) var_dump($parent_data); if ($debug) var_dump($parent_data);
$sys_course_path = api_get_path(SYS_COURSE_PATH); $sys_course_path = api_get_path(SYS_COURSE_PATH);
$course_dir = $sys_course_path . $course_info['path']; $course_dir = $sys_course_path.$course_info['path'];
$base_work_dir = $course_dir . '/work'; $base_work_dir = $course_dir.'/work';
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php'; require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
//Creating the parent folder in the session if does not exists already //Creating the parent folder in the session if does not exists already
@ -349,8 +349,8 @@ if (isset($_REQUEST['load_ajax'])) {
$sub_res = Database::query($sql); $sub_res = Database::query($sql);
$num_rows = Database::num_rows($sub_res); $num_rows = Database::num_rows($sub_res);
if ($num_rows > 0 ) { if ($num_rows > 0) {
$new_result = Database::fetch_array($sub_res,'ASSOC'); $new_result = Database::fetch_array($sub_res, 'ASSOC');
$created_dir = $new_result['url']; $created_dir = $new_result['url'];
$new_parent_id = $new_result['id']; $new_parent_id = $new_result['id'];
} else { } else {
@ -368,7 +368,7 @@ if (isset($_REQUEST['load_ajax'])) {
->setCId($course_id) ->setCId($course_id)
->setTitle($parent_data['title']) ->setTitle($parent_data['title'])
->setDescription( ->setDescription(
$parent_data['description'] . "folder_moved_from_session_id_$origin_session_id" $parent_data['description']."folder_moved_from_session_id_$origin_session_id"
) )
->setActive(false) ->setActive(false)
->setAccepted(true) ->setAccepted(true)
@ -390,11 +390,11 @@ if (isset($_REQUEST['load_ajax'])) {
//Creating student_publication_assignment if exists //Creating student_publication_assignment if exists
$sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION_ASSIGNMENT WHERE publication_id = $parent_id AND c_id = $course_id"; $sql = "SELECT * FROM $TBL_STUDENT_PUBLICATION_ASSIGNMENT WHERE publication_id = $parent_id AND c_id = $course_id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$rest_select = Database::query($sql); $rest_select = Database::query($sql);
if (Database::num_rows($rest_select) > 0 ) { if (Database::num_rows($rest_select) > 0) {
if ($update_database) { if ($update_database) {
$assignment_data = Database::fetch_array($rest_select,'ASSOC'); $assignment_data = Database::fetch_array($rest_select, 'ASSOC');
$sql_add_publication = "INSERT INTO " . $TBL_STUDENT_PUBLICATION_ASSIGNMENT . " SET $sql_add_publication = "INSERT INTO ".$TBL_STUDENT_PUBLICATION_ASSIGNMENT." SET
c_id = '$course_id', c_id = '$course_id',
expires_on = '".$assignment_data['expires_on']."', expires_on = '".$assignment_data['expires_on']."',
ends_on = '".$assignment_data['ends_on']."', ends_on = '".$assignment_data['ends_on']."',
@ -402,15 +402,15 @@ if (isset($_REQUEST['load_ajax'])) {
enable_qualification = '".$assignment_data['enable_qualification']."', enable_qualification = '".$assignment_data['enable_qualification']."',
publication_id = '".$new_parent_id."'"; publication_id = '".$new_parent_id."'";
if ($debug) echo $sql_add_publication; if ($debug) echo $sql_add_publication;
$rest_select = Database::query($sql_add_publication); $rest_select = Database::query($sql_add_publication);
$id = Database::insert_id(); $id = Database::insert_id();
$sql_update = "UPDATE " . $TBL_STUDENT_PUBLICATION . " SET " . $sql_update = "UPDATE ".$TBL_STUDENT_PUBLICATION." SET ".
"has_properties = '".$id."', "has_properties = '".$id."',
view_properties = '1' view_properties = '1'
WHERE id = ".$new_parent_id; WHERE id = ".$new_parent_id;
if ($debug) echo $sql_update; if ($debug) echo $sql_update;
$rest_update = Database::query($sql_update); $rest_update = Database::query($sql_update);
if ($debug) var_dump($sql_update); if ($debug) var_dump($sql_update);
@ -430,7 +430,7 @@ if (isset($_REQUEST['load_ajax'])) {
->setUrl($new_url) ->setUrl($new_url)
->setCId($course_id) ->setCId($course_id)
->setTitle($data['title']) ->setTitle($data['title'])
->setDescription($data['description'] . ' file moved') ->setDescription($data['description'].' file moved')
->setActive($data['active']) ->setActive($data['active'])
->setAccepted($data['accepted']) ->setAccepted($data['accepted'])
->setPostGroupId($data['post_group_id']) ->setPostGroupId($data['post_group_id'])
@ -455,7 +455,7 @@ if (isset($_REQUEST['load_ajax'])) {
unlink($full_file_name); unlink($full_file_name);
$sql = "DELETE FROM $TBL_STUDENT_PUBLICATION WHERE id= ".$data['id']; $sql = "DELETE FROM $TBL_STUDENT_PUBLICATION WHERE id= ".$data['id'];
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$result_delete = Database::query($sql); $result_delete = Database::query($sql);
api_item_property_update($course_info, 'work', $data['id'], 'DocumentDeleted', api_get_user_id()); api_item_property_update($course_info, 'work', $data['id'], 'DocumentDeleted', api_get_user_id());
} }
} }
@ -472,7 +472,7 @@ if (isset($_REQUEST['load_ajax'])) {
$sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id"; $sql = "SELECT id FROM $TBL_DROPBOX_FILE WHERE uploader_id = $user_id AND session_id = $origin_session_id AND c_id = $course_id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$res = Database::query($sql); $res = Database::query($sql);
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['id']; $id = $row['id'];
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_DROPBOX_FILE SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id"; $sql = "UPDATE $TBL_DROPBOX_FILE SET session_id = $new_session_id WHERE c_id = $course_id AND id = $id";
@ -496,7 +496,7 @@ if (isset($_REQUEST['load_ajax'])) {
WHERE user_id = $user_id AND session_id = $origin_session_id AND course = '$origin_course_code' AND c_id = $course_id"; WHERE user_id = $user_id AND session_id = $origin_session_id AND course = '$origin_course_code' AND c_id = $course_id";
if ($debug) var_dump($sql); if ($debug) var_dump($sql);
$res = Database::query($sql); $res = Database::query($sql);
while($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$id = $row['notebook_id']; $id = $row['notebook_id'];
if ($update_database) { if ($update_database) {
$sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id"; $sql = "UPDATE $TBL_NOTEBOOK SET session_id = $new_session_id WHERE c_id = $course_id AND notebook_id = $id";
@ -520,7 +520,7 @@ if (isset($_REQUEST['load_ajax'])) {
echo '<tr>'; echo '<tr>';
echo '<td width="50%" valign="top">'; echo '<td width="50%" valign="top">';
if ($origin_session_id == 0 ) { if ($origin_session_id == 0) {
echo '<h4>'.get_lang('OriginCourse').'</h4>'; echo '<h4>'.get_lang('OriginCourse').'</h4>';
} else { } else {
echo '<h4>'.get_lang('OriginSession').' #'.$origin_session_id.'</h4>'; echo '<h4>'.get_lang('OriginSession').' #'.$origin_session_id.'</h4>';
@ -528,7 +528,7 @@ if (isset($_REQUEST['load_ajax'])) {
compare_data($result_message); compare_data($result_message);
echo '</td>'; echo '</td>';
echo '<td width="50%" valign="top">'; echo '<td width="50%" valign="top">';
if ($new_session_id == 0 ) { if ($new_session_id == 0) {
echo '<h4>'.get_lang('DestinyCourse').'</h4>'; echo '<h4>'.get_lang('DestinyCourse').'</h4>';
} else { } else {
echo '<h4>'.get_lang('DestinySession').' #'.$new_session_id.'</h4>'; echo '<h4>'.get_lang('DestinySession').' #'.$new_session_id.'</h4>';
@ -592,8 +592,8 @@ function get_courses_list_by_user_id_based_in_exercises($user_id) {
$res = Database::query($sql); $res = Database::query($sql);
$course_list = array(); $course_list = array();
while ($row = Database::fetch_array($res,'ASSOC')) { while ($row = Database::fetch_array($res, 'ASSOC')) {
$course_list []= $row; $course_list [] = $row;
} }
return $course_list; return $course_list;
} }
@ -601,7 +601,7 @@ function get_courses_list_by_user_id_based_in_exercises($user_id) {
Display::display_header(get_lang('MoveUserStats')); Display::display_header(get_lang('MoveUserStats'));
echo '<div class="actions">'; echo '<div class="actions">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'',ICON_SIZE_MEDIUM).'</a>'; echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>'; echo '</div>';
Display::addFlash(Display::return_message(get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'), 'normal', false)); Display::addFlash(Display::return_message(get_lang('CompareUserResultsBetweenCoursesAndCoursesInASession'), 'normal', false));
@ -613,19 +613,19 @@ if (isset($_GET['page']) && !empty($_GET['page'])) {
} }
$default = 20; $default = 20;
$count = UserManager::get_number_of_users(); $count = UserManager::get_number_of_users();
$nro_pages = round($count/$default) + 1; $nro_pages = round($count / $default) + 1;
$begin = $default* ($page - 1); $begin = $default * ($page - 1);
$end = $default*$page; $end = $default * $page;
$navigation = "$begin - $end / $count<br />"; $navigation = "$begin - $end / $count<br />";
if ($page > 1) { if ($page > 1) {
$navigation .='<a href="'.api_get_self().'?page='.($page - 1).'">'.get_lang('Previous').'</a>'; $navigation .= '<a href="'.api_get_self().'?page='.($page - 1).'">'.get_lang('Previous').'</a>';
} else { } else {
$navigation .= get_lang('Previous'); $navigation .= get_lang('Previous');
} }
$navigation .= '&nbsp;'; $navigation .= '&nbsp;';
$page ++; $page++;
if ($page < $nro_pages) if ($page < $nro_pages)
$navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>'; $navigation .= '<a href="'.api_get_self().'?page='.$page.'">'.get_lang('Next').'</a>';
else else
@ -633,11 +633,11 @@ else
echo $navigation; echo $navigation;
$user_list = UserManager::get_user_list(array(), array(), $begin, $default); $user_list = UserManager::get_user_list(array(), array(), $begin, $default);
$session_list = SessionManager::get_sessions_list(array(),array('name')); $session_list = SessionManager::get_sessions_list(array(), array('name'));
$options = ''; $options = '';
$options .= '<option value="0">--'.get_lang('SelectASession').'--</option>'; $options .= '<option value="0">--'.get_lang('SelectASession').'--</option>';
foreach ($session_list as $session_data) { foreach ($session_list as $session_data) {
$my_session_list[$session_data['id']] =$session_data['name']; $my_session_list[$session_data['id']] = $session_data['name'];
$options .= '<option value="'.$session_data['id'].'">'.$session_data['name'].'</option>'; $options .= '<option value="'.$session_data['id'].'">'.$session_data['name'].'</option>';
} }
@ -686,7 +686,7 @@ if (!empty($user_list)) {
$course['name'] = $courseInfo['name']; $course['name'] = $courseInfo['name'];
} }
$course_list = $course_list_registered; $course_list = $course_list_registered;
echo '<div>'; echo '<div>';
echo '<table class="data_table">'; echo '<table class="data_table">';
@ -721,7 +721,7 @@ if (!empty($user_list)) {
$session_id = $course['id_session']; $session_id = $course['id_session'];
} }
echo '<td>'; echo '<td>';
echo get_lang('MoveTo'); echo '<br />'; echo get_lang('MoveTo'); echo '<br />';
$unique_id = uniqid(); $unique_id = uniqid();
$combinations[$unique_id] = array('course_code' =>$course_code, 'session_id'=>$session_id); $combinations[$unique_id] = array('course_code' =>$course_code, 'session_id'=>$session_id);

@ -92,9 +92,9 @@ $code = isset($code) ? $code : null;
$pageLength = (!empty($_REQUEST['pageLength']) ? intval($_REQUEST['pageLength']) : 10); $pageLength = (!empty($_REQUEST['pageLength']) ? intval($_REQUEST['pageLength']) : 10);
$pageCurrent = (!empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1); $pageCurrent = (!empty($_REQUEST['pageCurrent']) ? intval($_REQUEST['pageCurrent']) : 1);
$form = '<form action="'.$webAction.'" method="GET" >'; $form = '<form action="'.$webAction.'" method="GET" >';
$form .= '<input type="hidden" name="action" value="' . $action . '">'; $form .= '<input type="hidden" name="action" value="'.$action.'">';
$form .= '<input type="hidden" name="pageCurrent" value="' . $pageCurrent . '">'; $form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">';
$form .= '<input type="hidden" name="pageLength" value="' . $pageLength . '">'; $form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$form .= '<div class="form-group">'; $form .= '<div class="form-group">';
$form .= '<label>'.get_lang('CourseCategories').'</label>'; $form .= '<label>'.get_lang('CourseCategories').'</label>';
$form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">'; $form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">';
@ -102,11 +102,11 @@ $code = isset($code) ? $code : null;
foreach ($browse_course_categories[0] as $category) { foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code']; $categoryCode = $category['code'];
$countCourse = $category['count_courses']; $countCourse = $category['count_courses'];
$form .= '<option '. ($categoryCode == $codeType? 'selected="selected" ':'') .' value="' . $category['code'] . '">' . $category['name'] . ' ( '. $countCourse .' ) </option>'; $form .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '').' value="'.$category['code'].'">'.$category['name'].' ( '.$countCourse.' ) </option>';
if (!empty($browse_course_categories[$categoryCode])) { if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory){ foreach ($browse_course_categories[$categoryCode] as $subCategory) {
$subCategoryCode = $subCategory['code']; $subCategoryCode = $subCategory['code'];
$form .= '<option '. ($subCategoryCode == $codeType ? 'selected="selected" ':'') .' value="' . $subCategory['code'] . '"> ---' . $subCategory['name'] . ' ( '. $subCategory['count_courses'] .' ) </option>'; $form .= '<option '.($subCategoryCode == $codeType ? 'selected="selected" ' : '').' value="'.$subCategory['code'].'"> ---'.$subCategory['name'].' ( '.$subCategory['count_courses'].' ) </option>';
} }
} }
} }
@ -330,7 +330,7 @@ function return_teacher($course)
$html .= '<div class="block-author">'; $html .= '<div class="block-author">';
$length = count($teachers); $length = count($teachers);
foreach ($teachers as $value) { foreach ($teachers as $value) {
$name = $value['firstname'].' ' . $value['lastname']; $name = $value['firstname'].' '.$value['lastname'];
if ($length > 2) { if ($length > 2) {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'"> $html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">
@ -340,7 +340,7 @@ function return_teacher($course)
<img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>'; <img src="'.$value['avatar'].'" alt="'.get_lang('UserPicture').'"/></a>';
$html .= '<div class="teachers-details"><h5> $html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">' <a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
. $name . '</a></h5><p>'. get_lang('Teacher').'</p></div>'; . $name.'</a></h5><p>'.get_lang('Teacher').'</p></div>';
} }
} }
$html .= '</div>'; $html .= '</div>';
@ -363,7 +363,7 @@ function return_title($course, $registeredUser)
if (!$registeredUser) { if (!$registeredUser) {
$html .= $title; $html .= $title;
} else { } else {
$html .= '<a title="'.$title.'" href="' . $linkCourse . '">' . $title . '</a>'; $html .= '<a title="'.$title.'" href="'.$linkCourse.'">'.$title.'</a>';
} }
$html .= '</h4></div>'; $html .= '</h4></div>';
@ -396,7 +396,7 @@ function return_description_button($course)
api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'], api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'],
array( array(
'class' => 'ajax btn btn-default btn-sm', 'class' => 'ajax btn btn-default btn-sm',
'data-title' => $title,'title' => get_lang('Description'), 'data-title' => $title, 'title' => get_lang('Description'),
'aria-label' => get_lang('Description') 'aria-label' => get_lang('Description')
) )
); );
@ -412,7 +412,7 @@ function return_description_button($course)
*/ */
function return_goto_button($course) function return_goto_button($course)
{ {
$title=get_lang('GoToCourse'); $title = get_lang('GoToCourse');
$html = Display::url( $html = Display::url(
Display::returnFontAwesomeIcon('share'), Display::returnFontAwesomeIcon('share'),
api_get_course_url($course['code']), api_get_course_url($course['code']),
@ -438,7 +438,7 @@ function return_already_registered_label($in_status)
$html = Display::tag( $html = Display::tag(
'span', 'span',
$icon . ' ' . $title, $icon.' '.$title,
array('id' => 'register', 'class' => 'label-subscribed text-success', 'title' => $title, 'aria-label' => $title) array('id' => 'register', 'class' => 'label-subscribed text-success', 'title' => $title, 'aria-label' => $title)
); );
@ -458,8 +458,8 @@ function return_register_button($course, $stok, $code, $search_term)
{ {
$title = get_lang('Subscribe'); $title = get_lang('Subscribe');
$html = Display::url( $html = Display::url(
Display::returnFontAwesomeIcon('check') . ' ' . $title, Display::returnFontAwesomeIcon('check').' '.$title,
api_get_self() . '?action=subscribe_course&sec_token=' . $stok. api_get_self().'?action=subscribe_course&sec_token='.$stok.
'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code, '&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
array('class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title) array('class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title)
); );
@ -480,7 +480,7 @@ function return_unregister_button($course, $stok, $search_term, $code)
$title = get_lang('UnsubscriptionAllowed'); $title = get_lang('UnsubscriptionAllowed');
$html = Display::url( $html = Display::url(
Display::returnFontAwesomeIcon('sign-in').' '.$title, Display::returnFontAwesomeIcon('sign-in').' '.$title,
api_get_self() . '?action=unsubscribe&sec_token='.$stok api_get_self().'?action=unsubscribe&sec_token='.$stok
.'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code, .'&unsubscribe='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
array('class' => 'btn btn-danger btn-sm', 'title' => $title, 'aria-label' => $title) array('class' => 'btn btn-danger btn-sm', 'title' => $title, 'aria-label' => $title)
); );

@ -62,7 +62,7 @@ function loginWSAuthenticate($username, $password, $wsUrl)
$key = '-+*%$({[]})$%*+-'; $key = '-+*%$({[]})$%*+-';
// Complete password con PKCS7-specific padding // Complete password con PKCS7-specific padding
$blockSize = 16; $blockSize = 16;
$padding = $blockSize - (strlen($password)%$blockSize); $padding = $blockSize - (strlen($password) % $blockSize);
$password .= str_repeat(chr($padding), $padding); $password .= str_repeat(chr($padding), $padding);
$cipher = new Crypt_AES(CRYPT_AES_MODE_CFB); $cipher = new Crypt_AES(CRYPT_AES_MODE_CFB);
$cipher->setKeyLength(128); $cipher->setKeyLength(128);

@ -27,7 +27,7 @@ $okPicture = empty($pictureName) ? false : true;
if ($modifyIn) { if ($modifyIn) {
if ($debug > 0) { if ($debug > 0) {
echo '$modifyIn was set' . "<br />\n"; echo '$modifyIn was set'."<br />\n";
} }
// if the user has chosen to modify the question only in the current exercise // if the user has chosen to modify the question only in the current exercise
if ($modifyIn == 'thisExercise') { if ($modifyIn == 'thisExercise') {
@ -66,7 +66,7 @@ if ($modifyIn) {
unset($buttonBack); unset($buttonBack);
} }
$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercise/admin.php?' . api_get_cidreq() . '&exerciseId=' . $exerciseId; $hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&exerciseId='.$exerciseId;
// the answer form has been submitted // the answer form has been submitted
$submitAnswers = isset($_POST['submitAnswers']) ? true : false; $submitAnswers = isset($_POST['submitAnswers']) ? true : false;
@ -76,13 +76,13 @@ $nbrAnswers = isset($_POST['nbrAnswers']) ? intval($_POST['nbrAnswers']) : 0;
if ($submitAnswers || $buttonBack) { if ($submitAnswers || $buttonBack) {
if ($answerType == HOT_SPOT) { if ($answerType == HOT_SPOT) {
if ($debug > 0) { if ($debug > 0) {
echo '$submitAnswers or $buttonBack was set' . "<br />\n"; echo '$submitAnswers or $buttonBack was set'."<br />\n";
} }
$questionWeighting = $nbrGoodAnswers = 0; $questionWeighting = $nbrGoodAnswers = 0;
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
@ -116,7 +116,7 @@ if ($submitAnswers || $buttonBack) {
if (empty($msgErr)) { if (empty($msgErr)) {
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
@ -124,7 +124,7 @@ if ($submitAnswers || $buttonBack) {
$weighting[$i] = ($weighting[$i]); //it can be float $weighting[$i] = ($weighting[$i]); //it can be float
if ($weighting[$i]) { if ($weighting[$i]) {
$questionWeighting+=$weighting[$i]; $questionWeighting += $weighting[$i];
} }
// creates answer // creates answer
@ -147,15 +147,15 @@ if ($submitAnswers || $buttonBack) {
$editQuestion = $questionId; $editQuestion = $questionId;
unset($modifyAnswers); unset($modifyAnswers);
echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>'; echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'&message=ItemUpdated"</script>';
} }
if ($debug > 0) { if ($debug > 0) {
echo '$modifyIn was set - end' . "<br />\n"; echo '$modifyIn was set - end'."<br />\n";
} }
} else { } else {
if ($debug > 0) { if ($debug > 0) {
echo '$submitAnswers or $buttonBack was set' . "<br />\n"; echo '$submitAnswers or $buttonBack was set'."<br />\n";
} }
$questionWeighting = $nbrGoodAnswers = 0; $questionWeighting = $nbrGoodAnswers = 0;
@ -170,7 +170,7 @@ if ($submitAnswers || $buttonBack) {
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
@ -195,7 +195,7 @@ if ($submitAnswers || $buttonBack) {
$threadhold3_str = intval($threadhold3[$i]); $threadhold3_str = intval($threadhold3[$i]);
} }
$threadhold_total = $threadhold1_str . ';' . $threadhold2_str . ';' . $threadhold3_str; $threadhold_total = $threadhold1_str.';'.$threadhold2_str.';'.$threadhold3_str;
if (isset($try[$i]) && $try[$i] == 'on') { if (isset($try[$i]) && $try[$i] == 'on') {
$try_str = 1; $try_str = 1;
@ -221,7 +221,7 @@ if ($submitAnswers || $buttonBack) {
$question_str = $select_question[$i]; $question_str = $select_question[$i];
} }
$destination[$i] = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; $destination[$i] = $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str;
// checks if field is empty // checks if field is empty
if (empty($reponse[$i]) && $reponse[$i] != '0') { if (empty($reponse[$i]) && $reponse[$i] != '0') {
@ -279,12 +279,12 @@ if ($submitAnswers || $buttonBack) {
$question_str = $selectQuestionNoError; $question_str = $selectQuestionNoError;
} }
$destination_noerror = $threadhold_total . '@@' . $try_str . '@@' . $lp_str . '@@' . $question_str . '@@' . $url_str; $destination_noerror = $threadhold_total.'@@'.$try_str.'@@'.$lp_str.'@@'.$question_str.'@@'.$url_str;
if (empty($msgErr)) { if (empty($msgErr)) {
for ($i = 1; $i <= $nbrAnswers; $i++) { for ($i = 1; $i <= $nbrAnswers; $i++) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
} }
$reponse[$i] = trim($reponse[$i]); $reponse[$i] = trim($reponse[$i]);
@ -292,7 +292,7 @@ if ($submitAnswers || $buttonBack) {
$weighting[$i] = ($weighting[$i]); //it can be float $weighting[$i] = ($weighting[$i]); //it can be float
if ($weighting[$i]) { if ($weighting[$i]) {
$questionWeighting+=$weighting[$i]; $questionWeighting += $weighting[$i];
} }
// creates answer // creates answer
@ -327,14 +327,14 @@ if ($submitAnswers || $buttonBack) {
$editQuestion = $questionId; $editQuestion = $questionId;
unset($modifyAnswers); unset($modifyAnswers);
echo '<script type="text/javascript">window.location.href="' . $hotspot_admin_url . '&message=ItemUpdated"</script>'; echo '<script type="text/javascript">window.location.href="'.$hotspot_admin_url.'&message=ItemUpdated"</script>';
} }
} }
} }
if ($modifyAnswers) { if ($modifyAnswers) {
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 0) . '$modifyAnswers is set' . "<br />\n"; echo str_repeat('&nbsp;', 0).'$modifyAnswers is set'."<br />\n";
} }
// construction of the Answer object // construction of the Answer object
@ -342,7 +342,7 @@ if ($modifyAnswers) {
Session::write('objAnswer', $objAnswer); Session::write('objAnswer', $objAnswer);
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 2) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 2).'$answerType is HOT_SPOT'."<br />\n";
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
@ -524,11 +524,11 @@ if ($modifyAnswers) {
} }
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 2) . '$usedInSeveralExercises is untrue' . "<br />\n"; echo str_repeat('&nbsp;', 2).'$usedInSeveralExercises is untrue'."<br />\n";
} }
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 4) . '$answerType is HOT_SPOT' . "<br />\n"; echo str_repeat('&nbsp;', 4).'$answerType is HOT_SPOT'."<br />\n";
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
@ -568,14 +568,14 @@ if ($modifyAnswers) {
Display::tag( Display::tag(
'h3', 'h3',
get_lang('Question') . ": " . $questionName . Display::return_icon('info3.gif', strip_tags(get_lang('HotspotChoose'))) get_lang('Question').": ".$questionName.Display::return_icon('info3.gif', strip_tags(get_lang('HotspotChoose')))
); );
if (!empty($msgErr)) { if (!empty($msgErr)) {
echo Display::return_message($msgErr, 'normal'); //main API echo Display::return_message($msgErr, 'normal'); //main API
} }
$hotspot_admin_url = api_get_path(WEB_CODE_PATH) . 'exercise/admin.php?' . api_get_cidreq() . '&hotspotadmin=' . $modifyAnswers . '&exerciseId=' . $exerciseId . '&' . api_get_cidreq(); $hotspot_admin_url = api_get_path(WEB_CODE_PATH).'exercise/admin.php?'.api_get_cidreq().'&hotspotadmin='.$modifyAnswers.'&exerciseId='.$exerciseId.'&'.api_get_cidreq();
?> ?>
<form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise" name="frm_exercise"> <form method="post" action="<?php echo $hotspot_admin_url; ?>" class="form-horizontal" id="frm_exercise" name="frm_exercise">
<div class="form-group"> <div class="form-group">
@ -612,7 +612,7 @@ if ($modifyAnswers) {
<th><?php echo get_lang('Comment'); ?></th> <th><?php echo get_lang('Comment'); ?></th>
<?php <?php
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
echo '<th >' . get_lang('Scenario') . '</th>'; echo '<th >'.get_lang('Scenario').'</th>';
} }
} else { ?> } else { ?>
<th colspan="2"> <th colspan="2">
@ -641,36 +641,36 @@ if ($modifyAnswers) {
$isSelected = true; $isSelected = true;
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>'; $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
} }
if ($isSelected) { if ($isSelected) {
$option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp; $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else { } else {
$option_lp = '<option value="0" selected="selected" >' . get_lang('SelectTargetLP') . '</option>' . $option_lp; $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} }
// Feedback SELECT // Feedback SELECT
$question_list = $objExercise->selectQuestionList(); $question_list = $objExercise->selectQuestionList();
$option_feed = ''; $option_feed = '';
$option_feed.='<option value="0">' . get_lang('SelectTargetQuestion') . '</option>'; $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
foreach ($question_list as $key => $questionid) { foreach ($question_list as $key => $questionid) {
$selected = ''; $selected = '';
$question = Question::read($questionid); $question = Question::read($questionid);
$val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
if (isset($select_question[$i]) && $questionid == $select_question[$i]) { if (isset($select_question[$i]) && $questionid == $select_question[$i]) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>'; $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
} }
if (isset($select_question[$i]) && $select_question[$i] == -1) { if (isset($select_question[$i]) && $select_question[$i] == -1) {
$option_feed .= '<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>'; $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
} else { } else {
$option_feed .= '<option value="-1">' . get_lang('ExitTest') . '</option>'; $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
} }
//-------- IF it is a delineation //-------- IF it is a delineation
@ -684,9 +684,9 @@ if ($modifyAnswers) {
$selected2 = 'selected="selected"'; $selected2 = 'selected="selected"';
if ($k == $threadhold3[$i]) if ($k == $threadhold3[$i])
$selected3 = 'selected="selected"'; $selected3 = 'selected="selected"';
$option1.='<option ' . $selected1 . ' >' . $k . ' % </option>'; $option1 .= '<option '.$selected1.' >'.$k.' % </option>';
$option2.='<option ' . $selected2 . ' >' . $k . ' % </option>'; $option2 .= '<option '.$selected2.' >'.$k.' % </option>';
$option3.='<option ' . $selected3 . '>' . $k . ' %</option>'; $option3 .= '<option '.$selected3.'>'.$k.' %</option>';
} }
?> ?>
<tr> <tr>
@ -730,7 +730,7 @@ if ($modifyAnswers) {
<div class="checkbox"> <div class="checkbox">
<p> <p>
<label> <label>
<input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> /> <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -783,7 +783,7 @@ if ($modifyAnswers) {
<div class="checkbox"> <div class="checkbox">
<p> <p>
<label> <label>
<input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> /> <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -848,7 +848,7 @@ if ($modifyAnswers) {
<div class="checkbox"> <div class="checkbox">
<p> <p>
<label> <label>
<input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> /> <input type="checkbox" class="checkbox" name="<?php echo 'try['.$i; ?>]" <?php if (isset($try[$i]) && $try[$i] == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?> <?php echo get_lang('TryAgain'); ?>
</label> </label>
</p> </p>
@ -888,12 +888,12 @@ if ($modifyAnswers) {
<input class="form-control" type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($responseValue); ?>" /> <input class="form-control" type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($responseValue); ?>" />
</td> </td>
<?php <?php
$form = new FormValidator('form_' . $i); $form = new FormValidator('form_'.$i);
$config = array( $config = array(
'ToolbarSet' => 'TestProposedAnswer', 'ToolbarSet' => 'TestProposedAnswer',
'cols-size' => [0, 12, 0] 'cols-size' => [0, 12, 0]
); );
$form->addHtmlEditor('comment[' . $i . ']', null, false, false, $config); $form->addHtmlEditor('comment['.$i.']', null, false, false, $config);
$renderer = $form->defaultRenderer(); $renderer = $form->defaultRenderer();
$form_template = '{content}'; $form_template = '{content}';
$renderer->setFormTemplate($form_template); $renderer->setFormTemplate($form_template);
@ -902,7 +902,7 @@ if ($modifyAnswers) {
{element}'; {element}';
$renderer->setElementTemplate($element_template); $renderer->setElementTemplate($element_template);
$form->setDefaults(array('comment[' . $i . ']' => $commentValue)); $form->setDefaults(array('comment['.$i.']' => $commentValue));
$return = $form->return_form(); $return = $form->return_form();
?> ?>
<td colspan="2" align="left" ><?php echo $return; ?></td> <td colspan="2" align="left" ><?php echo $return; ?></td>
@ -939,35 +939,35 @@ if ($modifyAnswers) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
$isSelected = true; $isSelected = true;
} }
$option_lp.='<option value="' . $id . '" ' . $selected . '>' . $details['lp_name'] . '</option>'; $option_lp .= '<option value="'.$id.'" '.$selected.'>'.$details['lp_name'].'</option>';
} }
if ($isSelected) { if ($isSelected) {
$option_lp = '<option value="0">' . get_lang('SelectTargetLP') . '</option>' . $option_lp; $option_lp = '<option value="0">'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} else { } else {
$option_lp = '<option value="0" selected="selected" >' . get_lang('SelectTargetLP') . '</option>' . $option_lp; $option_lp = '<option value="0" selected="selected" >'.get_lang('SelectTargetLP').'</option>'.$option_lp;
} }
// Feedback SELECT // Feedback SELECT
$question_list = $objExercise->selectQuestionList(); $question_list = $objExercise->selectQuestionList();
$option_feed = ''; $option_feed = '';
$option_feed.='<option value="0">' . get_lang('SelectTargetQuestion') . '</option>'; $option_feed .= '<option value="0">'.get_lang('SelectTargetQuestion').'</option>';
$details = isset($details) ? $details : null; $details = isset($details) ? $details : null;
$id = isset($id) ? $id : 0; $id = isset($id) ? $id : 0;
$selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null; $selectQuestionNoError = isset($selectQuestionNoError) ? $selectQuestionNoError : null;
foreach ($question_list as $key => $questionid) { foreach ($question_list as $key => $questionid) {
$selected = ''; $selected = '';
$question = Question::read($questionid); $question = Question::read($questionid);
$val = 'Q' . $key . ' :' . substrwords($question->selectTitle(), ICON_SIZE_SMALL); $val = 'Q'.$key.' :'.substrwords($question->selectTitle(), ICON_SIZE_SMALL);
if ($questionid == $selectQuestionNoError) { if ($questionid == $selectQuestionNoError) {
$selected = 'selected="selected"'; $selected = 'selected="selected"';
} }
$option_feed.='<option value="' . $questionid . '" ' . $selected . ' >' . $val . '</option>'; $option_feed .= '<option value="'.$questionid.'" '.$selected.' >'.$val.'</option>';
} }
if ($selectQuestionNoError == -1) { if ($selectQuestionNoError == -1) {
$option_feed.='<option value="-1" selected="selected" >' . get_lang('ExitTest') . '</option>'; $option_feed .= '<option value="-1" selected="selected" >'.get_lang('ExitTest').'</option>';
} else { } else {
$option_feed.='<option value="-1">' . get_lang('ExitTest') . '</option>'; $option_feed .= '<option value="-1">'.get_lang('ExitTest').'</option>';
} }
if ($answerType == HOT_SPOT_DELINEATION) { if ($answerType == HOT_SPOT_DELINEATION) {
@ -1058,6 +1058,6 @@ if ($modifyAnswers) {
</script> </script>
<?php <?php
if ($debug > 0) { if ($debug > 0) {
echo str_repeat('&nbsp;', 0) . '$modifyAnswers was set - end' . "<br />\n"; echo str_repeat('&nbsp;', 0).'$modifyAnswers was set - end'."<br />\n";
} }
} }

@ -38,7 +38,7 @@ class MultipleAnswer extends Question
'Height' => '125' 'Height' => '125'
); );
$nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? $_POST['nb_answers'] : 4; // The previous default value was 2. See task #1759.
$nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0)); $nb_answers += (isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0));
$obj_ex = Session::read('objExercise'); $obj_ex = Session::read('objExercise');
@ -48,11 +48,11 @@ class MultipleAnswer extends Question
$html = '<table class="table table-striped table-hover"> $html = '<table class="table table-striped table-hover">
<thead> <thead>
<tr> <tr>
<th width="10">' . get_lang('Number') . '</th> <th width="10">' . get_lang('Number').'</th>
<th width="10">' . get_lang('True') . '</th> <th width="10">' . get_lang('True').'</th>
<th width="50%">' . get_lang('Answer') . '</th> <th width="50%">' . get_lang('Answer').'</th>
<th width="50%">' . get_lang('Comment') . '</th> <th width="50%">' . get_lang('Comment').'</th>
<th width="10">' . get_lang('Weighting') . '</th> <th width="10">' . get_lang('Weighting').'</th>
</tr> </tr>
</thead> </thead>
<tbody>'; <tbody>';
@ -81,10 +81,10 @@ class MultipleAnswer extends Question
for ($i = 1; $i <= $nb_answers; ++$i) { for ($i = 1; $i <= $nb_answers; ++$i) {
$form->addHtml('<tr>'); $form->addHtml('<tr>');
if (is_object($answer)) { if (is_object($answer)) {
$defaults['answer[' . $i . ']'] = $answer->answer[$i]; $defaults['answer['.$i.']'] = $answer->answer[$i];
$defaults['comment[' . $i . ']'] = $answer->comment[$i]; $defaults['comment['.$i.']'] = $answer->comment[$i];
$defaults['weighting[' . $i . ']'] = float_format($answer->weighting[$i], 1); $defaults['weighting['.$i.']'] = float_format($answer->weighting[$i], 1);
$defaults['correct[' . $i . ']'] = $answer->correct[$i]; $defaults['correct['.$i.']'] = $answer->correct[$i];
} else { } else {
$defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2'); $defaults['answer[1]'] = get_lang('DefaultMultipleAnswer2');
$defaults['comment[1]'] = get_lang('DefaultMultipleComment2'); $defaults['comment[1]'] = get_lang('DefaultMultipleComment2');
@ -100,26 +100,26 @@ class MultipleAnswer extends Question
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'correct[' . $i . ']' 'correct['.$i.']'
); );
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'counter[' . $i . ']' 'counter['.$i.']'
); );
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'answer[' . $i . ']' 'answer['.$i.']'
); );
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'comment[' . $i . ']' 'comment['.$i.']'
); );
$renderer->setElementTemplate( $renderer->setElementTemplate(
'<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', '<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>',
'weighting[' . $i . ']' 'weighting['.$i.']'
); );
$answer_number = $form->addElement('text', 'counter[' . $i . ']', null, 'value="' . $i . '"'); $answer_number = $form->addElement('text', 'counter['.$i.']', null, 'value="'.$i.'"');
$answer_number->freeze(); $answer_number->freeze();
$form->addElement( $form->addElement(
@ -132,11 +132,11 @@ class MultipleAnswer extends Question
$boxes_names[] = 'correct['.$i.']'; $boxes_names[] = 'correct['.$i.']';
$form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig); $form->addHtmlEditor("answer[$i]", null, null, true, $editorConfig);
$form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('answer['.$i.']', get_lang('ThisFieldIsRequired'), 'required');
$form->addHtmlEditor("comment[$i]", null, null, true, $editorConfig); $form->addHtmlEditor("comment[$i]", null, null, true, $editorConfig);
$form->addElement('text', 'weighting[' . $i . ']', null, array('style' => "width: 60px;", 'value' => '0')); $form->addElement('text', 'weighting['.$i.']', null, array('style' => "width: 60px;", 'value' => '0'));
$form->addHtml('</tr>'); $form->addHtml('</tr>');
} }
@ -227,7 +227,7 @@ class MultipleAnswer extends Question
function return_header($feedback_type = null, $counter = null, $score = null) function return_header($feedback_type = null, $counter = null, $score = null)
{ {
$header = parent::return_header($feedback_type, $counter, $score); $header = parent::return_header($feedback_type, $counter, $score);
$header .= '<table class="'.$this->question_table_class .'"> $header .= '<table class="'.$this->question_table_class.'">
<tr> <tr>
<th>'.get_lang("Choice").'</th> <th>'.get_lang("Choice").'</th>
<th>'. get_lang("ExpectedChoice").'</th> <th>'. get_lang("ExpectedChoice").'</th>

@ -8,7 +8,7 @@
// $cidReset : This is the main difference with gradebook.php, here we say, // $cidReset : This is the main difference with gradebook.php, here we say,
// basically, that we are inside a course, and many things depend from that // basically, that we are inside a course, and many things depend from that
$cidReset= true; $cidReset = true;
$_in_course = false; $_in_course = false;
//make sure the destination for scripts is index.php instead of gradebook.php //make sure the destination for scripts is index.php instead of gradebook.php
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -21,7 +21,7 @@ if (!empty($_GET['course'])) {
unset($_GET['course']); unset($_GET['course']);
} }
$selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0; $selectcat = isset($_GET['selectcat']) ? (int) $_GET['selectcat'] : 0;
$htmlHeadXtra[] = '<script> $htmlHeadXtra[] = '<script>
$(document).ready( function() { $(document).ready( function() {
@ -34,7 +34,7 @@ $(document).ready( function() {
</script>'; </script>';
api_block_anonymous_users(); api_block_anonymous_users();
$htmlHeadXtra[]= '<script> $htmlHeadXtra[] = '<script>
function confirmation () { function confirmation () {
if (confirm("'.get_lang('DeleteAll').'?")) { if (confirm("'.get_lang('DeleteAll').'?")) {
return true; return true;
@ -50,10 +50,10 @@ $filter_warning_msg = true;
//this is called when there is no data for the course admin //this is called when there is no data for the course admin
if (isset($_GET['createallcategories'])) { if (isset($_GET['createallcategories'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$coursecat= Category :: get_not_created_course_categories(api_get_user_id()); $coursecat = Category :: get_not_created_course_categories(api_get_user_id());
if (!count($coursecat) == 0) { if (!count($coursecat) == 0) {
foreach ($coursecat as $row) { foreach ($coursecat as $row) {
$cat= new Category(); $cat = new Category();
$cat->set_name($row[1]); $cat->set_name($row[1]);
$cat->set_course_code($row[0]); $cat->set_course_code($row[0]);
$cat->set_description(null); $cat->set_description(null);
@ -83,19 +83,19 @@ if (isset($_GET['movecat'])) {
api_get_self().'?movecat='.$move_cat.'&selectcat='.$selectcat api_get_self().'?movecat='.$move_cat.'&selectcat='.$selectcat
); );
if ($move_form->validate()) { if ($move_form->validate()) {
header('Location: ' . api_get_self() . '?selectcat=' . $selectcat header('Location: '.api_get_self().'?selectcat='.$selectcat
. '&movecat=' . $move_cat . '&movecat='.$move_cat
. '&targetcat=' . $move_form->exportValue('move_cat')); . '&targetcat='.$move_form->exportValue('move_cat'));
exit; exit;
} }
} else { } else {
$get_target_cat=Security::remove_XSS($_GET['targetcat']); $get_target_cat = Security::remove_XSS($_GET['targetcat']);
$targetcat= Category :: load($get_target_cat); $targetcat = Category :: load($get_target_cat);
$course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); $course_to_crsind = ($cats[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
if (!($course_to_crsind && !isset($_GET['confirm']))) { if (!($course_to_crsind && !isset($_GET['confirm']))) {
$cats[0]->move_to_cat($targetcat[0]); $cats[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . $selectcat); header('Location: '.api_get_self().'?categorymoved=&selectcat='.$selectcat);
exit; exit;
} }
unset($targetcat); unset($targetcat);
@ -106,31 +106,31 @@ if (isset($_GET['movecat'])) {
//move an evaluation //move an evaluation
if (isset($_GET['moveeval'])) { if (isset($_GET['moveeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$get_move_eval=Security::remove_XSS($_GET['moveeval']); $get_move_eval = Security::remove_XSS($_GET['moveeval']);
$evals= Evaluation :: load($get_move_eval); $evals = Evaluation :: load($get_move_eval);
if (!isset ($_GET['targetcat'])) { if (!isset ($_GET['targetcat'])) {
$move_form = new EvalForm(EvalForm :: TYPE_MOVE, $move_form = new EvalForm(EvalForm :: TYPE_MOVE,
$evals[0], $evals[0],
null, null,
'move_eval_form', 'move_eval_form',
null, null,
api_get_self() . '?moveeval=' . $get_move_eval. '&selectcat=' . $selectcat api_get_self().'?moveeval='.$get_move_eval.'&selectcat='.$selectcat
); );
if ($move_form->validate()) { if ($move_form->validate()) {
header('Location: ' .api_get_self() . '?selectcat=' . $selectcat header('Location: '.api_get_self().'?selectcat='.$selectcat
. '&moveeval=' . $get_move_eval . '&moveeval='.$get_move_eval
. '&targetcat=' . $move_form->exportValue('move_cat')); . '&targetcat='.$move_form->exportValue('move_cat'));
exit; exit;
} }
} else { } else {
$get_target_cat=Security::remove_XSS($_GET['targetcat']); $get_target_cat = Security::remove_XSS($_GET['targetcat']);
$targetcat= Category :: load($get_target_cat); $targetcat = Category :: load($get_target_cat);
$course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null);
if (!($course_to_crsind && !isset($_GET['confirm']))) { if (!($course_to_crsind && !isset($_GET['confirm']))) {
$evals[0]->move_to_cat($targetcat[0]); $evals[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . $selectcat); header('Location: '.api_get_self().'?evaluationmoved=&selectcat='.$selectcat);
exit; exit;
} }
unset($targetcat); unset($targetcat);
@ -141,8 +141,8 @@ if (isset($_GET['moveeval'])) {
// Move a link // Move a link
if (isset($_GET['movelink'])) { if (isset($_GET['movelink'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$get_move_link=Security::remove_XSS($_GET['movelink']); $get_move_link = Security::remove_XSS($_GET['movelink']);
$link= LinkFactory :: load($get_move_link); $link = LinkFactory :: load($get_move_link);
$move_form = new LinkForm( $move_form = new LinkForm(
LinkForm :: TYPE_MOVE, LinkForm :: TYPE_MOVE,
null, null,
@ -152,10 +152,10 @@ if (isset($_GET['movelink'])) {
api_get_self().'?movelink='.$get_move_link.'&selectcat='.$selectcat api_get_self().'?movelink='.$get_move_link.'&selectcat='.$selectcat
); );
if ($move_form->validate()) { if ($move_form->validate()) {
$targetcat= Category :: load($move_form->exportValue('move_cat')); $targetcat = Category :: load($move_form->exportValue('move_cat'));
$link[0]->move_to_cat($targetcat[0]); $link[0]->move_to_cat($targetcat[0]);
unset($link); unset($link);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . $selectcat); header('Location: '.api_get_self().'?linkmoved=&selectcat='.$selectcat);
exit; exit;
} }
} }
@ -164,11 +164,11 @@ if (isset($_GET['movelink'])) {
if (isset($_GET['visiblecat'])) { if (isset($_GET['visiblecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
if (isset($_GET['set_visible'])) { if (isset($_GET['set_visible'])) {
$visibility_command= 1; $visibility_command = 1;
} else { } else {
$visibility_command= 0; $visibility_command = 0;
} }
$cats= Category :: load($_GET['visiblecat']); $cats = Category :: load($_GET['visiblecat']);
$cats[0]->set_visible($visibility_command); $cats[0]->set_visible($visibility_command);
$cats[0]->save(); $cats[0]->save();
$cats[0]->apply_visibility_to_children(); $cats[0]->apply_visibility_to_children();
@ -183,7 +183,7 @@ if (isset($_GET['visiblecat'])) {
} }
if (isset($_GET['deletecat'])) { if (isset($_GET['deletecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$cats= Category :: load($_GET['deletecat']); $cats = Category :: load($_GET['deletecat']);
//delete all categories,subcategories and results //delete all categories,subcategories and results
if ($cats[0] != null) { if ($cats[0] != null) {
if ($cats[0]->get_id() != 0) { if ($cats[0]->get_id() != 0) {
@ -199,12 +199,12 @@ if (isset($_GET['deletecat'])) {
if (isset($_GET['visibleeval'])) { if (isset($_GET['visibleeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
if (isset($_GET['set_visible'])) { if (isset($_GET['set_visible'])) {
$visibility_command= 1; $visibility_command = 1;
} else { } else {
$visibility_command= 0; $visibility_command = 0;
} }
$eval= Evaluation :: load($_GET['visibleeval']); $eval = Evaluation :: load($_GET['visibleeval']);
$eval[0]->set_visible($visibility_command); $eval[0]->set_visible($visibility_command);
$eval[0]->save(); $eval[0]->save();
unset($eval); unset($eval);
@ -219,7 +219,7 @@ if (isset($_GET['visibleeval'])) {
if (isset($_GET['deleteeval'])) { if (isset($_GET['deleteeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$eval= Evaluation :: load($_GET['deleteeval']); $eval = Evaluation :: load($_GET['deleteeval']);
if ($eval[0] != null) { if ($eval[0] != null) {
$eval[0]->delete_with_results(); $eval[0]->delete_with_results();
} }
@ -234,7 +234,7 @@ if (isset($_GET['visiblelink'])) {
} else { } else {
$visibility_command = 0; $visibility_command = 0;
} }
$link= LinkFactory :: load($_GET['visiblelink']); $link = LinkFactory :: load($_GET['visiblelink']);
$link[0]->set_visible($visibility_command); $link[0]->set_visible($visibility_command);
$link[0]->save(); $link[0]->save();
unset($link); unset($link);
@ -267,9 +267,9 @@ if ($course_to_crsind && !isset($_GET['confirm'])) {
} }
$button = '<form name="confirm" $button = '<form name="confirm"
method="post" method="post"
action="'.api_get_self() .'?confirm=' action="'.api_get_self().'?confirm='
.(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat']) .(isset($_GET['movecat']) ? '&movecat='.Security::remove_XSS($_GET['movecat'])
: '&moveeval=' . intval($_GET['moveeval']) ).'&selectcat=' . $selectcat.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'"> : '&moveeval='.intval($_GET['moveeval'])).'&selectcat='.$selectcat.'&targetcat='.Security::remove_XSS($_GET['targetcat']).'">
<input type="submit" value="'.' '.get_lang('Ok').' '.'"> <input type="submit" value="'.' '.get_lang('Ok').' '.'">
</form>'; </form>';
@ -280,26 +280,26 @@ if ($course_to_crsind && !isset($_GET['confirm'])) {
//actions on the sortabletable //actions on the sortabletable
if (isset($_POST['action'])) { if (isset($_POST['action'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$number_of_selected_items= count($_POST['id']); $number_of_selected_items = count($_POST['id']);
if ($number_of_selected_items == '0') { if ($number_of_selected_items == '0') {
$warning_message = get_lang('NoItemsSelected'); $warning_message = get_lang('NoItemsSelected');
$filter_warning_msg = false; $filter_warning_msg = false;
} else { } else {
switch ($_POST['action']) { switch ($_POST['action']) {
case 'deleted': case 'deleted':
$number_of_deleted_categories= 0; $number_of_deleted_categories = 0;
$number_of_deleted_evaluations= 0; $number_of_deleted_evaluations = 0;
$number_of_deleted_links= 0; $number_of_deleted_links = 0;
foreach ($_POST['id'] as $indexstr) { foreach ($_POST['id'] as $indexstr) {
if (api_substr($indexstr, 0, 4) == 'CATE') { if (api_substr($indexstr, 0, 4) == 'CATE') {
$cats= Category :: load(api_substr($indexstr, 4)); $cats = Category :: load(api_substr($indexstr, 4));
if ($cats[0] != null) { if ($cats[0] != null) {
$cats[0]->delete_all(); $cats[0]->delete_all();
} }
$number_of_deleted_categories++; $number_of_deleted_categories++;
} }
if (api_substr($indexstr, 0, 4) == 'EVAL') { if (api_substr($indexstr, 0, 4) == 'EVAL') {
$eval= Evaluation :: load(api_substr($indexstr, 4)); $eval = Evaluation :: load(api_substr($indexstr, 4));
if ($eval[0] != null) { if ($eval[0] != null) {
$eval[0]->delete_with_results(); $eval[0]->delete_with_results();
} }
@ -308,7 +308,7 @@ if (isset($_POST['action'])) {
if (api_substr($indexstr, 0, 4) == 'LINK') { if (api_substr($indexstr, 0, 4) == 'LINK') {
$id = api_substr($indexstr, 4); $id = api_substr($indexstr, 4);
if (!empty($id)) { if (!empty($id)) {
$link= LinkFactory :: load(); $link = LinkFactory :: load();
if ($link[0] != null) { if ($link[0] != null) {
$link[0]->delete(); $link[0]->delete();
} }
@ -316,7 +316,7 @@ if (isset($_POST['action'])) {
} }
} }
} }
$confirmation_message = get_lang('DeletedCategories') . ' : <b>' . $number_of_deleted_categories . '</b><br />' . get_lang('DeletedEvaluations') . ' : <b>' . $number_of_deleted_evaluations . '</b><br />' . get_lang('DeletedLinks') . ' : <b>' . $number_of_deleted_links . '</b><br /><br />' . get_lang('TotalItems') . ' : <b>' . $number_of_selected_items . '</b>'; $confirmation_message = get_lang('DeletedCategories').' : <b>'.$number_of_deleted_categories.'</b><br />'.get_lang('DeletedEvaluations').' : <b>'.$number_of_deleted_evaluations.'</b><br />'.get_lang('DeletedLinks').' : <b>'.$number_of_deleted_links.'</b><br /><br />'.get_lang('TotalItems').' : <b>'.$number_of_selected_items.'</b>';
$filter_confirm_msg = false; $filter_confirm_msg = false;
break; break;
case 'setvisible' : case 'setvisible' :
@ -368,7 +368,7 @@ if (isset($_POST['action'])) {
} }
if (isset ($_POST['submit']) && isset ($_POST['keyword'])) { if (isset ($_POST['submit']) && isset ($_POST['keyword'])) {
header('Location: ' . api_get_self() . '?selectcat=' . $selectcat header('Location: '.api_get_self().'?selectcat='.$selectcat
. '&search='.Security::remove_XSS($_POST['keyword'])); . '&search='.Security::remove_XSS($_POST['keyword']));
exit; exit;
} }
@ -419,8 +419,8 @@ if (isset ($move_form)) {
// DISPLAY HEADERS AND MESSAGES - // DISPLAY HEADERS AND MESSAGES -
if (!isset($_GET['exportpdf']) && !isset($_GET['export_certificate'])) { if (!isset($_GET['exportpdf']) && !isset($_GET['export_certificate'])) {
if (isset ($_GET['studentoverview'])) { if (isset ($_GET['studentoverview'])) {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array(
'url' => $_SESSION['gradebook_dest'].'?selectcat=' . $selectcat.'&'.api_get_cidreq(), 'url' => $_SESSION['gradebook_dest'].'?selectcat='.$selectcat.'&'.api_get_cidreq(),
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
Display :: display_header(get_lang('FlatView')); Display :: display_header(get_lang('FlatView'));
@ -431,13 +431,13 @@ if (!isset($_GET['exportpdf']) && !isset($_GET['export_certificate'])) {
$gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']); $gradebook_dest = Security::remove_XSS($_SESSION['gradebook_dest']);
} }
$interbreadcrumb[]= array ('url' => $gradebook_dest,'name' => get_lang('Gradebook')); $interbreadcrumb[] = array('url' => $gradebook_dest, 'name' => get_lang('Gradebook'));
if ((isset($_GET['selectcat']) && $_GET['selectcat']>0)) { if ((isset($_GET['selectcat']) && $_GET['selectcat'] > 0)) {
if (!empty($_GET['course'])) { if (!empty($_GET['course'])) {
$interbreadcrumb[]= array ('url' => $gradebook_dest.'selectcat='.$selectcat,'name' => get_lang('Details')); $interbreadcrumb[] = array('url' => $gradebook_dest.'selectcat='.$selectcat, 'name' => get_lang('Details'));
} else { } else {
$interbreadcrumb[]= array ('url' => $_SESSION['gradebook_dest'].'?selectcat=0','name' => get_lang('Details')); $interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'].'?selectcat=0', 'name' => get_lang('Details'));
} }
} }
Display :: display_header(''); Display :: display_header('');
@ -447,8 +447,8 @@ if (!isset($_GET['exportpdf']) && !isset($_GET['export_certificate'])) {
} }
// LOAD DATA & DISPLAY TABLE - // LOAD DATA & DISPLAY TABLE -
$is_platform_admin= api_is_platform_admin(); $is_platform_admin = api_is_platform_admin();
$is_course_admin= api_is_allowed_to_edit(); $is_course_admin = api_is_allowed_to_edit();
//load data for category, evaluation and links //load data for category, evaluation and links
if (empty($selectcat)) { if (empty($selectcat)) {
@ -465,7 +465,7 @@ $simple_search_form = new UserForm(
null, null,
api_get_self().'?selectcat='.$selectcat api_get_self().'?selectcat='.$selectcat
); );
$values= $simple_search_form->exportValues(); $values = $simple_search_form->exportValues();
$keyword = ''; $keyword = '';
if (isset($_GET['search']) && !empty($_GET['search'])) { if (isset($_GET['search']) && !empty($_GET['search'])) {
$keyword = Security::remove_XSS($_GET['search']); $keyword = Security::remove_XSS($_GET['search']);
@ -475,13 +475,13 @@ if ($simple_search_form->validate() && (empty($keyword))) {
} }
if (!empty($keyword)) { if (!empty($keyword)) {
$cats= Category :: load($category); $cats = Category :: load($category);
$allcat= array (); $allcat = array();
if ((isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search'])) { if ((isset($_GET['selectcat']) && $_GET['selectcat'] == 0) && isset($_GET['search'])) {
$allcat= $cats[0]->get_subcategories(null); $allcat = $cats[0]->get_subcategories(null);
$allcat_info = Category::find_category($keyword,$allcat); $allcat_info = Category::find_category($keyword, $allcat);
$alleval=array(); $alleval = array();
$alllink=array(); $alllink = array();
} else { } else {
$alleval = Evaluation::find_evaluations($keyword, $cats[0]->get_id()); $alleval = Evaluation::find_evaluations($keyword, $cats[0]->get_id());
$alllink = LinkFactory::find_links($keyword, $cats[0]->get_id()); $alllink = LinkFactory::find_links($keyword, $cats[0]->get_id());
@ -489,13 +489,13 @@ if (!empty($keyword)) {
} elseif (isset ($_GET['studentoverview'])) { } elseif (isset ($_GET['studentoverview'])) {
//@todo this code seems to be deprecated because the gradebook tab is off //@todo this code seems to be deprecated because the gradebook tab is off
$cats= Category :: load($category); $cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); $stud_id = (api_is_allowed_to_edit() ? null : api_get_user_id());
$allcat= array (); $allcat = array();
$alleval= $cats[0]->get_evaluations($stud_id, true); $alleval = $cats[0]->get_evaluations($stud_id, true);
$alllink= $cats[0]->get_links($stud_id, true); $alllink = $cats[0]->get_links($stud_id, true);
if (isset ($_GET['exportpdf'])) { if (isset ($_GET['exportpdf'])) {
$datagen = new GradebookDataGenerator ($allcat,$alleval, $alllink); $datagen = new GradebookDataGenerator($allcat, $alleval, $alllink);
$header_names = array( $header_names = array(
get_lang('Name'), get_lang('Name'),
get_lang('Description'), get_lang('Description'),
@ -503,18 +503,18 @@ if (!empty($keyword)) {
get_lang('Date'), get_lang('Date'),
get_lang('Results'), get_lang('Results'),
); );
$data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME,0,null,true); $data_array = $datagen->get_data(GradebookDataGenerator :: GDG_SORT_NAME, 0, null, true);
$newarray = array(); $newarray = array();
foreach ($data_array as $data) { foreach ($data_array as $data) {
$newarray[] = array_slice($data, 1); $newarray[] = array_slice($data, 1);
} }
$pdf= new Cezpdf(); $pdf = new Cezpdf();
$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
$pdf->ezSetMargins(30, 30, 50, 30); $pdf->ezSetMargins(30, 30, 50, 30);
$pdf->ezSetY(810); $pdf->ezSetY(810);
$pdf->ezText(get_lang('FlatView').' ('. api_convert_and_format_date(null, DATE_FORMAT_SHORT) . ' ' . api_convert_and_format_date(null, TIME_NO_SEC_FORMAT) .')',12,array('justification'=>'center')); $pdf->ezText(get_lang('FlatView').' ('.api_convert_and_format_date(null, DATE_FORMAT_SHORT).' '.api_convert_and_format_date(null, TIME_NO_SEC_FORMAT).')', 12, array('justification'=>'center'));
$pdf->line(50,790,550,790); $pdf->line(50, 790, 550, 790);
$pdf->line(50,40,550,40); $pdf->line(50, 40, 550, 40);
$pdf->ezSetY(750); $pdf->ezSetY(750);
$pdf->ezTable( $pdf->ezTable(
$newarray, $newarray,
@ -531,57 +531,57 @@ if (!empty($keyword)) {
$pdf->ezStream(); $pdf->ezStream();
exit; exit;
} }
} elseif (!empty($_GET['export_certificate'])){ } elseif (!empty($_GET['export_certificate'])) {
//@todo this code seems not to be used //@todo this code seems not to be used
$user_id = strval(intval($_GET['user'])); $user_id = strval(intval($_GET['user']));
if (!api_is_allowed_to_edit(true,true)) { if (!api_is_allowed_to_edit(true, true)) {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
} }
$category = Category :: load ($_GET['cat_id']); $category = Category :: load($_GET['cat_id']);
if ($category[0]->is_certificate_available($user_id)) { if ($category[0]->is_certificate_available($user_id)) {
$user = api_get_user_info($user_id); $user = api_get_user_info($user_id);
$scoredisplay = ScoreDisplay :: instance(); $scoredisplay = ScoreDisplay :: instance();
$scorecourse = $category[0]->calc_score($user_id); $scorecourse = $category[0]->calc_score($user_id);
$scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse,SCORE_AVERAGE) : get_lang('NoResultsAvailable')); $scorecourse_display = (isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable'));
$cattotal = Category :: load(0); $cattotal = Category :: load(0);
$scoretotal= $cattotal[0]->calc_score($user_id); $scoretotal = $cattotal[0]->calc_score($user_id);
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable')); $scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'));
//prepare all necessary variables: //prepare all necessary variables:
$organization_name = api_get_setting('Institution'); $organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName'); $portal_name = api_get_setting('siteName');
$stud_fn = $user['firstname']; $stud_fn = $user['firstname'];
$stud_ln = $user['lastname']; $stud_ln = $user['lastname'];
$certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'),$organization_name,$stud_fn.' '.$stud_ln,$category[0]->get_name(),$scorecourse_display); $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn.' '.$stud_ln, $category[0]->get_name(), $scorecourse_display);
$certif_text = str_replace("\\n","\n",$certif_text); $certif_text = str_replace("\\n", "\n", $certif_text);
$date = api_convert_and_format_date(null, DATE_FORMAT_SHORT); $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT);
$pdf= new Cezpdf('a4','landscape'); $pdf = new Cezpdf('a4', 'landscape');
$pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm'); $pdf->selectFont(api_get_path(LIBRARY_PATH).'ezpdf/fonts/Courier.afm');
$pdf->ezSetMargins(30, 30, 50, 50); $pdf->ezSetMargins(30, 30, 50, 50);
//line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom) //line Y coordinates in landscape mode are upside down (500 is on top, 10 is on the bottom)
$pdf->line(50,50,790,50); $pdf->line(50, 50, 790, 50);
$pdf->line(50,550,790,550); $pdf->line(50, 550, 790, 550);
$pdf->ezSetY(450); $pdf->ezSetY(450);
$pdf->ezSetY(480); $pdf->ezSetY(480);
$pdf->ezText($certif_text,28,array('justification'=>'center')); $pdf->ezText($certif_text, 28, array('justification'=>'center'));
//$pdf->ezSetY(750); //$pdf->ezSetY(750);
$pdf->ezSetY(50); $pdf->ezSetY(50);
$pdf->ezText($date,18,array('justification'=>'center')); $pdf->ezText($date, 18, array('justification'=>'center'));
$pdf->ezSetY(580); $pdf->ezSetY(580);
$pdf->ezText($organization_name,22,array('justification'=>'left')); $pdf->ezText($organization_name, 22, array('justification'=>'left'));
$pdf->ezSetY(580); $pdf->ezSetY(580);
$pdf->ezText($portal_name,22,array('justification'=>'right')); $pdf->ezText($portal_name, 22, array('justification'=>'right'));
$pdf->ezStream(); $pdf->ezStream();
} }
exit; exit;
} else { } else {
$cats= Category :: load($category); $cats = Category :: load($category);
$stud_id= (api_is_allowed_to_edit() ? null : api_get_user_id()); $stud_id = (api_is_allowed_to_edit() ? null : api_get_user_id());
$allcat= $cats[0]->get_subcategories($stud_id); $allcat = $cats[0]->get_subcategories($stud_id);
$alleval= $cats[0]->get_evaluations($stud_id); $alleval = $cats[0]->get_evaluations($stud_id);
$alllink= $cats[0]->get_links($stud_id); $alllink = $cats[0]->get_links($stud_id);
} }
$addparams = array('selectcat' => $cats[0]->get_id()); $addparams = array('selectcat' => $cats[0]->get_id());
if (isset($_GET['search'])) { if (isset($_GET['search'])) {
@ -590,10 +590,10 @@ if (isset($_GET['search'])) {
if (isset ($_GET['studentoverview'])) { if (isset ($_GET['studentoverview'])) {
$addparams['studentoverview'] = ''; $addparams['studentoverview'] = '';
} }
if (isset($allcat_info) && count($allcat_info)>=0 && (isset($_GET['selectcat']) && $_GET['selectcat']==0) && isset($_GET['search']) && strlen(trim($_GET['search']))>0 ) { if (isset($allcat_info) && count($allcat_info) >= 0 && (isset($_GET['selectcat']) && $_GET['selectcat'] == 0) && isset($_GET['search']) && strlen(trim($_GET['search'])) > 0) {
$allcat=$allcat_info; $allcat = $allcat_info;
} else { } else {
$allcat=$allcat; $allcat = $allcat;
} }
$gradebooktable = new GradebookTable( $gradebooktable = new GradebookTable(
$cats[0], $cats[0],
@ -606,10 +606,10 @@ if (((empty($allcat)) && (empty ($alleval)) && (empty ($alllink)) && (!$is_platf
api_is_course_tutor() api_is_course_tutor()
) { ) {
echo Display::return_message( echo Display::return_message(
get_lang('GradebookWelcomeMessage') . get_lang('GradebookWelcomeMessage').
'<br /><br /> '<br /><br />
<form name="createcat" method="post" action="' . api_get_self() . '?createallcategories=1"> <form name="createcat" method="post" action="' . api_get_self().'?createallcategories=1">
<input type="submit" value="' . get_lang('CreateAllCat') . '"></form>', <input type="submit" value="' . get_lang('CreateAllCat').'"></form>',
'normal', 'normal',
false false
); );

@ -35,12 +35,12 @@ class LearnpathLink extends AbstractLink
$tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK); $tbl_grade_links = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = 'SELECT id, name FROM ' . $this->get_learnpath_table() . ' lp $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().' lp
WHERE c_id = ' . $this->course_id . ' AND id NOT IN ' WHERE c_id = ' . $this->course_id.' AND id NOT IN '
. ' (SELECT ref_id FROM ' . $tbl_grade_links . ' (SELECT ref_id FROM '.$tbl_grade_links
. ' WHERE type = ' . LINK_LEARNPATH . ' WHERE type = '.LINK_LEARNPATH
. " AND course_code = '" . $this->get_course_code() . "'" . " AND course_code = '".$this->get_course_code()."'"
. ') AND lp.session_id=' . api_get_session_id() . ''; . ') AND lp.session_id='.api_get_session_id().'';
$result = Database::query($sql); $result = Database::query($sql);
@ -69,8 +69,8 @@ class LearnpathLink extends AbstractLink
$session_condition = api_get_session_condition($session_id, true, true); $session_condition = api_get_session_condition($session_id, true, true);
} }
$sql = 'SELECT id, name FROM ' . $this->get_learnpath_table() . ' $sql = 'SELECT id, name FROM '.$this->get_learnpath_table().'
WHERE c_id = ' . $this->course_id . ' ' . $session_condition . ' '; WHERE c_id = ' . $this->course_id.' '.$session_condition.' ';
$result = Database::query($sql); $result = Database::query($sql);
$cats = array(); $cats = array();
@ -89,7 +89,7 @@ class LearnpathLink extends AbstractLink
{ {
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW); $tbl_stats = Database::get_course_table(TABLE_LP_VIEW);
$sql = "SELECT count(id) AS number FROM $tbl_stats $sql = "SELECT count(id) AS number FROM $tbl_stats
WHERE c_id = " . $this->course_id . " AND lp_id = " . $this->get_ref_id(); WHERE c_id = ".$this->course_id." AND lp_id = ".$this->get_ref_id();
$result = Database::query($sql); $result = Database::query($sql);
$number = Database::fetch_array($result, 'NUM'); $number = Database::fetch_array($result, 'NUM');
return ($number[0] != 0); return ($number[0] != 0);
@ -109,12 +109,12 @@ class LearnpathLink extends AbstractLink
$sql = "SELECT * FROM $tbl_stats $sql = "SELECT * FROM $tbl_stats
WHERE WHERE
c_id = " . $this->course_id . " AND c_id = ".$this->course_id." AND
lp_id = " . $this->get_ref_id() . " AND lp_id = " . $this->get_ref_id()." AND
session_id = $session_id "; session_id = $session_id ";
if (isset($stud_id)) { if (isset($stud_id)) {
$sql .= ' AND user_id = ' . intval($stud_id); $sql .= ' AND user_id = '.intval($stud_id);
} }
// order by id, that way the student's first attempt is accessed first // order by id, that way the student's first attempt is accessed first
@ -130,7 +130,7 @@ class LearnpathLink extends AbstractLink
} }
} else { } else {
// all students -> get average // all students -> get average
$students = array(); // user list, needed to make sure we only $students = array(); // user list, needed to make sure we only
// take first attempts into account // take first attempts into account
$rescount = 0; $rescount = 0;
$sum = 0; $sum = 0;
@ -177,13 +177,13 @@ class LearnpathLink extends AbstractLink
public function get_link() public function get_link()
{ {
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$url = api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?' . api_get_cidreq_params($this->get_course_code(), $url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq_params($this->get_course_code(),
$session_id) . '&gradebook=view'; $session_id).'&gradebook=view';
if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) { if (!api_is_allowed_to_edit() || $this->calc_score(api_get_user_id()) == null) {
$url .= '&action=view&lp_id=' . $this->get_ref_id(); $url .= '&action=view&lp_id='.$this->get_ref_id();
} else { } else {
$url .= '&action=build&lp_id=' . $this->get_ref_id(); $url .= '&action=build&lp_id='.$this->get_ref_id();
} }
return $url; return $url;
} }
@ -211,8 +211,8 @@ class LearnpathLink extends AbstractLink
*/ */
public function is_valid_link() public function is_valid_link()
{ {
$sql = 'SELECT count(id) FROM ' . $this->get_learnpath_table() . ' $sql = 'SELECT count(id) FROM '.$this->get_learnpath_table().'
WHERE c_id = ' . $this->course_id . ' AND id = ' . $this->get_ref_id() . ' '; WHERE c_id = ' . $this->course_id.' AND id = '.$this->get_ref_id().' ';
$result = Database::query($sql); $result = Database::query($sql);
$number = Database::fetch_row($result, 'NUM'); $number = Database::fetch_row($result, 'NUM');
return ($number[0] != 0); return ($number[0] != 0);
@ -260,8 +260,8 @@ class LearnpathLink extends AbstractLink
private function get_learnpath_data() private function get_learnpath_data()
{ {
if (!isset($this->learnpath_data)) { if (!isset($this->learnpath_data)) {
$sql = 'SELECT * FROM ' . $this->get_learnpath_table() . ' $sql = 'SELECT * FROM '.$this->get_learnpath_table().'
WHERE c_id = ' . $this->course_id . ' AND id = ' . $this->get_ref_id() . ' '; WHERE c_id = ' . $this->course_id.' AND id = '.$this->get_ref_id().' ';
$result = Database::query($sql); $result = Database::query($sql);
$this->learnpath_data = Database::fetch_array($result); $this->learnpath_data = Database::fetch_array($result);
} }

@ -114,7 +114,7 @@ class EvalForm extends FormValidator
) )
); );
foreach ($this->evaluation_object->get_not_subscribed_students() as $user) { foreach ($this->evaluation_object->get_not_subscribed_students() as $user) {
if ((!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1], 0,1)) == $this->extra if ((!isset($this->extra)) || empty($this->extra) || api_strtoupper(api_substr($user[1], 0, 1)) == $this->extra
) { ) {
$select->addoption($user[1].' '.$user[2].' ('.$user[3].')', $user[0]); $select->addoption($user[1].' '.$user[2].' ('.$user[3].')', $user[0]);
} }

@ -710,7 +710,7 @@ class CourseHome
} else { } else {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach(); $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && !api_is_coach();
if ($allowEditionInSession) { if ($allowEditionInSession) {
$is_allowed_to_edit = api_is_allowed_to_edit(null,true) && api_is_coach($session_id, api_get_course_int_id()); $is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_coach($session_id, api_get_course_int_id());
} }
} }

@ -13,8 +13,8 @@ define('DEBUG', false);
* @returns an array such as: for all i in [0..max[x][ : for all j in [0..max[y][ : array[i][j] = FALSE * @returns an array such as: for all i in [0..max[x][ : for all j in [0..max[y][ : array[i][j] = FALSE
*/ */
function poly_init($max) { function poly_init($max) {
return array_fill(0, $max["x"]-1, return array_fill(0, $max["x"] - 1,
array_fill(0, $max["y"]-1, FALSE)); array_fill(0, $max["y"] - 1, FALSE));
} }
@ -69,18 +69,18 @@ function poly_compile($poly, $max, $test = false) {
array_push($bords[$poly[0]['y']], $poly[0]['x']); array_push($bords[$poly[0]['y']], $poly[0]['x']);
$i = 1; // we re-use $i and $old_pente bellow the loop $i = 1; // we re-use $i and $old_pente bellow the loop
$old_pente=0; $old_pente = 0;
for ( ; // for each points of the polygon but the first for (; // for each points of the polygon but the first
$i<sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) { $i < sizeof($poly) && (!empty($poly[$i]['x']) && !empty($poly[$i]['y'])); $i++) {
/* special cases */ /* special cases */
if ($poly[$i-1]['y'] == $poly[$i]['y']) { if ($poly[$i - 1]['y'] == $poly[$i]['y']) {
if ($poly[$i-1]['x'] == $poly[$i]['x']) if ($poly[$i - 1]['x'] == $poly[$i]['x'])
continue; // twice the same point continue; // twice the same point
else { // infinite elevation of the edge else { // infinite elevation of the edge
if (is_array($bords[$poly[$i]['y']])) if (is_array($bords[$poly[$i]['y']]))
array_push($bords[$poly[$i]['y']],$poly[$i]['x']); array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
$old_pente=0; $old_pente = 0;
continue; continue;
} }
} }
@ -93,17 +93,17 @@ function poly_compile($poly, $max, $test = false) {
/* computing the elevation of the edge going */ /* computing the elevation of the edge going */
// from $poly[$i-1] to $poly[$i] // from $poly[$i-1] to $poly[$i]
$pente = ($poly[$i-1]['x']-$poly[$i]['x'])/ $pente = ($poly[$i - 1]['x'] - $poly[$i]['x']) /
($poly[$i-1]['y']-$poly[$i]['y']); ($poly[$i - 1]['y'] - $poly[$i]['y']);
// if the sign of the elevation change from the one of the // if the sign of the elevation change from the one of the
// previous edge, the point must be added a second time inside // previous edge, the point must be added a second time inside
// $bords // $bords
if ($i>1) if ($i > 1)
if (($old_pente<0 && $pente>0) if (($old_pente < 0 && $pente > 0)
|| ($old_pente>0 && $pente<0)) { || ($old_pente > 0 && $pente < 0)) {
if (is_array($bords[$poly[$i]['y']])) //avoid warning if (is_array($bords[$poly[$i]['y']])) //avoid warning
array_push($bords[$poly[$i]['y']],$poly[$i]['x']); array_push($bords[$poly[$i]['y']], $poly[$i]['x']);
if (DEBUG) if (DEBUG)
echo '*('.$poly[$i]['x']. echo '*('.$poly[$i]['x'].
@ -111,8 +111,8 @@ function poly_compile($poly, $max, $test = false) {
} }
/* detect the direction of the elevation in Y */ /* detect the direction of the elevation in Y */
$dy_inc = ($poly[$i]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1; $dy_inc = ($poly[$i]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;
$x = $poly[$i-1]['x']; $x = $poly[$i - 1]['x'];
// if (DEBUG) echo "init: ".$poly[$i-1]['y']." dy_inc: ".$dy_inc. // if (DEBUG) echo "init: ".$poly[$i-1]['y']." dy_inc: ".$dy_inc.
// " end: ".$poly[$i]['y']." pente:".$pente; // " end: ".$poly[$i]['y']." pente:".$pente;
@ -121,10 +121,10 @@ function poly_compile($poly, $max, $test = false) {
// we iterate w/ $dy in ]$poly[$i-1]['y'],$poly[$i-1]['y'][ // we iterate w/ $dy in ]$poly[$i-1]['y'],$poly[$i-1]['y'][
// w/ $dy_inc as increment // w/ $dy_inc as increment
for ($dy = $poly[$i-1]['y']+$dy_inc; for ($dy = $poly[$i - 1]['y'] + $dy_inc;
$dy != $poly[$i]['y']; $dy != $poly[$i]['y'];
$dy += $dy_inc) { $dy += $dy_inc) {
$x += $pente*$dy_inc; $x += $pente * $dy_inc;
array_push($bords[$dy], $x); array_push($bords[$dy], $x);
// if (DEBUG) echo '/('.$x.';'.$dy.') '; // if (DEBUG) echo '/('.$x.';'.$dy.') ';
} }
@ -132,47 +132,47 @@ function poly_compile($poly, $max, $test = false) {
} }
// closing the polygone (the edge between $poly[$i-1] and $poly[0]) // closing the polygone (the edge between $poly[$i-1] and $poly[0])
if ($poly[$i-1]['y']!=$poly[0]['y']) {// droite--> rien à faire if ($poly[$i - 1]['y'] != $poly[0]['y']) {// droite--> rien à faire
// elevation between $poly[0]['x'] and $poly[1]['x']) // elevation between $poly[0]['x'] and $poly[1]['x'])
$rest = $poly[0]['y']-$poly[1]['y']; $rest = $poly[0]['y'] - $poly[1]['y'];
if ($rest!=0) if ($rest != 0)
$pente1 = ($poly[0]['x']-$poly[1]['x'])/($rest); $pente1 = ($poly[0]['x'] - $poly[1]['x']) / ($rest);
else else
$pente1 = 0; $pente1 = 0;
// elevation between $poly[$i-1]['x'] and $poly[0]['x']) // elevation between $poly[$i-1]['x'] and $poly[0]['x'])
$pente = ($poly[$i-1]['x']-$poly[0]['x'])/ $pente = ($poly[$i - 1]['x'] - $poly[0]['x']) /
($poly[$i-1]['y']-$poly[0]['y']); ($poly[$i - 1]['y'] - $poly[0]['y']);
// if (DEBUG) echo 'start('.$poly[$i-1]['x'].','.$poly[$i-1]['y']. // if (DEBUG) echo 'start('.$poly[$i-1]['x'].','.$poly[$i-1]['y'].
// ')-end('.$poly[0]['x'].','.$poly[0]['y']. // ')-end('.$poly[0]['x'].','.$poly[0]['y'].
// ')-pente'.$pente; // ')-pente'.$pente;
// doubling the first point if needed (see above) // doubling the first point if needed (see above)
if (($pente1<0 && $pente>0) || ($pente1>0 && $pente<0)) { if (($pente1 < 0 && $pente > 0) || ($pente1 > 0 && $pente < 0)) {
if (is_array($bords[$poly[$i - 1]['y']])) if (is_array($bords[$poly[$i - 1]['y']]))
array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x'])); array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
//if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; //if (DEBUG) echo '('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') ';
} }
// doubling the last point if neededd // doubling the last point if neededd
if (($old_pente<0 && $pente>0) || ($old_pente>0 && $pente<0)) { if (($old_pente < 0 && $pente > 0) || ($old_pente > 0 && $pente < 0)) {
if (is_array($bords[$poly[$i-1]['y']])) //avoid warning if (is_array($bords[$poly[$i - 1]['y']])) //avoid warning
array_push($bords[$poly[$i-1]['y']], round($poly[$i-1]['x'])); array_push($bords[$poly[$i - 1]['y']], round($poly[$i - 1]['x']));
//if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') '; //if (DEBUG) echo '*('.$poly[$i-1]['x'].';'.$poly[$i-1]['y'].') ';
} }
$dy_inc = ($poly[0]['y']-$poly[$i-1]['y']) > 0 ? 1 : -1; $dy_inc = ($poly[0]['y'] - $poly[$i - 1]['y']) > 0 ? 1 : -1;
$x = $poly[$i-1]['x']; $x = $poly[$i - 1]['x'];
// if (DEBUG) echo "init: ".$poly[$i-1]['y']." dy_inc: ".$dy_inc. // if (DEBUG) echo "init: ".$poly[$i-1]['y']." dy_inc: ".$dy_inc.
// " end: ".$poly[0]['y']; // " end: ".$poly[0]['y'];
for ($dy = $poly[$i-1]['y']+$dy_inc; for ($dy = $poly[$i - 1]['y'] + $dy_inc;
$dy != $poly[0]['y']; $dy != $poly[0]['y'];
$dy += $dy_inc) $dy += $dy_inc)
{ {
$x += $pente*$dy_inc; $x += $pente * $dy_inc;
array_push($bords[$dy], round($x)); array_push($bords[$dy], round($x));
// if (DEBUG) echo '/('.$x.';'.$dy.') '; // if (DEBUG) echo '/('.$x.';'.$dy.') ';
} }
@ -182,20 +182,20 @@ function poly_compile($poly, $max, $test = false) {
/* basic idea: we sort a column of edges. /* basic idea: we sort a column of edges.
For each pair of point, we color the points in between */ For each pair of point, we color the points in between */
$n = count($bords); $n = count($bords);
for ($i = 0; $i<$n; $i++) { // Y for ($i = 0; $i < $n; $i++) { // Y
//error_log(__FILE__.' - Border Num '.$i,0); //error_log(__FILE__.' - Border Num '.$i,0);
if (is_array($bords[$i])) { if (is_array($bords[$i])) {
sort($bords[$i]); sort($bords[$i]);
} }
for ($j = 0; $j<sizeof($bords[$i]);$j+=2) { // bords for ($j = 0; $j < sizeof($bords[$i]); $j += 2) { // bords
if (!isset($bords[$i][$j + 1])) { if (!isset($bords[$i][$j + 1])) {
continue; continue;
} }
for ($k = round($bords[$i][$j]); $k<=$bords[$i][$j+1];$k++) { for ($k = round($bords[$i][$j]); $k <= $bords[$i][$j + 1]; $k++) {
$res[$k][$i] = true; //filling the array with trues $res[$k][$i] = true; //filling the array with trues
if ($test == 1) { if ($test == 1) {
/*how to draw the polygon in a human way: /*how to draw the polygon in a human way:
In ubuntu : sudo apt-get install gnuplot In ubuntu : sudo apt-get install gnuplot
Create an empty file with all points with the result of this echos (No commas, no point, no headers) Create an empty file with all points with the result of this echos (No commas, no point, no headers)
@ -222,19 +222,19 @@ function poly_compile($poly, $max, $test = false) {
* *
* @return string html code of the representation of the polygone image * @return string html code of the representation of the polygone image
*/ */
function poly_dump(&$poly, $max, $format='raw') { function poly_dump(&$poly, $max, $format = 'raw') {
if ($format == 'html') { if ($format == 'html') {
$s = "<div style='font-size: 8px; line-height:3px'><pre>\n"; $s = "<div style='font-size: 8px; line-height:3px'><pre>\n";
} }
for ($i=0; $i<$max['y']; $i++) { for ($i = 0; $i < $max['y']; $i++) {
for($j=0; $j<$max['x']; $j++) for ($j = 0; $j < $max['x']; $j++)
if($poly[$j][$i] == TRUE) if ($poly[$j][$i] == TRUE)
$s .= ($format=='html'?"<b>1</b>":'1'); $s .= ($format == 'html' ? "<b>1</b>" : '1');
else else
$s .= "0"; $s .= "0";
$s .= ($format=='html'?"<br />\n":"\n"); $s .= ($format == 'html' ? "<br />\n" : "\n");
} }
$s .= ($format=='html'?"</pre></div>\n":"\n"); $s .= ($format == 'html' ? "</pre></div>\n" : "\n");
return $s; return $s;
} }
@ -252,8 +252,8 @@ function poly_result(&$poly1, &$poly2, $max) {
$surfaceOf1 = 0; $surfaceOf1 = 0;
$surfaceOf2 = 0; $surfaceOf2 = 0;
for ($i=0; $i<$max['x']; $i++) for ($i = 0; $i < $max['x']; $i++)
for($j=0; $j<$max['y']; $j++) { for ($j = 0; $j < $max['y']; $j++) {
if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true)) { if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true)) {
$surfaceOf1++; $surfaceOf1++;
if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == false)) if (isset($poly2[$i][$j]) && ($poly2[$i][$j] == false))
@ -263,7 +263,7 @@ function poly_result(&$poly1, &$poly2, $max) {
$surfaceOf2++; $surfaceOf2++;
} }
return array ( return array(
"s1" => $surfaceOf1, "s1" => $surfaceOf1,
"s2" => $surfaceOf2, "s2" => $surfaceOf2,
"both" => $surfaceOf1 - $onlyIn1, "both" => $surfaceOf1 - $onlyIn1,
@ -282,8 +282,8 @@ function poly_result(&$poly1, &$poly2, $max) {
*/ */
function poly_touch(&$poly1, &$poly2, $max) { function poly_touch(&$poly1, &$poly2, $max) {
for ($i=0; $i<$max['x']; $i++) { for ($i = 0; $i < $max['x']; $i++) {
for($j=0; $j<$max['y']; $j++) { for ($j = 0; $j < $max['y']; $j++) {
if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true) if (isset($poly1[$i][$j]) && ($poly1[$i][$j] == true)
&& isset($poly2[$i][$j]) && ($poly2[$i][$j] == true)) { && isset($poly2[$i][$j]) && ($poly2[$i][$j] == true)) {
return true; return true;
@ -301,12 +301,12 @@ function poly_touch(&$poly1, &$poly2, $max) {
* @return array An array of points in the right format to use with the * @return array An array of points in the right format to use with the
* local functions * local functions
*/ */
function convert_coordinates($coords,$sep='|') { function convert_coordinates($coords, $sep = '|') {
$points = array(); $points = array();
$pairs = explode($sep,$coords); $pairs = explode($sep, $coords);
foreach ($pairs as $idx => $pcoord) { foreach ($pairs as $idx => $pcoord) {
list($x,$y) = explode(';',$pcoord); list($x, $y) = explode(';', $pcoord);
$points[] = array('x'=>$x,'y'=>$y); $points[] = array('x'=>$x, 'y'=>$y);
} }
return $points; return $points;
} }
@ -336,7 +336,7 @@ function poly_get_max(&$coords1, &$coords2) {
$my = $coord['y']; $my = $coord['y'];
} }
} }
return array('x'=>$mx,'y'=>$my); return array('x'=>$mx, 'y'=>$my);
} }
/** /**

@ -134,7 +134,7 @@ class MySpace
$sessionId = (int) $sessionId; $sessionId = (int) $sessionId;
$sql = 'SELECT login_course_date, logout_course_date $sql = 'SELECT login_course_date, logout_course_date
FROM ' . $tbl_track_course . ' FROM ' . $tbl_track_course.'
WHERE WHERE
user_id = '.$userId.' AND user_id = '.$userId.' AND
c_id = '.$courseId.' AND c_id = '.$courseId.' AND
@ -176,7 +176,7 @@ class MySpace
foreach ($course_list as $course_item) { foreach ($course_list as $course_item) {
$courseInfo = api_get_course_info($course_item['code']); $courseInfo = api_get_course_info($course_item['code']);
$courseId = $courseInfo['real_id']; $courseId = $courseInfo['real_id'];
$new_course_list[] = '"'.$courseId.'"'; $new_course_list[] = '"'.$courseId.'"';
} }
$course_list = implode(', ', $new_course_list); $course_list = implode(', ', $new_course_list);
@ -184,7 +184,7 @@ class MySpace
return false; return false;
} }
$sql = 'SELECT login_course_date, logout_course_date, c_id $sql = 'SELECT login_course_date, logout_course_date, c_id
FROM ' . $tbl_track_course . ' FROM ' . $tbl_track_course.'
WHERE WHERE
user_id = '.$user_id.' AND user_id = '.$user_id.' AND
c_id IN ('.$course_list.') AND c_id IN ('.$course_list.') AND
@ -246,7 +246,7 @@ class MySpace
// student score // student score
$avg_score = Tracking::get_avg_student_score($user_id, $courseCode); $avg_score = Tracking::get_avg_student_score($user_id, $courseCode);
if (is_numeric($avg_score)) { if (is_numeric($avg_score)) {
$avg_score = round($avg_score,2); $avg_score = round($avg_score, 2);
} else { } else {
$$avg_score = '-'; $$avg_score = '-';
} }
@ -309,7 +309,7 @@ class MySpace
} }
$table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); $table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;')); $table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
$table->set_column_filter(4, array('MySpace','course_info_tracking_filter')); $table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter'));
$table->display(); $table->display();
} }
@ -369,7 +369,7 @@ class MySpace
$table -> set_header(7, get_lang('Sessions'), false); $table -> set_header(7, get_lang('Sessions'), false);
if ($is_western_name_order) { if ($is_western_name_order) {
$csv_header[] = array ( $csv_header[] = array(
get_lang('FirstName'), get_lang('FirstName'),
get_lang('LastName'), get_lang('LastName'),
get_lang('TimeSpentOnThePlatform'), get_lang('TimeSpentOnThePlatform'),
@ -379,7 +379,7 @@ class MySpace
get_lang('NumberOfSessions') get_lang('NumberOfSessions')
); );
} else { } else {
$csv_header[] = array ( $csv_header[] = array(
get_lang('LastName'), get_lang('LastName'),
get_lang('FirstName'), get_lang('FirstName'),
get_lang('TimeSpentOnThePlatform'), get_lang('TimeSpentOnThePlatform'),
@ -519,9 +519,9 @@ class MySpace
if ($tracking_column != 3) { if ($tracking_column != 3) {
if ($tracking_direction == 'DESC') { if ($tracking_direction == 'DESC') {
usort($all_datas, array('MySpace','rsort_users')); usort($all_datas, array('MySpace', 'rsort_users'));
} else { } else {
usort($all_datas, array('MySpace','sort_users')); usort($all_datas, array('MySpace', 'sort_users'));
} }
} }
@ -583,7 +583,7 @@ class MySpace
/** /**
* Column config * Column config
*/ */
$column_model = array( $column_model = array(
array( array(
'name' => 'username', 'name' => 'username',
'index' => 'username', 'index' => 'username',
@ -624,7 +624,7 @@ class MySpace
$action_links = ''; $action_links = '';
// jqgrid will use this URL to do the selects // jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from; $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from;
//Table Id //Table Id
$tableId = 'lpProgress'; $tableId = 'lpProgress';
@ -646,11 +646,11 @@ class MySpace
true true
); );
$return = '<script>$(function() {'. $table . $return = '<script>$(function() {'.$table.
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
caption:"", caption:"",
title:"' . get_lang('ExportExcel') . '", title:"' . get_lang('ExportExcel').'",
onClickButton : function () { onClickButton : function () {
jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
} }
@ -700,7 +700,7 @@ class MySpace
/** /**
* Column config * Column config
*/ */
$column_model = array( $column_model = array(
array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'), array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'),
array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'), array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'),
@ -717,7 +717,7 @@ class MySpace
//get dynamic column names //get dynamic column names
// jqgrid will use this URL to do the selects // jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&exercise_id=' . $exerciseId . '&date_to=' . $date_to . '&date_from=' . $date_from; $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id='.$sessionId.'&course_id='.$courseId.'&exercise_id='.$exerciseId.'&date_to='.$date_to.'&date_from='.$date_from;
// Autowidth // Autowidth
$extra_params['autowidth'] = 'true'; $extra_params['autowidth'] = 'true';
@ -728,11 +728,11 @@ class MySpace
$tableId = 'exerciseProgressOverview'; $tableId = 'exerciseProgressOverview';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true); $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true);
$return = '<script>$(function() {'. $table . $return = '<script>$(function() {'.$table.
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
caption:"", caption:"",
title:"' . get_lang('ExportExcel') . '", title:"' . get_lang('ExportExcel').'",
onClickButton : function () { onClickButton : function () {
jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
} }
@ -799,7 +799,7 @@ class MySpace
// adding the fields that are checked to the session // adding the fields that are checked to the session
$message = ''; $message = '';
foreach ($values as $field_ids => $value) { foreach ($values as $field_ids => $value) {
if ($value == 1 && strstr($field_ids,'extra_export_field')) { if ($value == 1 && strstr($field_ids, 'extra_export_field')) {
$_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids); $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids);
} }
} }
@ -814,7 +814,7 @@ class MySpace
// Displaying a feedback message // Displaying a feedback message
if (!empty($_SESSION['additional_export_fields'])) { if (!empty($_SESSION['additional_export_fields'])) {
Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false); Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
} else { } else {
Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false); Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
} }
} else { } else {
@ -863,7 +863,7 @@ class MySpace
$table->set_header(0, '', false, null, array('style' => 'display: none')); $table->set_header(0, '', false, null, array('style' => 'display: none'));
$table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); $table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;')); $table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
$table->set_column_filter(2, array('MySpace','course_tracking_filter')); $table->set_column_filter(2, array('MySpace', 'course_tracking_filter'));
$table->display(); $table->display();
} }
@ -957,18 +957,18 @@ class MySpace
$progress += $progress_tmp[0]; $progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1]; $nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score($row->user_id, $course_code, array(), null, true); $score_tmp = Tracking::get_avg_student_score($row->user_id, $course_code, array(), null, true);
if(is_array($score_tmp)) { if (is_array($score_tmp)) {
$score += $score_tmp[0]; $score += $score_tmp[0];
$nb_score_lp += $score_tmp[1]; $nb_score_lp += $score_tmp[1];
} }
$nb_messages += Tracking::count_student_messages($row->user_id, $course_code); $nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. } else if ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
// Find the max and assign it to first_login_date // Find the max and assign it to first_login_date
if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} }
} }
@ -1106,7 +1106,7 @@ class MySpace
$progress += $progress_tmp[0]; $progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1]; $nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score($row->user_id, $course_code, array(), null, true); $score_tmp = Tracking::get_avg_student_score($row->user_id, $course_code, array(), null, true);
if(is_array($score_tmp)) { if (is_array($score_tmp)) {
$score += $score_tmp[0]; $score += $score_tmp[0];
$nb_score_lp += $score_tmp[1]; $nb_score_lp += $score_tmp[1];
} }
@ -1114,11 +1114,11 @@ class MySpace
$nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
// Find the max and assign it to first_login_date // Find the max and assign it to first_login_date
if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} }
} }
@ -1128,22 +1128,22 @@ class MySpace
$total_score_possible += $exercise_results_tmp['score_possible']; $total_score_possible += $exercise_results_tmp['score_possible'];
$total_questions_answered += $exercise_results_tmp['questions_answered']; $total_questions_answered += $exercise_results_tmp['questions_answered'];
} }
if($nb_progress_lp > 0) { if ($nb_progress_lp > 0) {
$avg_progress = round($progress / $nb_progress_lp, 2); $avg_progress = round($progress / $nb_progress_lp, 2);
} else { } else {
$avg_progress = 0; $avg_progress = 0;
} }
if($nb_score_lp > 0) { if ($nb_score_lp > 0) {
$avg_score = round($score / $nb_score_lp, 2); $avg_score = round($score / $nb_score_lp, 2);
} else { } else {
$avg_score = '-'; $avg_score = '-';
} }
if($last_login_date) { if ($last_login_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
} else { } else {
$last_login_date = '-'; $last_login_date = '-';
} }
if($total_score_possible > 0) { if ($total_score_possible > 0) {
$total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
} else { } else {
$total_score_percentage = 0; $total_score_percentage = 0;
@ -1321,10 +1321,10 @@ class MySpace
if ($last_login_date_tmp != false && $last_login_date == false) { if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: To be cleaned. // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date != false) { } else if ($last_login_date_tmp != false && $last_login_date != false) {
// TODO: Repeated previous condition! To be cleaned. // TODO: Repeated previous condition! To be cleaned.
// Find the max and assign it to first_login_date // Find the max and assign it to first_login_date
if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} }
} }
@ -1465,7 +1465,7 @@ class MySpace
$total_score_obtained = 0; $total_score_obtained = 0;
$total_score_possible = 0; $total_score_possible = 0;
$total_questions_answered = 0; $total_questions_answered = 0;
while($row_user = Database::fetch_object($result_users)) { while ($row_user = Database::fetch_object($result_users)) {
// get time spent in the course and session // get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id); $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true); $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
@ -1494,11 +1494,11 @@ class MySpace
$session_id, $session_id,
false false
); );
if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
// Find the max and assign it to first_login_date // Find the max and assign it to first_login_date
if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp; $last_login_date = $last_login_date_tmp;
} }
} }
@ -1508,27 +1508,27 @@ class MySpace
$total_score_possible += $exercise_results_tmp['score_possible']; $total_score_possible += $exercise_results_tmp['score_possible'];
$total_questions_answered += $exercise_results_tmp['questions_answered']; $total_questions_answered += $exercise_results_tmp['questions_answered'];
} }
if($nb_progress_lp > 0) { if ($nb_progress_lp > 0) {
$avg_progress = round($progress / $nb_progress_lp, 2); $avg_progress = round($progress / $nb_progress_lp, 2);
} else { } else {
$avg_progress = 0; $avg_progress = 0;
} }
if($nb_score_lp > 0) { if ($nb_score_lp > 0) {
$avg_score = round($score / $nb_score_lp, 2); $avg_score = round($score / $nb_score_lp, 2);
} else { } else {
$avg_score = '-'; $avg_score = '-';
} }
if($last_login_date) { if ($last_login_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
} else { } else {
$last_login_date = '-'; $last_login_date = '-';
} }
if($total_score_possible > 0) { if ($total_score_possible > 0) {
$total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
} else { } else {
$total_score_percentage = 0; $total_score_percentage = 0;
} }
if($total_score_percentage > 0) { if ($total_score_percentage > 0) {
$total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
} else { } else {
$total_score = '-'; $total_score = '-';
@ -1588,7 +1588,7 @@ class MySpace
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {
$score_obtained += $row['exe_result']; $score_obtained += $row['exe_result'];
$score_possible += $row['exe_weighting']; $score_possible += $row['exe_weighting'];
$questions_answered ++; $questions_answered++;
} }
if ($score_possible != 0) { if ($score_possible != 0) {
@ -1707,9 +1707,9 @@ class MySpace
} }
} }
// time spent in the course // time spent in the course
$csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId)); $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId));
// student progress in course // student progress in course
$csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2); $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2);
// student score // student score
$csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2); $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2);
// student tes score // student tes score
@ -1717,7 +1717,7 @@ class MySpace
// student messages // student messages
$csv_row[] = Tracking::count_student_messages($user[4], $row[0]); $csv_row[] = Tracking::count_student_messages($user[4], $row[0]);
// student assignments // student assignments
$csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]); $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]);
// student exercises results // student exercises results
$exercises_results = self::exercises_results($user[4], $row[0]); $exercises_results = self::exercises_results($user[4], $row[0]);
$csv_row[] = $exercises_results['score_obtained']; $csv_row[] = $exercises_results['score_obtained'];
@ -1725,7 +1725,7 @@ class MySpace
$csv_row[] = $exercises_results['questions_answered']; $csv_row[] = $exercises_results['questions_answered'];
$csv_row[] = $exercises_results['percentage']; $csv_row[] = $exercises_results['percentage'];
// first connection // first connection
$csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId); $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $courseId);
// last connection // last connection
$csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo)); $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo));
@ -1759,9 +1759,9 @@ class MySpace
// get all courses with limit // get all courses with limit
$sql = "SELECT course.code as col1, course.title as col2 $sql = "SELECT course.code as col1, course.title as col2
FROM $tbl_course course FROM $tbl_course course
WHERE course.code IN (".implode(',',$courses_code).")"; WHERE course.code IN (".implode(',', $courses_code).")";
if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC'; if (!in_array($direction, array('ASC', 'DESC'))) $direction = 'ASC';
$column = intval($column); $column = intval($column);
$from = intval($from); $from = intval($from);
@ -1830,7 +1830,7 @@ class MySpace
$table_row[] = $avg_assignments_in_course; $table_row[] = $avg_assignments_in_course;
//set the "from" value to know if I access the Reporting by the chamilo tab or the course link //set the "from" value to know if I access the Reporting by the chamilo tab or the course link
$table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq=' .$course_code.'&from=myspace&id_session='.$session_id.'"> $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq='.$course_code.'&from=myspace&id_session='.$session_id.'">
'.Display::return_icon('2rightarrow.png').' '.Display::return_icon('2rightarrow.png').'
</a> </a>
</center>'; </center>';
@ -1839,7 +1839,7 @@ class MySpace
$nb_students_in_course, $nb_students_in_course,
$avg_time_spent_in_course, $avg_time_spent_in_course,
is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%', is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%',
is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course , is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course,
is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%', is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%',
$avg_messages_in_course, $avg_messages_in_course,
$avg_assignments_in_course, $avg_assignments_in_course,
@ -1967,7 +1967,7 @@ class MySpace
$i++; $i++;
} }
} }
$username_array = array('username' => $desired_username , 'sufix' => $sufix); $username_array = array('username' => $desired_username, 'sufix' => $sufix);
return $username_array; return $username_array;
} else { } else {
$username_array = array('username' => $username, 'sufix' => ''); $username_array = array('username' => $username, 'sufix' => '');
@ -2244,7 +2244,7 @@ class MySpace
foreach ($users as $index => $user) { foreach ($users as $index => $user) {
$userid = $user['id']; $userid = $user['id'];
$sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at)
VALUES ('$id_session','$userid', '" . api_get_utc_datetime() . "')"; VALUES ('$id_session','$userid', '".api_get_utc_datetime()."')";
Database::query($sql_insert); Database::query($sql_insert);
$user['added_at_session'] = 1; $user['added_at_session'] = 1;
$new_users[] = $user; $new_users[] = $user;
@ -2278,10 +2278,10 @@ class MySpace
); );
$userInfo = api_get_user_info($user['id']); $userInfo = api_get_user_info($user['id']);
if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) { if ($user['added_at_platform'] == 1) {
$addedto = get_lang('UserCreatedPlatform'); $addedto = get_lang('UserCreatedPlatform');
} else { } else {
$addedto = ' '; $addedto = ' ';
} }
@ -2346,7 +2346,7 @@ class MySpace
global $current_tag; global $current_tag;
switch ($data) { switch ($data) {
case 'Contact' : case 'Contact' :
$user = array (); $user = array();
break; break;
default: default:
$current_tag = $data; $current_tag = $data;
@ -2393,9 +2393,9 @@ class MySpace
global $current_value; global $current_value;
global $user; global $user;
global $users; global $users;
$users = array (); $users = array();
$parser = xml_parser_create('UTF-8'); $parser = xml_parser_create('UTF-8');
xml_set_element_handler($parser, array('MySpace','element_start'), array('MySpace','element_end')); xml_set_element_handler($parser, array('MySpace', 'element_start'), array('MySpace', 'element_end'));
xml_set_character_data_handler($parser, "character_data"); xml_set_character_data_handler($parser, "character_data");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
@ -2441,7 +2441,7 @@ class MySpace
get_lang('SearchCourse'), get_lang('SearchCourse'),
$courseList, $courseList,
[ [
'url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query([ 'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?'.http_build_query([
'a' => 'search_course_by_session_all', 'a' => 'search_course_by_session_all',
'session_id' => $sessionId 'session_id' => $sessionId
]) ])
@ -2460,7 +2460,7 @@ class MySpace
course_id: $('#course_id').val() || 0 course_id: $('#course_id').val() || 0
}); });
return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params; return '" . api_get_path(WEB_AJAX_PATH)."session.ajax.php?' + params;
} }
" "
] ]
@ -2491,7 +2491,7 @@ class MySpace
course_id: $('#course_id').val() course_id: $('#course_id').val()
}); });
return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params; return '" . api_get_path(WEB_AJAX_PATH)."course.ajax.php?' + params;
} }
" "
] ]
@ -2592,7 +2592,7 @@ class MySpace
" : " " : "
u.lastname AS col2, u.lastname AS col2,
u.firstname AS col3, u.firstname AS col3,
" ) . " " )."
a.logout_course_date, a.logout_course_date,
c.title, c.title,
c.code, c.code,
@ -2603,7 +2603,7 @@ class MySpace
if (isset($_GET['session_id']) && !empty($_GET['session_id'])) { if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
$sessionId = intval($_GET['session_id']); $sessionId = intval($_GET['session_id']);
$sql .= " WHERE a.session_id = " . $sessionId; $sql .= " WHERE a.session_id = ".$sessionId;
} }
$sql .= " ORDER BY col$column $orderDirection "; $sql .= " ORDER BY col$column $orderDirection ";
@ -2707,13 +2707,13 @@ class MySpace
function get_stats($user_id, $courseId, $start_date = null, $end_date = null) function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
{ {
// Database table definitions // Database table definitions
$tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info_by_id($courseId); $course_info = api_get_course_info_by_id($courseId);
if (!empty($course_info)) { if (!empty($course_info)) {
$strg_sd = ''; $strg_sd = '';
$strg_ed = ''; $strg_ed = '';
if ($start_date != null && $end_date != null){ if ($start_date != null && $end_date != null) {
$end_date = add_day_to($end_date); $end_date = add_day_to($end_date);
$strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'"; $strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
$strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'"; $strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
@ -2722,10 +2722,10 @@ function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg, SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total, SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
count(user_id) as times count(user_id) as times
FROM ' . $tbl_track_course . ' FROM ' . $tbl_track_course.'
WHERE WHERE
user_id = ' . intval($user_id) . ' AND user_id = ' . intval($user_id).' AND
c_id = ' . intval($courseId) . ' '.$strg_sd.' '.$strg_ed.' '.' c_id = ' . intval($courseId).' '.$strg_sd.' '.$strg_ed.' '.'
ORDER BY login_course_date ASC'; ORDER BY login_course_date ASC';
$rs = Database::query($sql); $rs = Database::query($sql);
@ -2743,7 +2743,7 @@ function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
} }
function add_day_to($end_date) { function add_day_to($end_date) {
$foo_date = strtotime( $end_date ); $foo_date = strtotime($end_date);
$foo_date = strtotime(" +1 day", $foo_date); $foo_date = strtotime(" +1 day", $foo_date);
$foo_date = date("Y-m-d", $foo_date); $foo_date = date("Y-m-d", $foo_date);
return $foo_date; return $foo_date;
@ -2802,10 +2802,10 @@ function convert_to_string($sql_result)
*/ */
function grapher($sql_result, $start_date, $end_date, $type = "") function grapher($sql_result, $start_date, $end_date, $type = "")
{ {
if (empty($start_date)) { $start_date =""; } if (empty($start_date)) { $start_date = ""; }
if (empty($end_date)) { $end_date =""; } if (empty($end_date)) { $end_date = ""; }
if ($type == ""){ $type = 'day'; } if ($type == "") { $type = 'day'; }
$main_year = $main_month_year = $main_day = []; $main_year = $main_month_year = $main_day = [];
$period = new DatePeriod( $period = new DatePeriod(
new DateTime($start_date), new DateTime($start_date),
@ -2864,7 +2864,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
/* Create and populate the pData object */ /* Create and populate the pData object */
$myData = new pData(); $myData = new pData();
$myData->addPoints($main_date, 'Serie1'); $myData->addPoints($main_date, 'Serie1');
if (count($main_date)!= 1) { if (count($main_date) != 1) {
$myData->addPoints($labels, 'Labels'); $myData->addPoints($labels, 'Labels');
$myData->setSerieDescription('Labels', 'Months'); $myData->setSerieDescription('Labels', 'Months');
$myData->setAbscissa('Labels'); $myData->setAbscissa('Labels');
@ -2872,7 +2872,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
$myData->setSerieWeight('Serie1', 1); $myData->setSerieWeight('Serie1', 1);
$myData->setSerieDescription('Serie1', get_lang('MyResults')); $myData->setSerieDescription('Serie1', get_lang('MyResults'));
$myData->setAxisName(0, get_lang('Minutes')); $myData->setAxisName(0, get_lang('Minutes'));
$myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true); $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
// Cache definition // Cache definition
$cachePath = api_get_path(SYS_ARCHIVE_PATH); $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@ -2881,9 +2881,9 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
if ($myCache->isInCache($chartHash)) { if ($myCache->isInCache($chartHash)) {
//if we already created the img //if we already created the img
$imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
$myCache->saveFromCache($chartHash, $imgPath); $myCache->saveFromCache($chartHash, $imgPath);
$imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
} else { } else {
/* Define width, height and angle */ /* Define width, height and angle */
$mainWidth = 760; $mainWidth = 760;
@ -2912,7 +2912,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
/* Set the default font */ /* Set the default font */
$myPicture->setFontProperties( $myPicture->setFontProperties(
array( array(
"FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
"FontSize" => 10) "FontSize" => 10)
); );
/* Write the chart title */ /* Write the chart title */
@ -2929,7 +2929,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
/* Set the default font */ /* Set the default font */
$myPicture->setFontProperties( $myPicture->setFontProperties(
array( array(
"FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
"FontSize" => 8 "FontSize" => 8
) )
); );
@ -2971,7 +2971,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
/* Draw the line chart */ /* Draw the line chart */
$myPicture->setFontProperties( $myPicture->setFontProperties(
array( array(
"FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
"FontSize" => 10 "FontSize" => 10
) )
); );
@ -2990,15 +2990,15 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
/* Write and save into cache */ /* Write and save into cache */
$myCache->writeToCache($chartHash, $myPicture); $myCache->writeToCache($chartHash, $myPicture);
$imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
$myCache->saveFromCache($chartHash, $imgPath); $myCache->saveFromCache($chartHash, $imgPath);
$imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
} }
$html = '<img src="' . $imgPath . '">'; $html = '<img src="'.$imgPath.'">';
return $html; return $html;
} else { } else {
$foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8'); $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>', 'UTF-8');
return $foo_img; return $foo_img;
} }

@ -42,7 +42,7 @@ function add_specific_field($name)
function delete_specific_field($id) function delete_specific_field($id)
{ {
$table_sf = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD); $table_sf = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$id = (int)$id; $id = (int) $id;
if (!is_numeric($id)) { if (!is_numeric($id)) {
return false; return false;
} }
@ -60,7 +60,7 @@ function delete_specific_field($id)
function edit_specific_field($id, $name) function edit_specific_field($id, $name)
{ {
$table_sf = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD); $table_sf = Database::get_main_table(TABLE_MAIN_SPECIFIC_FIELD);
$id = (int)$id; $id = (int) $id;
if (!is_numeric($id)) { if (!is_numeric($id)) {
return false; return false;
} }

@ -260,7 +260,7 @@ class IndexManager
// Including the page for the news // Including the page for the news
$html = ''; $html = '';
if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
$open = @(string)file_get_contents($this->home.$_GET['include']); $open = @(string) file_get_contents($this->home.$_GET['include']);
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
} else { } else {
// Hiding home top when user not connected. // Hiding home top when user not connected.
@ -315,9 +315,9 @@ class IndexManager
$html = ''; $html = '';
// Notice // Notice
$home_notice = @(string)file_get_contents($this->home.'home_notice_'.$user_selected_language.'.html'); $home_notice = @(string) file_get_contents($this->home.'home_notice_'.$user_selected_language.'.html');
if (empty($home_notice)) { if (empty($home_notice)) {
$home_notice = @(string)file_get_contents($this->home.'home_notice.html'); $home_notice = @(string) file_get_contents($this->home.'home_notice.html');
} }
if (!empty($home_notice)) { if (!empty($home_notice)) {
@ -350,7 +350,7 @@ class IndexManager
} }
$html = ''; $html = '';
$home_menu = @(string)file_get_contents($this->home.'home_menu_'.$user_selected_language.'.html'); $home_menu = @(string) file_get_contents($this->home.'home_menu_'.$user_selected_language.'.html');
if (!empty($home_menu)) { if (!empty($home_menu)) {
$home_menu_content = '<ul class="nav nav-pills nav-stacked">'; $home_menu_content = '<ul class="nav nav-pills nav-stacked">';
$home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu))); $home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
@ -1183,7 +1183,7 @@ class IndexManager
$user_id, $user_id,
$specialCourseInfo['course_code'] $specialCourseInfo['course_code']
); );
$specialCourses[$key]['student_info']['progress'] = ($progress === false)? null : $progress; $specialCourses[$key]['student_info']['progress'] = ($progress === false) ? null : $progress;
} }
if ($studentInfoScore) { if ($studentInfoScore) {
@ -1231,7 +1231,7 @@ class IndexManager
$user_id, $user_id,
$courseInCatInfo['course_code'] $courseInCatInfo['course_code']
); );
$courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = ($progress === false)? null : $progress; $courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = ($progress === false) ? null : $progress;
} }
if ($studentInfoScore) { if ($studentInfoScore) {
@ -1461,7 +1461,7 @@ class IndexManager
array(), array(),
$session_id $session_id
); );
$course_session['student_info']['progress'] = ($progress === false)? null : $progress; $course_session['student_info']['progress'] = ($progress === false) ? null : $progress;
} }
if ($studentInfoScore) { if ($studentInfoScore) {
@ -1902,7 +1902,7 @@ class IndexManager
$listCategorySession['catSessionName'] $listCategorySession['catSessionName']
); );
// list of session // list of session
$htmlSession = ''; // start $htmlSession = ''; // start
foreach ($listCategorySession['sessionList'] as $k => $listSession) { foreach ($listCategorySession['sessionList'] as $k => $listSession) {
// add session // add session
$htmlSession .= '<div class="session-view-row">'; $htmlSession .= '<div class="session-view-row">';
@ -1920,7 +1920,7 @@ class IndexManager
} }
$htmlSessionCategory .= '</div>'; // end session cat block $htmlSessionCategory .= '</div>'; // end session cat block
$htmlCategory .= $htmlSessionCategory.'</div></div>'; $htmlCategory .= $htmlSessionCategory.'</div></div>';
$htmlCategory .= ''; // end course block $htmlCategory .= ''; // end course block
} }
$userCategoryHtml .= $htmlCategory; $userCategoryHtml .= $htmlCategory;
} }
@ -1947,11 +1947,11 @@ class IndexManager
} }
} }
$htmlCategory .= ''; $htmlCategory .= '';
$userCategoryHtml .= $htmlCategory; // end user cat block $userCategoryHtml .= $htmlCategory; // end user cat block
if ($userCategoryId != 0) { if ($userCategoryId != 0) {
$userCategoryHtml .= '</div>'; $userCategoryHtml .= '</div>';
} }
$html .= $userCategoryHtml; // $html .= $userCategoryHtml; //
} }
$html .= '</div>'; $html .= '</div>';
@ -2093,11 +2093,11 @@ class IndexManager
{ {
$html = ''; $html = '';
if ($categorySessionId == 0) { if ($categorySessionId == 0) {
$class1 = 'session-view-lvl-2'; // session $class1 = 'session-view-lvl-2'; // session
$class2 = 'session-view-lvl-4'; // got to course in session link $class2 = 'session-view-lvl-4'; // got to course in session link
} else { } else {
$class1 = 'session-view-lvl-3'; // session $class1 = 'session-view-lvl-3'; // session
$class2 = 'session-view-lvl-5'; // got to course in session link $class2 = 'session-view-lvl-5'; // got to course in session link
} }
$icon = Display::return_icon( $icon = Display::return_icon(

@ -246,12 +246,12 @@ class aicc extends learnpath
$this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding(). $this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding().
$sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)" . $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)".
"VALUES " . "VALUES ".
"($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."'," . "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."',".
"'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."'," . "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."',".
"'aicc_api.php','".$this->course_creator."',$dsp)"; "'aicc_api.php','".$this->course_creator."',$dsp)";
if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '. $sql, 0); } if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '.$sql, 0); }
Database::query($sql); Database::query($sql);
$lp_id = Database::insert_id(); $lp_id = Database::insert_id();
@ -280,7 +280,7 @@ class aicc extends learnpath
$previous = 0; $previous = 0;
foreach ($this->aulist as $identifier => $dummy) { foreach ($this->aulist as $identifier => $dummy) {
$oAu =& $this->aulist[$identifier]; $oAu = & $this->aulist[$identifier];
//echo "Item ".$oAu->identifier; //echo "Item ".$oAu->identifier;
$field_add = ''; $field_add = '';
$value_add = ''; $value_add = '';
@ -298,12 +298,12 @@ class aicc extends learnpath
$parent = 0; // TODO: Deal with the parent. $parent = 0; // TODO: Deal with the parent.
$previous = 0; $previous = 0;
$prereq = $oAu->prereq_string; $prereq = $oAu->prereq_string;
$sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) " . $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) ".
"VALUES " . "VALUES ".
"($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."'," . "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."',".
"'$path',0,100, $value_add" . "'$path',0,100, $value_add".
"$parent, $previous, 0, " . "$parent, $previous, 0, ".
"'$prereq', 0,'".(!empty($oAu->parameters)?Database::escape_string($oAu->parameters):'')."'" . "'$prereq', 0,'".(!empty($oAu->parameters) ? Database::escape_string($oAu->parameters) : '')."'".
")"; ")";
Database::query($sql_item); Database::query($sql_item);
if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); } if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); }
@ -354,7 +354,7 @@ class aicc extends learnpath
$zip_file_name = $zip_file_info['name']; $zip_file_name = $zip_file_info['name'];
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); } if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); }
$course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses
$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course. $course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course.
$current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/ $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); } if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); }
@ -371,7 +371,7 @@ class aicc extends learnpath
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); } if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); }
$new_dir = api_replace_dangerous_char(trim($file_base_name)); $new_dir = api_replace_dangerous_char(trim($file_base_name));
$this->subdir = $new_dir; $this->subdir = $new_dir;
if($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); } if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); }
/* /*
if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) { if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) {
@ -418,7 +418,7 @@ class aicc extends learnpath
$subdir_isset = true; $subdir_isset = true;
} else { } else {
if (!$subdir_isset) { if (!$subdir_isset) {
if (preg_match('?^.*/aicc$?i',dirname($thisContent['filename']))) { if (preg_match('?^.*/aicc$?i', dirname($thisContent['filename']))) {
//echo "Cutting subdir<br/>"; //echo "Cutting subdir<br/>";
$this->subdir .= '/'.substr(dirname($thisContent['filename']), 0, -5); $this->subdir .= '/'.substr(dirname($thisContent['filename']), 0, -5);
} else { } else {
@ -528,7 +528,7 @@ class aicc extends learnpath
// TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible! // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
//$safe_file = api_replace_dangerous_char($file, 'strict'); //$safe_file = api_replace_dangerous_char($file, 'strict');
$find_str = array('\\', '.php', '.phtml'); $find_str = array('\\', '.php', '.phtml');
$repl_str = array('/', '.txt', '.txt'); $repl_str = array('/', '.txt', '.txt');
$safe_file = str_replace($find_str, $repl_str, $file); $safe_file = str_replace($find_str, $repl_str, $file);
if ($safe_file != $file) { if ($safe_file != $file) {
@ -738,7 +738,7 @@ class aicc extends learnpath
if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); } if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); }
$path = ''; $path = '';
if (isset($this->resources[$id])) { if (isset($this->resources[$id])) {
$oRes =& $this->resources[$id]; $oRes = & $this->resources[$id];
$path = @$oRes->get_path(); $path = @$oRes->get_path();
} }
return $path; return $path;
@ -754,7 +754,7 @@ class aicc extends learnpath
if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); } if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); }
$type = ''; $type = '';
if (isset($this->resources[$id])) { if (isset($this->resources[$id])) {
$oRes =& $this->resources[$id]; $oRes = & $this->resources[$id];
$temptype = $oRes->get_scorm_type(); $temptype = $oRes->get_scorm_type();
if (!empty($temptype)) { if (!empty($temptype)) {
$type = $temptype; $type = $temptype;
@ -933,7 +933,7 @@ class aicc extends learnpath
$chr = $data{$i}; $chr = $data{$i};
switch ($chr) { switch ($chr) {
case $enclosure: case $enclosure:
if ($enclosed && $data{$i+1} == $enclosure) { if ($enclosed && $data{$i + 1} == $enclosure) {
$fldval .= $chr; $fldval .= $chr;
++$i; // Skip the next character. ++$i; // Skip the next character.
} else } else
@ -947,7 +947,7 @@ class aicc extends learnpath
$fldval .= $chr; $fldval .= $chr;
break; break;
case "\r": case "\r":
if (!$enclosed&&$data{$i+1} == "\n") { if (!$enclosed && $data{$i + 1} == "\n") {
continue; continue;
} }
// no break // no break
@ -960,7 +960,7 @@ class aicc extends learnpath
$fldval .= $chr; $fldval .= $chr;
break; break;
case "\\r": case "\\r":
if (!$enclosed&&$data{$i+1} == "\\n") { if (!$enclosed && $data{$i + 1} == "\\n") {
continue; continue;
} }
// no break // no break

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -258,7 +258,7 @@ class bbb
$params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false; $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false;
$max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode); $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode);
$max = isset($max) ? $max : -1; $max = isset($max) ? $max : -1;
$params['status'] = 1; $params['status'] = 1;
// Generate a pseudo-global-unique-id to avoid clash of conferences on // Generate a pseudo-global-unique-id to avoid clash of conferences on
@ -291,23 +291,23 @@ class bbb
$duration = 300; $duration = 300;
$bbbParams = array( $bbbParams = array(
'meetingId' => $params['remote_id'], // REQUIRED 'meetingId' => $params['remote_id'], // REQUIRED
'meetingName' => $meetingName, // REQUIRED 'meetingName' => $meetingName, // REQUIRED
'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee. 'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee.
'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator. 'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator.
'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize. 'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize.
'dialNumber' => '', // The main number to call into. Optional. 'dialNumber' => '', // The main number to call into. Optional.
'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required. 'voiceBridge' => $params['voice_bridge'], // PIN to join voice. Required.
'webVoice' => '', // Alphanumeric to join voice. Optional. 'webVoice' => '', // Alphanumeric to join voice. Optional.
'logoutUrl' => $this->logoutUrl, 'logoutUrl' => $this->logoutUrl,
'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number] 'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number]
'record' => $record, // New. 'true' will tell BBB to record the meeting. 'record' => $record, // New. 'true' will tell BBB to record the meeting.
'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number]
//'meta_category' => '', // Use to pass additional info to BBB server. See API docs. //'meta_category' => '', // Use to pass additional info to BBB server. See API docs.
); );
if ($this->debug) { if ($this->debug) {
error_log("create_meeting params: ".print_r($bbbParams,1)); error_log("create_meeting params: ".print_r($bbbParams, 1));
} }
$status = false; $status = false;
@ -320,7 +320,7 @@ class bbb
if (isset($result) && strval($result['returncode']) == 'SUCCESS') { if (isset($result) && strval($result['returncode']) == 'SUCCESS') {
if ($this->debug) { if ($this->debug) {
error_log( error_log(
"create_meeting result: " . print_r($result, 1) "create_meeting result: ".print_r($result, 1)
); );
} }
$meeting = $this->joinMeeting($meetingName, true); $meeting = $this->joinMeeting($meetingName, true);
@ -370,7 +370,7 @@ class bbb
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$sessionId = api_get_session_id(); $sessionId = api_get_session_id();
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 AND access_url = ?' => 'c_id = ? AND session_id = ? AND meeting_name = ? AND status = 1 AND access_url = ?' =>
array($courseId, $sessionId, $meetingName, $this->accessUrl) array($courseId, $sessionId, $meetingName, $this->accessUrl)
@ -379,7 +379,7 @@ class bbb
if ($this->hasGroupSupport()) { if ($this->hasGroupSupport()) {
$groupId = api_get_group_id(); $groupId = api_get_group_id();
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' => 'c_id = ? AND session_id = ? AND meeting_name = ? AND group_id = ? AND status = 1 AND access_url = ?' =>
array($courseId, $sessionId, $meetingName, $groupId, $this->accessUrl) array($courseId, $sessionId, $meetingName, $groupId, $this->accessUrl)
@ -481,7 +481,7 @@ class bbb
if ($this->debug) { if ($this->debug) {
error_log( error_log(
"meeting is running: " . intval($meetingInfoExists) "meeting is running: ".intval($meetingInfoExists)
); );
} }
@ -498,11 +498,11 @@ class bbb
if ($meetingInfoExists) { if ($meetingInfoExists) {
$joinParams = array( $joinParams = array(
'meetingId' => $meetingData['remote_id'], // -- REQUIRED - A unique id for the meeting 'meetingId' => $meetingData['remote_id'], // -- REQUIRED - A unique id for the meeting
'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting 'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
//'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. //'createTime' => api_get_utc_datetime(), //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => api_get_user_id(), //-- OPTIONAL - string 'userID' => api_get_user_id(), //-- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string 'webVoiceConf' => '' // -- OPTIONAL - string
); );
$url = $this->api->getJoinMeetingURL($joinParams); $url = $this->api->getJoinMeetingURL($joinParams);
@ -511,7 +511,7 @@ class bbb
$url = $this->logoutUrl; $url = $this->logoutUrl;
} }
if ($this->debug) { if ($this->debug) {
error_log("return url :" . $url); error_log("return url :".$url);
} }
return $url; return $url;
@ -552,7 +552,7 @@ class bbb
*/ */
public function getAllMeetingsInCourse($courseId, $sessionId, $status) public function getAllMeetingsInCourse($courseId, $sessionId, $status)
{ {
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'status = ? AND c_id = ? AND session_id = ? ' => array( 'status = ? AND c_id = ? AND session_id = ? ' => array(
$status, $status,
@ -592,14 +592,14 @@ class bbb
$conditions = []; $conditions = [];
if ($courseId || $sessionId || $groupId) { if ($courseId || $sessionId || $groupId) {
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? ' => array($courseId, $sessionId), 'c_id = ? AND session_id = ? ' => array($courseId, $sessionId),
), ),
); );
if ($this->hasGroupSupport()) { if ($this->hasGroupSupport()) {
$conditions = array( $conditions = array(
'where' => array( 'where' => array(
'c_id = ? AND session_id = ? AND group_id = ? ' => array($courseId, $sessionId, $groupId) 'c_id = ? AND session_id = ? AND group_id = ? ' => array($courseId, $sessionId, $groupId)
) )
@ -665,7 +665,7 @@ class bbb
$meetingBBB['end_url'] = $this->endUrl($meetingDB); $meetingBBB['end_url'] = $this->endUrl($meetingDB);
if (isset($meetingBBB['returncode']) && (string)$meetingBBB['returncode'] == 'FAILED') { if (isset($meetingBBB['returncode']) && (string) $meetingBBB['returncode'] == 'FAILED') {
if ($meetingDB['status'] == 1 && $this->isConferenceManager()) { if ($meetingDB['status'] == 1 && $this->isConferenceManager()) {
$this->endMeeting($meetingDB['id'], $courseCode); $this->endMeeting($meetingDB['id'], $courseCode);
} }
@ -721,7 +721,7 @@ class bbb
} }
$actionLinks = $this->getActionLinks($meetingDB, $record, $isGlobal, $isAdminReport); $actionLinks = $this->getActionLinks($meetingDB, $record, $isGlobal, $isAdminReport);
$item['show_links'] = $recordLink; $item['show_links'] = $recordLink;
} else { } else {
$actionLinks = $this->getActionLinks($meetingDB, [], $isGlobal, $isAdminReport); $actionLinks = $this->getActionLinks($meetingDB, [], $isGlobal, $isAdminReport);
@ -739,11 +739,11 @@ class bbb
if ($meetingDB['status'] == 1) { if ($meetingDB['status'] == 1) {
$joinParams = array( $joinParams = array(
'meetingId' => $meetingDB['remote_id'], //-- REQUIRED - A unique id for the meeting 'meetingId' => $meetingDB['remote_id'], //-- REQUIRED - A unique id for the meeting
'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting 'username' => $this->userCompleteName, //-- REQUIRED - The name that will display for the user in the meeting
'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here 'password' => $pass, //-- REQUIRED - The attendee or moderator password, depending on what's passed here
'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly. 'createTime' => '', //-- OPTIONAL - string. Leave blank ('') unless you set this correctly.
'userID' => '', // -- OPTIONAL - string 'userID' => '', // -- OPTIONAL - string
'webVoiceConf' => '' // -- OPTIONAL - string 'webVoiceConf' => '' // -- OPTIONAL - string
); );
$item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams); $item['go_url'] = $this->protocol.$this->api->getJoinMeetingURL($joinParams);
@ -819,8 +819,8 @@ class bbb
} }
$endParams = array( $endParams = array(
'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end. 'meetingId' => $meetingData['remote_id'], // REQUIRED - We have to know which meeting to end.
'password' => $pass, // REQUIRED - Must match moderator pass for meeting. 'password' => $pass, // REQUIRED - Must match moderator pass for meeting.
); );
$this->api->endMeetingWithXmlResponseArray($endParams); $this->api->endMeetingWithXmlResponseArray($endParams);
Database::update( Database::update(
@ -1073,7 +1073,7 @@ class bbb
*/ */
public function redirectToBBB($url) public function redirectToBBB($url)
{ {
if (file_exists(__DIR__ . '/../config.vm.php')) { if (file_exists(__DIR__.'/../config.vm.php')) {
// Using VM // Using VM
echo Display::url($this->plugin->get_lang('ClickToContinue'), $url); echo Display::url($this->plugin->get_lang('ClickToContinue'), $url);
exit; exit;
@ -1330,7 +1330,7 @@ class bbb
if ($meetingInfo['has_video_m4v']) { if ($meetingInfo['has_video_m4v']) {
$links[] = Display::url( $links[] = Display::url(
Display::return_icon('save.png', get_lang('DownloadFile')), Display::return_icon('save.png', get_lang('DownloadFile')),
$recordInfo['playbackFormatUrl'] . '/capture.m4v', $recordInfo['playbackFormatUrl'].'/capture.m4v',
['target' => '_blank'] ['target' => '_blank']
); );
} else { } else {
@ -1395,7 +1395,7 @@ class bbb
return false; return false;
} }
$hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'] . '/capture.m4v'); $hasCapture = SocialManager::verifyUrl($meetingInfo['video_url'].'/capture.m4v');
if ($hasCapture) { if ($hasCapture) {
return Database::update( return Database::update(

Loading…
Cancel
Save