Version 16.250

This commit is contained in:
Antonio Cañas Vargas 2017-07-09 20:31:11 +02:00
parent 985066554f
commit 695b6c365b
8 changed files with 187 additions and 7 deletions

View File

@ -567,6 +567,57 @@ CREATE TABLE IF NOT EXISTS forum_thread (
UNIQUE INDEX(FirstPstCod),
UNIQUE INDEX(LastPstCod));
--
-- Table surveys: stores the games
--
CREATE TABLE IF NOT EXISTS games (
GamCod INT NOT NULL AUTO_INCREMENT,
Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',
Cod INT NOT NULL DEFAULT -1,
Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',
NumNotif INT NOT NULL DEFAULT 0,
Roles INT NOT NULL DEFAULT 0,
UsrCod INT NOT NULL,
StartTime DATETIME NOT NULL,
EndTime DATETIME NOT NULL,
Title VARCHAR(2047) NOT NULL,
Txt TEXT NOT NULL,
UNIQUE INDEX(GamCod),
INDEX(Scope,Cod));
--
-- Table gam_answers: stores the answers to the games
--
CREATE TABLE IF NOT EXISTS gam_answers (
QstCod INT NOT NULL,
AnsInd TINYINT NOT NULL,
NumUsrs INT NOT NULL DEFAULT 0,
Answer TEXT NOT NULL,
UNIQUE INDEX(QstCod,AnsInd));
--
-- Table gam_grp: stores the groups associated to each game
--
CREATE TABLE IF NOT EXISTS gam_grp (
GamCod INT NOT NULL,
GrpCod INT NOT NULL,
UNIQUE INDEX(GamCod,GrpCod));
--
-- Table gam_questions: stores the questions in the games
--
CREATE TABLE IF NOT EXISTS gam_questions (
QstCod INT NOT NULL AUTO_INCREMENT,
GamCod INT NOT NULL,
QstInd INT NOT NULL DEFAULT 0,
AnsType ENUM('unique_choice','multiple_choice') NOT NULL,
Stem TEXT NOT NULL,
UNIQUE INDEX(QstCod),
INDEX(GamCod));
--
-- Table gam_users: stores the users who have answer the games
--
CREATE TABLE IF NOT EXISTS gam_users (
GamCod INT NOT NULL,
UsrCod INT NOT NULL,
UNIQUE INDEX(GamCod,UsrCod));
--
-- Table hidden_params: stores some hidden parameters passed from a page to another using database instead of forms
--
CREATE TABLE IF NOT EXISTS hidden_params (

View File

@ -1291,7 +1291,7 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod)
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
NumGrpTyp++)
if (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttOrSvy (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],AsgCod,Grp_ASSIGNMENT);
Grp_ListGrpsToEditAsgAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],AsgCod,Grp_ASSIGNMENT);
/***** End table and box *****/
Box_EndBoxTable ();

View File

@ -1213,7 +1213,7 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod)
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
NumGrpTyp++)
if (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttOrSvy (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],AttCod,Grp_ATT_EVENT);
Grp_ListGrpsToEditAsgAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],AttCod,Grp_ATT_EVENT);
/***** End table and box *****/
Box_EndBoxTable ();

View File

