Browse Source

Merge branch '1.9.x' into 7296

Imanol Losada 10 years ago
parent
commit
340144d383
64 changed files with 1315 additions and 1091 deletions
  1. 24 0
      documentation/dependencies.html
  2. 0 1
      main/css/base.css
  3. 74 58
      main/css/chamilo/scorm.css
  4. 15 19
      main/document/document.php
  5. 24 34
      main/document/edit_document.php
  6. 2 1
      main/inc/lib/social.lib.php
  7. 4 4
      main/inc/lib/specific_fields_manager.lib.php
  8. 52 48
      main/inc/lib/tracking.lib.php
  9. 9 14
      main/newscorm/aicc.class.php
  10. 8 7
      main/newscorm/aiccBlock.class.php
  11. 7 9
      main/newscorm/aiccItem.class.php
  12. 9 8
      main/newscorm/aiccObjective.class.php
  13. 3 5
      main/newscorm/aiccResource.class.php
  14. 3 3
      main/newscorm/aicc_hacp.php
  15. 283 211
      main/newscorm/learnpath.class.php
  16. 159 193
      main/newscorm/learnpathItem.class.php
  17. 1 21
      main/newscorm/lp_ajax_initialize.php
  18. 1 16
      main/newscorm/lp_ajax_last_update_status.php
  19. 2 33
      main/newscorm/lp_ajax_save_item.php
  20. 1 15
      main/newscorm/lp_ajax_save_objectives.php
  21. 1 23
      main/newscorm/lp_ajax_switch_item.php
  22. 4 18
      main/newscorm/lp_ajax_switch_item_toc.php
  23. 6 52
      main/newscorm/lp_comm.server.php
  24. 69 10
      main/newscorm/lp_controller.php
  25. 32 26
      main/newscorm/lp_list.php
  26. 3 7
      main/newscorm/lp_nav.php
  27. 1 1
      main/newscorm/lp_save.php
  28. 120 70
      main/newscorm/lp_stats.php
  29. 2 5
      main/newscorm/lp_upload.php
  30. 1 1
      main/newscorm/lp_view.php
  31. 6 6
      main/tracking/courseLogCSV.php
  32. 51 60
      main/tracking/userLog.php
  33. 13 0
      plugin/buycourses/lang/english.php
  34. 13 0
      plugin/buycourses/lang/french.php
  35. 13 0
      plugin/buycourses/lang/spanish.php
  36. 117 0
      plugin/buycourses/resources/css/style.css
  37. BIN
      plugin/buycourses/resources/img/128/accept.png
  38. BIN
      plugin/buycourses/resources/img/128/backlogs.png
  39. BIN
      plugin/buycourses/resources/img/128/buycourses.png
  40. BIN
      plugin/buycourses/resources/img/128/paymentsettings.png
  41. BIN
      plugin/buycourses/resources/img/128/settings.png
  42. BIN
      plugin/buycourses/resources/img/32/accept.png
  43. BIN
      plugin/buycourses/resources/img/32/backlogs.png
  44. BIN
      plugin/buycourses/resources/img/32/buycourses.png
  45. BIN
      plugin/buycourses/resources/img/32/delete.png
  46. BIN
      plugin/buycourses/resources/img/32/new.png
  47. BIN
      plugin/buycourses/resources/img/32/paymentsettings.png
  48. BIN
      plugin/buycourses/resources/img/32/save.png
  49. BIN
      plugin/buycourses/resources/img/32/settings.png
  50. BIN
      plugin/buycourses/resources/img/42/backlogs.png
  51. BIN
      plugin/buycourses/resources/img/42/buycourses.png
  52. BIN
      plugin/buycourses/resources/img/42/paymentsettings.png
  53. BIN
      plugin/buycourses/resources/img/42/settings.png
  54. BIN
      plugin/buycourses/resources/img/64/backlogs.png
  55. BIN
      plugin/buycourses/resources/img/64/buycourses.png
  56. BIN
      plugin/buycourses/resources/img/64/paymentsettings.png
  57. BIN
      plugin/buycourses/resources/img/64/settings.png
  58. 2 0
      plugin/buycourses/src/buy_course_plugin.class.php
  59. 2 2
      plugin/buycourses/src/configuration.php
  60. 2 2
      plugin/buycourses/src/paymentsetup.php
  61. 12 12
      plugin/buycourses/view/configuration.tpl
  62. 61 17
      plugin/buycourses/view/index.tpl
  63. 49 59
      plugin/buycourses/view/list.tpl
  64. 54 20
      plugin/buycourses/view/paymentsetup.tpl

+ 24 - 0
documentation/dependencies.html

@@ -102,6 +102,30 @@ We recommend using HTML5-compatible technology.
   <li>xajax </li>
   <li>jQuery</li>
 </ul>
+<h2>Extra features dependencies - server-side</h2>
+Chamilo LMS is a very complex software suite, and some of its components wil
+only work when some specific server-side libraries are installed. The names of
+the libraries below are taken from a Debian/Ubuntu installation, so you might
+need to adapt these if you are installing on Windows, Mac or another Linux
+distribution.<br />
+Please note that, as for the rest of free software, we are NOT giving or
+implying any warranty of any kind that this will work on your system, even on
+the intended Debian/Ubuntu systems. You should take your own precautions to
+ensure all components are installed by an expert in the field.<br />
+  <ul>
+    <li>Chamilo Rapid (ex Oogie(TM))</li>
+      <ul>
+        <li>libreoffice</li>
+      </ul>
+    <li>Audio recording</li>
+      <ul>
+        <li>libav-tools</li>
+      </ul>
+    <li>BigBlueButton videoconference</li>
+      <ul>
+        <li>bigbluebutton</li>
+      </ul>
+  </ul>
 </div>
 <hr />
     <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="margin: 1em; float: right;" height="31" width="88" /></a>

+ 0 - 1
main/css/base.css

@@ -34,7 +34,6 @@ legend {
 }
 
 #header_right #notifications li {
-    width:60px;
     text-align: right;
 }
 

+ 74 - 58
main/css/chamilo/scorm.css

@@ -106,7 +106,10 @@
     padding : 0 1.5em 0 7.5em;
 }
 
-.scorm_item.scorm_item_level_2 > a, .scorm_item.scorm_item_level_3 > a, .scorm_item.scorm_item_level_4 > a, .scorm_item.scorm_item_level_5 > a{
+.scorm_item.scorm_item_level_2 > a,
+.scorm_item.scorm_item_level_3 > a,
+.scorm_item.scorm_item_level_4 > a,
+.scorm_item.scorm_item_level_5 > a {
     font-weight: normal;
 }
 /* end of copy of default_scorm.css */
@@ -134,11 +137,10 @@
     overflow: auto;
     background-color: #D7EEF4;
     height: 210px;
-    /*padding: 10px;*/   
+    /*padding: 10px;*/
 }
 .inner_lp_toc .scorm_item_section {
     border:none;
-    background:#333;
     font-weight:normal;
     color:#fff;
     text-shadow:none;
@@ -166,14 +168,13 @@
     margin-left: 10px;
     margin-right:10px;
     text-decoration: none;
-    border-color: rgba(255, 255, 255, 0.3); 
-    
+    border-color: rgba(255, 255, 255, 0.3);
 }
+
 .inner_lp_toc .scorm_item.scorm_item_level_1{
     background: url(../img/archive.png) no-repeat;
 }
 
-
 .inner_lp_toc .scorm_title {
     font-weight: bold;
     background:#ccc;
@@ -285,10 +286,10 @@
     padding-bottom: 15px;
 }
 #learning_path_main #control {
-  opacity: 1;
+    opacity: 1;
 }
 .buttons a img:hover{
-opacity: 0.7;
+    opacity: 0.7;
 }
 #author_image{
     background-color: #d7eef4;
@@ -319,29 +320,29 @@ opacity: 0.7;
     color: #0088AA;
 }
 .progress {
-  height: 18px;
-  margin-bottom: 18px;
-  overflow: hidden;
-  background-color: #f7f7f7;
-  background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -ms-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
-  background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-image: linear-gradient(top, #f5f5f5, #f9f9f9);
-  background-repeat: repeat-x;
-  -webkit-border-radius: 4px;
+    height: 18px;
+    margin-bottom: 18px;
+    overflow: hidden;
+    background-color: #f7f7f7;
+    background-image: -moz-linear-gradient(top, #f5f5f5, #f9f9f9);
+    background-image: -ms-linear-gradient(top, #f5f5f5, #f9f9f9);
+    background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));
+    background-image: -webkit-linear-gradient(top, #f5f5f5, #f9f9f9);
+    background-image: -o-linear-gradient(top, #f5f5f5, #f9f9f9);
+    background-image: linear-gradient(top, #f5f5f5, #f9f9f9);
+    background-repeat: repeat-x;
+    -webkit-border-radius: 4px;
      -moz-border-radius: 4px;
           border-radius: 4px;
-  filter: progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);
-  -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
+    filter: progid:dximagetransform.microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);
+    -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
      -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
           box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
 }
 .progress-striped .bar {
-  background-color: #149BDF;
-  background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
-  background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+    background-color: #149BDF;
+    background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
+    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);
     -webkit-animation: progress-bar-stripes 2s linear infinite;
     animation: progress-bar-stripes 2s linear infinite;
 }
@@ -396,34 +397,49 @@ opacity: 0.7;
     background-position: 270px center !important;
     background-repeat: no-repeat;
 }
+
+.scorm_item_section.scorm_item_normal.scorm_completed {
+    background-image: url("images/blue_arrow.png") !important;
+    background-position: 270px center !important;
+    background-repeat: no-repeat;
+    background-color: #05abe0;
+}
+
+.scorm_item_section.scorm_item_normal.scorm_not_attempted {
+    background-image: none;
+    background-position: 270px center !important;
+    background-repeat: no-repeat;
+    background-color: #808080;
+}
+
 #learning_path_main #control {
-  background-image: none;
-  background-color: #d7eef4;
-  bottom: 0;
-  height: 34px;
-  margin-bottom: auto;
-  margin-left: auto;
-  margin-right: auto;
-  margin-top: auto;
-  padding-bottom: 8px;
-  padding-left: 0;
-  padding-right: 0;
-  padding-top: 8px;
-  position: absolute;
-  text-align: center;
-  width: 100%;
-  border-top:1px solid #00AAD4;
+    background-image: none;
+    background-color: #d7eef4;
+    bottom: 0;
+    height: 34px;
+    margin-bottom: auto;
+    margin-left: auto;
+    margin-right: auto;
+    margin-top: auto;
+    padding-bottom: 8px;
+    padding-left: 0;
+    padding-right: 0;
+    padding-top: 8px;
+    position: absolute;
+    text-align: center;
+    width: 100%;
+    border-top:1px solid #00AAD4;
 }
 
 #author_name {
-  color: #666666;
-  float: left;
-  font-size: 13px;
-  margin-top: 2px;
-  text-align: center;
-  width: 100%;
-  padding-top: 10px;
-  padding-bottom: 5px;
+    color: #666666;
+    float: left;
+    font-size: 13px;
+    margin-top: 2px;
+    text-align: center;
+    width: 100%;
+    padding-top: 10px;
+    padding-bottom: 5px;
 }
 .mejs-container{
     background: none;
@@ -436,19 +452,19 @@ opacity: 0.7;
     -moz-border-radius: 5px;
     border-radius: 5px;
     background: #45484d; /* Old browsers */
-background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6+ */
-background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#000000)); /* Chrome,Safari4+ */
-background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
-background: -o-linear-gradient(top, #45484d 0%,#000000 100%); /* Opera 11.10+ */
-background: -ms-linear-gradient(top, #45484d 0%,#000000 100%); /* IE10+ */
-background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C */
-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
+    background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6+ */
+    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#45484d), color-stop(100%,#000000)); /* Chrome,Safari4+ */
+    background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
+    background: -o-linear-gradient(top, #45484d 0%,#000000 100%); /* Opera 11.10+ */
+    background: -ms-linear-gradient(top, #45484d 0%,#000000 100%); /* IE10+ */
+    background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C */
+    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
 }
 .mejs-controls .mejs-time-rail .mejs-time-loaded{
     background: #333;
     background: rgba(50,50,50,0.8);
     background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(30,30,30,0.8)), to(rgba(60,60,60,0.8)));
-    background: -webkit-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8)); 
+    background: -webkit-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8));
     background: -moz-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8));
     background: -o-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8));
     background: -ms-linear-gradient(top, rgba(30,30,30,0.8), rgba(60,60,60,0.8));
@@ -463,4 +479,4 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#45484d', end
     background: -ms-linear-gradient(top, #a9e4f7 0%,#0fb4e7 100%); /* IE10+ */
     background: linear-gradient(to bottom, #a9e4f7 0%,#0fb4e7 100%); /* W3C */
     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a9e4f7', endColorstr='#0fb4e7',GradientType=0 ); /* IE6-9 */
-}
+}

+ 15 - 19
main/document/document.php

@@ -1108,30 +1108,26 @@ if ($is_allowed_to_edit ||
             $dir_name = $curdirpath.$added_slash.replace_dangerous_char($post_dir_name);
             $dir_name = disable_dangerous_file($dir_name);
             $dir_check = $base_work_dir.$dir_name;
+            $visibility = empty($groupId) ? null : 1;
 
-            if (!is_dir($dir_check)) {
-                $visibility = empty($groupId) ? null : 1;
-
-                $created_dir = create_unexisting_directory(
-                    $courseInfo,
-                    api_get_user_id(),
-                    $sessionId,
-                    $groupId,
-                    $to_user_id,
-                    $base_work_dir,
-                    $dir_name,
-                    $post_dir_name,
-                    $visibility
-                );
+            $created_dir = create_unexisting_directory(
+                $courseInfo,
+                api_get_user_id(),
+                $sessionId,
+                $groupId,
+                $to_user_id,
+                $base_work_dir,
+                $dir_name,
+                $post_dir_name,
+                $visibility
+            );
 
-                if ($created_dir) {
-                    $message = Display::return_message(get_lang('DirCr').' '.$created_dir, 'confirmation');
-                } else {
-                    $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
-                }
+            if ($created_dir) {
+                $message = Display::return_message(get_lang('DirCr').' '.$created_dir, 'confirmation');
             } else {
                 $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
             }
+
         }
         Session::write('message', $message);
     }

+ 24 - 34
main/document/edit_document.php

@@ -24,9 +24,6 @@
  * @todo improve script structure (FormValidator is used to display form, but
  * not for validation at the moment)
  */
-/**
- * Code
- */
 
 // Name of the language file that needs to be included
 $language_file = array('document', 'gradebook');
