diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php
index 82f29fbcfb..2f97da27a6 100755
--- a/main/inc/lib/tracking.lib.php
+++ b/main/inc/lib/tracking.lib.php
@@ -185,10 +185,11 @@ class Tracking
path
FROM $TBL_LP_ITEM as i
INNER JOIN $TBL_LP_ITEM_VIEW as iv
- ON (i.id = iv.lp_item_id AND i.c_id = $course_id AND iv.c_id = $course_id)
+ ON (i.id = iv.lp_item_id AND i.c_id = iv.c_id)
INNER JOIN $TBL_LP_VIEW as v
- ON (iv.lp_view_id = v.id AND v.c_id = $course_id)
+ ON (iv.lp_view_id = v.id AND v.c_id = iv.c_id)
WHERE
+ v.c_id = $course_id AND
i.id = $my_item_id AND
i.lp_id = $lp_id AND
v.user_id = $user_id AND
@@ -1291,9 +1292,10 @@ class Tracking
$condition_user = " AND user_id = $user_id ";
}
- $sql = "SELECT SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds "
- . "FROM $tbl_track_course "
- . "WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
+ $sql = "SELECT
+ SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
+ FROM $tbl_track_course
+ WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
if ($courseId != 0) {
$sql .= "AND c_id = '$courseId' ";
@@ -1307,6 +1309,7 @@ class Tracking
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
+
return $row['nb_seconds'];
}
@@ -1597,7 +1600,8 @@ class Tracking
* @internal param \Student $mixed id
* @internal param \Course $string code
* @internal param \Exercise $int id (optional), filtered by exercise
- * @internal param \Session $int id (optional), if param $session_id is null it'll return results including sessions, 0 = session is not filtered
+ * @internal param \Session $int id (optional), if param $session_id is null
+ * it'll return results including sessions, 0 = session is not filtered
* @return string value (number %) Which represents a round integer about the score average.
*/
public static function get_avg_student_exercise_score(
@@ -1743,8 +1747,10 @@ class Tracking
* @internal param \Student $int id
* @internal param \Course $string code
* @internal param \Exercise $int id
- * @internal param \Learning $int path id (optional), for showing attempts inside a learning path $lp_id and $lp_item_id params are required.
- * @internal param \Learning $int path item id (optional), for showing attempts inside a learning path $lp_id and $lp_item_id params are required.
+ * @internal param \Learning $int path id (optional),
+ * for showing attempts inside a learning path $lp_id and $lp_item_id params are required.
+ * @internal param \Learning $int path item id (optional),
+ * for showing attempts inside a learning path $lp_id and $lp_item_id params are required.
* @return int count of attempts
*/
public static function count_student_exercise_attempts(
@@ -2456,7 +2462,8 @@ class Tracking
* @param int|array Array of user ids or an user id
* @param string Course code
* @param array List of LP ids
- * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered
+ * @param int Session id (optional), if param $session_id is null(default)
+ * it'll return results including sessions, 0 = session is not filtered
* @param bool Returns an array of the type [sum_score, num_score] if set to true
* @param bool get only the latest attempts or ALL attempts
* @return string Value (number %) Which represents a round integer explain in got in 3.
@@ -2534,7 +2541,8 @@ class Tracking
* @param int|array Student id(s)
* @param string Course code
* @param array Limit average to listed lp ids
- * @param int Session id (optional), if param $session_id is null(default) it'll return results including sessions, 0 = session is not filtered
+ * @param int Session id (optional), if param $session_id is
+ * null(default) it'll return results including sessions, 0 = session is not filtered
* @return int Total time
*/
public static function get_time_spent_in_lp($student_id, $course_code, $lp_ids = array(), $session_id = null)
@@ -2567,7 +2575,7 @@ class Tracking
// Check the real number of LPs corresponding to the filter in the
// database (and if no list was given, get them all)
- //$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table $condition_lp $condition_session");
+
$res_row_lp = Database::query("SELECT DISTINCT(id) FROM $lp_table WHERE c_id = $course_id $condition_lp");
$count_row_lp = Database::num_rows($res_row_lp);
@@ -2593,6 +2601,7 @@ class Tracking
}
}
}
+
return $total_time;
}
@@ -2660,7 +2669,7 @@ class Tracking
$tbl_session_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
- $a_students = array ();
+ $students = [];
// At first, courses where $coach_id is coach of the course //
$sql = 'SELECT session_id, c_id
@@ -2700,7 +2709,7 @@ class Tracking
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
- $a_students[$row['user_id']] = $row['user_id'];
+ $students[$row['user_id']] = $row['user_id'];
}
}
@@ -2737,17 +2746,17 @@ class Tracking
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
- $a_students[$row['user_id']] = $row['user_id'];
+ $students[$row['user_id']] = $row['user_id'];
}
- return $a_students;
+ return $students;
}
/**
* Get student followed by a coach inside a session
* @param int Session id
* @param int Coach id
- * @return array students list
+ * @return array students list
*/
public static function get_student_followed_by_coach_in_a_session($id_session, $coach_id)
{
@@ -2755,7 +2764,7 @@ class Tracking
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
- $a_students = array ();
+ $students = [];
// At first, courses where $coach_id is coach of the course //
$sql = 'SELECT c_id FROM ' . $tbl_session_course_user . '
WHERE session_id="' . $id_session . '" AND user_id=' . $coach_id.' AND status=2';
@@ -2771,7 +2780,7 @@ class Tracking
session_id = '" . $id_session . "'";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
- $a_students[$row['user_id']] = $row['user_id'];
+ $students[$row['user_id']] = $row['user_id'];
}
}
@@ -2779,6 +2788,7 @@ class Tracking
$sql = 'SELECT id_coach FROM ' . $tbl_session . '
WHERE id="' . $id_session.'" AND id_coach="' . $coach_id . '"';
$result = Database::query($sql);
+
//He is the session_coach so we select all the users in the session
if (Database::num_rows($result) > 0) {
$sql = 'SELECT DISTINCT srcru.user_id
@@ -2786,11 +2796,11 @@ class Tracking
WHERE session_id="' . $id_session . '"';
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
- $a_students[$row['user_id']] = $row['user_id'];
+ $students[$row['user_id']] = $row['user_id'];
}
}
- return $a_students;
+ return $students;
}
/**
@@ -2819,13 +2829,13 @@ class Tracking
// Then, courses where $coach_id is coach of the session
$sql = 'SELECT session_course_user.user_id
- FROM ' . $tbl_session_course_user . ' as session_course_user
- INNER JOIN ' . $tbl_session_course . ' as session_course
- ON session_course.c_id = session_course_user.c_id
- INNER JOIN ' . $tbl_session . ' as session
- ON session.id = session_course.session_id
- AND session.id_coach = ' . $coach_id . '
- WHERE user_id = ' . $student_id;
+ FROM ' . $tbl_session_course_user . ' as session_course_user
+ INNER JOIN ' . $tbl_session_course . ' as session_course
+ ON session_course.c_id = session_course_user.c_id
+ INNER JOIN ' . $tbl_session . ' as session
+ ON session.id = session_course.session_id
+ AND session.id_coach = ' . $coach_id . '
+ WHERE user_id = ' . $student_id;
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
return true;
@@ -2860,6 +2870,7 @@ class Tracking
INNER JOIN '.$tbl_course.' c
ON (c.id = sc.c_id)
WHERE user_id = ' . $coach_id.' AND status = 2';
+
if (api_is_multiple_url_enabled()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){
@@ -2982,7 +2993,11 @@ class Tracking
$sql = "
$select
(
- SELECT DISTINCT id, name, date_start, date_end
+ SELECT DISTINCT
+ id,
+ name,
+ date_start,
+ date_end
FROM $tbl_session session INNER JOIN $tbl_session_rel_access_url session_rel_url
ON (session.id = session_rel_url.session_id)
WHERE
@@ -2990,12 +3005,16 @@ class Tracking
access_url_id = $access_url_id
$keywordCondition
UNION
- SELECT DISTINCT session.id, session.name, session.date_start, session.date_end
+ SELECT DISTINCT
+ session.id,
+ session.name,
+ session.date_start,
+ session.date_end
FROM $tbl_session as session
INNER JOIN $tbl_session_course_user as session_course_user
ON session.id = session_course_user.session_id AND
- session_course_user.user_id= $coach_id AND
- session_course_user.status=2
+ session_course_user.user_id = $coach_id AND
+ session_course_user.status = 2
INNER JOIN $tbl_session_rel_access_url session_rel_url
ON (session.id = session_rel_url.session_id)
WHERE
@@ -3010,12 +3029,13 @@ class Tracking
return $row['count'];
}
+ $sessions = [];
while ($row = Database::fetch_array($rs)) {
- $a_sessions[$row["id"]] = $row;
+ $sessions[$row['id']] = $row;
}
- if (is_array($a_sessions)) {
- foreach ($a_sessions as & $session) {
+ if (!empty($sessions)) {
+ foreach ($sessions as & $session) {
if ($session['date_start'] == '0000-00-00') {
$session['status'] = get_lang('SessionActive');
}
@@ -3039,7 +3059,7 @@ class Tracking
}
}
- return $a_sessions;
+ return $sessions;
}
/**
diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php
index 141b52db91..b5b1995ae1 100755
--- a/main/newscorm/learnpath.class.php
+++ b/main/newscorm/learnpath.class.php
@@ -1,7 +1,7 @@
debug > 2) { error_log('New LP - Checking the name for new LP: '.$check_name, 0); }
$res_name = Database::query($check_name);
}
// New name does not exist yet; keep it.
@@ -972,8 +972,8 @@ class learnpath
}
$this->current_time_stop = time();
if ($this->save) {
- $learnpath_view_table = Database :: get_course_table(TABLE_LP_VIEW);
/*
+ $learnpath_view_table = Database :: get_course_table(TABLE_LP_VIEW);
$sql = "UPDATE $learnpath_view_table " .
"SET " .
"stop_time = ".$this->current_time_stop.", " .
@@ -1307,14 +1307,14 @@ class learnpath
// TODO: htmlspecialchars to be checked for encoding related problems.
if ($same_parent && $same_previous) {
// Only update title and description.
- $sql_update = " UPDATE " . $tbl_lp_item . "
- SET title = '" . Database::escape_string($title) . "',
- prerequisite = '" . $prerequisites . "',
- description = '" . Database::escape_string($description) . "'
- " . $audio_update_sql . ",
- max_time_allowed = '" . Database::escape_string($max_time_allowed) . "'
- WHERE c_id = ".$course_id." AND id = " . $id;
- Database::query($sql_update);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET title = '" . Database::escape_string($title) . "',
+ prerequisite = '" . $prerequisites . "',
+ description = '" . Database::escape_string($description) . "'
+ " . $audio_update_sql . ",
+ max_time_allowed = '" . Database::escape_string($max_time_allowed) . "'
+ WHERE c_id = ".$course_id." AND id = " . $id;
+ Database::query($sql);
} else {
$old_parent = $row_select['parent_item_id'];
$old_previous = $row_select['previous_item_id'];
@@ -1327,49 +1327,46 @@ class learnpath
/* for the next and previous item it is like the current item doesn't exist anymore */
if ($old_previous != 0) {
- $sql_update_next = "
- UPDATE " . $tbl_lp_item . "
- SET next_item_id = " . $old_next . "
- WHERE c_id = ".$course_id." AND id = " . $old_previous;
- Database::query($sql_update_next);
- //echo '
' . $sql_update_next . '
';
+ // Next
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET next_item_id = " . $old_next . "
+ WHERE c_id = ".$course_id." AND id = " . $old_previous;
+ Database::query($sql);
}
if ($old_next != 0) {
- $sql_update_previous = "
- UPDATE " . $tbl_lp_item . "
- SET previous_item_id = " . $old_previous . "
- WHERE c_id = ".$course_id." AND id = " . $old_next;
- Database::query($sql_update_previous);
+ // Previous
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET previous_item_id = " . $old_previous . "
+ WHERE c_id = ".$course_id." AND id = " . $old_next;
+ Database::query($sql);
}
// display_order - 1 for every item with a display_order bigger then the display_order of the current item.
- $sql_update_order = "
- UPDATE " . $tbl_lp_item . "
- SET display_order = display_order - 1
- WHERE
- c_id = ".$course_id." AND
- display_order > " . $old_order . " AND lp_id = " . $this->lp_id . " AND
- parent_item_id = " . $old_parent;
- Database::query($sql_update_order);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET display_order = display_order - 1
+ WHERE
+ c_id = ".$course_id." AND
+ display_order > " . $old_order . " AND
+ lp_id = " . $this->lp_id . " AND
+ parent_item_id = " . $old_parent;
+ Database::query($sql);
/* END -- virtually remove the current item id */
/* BEGIN -- update the current item id to his new location */
if ($previous == 0) {
// Select the data of the item that should come after the current item.
- $sql_select_old = "SELECT id, display_order
- FROM " . $tbl_lp_item . "
- WHERE
- c_id = ".$course_id." AND
- lp_id = " . $this->lp_id . " AND
- parent_item_id = " . $parent . " AND
- previous_item_id = " . $previous;
- $res_select_old = Database::query($sql_select_old);
+ $sql = "SELECT id, display_order
+ FROM " . $tbl_lp_item . "
+ WHERE
+ c_id = ".$course_id." AND
+ lp_id = " . $this->lp_id . " AND
+ parent_item_id = " . $parent . " AND
+ previous_item_id = " . $previous;
+ $res_select_old = Database::query($sql);
$row_select_old = Database::fetch_array($res_select_old);
- //echo '' . $sql_select_old . '
';
-
// If the new parent didn't have children before.
if (Database :: num_rows($res_select_old) == 0) {
$new_next = 0;
@@ -1380,10 +1377,10 @@ class learnpath
}
} else {
// Select the data of the item that should come before the current item.
- $sql_select_old = " SELECT next_item_id, display_order
- FROM " . $tbl_lp_item . "
- WHERE c_id = ".$course_id." AND id = " . $previous;
- $res_select_old = Database::query($sql_select_old);
+ $sql = "SELECT next_item_id, display_order
+ FROM " . $tbl_lp_item . "
+ WHERE c_id = ".$course_id." AND id = " . $previous;
+ $res_select_old = Database::query($sql);
$row_select_old = Database :: fetch_array($res_select_old);
$new_next = $row_select_old['next_item_id'];
$new_order = $row_select_old['display_order'] + 1;
@@ -1391,64 +1388,60 @@ class learnpath
// TODO: htmlspecialchars to be checked for encoding related problems.
// Update the current item with the new data.
- $sql_update = "UPDATE " . $tbl_lp_item . "
- SET
- title = '" . Database::escape_string($title) . "',
- description = '" . Database::escape_string($description) . "',
- parent_item_id = " . $parent . ",
- previous_item_id = " . $previous . ",
- next_item_id = " . $new_next . ",
- display_order = " . $new_order . "
- " . $audio_update_sql . "
- WHERE c_id = ".$course_id." AND id = " . $id;
- Database::query($sql_update);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET
+ title = '" . Database::escape_string($title) . "',
+ description = '" . Database::escape_string($description) . "',
+ parent_item_id = " . $parent . ",
+ previous_item_id = " . $previous . ",
+ next_item_id = " . $new_next . ",
+ display_order = " . $new_order . "
+ " . $audio_update_sql . "
+ WHERE c_id = ".$course_id." AND id = " . $id;
+ Database::query($sql);
if ($previous != 0) {
// Update the previous item's next_item_id.
- $sql_update_previous = "
- UPDATE " . $tbl_lp_item . "
- SET next_item_id = " . $id . "
- WHERE c_id = ".$course_id." AND id = " . $previous;
- Database::query($sql_update_previous);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET next_item_id = " . $id . "
+ WHERE c_id = ".$course_id." AND id = " . $previous;
+ Database::query($sql);
}
if ($new_next != 0) {
// Update the next item's previous_item_id.
- $sql_update_next = "
- UPDATE " . $tbl_lp_item . "
- SET previous_item_id = " . $id . "
- WHERE c_id = ".$course_id." AND id = " . $new_next;
- Database::query($sql_update_next);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET previous_item_id = " . $id . "
+ WHERE c_id = ".$course_id." AND id = " . $new_next;
+ Database::query($sql);
}
if ($old_prerequisite != $prerequisites) {
- $sql_update_next = "
- UPDATE " . $tbl_lp_item . "
- SET prerequisite = " . $prerequisites . "
- WHERE c_id = ".$course_id." AND id = " . $id;
- Database::query($sql_update_next);
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET prerequisite = " . $prerequisites . "
+ WHERE c_id = ".$course_id." AND id = " . $id;
+ Database::query($sql);
}
if ($old_max_time_allowed != $max_time_allowed) {
- $sql_update_max_time_allowed = "
- UPDATE " . $tbl_lp_item . "
- SET max_time_allowed = " . $max_time_allowed . "
- WHERE c_id = ".$course_id." AND id = " . $id;
- Database::query($sql_update_max_time_allowed);
+ // update max time allowed
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET max_time_allowed = " . $max_time_allowed . "
+ WHERE c_id = ".$course_id." AND id = " . $id;
+ Database::query($sql);
}
// Update all the items with the same or a bigger display_order than the current item.
- $sql_update_order = "
- UPDATE " . $tbl_lp_item . "
- SET display_order = display_order + 1
- WHERE
- c_id = ".$course_id." AND
- lp_id = " . $this->get_id() . " AND
- id <> " . $id . " AND
- parent_item_id = " . $parent . " AND
- display_order >= " . $new_order;
+ $sql = "UPDATE " . $tbl_lp_item . "
+ SET display_order = display_order + 1
+ WHERE
+ c_id = ".$course_id." AND
+ lp_id = " . $this->get_id() . " AND
+ id <> " . $id . " AND
+ parent_item_id = " . $parent . " AND
+ display_order >= " . $new_order;
- Database::query($sql_update_order);
+ Database::query($sql);
}
if ($row_select['item_type'] == 'link') {
@@ -2234,7 +2227,7 @@ class learnpath
WHERE
item_view.c_id = $course_id AND
item.c_id = $course_id AND
- lp_view_id = " . $view_id . " AND
+ lp_view_id = $view_id AND
status IN ('passed','completed','succeeded','browsed','failed')";
$res = Database::query($sql);
$row = Database :: fetch_array($res);
@@ -2265,7 +2258,8 @@ class learnpath
// Getting all the information about the item.
$sql = "SELECT * FROM ".$tbl_lp_item." as lp
- INNER JOIN ".$tbl_lp_item_view." as lp_view on lp.id = lp_view.lp_item_id
+ INNER JOIN ".$tbl_lp_item_view." as lp_view
+ ON lp.id = lp_view.lp_item_id
WHERE
lp.id = '".$_SESSION['oLP']->current."' AND
lp.c_id = $course_id AND
@@ -2323,6 +2317,7 @@ class learnpath
$output .= $player;
$output .= '';
}
+
return $output;
}
@@ -2668,6 +2663,7 @@ class learnpath
return '';
}
}
+
/**
* Gets the learnpath author
* @return string LP's author
@@ -2757,7 +2753,8 @@ class learnpath
$prereq = preg_replace('/[^a-zA-Z_0-9](' . $id . ')[^a-zA-Z_0-9]/', 'ITEM_' . $this->refs_list[$id], $prereq);
}
}
- error_log('New LP - In learnpath::get_scorm_prereq_string(): returning modified string: ' . $prereq, 0);
+ //error_log('New LP - In learnpath::get_scorm_prereq_string(): returning modified string: ' . $prereq, 0);
+
return $prereq;
}
}
@@ -2957,7 +2954,8 @@ class learnpath
$table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);
$course_id = intval($course_id);
$lp_iv_id = intval($lp_iv_id);
- $sql = "SELECT count(*) FROM $table WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id";
+ $sql = "SELECT count(*) FROM $table
+ WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id";
//@todo seems that this always returns 0
$res = Database::query($sql);
$num = 0;
@@ -2965,6 +2963,7 @@ class learnpath
$row = Database :: fetch_array($res);
$num = $row[0];
}
+
return $num;
}
@@ -2979,7 +2978,9 @@ class learnpath
{
$course_id = api_get_course_int_id();
$table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);
- $sql = "SELECT * FROM $table WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id ORDER BY order_id ASC";
+ $sql = "SELECT * FROM $table
+ WHERE c_id = $course_id AND lp_iv_id = $lp_iv_id
+ ORDER BY order_id ASC";
$res = Database::query($sql);
$num = Database :: num_rows($res);
$list = array();
@@ -3050,7 +3051,6 @@ class learnpath
error_log('New LP - In learnpath::get_items_details_as_js()', 0);
}
$toc = $varname.' = new Array();';
- //echo "".print_r($this->items,true)."
";
foreach ($this->ordered_items as $item_id) {
$toc.= $varname."['i$item_id'] = '".$this->items[$item_id]->get_type()."';";
}
@@ -3094,7 +3094,8 @@ class learnpath
$course_id = api_get_course_int_id();
$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = intval($lp_id);
- $sql = "SELECT lp_type FROM $tbl_lp WHERE c_id = $course_id AND id = '" . $lp_id . "'";
+ $sql = "SELECT lp_type FROM $tbl_lp
+ WHERE c_id = $course_id AND id = '" . $lp_id . "'";
$res = Database::query($sql);
if ($res === false) {
return null;
@@ -3788,7 +3789,7 @@ class learnpath
$lp = $row['lp_id'];
// Update the item (switch with previous/next one).
switch ($direction) {
- case 'up' :
+ case 'up':
if ($this->debug > 2) {
error_log('Movement up detected', 0);
}
@@ -3854,8 +3855,7 @@ class learnpath
$display = $display -1;
}
break;
-
- case 'down' :
+ case 'down':
if ($this->debug > 2) {
error_log('Movement down detected', 0);
}
@@ -3965,7 +3965,9 @@ class learnpath
{
$course_id = api_get_course_int_id();
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
- $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." ORDER BY display_order";
+ $sql = "SELECT * FROM $lp_table
+ WHERE c_id = ".$course_id."
+ ORDER BY display_order";
$res = Database::query($sql);
if ($res === false)
return false;
@@ -4170,7 +4172,8 @@ class learnpath
$course_id = api_get_course_int_id();
$tbl_lp = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = intval($lp_id);
- $sql = "SELECT * FROM $tbl_lp where c_id = ".$course_id." AND id=$lp_id";
+ $sql = "SELECT * FROM $tbl_lp
+ WHERE c_id = ".$course_id." AND id = $lp_id";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$row = Database :: fetch_array($result);
@@ -4271,10 +4274,11 @@ class learnpath
$res = Database::query($sql);
$view_id = Database::insert_id();
- $sql = "UPDATE $lp_view_table SET id = iid WHERE iid = $view_id";
- Database::query($sql);
-
if ($view_id) {
+
+ $sql = "UPDATE $lp_view_table SET id = iid WHERE iid = $view_id";
+ Database::query($sql);
+
$this->lp_view_id = $view_id;
$this->attempt = $this->attempt + 1;
} else {
@@ -4525,7 +4529,8 @@ class learnpath
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$course_id = api_get_course_int_id();
$lp_id = $this->get_id();
- $sql = "UPDATE $lp_table SET content_maker = '" . Database::escape_string($this->maker) . "'
+ $sql = "UPDATE $lp_table SET
+ content_maker = '" . Database::escape_string($this->maker) . "'
WHERE c_id = ".$course_id." AND id = '$lp_id'";
if ($this->debug > 2) {
error_log('New LP - lp updated with new content_maker : ' . $this->maker, 0);
@@ -4551,7 +4556,8 @@ class learnpath
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
$course_id = api_get_course_int_id();
- $sql = "UPDATE $lp_table SET name = '" . Database::escape_string($this->name). "'
+ $sql = "UPDATE $lp_table SET
+ name = '" . Database::escape_string($this->name). "'
WHERE c_id = ".$course_id." AND id = '$lp_id'";
if ($this->debug > 2) {
error_log('New LP - lp updated with new name : ' . $this->name, 0);
@@ -4564,7 +4570,9 @@ class learnpath
$tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST);
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
$sql = "UPDATE $tbl_tool SET name = '$this->name'
- WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
+ WHERE
+ c_id = $course_id AND
+ (link='$link' AND image='scormbuilder.gif' $session_condition)";
Database::query($sql);
return true;
} else {
@@ -4613,7 +4621,9 @@ class learnpath
while ($lp_item = Database :: fetch_array($result)) {
// Get search_did.
$tbl_se_ref = Database :: get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
- $sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d LIMIT 1';
+ $sql = 'SELECT * FROM %s
+ WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d
+ LIMIT 1';
$sql = sprintf($sql, $tbl_se_ref, $this->cc, TOOL_LEARNPATH, $lp_id, $lp_item['id']);
//echo $sql; echo '
';
@@ -4670,6 +4680,7 @@ class learnpath
error_log('New LP - lp updated with new theme : ' . $this->theme, 0);
}
Database::query($sql);
+
return true;
}
@@ -4703,7 +4714,8 @@ class learnpath
* @param string Optional string giving the new author of this learnpath
* @return bool Returns true if author's name is not empty
*/
- public function set_author($name = '') {
+ public function set_author($name = '')
+ {
$course_id = api_get_course_int_id();
if ($this->debug > 0) {
error_log('New LP - In learnpath::set_author()', 0);
@@ -4717,6 +4729,7 @@ class learnpath
error_log('New LP - lp updated with new preview author : ' . $this->author, 0);
}
Database::query($sql);
+
return true;
}
@@ -4735,12 +4748,14 @@ class learnpath
$this->hide_toc_frame = $hide;
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
- $sql = "UPDATE $lp_table SET hide_toc_frame = '" . $this->hide_toc_frame . "'
+ $sql = "UPDATE $lp_table SET
+ hide_toc_frame = '" . $this->hide_toc_frame . "'
WHERE c_id = ".$course_id." AND id = '$lp_id'";
if ($this->debug > 2) {
error_log('New LP - lp updated with new preview hide_toc_frame : ' . $this->author, 0);
}
Database::query($sql);
+
return true;
} else {
return false;
@@ -4832,6 +4847,7 @@ class learnpath
error_log('New LP - lp updated with new use_max_score : ' . $this->use_max_score, 0);
}
Database::query($sql);
+
return true;
}
@@ -4861,6 +4877,7 @@ class learnpath
error_log('New LP - lp updated with new expired_on : ' . $this->expired_on, 0);
}
Database::query($sql);
+
return true;
}
@@ -4889,6 +4906,7 @@ class learnpath
error_log('New LP - lp updated with new publicated_on : ' . $this->publicated_on, 0);
}
Database::query($sql);
+
return true;
}
@@ -5099,6 +5117,7 @@ class learnpath
WHERE c_id = ".$course_id." AND id = " . $this->get_id();
Database::query($sql);
$this->force_commit = $force_return;
+
return $force_return;
} else {
if ($this->debug > 2) {
@@ -5130,9 +5149,9 @@ class learnpath
while ($row = Database :: fetch_array($res)) {
if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
$need_fix = true;
- $sql_u = "UPDATE $lp_table SET display_order = $i
- WHERE c_id = ".$course_id." AND id = " . $row['id'];
- Database::query($sql_u);
+ $sql = "UPDATE $lp_table SET display_order = $i
+ WHERE c_id = ".$course_id." AND id = " . $row['id'];
+ Database::query($sql);
}
$i++;
}
@@ -5209,7 +5228,8 @@ class learnpath
* @return boolean
* @author ndiechburg
**/
- public function set_attempt_mode($mode) {
+ public function set_attempt_mode($mode)
+ {
$course_id = api_get_course_int_id();
switch ($mode) {
case 'seriousgame' :
@@ -5232,7 +5252,9 @@ class learnpath
$this->prevent_reinit = $prevent_reinit;
$this->seriousgame_mode = $sg_mode;
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
- $sql = "UPDATE $lp_table SET prevent_reinit = $prevent_reinit , seriousgame_mode = $sg_mode
+ $sql = "UPDATE $lp_table SET
+ prevent_reinit = $prevent_reinit ,
+ seriousgame_mode = $sg_mode
WHERE c_id = ".$course_id." AND id = " . $this->get_id();
$res = Database::query($sql);
if ($res) {
@@ -5248,7 +5270,8 @@ class learnpath
* @return boolean
* @author ndiechburg
**/
- public function switch_attempt_mode() {
+ public function switch_attempt_mode()
+ {
if ($this->debug > 0) {
error_log('New LP - In learnpath::switch_attempt_mode()', 0);
}
@@ -5275,9 +5298,11 @@ class learnpath
* but possibility to do again a completed item.
*
* @return boolean true if seriousgame_mode has been set to 1, false otherwise
+ * @deprecated seems not to be used
* @author ndiechburg
**/
- public function set_seriousgame_mode() {
+ public function set_seriousgame_mode()
+ {
$course_id = api_get_course_int_id();
if ($this->debug > 0) {
error_log('New LP - In learnpath::set_seriousgame_mode()', 0);
@@ -5317,7 +5342,8 @@ class learnpath
error_log('New LP - In learnpath::update_scorm_debug()', 0);
}
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
- $sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." AND id = " . $this->get_id();
+ $sql = "SELECT * FROM $lp_table
+ WHERE c_id = ".$course_id." AND id = " . $this->get_id();
$res = Database::query($sql);
if (Database :: num_rows($res) > 0) {
$row = Database :: fetch_array($res);
@@ -5327,7 +5353,8 @@ class learnpath
} elseif ($force == 0) {
$force = 1;
}
- $sql = "UPDATE $lp_table SET debug = $force WHERE c_id = ".$course_id." AND id = " . $this->get_id();
+ $sql = "UPDATE $lp_table SET debug = $force
+ WHERE c_id = ".$course_id." AND id = " . $this->get_id();
$res = Database::query($sql);
$this->scorm_debug = $force;
return $force;
@@ -5745,6 +5772,7 @@ class learnpath
$return .= Display::tag('li', Display::div($item['data'], array('class'=>'item_data')).$sub_list, array('id'=>$key, 'class'=>'record li_container'));
}
}
+
return $return;
}
@@ -5870,8 +5898,9 @@ class learnpath
* @param array $course
* @return bool
*/
- public static function generate_learning_path_folder($course) {
- //Creating learning_path folder
+ public static function generate_learning_path_folder($course)
+ {
+ // Creating learning_path folder
$dir = '/learning_path';
$filepath = api_get_path(SYS_COURSE_PATH).$course['path'] . '/document';
$folder = false;
@@ -5952,7 +5981,8 @@ class learnpath
* @param array $_course
* @return string
*/
- public function create_document($_course) {
+ public function create_document($_course)
+ {
$course_id = api_get_course_int_id();
global $charset;
$dir = isset ($_GET['dir']) ? $_GET['dir'] : $_POST['dir']; // Please, do not modify this dirname formatting.
@@ -6184,6 +6214,7 @@ class learnpath
$return .= '';
}
}
+
return $return;
}
@@ -6217,14 +6248,15 @@ class learnpath
break;
case TOOL_DOCUMENT :
$tbl_doc = Database :: get_course_table(TABLE_DOCUMENT);
- $sql_step = " SELECT lp.*, doc.path as dir
- FROM " . $tbl_lp_item . " as lp
- LEFT JOIN " . $tbl_doc . " as doc ON doc.id = lp.path
- WHERE
- lp.c_id = $course_id AND
- doc.c_id = $course_id AND
- lp.id = " . intval($item_id);
- $res_step = Database::query($sql_step);
+ $sql = "SELECT lp.*, doc.path as dir
+ FROM " . $tbl_lp_item . " as lp
+ LEFT JOIN " . $tbl_doc . " as doc
+ ON doc.id = lp.path
+ WHERE
+ lp.c_id = $course_id AND
+ doc.c_id = $course_id AND
+ lp.id = " . intval($item_id);
+ $res_step = Database::query($sql);
$row_step = Database :: fetch_array($res_step);
$return .= $this->display_manipulate($item_id, $row['item_type']);
$return .= $this->display_document_form('edit', $item_id, $row_step);
@@ -6274,6 +6306,7 @@ class learnpath
break;
}
}
+
return $return;
}
@@ -6309,12 +6342,14 @@ class learnpath
Display::return_icon('forum.png', get_lang('Forums'), array(), ICON_SIZE_BIG),
Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'), array(), ICON_SIZE_BIG)
);
+
echo Display::display_normal_message(get_lang('ClickOnTheLearnerViewToSeeYourLearningPath'));
$chapter = $_SESSION['oLP']->display_item_form('chapter', get_lang('EnterDataNewChapter'), 'add_item');
echo Display::tabs(
$headers,
array($documents, $exercises, $links, $works, $forums, $chapter), 'resource_tab'
);
+
return true;
}
@@ -6373,10 +6408,12 @@ class learnpath
$item_title = $extra_info['title'];
$item_description = $extra_info['description'];
} elseif (is_numeric($extra_info)) {
- $sql_quiz = "SELECT title, description FROM " . $tbl_quiz . " WHERE c_id = ".$course_id." AND id = " . $extra_info;
+ $sql = "SELECT title, description
+ FROM " . $tbl_quiz . "
+ WHERE c_id = ".$course_id." AND id = " . $extra_info;
- $result = Database::query($sql_quiz);
- $row = Database :: fetch_array($result);
+ $result = Database::query($sql);
+ $row = Database::fetch_array($result);
$item_title = $row['title'];
$item_description = $row['description'];
} else {
@@ -6392,7 +6429,8 @@ class learnpath
else
$parent = 0;
- $sql = "SELECT * FROM " . $tbl_lp_item . " WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
+ $sql = "SELECT * FROM " . $tbl_lp_item . "
+ WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
$result = Database::query($sql);
$arrLP = array ();
@@ -6459,7 +6497,6 @@ class learnpath
$arrHide = array (
$id
);
- //$parent_item_id = $_SESSION['parent_item_id'];
for ($i = 0; $i < count($arrLP); $i++) {
if ($action != 'add') {
if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) {
@@ -6576,6 +6613,7 @@ class learnpath
$return .= '';
$return .= '';
+
return $return;
}
@@ -6586,7 +6624,8 @@ class learnpath
* @param mixed Extra information - can be an array with title and description indexes
* @return string HTML structure to display the hotpotatoes addition formular
*/
- public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '') {
+ public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '')
+ {
$course_id = api_get_course_int_id();
global $charset;
$uploadPath = DIR_HOTPOTATOES; //defined in main_api
@@ -6598,14 +6637,14 @@ class learnpath
} elseif (is_numeric($extra_info)) {
$TBL_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
- $sql_hot = "SELECT * FROM " . $TBL_DOCUMENT . "
- WHERE c_id = ".$course_id." AND
- path LIKE '" . $uploadPath . "/%/%htm%' AND
- id = " . (int) $extra_info . "
- ORDER BY id ASC";
-
- $res_hot = Database::query($sql_hot);
+ $sql = "SELECT * FROM " . $TBL_DOCUMENT . "
+ WHERE
+ c_id = ".$course_id." AND
+ path LIKE '" . $uploadPath . "/%/%htm%' AND
+ id = " . (int) $extra_info . "
+ ORDER BY id ASC";
+ $res_hot = Database::query($sql);
$row = Database::fetch_array($res_hot);
$item_title = $row['title'];
@@ -6619,10 +6658,11 @@ class learnpath
$item_description = '';
}
- if ($id != 0 && is_array($extra_info))
+ if ($id != 0 && is_array($extra_info)) {
$parent = $extra_info['parent_item_id'];
- else
+ } else {
$parent = 0;
+ }
$sql = "SELECT * FROM $tbl_lp_item
WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id;
@@ -6757,6 +6797,7 @@ class learnpath
$return .= '';
$return .= '';
$return .= '';
+
return $return;
}
@@ -6776,11 +6817,11 @@ class learnpath
if ($id != 0 && is_array($extra_info)) {
$item_title = stripslashes($extra_info['title']);
} elseif (is_numeric($extra_info)) {
- $sql_forum = "SELECT forum_title as title, forum_comment as comment
- FROM " . $tbl_forum . "
- WHERE c_id = ".$course_id." AND forum_id = " . $extra_info;
+ $sql = "SELECT forum_title as title, forum_comment as comment
+ FROM " . $tbl_forum . "
+ WHERE c_id = ".$course_id." AND forum_id = " . $extra_info;
- $result = Database::query($sql_forum);
+ $result = Database::query($sql);
$row = Database :: fetch_array($result);
$item_title = $row['title'];
@@ -6792,14 +6833,16 @@ class learnpath
$legend = '