Index: openacs-4/packages/cards/sql/postgresql/cards-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/cards/sql/postgresql/cards-create.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/cards/sql/postgresql/cards-create.sql	10 Jun 2005 08:26:55 -0000	1.1
+++ openacs-4/packages/cards/sql/postgresql/cards-create.sql	22 Jun 2006 10:49:22 -0000	1.2
@@ -1,82 +1,73 @@
 -- TABLE UV_CARD -------------------------------------------------------------
-create sequence uv_card_sequence start 1;
-create table uv_card (
-    id_card           integer primary key default nextval ('uv_card_sequence'),
-    ref_community_id  integer not null,
-    ref_user_id       integer not null,
+create sequence card_sequence start 1;
+create table card (
+    card_id           integer primary key default nextval ('card_sequence'),
+    ref_community     integer not null,
+    ref_user          integer not null,
     comm_student      varchar (1000),
     comm_teacher      varchar (1000),
+    closed            boolean default 'f',
     address           varchar (300),
-    phone1            varchar (30),
-    phone2            varchar (30)
+    phone1            varchar (60),
+    grade             varchar (30)
 );
-create unique index uv_card_idx on uv_card (ref_community_id, ref_user_id);
+create unique index card_idx on card (ref_community, ref_user);
 
-
--- TABLE UV_CARD_BASE_NOTE -------------------------------------------------------------
-create table uv_card_base_note (
-        community_id    integer primary key,
-        base_note       integer not null default 100,
-        alum_view   integer default 0
-); 
-
--- TABLE UV_CARD_BASETYPE_NOTE -------------------------------------------------------------
-create table uv_card_basetype_note (
-        id_basetype     integer primary key,          
-        name_basetype   varchar (30),
-        info_basetype   varchar (300),
-        is_numeric      boolean default true
+-- TABLE  CARD_PERCENT -------------------------------------------------------------
+create sequence card_percent_sequence start 1;
+create table card_percent (
+        percent_id          integer primary key default nextval('card_percent_sequence'),  
+        ref_community       integer not null,
+        percent_name        varchar (50),
+                type                            integer not null,
+        percent             double precision default 0,        
+        rvalor              double precision default 0.0
 );
+create index card_percent_comm_idx on card_percent (ref_community);
 
--- TABLE UV_CARD_XCENT_NOTE -------------------------------------------------------------
-create sequence uv_card_xcent_note_sequence start 1;
-create table uv_card_xcent_note (
-        id_xcent                integer primary key default nextval('uv_card_xcent_note_sequence'),  
-        ref_community_id        integer not null,
-        ref_basetype    integer not null,
-        name_xcent              varchar (50),
-        xcent               double precision default 0,
-        allow_act               boolean default false,
-        rvalor          double precision default 0.0,
-        np              boolean default false,
-        constraint              ref_basetype_fk foreign key (ref_basetype) references uv_card_basetype_note (id_basetype)
+-- TABLE CARD_TASK -------------------------------------------------------------
+create sequence card_task_sequence start 1;  
+create table card_task (
+        task_id                         integer primary key default nextval('card_task_sequence'),
+        ref_community       integer not null,
+        ref_percent         integer not null,
+                task_name           varchar (50),
+        task_percent        double precision default 0.00,
+                max_grade           double precision not null default 10.00,
+        constraint          ref_percent_fk foreign key (ref_percent) references card_percent (percent_id)
 );
-create index uv_card_xcent_comm_idx on uv_card_xcent_note (ref_community_id);
+create index card_task_comm_idx on card_task (ref_community);
+create index card_task_percent_idx on card_task (ref_percent);    
 
--- TABLE UV_CARD_SUBTYPE_NOTE -------------------------------------------------------------
-create sequence uv_card_subtype_note_sequence start 1;  
-create table uv_card_subtype_note (
-        id_subtype              integer primary key default nextval('uv_card_subtype_note_sequence'),
-        ref_community_id        integer not null,
-        ref_xcent               integer not null,
-        sub_xcent       double precision default 0.00,
-        name_subtype    varchar (50),
-        constraint              ref_xcent_fk foreign key (ref_xcent) references uv_card_xcent_note (id_xcent)
+-- TABLE CARD_NOTE -------------------------------------------------------------
+create sequence card_note_sequence start 1;
+create table card_note (
+        note_id        integer primary key default nextval('card_note_sequence'),
+        ref_card        integer not null,        
+                ref_community   integer not null,
+        ref_task        integer not null,
+                date            timestamptz default current_timestamp not null,
+                date_mod        timestamptz default current_timestamp not null,
+        grade           numeric(4,2) default 0.00,
+        note_comment    varchar (400),        
+        is_active       boolean default true,        
+        constraint      ref_task_fk foreign key (ref_task) references card_task (task_id),
+        constraint      ref_id_cards_fk foreign key (ref_card) references card (card_id)
 );
-create index uv_card_subtype_comm_idx on uv_card_subtype_note (ref_community_id);
-create index uv_card_subtype_xcent_idx on uv_card_subtype_note (ref_xcent);    
+create index card_note_comm_idx on card_note (ref_community);
+create index card_note_task_idx on card_note (ref_task);
 
--- TABLE UV_CARD_NOTES -------------------------------------------------------------
-create sequence uv_card_notes_sequence start 1;
-create table uv_card_notes (
-        id_card_notes   integer primary key default nextval('uv_card_notes_sequence'),
-        ref_id_card     integer not null,
-        note_datetime   timestamptz default current_timestamp not null,
-        ref_subtype     integer not null,
-        value_n         numeric(4,2) default 0.00,
-        value_s         varchar (300),
-        is_public       boolean default false,
-        is_active       boolean default true,
-        r_community_id  integer not null,
-        constraint      ref_subtype_fk foreign key (ref_subtype) references uv_card_subtype_note(id_subtype),
-        constraint      ref_id_cards_fk foreign key (ref_id_card) references uv_card(id_card)
-);
-create index uv_card_notes_comm_idx on uv_card_notes (r_community_id);
-create index uv_card_notes_subtype_idx on uv_card_notes (ref_subtype);
 
 
--- INICIALIZACI�N DE DATOS -------------------------------------------------------------
-insert into uv_card_basetype_note (id_basetype, name_basetype, info_basetype, is_numeric) values (1,'B�sico', 'Anotaciones sencillas: pr�cticas, tareas, trabajos, actividades, ...','t');
-insert into uv_card_basetype_note (id_basetype, name_basetype, info_basetype, is_numeric) values (2,'Seleccionable', 'Anotaciones que permiten selecci�n: ex�menes','t');
-insert into uv_card_basetype_note (id_basetype, name_basetype, info_basetype, is_numeric) values (3,'Texto', 'Anotaciones sin asignaci�n de nota: comentarios','f');
-
+-- TABLE CARD_COMMENTS  -------------------------------------------------------------
+create sequence card_comment_sequence start 1;
+create table card_comment (
+        comment_id      integer primary key default nextval('card_comment_sequence'),
+        ref_card        integer not null,        
+                ref_community   integer not null,
+        date            timestamptz default current_timestamp not null,
+                date_mod        timestamptz default current_timestamp not null,
+        comment         varchar (400),        
+        constraint      ref_id_cards_fk foreign key (ref_card) references card(card_id)
+);
+create index card_comment_comm_idx on card_comment (ref_community);
