Noel Dieschburg преди 13 години
родител
ревизия
ab0af849a2

+ 5 - 0
custompages/url-images/README

@@ -0,0 +1,5 @@
+Custom Pages : URL Images
+
+This features allows each access URL to have a number of images (currently three) specific to this URL. This allows easier customization of landing pages by access URL.
+
+You can access a URL's images by calling the static function CustomPages::getURLImages() in your custom page.

+ 33 - 0
main/admin/access_url_edit.php

@@ -43,6 +43,19 @@ if( $form->validate()) {
 			} else {
 				UrlManager::udpate($url_id, $url.'/', $description, $active);
 			}
+			// URL Images
+			$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
+			$image_fields = array("url_image_1", "url_image_2", "url_image_3");
+			foreach ($image_fields as $image_field) {
+				if ($_FILES[$image_field]['error'] == 0) {
+					// Hardcoded: only PNG files allowed
+					if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') {
+						move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png');
+					}
+					// else fail silently
+				}
+				// else fail silently
+			}
 			$url_to_go='access_urls.php';
 			$message=get_lang('URLEdited');
 		} else {
@@ -61,6 +74,21 @@ if( $form->validate()) {
 				$url_to_go='access_url_edit.php';
 				$message = get_lang('URLAlreadyAdded');
 			}
+			// URL Images
+			$url .= (substr($url,strlen($url)-1, strlen($url))=='/') ? '' : '/';
+			$url_id = UrlManager::get_url_id($url);
+			$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
+			$image_fields = array("url_image_1", "url_image_2", "url_image_3");
+			foreach ($image_fields as $image_field) {
+				if ($_FILES[$image_field]['error'] == 0) {
+					// Hardcoded: only PNG files allowed
+					if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') {
+						move_uploaded_file($_FILES[$image_field]['tmp_name'], $url_images_dir.$url_id.'_'.$image_field.'.png');
+					}
+					// else fail silently
+				}
+				// else fail silently
+			}
 		}
 		Security::clear_token();
 		$tok = Security::get_token();
@@ -122,6 +150,11 @@ if (isset ($_GET['action'])) {
 	}
 }
 
+// URL Images
+$form->addElement('file','url_image_1','URL Image 1 (PNG)');
+$form->addElement('file','url_image_2','URL Image 2 (PNG)');
+$form->addElement('file','url_image_3','URL Image 3 (PNG)');
+
 // Submit button
 $form->addElement('style_submit_button', 'submit', $submit_name, 'class="add"');
 $form->display();

+ 37 - 0
main/auth/conditional_login/first_login.php

@@ -0,0 +1,37 @@
+<?php
+require_once(dirname(__FILE__).'/../../inc/global.inc.php');
+require_once (api_get_path(LIBRARY_PATH).'conditionallogin.lib.php');
+require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+//Don't forget to change the url with the name of your file
+$url =  api_get_path(WEB_PATH).'main/auth/conditional_login/first_login.php';
+
+if (! isset($_SESSION['conditional_login']['uid']))
+  die("Not Authorised");
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
+  </head>
+  <body>
+  <h1> First login </h1>
+  <p> This is your first login please complete those fields : </p>
+  <form id="data_completion" name="data_completion" method="post" action="<?php echo $url?>">
+        Téléphone : <input type="text" name="phone_number" />
+        <input type="submit" name="submit" value="Submit" />
+    </form>
+  </body>
+</html>
+<?php
+if (isset($_POST['submit'])){
+  $u = UserManager::get_user_info_by_id($_SESSION['conditional_login']['uid']);
+  $u['phone'] = $_POST['phone_number'];
+  $password = null; // we don't want to change the password 
+  $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], $password, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'],'');
+
+  if ($updated) {
+    UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');
+    ConditionalLogin::login();
+  }
+}
+?>

BIN
main/img/gamepad.gif


+ 3 - 2
main/inc/lib/add_course.lib.inc.php

