mirror of https://github.com/acanas/swad-core.git
Version19.22
This commit is contained in:
parent
49d0c44847
commit
87751bd965
|
@ -471,10 +471,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.21 (2019-09-29)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.22 (2019-09-29)"
|
||||
#define CSS_FILE "swad19.15.css"
|
||||
#define JS_FILE "swad19.15.js"
|
||||
/*
|
||||
Version 19.22: Sep 29, 2019 Remove user from match tables in course. (246703 lines)
|
||||
Version 19.21: Sep 29, 2019 Code refactoring in games and matches. (246674 lines)
|
||||
Version 19.20: Sep 29, 2019 Code refactoring in games and matches. (246631 lines)
|
||||
14 changes necessary in database:
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_ID.h"
|
||||
#include "swad_match.h"
|
||||
#include "swad_notification.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_role.h"
|
||||
|
@ -91,11 +92,12 @@ typedef enum
|
|||
Enr_REMOVE_USR,
|
||||
} Enr_ReqDelOrDelUsr_t;
|
||||
|
||||
/* Remove important user production (works and match results)? */
|
||||
typedef enum
|
||||
{
|
||||
Enr_DO_NOT_REMOVE_WORKS,
|
||||
Enr_REMOVE_WORKS,
|
||||
} Enr_RemoveUsrWorks_t;
|
||||
Enr_DO_NOT_REMOVE_USR_PRODUCTION,
|
||||
Enr_REMOVE_USR_PRODUCTION,
|
||||
} Enr_RemoveUsrProduction_t;
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
|
@ -165,8 +167,10 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t
|
|||
|
||||
static void Enr_ReqAddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName);
|
||||
static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat);
|
||||
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *Crs,
|
||||
Enr_RemoveUsrWorks_t RemoveUsrWorks,Cns_QuietOrVerbose_t QuietOrVerbose);
|
||||
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
||||
struct Course *Crs,
|
||||
Enr_RemoveUsrProduction_t RemoveUsrWorks,
|
||||
Cns_QuietOrVerbose_t QuietOrVerbose);
|
||||
|
||||
static void Enr_AskIfRemAdm (bool ItsMe,Hie_Level_t Scope,
|
||||
const char *InsCtrDegName);
|
||||
|
@ -1299,14 +1303,16 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
|||
else // The teacher has not selected groups
|
||||
{
|
||||
Enr_EffectivelyRemUsrFromCrs (&UsrDat,&Gbl.Hierarchy.Crs,
|
||||
Enr_DO_NOT_REMOVE_WORKS,Cns_QUIET); // Remove user from the course
|
||||
Enr_DO_NOT_REMOVE_USR_PRODUCTION,
|
||||
Cns_QUIET); // Remove user from the course
|
||||
NumUsrsRemoved++;
|
||||
}
|
||||
}
|
||||
else // No groups
|
||||
{
|
||||
Enr_EffectivelyRemUsrFromCrs (&UsrDat,&Gbl.Hierarchy.Crs,
|
||||
Enr_DO_NOT_REMOVE_WORKS,Cns_QUIET); // Remove user from the course
|
||||
Enr_DO_NOT_REMOVE_USR_PRODUCTION,
|
||||
Cns_QUIET); // Remove user from the course
|
||||
NumUsrsRemoved++;
|
||||
}
|
||||
}
|
||||
|
@ -1925,7 +1931,8 @@ unsigned Enr_RemAllStdsInCrs (struct Course *Crs)
|
|||
{
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.LstUsrs[Rol_STD].Lst[NumUsr].UsrCod;
|
||||
Enr_EffectivelyRemUsrFromCrs (&Gbl.Usrs.Other.UsrDat,Crs,
|
||||
Enr_REMOVE_WORKS,Cns_QUIET);
|
||||
Enr_REMOVE_USR_PRODUCTION,
|
||||
Cns_QUIET);
|
||||
}
|
||||
|
||||
/***** Free memory for students list *****/
|
||||
|
@ -3459,7 +3466,8 @@ void Enr_RemUsrFromCrs1 (void)
|
|||
{
|
||||
if (Enr_CheckIfICanRemUsrFromCrs ())
|
||||
Enr_EffectivelyRemUsrFromCrs (&Gbl.Usrs.Other.UsrDat,&Gbl.Hierarchy.Crs,
|
||||
Enr_REMOVE_WORKS,Cns_VERBOSE);
|
||||
Enr_REMOVE_USR_PRODUCTION,
|
||||
Cns_VERBOSE);
|
||||
else
|
||||
Ale_CreateAlertUserNotFoundOrYouDoNotHavePermission ();
|
||||
}
|
||||
|
@ -4099,8 +4107,10 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
|||
/************************ Remove a user from a course ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *Crs,
|
||||
Enr_RemoveUsrWorks_t RemoveUsrWorks,Cns_QuietOrVerbose_t QuietOrVerbose)
|
||||
static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
|
||||
struct Course *Crs,
|
||||
Enr_RemoveUsrProduction_t RemoveUsrWorks,
|
||||
Cns_QuietOrVerbose_t QuietOrVerbose)
|
||||
{
|
||||
extern const char *Txt_THE_USER_X_has_been_removed_from_the_course_Y;
|
||||
bool ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
|
@ -4116,10 +4126,16 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course *
|
|||
/***** Remove user's status about reading of course information *****/
|
||||
Inf_RemoveUsrFromCrsInfoRead (UsrDat->UsrCod,Crs->CrsCod);
|
||||
|
||||
/***** Remove works zone of this user in course *****/
|
||||
if (RemoveUsrWorks == Enr_REMOVE_WORKS)
|
||||
/***** Remove important production of this user in course *****/
|
||||
if (RemoveUsrWorks == Enr_REMOVE_USR_PRODUCTION)
|
||||
{
|
||||
/* Remove works zone in course */
|
||||
Brw_RemoveUsrWorksInCrs (UsrDat,Crs);
|
||||
|
||||
/* Remove user's matches in course */
|
||||
Mch_RemoveUsrFromMatchTablesInCrs (UsrDat->UsrCod,Crs->CrsCod);
|
||||
}
|
||||
|
||||
/***** Remove fields of this user in its course record *****/
|
||||
Rec_RemoveFieldsCrsRecordInCrs (UsrDat->UsrCod,Crs);
|
||||
|
||||
|
|
154
swad_match.c
154
swad_match.c
|
@ -83,23 +83,6 @@ const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
|||
"results",
|
||||
};
|
||||
|
||||
/*
|
||||
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
||||
*/
|
||||
const char *MatchSecondaryTables[] =
|
||||
{
|
||||
"mch_players", // match players
|
||||
"mch_playing", // matches being played
|
||||
"mch_results", // matches results
|
||||
"mch_answers", // students' answers to matches
|
||||
"mch_times", // times associated to matches
|
||||
"mch_groups", // groups associated to matches
|
||||
"mch_indexes", // indexes associated to matches
|
||||
// "mch_matches" // the matches themselves, this table is treated separately
|
||||
};
|
||||
#define Mch_NUM_SECONDARY_TABLES (sizeof (MatchSecondaryTables) / \
|
||||
sizeof (MatchSecondaryTables[0]))
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private variables *****************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -136,6 +119,7 @@ static void Mch_RemoveMatchFromAllTables (long MchCod);
|
|||
static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName);
|
||||
static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName);
|
||||
static void Mch_RemoveMatchInCourseFromTable (long CrsCod,const char *TableName);
|
||||
static void Mch_RemoveUsrMchResultsInCrs (long UsrCod,long CrsCod,const char *TableName);
|
||||
|
||||
static void Mch_PutParamsEdit (void);
|
||||
static void Mch_PutParamsPlay (void);
|
||||
|
@ -946,16 +930,19 @@ void Mch_RemoveMatch (void)
|
|||
/*****************************************************************************/
|
||||
/********************** Remove match from all tables *************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
||||
*/
|
||||
static void Mch_RemoveMatchFromAllTables (long MchCod)
|
||||
{
|
||||
unsigned NumTable;
|
||||
|
||||
/***** Remove match from secondary tables *****/
|
||||
for (NumTable = 0;
|
||||
NumTable < Mch_NUM_SECONDARY_TABLES;
|
||||
NumTable++)
|
||||
Mch_RemoveMatchFromTable (MchCod,MatchSecondaryTables[NumTable]);
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_players");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_playing");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_results");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_answers");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_times");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_groups");
|
||||
Mch_RemoveMatchFromTable (MchCod,"mch_indexes");
|
||||
|
||||
/***** Remove match from main table *****/
|
||||
DB_QueryDELETE ("can not remove match",
|
||||
|
@ -963,53 +950,6 @@ static void Mch_RemoveMatchFromAllTables (long MchCod)
|
|||
MchCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove match in game from all tables *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mch_RemoveMatchesInGameFromAllTables (long GamCod)
|
||||
{
|
||||
unsigned NumTable;
|
||||
|
||||
/***** Remove matches from secondary tables *****/
|
||||
for (NumTable = 0;
|
||||
NumTable < Mch_NUM_SECONDARY_TABLES;
|
||||
NumTable++)
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,MatchSecondaryTables[NumTable]);
|
||||
|
||||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a game",
|
||||
"DELETE FROM mch_matches WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Remove match in course from all tables ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mch_RemoveMatchInCourseFromAllTables (long CrsCod)
|
||||
{
|
||||
unsigned NumTable;
|
||||
|
||||
/***** Remove matches from secondary tables *****/
|
||||
for (NumTable = 0;
|
||||
NumTable < Mch_NUM_SECONDARY_TABLES;
|
||||
NumTable++)
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,MatchSecondaryTables[NumTable]);
|
||||
|
||||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a course from table",
|
||||
"DELETE FROM %s"
|
||||
" USING gam_games,mch_matches"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove match from secondary table **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
||||
{
|
||||
/***** Remove match from secondary table *****/
|
||||
|
@ -1020,9 +960,26 @@ static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Remove all matches in game from secondary table ***************/
|
||||
/******************** Remove match in game from all tables *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mch_RemoveMatchesInGameFromAllTables (long GamCod)
|
||||
{
|
||||
/***** Remove matches from secondary tables *****/
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_players");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_playing");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_results");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_answers");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_times");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_groups");
|
||||
Mch_RemoveMatchesInGameFromTable (GamCod,"mch_indexes");
|
||||
|
||||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a game",
|
||||
"DELETE FROM mch_matches WHERE GamCod=%ld",
|
||||
GamCod);
|
||||
}
|
||||
|
||||
static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName)
|
||||
{
|
||||
/***** Remove matches in game from secondary table *****/
|
||||
|
@ -1038,9 +995,29 @@ static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Remove all matches in course from secondary table ***************/
|
||||
/******************* Remove match in course from all tables ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mch_RemoveMatchInCourseFromAllTables (long CrsCod)
|
||||
{
|
||||
/***** Remove matches from secondary tables *****/
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_players");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_playing");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_results");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_answers");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_times");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_groups");
|
||||
Mch_RemoveMatchInCourseFromTable (CrsCod,"mch_indexes");
|
||||
|
||||
/***** Remove matches from main table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a course from table",
|
||||
"DELETE FROM %s"
|
||||
" USING gam_games,mch_matches"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod",
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
static void Mch_RemoveMatchInCourseFromTable (long CrsCod,const char *TableName)
|
||||
{
|
||||
/***** Remove matches in course from secondary table *****/
|
||||
|
@ -1056,6 +1033,36 @@ static void Mch_RemoveMatchInCourseFromTable (long CrsCod,const char *TableName)
|
|||
TableName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Remove user from secondary match tables *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mch_RemoveUsrFromMatchTablesInCrs (long UsrCod,long CrsCod)
|
||||
{
|
||||
/***** Remove student from secondary tables *****/
|
||||
Mch_RemoveUsrMchResultsInCrs (UsrCod,CrsCod,"mch_players");
|
||||
Mch_RemoveUsrMchResultsInCrs (UsrCod,CrsCod,"mch_results");
|
||||
Mch_RemoveUsrMchResultsInCrs (UsrCod,CrsCod,"mch_answers");
|
||||
}
|
||||
|
||||
static void Mch_RemoveUsrMchResultsInCrs (long UsrCod,long CrsCod,const char *TableName)
|
||||
{
|
||||
/***** Remove matches in course from secondary table *****/
|
||||
DB_QueryDELETE ("can not remove matches of a user from table",
|
||||
"DELETE FROM %s"
|
||||
" USING gam_games,mch_matches,%s"
|
||||
" WHERE gam_games.CrsCod=%ld"
|
||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
||||
" AND mch_matches.MchCod=%s.MchCod"
|
||||
" AND %s.UsrCod=%ld",
|
||||
TableName,
|
||||
TableName,
|
||||
CrsCod,
|
||||
TableName,
|
||||
TableName,
|
||||
UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Params used to edit a match *************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -3053,4 +3060,3 @@ static long Mch_GetParamCurrentMchCod (void)
|
|||
{
|
||||
return Mch_CurrentMchCod;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ void Mch_RemoveMatch (void);
|
|||
|
||||
void Mch_RemoveMatchesInGameFromAllTables (long GamCod);
|
||||
void Mch_RemoveMatchInCourseFromAllTables (long CrsCod);
|
||||
void Mch_RemoveUsrFromMatchTablesInCrs (long UsrCod,long CrsCod);
|
||||
|
||||
void Mch_PutParamMchCod (long MchCod);
|
||||
void Mch_GetAndCheckParameters (struct Game *Game,struct Match *Match);
|
||||
|
|
Loading…
Reference in New Issue