From 19c84539099df16feee0aca3362b99bc064cf847 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 7 Feb 2014 14:57:41 +0100 Subject: [PATCH] Using Display::return_icon + removing SQMSESSID calls. --- main/newscorm/learnpath_functions.inc.php | 195 +++++++++++----------- 1 file changed, 94 insertions(+), 101 deletions(-) diff --git a/main/newscorm/learnpath_functions.inc.php b/main/newscorm/learnpath_functions.inc.php index b82fdf6029..515e8b39b7 100644 --- a/main/newscorm/learnpath_functions.inc.php +++ b/main/newscorm/learnpath_functions.inc.php @@ -23,8 +23,6 @@ * @todo rewrite functions to comply with phpDocumentor * @todo remove code duplication */ - - use \ChamiloSession as Session; /** @@ -34,9 +32,7 @@ use \ChamiloSession as Session; */ function deleteitem($id) { - $course_id = api_get_course_int_id(); - $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM); $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER); // Get the display order for this item before it is deleted. @@ -102,17 +98,16 @@ function deletemodule($parent_item_id) // Delete the chapter itself. $sql = "DELETE FROM $tbl_learnpath_chapter WHERE c_id = $course_id AND (id=$parent_item_id and lp_id=$learnpath_id)"; - $result = Database::query($sql); + Database::query($sql); // Delete items from that chapter. $sql2 = "DELETE FROM $tbl_learnpath_item WHERE c_id = $course_id AND parent_item_id=$parent_item_id"; - $result = Database::query($sql2); + Database::query($sql2); // Update all other chapters accordingly. $sql = "UPDATE $tbl_learnpath_item SET display_order = display_order-1 WHERE c_id = $course_id AND display_order > $display_order AND parent_item_id = $parent_id"; - $result = Database::query($sql); + Database::query($sql); $sql = "UPDATE $tbl_learnpath_chapter SET display_order = display_order-1 WHERE c_id = $course_id AND display_order > $display_order AND parent_item_id = $parent_id"; - $result = Database::query($sql); - + Database::query($sql); return true; } @@ -131,7 +126,7 @@ function deletepath($path_id) $course_id = api_get_course_int_id(); $sql = "DELETE FROM $tbl_learnpath_main WHERE c_id = $course_id AND lp_id='$path_id'"; - $result = Database::query($sql); + Database::query($sql); //@TODO check how this function is used before uncommenting the following //also delete all elements inside that path @@ -349,8 +344,6 @@ function array_learnpath_categories() while ($row = Database::fetch_array($result)) { $array_learnpath_categories[] = array($row['id'], $row['chapter_name']); } - - //$array_learnpath_categories = array($array_learnpath_categories_name, $array_learnpath_categories_id); return $array_learnpath_categories; } @@ -398,14 +391,16 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array(), $level // do not diplay useless information //echo " $lg_nochapters"; } else { - echo "  $lg_title_and_desc \n"."  $lg_add_learnpath_item \n"; + echo " +  $lg_title_and_desc +  $lg_add_learnpath_item "; if (is_prereq($learnpath_id)) { - echo "  $lg_prerequisites_limit \n"; + echo " $lg_prerequisites_limit "; } else { - echo "  $lg_prerequisites \n"; + echo " $lg_prerequisites "; } - - echo "  $lg_change_order  $lg_add_prereqi \n"."  $lg_add_title_and_desc  $lg_delete \n"." \n"; + echo " $lg_change_order  $lg_add_prereqi +  $lg_add_title_and_desc  $lg_delete "; } } @@ -428,67 +423,67 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array(), $level $oddclass = 'row_even'; } - //echo ''."\n".' '.str_repeat(" >", $level)."folder ".$row['title'].""."
 ".str_repeat("   ", $level)."\n".' \n"." '."\n".' '.str_repeat( - " >", - $level - )."folder ".$row['title'].""."
 ".str_repeat( - "   ", - $level - )."\n".' \n"." + '.str_repeat(" >", $level ). + Display::return_icon('documents.gif').' + +  '.$row['title'].' + +
