added new tables for attendance tool - partial CT#581

skala
Cristian Fasanando 15 years ago
parent bd95a52aaf
commit a369d05e19
  1. 69
      main/inc/lib/add_course.lib.inc.php
  2. 6
      main/inc/lib/database.lib.php
  3. 12
      main/install/migrate-db-1.8.6.2-1.8.7-pre.sql

@ -391,6 +391,14 @@ function update_Db_course($courseDbName, $language = null)
// Notebook
$TBL_NOTEBOOK = $courseDbName . 'notebook';
// Attendance
$TBL_ATTENDANCE = $courseDbName . 'attendance';
$TBL_ATTENDANCE_SHEET = $courseDbName . 'attendance_sheet';
$TBL_ATTENDANCE_CALENDAR = $courseDbName . 'attendance_calendar';
$TBL_ATTENDANCE_RESULT = $courseDbName . 'attendance_result';
/*
-----------------------------------------------------------
Announcement tool
@ -1713,6 +1721,67 @@ function update_Db_course($courseDbName, $language = null)
)" . $charset_clause;
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
/* Attendance tool */
// attendance table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE."` (
id int NOT NULL auto_increment PRIMARY KEY,
name text NOT NULL,
description TEXT NULL,
active tinyint(3) NOT NULL default 1,
attendance_qualify_title varchar(255) NULL,
attendance_qualify_max int NOT NULL default 0,
attendance_weight float(6,2) NOT NULL default '0.0',
session_id int NOT NULL default 0
)" . $charset_clause;
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TBL_ATTENDANCE . "` ADD INDEX (session_id)";
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TBL_ATTENDANCE . "` ADD INDEX (active)";
Database::query($sql, __FILE__, __LINE__);
// attendance sheet table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_SHEET."` (
user_id int NOT NULL,
attendance_calendar_id int NOT NULL,
presence tinyint(3) NOT NULL DEFAULT 0,
PRIMARY KEY(user_id, attendance_calendar_id)
)" . $charset_clause;
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_SHEET . "` ADD INDEX (presence) ";
Database::query($sql, __FILE__, __LINE__);
// attendance calendar table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_CALENDAR."` (
id int NOT NULL auto_increment,
attendance_id int NOT NULL ,
date_time datetime NOT NULL default '0000-00-00 00:00:00',
done_attendance tinyint(3) NOT NULL default 0,
PRIMARY KEY(id)
)" . $charset_clause;
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (attendance_id)";
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_CALENDAR."` ADD INDEX (done_attendance)";
Database::query($sql, __FILE__, __LINE__);
// attendance result table
$sql = "
CREATE TABLE `".$TBL_ATTENDANCE_RESULT."` (
id int NOT NULL auto_increment PRIMARY KEY,
user_id int NOT NULL,
attendance_id int NOT NULL,
score int NOT NULL DEFAULT 0
)" . $charset_clause;
$result = Database::query($sql, __FILE__, __LINE__) or die(mysql_error($sql));
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_RESULT."` ADD INDEX (attendance_id)";
Database::query($sql, __FILE__, __LINE__);
$sql = "ALTER TABLE `".$TBL_ATTENDANCE_RESULT."` ADD INDEX (user_id)";
Database::query($sql, __FILE__, __LINE__);
return 0;
}

@ -267,6 +267,12 @@ define('TABLE_MESSAGE_ATTACHMENT', 'message_attachment');
// Metadata
define('TABLE_METADATA', 'metadata');
// Attendance Sheet
define('TABLE_ATTENDANCE','attendance');
define('TABLE_ATTENDANCE_CALENDAR', 'attendance_calendar');
define('TABLE_ATTENDANCE_SHEET','attendance_sheet');
define('TABLE_ATTENDANCE_RESULT', 'attendance_result');
/*
==============================================================================

@ -35,4 +35,14 @@ INSERT INTO tool(name,link,image,visibility,admin,address,added_tool,target,cate
ALTER TABLE course_description ADD COLUMN progress INT NOT NULL DEFAULT 0 AFTER description_type;
ALTER TABLE item_property ADD id int NOT NULL auto_increment PRIMARY KEY FIRST;
UPDATE course_description SET description_type = (SELECT IF(description_type>7,description_type+1,description_type)); -- update description_type field for using thematic advance with description_type = 8
CREATE TABLE attendance_calendar (id int NOT NULL auto_increment, attendance_id int NOT NULL, date_time datetime NOT NULL default '0000-00-00 00:00:00', done_attendance tinyint(3) NOT NULL default 0, PRIMARY KEY(id));
ALTER TABLE attendance_calendar ADD INDEX(attendance_id);
ALTER TABLE attendance_calendar ADD INDEX(done_attendance);
CREATE TABLE attendance_sheet (user_id int NOT NULL, attendance_calendar_id int NOT NULL, presence tinyint(3) NOT NULL DEFAULT 0, PRIMARY KEY(user_id, attendance_calendar_id));
ALTER TABLE attendance_sheet ADD INDEX(presence);
CREATE TABLE attendance_result (id int NOT NULL auto_increment PRIMARY KEY, user_id int NOT NULL, attendance_id int NOT NULL, score int NOT NULL DEFAULT 0);
ALTER TABLE attendance_result ADD INDEX(attendance_id);
ALTER TABLE attendance_result ADD INDEX(user_id);
CREATE TABLE attendance (id int NOT NULL auto_increment PRIMARY KEY, name text NOT NULL, description TEXT NULL, active tinyint(3) NOT NULL default 1, attendance_qualify_title varchar(255) NULL, attendance_qualify_max int NOT NULL default 0, attendance_weight float(6,2) NOT NULL default '0.0', session_id int NOT NULL default 0);
ALTER TABLE attendance ADD INDEX(session_id);
ALTER TABLE attendance ADD INDEX(active);
Loading…
Cancel
Save