Minor - format code.

1.10.x
Julio Montoya 10 years ago
parent 0682cb6f49
commit a57b60d384
  1. 44
      main/newscorm/learnpath.class.php
  2. 37
      main/newscorm/learnpathItem.class.php
  3. 17
      main/newscorm/lp_edit_item_prereq.php

@ -4,6 +4,7 @@
use \ChamiloSession as Session; use \ChamiloSession as Session;
/** /**
* Class learnpath
* This class defines the parent attributes and methods for Chamilo learnpaths * This class defines the parent attributes and methods for Chamilo learnpaths
* and SCORM learnpaths. It is used by the scorm class. * and SCORM learnpaths. It is used by the scorm class.
* *
@ -1430,11 +1431,11 @@ class learnpath
/** /**
* Updates an item's prereq in place * Updates an item's prereq in place
* @param integer Element ID * @param integer $id Element ID
* @param string Prerequisite Element ID * @param string $prerequisite_id Prerequisite Element ID
* @param string Prerequisite item type * @param string $mastery_score Prerequisite min score
* @param string Prerequisite min score * @param string $max_score Prerequisite max score
* @param string Prerequisite max score *
* @return boolean True on success, false on error * @return boolean True on success, false on error
*/ */
public function edit_item_prereq($id, $prerequisite_id, $mastery_score = 0, $max_score = 100) public function edit_item_prereq($id, $prerequisite_id, $mastery_score = 0, $max_score = 100)
@ -1473,10 +1474,11 @@ class learnpath
Database::query($sql); Database::query($sql);
if ($prerequisite_id != 'NULL' && $prerequisite_id != '') { if ($prerequisite_id != 'NULL' && $prerequisite_id != '') {
$sql = " UPDATE " . $tbl_lp_item . " SET // Will this be enough to ensure unicity?
mastery_score = " . $mastery_score . $sql = " UPDATE $tbl_lp_item
//", max_score = " . $max_score . " " . // Max score cannot be changed in the form anyway - see display_item_prerequisites_form(). SET mastery_score = $mastery_score
" WHERE c_id = ".$course_id." AND ref = '" . $prerequisite_id . "'"; // Will this be enough to ensure unicity? WHERE c_id = $course_id AND ref = '$prerequisite_id'";
Database::query($sql); Database::query($sql);
} }
// TODO: Update the item object (can be ignored for now because refreshed). // 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])) { if (!is_object($this->items[$item_id])) {
return false; return false;
} }
/** @var learnpathItem $oItem */
$oItem = $this->items[$item_id]; $oItem = $this->items[$item_id];
$prereq = $oItem->get_prereq_string(); $prereq = $oItem->get_prereq_string();
@ -8235,7 +8238,8 @@ class learnpath
$tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM);
$item_id = intval($item_id); $item_id = intval($item_id);
/* Current prerequisite */ /* 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); $result = Database::query($sql);
$row = Database::fetch_array($result); $row = Database::fetch_array($result);
$preq_id = $row['prerequisite']; $preq_id = $row['prerequisite'];
@ -8246,8 +8250,8 @@ class learnpath
$return .= '<table class="data_table">'; $return .= '<table class="data_table">';
$return .= '<tr>'; $return .= '<tr>';
$return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>'; $return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Minimum') . '</th>'; $return .= '<th width="70" >' . get_lang('Minimum') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Maximum') . '</th>'; $return .= '<th width="70">' . get_lang('Maximum') . '</th>';
$return .= '</tr>'; $return .= '</tr>';
// Adding the none option to the prerequisites see http://www.chamilo.org/es/node/146 // Adding the none option to the prerequisites see http://www.chamilo.org/es/node/146
@ -8257,7 +8261,8 @@ class learnpath
$return .= '<label for="idNone">' . get_lang('None') . '</label>'; $return .= '<label for="idNone">' . get_lang('None') . '</label>';
$return .= '</tr>'; $return .= '</tr>';
$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); $result = Database::query($sql);
$arrLP = array (); $arrLP = array ();
while ($row = Database :: fetch_array($result)) { while ($row = Database :: fetch_array($result)) {
@ -8288,13 +8293,15 @@ class learnpath
unset($this->arrMenu); unset($this->arrMenu);
for ($i = 0; $i < count($arrLP); $i++) { for ($i = 0; $i < count($arrLP); $i++) {
if ($arrLP[$i]['id'] == $item_id) if ($arrLP[$i]['id'] == $item_id) {
break; break;
}
$return .= '<tr>'; $return .= '<tr>';
$return .= '<td class="radio"' . (($arrLP[$i]['item_type'] != TOOL_QUIZ && $arrLP[$i]['item_type'] != TOOL_HOTPOTATOES) ? ' colspan="3"' : '') . '>'; $return .= '<td class="radio"' . (($arrLP[$i]['item_type'] != TOOL_QUIZ && $arrLP[$i]['item_type'] != TOOL_HOTPOTATOES) ? ' colspan="3"' : '') . '>';
$return .= '<label for="id' . $arrLP[$i]['id'] . '">'; $return .= '<label for="id' . $arrLP[$i]['id'] . '">';
$return .= '<input' . (($arrLP[$i]['id'] == $preq_id) ? ' checked="checked" ' : '') . (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter') ? ' disabled="disabled" ' : ' ') . 'id="id' . $arrLP[$i]['id'] . '" name="prerequisites" style="margin-left:' . $arrLP[$i]['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $arrLP[$i]['id'] . '" />'; $return .= '<input' . (($arrLP[$i]['id'] == $preq_id) ? ' checked="checked" ' : '') . (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter') ? ' disabled="disabled" ' : ' ') . 'id="id' . $arrLP[$i]['id'] . '" name="prerequisites" style="margin-left:' . $arrLP[$i]['depth'] * 10 . 'px; margin-right:10px;" type="radio" value="' . $arrLP[$i]['id'] . '" />';
$icon_name = str_replace(' ', '', $arrLP[$i]['item_type']); $icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
if (file_exists('../img/lp_' . $icon_name . '.png')) { if (file_exists('../img/lp_' . $icon_name . '.png')) {
$return .= '<img alt="" src="../img/lp_' . $icon_name . '.png" style="margin-right:5px;" title="" />'; $return .= '<img alt="" src="../img/lp_' . $icon_name . '.png" style="margin-right:5px;" title="" />';
} else { } else {
@ -8307,7 +8314,6 @@ class learnpath
$return .= $arrLP[$i]['title'] . '</label>'; $return .= $arrLP[$i]['title'] . '</label>';
$return .= '</td>'; $return .= '</td>';
if ($arrLP[$i]['item_type'] == TOOL_QUIZ) { if ($arrLP[$i]['item_type'] == TOOL_QUIZ) {
// lets update max_score Quiz information depending of the Quiz Advanced properties // lets update max_score Quiz information depending of the Quiz Advanced properties
$tmp_obj_lp_item = new LpItem($course_id, $arrLP[$i]['id']); $tmp_obj_lp_item = new LpItem($course_id, $arrLP[$i]['id']);
@ -8317,19 +8323,19 @@ class learnpath
$tmp_obj_lp_item->update_in_bdd(); $tmp_obj_lp_item->update_in_bdd();
$arrLP[$i]['max_score'] = $tmp_obj_lp_item->max_score; $arrLP[$i]['max_score'] = $tmp_obj_lp_item->max_score;
$return .= '<td class="exercise" style="border:1px solid #ccc;">'; $return .= '<td class="exercise">';
$return .= '<center><input size="4" maxlength="3" name="min_' . $arrLP[$i]['id'] . '" type="text" value="' . (($arrLP[$i]['id'] == $preq_id) ? $preq_mastery : 0) . '" /></center>'; $return .= '<center><input size="4" maxlength="3" name="min_' . $arrLP[$i]['id'] . '" type="text" value="' . (($arrLP[$i]['id'] == $preq_id) ? $preq_mastery : 0) . '" /></center>';
$return .= '</td>'; $return .= '</td>';
$return .= '<td class="exercise" style="border:1px solid #ccc;">'; $return .= '<td class="exercise">';
$return .= '<center><input size="4" maxlength="3" name="max_' . $arrLP[$i]['id'] . '" type="text" value="' . $arrLP[$i]['max_score'] . '" disabled="true" /></center>'; $return .= '<center><input size="4" maxlength="3" name="max_' . $arrLP[$i]['id'] . '" type="text" value="' . $arrLP[$i]['max_score'] . '" disabled="true" /></center>';
$return .= '</td>'; $return .= '</td>';
} }
if ($arrLP[$i]['item_type'] == TOOL_HOTPOTATOES) { if ($arrLP[$i]['item_type'] == TOOL_HOTPOTATOES) {
$return .= '<td class="exercise" style="border:1px solid #ccc;">'; $return .= '<td class="exercise">';
$return .= '<center><input size="4" maxlength="3" name="min_' . $arrLP[$i]['id'] . '" type="text" value="' . (($arrLP[$i]['id'] == $preq_id) ? $preq_mastery : 0) . '" /></center>'; $return .= '<center><input size="4" maxlength="3" name="min_' . $arrLP[$i]['id'] . '" type="text" value="' . (($arrLP[$i]['id'] == $preq_id) ? $preq_mastery : 0) . '" /></center>';
$return .= '</td>'; $return .= '</td>';
$return .= '<td class="exercise" style="border:1px solid #ccc;">'; $return .= '<td class="exercise"">';
$return .= '<center><input size="4" maxlength="3" name="max_' . $arrLP[$i]['id'] . '" type="text" value="' . $arrLP[$i]['max_score'] . '" disabled="true" /></center>'; $return .= '<center><input size="4" maxlength="3" name="max_' . $arrLP[$i]['id'] . '" type="text" value="' . $arrLP[$i]['max_score'] . '" disabled="true" /></center>';
$return .= '</td>'; $return .= '</td>';
} }

@ -2512,10 +2512,12 @@ class learnpathItem
//AND origin_lp_item_id = '.$user_id.' //AND origin_lp_item_id = '.$user_id.'
$sql = 'SELECT exe_result, exe_weighting $sql = 'SELECT exe_result, exe_weighting
FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . ' FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
WHERE exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' WHERE
AND exe_user_id = ' . $user_id . ' exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . ' exe_user_id = ' . $user_id . ' AND
AND status <> "incomplete" orig_lp_id = ' . $this->lp_id . ' AND
orig_lp_item_id = ' . $prereqs_string . ' AND
status <> "incomplete"
ORDER BY exe_date DESC ORDER BY exe_date DESC
LIMIT 0, 1'; LIMIT 0, 1';
$rs_quiz = Database::query($sql); $rs_quiz = Database::query($sql);
@ -2535,17 +2537,17 @@ class learnpathItem
$returnstatus = false; $returnstatus = false;
} }
} }
} else { } else {
// 3. for multiple attempts we check that there are minimun 1 item completed. // 3. for multiple attempts we check that there are minimun 1 item completed.
// Checking in the database. // Checking in the database.
$sql = 'SELECT exe_result, exe_weighting $sql = 'SELECT exe_result, exe_weighting
FROM ' . Database :: get_main_table( FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
TABLE_STATISTIC_TRACK_E_EXERCISES WHERE
) . ' exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
WHERE exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' exe_user_id = ' . $user_id . ' AND
AND exe_user_id = ' . $user_id . ' AND orig_lp_id = ' . $this->lp_id . ' AND orig_lp_item_id = ' . $prereqs_string . ' '; 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); //error_log('results 2:'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
$rs_quiz = Database::query($sql); $rs_quiz = Database::query($sql);
@ -2600,7 +2602,11 @@ class learnpathItem
); );
$sql = 'SELECT id FROM ' . $lp_view . ' $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); $rs_lp = Database::query($sql);
$lp_id = Database :: fetch_row( $lp_id = Database :: fetch_row(
$rs_lp $rs_lp
@ -2608,7 +2614,11 @@ class learnpathItem
$my_lp_id = $lp_id[0]; $my_lp_id = $lp_id[0];
$sql = 'SELECT status FROM ' . $lp_item_view . ' $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); $rs_lp = Database::query($sql);
$status_array = Database :: fetch_row( $status_array = Database :: fetch_row(
$rs_lp $rs_lp
@ -2711,15 +2721,18 @@ class learnpathItem
} }
} }
} }
if (empty($this->prereq_alert)) { if (empty($this->prereq_alert)) {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted'); $this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
} }
if (self::debug > 1) { if (self::debug > 1) {
error_log( error_log(
'New LP - End of parse_prereq. Error code is now ' . $this->prereq_alert, 'New LP - End of parse_prereq. Error code is now ' . $this->prereq_alert,
0 0
); );
} }
return false; return false;
} }

@ -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. // Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' and $type == 'learnpathitem') { if ($action == 'add' and $type == 'learnpathitem') {
$htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>"; $htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
} }
if ((!$is_allowed_to_edit) || ($isStudentView)) { if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_edit_item_prereq.php'); 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. // Theme calls.
$show_learn_path = true; $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'); Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
$suredel = trim(get_lang('AreYouSureToDelete')); $suredel = trim(get_lang('AreYouSureToDelete'));
?> ?>
<script> <script>
/* <![CDATA[ */
function stripslashes(str) { function stripslashes(str) {
str=str.replace(/\\'/g,'\''); str=str.replace(/\\'/g,'\'');
str=str.replace(/\\"/g,'"'); str=str.replace(/\\"/g,'"');
@ -97,19 +98,19 @@ $suredel = trim(get_lang('AreYouSureToDelete'));
/* DISPLAY SECTION */ /* DISPLAY SECTION */
echo $_SESSION['oLP']->build_action_menu(); echo $lp->build_action_menu();
echo '<div class="row-fluid">'; echo '<div class="row-fluid">';
echo '<div class="span3">'; echo '<div class="span3">';
echo $_SESSION['oLP']->return_new_tree(); echo $lp->return_new_tree();
echo '</div>'; echo '</div>';
echo '<div class="span9">'; echo '<div class="span9">';
if (isset($is_success) && $is_success == true) { if (isset($is_success) && $is_success == true) {
echo $_SESSION['oLP']->display_manipulate($_GET['id'], null); echo $lp->display_manipulate($_GET['id'], null);
echo Display::return_message(get_lang("PrerequisitesAdded")); echo Display::return_message(get_lang("PrerequisitesAdded"));
} else { } else {
echo $_SESSION['oLP']->display_manipulate($_GET['id'], null); echo $lp->display_manipulate($_GET['id'], null);
echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']); echo $lp->display_item_prerequisites_form($_GET['id']);
} }
echo '</div>'; echo '</div>';

Loading…
Cancel
Save