+
 '.str_repeat("   ", $level).' + + + '.Display::return_icon('0.gif', $lg_add_learnpath_item).' + + ".$row['prerequisite']."\n"; + echo ">".$row['prerequisite'].""; // Showing the edit, delete and move icons. if (api_is_allowed_to_edit()) { $myaction = 'move_item'; if ($i < $num_modules) { // If we are still under the number of chapters in this section, show "move down". - //echo " "."".""."\n"; - echo " "."".""."\n"; + echo ' + + '.Display::return_icon('down.gif', $lg_move_down).' + + '; } else { - echo '  '."\n"; + echo ' '; } if ($i > 1) { - //echo ' '.""."".""."\n"; - echo ' '.""."".""."\n"; + echo ' + + '.Display::return_icon('up.gif', $lg_move_up).' + '; } else { - echo '  '."\n"; + echo ' '; } - echo "  \n"; - //echo " ".""."".""."\n"; - echo " ".""."".""."\n"; - - //echo " ".""."".""."\n"; - echo " ".""."".""."\n"; + echo " "; + echo ' + + '.Display::return_icon('edit.gif', $lg_edit_learnpath_module).' + + '; + echo ' + + '.Display::return_icon('delete.gif', $lg_delete_learnpath_module).' + '; } - - echo "\n"; + echo ""; $i++; - $xml_output .= ""; - - //display_learnpath_items($row['id']); display_learnpath_chapters($row['id'], $tree, $level + 1); - $xml_output .= ""; $xml_output .= ""; - - } else //if //($row['item_type'] === 'item') - { + } else { $row_items = $row; - echo "\n "; - //require 'resourcelinker.inc.php'; + echo ""; display_addedresource_link_in_learnpath( $row_items['item_type'], $row_items['ref'], @@ -515,8 +510,6 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array(), $level if ($row_items['prerequisite'] != '') { $prereq = $row_items['prerequisite']; - - //if ($row_items['prereq_type'] == 'i') { // item $sql_items2 = "SELECT * FROM $tbl_lp_item WHERE id='$prereq'"; // Check if prereq has been deleted. $result_items2 = Database::query($sql_items2); @@ -557,31 +550,38 @@ function display_learnpath_chapters($parent_item_id = 0, $tree = array(), $level // Move if ($i < $num_modules) { - echo ""."".""."".""; + echo "". + " + ".Display::return_icon('down.gif', $lg_move_down)." + "; } else { echo " "; } if ($i > 1) { - echo "".""."".""; + echo ""." + ".Display::return_icon('up.gif', $lg_move_up)." + "; } else { echo " "; } - echo "".""; + echo ""; // Edit prereq - echo "".""."".""; - + echo " + ".Display::return_icon('scormpre.gif', $lg_add_prereq)." + "; // Edit - echo "".""."".""; + echo " + + ".Display::return_icon('edit.gif', $lg_edit_learnpath_item)." + "; // Delete - echo ""."".""; + echo " + + ".Display::return_icon('delete.gif', $lg_delete_learnpath_item, array('onclick' => "javascript: return confirmation('".$row_items['item_type']."')"))." + "; } $i++; echo ""; @@ -675,32 +675,39 @@ function display_learnpath_items($categoryid) // Move if ($i < $number_items) { - echo ""; + echo " + ".Display::return_icon('down.gif', $lg_move_down)." + "; } else { echo " "; } if ($i > 1) { - echo ""; + echo " + + ".Display::return_icon('up.gif', $lg_move_up)." + "; } else { echo " "; } echo ""; // Edit prereq - echo ""; + echo " + ".Display::return_icon('scormpre.gif', $lg_add_prereq)." + "; // Edit - echo ""; + echo " + + ".Display::return_icon('edit.gif', $lg_edit_learnpath_item)." + "; // Delete echo ""; - echo ""; + echo " + ".Display::return_icon('delete.gif', $lg_delete_learnpath_item, array('onclick' => "javascript: return confirmation('".$langThisItem."');"))." + "; } $i++; echo ""; @@ -932,15 +939,7 @@ function prereqcheck($id_in_path) */ function get_learnpath_tree($learnpath_id) { - //error_log('New LP - In learnpath_functions::get_learnpath_tree', 0); - // Init elems - //global $tbl_learnpath_item, $tbl_learnpath_chapter; - /* - $tbl_learnpath_item = Database :: get_course_table(TABLE_LEARNPATH_ITEM); - $tbl_learnpath_chapter = Database :: get_course_table(TABLE_LEARNPATH_CHAPTER); - */ $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); - $tree = array(); $chapters = array(); $all_items_by_chapter = array(); @@ -1181,11 +1180,7 @@ function get_tracking_table($learnpath_id, $user_id, $parent_item_id = 0, $tree } $link = get_addedresource_link_in_learnpath($elem['item_type'], $elem['id'], $elem['item_id']); - //$link = display_addedresource_link_in_learnpath($elem['item_type'], $elem['id'], $row['status'], $elem['item_id'], 'player', 'none'); - - //$mytable .= "" echo ""."".str_repeat(" ", $level * 2 + 2); - //."hop" display_addedresource_link_in_learnpath( $elem['item_type'], $elem['ref'], @@ -1195,7 +1190,8 @@ function get_tracking_table($learnpath_id, $user_id, $parent_item_id = 0, $tree 'wrap' ); //we should also add the total score here - echo ""."
".$statusmessage."
"."".""."
".($myrow['score'] == 0 ? '-' : $myrow['score'])."
".""."\n"; + echo ""."
".$statusmessage."
+
".($myrow['score'] == 0 ? '-' : $myrow['score'])."
"; $counter++; } } @@ -1344,9 +1340,9 @@ function export_exercise($item_id) $test .= "

".$exerciseTitle."

"; if (!empty ($exerciseSound)) { - $test .= ".get_lang(
-            "; + $test .= " + ".Display::return_icon('sound.gif', get_lang("Sound"))." + "; } // Writing the .js file with to check the correct answers begin. @@ -1372,7 +1368,7 @@ function export_exercise($item_id) $s = "

$exerciseDescription

- + @@ -1407,9 +1403,7 @@ function export_exercise($item_id) // Destruction of the Question object. unset ($objQuestionTmp); - $test .= ''; - break; } } @@ -1484,7 +1478,7 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false /* ]]> */

- +
'.get_lang('AlreadyAnswered').' "'.$questionName.'"
@@ -1917,10 +1911,9 @@ function exportitem($id, $item_id, $item_type, $add_scorm_communications = false $target = '_blank'; } // 3. Write the link to the export string. - $expcontent .= "$LPname"; + $expcontent .= "$LPname"; // 4. Change the element type for later changes (this is lost, however, so useless here). $item_type = 'Link'; // To put this to the filename. - //$LPname="$LPname"; // I am still not sure about Link export : to export them as files or they can appear in the TOC at once ? // To enable the second possibility, unrem the row $LPname=... break;