added track_e_item_property table for using it like history, id for item_property and course tables - partial CT#613

skala
Cristian Fasanando 16 years ago
parent a249616238
commit 120af264c7
  1. 1
      main/inc/lib/database.lib.php
  2. 38
      main/inc/lib/main_api.lib.php
  3. 46
      main/inc/local.inc.php
  4. 4
      main/install/dokeos_main.sql
  5. 14
      main/install/dokeos_stats.sql

@ -126,6 +126,7 @@ define('TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING', 'track_e_attempt_recording')
define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot');
define('TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY', 'track_e_item_property');
// SCORM database tables
define('TABLE_SCORM_MAIN', 'scorm_main');

@ -133,6 +133,7 @@ define('TOOL_WIKI','wiki');
define('TOOL_GLOSSARY','glossary');
define('TOOL_GRADEBOOK','gradebook');
define('TOOL_NOTEBOOK','notebook');
define('TOOL_ATTENDANCE','attendance');
// CONSTANTS defining dokeos sections
define('SECTION_CAMPUS', 'mycampus');
@ -853,12 +854,20 @@ function api_get_user_info_from_username($username = '') {
}
/**
* Returns the current course id (integer)
* @TODO this function should be the real id (integer)
* Returns the current course code (string)
*/
function api_get_course_id() {
return $GLOBALS['_cid'];
}
/**
* Returns the current course id (integer)
*/
function api_get_real_course_id() {
return $GLOBALS['_real_cid'];
}
/**
* Returns the current course directory
*
@ -2459,6 +2468,31 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
return true;
}
/**
* get item property id from tool of a course
* @param string course code
* @param string tool name, linked to 'rubrique' of the course tool_list (Warning: language sensitive !!)
* @param int id of the item itself, linked to key of every tool ('id', ...), "*" = all items of the tool
*/
function api_get_item_property_id ($course_code, $tool, $ref) {
$course_info = api_get_course_info($course_code);
$tool = Database::escape_string($tool);
$ref = intval($ref);
// Definition of tables
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
$sql = "SELECT id FROM $TABLE_ITEMPROPERTY WHERE tool = '$tool' AND ref = '$ref' ";
$rs = Database::query($sql, __FILE__, __LINE__);
$item_property_id = '';
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs);
$item_property_id = $row['id'];
}
return $item_property_id;
}
/*
==============================================================================
Language Dropdown
@ -4030,7 +4064,7 @@ function api_get_tools_lists($my_tool = null) {
TOOL_COURSE_SETTING,TOOL_BACKUP,TOOL_COPY_COURSE_CONTENT,TOOL_RECYCLE_COURSE,
TOOL_COURSE_HOMEPAGE,TOOL_COURSE_RIGHTS_OVERVIEW,TOOL_UPLOAD,TOOL_COURSE_MAINTENANCE,
TOOL_VISIO,TOOL_VISIO_CONFERENCE,TOOL_VISIO_CLASSROOM,TOOL_SURVEY,TOOL_WIKI,
TOOL_GLOSSARY,TOOL_GRADEBOOK,TOOL_NOTEBOOK
TOOL_GLOSSARY,TOOL_GRADEBOOK,TOOL_NOTEBOOK,TOOL_ATTENDANCE
);
if (empty($my_tool)) {
return $tools_list;

@ -766,7 +766,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
if ($cidReq) {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT course.*, course_category.code faCode, course_category.name faName
$sql = "SELECT course.*, course_category.code faCode, course_category.name faName
FROM $course_table
LEFT JOIN $course_cat_table
ON course.category_code = course_category.code
@ -775,29 +775,34 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
if (Database::num_rows($result)>0) {
$cData = Database::fetch_array($result);
$_cid = $cData['code' ];
//@TODO real_cid should be cid, for working with numeric course id
$_real_cid = $cData['id'];
$_cid = $cData['code'];
$_course = array();
$_course['id' ] = $cData['code' ]; //auto-assigned integer
$_course['name' ] = $cData['title' ];
$_course['official_code'] = $cData['visual_code' ]; // use in echo
$_course['sysCode' ] = $cData['code' ]; // use as key in db
$_course['path' ] = $cData['directory' ]; // use as key in path
$_course['dbName' ] = $cData['db_name' ]; // use as key in db list
$_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries
$_course['titular' ] = $cData['tutor_name' ];
$_course['language' ] = $cData['course_language' ];
$_course['extLink' ]['url' ] = $cData['department_url' ];
$_course['extLink' ]['name'] = $cData['department_name'];
$_course['categoryCode'] = $cData['faCode' ];
$_course['categoryName'] = $cData['faName' ];
$_course['visibility' ] = $cData['visibility'];
$_course['subscribe_allowed'] = $cData['subscribe'];
$_course['unubscribe_allowed'] = $cData['unsubscribe'];
$_course['real_id'] = $cData['id'];
$_course['id'] = $cData['code']; //auto-assigned integer
$_course['name'] = $cData['title'];
$_course['official_code'] = $cData['visual_code']; // use in echo
$_course['sysCode'] = $cData['code']; // use as key in db
$_course['path'] = $cData['directory']; // use as key in path
$_course['dbName'] = $cData['db_name']; // use as key in db list
$_course['dbNameGlu'] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries
$_course['titular'] = $cData['tutor_name'];
$_course['language'] = $cData['course_language'];
$_course['extLink']['url' ] = $cData['department_url'];
$_course['extLink']['name'] = $cData['department_name'];
$_course['categoryCode'] = $cData['faCode'];
$_course['categoryName'] = $cData['faName'];
$_course['visibility'] = $cData['visibility'];
$_course['subscribe_allowed'] = $cData['subscribe'];
$_course['unubscribe_allowed'] = $cData['unsubscribe'];
api_session_register('_cid');
api_session_register('_course');
//@TODO real_cid should be cid, for working with numeric course id
api_session_register('_real_cid');
if ($_configuration['tracking_enabled'] && !isset($_SESSION['login_as'])) {
//We add a new record in the course tracking table
$course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
@ -832,6 +837,7 @@ if (isset($cidReset) && $cidReset) { // course session data refresh requested or
}
} else {
api_session_unregister('_cid');
api_session_unregister('_real_cid');
api_session_unregister('_course');
}
} else { // continue with the previous values

@ -134,6 +134,7 @@ UNLOCK TABLES;
DROP TABLE IF EXISTS course;
CREATE TABLE course (
id int auto_increment,
code varchar(40) NOT NULL,
directory varchar(40) default NULL,
db_name varchar(40) default NULL,
@ -156,7 +157,8 @@ CREATE TABLE course (
subscribe tinyint NOT NULL default '1',
unsubscribe tinyint NOT NULL default '1',
registration_code varchar(255) NOT NULL default '',
PRIMARY KEY (code)
PRIMARY KEY (id),
UNIQUE KEY code (code)
);
--

@ -228,7 +228,19 @@ CREATE TABLE track_e_hotspot (
KEY hotspot_question_id (hotspot_question_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
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,
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_course_access ADD INDEX (user_id);
ALTER TABLE track_e_course_access ADD INDEX (login_course_date);
ALTER TABLE track_e_course_access ADD INDEX (course_code);
ALTER TABLE track_e_online ADD INDEX (course);
ALTER TABLE track_e_online ADD INDEX (course);
ALTER TABLE track_e_item_property ADD INDEX (course_id, item_property_id, session_id);
Loading…
Cancel
Save