From 99890d63517adff2745f55cb530305893cad99d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 19 Sep 2017 16:45:42 +0200 Subject: [PATCH] Version 17.3.8 --- sql/swad.sql | 9 +++++---- swad_changelog.h | 6 +++++- swad_database.c | 24 +++++++++++++----------- swad_project.c | 45 ++++++++++++++++++++++++++++----------------- swad_role_type.h | 2 +- 5 files changed, 52 insertions(+), 34 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 7ba87a2d8..41e71e905 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -930,12 +930,13 @@ CREATE TABLE IF NOT EXISTS plugins ( IP CHAR(15) NOT NULL, UNIQUE INDEX(PlgCod)); -- --- Table Prj_grp: stores the groups associated to projects +-- Table prj_usr: stores the users inside projects -- -CREATE TABLE IF NOT EXISTS prj_grp ( +CREATE TABLE IF NOT EXISTS prj_usr ( PrjCod INT NOT NULL, - GrpCod INT NOT NULL, - UNIQUE INDEX(PrjCod,GrpCod)); + RoleInProject TINYINT NOT NULL DEFAULT 0, + UsrCod INT NOT NULL, + UNIQUE INDEX(PrjCod,RoleInProject,UsrCod)); -- -- Table projects: stores the projects proposed by the teachers to their students -- diff --git a/swad_changelog.h b/swad_changelog.h index 21f1a6e4e..2ffee3d4b 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -252,13 +252,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 17.3.7 (2017-09-19)" +#define Log_PLATFORM_VERSION "SWAD 17.3.8 (2017-09-19)" #define CSS_FILE "swad17.0.css" #define JS_FILE "swad16.206.3.js" // 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 17.3.8: Sep 19, 2017 Table for users in projects. (230000 lines) +DROP TABLE IF EXISTS prj_grp; +CREATE TABLE IF NOT EXISTS prj_usr (PrjCod INT NOT NULL,RoleInProject TINYINT NOT NULL DEFAULT 0,UsrCod INT NOT NULL,UNIQUE INDEX(PrjCod,RoleInProject,UsrCod)); + Version 17.3.7: Sep 19, 2017 New row in listing of projects for tutors. Not finished. (229983 lines) Version 17.3.6: Sep 19, 2017 Changes in listing of projects. (229849 lines) Version 17.3.5: Sep 19, 2017 Removed groups in projects. (229858 lines) diff --git a/swad_database.c b/swad_database.c index 5c1b8b0b9..976618cda 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1987,19 +1987,21 @@ mysql> DESCRIBE plugins; /***** Table prj_grp *****/ /* -mysql> DESCRIBE prj_grp; -+--------+---------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------+---------+------+-----+---------+-------+ -| PrjCod | int(11) | NO | PRI | NULL | | -| GrpCod | int(11) | NO | PRI | NULL | | -+--------+---------+------+-----+---------+-------+ -2 rows in set (0,00 sec) +mysql> DESCRIBE prj_usr; ++---------------+------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++---------------+------------+------+-----+---------+-------+ +| PrjCod | int(11) | NO | PRI | NULL | | +| RoleInProject | tinyint(4) | NO | PRI | 0 | | +| UsrCod | int(11) | NO | PRI | NULL | | ++---------------+------------+------+-----+---------+-------+ +3 rows in set (0,00 sec) */ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS prj_grp (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS prj_usr (" "PrjCod INT NOT NULL," - "GrpCod INT NOT NULL," - "UNIQUE INDEX(PrjCod,GrpCod))"); + "RoleInProject TINYINT NOT NULL DEFAULT 0," + "UsrCod INT NOT NULL," + "UNIQUE INDEX(PrjCod,RoleInProject,UsrCod))"); /***** Table projects *****/ /* diff --git a/swad_project.c b/swad_project.c index 283f288ca..fa978b074 100644 --- a/swad_project.c +++ b/swad_project.c @@ -48,12 +48,21 @@ extern struct Globals Gbl; /*****************************************************************************/ -/***************************** Private constants *****************************/ +/************************* Public constants and types ************************/ /*****************************************************************************/ +// Related with user's roles in a project +/* + Don't change these numbers! They are used in database +*/ -/*****************************************************************************/ -/******************************* Private types *******************************/ -/*****************************************************************************/ +#define Prj_NUM_ROLES_IN_PROJECT 4 +typedef enum + { + Prj_ROLE_UNK = 0, // Unknown + Prj_ROLE_STD = 1, // Student + Prj_ROLE_TUT = 2, // Tutor + Prj_ROLE_REV = 3, // Reviewer + } Prj_RoleInProject_t; /*****************************************************************************/ /***************************** Private variables *****************************/ @@ -70,7 +79,7 @@ static void Prj_PutIconsListProjects (void); static void Prj_PutIconToCreateNewPrj (void); static void Prj_PutButtonToCreateNewPrj (void); static void Prj_ShowOneProject (struct Project *Prj,bool PrintView); -static void Prj_WriteUsrs (long PrjCod); +static void Prj_WriteUsrs (long PrjCod,Prj_RoleInProject_t RoleInProject); static void Prj_WritePrjAuthor (struct Project *Prj); static void Prj_GetParamPrjOrder (void); @@ -514,7 +523,7 @@ static void Prj_ShowOneProject (struct Project *Prj,bool PrintView) "DAT", Prj->Materials); - /* Project tutors */ + /* Project tutors */ fprintf (Gbl.F.Out,"" "", Prj->Hidden ? "DAT_LIGHT" : "DAT"); - Prj_WriteUsrs (Prj->PrjCod); + Prj_WriteUsrs (Prj->PrjCod,Prj_ROLE_TUT); fprintf (Gbl.F.Out,"" ""); @@ -539,10 +548,10 @@ static void Prj_ShowOneProject (struct Project *Prj,bool PrintView) } /*****************************************************************************/ -/******************** Write list of recipients of a message ******************/ +/*************** Write list of users with a role in a project ****************/ /*****************************************************************************/ -static void Prj_WriteUsrs (long PrjCod) +static void Prj_WriteUsrs (long PrjCod,Prj_RoleInProject_t RoleInProject) { extern const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; @@ -559,22 +568,24 @@ static void Prj_WriteUsrs (long PrjCod) bool ShowPhoto; char PhotoURL[PATH_MAX + 1]; - /***** Get number of users of a project from database *****/ - sprintf (Query,"SELECT COUNT(*) FROM prj_usr WHERE PrjCod=%ld", - PrjCod); - NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get number of recipients"); + /***** Get number of users in project from database *****/ + sprintf (Query,"SELECT COUNT(*) FROM prj_usr" + " WHERE PrjCod=%ld AND RoleInProject=%u", + PrjCod,(unsigned) RoleInProject); + NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get users in project"); - /***** Get users of a project from database *****/ + /***** Get users in project from database *****/ sprintf (Query,"SELECT prj_usr.UsrCod," "usr_data.Surname1 AS S1," "usr_data.Surname2 AS S2," "usr_data.FirstName AS FN" " FROM prj_usr,usr_data" - " WHERE prj_usr.PrjCod=%ld" + " WHERE prj_usr.PrjCod=%ld AND RoleInProject=%u" " AND prj_usr.UsrCod=usr_data.UsrCod" " ORDER BY S1,S2,FN", - PrjCod); - NumUsrsKnown = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get users of a project"); + PrjCod,(unsigned) RoleInProject); + NumUsrsKnown = (unsigned) DB_QuerySELECT (Query,&mysql_res, + "can not get users in project"); /***** Check number of users *****/ if (NumUsrs) diff --git a/swad_role_type.h b/swad_role_type.h index f3c38c78a..9241544e0 100644 --- a/swad_role_type.h +++ b/swad_role_type.h @@ -28,7 +28,7 @@ /*****************************************************************************/ /*****************************************************************************/ -/************************** Public constant and types ************************/ +/************************* Public constants and types ************************/ /*****************************************************************************/ // Related with user's roles