@@ -241,10 +238,10 @@ if (isset($_POST['comment'])) {
 if ($is_allowed_to_edit) {
 	if (isset($_POST['formSent']) && $_POST['formSent'] == 1) {
 
-		$filename   = stripslashes($_POST['filename']);
-        $extension  = $_POST['extension'];
-		$content    = trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content'])));
-		$content    = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
+		$filename = stripslashes($_POST['filename']);
+        $extension = $_POST['extension'];
+		$content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null;
+		$content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY);
 
 		if (!strstr($content, '/css/frames.css')) {
 			$content = str_replace('</title></head>', '</title><link rel="stylesheet" href="../css/frames.css" type="text/css" /></head>', $content);
@@ -255,7 +252,7 @@ if ($is_allowed_to_edit) {
         }
 
 		$file = $dir.'/'.$filename.'.'.$extension;
-		$read_only_flag = $_POST['readonly'];
+		$read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null;
 		$read_only_flag = empty($read_only_flag) ? 0 : 1;
 
 		if (empty($filename)) {
@@ -267,17 +264,8 @@ if ($is_allowed_to_edit) {
 			if ($read_only_flag == 0) {
 				if (!empty($content)) {
 					if ($fp = @fopen($document_data['absolute_path'], 'w')) {
-						// For flv player, change absolute paht temporarely to prevent from erasing it in the following lines
+						// For flv player, change absolute path temporarily to prevent from erasing it in the following lines
 						$content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content);
-
-						// Change the path of mp3 to absolute
-						// The first regexp deals with ../../../ urls
-						// Disabled by Ivan Tcholakov.
-						//$content = preg_replace("|(flashvars=\"file=)(\.+/)+|","$1".api_get_path(REL_COURSE_PATH).$_course['path'].'/document/',$content);
-						// The second regexp deals with audio/ urls
-						// Disabled by Ivan Tcholakov.
-						//$content = preg_replace("|(flashvars=\"file=)([^/]+)/|","$1".api_get_path(REL_COURSE_PATH).$_course['path'].'/document/$2/',$content);
-
  						fputs($fp, $content);
 						fclose($fp);
 
@@ -331,15 +319,21 @@ if ($is_allowed_to_edit) {
 }
 
 // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/')
+$content = null;
+$extension = null;
+$filename = null;
 if (file_exists($document_data['absolute_path'])) {
     $path_info = pathinfo($document_data['absolute_path']);
     $filename = $path_info['filename'];
-    $extension = $path_info['extension'];
 
-	if (in_array($extension, array('html', 'htm'))) {
-		$content = file($document_data['absolute_path']);
-		$content = implode('', $content);
-	}
+    if (is_file($document_data['absolute_path'])) {
+        $extension = $path_info['extension'];
+
+        if (in_array($extension, array('html', 'htm'))) {
+            $content = file($document_data['absolute_path']);
+            $content = implode('', $content);
+        }
+    }
 }
 
 /*	Display user interface */
@@ -365,7 +359,13 @@ $document_info  = api_get_item_property_info(api_get_course_int_id(),'document',
 $owner_id       = $document_info['insert_user_id'];
 $last_edit_date = $document_info['lastedit_date'];
 
-if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_edit || GroupManager :: is_user_in_group(api_get_user_id(), api_get_group_id() )) {
+if ($owner_id == api_get_user_id() ||
+    api_is_platform_admin() ||
+    $is_allowed_to_edit || GroupManager:: is_user_in_group(
+        api_get_user_id(),
+        api_get_group_id()
+    )
+) {
 	$action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq();
 	$form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical'));
 
@@ -470,16 +470,6 @@ if ($owner_id == api_get_user_id() || api_is_platform_admin() || $is_allowed_to_
 
 Display::display_footer();
 
-
-/* General functions */
-
-/*
-	Workhorse functions
-
-	These do the actual work that is expected from of this tool, other functions
-	are only there to support these ones.
-*/
-
 /**
 	This function changes the name of a certain file.
 	It needs no global variables, it takes all info from parameters.

+ 2 - 1
main/inc/lib/social.lib.php

@@ -622,7 +622,7 @@ class SocialManager extends UserManager
         $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : '');
         $showUserImage = user_is_online($user_id) || api_is_platform_admin();
 
-        $html = '<div class="social-menu">';
+        $html = '<div>';
         if (in_array($show, $show_groups) && !empty($group_id)) {
             //--- Group image
             $group_info = GroupPortalManager::get_group_data($group_id);
@@ -662,6 +662,7 @@ class SocialManager extends UserManager
             }
             $html .= '</div>';
         }
+        $html .= '</div>';
         return $html;
     }
 

+ 4 - 4
main/inc/lib/specific_fields_manager.lib.php

@@ -106,7 +106,7 @@ function get_specific_field_values_list($conditions = array(), $order_by = array
     $sql = "SELECT * FROM $table_sfv";
     if (count($conditions) > 0) {
         $sql .= ' WHERE ';
-        
+
         //Fixing course id
         if (isset($conditions['c_id'])) {
             $course_info = api_get_course_info_by_id($conditions['c_id']);
@@ -117,9 +117,9 @@ function get_specific_field_values_list($conditions = array(), $order_by = array
         if (!isset($conditions['course_code'])) {
             $conditions['course_code'] = " '".api_get_course_id()."' ";
         }
-        
+
         $conditions_string_array = array();
-        foreach ($conditions as $field => $value) {            
+        foreach ($conditions as $field => $value) {
             $conditions_string_array[] = $field.' = '. $value;
         }
         $sql .= implode(' AND ', $conditions_string_array);
@@ -203,7 +203,7 @@ function delete_all_values_for_item($course_id, $tool_id, $ref_id) {
   $table_sf_values = Database :: get_main_table(TABLE_MAIN_SPECIFIC_FIELD_VALUES);
   $sql = 'DELETE FROM %s WHERE course_code = \'%s\' AND tool_id = \'%s\' AND ref_id = %s';
   $sql = sprintf($sql, $table_sf_values, $course_id, $tool_id, $ref_id);
-  $result = Database::query($sql);
+  Database::query($sql);
 }
 
 /**

+ 52 - 48
main/inc/lib/tracking.lib.php

@@ -1,19 +1,14 @@
 <?php
 /* For licensing terms, see /license.txt */
-/**
- *    This is the tracking library for Chamilo
- *    Include/require it in your code to use its functionality.
- *
- *    @package chamilo.library
- *    @author Julio Montoya <gugli100@gmail.com> (Score average fixes)
- */
 
 require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
 require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
 
 /**
- * Class
- * @package chamilo.library
+ *  Class Tracking
+ *
+ *  @author  Julio Montoya <gugli100@gmail.com>
+ *  @package chamilo.library
  */
 class Tracking
 {
@@ -95,8 +90,6 @@ class Tracking
                 null,
                 null
             );
-
-            //$platformCourses = SessionManager::getAllCoursesFromAllSessionFromDrh($userId);
             $courses = array();
             foreach ($platformCourses as $course) {
                 $courses[$course['code']] = $course['code'];
@@ -303,8 +296,9 @@ class Tracking
 
     /**
      * Get first connection date for a student
-     * @param    int                  Student id
-     * @return    string|bool     Date format long without day or false if there are no connections
+     * @param    int $student_id
+     *
+     * @return    string|bool Date format long without day or false if there are no connections
      */
     public static function get_first_connection_date($student_id)
     {
@@ -319,14 +313,15 @@ class Tracking
     			return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
     		}
     	}
+
     	return false;
     }
 
     /**
      * Get las connection date for a student
-     * @param int Student id
-     * @param bool Show a warning message (optional)
-     * @param bool True for returning results in timestamp (optional)
+     * @param int $student_id
+     * @param bool $warning_message Show a warning message (optional)
+     * @param bool $return_timestamp True for returning results in timestamp (optional)
      * @return string|int|bool Date format long without day, false if there are no connections or
      * timestamp if parameter $return_timestamp is true
      */
@@ -366,7 +361,7 @@ class Tracking
 
     /**
      * Get las connection date for a student
-     * @param array Student id array
+     * @param array $studentList Student id array
      * @param int $days
      * @param bool $getCount
      * @return int
@@ -536,6 +531,7 @@ class Tracking
     		$row = Database::fetch_object($rs);
     		$count = $row->count_connections;
     	}
+
     	return $count;
     }
 
@@ -1073,12 +1069,16 @@ class Tracking
      * @todo improve performance, when loading 1500 users with 20 lps the script dies
      * This function does not take the results of a Test out of a LP
      *
-     * @param   mixed       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   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
+     * @param   mixed       $student_id Array of user ids or an user id
+     * @param   string      $course_code
+     * @param   array       $lp_ids List of LP ids
+     * @param   int         $session_id Session id (optional),
+     * if param $session_id is null(default) it'll return results
+     * including sessions, 0 = session is not filtered
+     * @param   bool        $return_array Returns an array of the
+     * type [sum_score, num_score] if set to true
+     * @param   bool        $get_only_latest_attempt_results get only the latest attempts or ALL attempts
+     *
      * @return  string      Value (number %) Which represents a round integer explain in got in 3.
      */
     public static function get_avg_student_score(
@@ -1095,14 +1095,14 @@ class Tracking
         }
 
         if ($debug) echo '<h1>Tracking::get_avg_student_score</h1>';
-        $tbl_stats_exercices        = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-        $tbl_stats_attempts         = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
+        $tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+        $tbl_stats_attempts = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
 
         $course = api_get_course_info($course_code);
 
         if (!empty($course)) {
 
-            // get course tables names
+            // Get course tables names
             $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION);
             $lp_table           = Database :: get_course_table(TABLE_LP_MAIN);
             $lp_item_table      = Database :: get_course_table(TABLE_LP_ITEM);
@@ -1112,7 +1112,6 @@ class Tracking
             $course_id = $course['real_id'];
 
             // Compose a filter based on optional learning paths list given
-
             $condition_lp = "";
             if (count($lp_ids) > 0) {
                 $condition_lp =" AND id IN(".implode(',',$lp_ids).") ";
@@ -1130,9 +1129,11 @@ class Tracking
             // database (and if no list was given, get them all)
 
             if (empty($session_id)) {
-                $sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table WHERE c_id = $course_id AND session_id = 0 $condition_lp ";
+                $sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table
+                        WHERE c_id = $course_id AND session_id = 0 $condition_lp ";
             } else {
-                $sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table WHERE c_id = $course_id $condition_lp ";
+                $sql = "SELECT DISTINCT(id), use_max_score FROM $lp_table
+                        WHERE c_id = $course_id $condition_lp ";
             }
 
             $res_row_lp   = Database::query($sql);
@@ -1152,8 +1153,6 @@ class Tracking
             $progress = 0;
 
             // prepare filter on users
-            $condition_user1 = "";
-
             if (is_array($student_id)) {
                 array_walk($student_id, 'intval');
                 $condition_user1 =" AND user_id IN (".implode(',', $student_id).") ";
@@ -1165,7 +1164,8 @@ class Tracking
 
                 // Getting latest LP result for a student
                 //@todo problem when a  course have more than 1500 users
-                $sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id  FROM $lp_view_table
+                $sql = "SELECT MAX(view_count) as vc, id, progress, lp_id, user_id
+                        FROM $lp_view_table
                         WHERE 	c_id = $course_id AND
                                 lp_id IN (".implode(',',$lp_list).")
                                 $condition_user1 AND
@@ -1201,7 +1201,7 @@ class Tracking
                             while ($row_lp_item = Database::fetch_array($res_lp_item,'ASSOC')) {
                                 $my_lp_item_id = $row_lp_item['lp_item_id'];
 
-                                //Getting the most recent attempt
+                                // Getting the most recent attempt
                                 $sql = "SELECT  lp_iv.id as lp_item_view_id,
                                                 lp_iv.score as score,
                                                 lp_i.max_score,
@@ -1215,8 +1215,9 @@ class Tracking
                                                 lp_iv.c_id = $course_id AND
                                                 lp_i.c_id  = $course_id AND
                                                 (lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
-                                        WHERE 	lp_item_id = $my_lp_item_id AND
-                                                lp_view_id = $lp_view_id
+                                        WHERE
+                                            lp_item_id = $my_lp_item_id AND
+                                            lp_view_id = $lp_view_id
                                         ORDER BY view_count DESC
                                         LIMIT 1";
                                 $res_lp_item_result = Database::query($sql);
@@ -1255,25 +1256,29 @@ class Tracking
                         $score_of_scorm_calculate = 0;
 
                         foreach ($list as $row_max_score) {
-                            $max_score              = $row_max_score['max_score'];  //Came from the original lp_item
-                            $max_score_item_view    = $row_max_score['max_score_item_view']; //Came from the lp_item_view
-                            $score                  = $row_max_score['score'];
+                            // Came from the original lp_item
+                            $max_score = $row_max_score['max_score'];
+                            // Came from the lp_item_view
+                            $max_score_item_view = $row_max_score['max_score_item_view'];
+                            $score = $row_max_score['score'];
 
                             if ($debug) echo '<h3>Item Type: ' .$row_max_score['item_type'].'</h3>';
 
                             if ($row_max_score['item_type'] == 'sco') {
-                                // Check if it is sco (easier to get max_score)
-                                //when there's no max score, we assume 100 as the max score, as the SCORM 1.2 says that the value should always be between 0 and 100.
+                                /* Check if it is sco (easier to get max_score)
+                                   when there's no max score, we assume 100 as the max score,
+                                   as the SCORM 1.2 says that the value should always be between 0 and 100.
+                                */
                                 if ($max_score == 0 || is_null($max_score) || $max_score == '') {
-                                    //Chamilo style
+                                    // Chamilo style
                                     if ($use_max_score[$lp_id]) {
                                         $max_score = 100;
                                     } else {
-                                        //Overwrites max score = 100 to use the one that came in the lp_item_view see BT#1613
+                                        // Overwrites max score = 100 to use the one that came in the lp_item_view see BT#1613
                                         $max_score = $max_score_item_view;
                                     }
                                 }
-                                //Avoid division by zero errors
+                                // Avoid division by zero errors
                                 if (!empty($max_score)) {
                                     $lp_partial_total += $score/$max_score;
                                 }
@@ -1338,7 +1343,7 @@ class Tracking
                             }
                         } //end for
 
-                        $score_of_scorm_calculate += $count_items?(($lp_partial_total/$count_items)*100):0;
+                        $score_of_scorm_calculate += $count_items ? (($lp_partial_total / $count_items) * 100) : 0;
 
                         if ($debug) echo '<h3>$count_items '.$count_items.'</h3>';
                         if ($debug) echo '<h3>$score_of_scorm_calculate '.$score_of_scorm_calculate.'</h3>';
@@ -1351,7 +1356,7 @@ class Tracking
                 $lp_with_quiz = 0;
                 if ($debug) var_dump($lp_list);
                 foreach ($lp_list as $lp_id) {
-                    //Check if LP have a score we asume that all SCO have an score
+                    // Check if LP have a score we assume that all SCO have an score
                     $sql = "SELECT count(id) as count FROM $lp_item_table
                             WHERE c_id = $course_id AND  (item_type = 'quiz' OR item_type = 'sco') AND lp_id = ".$lp_id;
                     if ($debug) echo $sql;
@@ -1373,7 +1378,6 @@ class Tracking
                         $score_of_scorm_calculate = round(($global_result/$lp_with_quiz),2);
                         if ($debug) var_dump($score_of_scorm_calculate);
                         if (empty($lp_ids)) {
-                            //$score_of_scorm_calculate = round($score_of_scorm_calculate/count($lp_list),2);
                             if ($debug) echo '<h2>All lps fix: '.$score_of_scorm_calculate.'</h2>';
                         }
                         return $score_of_scorm_calculate;
@@ -1422,8 +1426,7 @@ class Tracking
             $conditions[] = " c_id = $courseId";
         }
 
-        // get course tables names
-        $tbl_quiz_questions = Database :: get_course_table(TABLE_QUIZ_QUESTION);
+        // Get course tables names
         $lp_table           = Database :: get_course_table(TABLE_LP_MAIN);
         $lp_item_table      = Database :: get_course_table(TABLE_LP_ITEM);
         $lp_view_table      = Database :: get_course_table(TABLE_LP_VIEW);
@@ -1586,6 +1589,7 @@ class Tracking
                 }
             }
         }
+
         return $last_time;
     }
 

+ 9 - 14
main/newscorm/aicc.class.php

@@ -1,26 +1,21 @@
 <?php
 /* For licensing terms, see /license.txt */
 
-/**
- * Defines the AICC class, which is meant to contain the aicc items (nuclear elements)
- * @package chamilo.learnpath
- * @author	Yannick Warnier <ywarnier@beeznest.org>
- * @license	GNU/GPL
- */
-/**
- * Code
- */
 require_once 'aiccItem.class.php';
 //require_once 'aiccMetadata.class.php';
 //require_once 'aiccOrganization.class.php';
 require_once 'aiccResource.class.php';
 require_once 'aiccBlock.class.php';
 /**
- * Class
+ * Class aicc
+ * Defines the AICC class, which is meant to contain the aicc items (nuclear elements)
+ * @package chamilo.learnpath
+ * @author	Yannick Warnier <ywarnier@beeznest.org>
+ * @license	 GNU/GPL
  * @package chamilo.learnpath
  */
-class aicc extends learnpath {
-
+class aicc extends learnpath
+{
     public $config = array();
     public $config_basename = '';	// The configuration files might be multiple and might have
                                     // funny names. We need to keep the name of that file while we
@@ -228,7 +223,7 @@ class aicc extends learnpath {
      */
     function import_aicc($course_code) {
         $course_id = api_get_course_int_id();
-        
+
         if ($this->debug > 0) { error_log('New LP - In aicc::import_aicc('.$course_code.')', 0); }
         // Get table names.
         $new_lp = 'lp';
@@ -239,7 +234,7 @@ class aicc extends learnpath {
         $res = Database::query($sql);
         if (Database::num_rows($res) < 1) { error_log('New LP - Database for '.$course_code.' not found '.__FILE__.' '.__LINE__, 0); return -1; }
         $row = Database::fetch_array($res);
-                
+
         $new_lp = Database::get_course_table(TABLE_LP_MAIN);
         $new_lp_item = Database::get_course_table(TABLE_LP_ITEM);
         $get_max = "SELECT MAX(display_order) FROM $new_lp WHERE c_id = $course_id";

+ 8 - 7
main/newscorm/aiccBlock.class.php

@@ -2,17 +2,16 @@
 /* For licensing terms, see /license.txt */
 
 /**
+ * Class defining the Block elements in an AICC Course Structure file.
+ *
  * Container for the aiccResource class that deals with elemens from AICC Course Structure file
  * @package	chamilo.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL
  */
-
-/**
- * Class defining the Block elements in an AICC Course Structure file.
- */
 require_once 'learnpathItem.class.php';
-class aiccBlock extends learnpathItem {
+class aiccBlock extends learnpathItem
+{
     public $identifier = '';
     public $members = array();
 
@@ -32,8 +31,8 @@ class aiccBlock extends learnpathItem {
                 default:
                     foreach ($params as $a => $value) {
                         switch ($a) {
-                               case 'system_id':
-                                   $this->identifier = strtolower($value);
+                            case 'system_id':
+                               $this->identifier = strtolower($value);
                                 break;
                             case 'member':
                                 if (strstr($value, ',') !== false) {
@@ -47,9 +46,11 @@ class aiccBlock extends learnpathItem {
                                 break;
                         }
                     }
+
                     return true;
             }
         }
+
         return false;
     }
 }

+ 7 - 9
main/newscorm/aiccItem.class.php

@@ -1,21 +1,18 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+require_once 'learnpathItem.class.php';
+
 /**
+ * This class handles the elements from an AICC Descriptor file.
  * Container for the aiccItem class that deals with AICC Assignable Units (AUs)
  * @package	chamilo.learnpath
  * @author	Yannick Warnier	<ywarnier@beeznest.org>
  * @license	GNU/GPL
- */
-/**
- * Code
- */
-require_once 'learnpathItem.class.php';
-/**
- * This class handles the elements from an AICC Descriptor file.
  * @package	chamilo.learnpath
  */
-class aiccItem extends learnpathItem {
+class aiccItem extends learnpathItem
+{
     public $identifier = ''; // AICC AU's system_id
     public $identifierref = '';
     public $parameters = ''; // AICC AU's web_launch
@@ -39,7 +36,8 @@ class aiccItem extends learnpathItem {
      * @param	string	Type of construction needed ('db' or 'config', default = 'config')
      * @param	mixed	Depending on the type given, DB id for the lp_item or parameters array
      */
-    public function aiccItem($type = 'config', $params = array(), $course_id = null) {
+    public function aiccItem($type = 'config', $params = array(), $course_id = null)
+    {
         if (isset($params)) {
             switch ($type) {
                 case 'db':

+ 9 - 8
main/newscorm/aiccObjective.class.php

@@ -1,18 +1,17 @@
 <?php
 /* For licensing terms, see /license.txt */
 
+require_once 'learnpathItem.class.php';
+
 /**
+ * Class defining the Block elements in an AICC Course Structure file.
  * Container for the aiccResource class that deals with elemens from AICC Objectives file
  * @package	chamilo.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL
  */
-
-/**
- * Class defining the Block elements in an AICC Course Structure file.
- */
-require_once 'learnpathItem.class.php';
-class aiccObjective extends learnpathItem {
+class aiccObjective extends learnpathItem
+{
     public $identifier = '';
     public $members = array();
 
@@ -22,8 +21,8 @@ class aiccObjective extends learnpathItem {
      * @param	string	Type of construction needed ('db' or 'config', default = 'config')
      * @param	mixed	Depending on the type given, DB id for the lp_item or parameters array
      */
-    function aiccObjective($type = 'config', $params) {
-
+    function aiccObjective($type = 'config', $params)
+    {
         if (isset($params)) {
             switch ($type) {
                 case 'db':
@@ -48,9 +47,11 @@ class aiccObjective extends learnpathItem {
                                  break;
                          }
                      }
+
                     return true;
             }
         }
+
         return false;
      }
 }

+ 3 - 5
main/newscorm/aiccResource.class.php

@@ -2,16 +2,14 @@
 /* For licensing terms, see /license.txt */
 
 /**
+ * Class defining the elements from an AICC Descriptor file.
  * Container for the aiccResource class that deals with elemens from AICC Descriptor file
  * @package	chamilo.learnpath
  * @author	Yannick Warnier <ywarnier@beeznest.org>
  * @license	GNU/GPL
  */
-
-/**
- * Class defining the elements from an AICC Descriptor file.
- */
-class aiccResource {
+class aiccResource
+{
     public $identifier = '';
     public $title = '';
     public $description = '';

+ 3 - 3
main/newscorm/aicc_hacp.php

@@ -54,9 +54,9 @@ require_once 'aicc.class.php';
 
 // Is this needed? This is probabaly done in the header file.
 //$_user							= $_SESSION['_user'];
-$file							= $_SESSION['file'];
-$oLP							= unserialize($_SESSION['lpobject']);
-$oItem 							=& $oLP->items[$oLP->current];
+$file = $_SESSION['file'];
+$oLP = unserialize($_SESSION['lpobject']);
+$oItem =& $oLP->items[$oLP->current];
 if (!is_object($oItem)) {
     error_log('New LP - aicc_hacp - Could not load oItem item', 0);
     exit;

File diff suppressed because it is too large
+ 283 - 211
main/newscorm/learnpath.class.php


+ 159 - 193
main/newscorm/learnpathItem.class.php

@@ -72,7 +72,6 @@ class learnpathItem
     public $view_id;
     //var used if absolute session time mode is used
     private $last_scorm_session_time = 0;
-
     const debug = 0; // Logging parameter.
 
     /**
@@ -107,7 +106,6 @@ class learnpathItem
         $id = intval($id);
 
         if (empty($item_content)) {
-
             if (empty($course_id)) {
                 $course_id = api_get_course_int_id();
             } else {
@@ -320,25 +318,23 @@ class learnpathItem
         }
         Database::query($sql_del_view);
 
-        $sql_sel = "SELECT * FROM $lp_item
-            WHERE c_id = $course_id AND id = " . $this->db_id;
-        $res_sel = Database::query($sql_sel);
+        $sql = "SELECT * FROM $lp_item
+                WHERE c_id = $course_id AND id = " . $this->db_id;
+        $res_sel = Database::query($sql);
         if (Database::num_rows($res_sel) < 1) {
             return false;
         }
 
-        $sql_del_item = "DELETE FROM $lp_item
-            WHERE c_id = $course_id AND id = " . $this->db_id;
-        Database::query($sql_del_item);
+        $sql = "DELETE FROM $lp_item
+                WHERE c_id = $course_id AND id = " . $this->db_id;
+        Database::query($sql);
         if (self::debug > 0) {
             error_log('Deleting from lp_item: ' . $sql_del_view);
         }
 
         if (api_get_setting('search_enabled') == 'true') {
             if (!is_null($this->search_did)) {
-                require_once api_get_path(
-                        LIBRARY_PATH
-                    ) . 'search/ChamiloIndexer.class.php';
+                require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
                 $di = new ChamiloIndexer();
                 $di->remove_document($this->search_did);
             }
@@ -434,8 +430,8 @@ class learnpathItem
         $credit = 'credit';
         // Now check the value of prevent_reinit (if it's 0, return credit as
         // the default was).
-        if ($this->get_prevent_reinit() != 0
-        ) { // If prevent_reinit == 1 (or more).
+        // If prevent_reinit == 1 (or more).
+        if ($this->get_prevent_reinit() != 0) {
             // If status is not attempted or incomplete, credit anyway.
             // Otherwise:
             // Check the status in the database rather than in the object, as
@@ -450,8 +446,9 @@ class learnpathItem
                 );
             }
             //0=not attempted - 1 = incomplete
-            if ($status != $this->possible_status[0]
-                    && $status != $this->possible_status[1]) {
+            if ($status != $this->possible_status[0]&&
+                $status != $this->possible_status[1]
+            ) {
                 $credit = 'no-credit';
             }
         }
@@ -616,10 +613,11 @@ class learnpathItem
         if ($checkdb) {
             $tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
             $sql = "SELECT id FROM $tbl
-                WHERE c_id = $course_id
-                AND lp_item_id = " . $this->db_id . "
-                AND   lp_view_id = " . $this->view_id ."
-                AND   view_count = " . $this->get_attempt_id();
+                    WHERE
+                        c_id = $course_id AND
+                        lp_item_id = " . $this->db_id . " AND
+                        lp_view_id = " . $this->view_id ." AND
+                        view_count = " . $this->get_attempt_id();
             $res = Database::query($sql);
             if (Database::num_rows($res) > 0) {
                 $row = Database::fetch_array($res);
@@ -905,8 +903,7 @@ class learnpathItem
                 $table = Database::get_course_table(TABLE_LP_MAIN);
                 $sql = "SELECT prevent_reinit
                     FROM $table
-                    WHERE c_id = $course_id
-                        AND id = " . $this->lp_id;
+                    WHERE c_id = $course_id AND id = " . $this->lp_id;
                 $res = Database::query($sql);
                 if (Database::num_rows($res) < 1) {
                     $this->error = "Could not find parent learnpath in lp table";
@@ -951,9 +948,8 @@ class learnpathItem
             if (!empty($this->lp_id)) {
                 $table = Database::get_course_table(TABLE_LP_MAIN);
                 $sql = "SELECT seriousgame_mode
-                    FROM $table
-                    WHERE c_id = $course_id
-                        AND id = " . $this->lp_id;
+                        FROM $table
+                        WHERE c_id = $course_id AND id = " . $this->lp_id;
                 $res = @Database::query($sql);
                 if (Database::num_rows($res) < 1) {
                     $this->error = "Could not find parent learnpath in learnpath table";
@@ -1774,6 +1770,24 @@ class learnpathItem
         }
     }
 
+    /**
+     * @param string $origin
+     * @return string
+     */
+    public static function getScormTimeFromParameter($origin = 'php', $time = null)
+    {
+        $h = get_lang('h');
+        if (!isset($time)) {
+            if ($origin == 'js') {
+                return '00:00:00';
+            } else {
+                return '00' . $h . '00\'00"';
+            }
+        } else {
+            return self::calculateScormTime($origin, $time);
+        }
+    }
+
     /**
      * Gets the total time spent on this item view so far
      * @param  string  $origin  Origin of the request. If coming from PHP,
@@ -1787,7 +1801,6 @@ class learnpathItem
         $given_time = null,
         $query_db = false
     ) {
-        $h = get_lang('h');
         $time = null;
         $course_id = api_get_course_int_id();
         if (!isset($given_time)) {
@@ -1797,34 +1810,26 @@ class learnpathItem
                     0
                 );
             }
-            if (is_object($this)) {
-                if ($query_db === true) {
-                    $table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
-                    $sql = "SELECT start_time, total_time FROM $table
-                           WHERE
-                                c_id = $course_id AND
-                                id = '" . $this->db_item_view_id . "' AND
-                                view_count = '" . $this->get_attempt_id() . "'";
-                    $res = Database::query($sql);
-                    $row = Database::fetch_array($res);
-                    $start = $row['start_time'];
-                    $stop = $start + $row['total_time'];
-                } else {
-                    $start = $this->current_start_time;
-                    $stop = $this->current_stop_time;
-                }
-                if (!empty($start)) {
-                    if (!empty($stop)) {
-                        $time = $stop - $start;
-                    } else {
-                        $time = time() - $start;
-                    }
-                }
+            if ($query_db === true) {
+                $table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
+                $sql = "SELECT start_time, total_time FROM $table
+                       WHERE
+                            c_id = $course_id AND
+                            id = '" . $this->db_item_view_id . "' AND
+                            view_count = '" . $this->get_attempt_id() . "'";
+                $res = Database::query($sql);
+                $row = Database::fetch_array($res);
+                $start = $row['start_time'];
+                $stop = $start + $row['total_time'];
             } else {
-                if ($origin == 'js') {
-                    return '00:00:00';
+                $start = $this->current_start_time;
+                $stop = $this->current_stop_time;
+            }
+            if (!empty($start)) {
+                if (!empty($stop)) {
+                    $time = $stop - $start;
                 } else {
-                    return '00' . $h . '00\'00"';
+                    $time = time() - $start;
                 }
             }
         } else {
@@ -1836,21 +1841,35 @@ class learnpathItem
                 0
             );
         }
+        $time = self::calculateScormTime($origin, $time);
+
+        return $time;
+    }
+
+    /**
+     * @param string $origin
+     * @param string $time
+     * @return string
+     */
+    public static function calculateScormTime($origin, $time)
+    {
+        $h = get_lang('h');
         $hours = $time / 3600;
         $mins = ($time % 3600) / 60;
         $secs = ($time % 60);
+
         if ($origin == 'js') {
-            $scorm_time = trim(sprintf("%4d:%02d:%02d", $hours, $mins, $secs));
+            $scormTime = trim(sprintf("%4d:%02d:%02d", $hours, $mins, $secs));
         } else {
-            $scorm_time = trim(
+            $scormTime = trim(
                 sprintf("%4d$h%02d'%02d\"", $hours, $mins, $secs)
             );
         }
         if (self::debug > 2) {
-            error_log('learnpathItem::get_scorm_time(' . $scorm_time . ')', 0);
+            error_log('learnpathItem::get_scorm_time(' . $scormTime . ')', 0);
         }
 
-        return $scorm_time;
+        return $scormTime;
     }
 
     /**
@@ -3741,12 +3760,13 @@ class learnpathItem
         $credit = $this->get_credit();
 
         $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
-        $sql_verified = 'SELECT status FROM ' . $item_view_table . '
-		                 WHERE c_id = ' . $course_id . '
-		                    AND lp_item_id="' . $this->db_id . '"
-		                    AND lp_view_id="' . $this->view_id . '"
-		                    AND view_count="' . $this->get_attempt_id() . '" ;';
-        $rs_verified = Database::query($sql_verified);
+        $sql = 'SELECT status FROM ' . $item_view_table . '
+                WHERE
+                    c_id = ' . $course_id . ' AND
+                    lp_item_id="' . $this->db_id . '" AND
+                    lp_view_id="' . $this->view_id . '" AND
+                    view_count="' . $this->get_attempt_id() . '" ;';
+        $rs_verified = Database::query($sql);
         $row_verified = Database::fetch_array($rs_verified);
 
         $my_case_completed = array(
@@ -3754,7 +3774,7 @@ class learnpathItem
             'passed',
             'browsed',
             'failed'
-        ); // Added by Isaac Flores.
+        );
 
         $save = true;
 
@@ -3765,9 +3785,8 @@ class learnpathItem
         }
 
         if ((($save === false && $this->type == 'sco') ||
-                ($this->type == 'sco' &&
-                    ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse'))
-            ) && ($this->seriousgame_mode != 1 && $this->type == 'sco')
+           ($this->type == 'sco' && ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse'))
+           ) && ($this->seriousgame_mode != 1 && $this->type == 'sco')
         ) {
             if (self::debug > 1) {
                 error_log(
@@ -3784,8 +3803,8 @@ class learnpathItem
             $inserted = false;
 
             // This a special case for multiple attempts and Chamilo exercises.
-            if ($this->type == 'quiz' && $this->get_prevent_reinit(
-                ) == 0 && $this->get_status() == 'completed'
+            if ($this->type == 'quiz' && $this->get_prevent_reinit() == 0 &&
+                $this->get_status() == 'completed'
             ) {
                 // We force the item to be restarted.
                 $this->restart();
@@ -3820,7 +3839,7 @@ class learnpathItem
                         0
                     );
                 }
-                $res = Database::query($sql);
+                Database::query($sql);
                 $this->db_item_view_id = Database::insert_id();
                 $inserted = true;
             }
@@ -3871,7 +3890,7 @@ class learnpathItem
                         0
                     );
                 }
-                $res = Database::query($sql);
+                Database::query($sql);
                 $this->db_item_view_id = Database::insert_id();
             } else {
                 $sql = '';
@@ -3928,57 +3947,42 @@ class learnpathItem
                             'failed'
                         );
 
-                        //is not multiple attempts
+                        // Is not multiple attempts
                         if ($this->seriousgame_mode == 1 && $this->type == 'sco') {
-                            $total_time = " total_time = total_time +" . $this->get_total_time(
-                                ) . ", ";
-                            $my_status = " status = '" . $this->get_status(
-                                    false
-                                ) . "' ,";
+                            $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
+                            $my_status = " status = '" . $this->get_status(false) . "' ,";
                         } elseif ($this->get_prevent_reinit() == 1) {
                             // Process of status verified into data base.
-                            $sql_verified = 'SELECT status FROM ' . $item_view_table . '
-                                WHERE c_id = ' . $course_id . '
-                                    AND lp_item_id="' . $this->db_id . '"
-                                    AND lp_view_id="' . $this->view_id . '"
-                                    AND view_count="' . $this->get_attempt_id() . '" ;';
-                            $rs_verified = Database::query($sql_verified);
+                            $sql = 'SELECT status FROM ' . $item_view_table . '
+                                    WHERE
+                                        c_id = ' . $course_id . ' AND
+                                        lp_item_id="' . $this->db_id . '" AND
+                                        lp_view_id="' . $this->view_id . '" AND
+                                        view_count="' . $this->get_attempt_id() . '" ;';
+                            $rs_verified = Database::query($sql);
                             $row_verified = Database::fetch_array($rs_verified);
 
                             // Get type lp: 1=lp dokeos and  2=scorm.
                             // If not is completed or passed or browsed and learning path is scorm.
-                            if (!in_array(
-                                    $this->get_status(false),
-                                    $case_completed
-                                ) && $my_type_lp == 2
-                            ) { //&& $this->type!='dir'
+                            if (!in_array($this->get_status(false), $case_completed) &&
+                                $my_type_lp == 2
+                            ) {
                                 $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
-                                $my_status = " status = '" . $this->get_status(
-                                        false
-                                    ) . "' ,";
+                                $my_status = " status = '" . $this->get_status(false) . "' ,";
                             } else {
-                                // Verified into data base.
-                                if (!in_array(
-                                        $row_verified['status'],
-                                        $case_completed
-                                    ) && $my_type_lp == 2
-                                ) { //&& $this->type!='dir'
+                                // Verified into database.
+                                if (!in_array($row_verified['status'], $case_completed) &&
+                                    $my_type_lp == 2
+                                ) {
                                     $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
-                                    $my_status = " status = '" . $this->get_status(
-                                            false
-                                        ) . "' ,";
-                                } elseif (in_array(
-                                        $row_verified['status'],
-                                        $case_completed
-                                    ) && $my_type_lp == 2 && $this->type != 'sco'
-                                ) { //&& $this->type!='dir'
+                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
+                                } elseif (in_array($row_verified['status'], $case_completed ) &&
+                                    $my_type_lp == 2 && $this->type != 'sco'
+                                ) {
                                     $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
-                                    $my_status = " status = '" . $this->get_status(
-                                            false
-                                        ) . "' ,";
+                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
                                 } else {
-                                    //&& !in_array($row_verified['status'], $case_completed)
-                                    //is lp dokeos
+                                    // Is lp chamilo
                                     if ($my_type_lp == 1 && $this->type != 'chapter') {
                                         $total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
                                         $my_status = " status = '" . $this->get_status(false) . "' ,";
@@ -3993,42 +3997,34 @@ class learnpathItem
                                 ) && $my_type_lp == 2
                             ) {
                                 // Reset zero new attempt ?
-                                $my_status = " status = '" . $this->get_status(
-                                        false
-                                    ) . "' ,";
-                            } elseif (!in_array(
-                                    $this->get_status(false),
-                                    $case_completed
-                                ) && $my_type_lp == 2
+                                $my_status = " status = '" . $this->get_status(false) . "' ,";
+                            } elseif (!in_array($this->get_status(false), $case_completed) &&
+                                $my_type_lp == 2
                             ) {
                                 $total_time = " total_time = " . $this->get_total_time() . ", ";
                                 $my_status = " status = '" . $this->get_status(false) . "' ,";
                             } else {
-                                // It is dokeos LP.
+                                // It is chamilo LP.
                                 $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
                                 $my_status = " status = '" . $this->get_status(false) . "' ,";
                             }
 
-                            // Code added by Isaac Flores.
                             // This code line fixes the problem of wrong status.
                             if ($my_type_lp == 2) {
                                 // Verify current status in multiples attempts.
-                                $sql_status = 'SELECT status FROM ' . $item_view_table . '
-                                    WHERE c_id = ' . $course_id . '
-                                        AND lp_item_id="' . $this->db_id . '"
-                                        AND lp_view_id="' . $this->view_id . '"
-                                        AND view_count="' . $this->get_attempt_id() . '" ';
-                                $rs_status = Database::query($sql_status);
+                                $sql = 'SELECT status FROM ' . $item_view_table . '
+                                        WHERE
+                                            c_id = ' . $course_id . ' AND
+                                            lp_item_id="' . $this->db_id . '" AND
+                                            lp_view_id="' . $this->view_id . '" AND
+                                            view_count="' . $this->get_attempt_id() . '" ';
+                                $rs_status = Database::query($sql);
                                 $current_status = Database::result(
                                     $rs_status,
                                     0,
                                     'status'
                                 );
-                                if (in_array(
-                                    $current_status,
-                                    $case_completed
-                                )
-                                ) {
+                                if (in_array($current_status, $case_completed)) {
                                     $my_status = '';
                                     $total_time = '';
                                 } else {
@@ -4052,6 +4048,7 @@ class learnpathItem
                             "WHERE c_id = $course_id AND lp_item_id = " . $this->db_id . " " .
                             "AND lp_view_id = " . $this->view_id . " " .
                             "AND view_count = " . $this->get_attempt_id();
+
                     } else {
                         $sql = "UPDATE $item_view_table " .
                             "SET " . $total_time .
@@ -4074,13 +4071,10 @@ class learnpathItem
                         0
                     );
                 }
-                $res = Database::query($sql);
+                Database::query($sql);
             }
 
-            if (is_array($this->interactions) && count(
-                    $this->interactions
-                ) > 0
-            ) {
+            if (is_array($this->interactions) && count($this->interactions) > 0) {
                 // Save interactions.
                 $tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
                 $sql = "SELECT id FROM $tbl " .
@@ -4129,30 +4123,14 @@ class learnpathItem
                             $iva_row = Database::fetch_array($iva_res);
                             $iva_id = $iva_row[0];
                             $ivau_sql = "UPDATE $iva_table " .
-                                "SET interaction_id = '" . Database::escape_string(
-                                    $interaction[0]
-                                ) . "'," .
-                                "interaction_type = '" . Database::escape_string(
-                                    $interaction[1]
-                                ) . "'," .
-                                "weighting = '" . Database::escape_string(
-                                    $interaction[3]
-                                ) . "'," .
-                                "completion_time = '" . Database::escape_string(
-                                    $interaction[2]
-                                ) . "'," .
-                                "correct_responses = '" . Database::escape_string(
-                                    $correct_resp
-                                ) . "'," .
-                                "student_response = '" . Database::escape_string(
-                                    $interaction[5]
-                                ) . "'," .
-                                "result = '" . Database::escape_string(
-                                    $interaction[6]
-                                ) . "'," .
-                                "latency = '" . Database::escape_string(
-                                    $interaction[7]
-                                ) . "'" .
+                                "SET interaction_id = '" . Database::escape_string($interaction[0]) . "'," .
+                                "interaction_type = '" . Database::escape_string($interaction[1]) . "'," .
+                                "weighting = '" . Database::escape_string($interaction[3]) . "'," .
+                                "completion_time = '" . Database::escape_string($interaction[2]) . "'," .
+                                "correct_responses = '" . Database::escape_string($correct_resp) . "'," .
+                                "student_response = '" . Database::escape_string($interaction[5]) . "'," .
+                                "result = '" . Database::escape_string($interaction[6]) . "'," .
+                                "latency = '" . Database::escape_string($interaction[7]) . "'" .
                                 "WHERE c_id = $course_id AND id = $iva_id";
                             Database::query($ivau_sql);
                         } else {
@@ -4161,25 +4139,15 @@ class learnpathItem
                                 "weighting, completion_time, correct_responses, " .
                                 "student_response, result, latency)" .
                                 "VALUES" .
-                                "($course_id, " . $index . "," . $lp_iv_id . ",'" . Database::escape_string(
-                                    $interaction[0]
-                                ) . "','" . Database::escape_string(
-                                    $interaction[1]
-                                ) . "'," .
-                                "'" . Database::escape_string(
-                                    $interaction[3]
-                                ) . "','" . Database::escape_string(
-                                    $interaction[2]
-                                ) . "','" . Database::escape_string(
-                                    $correct_resp
-                                ) . "'," .
-                                "'" . Database::escape_string(
-                                    $interaction[5]
-                                ) . "','" . Database::escape_string(
-                                    $interaction[6]
-                                ) . "','" . Database::escape_string(
-                                    $interaction[7]
-                                ) . "'" .
+                                "($course_id, " . $index . "," . $lp_iv_id . ",'" .
+                                Database::escape_string($interaction[0]) . "','" .
+                                Database::escape_string($interaction[1]) . "'," ."'" .
+                                Database::escape_string($interaction[3]) . "','" .
+                                Database::escape_string($interaction[2]) . "','" .
+                                Database::escape_string($correct_resp) . "'," ."'" .
+                                Database::escape_string($interaction[5]) . "','" .
+                                Database::escape_string($interaction[6]) . "','" .
+                                Database::escape_string($interaction[7]) . "'" .
                                 ")";
                             Database::query($ivai_sql);
                         }
@@ -4200,9 +4168,7 @@ class learnpathItem
     public function add_audio()
     {
         $course_info = api_get_course_info();
-        $filepath = api_get_path(
-                SYS_COURSE_PATH
-            ) . $course_info['path'] . '/document/';
+        $filepath = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/';
 
         if (!is_dir($filepath . 'audio')) {
             mkdir(
@@ -4264,13 +4230,12 @@ class learnpathItem
 
             // Store the mp3 file in the lp_item table.
             $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-            $sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '" . Database::escape_string(
-                    $file_path
-                ) . "'
-                                WHERE c_id = {$course_info['real_id']} AND id = '" . Database::escape_string(
-                    $this->db_id
-                ) . "'";
-            Database::query($sql_insert_audio);
+            $sql = "UPDATE $tbl_lp_item SET
+                    audio = '" . Database::escape_string($file_path) . "'
+                    WHERE
+                        c_id = {$course_info['real_id']} AND
+                        id = '" . Database::escape_string($this->db_id) . "'";
+            Database::query($sql);
         }
         return $file_path;
     }
@@ -4292,12 +4257,11 @@ class learnpathItem
             $file_path = basename($document_data['path']);
             // Store the mp3 file in the lp_item table.
             $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
-            $sql = "UPDATE $tbl_lp_item SET audio = '" . Database::escape_string(
-                    $file_path
-                ) . "'
-                    WHERE c_id = {$course_info['real_id']} AND id = " . intval(
-                    $this->db_id
-                );
+            $sql = "UPDATE $tbl_lp_item SET
+                        audio = '" . Database::escape_string($file_path) . "'
+                    WHERE
+                        c_id = {$course_info['real_id']} AND
+                        id = " . intval($this->db_id);
             Database::query($sql);
         }
         return $file_path;
@@ -4316,7 +4280,9 @@ class learnpathItem
         if (empty($this->db_id)) {
             return false;
         }
-        $sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (" . $this->db_id . ")";
+        $sql = "UPDATE $tbl_lp_item SET
+                audio = ''
+                WHERE c_id = $course_id AND id IN (" . $this->db_id . ")";
         Database::query($sql);
     }
 

+ 1 - 21
main/newscorm/lp_ajax_initialize.php

@@ -46,27 +46,7 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
      * -'last'
      * - a real item ID
      */
-
-    $mylp = '';
-
-    $lpobject = Session::read('lpobject');
-    if (isset($lpobject)) {
-        $oLP = unserialize($lpobject);
-        if ($debug) error_log("lpobject was set");
-        if (!is_object($oLP)) {
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code, $lp_id, $user_id);
-            if ($debug) error_log("Creating learnpath");
-        } else {
-            $mylp = $oLP;
-            if ($debug) error_log("Loading learnpath from unserialize");
-        }
-    } else {
-        if ($debug) {
-            error_log("lpobject was not set");
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $mylp->set_current_item($next_item);
     if ($debug > 1) { error_log('In initialize_item() - new item is '.$next_item, 0); }
     $mylp->start_current_item(true);

+ 1 - 16
main/newscorm/lp_ajax_last_update_status.php

@@ -49,22 +49,7 @@ function last_update_status($lp_id, $user_id, $view_id, $item_id) {
     require_once 'scorm.class.php';
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 2) { error_log(print_r($oLP, true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code,$lp_id,$user_id);
-        } else {
-            if ($debug > 2) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
-    error_log(__LINE__);
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
 
     // This function should only be used for SCORM paths.
     if ($mylp->get_type() != 2) {

+ 2 - 33
main/newscorm/lp_ajax_save_item.php

@@ -8,9 +8,6 @@
  * @package chamilo.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
-/**
- * Code
- */
 
 use \ChamiloSession as Session;
 
@@ -71,33 +68,7 @@ function save_item(
         error_log("score: $score - max:$max - min: $min - status:$status - time:$time - suspend: $suspend - location: $location - core_exit: $core_exit");
     }
 
-    $mylp = null;
-    $lpobject = Session::read('lpobject');
-    /*if (!is_object($lpobject) && isset($sessionId) && isset($courseId)) {
-        $lpobject = new learnpathItem($lp_id, $user_id, $courseId);
-    }*/
-
-    if (isset($lpobject)) {
-        if (is_object($lpobject)) {
-            $mylp = $lpobject;
-        } else {
-            $oLP = unserialize($lpobject);
-            if ($debug) error_log("lpobject was set");
-            if (!is_object($oLP)) {
-                unset($oLP);
-                $code = api_get_course_id();
-                $mylp = new learnpath($code, $lp_id, $user_id);
-                if ($debug) error_log("Creating learnpath");
-            } else {
-                $mylp = $oLP;
-                if ($debug) error_log("Loading learnpath from unserialize");
-            }
-        }
-    } else {
-        if ($debug) {
-            error_log("lpobject was not set");
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
 
     if (!is_a($mylp, 'learnpath')) {
         if ($debug) {
@@ -131,7 +102,6 @@ function save_item(
         }
 
         return $return;
-
     } else {
         if ($debug > 1) { error_log('Prerequisites are OK'); }
 
@@ -205,9 +175,8 @@ function save_item(
         } else {
             $time = $mylpi->get_total_time();
         }
-
         if (isset($suspend) && $suspend != '' && $suspend != 'undefined') {
-            $mylpi->current_data = $suspend; //escapetxt($suspend);
+            $mylpi->current_data = $suspend;
         }
 
         if (isset($location) && $location != '' && $location!='undefined') {

+ 1 - 15
main/newscorm/lp_ajax_save_objectives.php

@@ -38,21 +38,7 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = arr
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP =unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 2) { error_log(print_r($oLP,true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code, $lp_id, $user_id);
-        }else{
-            if ($debug > 2) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $mylpi =& $mylp->items[$item_id];
     //error_log(__FILE__.' '.__LINE__.' '.print_r($objectives,true), 0);
     if(is_array($objectives) && count($objectives)>0){

+ 1 - 23
main/newscorm/lp_ajax_switch_item.php

@@ -51,29 +51,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) {
-            error_log('$_SESSION[lpobject] is set', 0);
-        }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 1) {
-                error_log(print_r($oLP, true), 0);
-            }
-            if ($debug > 2) {
-                error_log('Building new lp', 0);
-            }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code, $lp_id, $user_id);
-        } else {
-            if ($debug > 1) {
-                error_log('Reusing session lp', 0);
-            }
-            $mylp = $oLP;
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $new_item_id = 0;
     switch ($next_item) {
         case 'next':

+ 4 - 18
main/newscorm/lp_ajax_switch_item_toc.php

@@ -36,21 +36,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 1) { error_log(print_r($oLP, true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code, $lp_id, $user_id);
-        } else {
-            if ($debug > 1) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $new_item_id = 0;
     switch ($next_item) {
         case 'next':
@@ -87,7 +73,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
     $mylp->start_current_item(true);
     if ($mylp->force_commit) {
         $mylp->save_current();
-    }    
+    }
     if (is_object($mylp->items[$new_item_id])) {
         $mylpi = $mylp->items[$new_item_id];
     } else {
@@ -181,6 +167,6 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
     if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
     $_SESSION['scorm_item_id'] = $new_item_id; // Save the new item ID for the exercise tool to use.
     $_SESSION['lpobject'] = serialize($mylp);
-    return $return;    
+    return $return;
 }
-echo switch_item_toc($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid'], $_POST['next']);
+echo switch_item_toc($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid'], $_POST['next']);

+ 6 - 52
main/newscorm/lp_comm.server.php

@@ -73,24 +73,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 2) { error_log(print_r($oLP, true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code, $lp_id, $user_id);
-        } else {
-            if ($debug > 2) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
-    //$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
-
-
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $prereq_check = $mylp->prerequisites_match($item_id);
     if ($prereq_check === true) { // Launch the prerequisites check and set error if needed.
 
@@ -144,7 +127,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
     $mycomplete         = $mylp->get_complete_items_count();
     $myprogress_mode    = $mylp->get_progress_bar_mode();
     $myprogress_mode    = ($myprogress_mode == '' ? '%' : $myprogress_mode);
-    
+
     //$mylpi->write_to_db();
     $_SESSION['lpobject'] = serialize($mylp);
     if ($mylpi->get_type()!='sco'){
@@ -170,7 +153,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
 
         $tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
 
-        $sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login 
+        $sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login
                                 WHERE login_user_id='".api_get_user_id()."' ORDER BY login_date DESC LIMIT 0,1";
 
         $q_last_connection = Database::query($sql_last_connection);
@@ -205,24 +188,9 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = arr
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 2) { error_log(print_r($oLP, true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code,$lp_id,$user_id);
-        } else {
-            if ($debug > 2) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $mylpi =& $mylp->items[$item_id];
-    //error_log(__FILE__.' '.__LINE__.' '.print_r($objectives,true), 0);
-    if(is_array($objectives) && count($objectives)>0){
+    if (is_array($objectives) && count($objectives)>0){
         foreach($objectives as $index=>$objective){
             //error_log(__FILE__.' '.__LINE__.' '.$objectives[$index][0], 0);
             $mylpi->add_objective($index,$objectives[$index]);
@@ -259,21 +227,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
     require_once 'learnpathItem.class.php';
     require_once 'scormItem.class.php';
     require_once 'aiccItem.class.php';
-    $mylp = '';
-    if (isset($_SESSION['lpobject'])) {
-        if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
-        $oLP = unserialize($_SESSION['lpobject']);
-        if (!is_object($oLP)) {
-            if ($debug > 1) { error_log(print_r($oLP, true), 0); }
-            if ($debug > 2) { error_log('Building new lp', 0); }
-            unset($oLP);
-            $code = api_get_course_id();
-            $mylp = new learnpath($code,$lp_id,$user_id);
-        } else {
-            if ($debug > 1) { error_log('Reusing session lp', 0); }
-            $mylp = $oLP;
-        }
-    }
+    $mylp = learnpath::getLpFromSession(api_get_course_id(), $lp_id, $user_id);
     $new_item_id = 0;
     switch ($next_item) {
         case 'next':

+ 69 - 10
main/newscorm/lp_controller.php

@@ -425,10 +425,27 @@ switch ($action) {
                         } else {
                             $document_id = $_SESSION['oLP']->create_document($_course);
                         }
-                        $new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $document_id, $post_title, $_POST['description'], $_POST['prerequisites']);
+                        $new_item_id = $_SESSION['oLP']->add_item(
+                            $_POST['parent'],
+                            $_POST['previous'],
+                            $_POST['type'],
+                            $document_id,
+                            $post_title,
+                            $_POST['description'],
+                            $_POST['prerequisites']
+                        );
                     } else {
                         // For all other item types than documents, load the item using the item type and path rather than its ID.
-                        $new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $_POST['path'], $post_title, $_POST['description'], $_POST['prerequisites'], $_POST['maxTimeAllowed']);
+                        $new_item_id = $_SESSION['oLP']->add_item(
+                            $_POST['parent'],
+                            $_POST['previous'],
+                            $_POST['type'],
+                            $_POST['path'],
+                            $post_title,
+                            $_POST['description'],
+                            $_POST['prerequisites'],
+                            $_POST['maxTimeAllowed']
+                        );
                     }
                     $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
                     header('Location: '.$url);
@@ -512,7 +529,16 @@ switch ($action) {
                 	$expired_on   = null;
                 }
 
-                $new_lp_id = learnpath::add_lp(api_get_course_id(), Security::remove_XSS($_REQUEST['lp_name']), '', 'chamilo', 'manual', '', $publicated_on, $expired_on);
+                $new_lp_id = learnpath::add_lp(
+                    api_get_course_id(),
+                    Security::remove_XSS($_REQUEST['lp_name']),
+                    '',
+                    'chamilo',
+                    'manual',
+                    '',
+                    $publicated_on,
+                    $expired_on
+                );
 
                 if (is_numeric($new_lp_id)) {
                     // TODO: Maybe create a first module directly to avoid bugging the user with useless queries
@@ -586,7 +612,17 @@ switch ($action) {
                 if (isset($_FILES['mp3'])) {
                     $audio = $_FILES['mp3'];
                 }
-                $_SESSION['oLP']->edit_item($_REQUEST['id'], $_POST['parent'], $_POST['previous'], $post_title, $_POST['description'], $_POST['prerequisites'], $audio, $_POST['maxTimeAllowed'], $_POST['url']);
+                $_SESSION['oLP']->edit_item(
+                    $_REQUEST['id'],
+                    $_POST['parent'],
+                    $_POST['previous'],
+                    $post_title,
+                    $_POST['description'],
+                    $_POST['prerequisites'],
+                    $audio,
+                    $_POST['maxTimeAllowed'],
+                    $_POST['url']
+                );
 
                 if (isset($_POST['content_lp'])) {
                     $_SESSION['oLP']->edit_document($_course);
@@ -615,8 +651,14 @@ switch ($action) {
                 //Updating the lp.modified_on
                 $_SESSION['oLP']->set_modified_on();
                 $_SESSION['refresh'] = 1;
+                $editPrerequisite = $_SESSION['oLP']->edit_item_prereq(
+                    $_GET['id'],
+                    $_POST['prerequisites'],
+                    $_POST['min_' . $_POST['prerequisites']],
+                    $_POST['max_' . $_POST['prerequisites']]
+                );
 
-                if ($_SESSION['oLP']->edit_item_prereq($_GET['id'], $_POST['prerequisites'], $_POST['min_' . $_POST['prerequisites']], $_POST['max_' . $_POST['prerequisites']])) {
+                if ($editPrerequisite) {
                     $is_success = true;
                 }
 
@@ -639,7 +681,13 @@ switch ($action) {
             if (isset($_POST['submit_button'])) {
                 //Updating the lp.modified_on
                 $_SESSION['oLP']->set_modified_on();
-                $_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $post_title, $_POST['description']);
+                $_SESSION['oLP']->edit_item(
+                    $_GET['id'],
+                    $_POST['parent'],
+                    $_POST['previous'],
+                    $post_title,
+                    $_POST['description']
+                );
                 $is_success = true;
                 $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
                 header('Location: '.$url);
@@ -834,7 +882,8 @@ switch ($action) {
             //$author_fixed = $author;
 
             $_SESSION['oLP']->set_author($author_fixed);
-            $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);  // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
+            // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed.
+            $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']);
 
             if (isset($_REQUEST['lp_maker'])) {
                 $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']);
@@ -892,11 +941,22 @@ switch ($action) {
                     $new_values = explode(',', trim($_REQUEST[$specific_field['code']]));
                     if (!empty($new_values)) {
                         array_walk($new_values, 'trim');
-                        delete_all_specific_field_value(api_get_course_id(), $specific_field['id'], TOOL_LEARNPATH, $_SESSION['oLP']->lp_id);
+                        delete_all_specific_field_value(
+                            api_get_course_id(),
+                            $specific_field['id'],
+                            TOOL_LEARNPATH,
+                            $_SESSION['oLP']->lp_id
+                        );
 
                         foreach ($new_values as $value) {
                             if (!empty($value)) {
-                                add_specific_field_value($specific_field['id'], api_get_course_id(), TOOL_LEARNPATH, $_SESSION['oLP']->lp_id, $value);
+                                add_specific_field_value(
+                                    $specific_field['id'],
+                                    api_get_course_id(),
+                                    TOOL_LEARNPATH,
+                                    $_SESSION['oLP']->lp_id,
+                                    $value
+                                );
                             }
                         }
                     }
@@ -919,7 +979,6 @@ switch ($action) {
                 $_SESSION['from_learnpath']='yes';
                 $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']);
                 require 'resourcelinker.php';
-                //$_SESSION['oLP']->add_sub_item($_REQUEST['parent_item_id'], $_REQUEST['previous'], $_REQUEST['type'], $_REQUEST['path'], $_REQUEST['title']);
             } else {
                 require 'lp_admin_view.php';
             }

+ 32 - 26
main/newscorm/lp_list.php

@@ -2,8 +2,8 @@
 /* For licensing terms, see /license.txt */
 
 /**
- * This file was origially the copy of document.php, but many modifications happened since then ;
- * the direct file view is not any more needed, if the user uploads a scorm zip file, a directory
+ * This file was originally the copy of document.php, but many modifications happened since then ;
+ * the direct file view is not any more needed, if the user uploads a SCORM zip file, a directory
  * will be automatically created for it, and the files will be uncompressed there for example ;
  *
  * @package chamilo.learnpath
@@ -108,7 +108,6 @@ $userInfo = api_get_user_info();
 $list = new LearnpathList($userId);
 $flat_list = $list->get_flat_list();
 
-
 if (!empty($flat_list)) {
     echo '<table class="data_table">';
     echo '<tr>';
@@ -229,12 +228,17 @@ if (!empty($flat_list)) {
         $dsp_debug = '';
         $dsp_order = '';
 
-        $progress = learnpath::get_db_progress($id, $userId, '%', '', false, api_get_session_id());
+        $progress = learnpath::getProgress(
+            $id,
+            $userId,
+            api_get_course_int_id(),
+            api_get_session_id()
+        );
 
         if ($is_allowed_to_edit) {
             $dsp_progress = '<td><center>'.$progress.'</center></td>';
         } else {
-            $dsp_progress = '<td>'.learnpath::get_progress_bar('%', learnpath::get_db_progress($id, $userId, '%', '', false, api_get_session_id())).'</td>';
+            $dsp_progress = '<td>'.learnpath::get_progress_bar($progress, '%').'</td>';
         }
 
         $dsp_edit = '<td class="td_actions">';
@@ -252,7 +256,8 @@ if (!empty($flat_list)) {
 
             // EDIT LP
             if ($current_session == $details['lp_session']) {
-                $dsp_edit_lp = '<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'">'.Display::return_icon('settings.png', get_lang('CourseSettings'), '', ICON_SIZE_SMALL).'</a>';
+                $dsp_edit_lp = '<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'">'.
+                                Display::return_icon('settings.png', get_lang('CourseSettings'), '', ICON_SIZE_SMALL).'</a>';
             } else {
                 $dsp_edit_lp = Display::return_icon('settings_na.png', get_lang('CourseSettings'), '', ICON_SIZE_SMALL);
             }
@@ -260,7 +265,8 @@ if (!empty($flat_list)) {
             // BUILD
             if ($current_session == $details['lp_session']) {
                 if ($details['lp_type'] == 1 || $details['lp_type'] == 2) {
-                    $dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=add_item&amp;type=step&amp;lp_id='.$id.'">'.Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'), '', ICON_SIZE_SMALL).'</a>';
+                    $dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=add_item&amp;type=step&amp;lp_id='.$id.'">'.
+                                  Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'), '', ICON_SIZE_SMALL).'</a>';
                 } else {
                     $dsp_build = Display::return_icon('edit_na.png', get_lang('LearnpathEditLearnpath'), '', ICON_SIZE_SMALL);
                 }
@@ -270,16 +276,15 @@ if (!empty($flat_list)) {
 
             /* VISIBILITY COMMAND */
 
-            // Session test not necessary if we want to show base course learning paths inside the session (see http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
-            //if ($current_session == $details['lp_session']) {
+            /*  Session test not necessary if we want to show base course learning
+                paths inside the session.
+                See http://support.chamilo.org/projects/chamilo-18/wiki/Tools_and_sessions).
+            */
             if ($details['lp_visibility'] == 0) {
                 $dsp_visible = "<a href=\"".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=1\">".Display::return_icon('invisible.png', get_lang('Show'), '', ICON_SIZE_SMALL)."</a>";
             } else {
                 $dsp_visible = "<a href='".api_get_self()."?".api_get_cidreq()."&lp_id=$id&action=toggle_visible&new_status=0'>".Display::return_icon('visible.png', get_lang('Hide'), '', ICON_SIZE_SMALL)."</a>";
             }
-            //} else {
-            //	$dsp_visible = '<img src="../img/invisible.gif" border="0" title="'.get_lang('Show').'" />';
-            //}
 
             /* PUBLISH COMMAND */
             if ($current_session == $details['lp_session']) {
@@ -349,7 +354,6 @@ if (!empty($flat_list)) {
             }
 
             /*  DEBUG  */
-
             if ($test_mode == 'test' or api_is_platform_admin()) {
                 if ($details['lp_scorm_debug'] == 1) {
                     $dsp_debug = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_scorm_debug&lp_id='.$id.'">'.
@@ -360,9 +364,7 @@ if (!empty($flat_list)) {
                 }
             }
 
-
             /* Export */
-
             if ($details['lp_type'] == 1) {
                 $dsp_disk = Display::url(Display::return_icon('cd.gif', get_lang('Export'), array(), ICON_SIZE_SMALL), api_get_self()."?".api_get_cidreq()."&action=export&lp_id=$id");
             } elseif ($details['lp_type'] == 2) {
@@ -372,7 +374,15 @@ if (!empty($flat_list)) {
             }
 
             // Copy
-            $copy = Display::url(Display::return_icon('cd_copy.png', get_lang('Copy'), array(), ICON_SIZE_SMALL), api_get_self()."?".api_get_cidreq()."&action=copy&lp_id=$id");
+            $copy = Display::url(
+                Display::return_icon(
+                    'cd_copy.png',
+                    get_lang('Copy'),
+                    array(),
+                    ICON_SIZE_SMALL
+                ),
+                api_get_self() . "?" . api_get_cidreq() . "&action=copy&lp_id=$id"
+            );
 
             /* Auto Lunch LP code */
             if (api_get_course_setting('enable_lp_auto_launch') == 1) {
@@ -386,14 +396,11 @@ if (!empty($flat_list)) {
                 }
             }
 
-            //if (api_get_setting('pdf_export_watermark_enable') == 'true') {
-            //Export to PDF
+            // Export to PDF
             $export_icon = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=export_to_pdf&lp_id='.$id.'">
 				  '.Display::return_icon('pdf.png', get_lang('ExportToPDFOnlyHTMLAndImages'), '', ICON_SIZE_SMALL).'</a>';
-            //}
-
-            /* DELETE COMMAND */
 
+            /* Delete */
             if ($current_session == $details['lp_session']) {
                 $dsp_delete = "<a href=\"lp_controller.php?".api_get_cidreq()."&action=delete&lp_id=$id\" ".
                     "onclick=\"javascript: return confirmation('".addslashes($name)."');\">".
@@ -403,9 +410,7 @@ if (!empty($flat_list)) {
             }
 
             /* COLUMN ORDER	 */
-
             // Only active while session mode is not active
-
             if ($current_session == 0) {
                 if ($details['lp_display_order'] == 1 && $max != 1) {
                     $dsp_order .= '<a href="lp_controller.php?'.api_get_cidreq().'&action=move_lp_down&lp_id='.$id.'">
@@ -428,7 +433,7 @@ if (!empty($flat_list)) {
             } else {
                 $start_time = $end_time = '';
             }
-        } else { // end if ($is_allowedToEdit)
+        } else {
             //Student
             $export_icon = ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=export_to_pdf&lp_id='.$id.'">'.Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_SMALL).'</a>';
         }
@@ -450,9 +455,10 @@ if (!empty($flat_list)) {
         $dsp_default_view.$dsp_debug.$dsp_disk.$copy.$lp_auto_lunch_icon.$export_icon.$dsp_delete.$dsp_order.$dsp_edit_close;
 
         echo "</tr>";
-        $current++; //counter for number of elements treated
+        //counter for number of elements treated
+        $current++;
+
     } // end foreach ($flat_list)
-    // TODO: Erint some user-friendly message if counter is still = 0 to tell nothing can be display yet.
     echo "</table>";
 } else {
     if ($is_allowed_to_edit) {

+ 3 - 7
main/newscorm/lp_nav.php

@@ -6,9 +6,7 @@
  * @package chamilo.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
-/**
- * Code
- */
+
 // Flag to allow for anonymous user - needs to be set before global.inc.php.
 $use_anonymous = true;
 
@@ -32,7 +30,6 @@ $display_mode = '';
 $autostart = 'true';
 
 if (isset($_SESSION['lpobject'])) {
-    //if($debug>0) //error_log('New LP - in lp_nav.php - SESSION[lpobject] is defined',0);
     $oLP = unserialize($_SESSION['lpobject']);
     if (is_object($oLP)) {
         $_SESSION['oLP'] = $oLP;
@@ -46,8 +43,7 @@ if (isset($_SESSION['lpobject'])) {
 
     $my_style = api_get_visual_theme();
 
-    //Setting up the CSS theme if exists
-
+    // Setting up the CSS theme if exists
     $mycourselptheme = null;
     if (api_get_setting('allow_course_theme') == 'true') {
         $mycourselptheme = api_get_course_setting('allow_learning_path_theme');
@@ -59,7 +55,7 @@ if (isset($_SESSION['lpobject'])) {
         $lp_theme_css = $my_style;
     }
 
-    $progress_bar 	= $_SESSION['oLP']->get_progress_bar('', -1, '', true);
+    $progress_bar 	= $_SESSION['oLP']->getProgressBar();
     $navigation_bar = $_SESSION['oLP']->get_navigation_bar();
     $mediaplayer 	= $_SESSION['oLP']->get_mediaplayer($autostart);
 }

+ 1 - 1
main/newscorm/lp_save.php

@@ -26,7 +26,7 @@ error_log('New LP - Loaded lp_save : '.$_SERVER['REQUEST_URI'].' from '.$_SERVER
 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo api_get_system_encoding(); ?>" />
 <script language='javascript'>
 <?php
-if ($_SESSION['oLP']->mode != 'fullscreen'){
+if ($_SESSION['oLP']->mode != 'fullscreen') {
 }
 ?>
 </script>

+ 120 - 70
main/newscorm/lp_stats.php

@@ -1,6 +1,6 @@
 <?php
-
 /* For licensing terms, see /license.txt */
+
 /**
  * This script displays statistics on the current learning path (scorm)
  * This script must be included by lp_controller.php to get basic initialisation
@@ -8,9 +8,7 @@
  * @author Yannick Warnier <ywarnier@beeznest.org>
  * @todo clean this file like the exercise files J.M
  */
-/**
- * Code
- */
+
 require_once 'learnpath.class.php';
 require_once 'resourcelinker.inc.php';
 require_once '../exercice/exercise.lib.php';
@@ -22,8 +20,8 @@ if (empty($user_id)) {
 }
 
 // Declare variables to be used in lp_stats.php
-//When checking the reporting myspace/lp_tracking.php
-//isset($_GET['lp_id']) &&
+// When checking the reporting myspace/lp_tracking.php
+
 if (isset($lp_id) && !empty($lp_id)) {
     $lp_id = intval($lp_id);
     if (!isset($list)) {
@@ -156,23 +154,25 @@ if (isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) {
     if (Database::num_rows($res_path) > 0) {
         if ($origin != 'tracking') {
             $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . '
-            				 WHERE  exe_exo_id="' . (int) $row_path['path'] . '" AND
-                                    status <> "incomplete"  AND
-                                    exe_user_id="' . api_get_user_id() . '" AND
-                                    orig_lp_id = "' . (int) $clean_lp_id . '" AND
-                                    orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
-                                    exe_cours_id="' . $clean_course_code . '"  AND
-                                    session_id = ' . $session_id . '
+            				 WHERE
+            				    exe_exo_id="' . (int) $row_path['path'] . '" AND
+                                status <> "incomplete"  AND
+                                exe_user_id="' . api_get_user_id() . '" AND
+                                orig_lp_id = "' . (int) $clean_lp_id . '" AND
+                                orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
+                                exe_cours_id="' . $clean_course_code . '"  AND
+                                session_id = ' . $session_id . '
                              ORDER BY exe_date';
         } else {
             $sql_attempts = 'SELECT * FROM ' . $tbl_stats_exercices . '
-            				 WHERE  exe_exo_id="' . (int) $row_path['path'] . '" AND
-                                    status <> "incomplete"  AND
-                                    exe_user_id="' . $student_id . '" AND
-                                    orig_lp_id = "' . (int) $clean_lp_id . '" AND
-                                    orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
-                                    exe_cours_id="' . $clean_course_code . '"  AND
-                                    session_id = ' . $session_id . '
+            				 WHERE
+            				    exe_exo_id="' . (int) $row_path['path'] . '" AND
+                                status <> "incomplete"  AND
+                                exe_user_id="' . $student_id . '" AND
+                                orig_lp_id = "' . (int) $clean_lp_id . '" AND
+                                orig_lp_item_id = "' . (int) $clean_lp_item_id . '" AND
+                                exe_cours_id="' . $clean_course_code . '"  AND
+                                session_id = ' . $session_id . '
                              ORDER BY exe_date';
         }
     }
@@ -259,7 +259,8 @@ if (is_array($list) && count($list) > 0) {
                 // Check results_disabled in quiz table.
                 $my_path = Database::escape_string($row['path']);
 
-                $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . $my_path . "'";
+                $sql = "SELECT results_disabled FROM $TBL_QUIZ
+                        WHERE c_id = $course_id AND id ='" . $my_path . "'";
                 $res_result_disabled = Database::query($sql);
                 $row_result_disabled = Database::fetch_row($res_result_disabled);
 
@@ -277,7 +278,8 @@ if (is_array($list) && count($list) > 0) {
             $extend_link = '';
             if (!empty($inter_num)) {
                 $extend_link = '<a href="' . api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix . '">
-                                <img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '"  border="0"></a>';
+                                <img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '"  border="0">
+                                </a>';
             }
             $title = $row['mytitle'];
 
@@ -315,10 +317,12 @@ if (is_array($list) && count($list) > 0) {
                     if (!empty($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) {
                         // The extend button for this attempt has been clicked.
                         $extend_this_attempt = 1;
-                        $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '" border="0"></a>';
+                        $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '">
+                            <img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '" border="0"></a>';
                     } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
                         // The extend button for this attempt has not been clicked.
-                        $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '"  border="0"></a>';
+                        $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '">
+                            <img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '"  border="0"></a>';
                     }
                 }
 
@@ -331,7 +335,7 @@ if (is_array($list) && count($list) > 0) {
                 $lesson_status = $row['mystatus'];
                 $score = $row['myscore'];
                 $time_for_total = $row['mytime'];
-                $time = learnpathItem :: get_scorm_time('js', $row['mytime']);
+                $time = learnpathItem :: getScormTimeFromParameter('js', $row['mytime']);
                 $scoIdentifier = $row['myid'];
 
                 if ($score == 0) {
@@ -373,7 +377,7 @@ if (is_array($list) && count($list) > 0) {
                                 break;
                         }
                     }
-                    //$attemptCount = $row['iv_view_count'];
+
                     $output .= '<tr class="' . $oddclass . '">
                                     <td></td>
                                     <td>' . $extend_attempt_link . '</td>
@@ -413,13 +417,14 @@ if (is_array($list) && count($list) > 0) {
                         } else {
                             $oddclass = 'row_even';
                         }
-                        $student_response = urldecode($interaction['student_response']); // Code added by Isaac Flores.
+                        $student_response = urldecode($interaction['student_response']);
                         $content_student_response = array();
                         $content_student_response = explode('__|', $student_response);
 
                         if (count($content_student_response) > 0) {
                             if (count($content_student_response) >= 3) {
-                                $new_content_student_response = array_pop($content_student_response); // Pop the element off the end of array.
+                                // Pop the element off the end of array.
+                                $new_content_student_response = array_pop($content_student_response);
                             }
                             $student_response = implode(',', $content_student_response);
                         }
@@ -477,7 +482,8 @@ if (is_array($list) && count($list) > 0) {
                 // Check results_disabled in quiz table.
                 $my_path = Database::escape_string($my_path);
 
-                $sql = "SELECT results_disabled FROM $TBL_QUIZ WHERE c_id = $course_id AND id ='" . (int) $my_path . "'";
+                $sql = "SELECT results_disabled FROM $TBL_QUIZ
+                        WHERE c_id = $course_id AND id ='" . (int) $my_path . "'";
                 $res_result_disabled = Database::query($sql);
                 $row_result_disabled = Database::fetch_row($res_result_disabled);
 
@@ -497,10 +503,14 @@ if (is_array($list) && count($list) > 0) {
                 if (!empty($_GET['extend_attempt_id']) && $_GET['extend_attempt_id'] == $row['iv_id']) {
                     // The extend button for this attempt has been clicked.
                     $extend_this_attempt = 1;
-                    $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '" border="0"></a>' . "\n";
+                    $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&fold_attempt_id=' . $row['iv_id'] . $url_suffix . '">
+                        <img src="../img/visible.gif" alt="' . get_lang('HideAttemptView') . '" title="' . get_lang('HideAttemptView') . '" border="0">
+                        </a>';
                 } else { // Same case if fold_attempt_id is set, so not implemented explicitly.
                     // The extend button for this attempt has not been clicked.
-                    $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '" border="0"></a>' . "\n";
+                    $extend_attempt_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '">
+                        <img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '" border="0">
+                        </a>';
                 }
             }
 
@@ -512,7 +522,9 @@ if (is_array($list) && count($list) > 0) {
 
             $extend_link = '';
             if ($inter_num > 1) {
-                $extend_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '"><img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '"  border="0"></a>';
+                $extend_link = '<a href="' . api_get_self() . '?action=stats&extend_id=' . $my_item_id . '&extend_attempt_id=' . $row['iv_id'] . $url_suffix . '">
+                    <img src="../img/invisible.gif" alt="' . get_lang('ExtendAttemptView') . '" title="' . get_lang('ExtendAttemptView') . '"  border="0">
+                </a>';
             }
 
             $lesson_status = $row['mystatus'];
@@ -528,23 +540,25 @@ if (is_array($list) && count($list) > 0) {
             // Selecting the exe_id from stats attempts tables in order to look the max score value.
             if ($origin != 'tracking') {
                 $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
-                                     WHERE  exe_exo_id="' . $row['path'] . '" AND
-                                            exe_user_id="' . api_get_user_id() . '" AND
-                                            orig_lp_id = "' . $lp_id . '" AND
-                                            orig_lp_item_id = "' . $row['myid'] . '" AND
-                                            exe_cours_id="' . $course_code . '" AND
-                                            status <> "incomplete" AND
-                                            session_id = ' . $session_id . '
+                                     WHERE
+                                        exe_exo_id="' . $row['path'] . '" AND
+                                        exe_user_id="' . api_get_user_id() . '" AND
+                                        orig_lp_id = "' . $lp_id . '" AND
+                                        orig_lp_item_id = "' . $row['myid'] . '" AND
+                                        exe_cours_id="' . $course_code . '" AND
+                                        status <> "incomplete" AND
+                                        session_id = ' . $session_id . '
                                      ORDER BY exe_date DESC limit 1';
             } else {
                 $sql_last_attempt = 'SELECT * FROM ' . $tbl_stats_exercices . '
-                                     WHERE  exe_exo_id="' . $row['path'] . '" AND
-                                            exe_user_id="' . $student_id . '" AND
-                                            orig_lp_id = "' . $lp_id . '" AND
-                                            orig_lp_item_id = "' . $row['myid'] . '" AND
-                                            exe_cours_id="' . $course_code . '" AND
-                                            status <> "incomplete" AND
-                                            session_id = ' . $session_id . '
+                                     WHERE
+                                        exe_exo_id="' . $row['path'] . '" AND
+                                        exe_user_id="' . $student_id . '" AND
+                                        orig_lp_id = "' . $lp_id . '" AND
+                                        orig_lp_item_id = "' . $row['myid'] . '" AND
+                                        exe_cours_id="' . $course_code . '" AND
+                                        status <> "incomplete" AND
+                                        session_id = ' . $session_id . '
                                      ORDER BY exe_date DESC limit 1';
             }
 
@@ -571,13 +585,19 @@ if (is_array($list) && count($list) > 0) {
                     if ($row['item_type'] == 'quiz') {
                         // Get score and total time from last attempt of a exercise en lp.
                         $sql = "SELECT score FROM $TBL_LP_ITEM_VIEW
-                                WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "'
+                                WHERE
+                                    c_id = $course_id AND
+                                    lp_item_id = '" . (int) $my_id . "' AND
+                                    lp_view_id = '" . (int) $my_lp_view_id . "'
                                 ORDER BY view_count DESC limit 1";
                         $res_score = Database::query($sql);
                         $row_score = Database::fetch_array($res_score);
 
                         $sql = "SELECT SUM(total_time) as total_time FROM $TBL_LP_ITEM_VIEW
-                                WHERE c_id = $course_id AND lp_item_id = '" . (int) $my_id . "' AND lp_view_id = '" . (int) $my_lp_view_id . "'";
+                                WHERE
+                                    c_id = $course_id AND
+                                    lp_item_id = '" . (int) $my_id . "' AND
+                                    lp_view_id = '" . (int) $my_lp_view_id . "'";
                         $res_time = Database::query($sql);
                         $row_time = Database::fetch_array($res_time);
 
@@ -588,8 +608,6 @@ if (is_array($list) && count($list) > 0) {
                             $score = 0;
                             $subtotal_time = 0;
                         }
-                        //echo $subtotal_time ;
-                        //$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
                         // Selecting the max score from an attempt.
                         $sql = "SELECT SUM(t.ponderation) as maxscore
                                 FROM (
@@ -609,7 +627,7 @@ if (is_array($list) && count($list) > 0) {
             }
 
             $time_for_total = $subtotal_time;
-            $time = learnpathItem :: get_scorm_time('js', $subtotal_time);
+            $time = learnpathItem :: getScormTimeFromParameter('js', $subtotal_time);
             if (empty($title)) {
                 $title = rl_get_resource_name(api_get_course_id(), $lp_id, $row['myid']);
             }
@@ -649,9 +667,11 @@ if (is_array($list) && count($list) > 0) {
                     $num = Database :: num_rows($resultLastAttempt);
                     if ($num > 0) {
                         if (isset($_GET['extend_attempt']) && $_GET['extend_attempt'] == 1 && (isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) {
-                            $correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '"><img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="' . get_lang('HideAllAttempts') . '"></a>';
+                            $correct_test_link = '<a href="' . api_get_self() . '?action=stats' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '">
+                            <img src="../img/view_less_stats.gif" alt="fold_view" border="0" title="' . get_lang('HideAllAttempts') . '"></a>';
                         } else {
-                            $correct_test_link = '<a href="' . api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '"><img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="' . get_lang('ShowAllAttemptsByExercise') . '"></a>';
+                            $correct_test_link = '<a href="' . api_get_self() . '?action=stats&extend_attempt=1' . $my_url_suffix . '&session_id=' . api_get_session_id() . '&lp_item_id=' . $my_id . '">
+                            <img src="../img/view_more_stats.gif" alt="extend_view" border="0" title="' . get_lang('ShowAllAttemptsByExercise') . '"></a>';
                         }
                     } else {
                         $correct_test_link = '-';
@@ -674,7 +694,9 @@ if (is_array($list) && count($list) > 0) {
                                 </tr>';
                     $output .= '</tr>';
                 } else {
-                    if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)) {
+                    if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id ) &&
+                        (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id)
+                    ) {
                         $output .= "<tr class='$oddclass'>";
                     } else {
                         $output .= "<tr class='$oddclass'>";
@@ -775,7 +797,10 @@ if (is_array($list) && count($list) > 0) {
             }
 
             // Attempts listing by exercise.
-            if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) && (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id) && isset($_GET['extend_attempt'])) {
+            if ((isset($_GET['lp_id']) && $_GET['lp_id'] == $my_lp_id) &&
+                (isset($_GET['lp_item_id']) && $_GET['lp_item_id'] == $my_id) &&
+                isset($_GET['extend_attempt'])
+            ) {
 
                 $res_attempts = Database::query($sql_attempts);
                 $num_attempts = Database :: num_rows($res_attempts);
@@ -793,7 +818,7 @@ if (is_array($list) && count($list) > 0) {
                             $mktime_exe_date = api_strtotime($row_attempts['exe_date'], 'UTC');
                             if ($mktime_start_date && $mktime_exe_date) {
                                 $mytime = ((int) $mktime_exe_date - (int) $mktime_start_date);
-                                $time_attemp = learnpathItem :: get_scorm_time('js', $mytime);
+                                $time_attemp = learnpathItem :: getScormTimeFromParameter('js', $mytime);
                                 $time_attemp = str_replace('NaN', '00' . $h . '00\'00"', $time_attemp);
                             } else {
                                 $time_attemp = ' - ';
@@ -871,39 +896,66 @@ if (!empty($a_my_id)) {
         $my_course_id = Database::escape_string(api_get_course_id());
     }
     if (isset($_GET['extend_attempt'])) {
-        //"Right green cross" extended
-        $total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id, $session_id, false, false);
+        // "Right green cross" extended
+        $total_score = Tracking::get_avg_student_score(
+            $my_studen_id,
+            $my_course_id,
+            $a_my_id,
+            $session_id,
+            false,
+            false
+        );
+
     } else {
-        //"Left green cross" extended
-        $total_score = Tracking::get_avg_student_score($my_studen_id, $my_course_id, $a_my_id, $session_id, false, true);
+        // "Left green cross" extended
+        $total_score = Tracking::get_avg_student_score(
+            $my_studen_id,
+            $my_course_id,
+            $a_my_id,
+            $session_id,
+            false,
+            true
+        );
     }
 } else {
     // Extend all "left green cross"
     if ($origin == 'tracking') {
         $my_course_id = Database::escape_string($_GET['course']);
         if (!empty($student_id) && !empty($my_course_id)) {
-            $total_score = Tracking::get_avg_student_score($student_id, $my_course_id, array(intval($_GET['lp_id'])), $session_id, false, false);
+            $total_score = Tracking::get_avg_student_score(
+                $student_id,
+                $my_course_id,
+                array(intval($_GET['lp_id'])),
+                $session_id,
+                false,
+                false
+            );
         } else {
             $total_score = 0;
         }
     } else {
-        $total_score = Tracking::get_avg_student_score(api_get_user_id(), api_get_course_id(), array(intval($_GET['lp_id'])), $session_id, false, false);
+        $total_score = Tracking::get_avg_student_score(
+            api_get_user_id(),
+            api_get_course_id(),
+            array(intval($_GET['lp_id'])),
+            $session_id,
+            false,
+            false
+        );
     }
 }
 
-$total_time = learnpathItem :: get_scorm_time('js', $total_time);
-//$total_time = str_replace('NaN', '00:00:00' ,$total_time);
+$total_time = learnpathItem :: getScormTimeFromParameter('js', $total_time);
 $total_time = str_replace('NaN', '00' . $h . '00\'00"', $total_time);
-//$lp_type = learnpath :: get_type_static($lp_id);
-//$total_percent = 0;
 
 if (!$is_allowed_to_edit && $result_disabled_ext_all) {
     $final_score = Display::return_icon('invisible.gif', get_lang('ResultsHiddenByExerciseSetting'));
 } else {
-    if (is_numeric($total_score))
+    if (is_numeric($total_score)) {
         $final_score = $total_score . '%';
-    else
+    } else {
         $final_score = $total_score;
+    }
 }
 
 if (($counter % 2) == 0) {
@@ -912,7 +964,6 @@ if (($counter % 2) == 0) {
     $oddclass = 'row_even';
 }
 
-//if (empty($extend_all)) {
 $output .= '<tr class="'.$oddclass.'">
                 <td></td>
                 <td colspan="4">
@@ -924,7 +975,6 @@ $output .= '<tr class="'.$oddclass.'">
                 </td>
                 <td colspan="2">' . $total_time . '</div><td></td>
            </tr>';
-//}
 
 $output .= "</table>";
 

+ 2 - 5
main/newscorm/lp_upload.php

@@ -5,9 +5,7 @@
  * @package chamilo.learnpath
  * @author Yannick Warnier <ywarnier@beeznest.org>
  */
-/**
- * Code
- */
+
 // Flag to allow for anonymous user - needs to be set before global.inc.php.
 $use_anonymous = true;
 require_once 'back_compat.inc.php';
@@ -25,13 +23,12 @@ $uncompress = 1;
  * because if the file size exceed the maximum file upload
  * size set in php.ini, all variables from POST are cleared !
  */
-
 $user_file = Request::is_post() ? Request::file('user_file') : array();
 $user_file = $user_file ? $user_file : array();
 $is_error = isset($user_file['error']) ? $user_file['error'] : false;
 if (Request::is_post() && $is_error) {
     return api_failure::set_failure('upload_file_too_big');
-    unset($_FILEs['user_file']);
+    unset($_FILES['user_file']);
 } else if ($_SERVER['REQUEST_METHOD'] == 'POST' && count($_FILES) > 0 && !empty($_FILES['user_file']['name'])) {
 
     // A file upload has been detected, now deal with the file...

+ 1 - 1
main/newscorm/lp_view.php

@@ -311,7 +311,7 @@ if (!empty ($lp_theme_css) && !empty ($mycourselptheme) && $mycourselptheme != -
     $lp_theme_css = $my_style;
 }
 
-$progress_bar   = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
+$progress_bar   = $_SESSION['oLP']->getProgressBar();
 $navigation_bar = $_SESSION['oLP']->get_navigation_bar();
 $mediaplayer    = $_SESSION['oLP']->get_mediaplayer($autostart);
 

+ 6 - 6
main/tracking/courseLogCSV.php

@@ -118,11 +118,11 @@ if ($is_allowedToTrack) {
                 // BEGIN % visited
                 // sum of all items (= multiple learningpaths + SCORM imported paths)
                 $sql = "SELECT COUNT(DISTINCT(iv.lp_item_id)) FROM $tbl_learnpath_item_view iv " .
-                        "INNER JOIN $tbl_learnpath_view v 
+                        "INNER JOIN $tbl_learnpath_view v
                         ON iv.lp_view_id = v.id " .
                         "WHERE
                         	v.c_id = $course_id AND
-                        	iv.c_id = $course_id AND                        	 
+                        	iv.c_id = $course_id AND
                 		v.user_id = " . $results[$j][0];
                 $total_lpath_items = getOneResult($sql);
 
@@ -130,7 +130,7 @@ if ($is_allowedToTrack) {
                 $sql = "SELECT COUNT(DISTINCT(iv.lp_item_id)) " .
                         "FROM $tbl_learnpath_item_view iv " .
                         "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id = v.id " .
-                        "WHERE 
+                        "WHERE
                         	v.c_id = $course_id AND
                         	iv.c_id = $course_id AND
                         	v.user_id = " . $results[$j][0] . " " .
@@ -272,7 +272,7 @@ if ($is_allowedToTrack) {
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
                     WHERE
                     	cl.c_id = $course_id AND
-                    	sl.links_link_id = cl.id AND 
+                    	sl.links_link_id = cl.id AND
                     	sl.links_cours_id = '$_cid'
                     GROUP BY cl.title, cl.url";
 
@@ -371,7 +371,7 @@ if ($is_allowedToTrack) {
                                         "FROM $tbl_learnpath_item i " .
                                         "INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id " .
                                         "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id " .
-                                        "WHERE 	i.c_id = $course_id AND 
+                                        "WHERE 	i.c_id = $course_id AND
                                         		iv.c_id = $course_id AND
                                         		v.c_id = $course_id AND
                                 				v.user_id=$studentId and v.lp_id=$contentId ORDER BY v.id, i.id";
@@ -380,7 +380,7 @@ if ($is_allowedToTrack) {
                                 $title_line .= get_lang('ScormTitleColumn') . ";" . get_lang('ScormStatusColumn') . ";" . get_lang('ScormScoreColumn') . ";" . get_lang('ScormTimeColumn');
                                 while ($ar3['status'] != '') {
                                     require_once '../newscorm/learnpathItem.class.php';
-                                    $time = learnpathItem::get_scorm_time('php', $ar3['total_time']);
+                                    $time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
                                     $line .= $title . ";" . $ar3['status'] . ";" . $ar3['score'] . ";" . $time;
                                     $ar3 = Database::fetch_array($result3);
                                 }

+ 51 - 60
main/tracking/userLog.php

@@ -7,11 +7,6 @@
  * @package chamilo.tracking
  * @todo clean code - structure is unclear and difficult to modify
  */
-/**
- * Code
- */
-
-/* INIT SECTION */
 
 $uInfo = $_REQUEST['uInfo'];
 $view  = $_REQUEST['view'];
@@ -174,18 +169,16 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
             $offset = 0;
         }
         echo $navLink;
-
-    if (!settype($offset, 'integer') || !settype($step, 'integer')) die('Offset or step variables are not integers.');	//sanity check of integer vars
-        if( $is_allowedToTrackEverybodyInCourse ) {
+    //sanity check of integer vars
+    if (!settype($offset, 'integer') || !settype($step, 'integer')) die('Offset or step variables are not integers.');
+        if ($is_allowedToTrackEverybodyInCourse) {
             // list of users in this course
             $sql = "SELECT u.user_id, u.firstname,u.lastname
                         FROM $TABLECOURSUSER cu , $TABLEUSER u
                         WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
                             AND cu.course_code = '".Database::escape_string($_cid)."'
                         LIMIT $offset,$step";
-        }
-        else
-        {
+        } else {
             // list of users of this group
             $sql = "SELECT u.user_id, u.firstname,u.lastname
                         FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
@@ -198,7 +191,7 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
                     ."<tr align='center' valign='top' bgcolor='#E6E6E6'>\n"
                     ."<td align='left'>",get_lang('UserName'),"</td>\n"
                     ."</tr>\n";
-        for($i = 0 ; $i < sizeof($list_users) ; $i++) {
+        for ($i = 0 ; $i < sizeof($list_users) ; $i++) {
             echo    "<tr valign='top' align='center'>\n"
                     ."<td align='left'>"
                     ."<a href='".api_get_self()."?uInfo=",$list_users[$i][0],"'>"
@@ -206,8 +199,7 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
                     ."</a>".
                     "</td>\n";
         }
-        echo        "</table>\n";
-
+        echo        "</table>";
         echo $navLink;
     } else {
         // if uInfo is set
@@ -225,10 +217,10 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
 
             // check if user is in the group of this tutor
             $sql = "SELECT u.firstname,u.lastname, u.email
-                        FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
-                        WHERE gu.user_id = u.user_id
-                            AND gu.group_id = '".Database::escape_string($_gid)."'
-                            AND u.user_id = '".Database::escape_string($uInfo)."'";
+                    FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
+                    WHERE gu.user_id = u.user_id
+                        AND gu.group_id = '".Database::escape_string($_gid)."'
+                        AND u.user_id = '".Database::escape_string($uInfo)."'";
             $query = Database::query($sql);
             $tracked_user_info = @Database::fetch_assoc($query);
             if(is_array($tracked_user_info)) $tracking_is_accepted = true;
@@ -256,8 +248,8 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
                     "</td>
                 </tr>
             ";
-            if(!isset($view))
-            {
+
+            if(!isset($view)) {
                 $view ='0000000';
             }
             //Logins
@@ -278,7 +270,6 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
             echo get_lang('ErrorUserNotInGroup');
         }
 
-
         /*
          *		Scorm contents and Learning Path
          */
@@ -306,45 +297,46 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
                     echo "<tr><td>";
                     echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."&uInfo=".Security::remove_XSS($uInfo)."' class='specialLink'>$lp_title</a>";
                     echo "</td></tr>";
-                    if ($ar['id']==$scormcontopen) { //have to list the students here
-                            $contentId=$ar['id'];
-                            $sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time " .
-                                    "FROM $tbl_learnpath_item i " .
-                                    "INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id " .
-                                    "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id " .
-                                    "WHERE (v.user_id=".Database::escape_string($uInfo)." and v.lp_id=$contentId) ORDER BY v.id, i.id";
-                               $result3=Database::query($sql3);
+                    if ($ar['id'] == $scormcontopen) {
+                        //have to list the students here
+                        $contentId=$ar['id'];
+                        $sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time " .
+                                "FROM $tbl_learnpath_item i " .
+                                "INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id " .
+                                "INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id " .
+                                "WHERE (v.user_id=".Database::escape_string($uInfo)." and v.lp_id=$contentId) ORDER BY v.id, i.id";
+                        $result3=Database::query($sql3);
+                        $ar3=Database::fetch_array($result3);
+                        if (is_array($ar3)) {
+                            echo "<tr><td>&nbsp;&nbsp;&nbsp;</td>
+                                   <td class='secLine'>
+                                   &nbsp;".get_lang('ScormTitleColumn')."&nbsp;
+                                   </td>
+                                   <td class='secLine'>
+                                   &nbsp;".get_lang('ScormStatusColumn')."&nbsp;
+                                   </td>
+                                   <td class='secLine'>
+                                   &nbsp;".get_lang('ScormScoreColumn')."&nbsp;
+                                   </td>
+                                   <td class='secLine'>
+                                   &nbsp;".get_lang('ScormTimeColumn')."&nbsp;
+                                   </td>
+                                   </tr>";
+                            while ($ar3['status'] != '') {
+                            require_once '../newscorm/learnpathItem.class.php';
+                            $time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']);
+                               echo "<tr><td>&nbsp;&nbsp;&nbsp;</td><td>";
+                               echo "$title</td><td align=right>{$ar3['status']}</td><td align=right>{$ar3['score']}</td><td align=right>$time</td>";
+                               echo "</tr>";
                                $ar3=Database::fetch_array($result3);
-                            if (is_array($ar3)) {
-                                echo "<tr><td>&nbsp;&nbsp;&nbsp;</td>
-                                       <td class='secLine'>
-                                       &nbsp;".get_lang('ScormTitleColumn')."&nbsp;
-                                       </td>
-                                       <td class='secLine'>
-                                       &nbsp;".get_lang('ScormStatusColumn')."&nbsp;
-                                       </td>
-                                       <td class='secLine'>
-                                       &nbsp;".get_lang('ScormScoreColumn')."&nbsp;
-                                       </td>
-                                       <td class='secLine'>
-                                       &nbsp;".get_lang('ScormTimeColumn')."&nbsp;
-                                       </td>
-                                       </tr>";
-                                   while ($ar3['status'] != '') {
-                                    require_once '../newscorm/learnpathItem.class.php';
-                                    $time = learnpathItem::get_scorm_time('php',$ar3['total_time']);
-                                       echo "<tr><td>&nbsp;&nbsp;&nbsp;</td><td>";
-                                       echo "$title</td><td align=right>{$ar3['status']}</td><td     align=right>{$ar3['score']}</td><td align=right>$time</td>";
-                                       echo "</tr>";
-                                       $ar3=Database::fetch_array($result3);
-                                   }
-                            } else {
-                                echo "<tr>";
-                                echo "<td colspan='3'><center>".get_lang('ScormNeverOpened')."</center></td>";
-                                echo"</tr>";
                             }
-                       }
-                    $ar=Database::fetch_array($result);
+                        } else {
+                            echo "<tr>";
+                            echo "<td colspan='3'><center>".get_lang('ScormNeverOpened')."</center></td>";
+                            echo"</tr>";
+                        }
+                    }
+                    $ar = Database::fetch_array($result);
                 }
             } else {
                 $noscorm=true;
@@ -367,11 +359,10 @@ if( ( $is_allowedToTrack || $is_allowedToTrackEverybodyInCourse )) {
                 </tr>
             ";
         }
-
     }
 } else {
     // not allowed
-        api_not_allowed();
+    api_not_allowed();
 }
 ?>
 </table>

+ 13 - 0
plugin/buycourses/lang/english.php

@@ -67,3 +67,16 @@ $strings['TransfersConfig'] = "Bank transfers configuration:";
 $strings['PayPalPaymentOKPleaseConfirm'] = "PayPal reports the transaction is ready to be executed. To acknowledge that you are OK to proceed, please click the confirmation button below. Once clicked, you will be registered to the course and the funds will be transferred from your PayPal account to our shop. You can always access your courses through the 'My courses' tab. Thank you for your custom!";
 $strings['EnrollToSessionXSuccessful'] = "Your subscription to the session is complete";
 $strings['TheUserIsAlreadyRegisteredInTheSession'] = 'You are already registered in the session';
+$strings['Instructions'] = 'Instructions';
+$strings['InstructionsStepOne'] = 'Create a course or session on the platform.';
+$strings['InstructionsStepTwo'] = 'In the <strong>payment settings</strong>, set the currency with which you would like to sell your courses or sessions.';
+$strings['InstructionsStepThree'] = 'Configure courses to sell in the <strong>Courses and prices</strong > settings.';
+$strings['PluginPresentation'] = 'The BuyCourses Plugin gives you the means to sell your courses or sessions and teach online, through only a few simple steps and settings. What are you waiting for? Start selling courses through Chamilo LMS!';
+$strings['TitlePlugin'] = 'Everything you need to teach and sell courses online';
+$strings['PluginInstruction'] = 'You can enable or disable the option to pay via PayPal or bank transfer settings in the configuration section of the plugin.';
+$strings['ClickHere'] = 'Click here for more details';
+$strings['InfoCurrency'] = 'Sets the currency for the payment of your courses.';
+$strings['InfoApiCredentials'] = 'To generate your API credentials to integrate Chamilo with your PayPal account, you must follow the following steps';
+$strings['InfoApiStepOne'] = 'Go to your PayPal account, <strong>Summary</strong>, then <front>Seller preferences</front> in the <front>Selling Tools</front> menu (if you do not have this menu entry, you might need to get the authorization to sell stuff through PayPal first).';
+$strings['InfoApiStepTwo'] = 'In paragraph <strong>API access</strong>, click <strong>Update</strong>';
+$strings['InfoApiStepThree'] = 'In Option 2 (Request API credentials to create your own API username and password), click the <strong>View API Signature</strong> link, and copy the credentials shown right into the BuyCourses plugin form';

+ 13 - 0
plugin/buycourses/lang/french.php

@@ -67,3 +67,16 @@ $strings['TransfersConfig'] = "Configuration des transfers bancaires:";
 $strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nous indique que la transaction est prête à être exécutée. Par mesure de sécurité, nous vous demandons de bien vouloir confirmer une dernière fois la transaction en cliquant sur le bouton de confirmation ci-dessous. Une fois cliqué, vous serez immédiatement enregistré au cours, et les fonds correspondants seront soustraits de votre compte PayPal. Vous pouvez accéder à vos cours à tout moment à partir de l'onglet 'Mes cours'. Merci de votre fidélité!";
 $strings['EnrollToSessionXSuccessful'] = "Votre inscription à la session %s est terminée.";
 $strings['TheUserIsAlreadyRegisteredInTheSession'] = "Vous êtes déjà inscrit à cette session";
+$strings['Instructions'] = 'Instructions d\'utilisation';
+$strings['InstructionsStepOne'] = 'Créer un cours ou une session de formation sur la plateforme.';
+$strings['InstructionsStepTwo'] = 'Dans la section <strong>configuration de paiements</strong>, configurer le type de devise dans lequel vous souhaitez vendre vos cours et sessions';
+$strings['InstructionsStepThree'] = 'Configurer les cours à vendre dans la section <strong>Configuration de cours et prix</strong>';
+$strings['PluginPresentation'] = 'Le plugin BuyCourses vous donne les moyens nécessaires pour vendre vos cours ou vos sessions existants et d\'enseigner en ligne, en quelques étapes très simples. Qu\'attendez-vous? Commencez à vendre des cours grâce à Chamilo dès maintenant!';
+$strings['TitlePlugin'] = 'Tout le nécessaire pour enseigner et vendre des cours en ligne';
+$strings['PluginInstruction'] = 'Vous pouvez activer ou désactiver l\'option de paiements via PayPal ou de transferts bancaires dans la section de configuration des plugins.';
+$strings['ClickHere'] = 'Cliquez ici pour plus d\'infos';
+$strings['InfoCurrency'] = 'Permet configurer le type de devise pour l\'achat des cours.';
+$strings['InfoApiCredentials'] = 'Pour générer vos données API pour intégrer votre compte PayPal à Chamilo, il vous faudra suivre les étapes suivantes';
+$strings['InfoApiStepOne'] = 'Aller dans l\'option <strong>profil</strong> de PayPal, et ensuite dans <strong>Outils de vente</strong>';
+$strings['InfoApiStepTwo'] = 'Dans la section <strong>API d\'accès</strong>, cloquer sur l\'option <strong>Mettre à jour</strong>';
+$strings['InfoApiStepThree'] = 'Dans l\'option 2 de Configuration des données et permissions API, cliquer sur <strong>Voir signature API</strong>. Copier ces donées dans le formulaire de configuration de ce plugin';

+ 13 - 0
plugin/buycourses/lang/spanish.php

@@ -67,3 +67,16 @@ $strings['TransfersConfig'] = "Configuraci&oacute;n de transferencias:";
 $strings['PayPalPaymentOKPleaseConfirm'] = "PayPal nos indicó que todo estaba listo para ejecutar el pago. Por seguridad, le pedimos confirme una última vez su pedido dando clic en el botón de confirmación a bajo. Una vez le haya dado clic, será registrado al curso y el monto correspondiente será retirado de su cuenta PayPal. Siempre puede acceder a sus cursos a partir de la pestaña 'Mis cursos'. Gracias por su compra!";
 $strings['EnrollToSessionXSuccessful'] = "Su inscripción en la sesión %s se ha completado.";
 $strings['TheUserIsAlreadyRegisteredInTheSession'] = 'El usuario ya está registrado en la sesión.';
+$strings['Instructions'] = 'Instrucciones de uso';
+$strings['InstructionsStepOne'] = 'Crea un curso o una sesión de formación en la plataforma.';
+$strings['InstructionsStepTwo'] = 'En la sección <strong>configuración de pagos</strong>, configure el tipo de moneda con el que venderá sus cursos o sesiones.';
+$strings['InstructionsStepThree'] = 'Configure los cursos a vender en la sección <strong>Configuración de cursos y precios</strong>';
+$strings['PluginPresentation'] = 'El Plugin BuyCourses le da los recursos para vender sus cursos o sus sesiones ya creados y enseñar en línea, todo en unos simples pasos y configuraciones. ¿Qué espera? Empiece a vender cursos a través de Chamilo ahora!';
+$strings['TitlePlugin'] = 'Todo lo que necesita para enseñar y vender cursos en línea';
+$strings['PluginInstruction'] = 'Puede activar o desactivar la opción de pagos vía PayPal o configuración de transferencias bancarias, en la sección del configuración del plugin.';
+$strings['ClickHere'] = 'Clic Aquí';
+$strings['InfoCurrency'] = 'Permite configurar el tipo de moneda (de pago) para sus cursos.';
+$strings['InfoApiCredentials'] = 'Para generar tu credenciales API para integrar su cuenta PayPal con Chamilo LMS, deberá seguir los siguientes pasos';
+$strings['InfoApiStepOne'] = 'Ir a la opción de <strong>Perfil de PayPal</strong>, luego en <strong>Mis herramientas de venta</strong>';
+$strings['InfoApiStepTwo'] = 'En el apartado <strong>Acceso API</strong>, dar clic en la opción <strong>Actualizar</strong>';
+$strings['InfoApiStepThree'] = 'En la opción 2, de Configuración de credenciales y permisos de API, dar clic en <strong>Ver firma de API</strong>. Copiar los datos de las credenciales en el formulario de configuración de este plugin';

+ 117 - 0
plugin/buycourses/resources/css/style.css

@@ -0,0 +1,117 @@
+.thumbnail .caption{
+	text-align: center;
+}
+.cleared {
+    content: ".";
+    display: block;
+    height: 0;
+    clear: both;
+    visibility: hidden;
+    line-height: 0;
+}
+table .bg-color{
+	background-color: #E5EDF9;
+	color: #333;
+}
+table td.ta-center, table th.ta-center {
+    text-align: center;
+}
+
+#courses_table td, #transfer_table td, #order_table td {
+    vertical-align: middle;
+}
+
+#courses_table td input.price, #transfer_table td input, #currency_type {
+    margin: 0;
+}
+
+#courses_table td.btop {
+    border-top: 1px solid #C5DEEB;
+    border-bottom: 1px solid #C5DEEB;
+}
+
+#courses_table tr.fmod {
+    border: 1px solid #C5DEEB;
+    background: #C5DEEB;
+}
+
+.sprice {
+    color: #4D984E;
+    font-size: 18px;
+    font-weight: bold;
+    margin: 15px 0;
+}
+
+.dinline {
+    display: inline;
+}
+
+.fright {
+    float: right;
+}
+
+.cursor {
+    cursor: pointer;
+}
+
+.ta-center {
+    text-align: center;
+}
+
+textarea#message {
+    width: 50%;
+}
+
+.send_result {
+    font-weight: bold;
+}
+
+select#lsessions, select#lcourses, select#lexercises, select#status {
+    margin-bottom: 0px;
+}
+
+.column_field_filter {
+    padding: 6px 10px 1px 1px;
+    text-align: right;
+}
+
+.height5 {
+    height: 5px;
+}
+
+.margin-left-fifty{
+    margin-left: 50px !important;
+}
+#course_category_well h4{
+	padding-left: 0;
+}
+#course_category_well .form-content{
+	padding-left: 1em;
+	padding-right: 1em;
+}
+#course_category_well .btn{
+	width: 100%;
+	line-height: 30px;
+	font-size: 16px;
+}
+.icon-course .thumbnail{
+	border: none;
+	box-shadow: none;
+}
+.well-course{
+	padding-top: 1em;
+	padding-bottom: 1em;
+	border-bottom: 1px solid #D3E6F0;
+}
+.ui-widget-content .well-course a, .ui-widget-content .well-course a:hover{
+	color: #fff;
+}
+.label-info, .badge-info {
+  background-color: #53a0c6;
+  font-weight: normal;
+}
+.categories-course-description h3 {
+  color: #666;
+  font-weight: bold;
+  font-family: Arial;
+}

BIN
plugin/buycourses/resources/img/128/accept.png


BIN
plugin/buycourses/resources/img/128/backlogs.png


BIN
plugin/buycourses/resources/img/128/buycourses.png


BIN
plugin/buycourses/resources/img/128/paymentsettings.png


BIN
plugin/buycourses/resources/img/128/settings.png


BIN
plugin/buycourses/resources/img/32/accept.png


BIN
plugin/buycourses/resources/img/32/backlogs.png


BIN
plugin/buycourses/resources/img/32/buycourses.png


BIN
plugin/buycourses/resources/img/32/delete.png


BIN
plugin/buycourses/resources/img/32/new.png


BIN
plugin/buycourses/resources/img/32/paymentsettings.png


BIN
plugin/buycourses/resources/img/32/save.png


BIN
plugin/buycourses/resources/img/32/settings.png


BIN
plugin/buycourses/resources/img/42/backlogs.png


BIN
plugin/buycourses/resources/img/42/buycourses.png


BIN
plugin/buycourses/resources/img/42/paymentsettings.png


BIN
plugin/buycourses/resources/img/42/settings.png


BIN
plugin/buycourses/resources/img/64/backlogs.png


BIN
plugin/buycourses/resources/img/64/buycourses.png


BIN
plugin/buycourses/resources/img/64/paymentsettings.png


BIN
plugin/buycourses/resources/img/64/settings.png


+ 2 - 0
plugin/buycourses/src/buy_course_plugin.class.php

@@ -5,6 +5,7 @@
  * @package chamilo.plugin.buycourses
  * @author Jose Angel Ruiz    <jaruiz@nosolored.com>
  * @author Imanol Losada      <imanol.losada@beeznest.com>
+ * @author Alex Aragón      <alex.aragon@beeznest.com>
  */
 /**
  * Plugin class for the BuyCourses plugin
@@ -27,6 +28,7 @@ class BuyCoursesPlugin extends Plugin
             '1.0',
             'Jose Angel Ruiz - NoSoloRed (original author),
             Francis Gonzales and Yannick Warnier - BeezNest (integration),
+            Alex Aragón - BeezNest (Design icons and css styles),
             Imanol Losada - BeezNest (introduction of sessions purchase)',
             array(
                 'include_sessions' => 'boolean',

+ 2 - 2
plugin/buycourses/src/configuration.php

@@ -33,8 +33,8 @@ if ($teacher) {
     $visibility[] = getCourseVisibilityIcon('3');
 
     $coursesList = listCourses();
-    $confirmationImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/message_confirmation.png';
-    $saveImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/save.png';
+    $confirmationImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/img/32/accept.png';
+    $saveImgPath = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/img/32/save.png';
     $currencyType = findCurrency();
 
     $tpl->assign('server', $_configuration['root_web']);

+ 2 - 2
plugin/buycourses/src/paymentsetup.php

@@ -28,8 +28,8 @@ if ($teacher) {
 
     $confirmationImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/message_confirmation.png';
     $saveImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/save.png';
-    $moreImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/more.png';
-    $deleteImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/delete.png';
+    $moreImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/img/32/new.png';
+    $deleteImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/img/32/delete.png';
     $showImg = api_get_path(WEB_PLUGIN_PATH) . 'buycourses/resources/acces_tool.gif';
 
     $paypalEnable = $plugin->get('paypal_enable');

+ 12 - 12
plugin/buycourses/view/configuration.tpl

@@ -1,6 +1,6 @@
 <script type='text/javascript' src="../js/buycourses.js"></script>
 
-<link rel="stylesheet" type="text/css" href="../resources/plugin.css"/>
+<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/>
 
 <script>
 $(function() {
@@ -22,11 +22,11 @@ $(function() {
     <div class="span12">
         <table id="courses_table" class="data_table">
             <tr class="row_odd">
-                <th>{{ 'Title'|get_lang }}</th>
-                <th>{{ 'OfficialCode'|get_lang }}</th>
-                <th class="ta-center">{{ 'Visible'|get_lang }}</th>
-                <th class="span2">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th>
-                <th class="span1 ta-center">{{ 'Option'|get_lang }}</th>
+                <th class="bg-color">{{ 'Title'|get_lang }}</th>
+                <th class="bg-color">{{ 'OfficialCode'|get_lang }}</th>
+                <th class="ta-center bg-color">{{ 'Visible'|get_lang }}</th>
+                <th class="span2 bg-color">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th>
+                <th class="span1 ta-center bg-color">{{ 'Option'|get_lang }}</th>
             </tr>
             {% set i = 0 %}
 
@@ -64,12 +64,12 @@ $(function() {
     <div class="span12">
         <table id="courses_table" class="data_table">
             <tr class="row_odd">
-                <th>{{ 'Title'|get_lang }}</th>
-                <th>{{ 'StartDate'|get_lang }}</th>
-                <th>{{ 'EndDate'|get_lang }}</th>
-                <th class="ta-center">{{ 'Visible'|get_lang }}</th>
-                <th class="span2">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th>
-                <th class="span1 ta-center">{{ 'Option'|get_lang }}</th>
+                <th class="bg-color">{{ 'Title'|get_lang }}</th>
+                <th class="bg-color">{{ 'StartDate'|get_lang }}</th>
+                <th class="bg-color">{{ 'EndDate'|get_lang }}</th>
+                <th class="bg-color ta-center">{{ 'Visible'|get_lang }}</th>
+                <th class="bg-color span2">{{ 'Price'|get_plugin_lang('BuyCoursesPlugin') }}</th>
+                <th class="bg-color span1 ta-center">{{ 'Option'|get_lang }}</th>
             </tr>
             {% set i = 0 %}
 

+ 61 - 17
plugin/buycourses/view/index.tpl

@@ -1,19 +1,63 @@
-<div class="well sidebar-nav static normal-message">
-    <h4> {{title}} </h4>
-    <ul class="nav nav-list">
-        <li>
-            <a href="src/list.php"> {{ BuyCourses }} </a>
-        </li>        
+<link rel="stylesheet" type="text/css" href="resources/css/style.css"/>
+<div class="row">
+    <div class="span12">
+        <div class="row">
         {% if isAdmin == 'true' %}
-        <li>
-            <a href="src/configuration.php"> {{ ConfigurationOfCoursesAndPrices }} </a>
-        </li>
-        <li>
-            <a href="src/paymentsetup.php"> {{ ConfigurationOfPayments }} </a>
-        </li>
-        <li>
-            <a href="src/pending_orders.php"> {{ OrdersPendingOfPayment }} </a>
-        </li>
+            <div class="span12">
+                <div>
+                    <h2>{{ 'TitlePlugin'|get_plugin_lang('BuyCoursesPlugin') }}</h2>
+                    <p>{{ 'PresentationPlugin'|get_plugin_lang('BuyCoursesPlugin') }}</p>
+                </div>
+                <div class="normal-message">
+                    <h3>{{ 'Instructions'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
+                    <ul>
+                        <li>{{ 'InstructionsStep1'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+                        <li>{{ 'InstructionsStep2'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+                        <li>{{ 'InstructionsStep3'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+                    </ul>
+                </div>
+            </div>
         {% endif %}
-    </ul>
-</div>
+            <div class="span12">
+                
+            </div>
+        </div>
+        <div class="row">
+            
+            <div class="span3">
+                <div class="thumbnail">
+                    <img src="resources/img/128/buycourses.png">
+                    <div class="caption">
+                        <a class="btn" href="src/list.php">{{ BuyCourses }}</a>
+                    </div>
+                </div>
+            </div>
+            {% if isAdmin == 'true' %}
+            <div class="span3">
+                <div class="thumbnail">
+                    <img src="resources/img/128/settings.png">
+                    <div class="caption">
+                        <a class="btn" href="src/configuration.php">{{ ConfigurationOfCoursesAndPrices }}</a>
+                    </div>
+                </div>
+            </div>
+            <div class="span3">
+                <div class="thumbnail">
+                    <img src="resources/img/128/paymentsettings.png">
+                    <div class="caption">
+                        <a class="btn" href="src/paymentsetup.php">{{ ConfigurationOfPayments }} </a>
+                    </div>
+                </div>
+            </div>
+            <div class="span3">
+                <div class="thumbnail">
+                    <img src="resources/img/128/backlogs.png">
+                    <div class="caption">
+                        <a class="btn" href="src/pending_orders.php"> {{ OrdersPendingOfPayment }} </a>
+                    </div>
+                </div>
+            </div>
+            {% endif %}
+        </div>
+    </div>
+</div>

+ 49 - 59
plugin/buycourses/view/list.tpl

@@ -1,6 +1,6 @@
 <script type='text/javascript' src="../js/buycourses.js"></script>
 
-<link rel="stylesheet" type="text/css" href="../resources/plugin.css"/>
+<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/>
 
 <script>
 $(function() {
@@ -18,33 +18,28 @@ $(function() {
     <div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs"> <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"> <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"> <a href="#tabs-1">{{ 'Courses'|get_lang }}</a></li><li class="ui-state-default ui-corner-top"> <a href="#tabs-2">{{ 'Sessions'|get_lang }}</a></li></ul>
 {% endif %}
 
-<div id="tabs-1" class="row">
+<div id="tabs-1">
+<div class="row">
     <div class="span3">
         <div id="course_category_well" class="well">
-            <ul class="nav nav-list">
-                <li class="nav-header"><h4>{{ 'SearchFilter'|get_plugin_lang('BuyCoursesPlugin') }}:</h4></li>
-                <li class="nav-header">{{ 'CourseName'|get_lang }}:</li>
-                <li><input type="text" id="course_name" style="width:95%"/></li>
-                <li class="nav-header">{{ 'MinimumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:
-                    <input type="text" id="price_min" class="span1"/>
-                </li>
-                <li class="nav-header">{{ 'MaximumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:
-                    <input type="text" id="price_max" class="span1"/>
-                </li>
-                <li class="nav-header">{{ 'Categories'|get_lang }}:</li>
-                <li>
-                    <select id="courses_category">
-                        <option value="" selected="selected"></option>
-                        {% for category in categories %}
-                            <option value="{{ category.code }}">{{ category.name }}</option>
-                        {% endfor %}
-                    </select>
-                </li>
-                <br />
-                <li class="ta-center">
-                    <input type="button" class="btn btn-primary" value="{{ 'Search'|get_lang }}" id="confirm_filter" />
-                </li>
-            </ul>
+            <div class="form-content">
+                <h4>{{ 'SearchFilter'|get_plugin_lang('BuyCoursesPlugin') }}:</h4>
+                <label class="control-label">{{ 'CourseName'|get_lang }}:</label>
+                <input type="text" id="course_name" />
+                <label class="control-label">{{ 'MinimumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:</label>
+                <input type="text" id="price_min" class="span1"/>
+                <label class="control-label">{{ 'MaximumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:</label>
+                <input type="text" id="price_max" class="span1"/>
+                    {% for category in categories %}
+                        <label class="control-label">{{ 'Categories'|get_lang }}:</label>
+                        <select id="courses_category">
+                            <option value="" selected="selected"></option>
+                                <option value="{{ category.code }}">{{ category.name }}</option>
+                        </select>
+                    {% endfor %}
+                <br>
+                 <input type="button" class="btn btn-primary" value="{{ 'Search'|get_lang }}" id="confirm_filter" />
+            </div>
         </div>
     </div>
     <div class="span8" id="course_results">
@@ -54,16 +49,16 @@ $(function() {
             </div>
         {% endif %}
         {% for course in courses %}
-            <div class="well_border span8">
-                <div class="row">
-                    <div class="span">
+            <div class="span8">
+                <div class="row well-course">
+                    <div class="span1 icon-course">
                         <div class="thumbnail">
                             <a class="ajax" rel="gb_page_center[778]" title="" href="{{ server }}plugin/buycourses/src/ajax.php?code={{ course.code }}">
                                 <img alt="" src="{{ server }}{{ course.course_img }}">
                             </a>
                         </div>
                     </div>
-                    <div class="span4">
+                    <div class="span3">
                         <div class="categories-course-description">
                             <h3>{{ course.title }}</h3>
                             <h5>{{ 'Teacher'|get_lang }}: {{ course.teacher }}</h5>
@@ -75,12 +70,12 @@ $(function() {
                             <span class="label label-warning">{{ 'WaitingToReceiveThePayment'|get_plugin_lang('BuyCoursesPlugin') }}</span>
                         {% endif %}
                     </div>
-                    <div class="span right">
+                    <div class="span3 right">
                         <div class="sprice right">
                             {{ course.price }} {{ currency }}
                         </div>
                         <div class="cleared"></div>
-                        <div class="btn-toolbar right">
+                        <div class="btn-group right">
                             <a class="ajax btn btn-primary" title="" href="{{ server }}plugin/buycourses/src/ajax.php?code={{ course.code }}">
                                 {{ 'Description'|get_lang }}
                             </a>
@@ -96,34 +91,29 @@ $(function() {
         {% endfor %}
     </div>
 </div>
+</div>
 {% if sessionsAreIncluded == "YES" %}
 <div id="tabs-2" class="row">
     <div class="span3">
         <div id="course_category_well" class="well">
-            <ul class="nav nav-list">
-                <li class="nav-header"><h4>{{ 'SearchFilter'|get_plugin_lang('BuyCoursesPlugin') }}:</h4></li>
-                <li class="nav-header">{{ 'SessionName'|get_lang }}:</li>
-                <li><input type="text" id="session_name" style="width:95%"/></li>
-                <li class="nav-header">{{ 'MinimumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:
-                    <input type="text" id="session_price_min" class="span1"/>
-                </li>
-                <li class="nav-header">{{ 'MaximumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:
-                    <input type="text" id="session_price_max" class="span1"/>
-                </li>
-                <li class="nav-header">{{ 'Categories'|get_lang }}:</li>
-                <li>
-                    <select id="sessions_category">
-                        <option value="" selected="selected"></option>
-                        {% for category in categories %}
-                            <option value="{{ category.code }}">{{ category.name }}</option>
-                        {% endfor %}
-                    </select>
-                </li>
-                <br />
-                <li class="ta-center">
-                    <input type="button" class="btn btn-primary" value="{{ 'Search'|get_lang }}" id="confirm_session_filter" />
-                </li>
-            </ul>
+            <div class="form-content">
+                <h4>{{ 'SearchFilter'|get_plugin_lang('BuyCoursesPlugin') }}:</h4>
+                <label class="control-label">{{ 'CourseName'|get_lang }}:</label>
+                <input type="text" id="course_name" />
+                <label class="control-label">{{ 'MinimumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:</label>
+                <input type="text" id="price_min" class="span1"/>
+                <label class="control-label">{{ 'MaximumPrice'|get_plugin_lang('BuyCoursesPlugin') }}:</label>
+                <input type="text" id="price_max" class="span1"/>
+                    {% for category in categories %}
+                        <label class="control-label">{{ 'Categories'|get_lang }}:</label>
+                        <select id="courses_category">
+                            <option value="" selected="selected"></option>
+                                <option value="{{ category.code }}">{{ category.name }}</option>
+                        </select>
+                    {% endfor %}
+                <br>
+                 <input type="button" class="btn btn-primary" value="{{ 'Search'|get_lang }}" id="confirm_filter" />
+            </div>
         </div>
     </div>
     <div class="span8" id="session_results">
@@ -133,7 +123,7 @@ $(function() {
             </div>
         {% endif %}
         {% for session in sessions %}
-            <div class="well_border span8">
+            <div class="span8 well-course">
                 <div class="row">
                     <div class="span4 ">
                         <div class="categories-course-description">
@@ -152,7 +142,7 @@ $(function() {
                             {{ session.price }} {{ currency }}
                         </div>
                         <div class="cleared"></div>
-                        <div class="btn-toolbar right">
+                        <div class="btn-group right">
                             {% if session.enrolled == "NO" %}
                                 <a class="btn btn-success" title="" href="{{ server }}plugin/buycourses/src/process.php?scode={{ session.session_id }}">
                                     {{ 'Buy'|get_plugin_lang('BuyCoursesPlugin') }}
@@ -184,7 +174,7 @@ $(function() {
                         </div>
                         <div class="span right">
                             <div class="cleared"></div>
-                            <div class="btn-toolbar right">
+                            <div class="btn-group right">
                                 <a class="ajax btn btn-primary" title="" href="{{ server }}plugin/buycourses/src/ajax.php?code={{ course.code }}">
                                     {{ 'Description'|get_lang }}
                                 </a>

+ 54 - 20
plugin/buycourses/view/paymentsetup.tpl

@@ -1,11 +1,22 @@
 <script type='text/javascript' src="../js/buycourses.js"></script>
 
-<link rel="stylesheet" type="text/css" href="../resources/plugin.css"/>
-
+<link rel="stylesheet" type="text/css" href="../resources/css/style.css"/>
 <div class="row">
     <div class="span12">
-        <h3>{{ 'CurrencyType'|get_plugin_lang('BuyCoursesPlugin') }}:</h3>
-        <select id="currency_type">
+        <p class="normal-message">{{ 'PluginInstruction'|get_plugin_lang('BuyCoursesPlugin') }}<a href="{{ server }}main/admin/configure_plugin.php?name=buycourses">{{ 'ClickHere'|get_plugin_lang('BuyCoursesPlugin') }}</a></p>
+    </div>
+</div>
+<div class="row">
+    <div class="span6">
+        <div class="info">
+            
+
+            <h3>{{ 'CurrencyType'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
+            <p>{{ 'InfoCurrency'|get_plugin_lang('BuyCoursesPlugin') }}</p>
+
+        </div>
+        <div class="input-content">
+            <select id="currency_type">
             <option value="" selected="selected">{{ 'SelectACurrency'|get_plugin_lang('BuyCoursesPlugin') }}</option>
             {% for currency in currencies %}
                 {% if currency.status == 1 %}
@@ -17,31 +28,54 @@
             {% endfor %}
         </select>
         <input type="button" id="save_currency" class="btn btn-primary" value="{{ 'Save'|get_lang }}" />
-
-        {% if paypal_enable == "true" %}
-            <hr />
+        </div>
+    </div>
+    {% if paypal_enable == "true" %}
+    <div class="span6">
+        <div class="info">
             <h3>{{ 'PayPalConfig'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
-                {% if paypal.sandbox == "YES" %}
-                    {{ 'Sandbox'|get_plugin_lang('BuyCoursesPlugin') }}: <input type="checkbox" id="sandbox" value="YES" checked="checked"/>
+        </div>
+         <div class="input-content">
+            
+            <p>{{ 'InfoApiCredentials'|get_plugin_lang('BuyCoursesPlugin') }}</p>
+            <ul>
+                <li>{{ 'InfoApiStepOne'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+                <li>{{ 'InfoApiStepTwo'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+                <li>{{ 'InfoApiStepThree'|get_plugin_lang('BuyCoursesPlugin') }}</li>
+            </ul>
+            <label class="control-label">API_UserName: </label><input type="text" id="username" value="{{ paypal.username | e}}" />
+            <label class="control-label">API_Password: </label><input type="text" id="password" value="{{ paypal.password | e }}"/>
+            <label class="control-label">API_Signature: </label> <input type="text" id="signature" value="{{ paypal.signature | e }}"/>
+           
+            {% if paypal.sandbox == "YES" %}
+                    <label class="checkbox">
+                        <input type="checkbox" id="sandbox" value="YES" checked="checked"> {{ 'Sandbox'|get_plugin_lang('BuyCoursesPlugin') }}
+                    </label>
                 {% else %}
-                    {{ 'Sandbox'|get_plugin_lang('BuyCoursesPlugin') }}: <input type="checkbox" id="sandbox" value="YES" />
-                {% endif %}
-            <br />
-            API_UserName: <input type="text" id="username" value="{{ paypal.username | e}}" /><br/>
-            API_Password: <input type="text" id="password" value="{{ paypal.password | e }}"/><br/>
-            API_Signature: <input type="text" id="signature" value="{{ paypal.signature | e }}"/><br/>
+                    <label class="checkbox">
+                        <input type="checkbox" id="sandbox" value="YES" />{{ 'Sandbox'|get_plugin_lang('BuyCoursesPlugin') }}
+                    </label>
+                     
+            {% endif %}
+            
             <input type="button" id="save_paypal" class="btn btn-primary" value="{{ 'Save'|get_lang }}"/>
-        {% endif %}
+         </div>
+    </div>
+    {% endif %}
+</div>
 
+<div class="row">
+    <div class="span12">
+        
         {% if transfer_enable == "true" %}
             <hr />
             <h3>{{ 'TransfersConfig'|get_plugin_lang('BuyCoursesPlugin') }}</h3>
             <table id="transfer_table" class="data_table">
                 <tr class="row_odd">
-                <th>{{ 'Name'|get_lang }}</th>
-                <th>{{ 'BankAccount'|get_plugin_lang('BuyCoursesPlugin') }}</th>
-                <th>{{ 'SWIFT'|get_lang }}</th>
-                <th class="span1 ta-center">{{ 'Option'|get_lang }}</th>
+                <th class="bg-color">{{ 'Name'|get_lang }}</th>
+                <th class="bg-color">{{ 'BankAccount'|get_plugin_lang('BuyCoursesPlugin') }}</th>
+                <th class="bg-color">{{ 'SWIFT'|get_lang }}</th>
+                <th class="span1 ta-center bg-color">{{ 'Option'|get_lang }}</th>
                 </tr>
                 {% set i = 0 %}
 

Some files were not shown because too many files changed in this diff