[svn r16892] Added glossary tool (FS#3248)

skala
Yannick Warnier 16 years ago
parent ba7c4545a1
commit 2131302adb
  1. 86
      main/glossary/glossaryfunction.inc.php
  2. 126
      main/glossary/index.php
  3. 45
      main/inc/lib/add_course.lib.inc.php
  4. 5
      main/inc/lib/database.lib.php
  5. 1
      main/inc/lib/main_api.lib.php
  6. 4
      main/install/dokeos_main.sql
  7. 4
      main/install/migrate-db-1.8.5-1.8.6-pre.sql

@ -0,0 +1,86 @@
<?php
/*
* Created on 19/11/2008
* @author Christian Fasanando
*
* This class allows the maintenance of the tool glossary
*/
/**
* This function retrieves glossary details by course
* @return array Array of type ([glossary_id=>w,name=>x,description=>y],[])
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version november 2008, dokeos 1.8.6
*/
function get_glossary_details() {
$t_glosary = Database :: get_course_table(TABLE_GLOSSARY);
$sql = "SELECT glossary_id,name,description
FROM $t_glosary";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function add glosary details by course
* @param name type String
* @param description type String
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version november 2008, dokeos 1.8.6
*/
function add_glossary_details($name,$description) {
$t_glosary = Database :: get_course_table(TABLE_GLOSSARY);
$safe_name = Database::escape_string($name);
$safe_description = Database::escape_string($description);
if (empty($name) || empty($description)) {
return false;
}
$sql = "INSERT INTO $t_glosary(name,description) VALUES('$safe_name' , '$safe_description')";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function edit glosary details by course
* @param glossary_id int
* @param name type String
* @param description type String
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version november 2008, dokeos 1.8.6
*/
function edit_glossary_details($glossary_id,$name,$description) {
$t_glosary = Database :: get_course_table(TABLE_GLOSSARY);
$safe_name = Database::escape_string($name);
$safe_description = Database::escape_string($description);
$safe_glossary_id = Database::escape_string($glossary_id);
if (empty($name) || empty($description))return false;
$sql = "UPDATE $t_glosary SET name='$safe_name' , description='$safe_description' WHERE glossary_id=$safe_glossary_id";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}
/**
* This function delete glosary details by course
* @param glossary_id int
* @return boolean
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version november 2008, dokeos 1.8.6
*/
function delete_glossary_details($glossary_id) {
$t_glosary = Database :: get_course_table(TABLE_GLOSSARY);
$safe_glossary_id = Database::escape_string($glossary_id);
$sql = "DELETE FROM $t_glosary WHERE glossary_id=$safe_glossary_id";
$result = api_sql_query($sql, __FILE__, __LINE__);
return $result;
}

@ -0,0 +1,126 @@
<?php
/**
* Created on 15/10/2008
* @Author Christian Fasanando
* Show a glossary
*
*/
$language_file = array('glossary');
require_once('../inc/global.inc.php');
include('glossaryfunction.inc.php');
$status = $_user['status'];
/*
-----------------------------------------------------------
Header
-----------------------------------------------------------
*/
$htmlHeadXtra[] =
"<script type=\"text/javascript\">
function confirmation (name)
{
if (confirm(\" ". get_lang("AreYouSureToDeleteThis") ." \"+ name + \" ?\"))
{return true;}
else
{return false;}
}
function text_focus(){
document.form_glossary.n_glossary.focus();
document.form_glossary.n_glossary.select();
}
</script>";
$tool = TOOL_GLOSSARY;
Display::display_header($tool);
//---------------------------------------------------------
if($status=='1') {
echo '<a href="index.php?action=addglossary"><img src="../img/filenew.gif" title ="'.get_lang('NewDescription').'">'.get_lang('NewDescription').'</a>';
/*======================================
Form Glossary
======================================*/
echo '<p><div>';
if ($_GET['action'] == 'addglossary'){
echo '<form name="frm_glossary" action="index.php">';
echo '<div class="term_glossary">'.get_lang('Name').'<br /><input type="text" name="name_glossary"></div>';
echo '<div class="definition_glossary">'.get_lang('Definition').'<br /><textarea cols="60" rows="5" maxlength="255" name="description_glossary"></textarea></div>';
echo '<div class="action_glossary"><input type="submit" value="'.get_lang('Ok').'"></div>';
echo '</form>';
}
echo '</div><hr />';
}
/*======================================
Add Glossary Details
======================================*/
$name_glossary = Security::remove_XSS($_GET['name_glossary']);
$description_glossary = Security::remove_XSS($_GET['description_glossary']);
$add_glossary = add_glossary_details($name_glossary,$description_glossary);
/*======================================
Edit Glossary Details
======================================*/
$g_id = Security::remove_XSS($_GET['g_id']);
$n_glossary = Security::remove_XSS($_GET['n_glossary']);
$d_glossary = Security::remove_XSS($_GET['d_glossary']);
$edit_glossary = edit_glossary_details($g_id,$n_glossary,$d_glossary);
/*======================================
Delete Glossary Details
======================================*/
if ($_GET['action'] == 'delete_glossary') {
$g_id = Security::remove_XSS($_GET['glossary_id']);
$delete_glossary = delete_glossary_details($g_id);
Display::display_confirmation_message(get_lang('NameDeleted'));
}
/*======================================
Display Glossary Details
======================================*/
$glossary_list=get_glossary_details();
Database::num_rows($glossary_list);
echo '<p><div><dl>';
while ($row_glossary_list=Database::fetch_array($glossary_list)) {
if ($_GET['action'] == 'edit_glossary' && $_GET['glossary_id']==$row_glossary_list['glossary_id']){
echo '<body onload="text_focus()">';
echo '<form name="form_glossary" action="index.php">';
echo '<input type="hidden" name="g_id" value="'.Security::remove_XSS($_GET['glossary_id']).'"><dl>';
echo '<dt><strong>'.get_lang('Name').'</strong><br /><input type="text" name="n_glossary" value="'.$row_glossary_list['name'].'" onfocus="this.select()"></dt>';
echo '<dd><strong>'.get_lang('Definition').'</strong><br /><textarea cols="60" rows="5" maxlength="255" name="d_glossary" onfocus="this.select()">'.$row_glossary_list['description'].'</textarea><br>';
echo '<input type="submit" value="'.get_lang('OK').'"></dd><br>';
echo '</dl></form></body>';
}else{
echo '<dt><strong>'.$row_glossary_list['name'].'</strong></dt>';
echo '<dd>'.$row_glossary_list['description'].'<br><br>';
$icon_edit ='edit.gif';
$icon_delete ='delete.gif';
if($status=='1'){
echo '<a href="index.php?action=edit_glossary&glossary_id='.$row_glossary_list['glossary_id'].'"><img src="../img/'.$icon_edit.'" title ="'.get_lang('Editar').'"></a>&nbsp;';
echo '<a href="index.php?action=delete_glossary&glossary_id='.$row_glossary_list['glossary_id'].'" onclick="return confirmation(\''.$row_glossary_list['name'].'\');"><img src="../img/'.$icon_delete.'" title ="'.get_lang('Eliminar').'"></a></dd><p>';
}
}
}
echo '</dl><br></p></div>';
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
?>

@ -2,7 +2,6 @@
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) various contributors
@ -395,6 +394,9 @@ function update_Db_course($courseDbName)
// Course settings
$TABLESETTING = $courseDbName . 'course_setting';
// Glossary
$TBL_GLOSSARY = $courseDbName . 'glossary';
/*
-----------------------------------------------------------
@ -1547,12 +1549,6 @@ function update_Db_course($courseDbName)
$result = api_sql_query($sql,__FILE__,__LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TABLESURVEY."` ADD INDEX ( session_id )";
api_sql_query($sql,__FILE__,__LINE__);
/*
if(!api_sql_query($sql))
{
error_log($sql,0);
}
*/
$sql = "CREATE TABLE `".$TABLESURVEYINVITATION."` (
survey_invitation_id int unsigned NOT NULL auto_increment,
@ -1565,12 +1561,6 @@ function update_Db_course($courseDbName)
PRIMARY KEY (survey_invitation_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/*
if(!api_sql_query($sql))
{
error_log($sql,0);
}
*/
$sql = "CREATE TABLE `".$TABLESURVEYQUESTION."` (
question_id int unsigned NOT NULL auto_increment,
@ -1588,12 +1578,6 @@ function update_Db_course($courseDbName)
PRIMARY KEY (question_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/*
if(!api_sql_query($sql))
{
error_log($sql,0);
}
*/
$sql ="CREATE TABLE `".$TABLESURVEYQUESTIONOPTION."` (
question_option_id int unsigned NOT NULL auto_increment,
@ -1605,12 +1589,6 @@ function update_Db_course($courseDbName)
PRIMARY KEY (question_option_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/*
if(!api_sql_query($sql))
{
error_log($sql,0);
}
*/
$sql = "CREATE TABLE `".$TABLESURVEYANSWER."` (
answer_id int unsigned NOT NULL auto_increment,
@ -1622,12 +1600,6 @@ function update_Db_course($courseDbName)
PRIMARY KEY (answer_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/*
if(!api_sql_query($sql))
{
error_log($sql,0);
}
*/
$sql = "CREATE TABLE `".$TABLESURVEYGROUP."` (
id int unsigned NOT NULL auto_increment,
@ -1639,6 +1611,15 @@ function update_Db_course($courseDbName)
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
// table glosary
$sql = "CREATE TABLE `".$TBL_GLOSSARY."` (
glossary_id int unsigned NOT NULL auto_increment,
name varchar(255) NOT NULL,
description text not null,
PRIMARY KEY (glossary_id)
)";
$result = api_sql_query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
return 0;
}
@ -1968,7 +1949,7 @@ function fill_Db_course($courseDbName, $courseRepository, $language,$default_doc
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_SURVEY."','survey/survey_list.php','survey.gif','1','0','','NO','_self','interaction')");
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_WIKI ."','wiki/index.php','wiki.gif','".string2binary(api_get_setting('course_create_active_tools', 'wiki')) . "','0','squaregrey.gif','NO','_self','interaction')", __FILE__, __LINE__);
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GRADEBOOK."','gradebook/index.php','gradebook.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook'))."','0','','NO','_self','authoring')");
api_sql_query("INSERT INTO `" . $tbl_course_homepage . "` VALUES (NULL, '" . TOOL_GLOSSARY."','glossary/index.php','file_txt.gif','".string2binary(api_get_setting('course_create_active_tools', 'gradebook'))."','0','','NO','_self','authoring')");
if(api_get_setting('service_visio','active')=='true')
{
$mycheck = api_get_setting('service_visio','visio_host');

@ -1,4 +1,4 @@
<?php // $Id: database.lib.php 16685 2008-11-06 16:27:42Z yannoo $
<?php // $Id: database.lib.php 16892 2008-11-24 20:58:06Z yannoo $
/* See license terms in /dokeos_license.txt */
/**
==============================================================================
@ -182,7 +182,8 @@ define('TABLE_WIKI_CONF', 'wiki_conf');
define('TABLE_WIKI_DISCUSS', 'wiki_discuss');
define('TABLE_WIKI_MAILCUE', 'wiki_mailcue');
// GLOSSARY
define('TABLE_GLOSSARY', 'glossary');
/*
==============================================================================
DATABASE CLASS

@ -137,6 +137,7 @@ define('TOOL_VISIO_CONFERENCE','visio_conference');
define('TOOL_VISIO_CLASSROOM','visio_classroom');
define('TOOL_SURVEY','survey');
define('TOOL_WIKI','wiki');
define('TOOL_GLOSSARY','glossary');
// CONSTANTS defining dokeos sections
define('SECTION_CAMPUS', 'mycampus');

@ -250,6 +250,7 @@ INSERT INTO course_module VALUES
(24,'survey','survey/survey_list.php','survey.gif',2,1,'basic'),
(25,'wiki','wiki/index.php','wiki.gif',2,3,'basic'),
(26,'gradebook','gradebook/index.php','gradebook.gif',2,2,'basic');
(27,'glossary','glossary/index.php','file_txt.gif',2,1,'basic');
UNLOCK TABLES;
/*!40000 ALTER TABLE course_module ENABLE KEYS */;
@ -623,7 +624,8 @@ VALUES
('extend_rights_for_coach_on_survey',NULL,'radio','Security','true','ExtendRightsForCoachOnSurveyTitle','ExtendRightsForCoachOnSurveyComment',NULL,NULL),
('course_create_active_tools','wiki','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Wiki'),
('show_session_coach', NULL, 'radio','Platform','false', 'ShowSessionCoachTitle','ShowSessionCoachComment', NULL, NULL),
('course_create_active_tools','gradebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Gradebook');
('course_create_active_tools','gradebook','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Gradebook'),
('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary');
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */;

@ -37,6 +37,8 @@ INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES
ALTER TABLE gradebook_category ADD session_id int DEFAULT NULL;
CREATE TABLE gradebook_result_log (id int NOT NULL auto_increment,id_result int NOT NULL,user_id int NOT NULL,evaluation_id int NOT NULL,date_log datetime default '0000-00-00 00:00:00',score float unsigned default NULL,PRIMARY KEY(id));
CREATE TABLE gradebook_linkeval_log (id int NOT NULL auto_increment,id_linkeval_log int NOT NULL,name text,description text,date_log datetime default '0000-00-00 00:00:00',weight smallint default NULL,visible tinyint default NULL,type varchar(20) NOT NULL,user_id_log int NOT NULL,PRIMARY KEY (id));
INSERT INTO course_module (name, link, image, `row`, `column`, position) VALUES ('glossary','glossary/index.php','file_txt.gif',2,1,'basic');
INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url, access_url_changeable) VALUES ('course_create_active_tools','glossary','checkbox','Tools','true','CourseCreateActiveToolsTitle','CourseCreateActiveToolsComment',NULL,'Glossary',1,0);
-- xxSTATSxx
ALTER TABLE track_e_exercices ADD status varchar(20) NOT NULL default '';
@ -120,4 +122,4 @@ UPDATE forum_notification SET thread_id=NULL WHERE thread_id='';
ALTER TABLE forum_notification CHANGE thread_id thread_id INT NULL;
UPDATE forum_notification SET post_id=NULL WHERE post_id='';
ALTER TABLE forum_notification CHANGE post_id post_id INT NULL;
ALTER TABLE quiz_answer CHANGE hotspot_coordinates hotspot_coordinates text;
ALTER TABLE quiz_answer CHANGE hotspot_coordinates hotspot_coordinates text;

Loading…
Cancel
Save