
CREATE TABLE prefix_autoattend_sessions (
  id 	 		SERIAL PRIMARY KEY,
  courseid 		integer NOT NULL default '0',
  creator 		integer NOT NULL default '0',
  sessdate 		integer NOT NULL default '0',
  takenby 		integer NOT NULL default '0',
  timetaken 	integer NOT NULL default '0',
  timemodified 	integer NOT NULL default '0',

  method		varchar(1) NOT NULL default 'S',
  state			varchar(1) NOT NULL default 'N',
  starttime		integer NOT NULL default '0',
  latetime		integer NOT NULL default '0',
  endtime		integer NOT NULL default '0',
  denysameip	integer NOT NULL default '1'

  attendkey		varchar(36)  NULL default '',
  allowip		varchar(128) NULL default '',
  description 	varchar(128) NULL default '',
);

CREATE INDEX prefix_autoattend_sessions_courseid_idx  ON prefix_autoattend_sessions (courseid);
CREATE INDEX prefix_autoattend_sessions_sessdate_idx  ON prefix_autoattend_sessions (sessdate);
CREATE INDEX prefix_autoattend_sessions_starttime_idx ON prefix_autoattend_sessions (starttime);



CREATE TABLE prefix_autoattend_students (
  id 			SERIAL PRIMARY KEY,
  attsid 		integer NOT NULL default '0',
  studentid 	integer NOT NULL default '0',
  status 		varchar(1)  NOT NULL default 'Y',
  called    	varchar(1)  NOT NULL default 'D',
  alledby		integer NOT NULL default '0',
  calledtime	integer NOT NULL default '0',
  remarks 		varchar(50) default '',
  ipaddress 	varchar(20) default ''
);

CREATE INDEX prefix_autoattend_students_attsid_idx    ON prefix_autoattend_students (attsid);
CREATE INDEX prefix_autoattend_students_studentid_idx ON prefix_autoattend_students (studentid);
CREATE INDEX prefix_autoattend_students_status_idx    ON prefix_autoattend_students (status);



CREATE TABLE prefix_autoattend_settings (
  id 		SERIAL PRIMARY KEY,
  courseid 	integer NOT NULL default '0',
  status 	varchar(1) NOT NULL default 'Y',
  grade 	integer NOT NULL default '0'
);

CREATE INDEX prefix_autoattend_settings_courseid_idx ON prefix_autoattend_settings (courseid);
CREATE INDEX prefix_autoattend_settings_status_idx 	 ON prefix_autoattend_settings (status);



INSERT INTO prefix_autoattend_settings VALUES (nextval('id'), 0, 'P', '2');
INSERT INTO prefix_autoattend_settings VALUES (nextval('id'), 0, 'L', '1');
INSERT INTO prefix_autoattend_settings VALUES (nextval('id'), 0, 'E', '1');
INSERT INTO prefix_autoattend_settings VALUES (nextval('id'), 0, 'X', '0');
INSERT INTO prefix_autoattend_settings VALUES (nextval('id'), 0, 'Y', '0');