@@ -1218,8 +1218,9 @@ function update_Db_course($course_db_name) {
         "author         varchar(255)        not null default '', " .        // stores the theme of the LP
         "session_id     int unsigned        not null default 0, " .         // the session_id
 	"prerequisite  	int	unsigned not null  default 0," . // pre requisite for next lp
-        "hide_toc_frame tinyint NOT NULL DEFAULT 0,".
-        "use_max_score  int unsigned        not null default 1, " .         // max scores for scorm packages
+	"hide_toc_frame tinyint NOT NULL DEFAULT 0".
+        "seriousgame_mode tinyint NOT NULL DEFAULT 0".
+        "use_max_score  int unsigned        not null default 1, " .
         "autolunch      int unsigned        not null default 0, " .          // auto lunch LP
         "created_on     DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .          // auto lunch LP
         "modified_on    DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', " .          // auto lunch LP

+ 17 - 0
main/inc/lib/custompages.lib.php

@@ -3,6 +3,8 @@
 // Used to implement the loading of custom pages
 // 2011, Jean-Karim Bockstael <jeankarim@cblue.be>
 
+require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
+
 class CustomPages {
 	
 	public static function displayPage($page_name) {
@@ -16,5 +18,20 @@ class CustomPages {
 			error_log('CustomPages::displayPage : could not read file '.$file_name);
 		}
 	}
+
+	public static function getURLImages($url_id = null) {
+		if (is_null($url_id)) {
+			$url = 'http://'.$_SERVER['HTTP_HOST'].'/';
+			$url_id = UrlManager::get_url_id($url);
+		}
+		$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
+		$images = array();
+		for ($img_id = 1; $img_id <= 3; $img_id++) {
+			 if (file_exists($url_images_dir.$url_id.'_url_image_'.$img_id.'.png')) {
+			 	$images[] = api_get_path(WEB_PATH).'custompages/url-images/'.$url_id.'_url_image_'.$img_id.'.png';
+			 }
+		}
+		return $images;
+	}
 }
 ?>

+ 9 - 5
main/install/db_main.sql

@@ -841,11 +841,11 @@ VALUES
 ('teacher_autosubscribe', NULL, 'textfield', 'Platform', '', 'TeacherAutosubscribeTitle', 'TeacherAutosubscribeComment', NULL, NULL, 0),
 ('DRH_autosubscribe', NULL, 'textfield', 'Platform', '', 'DRHAutosubscribeTitle', 'DRHAutosubscribeComment', NULL, NULL, 0),
 ('sessionadmin_autosubscribe', NULL, 'textfield', 'Platform', '', 'SessionadminAutosubscribeTitle', 'SessionadminAutosubscribeComment', NULL, NULL, 0),
-('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
+('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1),
 ('show_tabs', 'custom_tab_2', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom2', 1),
 ('show_tabs', 'custom_tab_3', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom3', 1),
-('custom_tab_1_name', NULL, 'textfield', 'Platform', '', 'CustomTab1NameTitle', 'CustomTab1NameComment', NULL, NULL, 0),
-('custom_tab_1_url', NULL, 'textfield', 'Platform', '', 'CustomTab1URLTitle', 'CustomTab1URLComment', NULL, NULL, 0),
+('custom_tab_1_name', NULL, 'textfield', 'Platform', 'Reports', 'CustomTab1NameTitle', 'CustomTab1NameComment', NULL, NULL, 0),
+('custom_tab_1_url', NULL, 'textfield', 'Platform', '/main/reports/', 'CustomTab1URLTitle', 'CustomTab1URLComment', NULL, NULL, 0),
 ('custom_tab_2_name', NULL, 'textfield', 'Platform', '', 'CustomTab2NameTitle', 'CustomTab2NameComment', NULL, NULL, 0),
 ('custom_tab_2_url', NULL, 'textfield', 'Platform', '', 'CustomTab2URLTitle', 'CustomTab2URLComment', NULL, NULL, 0),
 ('custom_tab_3_name', NULL, 'textfield', 'Platform', '', 'CustomTab3NameTitle', 'CustomTab3NameComment', NULL, NULL, 0),
@@ -855,8 +855,11 @@ VALUES
 ('languagePriority3', NULL, 'radio', 'Languages','user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0), 
 ('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang','LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0),
 ('activate_send_event_by_mail', NULL, 'radio', 'Platform', 'false', 'ActivateSendEventByMailTitle', 'ActivateSendEventByMailComment', NULL, NULL, 0),
+('scorm_cumulative_session_time', NULL, 'radio', 'Course', 'true', 'ScormCumulativeSessionTimeTitle', 'ScormCumulativeSessionTimeComment', NULL, NULL, 0),
 ('chamilo_database_version',NULL,'textfield',NULL, '1.8.8.14519','DokeosDatabaseVersion','', NULL, NULL, 0);
 
+
+
 UNLOCK TABLES;
 /*!40000 ALTER TABLE settings_current ENABLE KEYS */;
 
@@ -1148,8 +1151,9 @@ VALUES
 ('languagePriority4','user_selected_lang','UserSelectedLanguage'),
 ('languagePriority4','course_lang','CourseLanguage'),
 ('activate_send_event_by_mail', 'true', 'Yes'),
-('activate_send_event_by_mail', 'false', 'No');
-
+('activate_send_event_by_mail', 'false', 'No'),
+('scorm_cumulative_session_time','true','Yes'),
+('scorm_cumulative_session_time','false','No');
 
 UNLOCK TABLES;
 

+ 83 - 5
main/install/migrate-db-1.8.6.2-1.8.7-pre.sql

@@ -22,7 +22,7 @@ ALTER TABLE session_rel_user ADD COLUMN relation_type int NOT NULL default 0;
 ALTER TABLE course_rel_user  ADD COLUMN relation_type int NOT NULL default 0;
 
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','notebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Notebook',1,0);
-ALTER TABLE course DROP PRIMARY KEY , ADD UNIQUE KEY code (code);
+ALTER TABLE course DROP PRIMARY KEY , ADD UNIQUE KEY code (code); 
 ALTER TABLE course ADD id int NOT NULL auto_increment PRIMARY KEY FIRST;
 CREATE TABLE block (id INT NOT NULL auto_increment, name VARCHAR(255) NULL, description TEXT NULL, path VARCHAR(255) NOT NULL, controller VARCHAR(100) NOT NULL, active TINYINT NOT NULL default 1, PRIMARY KEY(id));
 ALTER TABLE block ADD UNIQUE(path);
@@ -88,16 +88,84 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_user
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_link_bug_notification', NULL, 'radio', 'Platform', 'true', 'ShowLinkBugNotificationTitle', 'ShowLinkBugNotificationComment', NULL, NULL, 0);
 INSERT INTO settings_options (variable, value, display_text) VALUES ('show_link_bug_notification', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('show_link_bug_notification', 'false', 'No');
+-- CAS
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_activate', NULL, 'radio', 'CAS', 'false', 'CasMainActivateTitle', 'CasMainActivateComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) values ('cas_activate', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) values ('cas_activate', 'false', 'No');
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_server', NULL, 'textfield', 'CAS', '', 'CasMainServerTitle', 'CasMainServerComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_server_uri', NULL, 'textfield', 'CAS', '', 'CasMainServerURITitle', 'CasMainServerURIComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_port', NULL, 'textfield', 'CAS', '', 'CasMainPortTitle', 'CasMainPortComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_protocol', NULL, 'radio', 'CAS', '', 'CasMainProtocolTitle', 'CasMainProtocolComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'CAS1', 'CAS1Text');
+INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'CAS2', 'CAS2Text');
+INSERT INTO settings_options (variable, value, display_text) values ('cas_protocol', 'SAML', 'SAMLText');
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_activate', NULL, 'radio', 'CAS', '', 'CasUserAddActivateTitle', 'CasUserAddActivateComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) values ('cas_add_user_activate', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) values ('cas_add_user_activate', 'false', 'No');
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_login_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddLoginAttributeTitle', 'CasUserAddLoginAttributeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_email_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddEmailAttributeTitle', 'CasUserAddEmailAttributeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_firstname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddFirstnameAttributeTitle', 'CasUserAddFirstnameAttributeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('cas_add_user_lastname_attr', NULL, 'textfield', 'CAS', '', 'CasUserAddLastnameAttributeTitle', 'CasUserAddLastnameAttributeComment', NULL, NULL, 0);
+-- Custom Pages
+INSERT INTO settings_options (variable, value, display_text) VALUES ('use_custom_pages', 'true', 'Yes'), ('use_custom_pages', 'false', 'No');
+INSERT INTO settings_current (variable, type, category, selected_value, title, comment, scope) VALUES ('use_custom_pages','radio','Platform','false','UseCustomPages','UseCustomPagesComment', 'platform');
 
 ALTER TABLE gradebook_score_display ADD category_id int NOT NULL DEFAULT 0;
 ALTER TABLE gradebook_score_display ADD INDEX (category_id);
 ALTER TABLE gradebook_score_display ADD score_color_percent float unsigned NOT NULL DEFAULT 0;
+-- CBlue custom
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_page_after_login', NULL, 'textfield', 'Platform', '', 'StudentPageAfterLoginTitle', 'StudentPageAfterLoginComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('teacher_page_after_login', NULL, 'textfield', 'Platform', '', 'TeacherPageAfterLoginTitle', 'TeacherPageAfterLoginComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('DRH_page_after_login', NULL, 'textfield', 'Platform', '', 'DRHPageAfterLoginTitle', 'DRHPageAfterLoginComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('sessionadmin_page_after_login', NULL, 'textfield', 'Platform', '', 'SessionAdminPageAfterLoginTitle', 'SessionAdminPageAfterLoginComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('student_autosubscribe', NULL, 'textfield', 'Platform', '', 'StudentAutosubscribeTitle', 'StudentAutosubscribeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('teacher_autosubscribe', NULL, 'textfield', 'Platform', '', 'TeacherAutosubscribeTitle', 'TeacherAutosubscribeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('DRH_autosubscribe', NULL, 'textfield', 'Platform', '', 'DRHAutosubscribeTitle', 'DRHAutosubscribeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('sessionadmin_autosubscribe', NULL, 'textfield', 'Platform', '', 'SessionadminAutosubscribeTitle', 'SessionadminAutosubscribeComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_1', 'checkbox', 'Platform', 'true', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom1', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_2', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom2', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('show_tabs', 'custom_tab_3', 'checkbox', 'Platform', 'false', 'ShowTabsTitle', 'ShowTabsComment', NULL, 'TabsCustom3', 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_1_name', NULL, 'textfield', 'Platform', 'Reports', 'CustomTab1NameTitle', 'CustomTab1NameComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_1_url', NULL, 'textfield', 'Platform', '/main/reports/', 'CustomTab1URLTitle', 'CustomTab1URLComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_2_name', NULL, 'textfield', 'Platform', '', 'CustomTab2NameTitle', 'CustomTab2NameComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_2_url', NULL, 'textfield', 'Platform', '', 'CustomTab2URLTitle', 'CustomTab2URLComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_3_name', NULL, 'textfield', 'Platform', '', 'CustomTab3NameTitle', 'CustomTab3NameComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('custom_tab_3_url', NULL, 'textfield', 'Platform', '', 'CustomTab3URLTitle', 'CustomTab3URLComment', NULL, NULL, 0);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES('scorm_cumulative_session_time', NULL, 'radio', 'Course', 'true', 'ScormCumulativeSessionTimeTitle', 'ScormCumulativeSessionTimeComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('scorm_cumulative_session_time','true','Yes'), ('scorm_cumulative_session_time','false','No');
+
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('activate_send_event_by_mail', NULL, 'radio', 'Platform', 'false', 'ActivateSendEventByMailTitle', 'ActivateSendEventByMailComment', NULL, NULL, 0);
+INSERT INTO settings_options (variable, value, display_text) VALUES ('activate_send_event_by_mail', 'true', 'Yes'),('activate_send_event_by_mail', 'false', 'No');
+CREATE TABLE `event_type` (`id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `name_lang_var` varchar(40) NOT NULL, `desc_lang_var` varchar(50) NOT NULL, PRIMARY KEY (`id`));
+CREATE TABLE `event_type_message` (`id` int(11) NOT NULL AUTO_INCREMENT, `event_type_id` int(11) NOT NULL,`language_id` int(11) NOT NULL, `message` varchar(200) NOT NULL, `subject` varchar(60) NOT NULL, PRIMARY KEY (`id`));
+CREATE TABLE `user_rel_event_type` (`id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `event_type_id` int(11) NOT NULL, PRIMARY KEY (`id`));
+INSERT INTO `event_type` VALUES (1, 'course_deleted','courseDeletedTitle','courseDeletedComment'),(2,'course_created','courseCreatedTitle','courseCreatedComment'),(3,'user_deleted','userDeletedTitle','userDeletedComment'),(4,'user_created','userCreatedTitle','userCreatedComment'), (5, 'session_created','sessionCreatedTitle','sessionCreatedComment'), (6,'session_deleted','sessionDeletedTitle','sessionDeletedComment'), (7,'session_category_created','sessionCategoryCreatedTitle','sessionCategoryCreatedComment'),(8,'session_category_deleted','sessionCategoryDeletedTitle','sessionCategoryDeletedComment'),(9,'settings_changed','settingsChangedTitle','settingsChangedComment'),(10,'user_subscribed','userSubscribedTitle','userSubscribedComment'), (11,'user_unsubscribed','userUnsubscribedTitle','userUnsubscribedComment');
+INSERT INTO `event_type_message` (`id`,`event_type_id`, `language_id`, `message`,`subject`) VALUES (1,4,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été créé.\r\nEmail : %mail%\r\n\r\nBien à vous.',''),(2,1,10,'Delete formation',''),(3,2,10,'Create formation',''),(4,3,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été supprimé.\r\n\r\nBien à vous.',''),(6,5,10,'Create session test',''),(7,6,10,'Delete session',''),(8,7,10,'Create category session',''),(9,8,10,'Delete category session',''),(10,9,10,'Change setting',''),(11,10,10,'Subscribe',''),(12,11,10,'Unsubscribe','');
+INSERT INTO user_field (field_type, field_variable, field_display_text, field_visible, field_changeable) values (1, 'already_logged_in','Already logged in',0,0);
+CREATE TABLE announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id));
+
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES  ('languagePriority1', NULL, 'radio', 'Languages', 'course_lang', 'LanguagePriority1Title', 'LanguagePriority1Comment', NULL, NULL, 0); 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority2', NULL, 'radio', 'Languages', 'user_profil_lang', 'LanguagePriority2Title', 'LanguagePriority2Comment', NULL, NULL, 0); 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority3', NULL, 'radio', 'Languages', 'user_selected_lang', 'LanguagePriority3Title', 'LanguagePriority3Comment', NULL, NULL, 0); 
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('languagePriority4', NULL, 'radio', 'Languages', 'platform_lang', 'LanguagePriority4Title', 'LanguagePriority4Comment', NULL, NULL, 0); 
+INSERT INTO settings_options (variable, value, display_text) VALUES ('languagePriority1','platform_lang','PlatformLanguage'), ('languagePriority1','user_profil_lang','UserLanguage'), ('languagePriority1','user_selected_lang','UserSelectedLanguage'), ('languagePriority1','course_lang','CourseLanguage'), ('languagePriority2','platform_lang','PlatformLanguage'), ('languagePriority2','user_profil_lang','UserLanguage'), ('languagePriority2','user_selected_lang','UserSelectedLanguage'), ('languagePriority2','course_lang','CourseLanguage'), ('languagePriority3','platform_lang','PlatformLanguage'), ('languagePriority3','user_profil_lang','UserLanguage'), ('languagePriority3','user_selected_lang','UserSelectedLanguage'), ('languagePriority3','course_lang','CourseLanguage'), ('languagePriority4','platform_lang','PlatformLanguage'), ('languagePriority4','user_profil_lang','UserLanguage'), ('languagePriority4','user_selected_lang','UserSelectedLanguage'), ('languagePriority4','course_lang','CourseLanguage');
+
+
+-- 
+-- Table structure for LP custom storage API
+--
+CREATE TABLE stored_values (user_id INT NOT NULL, sco_id INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL );
+ALTER TABLE stored_values ADD KEY (user_id, sco_id, course_id, sv_key);
+ALTER TABLE stored_values ADD UNIQUE (user_id, sco_id, course_id, sv_key);
+CREATE TABLE stored_values_stack (user_id INT NOT NULL, sco_id INT NOT NULL, stack_order INT NOT NULL, course_id CHAR(40) NOT NULL, sv_key CHAR(64) NOT NULL, sv_value TEXT NOT NULL );
+ALTER TABLE stored_values_stack ADD KEY (user_id, sco_id, course_id, sv_key, stack_order);
+ALTER TABLE stored_values_stack ADD UNIQUE (user_id, sco_id, course_id, sv_key, stack_order);
 
 -- xxSTATSxx
 CREATE TABLE track_e_item_property(id int NOT NULL auto_increment PRIMARY KEY, course_id int NOT NULL, item_property_id int NOT NULL, title varchar(255), content text, progress int NOT NULL default 0, lastedit_date datetime NOT NULL default '0000-00-00 00:00:00', lastedit_user_id int  NOT NULL, session_id int NOT NULL default 0);
 ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
 ALTER TABLE track_e_access ADD access_session_id INT NOT NULL DEFAULT 0;
-ALTER TABLE track_e_access ADD INDEX (access_session_id);
+ALTER TABLE track_e_access ADD INDEX (access_session_id);  
 ALTER TABLE track_e_course_access ADD session_id INT NOT NULL DEFAULT 0;
 ALTER TABLE track_e_course_access ADD INDEX (session_id);
 ALTER TABLE track_e_downloads ADD down_session_id INT NOT NULL DEFAULT 0;
@@ -114,6 +182,11 @@ ALTER TABLE track_e_attempt_recording ADD session_id INT NOT NULL DEFAULT 0;
 ALTER TABLE track_e_attempt_recording ADD INDEX (question_id);
 ALTER TABLE track_e_attempt_recording ADD INDEX (session_id);
 ALTER TABLE track_e_online ADD COLUMN access_url_id INT NOT NULL DEFAULT 1;
+-- Groups can have subgroups
+CREATE TABLE group_rel_group ( id int NOT NULL AUTO_INCREMENT, group_id int NOT NULL, subgroup_id int NOT NULL, relation_type int NOT NULL, PRIMARY KEY (id));
+ALTER TABLE group_rel_group ADD INDEX ( group_id );
+ALTER TABLE group_rel_group ADD INDEX ( subgroup_id );
+ALTER TABLE group_rel_group ADD INDEX ( relation_type );
 
 -- xxUSERxx
 
@@ -137,9 +210,9 @@ ALTER TABLE lp_view ADD INDEX(session_id);
 INSERT INTO course_setting (variable,value,category) VALUES ('allow_user_view_user_list',1,'user');
 ALTER TABLE tool_intro ADD COLUMN session_id INT  NOT NULL DEFAULT 0 AFTER intro_text, DROP PRIMARY KEY, ADD PRIMARY KEY  USING BTREE(id, session_id);
 CREATE TABLE thematic (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, title VARCHAR( 255 ) NOT NULL, content TEXT NULL, display_order int unsigned not null default 0, active TINYINT NOT NULL default 0, session_id INT NOT NULL DEFAULT 0);
-ALTER TABLE thematic ADD INDEX (active, session_id);
-CREATE TABLE thematic_plan (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT NULL, description_type INT NOT NULL);
-ALTER TABLE thematic_plan ADD INDEX (thematic_id, description_type);
+ALTER TABLE thematic ADD INDEX (active, session_id);  
+CREATE TABLE thematic_plan (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, title VARCHAR(255) NOT NULL, description TEXT NULL, description_type INT NOT NULL); 
+ALTER TABLE thematic_plan ADD INDEX (thematic_id, description_type); 
 CREATE TABLE thematic_advance (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, thematic_id INT NOT NULL, attendance_id INT NOT NULL DEFAULT 0, content TEXT NOT NULL, start_date DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', duration INT NOT NULL DEFAULT 0, done_advance tinyint NOT NULL DEFAULT 0);
 ALTER TABLE thematic_advance ADD INDEX (thematic_id);
 INSERT INTO course_setting (variable,value,category) VALUES ('display_info_advance_inside_homecourse',1,'thematic_advance');
@@ -149,3 +222,8 @@ ALTER TABLE student_publication MODIFY COLUMN description TEXT DEFAULT NULL;
 ALTER TABLE student_publication ADD COLUMN user_id INTEGER  NOT NULL AFTER session_id;
 INSERT INTO course_setting(variable,value,category) VALUES ('email_alert_students_on_new_homework',0,'work');
 ALTER TABLE course_setting DROP INDEX unique_setting;
+-- CBlue custom
+ALTER TABLE lp ADD COLUMN hide_toc_frame TINYINT NOT NULL DEFAULT 0;
+ALTER TABLE lp ADD COLUMN seriousgame_mode TINYINT NOT NULL DEFAULT 0;
+
+alter table lp_item_view modify column suspend_data longtext;

+ 2 - 0
main/lang/english/admin.inc.php

@@ -1531,4 +1531,6 @@ $ChooseRelationType = 'Choose a relation type';
 $UserListInGroup = 'Users subscribed to this group';
 $ActivateSendEventByMailTitle='Activates the send events by mail feature';
 $ActivateSendEventByMailComment = '';
+$ScormCumulativeSessionTimeTitle = 'Cumulative incerementation of session_time in scorm contents';
+$ScormCumulativeSessionTimeComment = ''
 ?>

+ 2 - 0
main/lang/french/admin.inc.php

@@ -1323,6 +1323,8 @@ $ActivateSendEventByMailTitle='Activer les envois d\'évènements par email';
 $ActivateSendEventByMailComment = '';
 $AllowUsersCopyFilesTitle = "Permet aux utilisateurs de copier des fichiers à partir d'un cours de votre dossier personnel";
 $AllowUsersCopyFilesComment = "Permet aux utilisateurs de copier des fichiers à partir d'un cours de votre dossier personnel, visible à travers les réseaux sociaux ou par l'intermédiaire de l'éditeur HTML lorsqu'ils ne font pas partis d'un cours";
+$ScormCumulativeSessionTimeTitle = 'La valeur session_time est incrémentée de manière cumulative dans les contenus scorm';
+$ScormCumulativeSessionTimeComment = '';
 $ReviewCourseRequests = "Réviser les demandes de cours";
 $AcceptedCourseRequests = "Demandes de cours acceptées";
 $RejectedCourseRequests = "Demandes de cours rejetées";

+ 132 - 0
main/newscorm/learnpath.class.php

@@ -49,6 +49,8 @@ class learnpath {
     public $prevent_reinit = 1;
 
     // Describes the mode of progress bar display.
+    public $seriousgame_mode = 0;
+
     public $progress_bar_mode = '%';
 
     // Percentage progress as saved in the db.
@@ -135,6 +137,7 @@ class learnpath {
                 $this->theme            = $row['theme'];
                 $this->maker            = $row['content_maker'];
                 $this->prevent_reinit   = $row['prevent_reinit'];
+    	        $this->seriousgame_mode = $row['seriousgame_mode'];
                 $this->license          = $row['content_license'];
                 $this->scorm_debug      = $row['debug'];
                 $this->js_lib           = $row['js_lib'];
@@ -4438,6 +4441,135 @@ class learnpath {
         return -1;
     }
 
+  /**
+   * Determine the attempt_mode thanks to prevent_reinit and seriousgame_mode db flag
+   *
+   * @return string 'single', 'multi' or 'seriousgame'
+   * @author ndiechburg <noel@cblue.be>
+   **/
+  public function get_attempt_mode()
+  {
+    if (!isset($this->seriousgame_mode)) { //Set default value for seriousgame_mode
+      $this->seriousgame_mode=0;
+    }
+    if (!isset($this->prevent_reinit)) { // Set default value for prevent_reinit
+      $this->prevent_reinit =1;
+    }
+    if ($this->seriousgame_mode == 1 && $this->prevent_reinit == 1) {
+      return 'seriousgame';
+    }
+    if ($this->seriousgame_mode == 0 && $this->prevent_reinit == 1) {
+      return 'single';
+    }
+    if ($this->seriousgame_mode == 0 && $this->prevent_reinit == 0) {
+      return 'multiple';
+    }
+    return 'single';
+  }
+
+  /**
+   * Register the attempt mode into db thanks to flags prevent_reinit and seriousgame_mode flags
+   *
+   * @param string 'seriousgame', 'single' or 'multiple'
+   * @return boolean
+   * @author ndiechburg <noel@cblue.be>
+   **/
+  public function set_attempt_mode($mode)
+  {
+    switch ($mode) {
+    case 'seriousgame' : 
+      $sg_mode = 1;
+      $prevent_reinit = 1;
+      break;
+    case 'single' : 
+      $sg_mode = 0;
+      $prevent_reinit = 1;
+      break;
+    case 'multiple' : 
+      $sg_mode = 0;
+      $prevent_reinit = 0;
+      break;
+    default :
+      $sg_mode = 0;
+      $prevent_reinit = 0;
+      break;
+    }
+    $this->prevent_reinit = $prevent_reinit;
+    $this->seriousgame_mode = $sg_mode;
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
+    $sql = "UPDATE $lp_table SET prevent_reinit = $prevent_reinit , seriousgame_mode = $sg_mode WHERE id = " . $this->get_id();
+    $res = Database::query($sql);
+    if ($res) {
+      return true;
+    }
+    else {
+      return false;
+    }
+  }
+
+  /**
+   * switch between multiple attempt, single attempt or serious_game mode (only for scorm)
+   *
+   * @return boolean
+   * @author ndiechburg <noel@cblue.be>
+   **/
+  public function switch_attempt_mode()
+  {
+    if ($this->debug > 0) {
+      error_log('New LP - In learnpath::switch_attempt_mode()', 0);
+    }
+    $mode = $this->get_attempt_mode();
+    switch ($mode) {
+    case 'single' :
+      $next_mode = 'multiple';
+      break;
+    case 'multiple' :
+      $next_mode = 'seriousgame';
+      break;
+    case 'seriousgame' :
+      $next_mode = 'single';
+      break;
+    default : 
+      $next_mode = 'single';
+      break;
+    }
+    $this->set_attempt_mode($next_mode);
+  }
+
+  /**
+   * Swithc the lp in ktm mode. This is a special scorm mode with unique attempt but possibility to do again a completed item.
+   *
+   * @return boolean true if seriousgame_mode has been set to 1, false otherwise
+   * @author ndiechburg <noel@cblue.be>
+   **/
+  public function set_seriousgame_mode()
+  {
+		if ($this->debug > 0) {
+			error_log('New LP - In learnpath::set_seriousgame_mode()', 0);
+		}
+		$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
+		$sql = "SELECT * FROM $lp_table WHERE id = " . $this->get_id();
+		$res = Database::query($sql);
+		if (Database :: num_rows($res) > 0) {
+			$row = Database :: fetch_array($res);
+			$force = $row['seriousgame_mode'];
+			if ($force == 1) {
+				$force = 0;
+			} elseif ($force == 0) {
+				$force = 1;
+			}
+			$sql = "UPDATE $lp_table SET seriousgame_mode = $force WHERE id = " . $this->get_id();
+			$res = Database::query($sql);
+			$this->seriousgame_mode = $force;
+			return $force;
+		} else {
+			if ($this->debug > 2) {
+				error_log('New LP - Problem in set_seriousgame_mode() - could not find LP ' . $this->get_id() . ' in DB', 0);
+			}
+		}
+		return -1;
+
+  }
     /**
      * Updates the "scorm_debug" value that shows or hide the debug window
      * @return	boolean	True if scorm_debug has been set to 'on', false otherwise (or 1 or 0 in this case)

+ 117 - 8
main/newscorm/learnpathItem.class.php

@@ -49,6 +49,7 @@ class learnpathItem {
 	public $prereqs = array();
 	public $previous;
 	public $prevent_reinit = 1; // 0 =  multiple attempts   1 = one attempt
+	public $seriousgame_mode;
 	public $ref;
 	public $save_on_close = true;
 	public $search_did = null;
@@ -56,6 +57,8 @@ class learnpathItem {
 	public $title;
 	public $type; // This attribute can contain chapter|link|student_publication|module|quiz|document|forum|thread
 	public $view_id;
+  //var used if absolute session time mode is used
+  private $last_scorm_session_time =0;
 
 	const debug = 0; // Logging parameter.
 
@@ -103,6 +106,7 @@ class learnpathItem {
 		}
 		$this->save_on_close = true;
 		$this->db_id = $id;
+    $this->seriousgame_mode = $this->get_seriousgame_mode();
 
 		// Get search_did.
 		if (api_get_setting('search_enabled')=='true') {
@@ -634,6 +638,37 @@ class learnpathItem {
 	}
 
 	/**
+     * Returns 1 if seriousgame_mode is activated, 0 otherwise
+     *
+     * @return int (0 or 1)
+     * @author ndiechburg <noel@cblue.be>
+     **/
+    public function get_seriousgame_mode()
+    {
+      if(self::debug>2){error_log('New LP - In learnpathItem::get_seriousgame_mode()',0);}
+        if(!isset($this->seriousgame_mode)){
+          if(!empty($this->lp_id)){
+            $db = Database::get_course_table(TABLE_LP_MAIN);
+            $sql = "SELECT * FROM $db WHERE id = ".$this->lp_id;
+            $res = @Database::query($sql);
+            if(Database::num_rows($res)<1)
+            {
+              $this->error = "Could not find parent learnpath in learnpath table";
+              if(self::debug>2){error_log('New LP - End of learnpathItem::get_seriousgame_mode() - Returning false',0);}
+              return false;
+            }else{
+              $row = Database::fetch_array($res);
+              $this->seriousgame_mode = isset($row['seriousgame_mode'])? $row['seriousgame_mode'] : 0;
+            }
+          }else{
+            $this->seriousgame_mode = 0; //SeriousGame mode is always off by default
+          }
+        }
+      if(self::debug>2){error_log('New LP - End of learnpathItem::get_seriousgame_mode() - Returned '.$this->seriousgame_mode,0);}
+        return $this->seriousgame_mode;
+    }
+
+    /**
 	 * Gets the item's reference column
 	 * @return string	The item's reference field (generally used for SCORM identifiers)
 	 */
@@ -1119,7 +1154,7 @@ class learnpathItem {
 			// If status is not attempted or incomplete, authorize retaking (of the same) anyway. Otherwise:
 			if ($mystatus != $this->possible_status[0] && $mystatus != $this->possible_status[1]) {
 				$restart = -1;
-			} else {
+			}else{ //status incompleted or not attempted
 				$restart = 0;
 			}
 		} else {
@@ -1577,7 +1612,18 @@ class learnpathItem {
 	 */
 	public function restart() {
 		if (self::debug > 0) { error_log('New LP - In learnpathItem::restart()', 0); }
+      if ($this->type == 'sco') { //If this is a sco, chamilo can't update the time without explicit scorm call
+        $this->current_start_time = 0;
+        $this->current_stop_time = 0; //Those 0 value have this effect
+        $this->last_scorm_session_time = 0;
+      }
 		$this->save();
+    //For serious game  : We reuse same attempt_id
+    if ($this->get_seriousgame_mode() == 1 && $this->type == 'sco') {
+			$this->current_start_time = 0;
+			$this->current_stop_time = 0;
+      return true;
+    }
 		$allowed = $this->is_restart_allowed();
 		if ($allowed === -1) {
 			// Nothing allowed, do nothing.
@@ -1606,6 +1652,8 @@ class learnpathItem {
 			$this->current_data = '';
 			$this->status = $this->possible_status[0];
 			$this->interactions_count = $this->get_interactions_count(true);
+      if ($this->type == 'sco') 
+        $this->scorm_init_time();
 		}
 		return true;
 	}
@@ -1995,10 +2043,10 @@ class learnpathItem {
 					$sec = $res[3];
 					// Getting total number of seconds spent.
 			 		$total_sec = $hour*3600 + $min*60 + $sec;
-			 		$this->update_time($total_sec);
+   		     		        $this->scorm_update_time($total_sec);
 			 	}
 	 		} elseif ($format == 'int') {
-	 			$this->update_time($scorm_time);
+     			$this->scorm_update_time($scorm_time);
 	 		}
 	 	}
 	}
@@ -2087,6 +2135,47 @@ class learnpathItem {
 	}
 
 	/**
+     * Special scorm update time function. This function will update time directly into db for scorm objects
+     **/
+    public function scorm_update_time($total_sec=0){
+      //Step 1 : get actual total time stored in db
+   		$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
+      $get_view_sql='SELECT total_time, status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
+      $result=Database::query($get_view_sql);
+      $row=Database::fetch_array($result);
+      if (!isset($row['total_time'])) {
+        $total_time = 0;
+      }
+      else { 
+        $total_time = $row['total_time'];
+      }
+      
+      //Step 2.1 : if normal mode total_time = total_time + total_sec
+      if (api_get_setting('scorm_cumulative_session_time') != 'false'){
+        $total_time +=$total_sec;
+        //$this->last_scorm_session_time = $total_sec;
+      }
+      //Step 2.2 : if not cumulative mode total_time = total_time - last_update + total_sec 
+      else{
+        $total_time = $total_time - $this->last_scorm_session_time + $total_sec;
+        $this->last_scorm_session_time = $total_sec;
+      }
+      //Step 3 update db only if status != completed, passed, browsed or seriousgamemode not activated
+      $case_completed=array('completed','passed','browsed'); //TODO COMPLETE
+      if ($this->seriousgame_mode!=1 || !in_array($row['status'], $case_completed)){
+        $update_view_sql='UPDATE '.$item_view_table." SET total_time =$total_time".' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
+        $result=Database::query($update_view_sql);
+      }
+    }
+    /**
+    * Set the total_time to 0 into db
+    **/
+    public function scorm_init_time(){
+      $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
+      $update_view_sql='UPDATE '.$item_view_table.' SET total_time = 0, start_time='.time().' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
+      $result=Database::query($update_view_sql);
+    }
+    /**
 	 * Write objectives to DB. This method is separate from write_to_db() because otherwise
 	 * objectives are lost as a side effect to AJAX and session concurrent access
 	 * @return	boolean		True or false on error
@@ -2171,9 +2260,10 @@ class learnpathItem {
    			$save = true;
    		}
 
-   		if (($save === false && $this->type == 'sco') ||(($this->type == 'sco') && ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse'))) {
-   			// This info shouldn't be saved as the credit or lesson mode info prevent it.
-   			if (self::debug > 1) { error_log('New LP - In learnpathItem::write_to_db() - credit('.$credit.') or lesson_mode('.$mode.') prevent recording!', 0); }
+   		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 info shouldn't be saved as the credit or lesson mode info prevent it
+   			if(self::debug>1){error_log('New LP - In learnpathItem::write_to_db() - credit('.$credit.') or lesson_mode('.$mode.') prevent recording!',0);}
    		} else {
 	  		// Check the row exists.
 	  		$inserted = false;
@@ -2293,8 +2383,12 @@ class learnpathItem {
 		 				// This is a array containing values finished
 		 				$case_completed = array('completed', 'passed', 'browsed');
 
-		 				if ($this->get_prevent_reinit() == 1) {
-		 					// Multiple attempts are prevented.
+	     				//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)."' ,";
+              } elseif ($this->get_prevent_reinit()==1) {
+			  		     	// process of status verified into data base
 
 		 					// Process of status verified into data base.
 			 				$sql_verified = 'SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
@@ -2357,6 +2451,20 @@ class learnpathItem {
 		 				}*/
 		 			}
 
+            
+            if ($this->type == 'sco'){ //IF scorm scorm_update_time has already updated total_tim in db
+			     	$sql = "UPDATE $item_view_table " .
+			     			" SET ".//start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
+			     			" score = ".$this->get_score().", " .
+			     			$my_status.
+			     			" max_score = '".$this->get_max()."'," .
+			     			" suspend_data = '".Database::escape_string($this->current_data)."'," .
+			     			//" max_time_allowed = '".$this->get_max_time_allowed()."'," .
+			     			" lesson_location = '".$this->lesson_location."' " .
+			     			"WHERE lp_item_id = ".$this->db_id." " .
+			     			"AND lp_view_id = ".$this->view_id." " .
+			     			"AND view_count = ".$this->attempt_id;
+            } else {
 				 	$sql = "UPDATE $item_view_table " .
 				 			"SET " .$total_time.
 				 			" start_time = ".$this->get_current_start_time().", " .
@@ -2369,6 +2477,7 @@ class learnpathItem {
 				 			"WHERE lp_item_id = ".$this->db_id." " .
 				 			"AND lp_view_id = ".$this->view_id." " .
 				 			"AND view_count = ".$this->attempt_id;
+            }
 
 				 	$this->current_start_time = time();
 		 		}

+ 1 - 0
main/newscorm/learnpathList.class.php

@@ -114,6 +114,7 @@ class learnpathList {
                 'lp_visibility'     => $vis,
                 'lp_published'	    => $pub,
                 'lp_prevent_reinit' => $row['prevent_reinit'],
+    			'seriousgame_mode' => $row['seriousgame_mode'],
                 'lp_scorm_debug'    => $row['debug'],
                 'lp_display_order'  => $row['display_order'],
                 'lp_preview_image'  => stripslashes($row['preview_image']),

+ 16 - 1
main/newscorm/lp_controller.php

@@ -841,12 +841,27 @@ switch ($action) {
         $_SESSION['oLP']->update_default_scorm_commit();
         require 'lp_list.php';
         break;
-
+    /* Those 2 switches have been replaced by switc_attempt_mode switch
     case 'switch_reinit':
         if ($debug > 0) error_log('New LP - switch_reinit action triggered', 0);
         if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; }
         $_SESSION['refresh'] = 1;
         $_SESSION['oLP']->update_reinit();
+		require 'lp_list.php';
+		break;
+	case 'switch_seriousgame_mode':
+		if($debug>0) error_log('New LP - switch_seriousgame_mode action triggered',0);
+		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
+		$_SESSION['refresh'] = 1;
+		$_SESSION['oLP']->set_seriousgame_mode();
+		require 'lp_list.php';
+		break;
+     */
+	case 'switch_attempt_mode':
+		if($debug>0) error_log('New LP - switch_reinit action triggered',0);
+		if(!$lp_found){ error_log('New LP - No learnpath given for switch',0); require 'lp_list.php'; }
+		$_SESSION['refresh'] = 1;
+		$_SESSION['oLP']->switch_attempt_mode();
         require 'lp_list.php';
         break;
 

+ 17 - 7
main/newscorm/lp_list.php

@@ -350,16 +350,26 @@ if (is_array($flat_list)) {
                 $dsp_publish = Display::return_icon('lp_publish_na.png', get_lang('_no_publish'),'','22');
             }
 
-            /*  MULTIPLE ATTEMPTS */
+			/*  MULTIPLE ATTEMPTS OR SERIOUS GAME MODE */
 
             if ($current_session == $details['lp_session']) {
-                if ($details['lp_prevent_reinit'] == 1) {
-                    $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
+        if ($details['seriousgame_mode'] == 1 && $details['lp_prevent_reinit'] == 1) { //seriousgame mode | next = single
+          dir('serious');
                         Display::return_icon('reload_na.png', get_lang('AllowMultipleAttempts'),'','22').'</a>';
-                } else {
-                    $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_reinit&lp_id='.$id.'">' .
-                        Display::return_icon('reload.png', get_lang('PreventMultipleAttempts'),'','22').'</a>';
-                }
+            '<img src="../img/gamepad.gif" border="0" alt="Prevent reinit" title="'.get_lang("PreventMultipleAttempts").'"/>' .
+            '</a>&nbsp;';
+        }
+        if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 1) { //single mode | next = multiple
+          $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
+            '<img src="../img/kaboodleloop_gray.gif" border="0" alt="Allow reinit" title="'.get_lang("AllowMultipleAttempts").'"/>' .
+            '</a>&nbsp;';
+        }
+        if ($details['seriousgame_mode'] == 0 && $details['lp_prevent_reinit'] == 0) { //multiple mode | next = seriousgame
+          $dsp_reinit = '<a href="lp_controller.php?'.api_get_cidreq().'&action=switch_attempt_mode&lp_id='.$id.'">' .
+            '<img src="../img/kaboodleloop.gif" border="0" alt="Serious game mode" title="'.get_lang("SeriousGameMode").'"/>' .
+							'</a>&nbsp;';
+            '</a>&nbsp;';
+        }
             } else {
                 $dsp_reinit = Display::return_icon('reload_na.png', get_lang('AllowMultipleAttempts'),'','22');
             }