Juan Carlos Raña 15 years ago
parent
commit
0570f14dbc

+ 6 - 2
main/exercice/exercice_submit.php

@@ -68,7 +68,10 @@ $language_file = 'exercice';
 
 require_once '../inc/global.inc.php';
 $this_section = SECTION_COURSES;
-
+if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
+  $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
+  $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/glossary.js" type="text/javascript" language="javascript"></script>'; //Glossary
+ }
 /* ------------	ACCESS RIGHTS ------------ */
 // notice for unauthorized people.
 api_protect_course_script(true);
@@ -901,7 +904,7 @@ if (api_is_course_admin() && $origin != 'learnpath') {
 	echo Display :: return_icon('edit.gif', get_lang('ModifyExercise')) . '<a href="exercise_admin.php?modifyExercise=yes&exerciseId=' . $objExercise->id . '">' . get_lang('ModifyExercise') . '</a>';
 	echo '</div>';
 }
-
+  echo '<div class="glossary-content">';
 $exerciseTitle = api_parse_tex($exerciseTitle);
 
 echo "<h3>" . $exerciseTitle . "</h3>";
@@ -1111,6 +1114,7 @@ if ($_configuration['live_exercise_tracking'] == true && $exerciseFeedbackType !
 
 if ($origin != 'learnpath') {
 	//so we are not in learnpath tool
+  echo '</div>'; //End glossary div
 	Display :: display_footer();
 } else {
 	echo '</body></html>';

+ 1 - 1
main/group/group_edit.php

@@ -335,7 +335,7 @@ Display :: display_header($nameTools, "Group");
 <?php
 
 if (isset($_GET['show_message'])) {
-	echo Display::display_error_message(get_lang($_GET['show_message']));
+	echo Display::display_error_message($_GET['show_message']);
 }
 $defaults['referer'] = $referer;
 $form->setDefaults($defaults);

+ 7 - 7
main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js

@@ -6,7 +6,7 @@ $(document).ready(function() {
 	 work_path = my_pathname.substr(0,my_pathname.indexOf('/courses/'));
      $.ajax({
         contentType: "application/x-www-form-urlencoded",
-        beforeSend: function(objeto) {
+        beforeSend: function(content_object) {
         },
         type: "POST",
         url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
@@ -15,11 +15,11 @@ $(document).ready(function() {
 			  if (datos.length==0) {
 			  	return false;
 			  }
-                data_terms=datos.split("[|.|_|.|-|.|]");
+                data_terms=datas.split("[|.|_|.|-|.|]");
                 for(i=0;i<data_terms.length;i++) {
                     specific_terms=data_terms[i].split("__|__|");
-                   var my_specific_terms = new RegExp(specific_terms[1],"gi");
-				    new_html=my_text.replace(my_specific_terms,"<a href=\"javascript:void(0)\" class=\"glossary-ajax\" name=\"link"+specific_terms[0]+"\" onclick=\"\">"+specific_terms[1]+"</a>");
+                    var my_specific_terms = new RegExp('[^A-Za-z0-9/_\]('+specific_terms[1]+')',"gi");
+				    new_html=my_text.replace(my_specific_terms,"<span class=\"glossary-ajax\" style='color:blue'  name=\"link"+specific_terms[0]+"\">"+specific_terms[1]+"</span>");
                     $("body").html(new_html);
                     my_text=$("body").html();
                 }
@@ -36,13 +36,13 @@ $(document).ready(function() {
 	                my_glossary_id=data_notebook[1];
 	                $.ajax({
 	                    contentType: "application/x-www-form-urlencoded",
-	                    beforeSend: function(objeto) {
+	                    beforeSend: function(content_object) {
 	                    $("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
 	                    type: "POST",
 	                    url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
 	                    data: "glossary_id="+my_glossary_id,
-	                    success: function(datos) {
-	                        $("div#"+div_content_id).html(datos);
+	                    success: function(datas) {
+	                        $("div#"+div_content_id).html(datas);
 	                    }
 	                });
 	          });

+ 3 - 3
main/inc/lib/groupmanager.lib.php

@@ -183,7 +183,7 @@ class GroupManager {
 		}
 
 		$groups = array ();
-		if(is_array($thisGroup = Database::fetch_array($groupList))){
+		$thisGroup= array();
 			while ($thisGroup = Database::fetch_array($groupList)) {
 				if ($thisGroup['category_id'] == VIRTUAL_COURSE_CATEGORY)
 				{
@@ -202,7 +202,7 @@ class GroupManager {
 					}
 				}
 				$groups[] = $thisGroup;
-			}
+			
 		}
 		return $groups;
 	}
@@ -826,7 +826,7 @@ class GroupManager {
 		 * Retrieve all the groups where enrollment is still allowed
 		 * (reverse) ordered by the number of place available
 		 */
-		echo $sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student
+		$sql = "SELECT g.id gid, g.max_student-count(ug.user_id) nbPlaces, g.max_student
 				FROM ".$group_table." g
 				LEFT JOIN  ".$group_user_table." ug
 				ON    `g`.`id` = `ug`.`group_id`

+ 64 - 0
main/inc/lib/javascript/glossary.js

@@ -0,0 +1,64 @@
+$(document).ready(function() {
+    $(window).load(function () {
+
+     var my_text=$(".glossary-content").html();
+     my_protocol = location.protocol;
+     my_pathname=location.pathname;
+     work_path = my_pathname.substr(0,my_pathname.indexOf('/courses/'));
+     $.ajax({
+        contentType: "application/x-www-form-urlencoded",
+        beforeSend: function(content_object) {
+        },
+        type: "POST",
+        url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
+        data: "glossary_data=true",
+        success: function(datas) {
+              if (datas.length==0) {
+                return false;
+              }
+                data_terms=datas.split("[|.|_|.|-|.|]");
+				
+                for(i=0;i<data_terms.length;i++) {
+                    specific_terms=data_terms[i].split("__|__|");
+                    var my_specific_terms = new RegExp('[^A-Za-z0-9/_\]('+specific_terms[1]+')',"gi");
+					new_html=my_text.replace(my_specific_terms," <span class=\"glossary-ajax\" style='color:blue' name=\"link"+specific_terms[0]+"\">"+specific_terms[1]+"</span>");
+					$(".glossary-content").html(new_html);
+                    my_text=$(".glossary-content").html();
+					
+                }
+
+              $(".glossary-content .glossary-ajax").mouseover(function(){
+                random_id=Math.round(Math.random()*100);
+                div_show_id="div_show_id"+random_id;
+                div_content_id="div_content_id"+random_id;
+                 $(this).append("<div id="+div_show_id+" ><div id="+div_content_id+">&nbsp;</div></div>");
+                 $("div#"+div_show_id).attr("style","display:inline;float:left;position:absolute;background-color:#F5F6CE;border-bottom: 1px dashed #dddddd;border-right: 1px dashed #dddddd;border-left: 1px dashed #dddddd;border-top: 1px dashed #dddddd;color:#305582;margin-left:5px;margin-right:5px;");
+                 $("div#"+div_content_id).attr("style","background-color:#F5F6CE;color:#305582;margin-left:8px;margin-right:8px;margin-top:5px;margin-bottom:5px;");
+                    notebook_id=$(this).attr("name");
+                    data_notebook=notebook_id.split("link");
+                    my_glossary_id=data_notebook[1];
+                    $.ajax({
+                        contentType: "application/x-www-form-urlencoded",
+                        beforeSend: function(content_object) {
+                        $("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
+                        type: "POST",
+                        url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
+                        data: "glossary_id="+my_glossary_id,
+                        success: function(datas) {
+                            $("div#"+div_content_id).html(datas);
+                        }
+                    });
+              });
+              $(".glossary-content .glossary-ajax").mouseout(function(){
+                    var current_element,
+                    current_element=$(this);
+                    div_show_id=current_element.find("div").attr("id");
+                    $("div#"+div_show_id).remove();
+              });
+
+
+                }
+
+            });
+        });
+});

+ 4 - 2
main/install/dokeos_main.sql

@@ -735,6 +735,7 @@ VALUES
 ('search_show_unlinked_results',NULL,'radio','Search','true','SearchShowUnlinkedResultsTitle','SearchShowUnlinkedResultsComment',NULL,NULL,1),
 ('show_courses_descriptions_in_catalog', NULL, 'radio', 'Course', 'true', 'ShowCoursesDescriptionsInCatalogTitle', 'ShowCoursesDescriptionsInCatalogComment', NULL, NULL, 1),
 ('allow_coach_to_edit_course_session',NULL,'radio','Course','false','AllowCoachsToEditInsideTrainingSessions','AllowCoachsToEditInsideTrainingSessionsComment',NULL,NULL, 0),
+('show_glossary_in_extra_tools', NULL, 'radio', 'Course', 'false', 'ShowGlossaryInExtraToolsTitle', 'ShowGlossaryInExtraToolsComment', NULL, NULL,1),
 ('dokeos_database_version', NULL, 'textfield', NULL,'1.8.6.1.8565','DokeosDatabaseVersion','',NULL,NULL,0);
 UNLOCK TABLES;
 /*!40000 ALTER TABLE settings_current ENABLE KEYS */;
@@ -918,8 +919,9 @@ VALUES
 ('show_courses_descriptions_in_catalog', 'true', 'Yes'),
 ('show_courses_descriptions_in_catalog', 'false', 'No'),
 ('allow_coach_to_edit_course_session','true','Yes'),
-('allow_coach_to_edit_course_session','false','No');
-
+('allow_coach_to_edit_course_session','false','No'),
+('show_glossary_in_extra_tools', 'true', 'Yes'),
+('show_glossary_in_extra_tools', 'false', 'No');
 
 UNLOCK TABLES;
 

+ 6 - 1
main/install/migrate-db-1.8.6.1-1.8.6.2-pre.sql

@@ -20,8 +20,10 @@ ALTER TABLE session_rel_course_rel_user ADD COLUMN visibility int NOT NULL defau
 ALTER TABLE session_rel_course_rel_user ADD COLUMN status int NOT NULL default 0;
 CREATE TABLE session_category (id int(11) NOT NULL auto_increment, name varchar(100) default NULL, date_start date default NULL, date_end date default NULL, PRIMARY KEY  (id));
 
+
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_coach_to_edit_course_session', NULL, 'radio', 'Course', 'false', 'AllowCoachsToEditInsideTrainingSessions', 'AllowCoachsToEditInsideTrainingSessionsComment', NULL, NULL, 0);
 INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_courses_descriptions_in_catalog', NULL, 'radio', 'Course', 'true', 'ShowCoursesDescriptionsInCatalogTitle', 'ShowCoursesDescriptionsInCatalogComment', NULL, NULL, 1, 1);
+INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('show_glossary_in_extra_tools', NULL, 'radio', 'Course', 'false', 'ShowGlossaryInExtraToolsTitle', 'ShowGlossaryInExtraToolsComment', NULL, NULL,1,0);
 
 INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('show_courses_descriptions_in_catalog', 'false', 'No');
@@ -29,6 +31,9 @@ INSERT INTO settings_options (variable, value, display_text) VALUES ('show_cours
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'true', 'Yes');
 INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_coach_to_edit_course_session', 'false', 'No');
 
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'true', 'Yes');
+INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'false', 'No');
+
 CREATE TABLE user_tag (id int NOT NULL auto_increment, tag varchar(255) NOT NULL, field_id int NOT NULL, count int NOT NULL, PRIMARY KEY  (id));
 CREATE TABLE user_rel_tag (id int NOT NULL auto_increment,user_id int NOT NULL,tag_id int NOT NULL, PRIMARY KEY  (id));
 
@@ -49,4 +54,4 @@ ALTER TABLE wiki ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id
 ALTER TABLE tool ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
 ALTER TABLE link_category ADD COLUMN session_id smallint DEFAULT 0, ADD INDEX (session_id);
 ALTER TABLE item_property ADD id_session INT NOT NULL DEFAULT 0;
-ALTER TABLE item_property DROP INDEX idx_item_property_toolref, ADD INDEX idx_item_property_toolref (tool, ref, id_session); 
+ALTER TABLE item_property DROP INDEX idx_item_property_toolref, ADD INDEX idx_item_property_toolref (tool, ref, id_session); 

+ 81 - 0
main/newscorm/scorm_api.php

@@ -184,6 +184,13 @@ $(document).ready( function() {
   //alert("Document title: " + $("iframe#content_id").attr('src'));
   info_lms_item[0]=info_lms_item[1];
   info_lms_item[1]= info_lms_item[1];
+  <?php
+  if (api_get_setting('show_glossary_in_extra_tools') == 'true') {
+  ?>
+    attach_glossary_into_scorm();
+  <?php
+  }
+  ?>
  });
 });
 
@@ -1578,3 +1585,77 @@ addEvent(window,'load',addListeners,false);
 if(lms_lp_type==1 || lms_item_type=='asset'){
 	xajax_start_timer();
 }
+
+/**
+*Allow attach the glossary terms into html document of scorm
+*Added by Isaac flores
+*/
+function attach_glossary_into_scorm() {
+  var f = $('#content_id')[0];
+ 
+  var doc = f.contentWindow ? f.contentWindow.document :
+  f.contentDocument ? f.contentDocument : f.document; 
+  
+  var $frame_content = $('body',doc);
+  var my_text=$frame_content.html();
+  
+   my_protocol = location.protocol;
+   my_pathname=location.pathname;
+   work_path = my_pathname.substr(0,my_pathname.indexOf('/courses/'));
+     
+     $.ajax({
+        contentType: "application/x-www-form-urlencoded",
+        beforeSend: function(objeto) {
+        },
+        type: "POST",
+        url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
+        data: "glossary_data=true",
+        success: function(datos) {
+        if (datos.length==0) {
+          return false;
+        }
+                data_terms=datos.split("[|.|_|.|-|.|]");
+                for(i=0;i<data_terms.length;i++) {
+                    specific_terms=data_terms[i].split("__|__|");
+                    var my_specific_terms = new RegExp('[^A-Za-z0-9/_\]('+specific_terms[1]+')',"gi");
+                    new_html=my_text.replace(my_specific_terms," <span style='color:blue' class=\"glossary-ajax\" name=\"link"+specific_terms[0]+"\" >"+specific_terms[1]+"</span>");
+                    $frame_content.html(new_html);
+                    my_text=$frame_content.html();
+                }
+        //mouse over event
+        $("iframe").contents().find('body').find('.glossary-ajax').mouseover(function(){
+              random_id=Math.round(Math.random()*100);
+              div_show_id="div_show_id"+random_id;
+              div_content_id="div_content_id"+random_id;
+               $(this).append("<div id="+div_show_id+" ><div id="+div_content_id+">&nbsp;</div></div>");
+               $("iframe").contents().find('body').find("div#"+div_show_id).attr("style","display:inline;float:left;position:absolute;background-color:#F5F6CE;border-bottom: 1px dashed #dddddd;border-right: 1px dashed #dddddd;border-left: 1px dashed #dddddd;border-top: 1px dashed #dddddd;color:#305582;margin-left:5px;margin-right:5px;");
+              $("iframe").contents().find('body').find("div#"+div_content_id).attr("style","background-color:#F5F6CE;color:#305582;margin-left:8px;margin-right:8px;margin-top:5px;margin-bottom:5px;");
+                  notebook_id=$(this).attr("name");
+                  data_notebook=notebook_id.split("link");
+                  my_glossary_id=data_notebook[1];
+                  $.ajax({
+                      contentType: "application/x-www-form-urlencoded",
+                      beforeSend: function(objeto) {
+                      $("iframe").contents().find('body').find("div#"+div_content_id).html("<img src="+my_protocol+"//"+location.host+work_path+"/main/inc/lib/javascript/indicator.gif />"); },
+                      type: "POST",
+                      url: my_protocol+"//"+location.host+work_path+"/main/glossary/glossary_ajax_request.php",
+                      data: "glossary_id="+my_glossary_id,
+                      success: function(datos) {
+                          $("iframe").contents().find('body').find("div#"+div_content_id).html(datos);
+                      }
+                  });
+            });
+            // mouse out event
+            $("iframe").contents().find('body').find('.glossary-ajax').mouseout(function(){
+                var current_element,
+                current_element=$(this);
+                div_show_id=current_element.find("div").attr("id");
+               $("iframe").contents().find('body').find("div#"+div_show_id).remove();
+            });
+
+
+        }
+
+            });
+	
+}