Sfoglia il codice sorgente

Slight improvement in top window selector for API and comments - refs #3343

Yannick Warnier 12 anni fa
parent
commit
1ac878fdff
2 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 3 2
      main/exercice/savescores.php
  2. 6 3
      main/newscorm/learnpathItem.class.php

+ 3 - 2
main/exercice/savescores.php

@@ -84,7 +84,8 @@ function save_scores($file, $score) {
                 //API_obj = window.frames.window.content.API;
                 //API_obj = $('content_id').context.defaultView.content.API; //works only in FF
                 //console.log(window.parent.frames.window.top.API);
-                API_obj = window.parent.frames.window.top.API;
+                //API_obj = window.parent.frames.window.top.API;
+                API_obj = window.top.API;
                 API_obj.void_save_asset('$score', '$weighting', 0, 'completed');
             });
         </script>";
@@ -104,4 +105,4 @@ if ($origin != 'learnpath') {
     Display::display_reduced_header();
     Display::display_confirmation_message(get_lang('HotPotatoesFinished'));
     Display::display_footer();
-}
+}

+ 6 - 3
main/newscorm/learnpathItem.class.php

@@ -1118,21 +1118,24 @@ class learnpathItem {
 	 * @return	integer	Total time
 	 */
 	public function get_total_time() {
-		if (self::debug > 0) { error_log('learnpathItem::get_total_time()', 0); }
+		if (self::debug > 0) { error_log('learnpathItem::get_total_time() for item '.$this->db_id.' - Initially, current_start_time = '.$this->current_start_time.' and current_stop_time = '.$this->current_stop_time, 0); }
 		if ($this->current_start_time == 0) { // Shouldn't be necessary thanks to the open() method.
+			if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Current start time was empty', 0); }
 			$this->current_start_time = time();
 		}
 		//$this->current_stop_time=time();
-		if (time() < $this->current_stop_time) {
+		if (time() < $this->current_stop_time or $this->current_stop_time == 0) {
+			if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Current stop time was greater than the current time or was empty', 0); }
 			// If this case occurs, then we risk to write huge time data in db.
 			// In theory, stop time should be *always* updated here, but it might be used in some unknown goal.
 			$this->current_stop_time = time();
 		}
 		$time = $this->current_stop_time - $this->current_start_time;
 		if ($time < 0) {
+			if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Time smaller than 0. Returning 0', 0); }
 			return 0;
 		} else {
-			if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Current stop time = '.$this->current_stop_time.', current start time = '.$this->current_start_time.' Returning '.$time, 0); }
+			if (self::debug > 2) { error_log('learnpathItem::get_total_time() - Current start time = '.$this->current_start_time.', current stop time = '.$this->current_stop_time.' Returning '.$time."-----------\n", 0); }
 			return $time;
 		}
 	}