From 695b6c365bb36981a6a09d54293fab5c2b80ebd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 9 Jul 2017 20:31:11 +0200 Subject: [PATCH] Version 16.250 --- sql/swad.sql | 51 +++++++++++++++++++++ swad_assignment.c | 2 +- swad_attendance.c | 2 +- swad_changelog.h | 8 ++++ swad_database.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++ swad_group.c | 10 +++- swad_group.h | 6 ++- swad_survey.c | 2 +- 8 files changed, 187 insertions(+), 7 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index ff101bd59..2caf94168 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -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 ( diff --git a/swad_assignment.c b/swad_assignment.c index 3c115e79d..54b526695 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -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 (); diff --git a/swad_attendance.c b/swad_attendance.c index c637de8f5..6932f64c3 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -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 (); diff --git a/swad_changelog.h b/swad_changelog.h index 7c4c8b11e..96294b7d8 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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) diff --git a/swad_database.c b/swad_database.c index 0de9af6e3..d27f801cf 100644 --- a/swad_database.c +++ b/swad_database.c @@ -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; diff --git a/swad_group.c b/swad_group.c index b1c02bf90..543ee47fd 100644 --- a/swad_group.c +++ b/swad_group.c @@ -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\""); diff --git a/swad_group.h b/swad_group.h index 13dfbd03f..fcb43e524 100644 --- a/swad_group.h +++ b/swad_group.h @@ -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); diff --git a/swad_survey.c b/swad_survey.c index d33e897da..c32a044d5 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -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 ();