diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index b271ae0b07..93c5c4e220 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -4,6 +4,7 @@ use \ChamiloSession as Session; /** + * Class learnpath * This class defines the parent attributes and methods for Chamilo learnpaths * and SCORM learnpaths. It is used by the scorm class. * @@ -1430,11 +1431,11 @@ class learnpath /** * Updates an item's prereq in place - * @param integer Element ID - * @param string Prerequisite Element ID - * @param string Prerequisite item type - * @param string Prerequisite min score - * @param string Prerequisite max score + * @param integer $id Element ID + * @param string $prerequisite_id Prerequisite Element ID + * @param string $mastery_score Prerequisite min score + * @param string $max_score Prerequisite max score + * * @return boolean True on success, false on error */ public function edit_item_prereq($id, $prerequisite_id, $mastery_score = 0, $max_score = 100) @@ -1473,10 +1474,11 @@ class learnpath Database::query($sql); if ($prerequisite_id != 'NULL' && $prerequisite_id != '') { - $sql = " UPDATE " . $tbl_lp_item . " SET - mastery_score = " . $mastery_score . - //", max_score = " . $max_score . " " . // Max score cannot be changed in the form anyway - see display_item_prerequisites_form(). - " WHERE c_id = ".$course_id." AND ref = '" . $prerequisite_id . "'"; // Will this be enough to ensure unicity? + // Will this be enough to ensure unicity? + $sql = " UPDATE $tbl_lp_item + SET mastery_score = $mastery_score + WHERE c_id = $course_id AND ref = '$prerequisite_id'"; + Database::query($sql); } // TODO: Update the item object (can be ignored for now because refreshed). @@ -2656,6 +2658,7 @@ class learnpath if (!is_object($this->items[$item_id])) { return false; } + /** @var learnpathItem $oItem */ $oItem = $this->items[$item_id]; $prereq = $oItem->get_prereq_string(); @@ -8235,7 +8238,8 @@ class learnpath $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); $item_id = intval($item_id); /* Current prerequisite */ - $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = $course_id AND id = " . $item_id; + $sql = "SELECT * FROM $tbl_lp_item + WHERE c_id = $course_id AND id = " . $item_id; $result = Database::query($sql); $row = Database::fetch_array($result); $preq_id = $row['prerequisite']; @@ -8246,8 +8250,8 @@ class learnpath $return .= '
' . get_lang('LearnpathPrerequisites') . ' | '; - $return .= '' . get_lang('Minimum') . ' | '; - $return .= '' . get_lang('Maximum') . ' | '; + $return .= '' . get_lang('Minimum') . ' | '; + $return .= '' . get_lang('Maximum') . ' | '; $return .= '||||||
---|---|---|---|---|---|---|---|---|---|---|
'; $return .= ''; $return .= ' | '; - if ($arrLP[$i]['item_type'] == TOOL_QUIZ) { // lets update max_score Quiz information depending of the Quiz Advanced properties $tmp_obj_lp_item = new LpItem($course_id, $arrLP[$i]['id']); @@ -8317,19 +8323,19 @@ class learnpath $tmp_obj_lp_item->update_in_bdd(); $arrLP[$i]['max_score'] = $tmp_obj_lp_item->max_score; - $return .= ''; + $return .= ' | ';
$return .= ' | ';
- $return .= ''; + $return .= ' | ';
$return .= ' | ';
}
if ($arrLP[$i]['item_type'] == TOOL_HOTPOTATOES) {
- $return .= ''; + $return .= ' | ';
$return .= ' | ';
- $return .= ''; + $return .= ' | ';
$return .= ' | ';
}
diff --git a/main/newscorm/learnpathItem.class.php b/main/newscorm/learnpathItem.class.php
index 3716bec78d..c734e5b4d6 100755
--- a/main/newscorm/learnpathItem.class.php
+++ b/main/newscorm/learnpathItem.class.php
@@ -2512,12 +2512,14 @@ class learnpathItem
//AND origin_lp_item_id = '.$user_id.'
$sql = 'SELECT exe_result, exe_weighting
FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
- WHERE exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . '
- AND exe_user_id = ' . $user_id . '
- AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . '
- AND status <> "incomplete"
- ORDER BY exe_date DESC
- LIMIT 0, 1';
+ WHERE
+ exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
+ exe_user_id = ' . $user_id . ' AND
+ orig_lp_id = ' . $this->lp_id . ' AND
+ orig_lp_item_id = ' . $prereqs_string . ' AND
+ status <> "incomplete"
+ ORDER BY exe_date DESC
+ LIMIT 0, 1';
$rs_quiz = Database::query($sql);
if ($quiz = Database :: fetch_array($rs_quiz)) {
if ($quiz['exe_result'] >= $items[$refs_list[$prereqs_string]]->get_mastery_score()) {
@@ -2535,17 +2537,17 @@ class learnpathItem
$returnstatus = false;
}
}
-
} else {
// 3. for multiple attempts we check that there are minimun 1 item completed.
// Checking in the database.
$sql = 'SELECT exe_result, exe_weighting
- FROM ' . Database :: get_main_table(
- TABLE_STATISTIC_TRACK_E_EXERCISES
- ) . '
- WHERE exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . '
- AND exe_user_id = ' . $user_id . ' AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . ' ';
+ FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
+ WHERE
+ exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
+ exe_user_id = ' . $user_id . ' AND
+ orig_lp_id = ' . $this->lp_id . ' AND
+ orig_lp_item_id = ' . $prereqs_string . ' ';
//error_log('results 2:'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
$rs_quiz = Database::query($sql);
@@ -2600,7 +2602,11 @@ class learnpathItem
);
$sql = 'SELECT id FROM ' . $lp_view . '
- WHERE c_id = ' . $course_id . ' AND user_id = ' . $user_id . ' AND lp_id = ' . $this->lp_id . ' LIMIT 0, 1';
+ WHERE
+ c_id = ' . $course_id . ' AND
+ user_id = ' . $user_id . ' AND
+ lp_id = ' . $this->lp_id . '
+ LIMIT 0, 1';
$rs_lp = Database::query($sql);
$lp_id = Database :: fetch_row(
$rs_lp
@@ -2608,7 +2614,11 @@ class learnpathItem
$my_lp_id = $lp_id[0];
$sql = 'SELECT status FROM ' . $lp_item_view . '
- WHERE c_id = ' . $course_id . ' AND lp_view_id = ' . $my_lp_id . ' AND lp_item_id = ' . $refs_list[$prereqs_string] . ' LIMIT 0, 1';
+ WHERE
+ c_id = ' . $course_id . ' AND
+ lp_view_id = ' . $my_lp_id . ' AND
+ lp_item_id = ' . $refs_list[$prereqs_string] . '
+ LIMIT 0, 1';
$rs_lp = Database::query($sql);
$status_array = Database :: fetch_row(
$rs_lp
@@ -2670,11 +2680,11 @@ class learnpathItem
);
}
$orstatus = $orstatus || $this->parse_prereq(
- $condition,
- $items,
- $refs_list,
- $user_id
- );
+ $condition,
+ $items,
+ $refs_list,
+ $user_id
+ );
if ($orstatus) {
// Shortcircuit OR.
if (self::debug > 1) {
@@ -2711,15 +2721,18 @@ class learnpathItem
}
}
}
+
if (empty($this->prereq_alert)) {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
}
+
if (self::debug > 1) {
error_log(
'New LP - End of parse_prereq. Error code is now ' . $this->prereq_alert,
0
);
}
+
return false;
}
diff --git a/main/newscorm/lp_edit_item_prereq.php b/main/newscorm/lp_edit_item_prereq.php
index d549dc1cda..3341bc5175 100755
--- a/main/newscorm/lp_edit_item_prereq.php
+++ b/main/newscorm/lp_edit_item_prereq.php
@@ -38,7 +38,7 @@ $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
// Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' and $type == 'learnpathitem') {
- $htmlHeadXtra[] = "";
+ $htmlHeadXtra[] = "";
}
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_edit_item_prereq.php');
@@ -69,14 +69,15 @@ $interbreadcrumb[] = array('url' => api_get_self() . "?action=add_item&type=step
// Theme calls.
$show_learn_path = true;
-$lp_theme_css = $_SESSION['oLP']->get_theme();
+/** @var learnpath $lp */
+$lp = $_SESSION['oLP'];
+$lp_theme_css = $lp->get_theme();
Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
$suredel = trim(get_lang('AreYouSureToDelete'));
?>