Minor - format code

pull/2487/head
jmontoyaa 8 years ago
parent f334ecd9a1
commit 1451a902b8
  1. 125
      main/exercise/exercise_submit.php
  2. 51
      main/exercise/question_pool.php
  3. 6
      main/inc/lib/display.lib.php
  4. 53
      main/inc/lib/document.lib.php
  5. 126
      main/lp/learnpath.class.php
  6. 13
      main/lp/scorm.class.php
  7. 27
      main/survey/surveyUtil.class.php

@ -4,29 +4,29 @@
use ChamiloSession as Session;
/**
* Exercise submission
* This script allows to run an exercise. According to the exercise type, questions
* can be on an unique page, or one per page with a Next button.
*
* One exercise may contain different types of answers (unique or multiple selection,
* matching, fill in blanks, free answer, hot-spot).
*
* Questions are selected randomly or not.
*
* When the user has answered all questions and clicks on the button "Ok",
* it goes to exercise_result.php
*
* Notice : This script is also used to show a question before modifying it by
* the administrator
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya <gugli100@gmail.com>
* Fill in blank option added (2008)
* Cleaning exercises (2010),
* Adding hotspot delineation support (2011)
* Adding reminder + ajax support (2011)
* Modified by hubert.borderiou (2011-10-21 question category)
*/
* Exercise submission
* This script allows to run an exercise. According to the exercise type, questions
* can be on an unique page, or one per page with a Next button.
*
* One exercise may contain different types of answers (unique or multiple selection,
* matching, fill in blanks, free answer, hot-spot).
*
* Questions are selected randomly or not.
*
* When the user has answered all questions and clicks on the button "Ok",
* it goes to exercise_result.php
*
* Notice : This script is also used to show a question before modifying it by
* the administrator
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya <gugli100@gmail.com>
* Fill in blank option added (2008)
* Cleaning exercises (2010),
* Adding hotspot delineation support (2011)
* Adding reminder + ajax support (2011)
* Modified by hubert.borderiou (2011-10-21 question category)
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_QUIZ;
@ -117,33 +117,43 @@ if (!isset($exerciseInSession) || isset($exerciseInSession) && ($exerciseInSessi
// Construction of Exercise
$objExercise = new Exercise();
Session::write('firstTime', true);
if ($debug) {error_log('1. Setting the $objExercise variable'); };
if ($debug) {
error_log('1. Setting the $objExercise variable');
}
Session::erase('questionList');
// if the specified exercise doesn't exist or is disabled
if (!$objExercise->read($exerciseId) ||
(!$objExercise->selectStatus() && !$is_allowedToEdit && $origin != 'learnpath')
) {
if ($debug) {error_log('1.1. Error while reading the exercise'); };
if ($debug) {
error_log('1.1. Error while reading the exercise');
}
unset($objExercise);
$error = get_lang('ExerciseNotFound');
} else {
// Saves the object into the session
Session::write('objExercise', $objExercise);
if ($debug) {error_log('1.1. $exerciseInSession was unset - set now - end'); };
if ($debug) {
error_log('1.1. $exerciseInSession was unset - set now - end');
}
}
} else {
Session::write('firstTime', false);
}
//2. Checking if $objExercise is set
if (!isset($objExercise) && isset($exerciseInSession)) {
if ($debug) { error_log('2. Loading $objExercise from session'); };
if ($debug) {
error_log('2. Loading $objExercise from session');
}
$objExercise = $exerciseInSession;
}
//3. $objExercise is not set, then return to the exercise list
if (!is_object($objExercise)) {
if ($debug) {error_log('3. $objExercise was not set, kill the script'); };
if ($debug) {
error_log('3. $objExercise was not set, kill the script');
}
header('Location: exercise.php');
exit;
}
@ -313,7 +323,9 @@ Session::write('question_list_uncompressed', $questionListUncompressed);
$clock_expired_time = null;
if (empty($exercise_stat_info)) {
if ($debug) error_log('5 $exercise_stat_info is empty ');
if ($debug) {
error_log('5 $exercise_stat_info is empty ');
}
$total_weight = 0;
$questionList = $objExercise->get_validated_question_list();
foreach ($questionListUncompressed as $question_id) {
@ -323,16 +335,25 @@ if (empty($exercise_stat_info)) {
if ($time_control) {
$expected_time = $current_timestamp + $total_seconds;
if ($debug) error_log('5.1. $current_timestamp '.$current_timestamp);
if ($debug) error_log('5.2. $expected_time '.$expected_time);
if ($debug) {
error_log('5.1. $current_timestamp '.$current_timestamp);
}
if ($debug) {
error_log('5.2. $expected_time '.$expected_time);
}
$clock_expired_time = api_get_utc_datetime($expected_time);
if ($debug) error_log('5.3. $expected_time '.$clock_expired_time);
if ($debug) {
error_log('5.3. $expected_time '.$clock_expired_time);
}
//Sessions that contain the expired time
$_SESSION['expired_time'][$current_expired_time_key] = $clock_expired_time;
if ($debug) { error_log('5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]); };
if ($debug) {
error_log(
'5.4. Setting the $_SESSION[expired_time]: '.$_SESSION['expired_time'][$current_expired_time_key]
);
};
}
$exe_id = $objExercise->save_stat_track_exercise_info(
@ -348,7 +369,9 @@ if (empty($exercise_stat_info)) {
$learnpath_item_id,
$learnpath_item_view_id
);
if ($debug) error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id");
if ($debug) {
error_log("5.5 exercise_stat_info[] exists getting exe_id $exe_id");
}
} else {
$exe_id = $exercise_stat_info['exe_id'];
// Remember last question id position.
@ -372,7 +395,9 @@ if (empty($exercise_stat_info)) {
}
}
if ($debug) error_log("5 exercise_stat_info[] exists getting exe_id $exe_id ");
if ($debug) {
error_log("5 exercise_stat_info[] exists getting exe_id $exe_id ");
}
}
$questionListInSession = Session::read('questionList');
@ -407,7 +432,14 @@ if (!isset($questionListInSession)) {
// Array to check in order to block the chat
ExerciseLib::create_chat_exercise_session($exe_id);
if ($debug) { error_log('6. $objExercise->get_stat_track_exercise_info function called:: '.print_r($exercise_stat_info, 1)); };
if ($debug) {
error_log(
'6. $objExercise->get_stat_track_exercise_info function called:: '.print_r(
$exercise_stat_info,
1
)
);
};
if (!empty($exercise_stat_info['questions_to_check'])) {
$my_remind_list = $exercise_stat_info['questions_to_check'];
@ -416,10 +448,14 @@ if (!empty($exercise_stat_info['questions_to_check'])) {
}
$params = "exe_id=$exe_id&exerciseId=$exerciseId&origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
if ($debug) { error_log("6.1 params: -> $params"); };
if ($debug) {
error_log("6.1 params: -> $params");
}
if ($reminder == 2 && empty($my_remind_list)) {
if ($debug) { error_log("6.2 calling the exercise_reminder.php "); };
if ($debug) {
error_log("6.2 calling the exercise_reminder.php ");
};
header('Location: exercise_reminder.php?'.$params);
exit;
}
@ -484,7 +520,9 @@ if ($time_control) {
$clock_expired_time = $_SESSION['expired_time'][$current_expired_time_key];
}
} else {
if ($debug) { error_log("7 No time control"); };
if ($debug) {
error_log("7 No time control");
}
}
// Get time left for expiring time
@ -513,7 +551,9 @@ if (!isset($_SESSION['questionList'])) {
}
}
if ($debug) error_log('8. Question list loaded '.print_r($questionList, 1));
if ($debug) {
error_log('8. Question list loaded '.print_r($questionList, 1));
}
//Real question count
$question_count = 0;
@ -663,7 +703,6 @@ if (is_null($current_question)) {
$current_question++;
}
if ($question_count != 0) {
if (($objExercise->type == ALL_ON_ONE_PAGE ||
$current_question > $question_count)
@ -855,10 +894,8 @@ if ($reminder == 2) {
//Checking which questions we are going to call from the remind list
for ($i = 0; $i < count($data_tracking); $i++) {
for ($j = 0; $j < count($my_remind_list); $j++) {
if (!empty($remind_question_id)) {
if ($remind_question_id == $my_remind_list[$j]) {
if ($remind_question_id == $data_tracking[$i]) {
if (isset($my_remind_list[$j + 1])) {
$remind_question_id = $my_remind_list[$j + 1];

@ -2,14 +2,14 @@
/* For licensing terms, see /license.txt */
/**
* Question Pool
* This script allows administrators to manage questions and add them into their exercises.
* One question can be in several exercises
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya adding support to query all questions from all session, courses, exercises
* @author Modify by hubert borderiou 2011-10-21 Question's category
*/
* Question Pool
* This script allows administrators to manage questions and add them into their exercises.
* One question can be in several exercises
* @package chamilo.exercise
* @author Olivier Brouckaert
* @author Julio Montoya adding support to query all questions from all session, courses, exercises
* @author Modify by hubert borderiou 2011-10-21 Question's category
*/
use ChamiloSession as Session;
@ -119,7 +119,7 @@ if ($is_allowedToEdit) {
// destruction of the Question object
unset($objQuestionTmp);
if (!$objExercise instanceOf Exercise) {
if (!$objExercise instanceof Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -160,7 +160,7 @@ if ($is_allowedToEdit) {
unset($new_question_obj);
unset($old_question_obj);
if (!$objExercise instanceOf Exercise) {
if (!$objExercise instanceof Exercise) {
$objExercise = new Exercise();
$objExercise->read($fromExercise);
}
@ -565,7 +565,6 @@ if ($exerciseId > 0) {
if (!empty($my_exercise)) {
if (!empty($my_exercise->questionList)) {
foreach ($my_exercise->questionList as $question_id) {
$question_obj = Question::read(
$question_id,
$courseItemId
@ -709,15 +708,8 @@ $header = array(
$data = array();
/*$hideDoubles = false;
if (empty($exerciseId) && !empty($session_id) && $session_id != '-1') {
$hideDoubles = true;
}
$questionAdded = array();*/
if (is_array($mainQuestionList)) {
foreach ($mainQuestionList as $question) {
/*if ($hideDoubles) {
if (in_array($question['question'], $questionAdded)) {
continue;
@ -762,8 +754,7 @@ if (is_array($mainQuestionList)) {
$answerType,
$session_id,
$exerciseId
).
"&nbsp;".
)."&nbsp;".
get_action_icon_for_question(
$actionIcon2,
$fromExercise,
@ -795,10 +786,10 @@ if (!$nbrQuestions) {
Display::display_footer();
/**
* Put the menu entry for level and type to default "Choice"
* It is useful if you change the exercise, you need to reset the other menus
* @author hubert.borderiou 13-10-2011
*/
* Put the menu entry for level and type to default "Choice"
* It is useful if you change the exercise, you need to reset the other menus
* @author hubert.borderiou 13-10-2011
*/
function reset_menu_lvl_type()
{
global $exerciseLevel, $answerType;
@ -807,10 +798,10 @@ function reset_menu_lvl_type()
}
/**
* Put the menu entry for exercise and level and type to default "Choice"
* It is useful if you change the course, you need to reset the other menus
* @author hubert.borderiou 13-10-2011
*/
* Put the menu entry for exercise and level and type to default "Choice"
* It is useful if you change the course, you need to reset the other menus
* @author hubert.borderiou 13-10-2011
*/
function reset_menu_exo_lvl_type()
{
global $exerciseId, $courseCategoryId;
@ -881,12 +872,12 @@ function get_action_icon_for_question(
$res = "";
$getParams = "&selected_course=$in_selected_course&courseCategoryId=$in_courseCategoryId&exerciseId=$in_exercise_id&exerciseLevel=$in_exerciseLevel&answerType=$in_answerType&session_id=$in_session_id";
switch ($in_action) {
case "delete" :
case "delete":
$res = "<a href='".api_get_self()."?".api_get_cidreq().$getParams."&delete=$in_questionid' onclick='return confirm_your_choice()'>";
$res .= Display::return_icon("delete.png", get_lang('Delete'));
$res .= "</a>";
break;
case "edit" :
case "edit":
$res = get_a_tag_for_question(
1,
$from_exercise,

@ -629,6 +629,7 @@ class Display
* @param char $selected_letter The letter that should be selected
* @todo This is English language specific implementation.
* It should be adapted for the other languages.
* @return string
*/
public static function get_alphabet_options($selected_letter = '')
{
@ -804,6 +805,7 @@ class Display
* @param string $alt_text the alt text (probably a language variable)
* @param array $additional_attributes (for instance height, width, onclick, ...)
* @param boolean $filterPath Optional. Whether filter the image path. Default is true
* @return string
* @author Julio Montoya 2010
*/
public static function img($image_path, $alt_text = '', $additional_attributes = null, $filterPath = true)
@ -849,6 +851,8 @@ class Display
* @param string $tag the tag name
* @param string $content the tag's content
* @param array $additional_attributes (for instance height, width, onclick, ...)
*
* @return string
* @author Julio Montoya 2010
*/
public static function tag($tag, $content, $additional_attributes = array())
@ -910,7 +914,6 @@ class Display
/**
* Displays an HTML input tag
*
*/
public static function input($type, $name, $value, $attributes = array())
{
@ -2060,7 +2063,6 @@ class Display
}
/**
*
* @param int $nextValue
* @param array $list
* @param int $current

@ -1428,7 +1428,6 @@ class DocumentManager
$www = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document';
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$id = intval($id);
$sessionCondition = api_get_session_condition($session_id, true, true);
$sql = "SELECT * FROM $TABLE_DOCUMENT
@ -1512,8 +1511,14 @@ class DocumentManager
* @param int $user_id
* @return bool
*/
public static function set_document_as_template($title, $description, $document_id_for_template, $course_code, $user_id, $image)
{
public static function set_document_as_template(
$title,
$description,
$document_id_for_template,
$course_code,
$user_id,
$image
) {
// Database table definition
$table_template = Database::get_main_table(TABLE_MAIN_TEMPLATES);
$params = [
@ -1565,7 +1570,7 @@ class DocumentManager
* Return true if the documentpath have visibility=1 as
* item_property (you should use the is_visible_by_id)
*
* @param string $document_path the relative complete path of the document
* @param string $doc_path the relative complete path of the document
* @param array $course the _course array info of the document's course
* @param int
* @param string
@ -1911,7 +1916,7 @@ class DocumentManager
$user_id = intval($user_id);
$course_info = api_get_course_info($course_id);
// Portal infor
// Portal info
$organization_name = api_get_setting('Institution');
$portal_name = api_get_setting('siteName');
@ -2306,7 +2311,12 @@ class DocumentManager
$dir = dirname($abs_path).'/';
}
$new_abs_path = realpath($dir.$second_part);
$in_files_list[] = self::get_resources_from_source_html($new_abs_path, true, TOOL_DOCUMENT, $recursivity + 1);
$in_files_list[] = self::get_resources_from_source_html(
$new_abs_path,
true,
TOOL_DOCUMENT,
$recursivity + 1
);
if (count($in_files_list) > 0) {
$files_list = array_merge($files_list, $in_files_list);
}
@ -2331,7 +2341,12 @@ class DocumentManager
if (substr($source, 0, 1) === '/') {
//link starts with a /, making it absolute (relative to DocumentRoot)
$files_list[] = array($source, 'local', 'abs');
$in_files_list[] = self::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1);
$in_files_list[] = self::get_resources_from_source_html(
$source,
true,
TOOL_DOCUMENT,
$recursivity + 1
);
if (count($in_files_list) > 0) {
$files_list = array_merge($files_list, $in_files_list);
}
@ -3368,6 +3383,7 @@ class DocumentManager
* @param bool $showInvisibleFiles
* @param bool $showOnlyFolders
* @param int $folderId
*
* @return string
*/
public static function get_document_preview(
@ -3814,7 +3830,7 @@ class DocumentManager
$onclick = '';
// if in LP, hidden folder are displayed in grey
$folder_class_hidden = "";
$folder_class_hidden = '';
if ($lp_id) {
if (isset($resource['visible']) && $resource['visible'] == 0) {
$folder_class_hidden = "doc_folder_hidden"; // in base.css
@ -4026,7 +4042,26 @@ class DocumentManager
// mime_content_type does not detect correctly some formats that are going to be supported for index, so an extensions array is used for the moment
if (empty($doc_mime)) {
$allowed_extensions = array('doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'xls', 'xlsx', 'odt', 'odp', 'ods', 'pdf', 'txt', 'rtf', 'msg', 'csv', 'html', 'htm');
$allowed_extensions = array(
'doc',
'docx',
'ppt',
'pptx',
'pps',
'ppsx',
'xls',
'xlsx',
'odt',
'odp',
'ods',
'pdf',
'txt',
'rtf',
'msg',
'csv',
'html',
'htm',
);
$extensions = preg_split("/[\/\\.]/", $doc_path);
$doc_ext = strtolower($extensions[count($extensions) - 1]);
if (in_array($doc_ext, $allowed_extensions)) {

@ -722,7 +722,11 @@ class learnpath
* @param string Learnpath description string, if provided
* @param string Type of learnpath (default = 'guess', others = 'dokeos', 'aicc',...)
* @param string Type of files origin (default = 'zip', others = 'dir','web_dir',...)
* @param string Zip file containing the learnpath or directory containing the learnpath
* @param string $zipname Zip file containing the learnpath or directory containing the learnpath
* @param string $publicated_on
* @param string $expired_on
* @param int $categoryId
* @param int $userId
* @return integer The new learnpath ID on success, 0 on failure
*/
public static function add_lp(
@ -763,14 +767,6 @@ class learnpath
$res_name = Database::query($check_name);
if (empty($publicated_on)) {
//by default the publication date is the same that the creation date
//The behaviour above was changed due BT#2800
// global $_custom;
// if (isset($_custom['lps_hidden_when_no_start_date']) && $_custom['lps_hidden_when_no_start_date']) {
// $publicated_on = null;
// } else {
// $publicated_on = null;
// }
$publicated_on = null;
} else {
$publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on));
@ -1084,7 +1080,7 @@ class learnpath
// No other LP uses that directory, delete it.
$course_rel_dir = api_get_course_path().'/scorm/'; // scorm dir web path starting from /courses
$course_scorm_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path for this course.
if ($delete == 'remove' && is_dir($course_scorm_dir.$path) and !empty ($course_scorm_dir)) {
if ($delete == 'remove' && is_dir($course_scorm_dir.$path) && !empty ($course_scorm_dir)) {
if ($this->debug > 2) {
error_log('New LP - In learnpath::delete(), found SCORM, deleting directory: '.$course_scorm_dir.$path, 0);
}
@ -1147,7 +1143,7 @@ class learnpath
error_log('New LP - In learnpath::delete_children_items('.$id.')', 0);
}
$num = 0;
if (empty ($id) || $id != strval(intval($id))) {
if (empty($id) || $id != strval(intval($id))) {
return false;
}
$lp_item = Database::get_course_table(TABLE_LP_ITEM);
@ -1177,7 +1173,7 @@ class learnpath
error_log('New LP - In learnpath::delete_item()', 0);
}
// TODO: Implement the resource removal.
if (empty ($id) || $id != strval(intval($id))) {
if (empty($id) || $id != strval(intval($id))) {
return false;
}
// First select item to get previous, next, and display order.
@ -1268,10 +1264,10 @@ class learnpath
if ($this->debug > 0) {
error_log('New LP - In learnpath::edit_item()', 0);
}
if (empty ($max_time_allowed)) {
if (empty($max_time_allowed)) {
$max_time_allowed = 0;
}
if (empty ($id) || ($id != strval(intval($id))) || empty ($title)) {
if (empty($id) || ($id != strval(intval($id))) || empty($title)) {
return false;
}
@ -1280,7 +1276,7 @@ class learnpath
$res_select = Database::query($sql_select);
$row_select = Database::fetch_array($res_select);
$audio_update_sql = '';
if (is_array($audio) && !empty ($audio['tmp_name']) && $audio['error'] === 0) {
if (is_array($audio) && !empty($audio['tmp_name']) && $audio['error'] === 0) {
// Create the audio folder if it does not exist yet.
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
if (!is_dir($filepath.'audio')) {
@ -1428,7 +1424,7 @@ class learnpath
// TODO: htmlspecialchars to be checked for encoding related problems.
// Update the current item with the new data.
$sql = "UPDATE ".$tbl_lp_item."
$sql = "UPDATE $tbl_lp_item
SET
title = '" . Database::escape_string($title)."',
description = '" . Database::escape_string($description)."',
@ -1507,7 +1503,7 @@ class learnpath
error_log('New LP - In learnpath::edit_item_prereq('.$id.','.$prerequisite_id.','.$mastery_score.','.$max_score.')', 0);
}
if (empty($id) || ($id != strval(intval($id))) || empty ($prerequisite_id)) {
if (empty($id) || ($id != strval(intval($id))) || empty($prerequisite_id)) {
return false;
}
@ -1627,7 +1623,7 @@ class learnpath
error_log('New LP - In learnpath::get_brother_items('.$id.')', 0);
}
if (empty ($id) || $id != strval(intval($id))) {
if (empty($id) || $id != strval(intval($id))) {
return array();
}
@ -4435,6 +4431,7 @@ class learnpath
/**
* Sets the encoding
* @param string New encoding
* @return bool
* TODO (as of Chamilo 1.8.8): Check in the future whether this method is needed.
*/
public function set_encoding($enc = 'UTF-8')
@ -4879,9 +4876,7 @@ class learnpath
}
$this->publicated_on = !empty($publicated_on) ? api_get_utc_datetime($publicated_on, false, true) : null;
$lp->setPublicatedOn($this->publicated_on);
$em->persist($lp);
$em->flush();
@ -6849,34 +6844,6 @@ class learnpath
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
}
}
/*// Commented the prerequisites, only visible in edit (exercise).
$return .= '<tr>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('LearnpathPrerequisites').'</label></td>';
$return .= '<td class="input"><select name="prerequisites" id="prerequisites" class="learnpath_item_form"><option value="0">'.get_lang('NoPrerequisites').'</option>';
foreach($arrHide as $key => $value){
if($key==$s_selected_position && $action == 'add'){
$return .= '<option value="'.$key.'" selected="selected">'.$value['value'].'</option>';
}
elseif($key==$id_prerequisite && $action == 'edit'){
$return .= '<option value="'.$key.'" selected="selected">'.$value['value'].'</option>';
}
else{
$return .= '<option value="'.$key.'">'.$value['value'].'</option>';
}
}
$return .= "</select></td>";
*/
/*$return .= '<tr>';
$return .= '<td class="label"><label for="maxTimeAllowed">' . get_lang('MaxTimeAllowed') . '</label></td>';
$return .= '<td class="input"><input name="maxTimeAllowed" style="width:98%;" id="maxTimeAllowed" value="' . $extra_info['max_time_allowed'] . '" /></td>';
// Remove temporarily the test description.
//$return .= '<td class="label"><label for="idDescription">'.get_lang('Description').' :</label></td>';
//$return .= '<td class="input"><textarea id="idDescription" name="description" rows="4">' . $item_description . '</textarea></td>';
$return .= '</tr>'; */
}
if ($action == 'add') {
@ -7194,7 +7161,10 @@ class learnpath
//$parent_item_id = $_SESSION['parent_item_id'];
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
if ($arrLP[$i]['item_type'] == 'dir' &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
$selectParent->addOption(
$arrLP[$i]['title'],
$arrLP[$i]['id'],
@ -7621,7 +7591,16 @@ class learnpath
$form->addElement('hidden', 'title');
}
$parent_select = $form->addElement('select', 'parent', get_lang('Parent'), '', array('id' => 'idParent', 'onchange' => "javascript: load_cbo(this.value);"));
$parent_select = $form->addElement(
'select',
'parent',
get_lang('Parent'),
'',
array(
'id' => 'idParent',
'onchange' => "javascript: load_cbo(this.value);",
)
);
foreach ($arrHide as $key => $value) {
$parent_select->addOption($value['value'], $key, 'style="padding-left:'.$value['padding'].'px;"');
@ -7843,7 +7822,10 @@ class learnpath
$return .= '</legend>';
if (isset($_GET['edit']) && $_GET['edit'] == 'true') {
$return .= Display::return_message('<strong>'.get_lang('Warning').' !</strong><br />'.get_lang('WarningEditingDocument'), false);
$return .= Display::return_message(
'<strong>'.get_lang('Warning').' !</strong><br />'.get_lang('WarningEditingDocument'),
false
);
}
$form = new FormValidator(
'form',
@ -7895,7 +7877,10 @@ class learnpath
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if ($arrLP[$i]['item_type'] == 'dir' && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
if ($arrLP[$i]['item_type'] == 'dir' &&
!in_array($arrLP[$i]['id'], $arrHide) &&
!in_array($arrLP[$i]['parent_item_id'], $arrHide)
) {
$arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title'];
$arrHide[$arrLP[$i]['id']]['padding'] = 20 + $arrLP[$i]['depth'] * 20;
if ($parent == $arrLP[$i]['id']) {
@ -8707,7 +8692,7 @@ class learnpath
/**
* Display the form to allow moving an item
* @param integer Item ID
* @param integer $item_id Item ID
* @return string HTML form
*/
public function display_move_item($item_id)
@ -8727,7 +8712,13 @@ class learnpath
case 'dir':
case 'asset':
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_item_form($row['item_type'], get_lang('MoveCurrentChapter'), 'move', $item_id, $row);
$return .= $this->display_item_form(
$row['item_type'],
get_lang('MoveCurrentChapter'),
'move',
$item_id,
$row
);
break;
case TOOL_DOCUMENT:
$return .= $this->display_manipulate($item_id, $row['item_type']);
@ -10361,7 +10352,12 @@ EOD;
$file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc);
// Try loading document from the base course.
if (empty($file_data) && !empty($sessionId)) {
$file_data = DocumentManager::get_document_data_by_id($item->path, $this->cc, false, 0);
$file_data = DocumentManager::get_document_data_by_id(
$item->path,
$this->cc,
false,
0
);
}
$file_path = api_get_path(SYS_COURSE_PATH).$course_data['path'].'/document'.$file_data['path'];
if (file_exists($file_path)) {
@ -10527,7 +10523,10 @@ EOD;
$max_order = $row_max_order->display_order;
// Get the previous item ID
$sql = "SELECT id as previous FROM $table_lp_item
WHERE c_id = $course_id AND lp_id = '".$this->lp_id."' AND display_order = '".$max_order."' ";
WHERE
c_id = $course_id AND
lp_id = '".$this->lp_id."' AND
display_order = '".$max_order."' ";
$rs_max = Database::query($sql);
$row_max = Database::fetch_object($rs_max);
@ -10556,8 +10555,15 @@ EOD;
//Course restorer
$course_restorer = new CourseRestorer($course);
$course_restorer->set_add_text_in_items(true);
$course_restorer->set_tool_copy_settings(array('learnpaths' => array('reset_dates' => true)));
$course_restorer->restore(api_get_course_id(), api_get_session_id(), false, false);
$course_restorer->set_tool_copy_settings(
array('learnpaths' => array('reset_dates' => true))
);
$course_restorer->restore(
api_get_course_id(),
api_get_session_id(),
false,
false
);
}
public function verify_document_size($s)
@ -10895,7 +10901,6 @@ EOD;
public function setCategoryId($categoryId)
{
$this->categoryId = intval($categoryId);
$courseId = api_get_course_int_id();
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
@ -10920,6 +10925,7 @@ EOD;
* Set whether this is a learning path with the possibility to subscribe
* users or not
* @param int $subscribeUsers (0 = false, 1 = true)
* @return bool
*/
public function setSubscribeUsers($value)
{
@ -11209,6 +11215,7 @@ EOD;
/**
* Get the forum for this learning path
* @param int $sessionId
* @return boolean
*/
public function getForum($sessionId = 0)
@ -11675,6 +11682,7 @@ EOD;
* @param string Course code
* @param string The tool type (using constants declared in main_api.lib.php)
* @param integer The resource ID
* @return string
*/
public static function rl_get_resource_name($course_code, $learningPathId, $id_in_path)
{

@ -78,18 +78,14 @@ class scorm extends learnpath
}
if (is_file($file) && is_readable($file) && ($xml = @file_get_contents($file))) {
// Parsing using PHP5 DOMXML methods.
if ($this->debug > 0) { error_log('In scorm::parse_manifest() - Parsing using PHP5 method', 0); }
//$this->manifest_encoding = api_detect_encoding_xml($xml); // This is the usual way for reading the encoding.
// This method reads the encoding, it tries to be correct even in cases of wrong or missing encoding declarations.
$this->manifest_encoding = self::detect_manifest_encoding($xml);
// UTF-8 is supported by DOMDocument class, this is for sure.
$xml = api_utf8_encode_xml($xml, $this->manifest_encoding);
$doc = new DOMDocument();
$res = @$doc->loadXML($xml);
if ($res === false) {
@ -213,9 +209,7 @@ class scorm extends learnpath
}
}
unset($doc);
// End parsing using PHP5 DOMXML methods.
} else {
if ($this->debug > 1) { error_log('New LP - Could not open/read file '.$file, 0); }
$this->set_error_msg("File $file could not be read");
@ -628,7 +622,6 @@ class scorm extends learnpath
if ($package_type == '') {
// && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM)
if ($this->debug > 1) { error_log('New LP - Package type is empty', 0); }
Display::addFlash(
Display::return_message(get_lang('NotScormContent'))
);
@ -665,7 +658,6 @@ class scorm extends learnpath
if (is_dir($course_sys_dir.$new_dir) ||
@mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())
) {
// PHP method - slower...
if ($this->debug >= 1) { error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0); }
$saved_dir = getcwd();
@ -840,7 +832,8 @@ class scorm extends learnpath
}
/**
* Exports the current SCORM object's files as a zip. Excerpts taken from learnpath_functions.inc.php::exportpath()
* Exports the current SCORM object's files as a zip.
* Excerpts taken from learnpath_functions.inc.php::exportpath()
* @param integer Learnpath ID (optional, taken from object context if not defined)
*/
public function export_zip($lp_id = null)
@ -877,11 +870,9 @@ class scorm extends learnpath
$zipfilename = $zipfoldername.'/'.$LPnamesafe.'.zip';
// Get a temporary dir for creating the zip file.
//error_log('New LP - cleaning dir '.$zipfoldername, 0);
my_delete($zipfoldername); // Make sure the temp dir is cleared.
mkdir($zipfoldername, api_get_permissions_for_new_directories());
//error_log('New LP - made dir '.$zipfoldername, 0);
// Create zipfile of given directory.
$zip_folder = new PclZip($zipfilename);

@ -308,7 +308,6 @@ class SurveyUtil
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
// Actions bar
@ -839,8 +838,7 @@ class SurveyUtil
// Getting the number of options per question
echo ' <tr>';
echo ' <th>';
if (
(isset($_POST['submit_question_filter']) && $_POST['submit_question_filter']) ||
if ((isset($_POST['submit_question_filter']) && $_POST['submit_question_filter']) ||
(isset($_POST['export_report']) && $_POST['export_report'])
) {
echo '<button class="cancel" type="submit" name="reset_question_filter" value="'.get_lang('ResetQuestionFilter').'">'.get_lang('ResetQuestionFilter').'</button>';
@ -1060,7 +1058,13 @@ class SurveyUtil
if ($display_extra_user_fields) {
// Show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data(intval($user), false, false, false, true);
$user_fields_values = UserManager::get_extra_user_data(
intval($user),
false,
false,
false,
true
);
foreach ($user_fields_values as & $value) {
echo '<td align="center">'.$value.'</td>';
}
@ -1080,18 +1084,16 @@ class SurveyUtil
echo $answers_of_user[$question_id][$option_id]['value'];
echo "</td>";
}
}
else {
} else {
echo '<td align="center">';
if (!empty($answers_of_user[$question_id][$option_id])) {
if ($answers_of_user[$question_id][$option_id]['value'] != 0) {
echo $answers_of_user[$question_id][$option_id]['value'];
}
else {
} else {
echo 'v';
}
}
} // </hub>
}
}
}
}
@ -1820,9 +1822,8 @@ class SurveyUtil
}
$tableHtml .= '</tr>';
}
}
} else {
// The Y axis is NOT a score question type so the number of rows = the number of options
else {
$tableHtml .= '<tr>';
for ($ii = 0; $ii <= count($question_x['answers']); $ii++) {
if ($question_x['type'] == 'score') {
@ -2106,7 +2107,6 @@ class SurveyUtil
$counter = 0; // Nr of invitations "sent" (if sendmail option)
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
$result = CourseManager::separateUsersGroups($users_array);
$groupList = $result['groups'];
@ -2156,7 +2156,6 @@ class SurveyUtil
$new_user = false; // User not already invited
// Store the invitation if user_id not in $already_invited['course_users'] OR email is not in $already_invited['additional_users']
$addit_users_array = isset($already_invited['additional_users']) && !empty($already_invited['additional_users']) ? explode(';', $already_invited['additional_users']) : array();
$my_alredy_invited = $already_invited['course_users'] == null ? array() : $already_invited['course_users'];
if ((is_numeric($value) && !in_array($value, $my_alredy_invited)) ||
(!is_numeric($value) && !in_array($value, $addit_users_array))
@ -2205,7 +2204,6 @@ class SurveyUtil
) {
$insertId = Database::insert($table, $params);
if ($insertId) {
$sql = "UPDATE $table SET survey_invitation_id = $insertId
WHERE iid = $insertId";
Database::query($sql);
@ -2736,6 +2734,7 @@ class SurveyUtil
FROM ".$table_survey.' '.$search_restriction;
$res = Database::query($sql);
$obj = Database::fetch_object($res);
return $obj->total_number_of_items;
}

Loading…
Cancel
Save