@ -243,6 +243,14 @@
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/*
Version 16.250: Jul 09, 2017 Listing games for remote control. Not finished. (226738 lines)
5 changes necessary in database:
CREATE TABLE IF NOT EXISTS games (GamCod INT NOT NULL AUTO_INCREMENT,Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',Cod INT NOT NULL DEFAULT -1,Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',NumNotif INT NOT NULL DEFAULT 0,Roles INT NOT NULL DEFAULT 0,UsrCod INT NOT NULL,StartTime DATETIME NOT NULL,EndTime DATETIME NOT NULL,Title VARCHAR(2047) NOT NULL,Txt TEXT NOT NULL,UNIQUE INDEX(GamCod),INDEX(Scope,Cod));
CREATE TABLE IF NOT EXISTS gam_answers (QstCod INT NOT NULL,AnsInd TINYINT NOT NULL,NumUsrs INT NOT NULL DEFAULT 0,Answer TEXT NOT NULL,UNIQUE INDEX(QstCod,AnsInd));
CREATE TABLE IF NOT EXISTS gam_grp (GamCod INT NOT NULL,GrpCod INT NOT NULL,UNIQUE INDEX(GamCod,GrpCod));
CREATE TABLE IF NOT EXISTS gam_questions (QstCod INT NOT NULL AUTO_INCREMENT,GamCod INT NOT NULL,QstInd INT NOT NULL DEFAULT 0,AnsType ENUM('unique_choice','multiple_choice') NOT NULL,Stem TEXT NOT NULL,UNIQUE INDEX(QstCod),INDEX(GamCod));
CREATE TABLE IF NOT EXISTS gam_users (GamCod INT NOT NULL,UsrCod INT NOT NULL,UNIQUE INDEX(GamCod,UsrCod));
Version 16.249.5: Jul 06, 2017 Listing games for remote control. Not finished. (226564 lines)
Version 16.249.4: Jul 06, 2017 Listing games for remote control. Not finished. (226463 lines)
Version 16.249.3: Jul 04, 2017 Listing games for remote control. Not finished. (226322 lines)

View File

@ -1234,6 +1234,119 @@ mysql> DESCRIBE forum_thread;
"UNIQUE INDEX(FirstPstCod),"
"UNIQUE INDEX(LastPstCod))");
/***** Table games *****/
/*
mysql> DESCRIBE games;
+-----------+-------------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+-------------------------------------------+------+-----+---------+----------------+
| GamCod | int(11) | NO | PRI | NULL | auto_increment |
| Scope | enum('Sys','Cty','Ins','Ctr','Deg','Crs') | NO | MUL | Sys | |
| Cod | int(11) | NO | | -1 | |
| DegCod | int(11) | NO | | -1 | |
| CrsCod | int(11) | NO | | -1 | |
| Hidden | enum('N','Y') | NO | | N | |
| NumNotif | int(11) | NO | | 0 | |
| Roles | int(11) | NO | | 0 | |
| UsrCod | int(11) | NO | | NULL | |
| StartTime | datetime | NO | | NULL | |
| EndTime | datetime | NO | | NULL | |
| Title | varchar(2047) | NO | | NULL | |
| Txt | text | NO | | NULL | |
+-----------+-------------------------------------------+------+-----+---------+----------------+
13 rows in set (0,00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS games ("
"GamCod INT NOT NULL AUTO_INCREMENT,"
"Scope ENUM('Sys','Cty','Ins','Ctr','Deg','Crs') NOT NULL DEFAULT 'Sys',"
"Cod INT NOT NULL DEFAULT -1,"
"Hidden ENUM('N','Y') NOT NULL DEFAULT 'N',"
"NumNotif INT NOT NULL DEFAULT 0,"
"Roles INT NOT NULL DEFAULT 0,"
"UsrCod INT NOT NULL,"
"StartTime DATETIME NOT NULL,"
"EndTime DATETIME NOT NULL,"
"Title VARCHAR(2047) NOT NULL," // Svy_MAX_BYTES_SURVEY_TITLE
"Txt TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(GamCod),"
"INDEX(Scope,Cod))");
/***** Table gam_answers *****/
/*
mysql> DESCRIBE gam_answers;
+---------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+---------+-------+
| QstCod | int(11) | NO | PRI | NULL | |
| AnsInd | tinyint(4) | NO | PRI | NULL | |
| NumUsrs | int(11) | NO | | 0 | |
| Answer | text | NO | | NULL | |
+---------+------------+------+-----+---------+-------+
4 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_answers ("
"QstCod INT NOT NULL,"
"AnsInd TINYINT NOT NULL,"
"NumUsrs INT NOT NULL DEFAULT 0,"
"Answer TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(QstCod,AnsInd))");
/***** Table gam_grp *****/
/*
mysql> DESCRIBE gam_grp;
+--------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| GamCod | int(11) | NO | PRI | NULL | |
| GrpCod | int(11) | NO | PRI | NULL | |
+--------+---------+------+-----+---------+-------+
2 rows in set (0.01 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_grp ("
"GamCod INT NOT NULL,"
"GrpCod INT NOT NULL,"
"UNIQUE INDEX(GamCod,GrpCod))");
/***** Table gam_questions *****/
/*
mysql> DESCRIBE gam_questions;
+---------+-----------------------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-----------------------------------------+------+-----+---------+----------------+
| QstCod | int(11) | NO | PRI | NULL | auto_increment |
| SvyCod | int(11) | NO | MUL | NULL | |
| QstInd | int(11) | NO | | 0 | |
| AnsType | enum('unique_choice','multiple_choice') | NO | | NULL | |
| Stem | text | NO | | NULL | |
+---------+-----------------------------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_questions ("
"QstCod INT NOT NULL AUTO_INCREMENT,"
"GamCod INT NOT NULL,"
"QstInd INT NOT NULL DEFAULT 0,"
"AnsType ENUM ('unique_choice','multiple_choice') NOT NULL,"
"Stem TEXT NOT NULL," // Cns_MAX_BYTES_TEXT
"UNIQUE INDEX(QstCod),"
"INDEX(GamCod))");
/***** Table gam_users *****/
/*
mysql> DESCRIBE gam_users;
+--------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| SvyCod | int(11) | NO | PRI | NULL | |
| UsrCod | int(11) | NO | PRI | NULL | |
+--------+---------+------+-----+---------+-------+
2 rows in set (0.00 sec)
*/
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_users ("
"GamCod INT NOT NULL,"
"UsrCod INT NOT NULL,"
"UNIQUE INDEX(GamCod,UsrCod))");
/***** Table hidden_params *****/
/*
mysql> DESCRIBE hidden_params;

View File

@ -36,6 +36,7 @@
#include "swad_group.h"
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_remote_control.h"
#include "swad_table.h"
/*****************************************************************************/
@ -1645,10 +1646,12 @@ static void Grp_WriteHeadingGroups (void)
}
/*****************************************************************************/
/* List groups of a type to edit assignments, attendance events, or surveys **/
/********* List groups of a type **********/
/********* to edit assignments, attendance events, surveys or games **********/
/*****************************************************************************/
void Grp_ListGrpsToEditAsgAttOrSvy (struct GroupType *GrpTyp,long Cod,Grp_AsgOrSvy_t Grp_AsgAttOrSvy)
void Grp_ListGrpsToEditAsgAttSvyGam (struct GroupType *GrpTyp,long Cod,
Grp_AsgAttSvyGam_t Grp_AsgAttOrSvy)
{
struct ListCodGrps LstGrpsIBelong;
unsigned NumGrpThisType;
@ -1694,6 +1697,9 @@ void Grp_ListGrpsToEditAsgAttOrSvy (struct GroupType *GrpTyp,long Cod,Grp_AsgOrS
case Grp_SURVEY:
AssociatedToGrp = Svy_CheckIfSvyIsAssociatedToGrp (Cod,Grp->GrpCod);
break;
case Grp_GAME:
AssociatedToGrp = Rmt_CheckIfGamIsAssociatedToGrp (Cod,Grp->GrpCod);
break;
}
if (AssociatedToGrp)
fprintf (Gbl.F.Out," checked=\"checked\"");

View File

@ -126,7 +126,8 @@ typedef enum
Grp_ASSIGNMENT,
Grp_ATT_EVENT,
Grp_SURVEY,
} Grp_AsgOrSvy_t;
Grp_GAME,
} Grp_AsgAttSvyGam_t;
/*****************************************************************************/
/****************************** Public prototypes ****************************/
@ -151,7 +152,8 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGrps);
void Grp_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod);
void Grp_RemUsrFromAllGrps (long UsrCod);
void Grp_ListGrpsToEditAsgAttOrSvy (struct GroupType *GrpTyp,long Cod,Grp_AsgOrSvy_t Grp_AsgOrSvy);
void Grp_ListGrpsToEditAsgAttSvyGam (struct GroupType *GrpTyp,long Cod,
Grp_AsgAttSvyGam_t Grp_AsgOrSvy);
void Grp_ReqRegisterInGrps (void);
void Grp_ShowLstGrpsToChgMyGrps (void);

View File

@ -2043,7 +2043,7 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod)
NumGrpTyp < Gbl.CurrentCrs.Grps.GrpTypes.Num;
NumGrpTyp++)
if (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttOrSvy (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],SvyCod,Grp_SURVEY);
Grp_ListGrpsToEditAsgAttSvyGam (&Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],SvyCod,Grp_SURVEY);
/***** End table and box *****/
Box_EndBoxTable ();