<?php

class Upgrade_Scorm extends Upgrade {
	
	var $platfom = 'lms';
	
	var $mname = 'scorm';
	
	/**
	 * upgrade the module version
	 * @param string 	$start_version 	the start version, automaticaly prooceed to the next
	 *
	 * @return mixed 	true if the version jump was successful, else an array with an error code and an error message
	 * 					array( 'error_code', 'error_msg' )
	 **/
	function oneStepUpgrade($start_version) {
		
		switch($start_version) {
			case "2.0.4" : {
				
				$query = "
				SELECT idscorm_package, path 
				FROM learning_scorm_package";
				$result = $this->db_man->query($query);
				
				while(list($id, $path) = $this->db_man->fetchRow($result)) {
					
					$new_path = substr($path, (strrpos($path, '/') + 1));
					
					$query = "
					UPDATE learning_scorm_package
					SET path = '".$new_path."'
					WHERE idscorm_package = '".$id."'";
					$re = $this->db_man->query($query);
				}
				
				
				$this->end_version = '3.0';
				return true;
			};break;
			
		}
		return true;
	}
}

?>