mirror of https://github.com/acanas/swad-core.git
Version19.17.3
This commit is contained in:
parent
86884a2e7e
commit
52039c5f94
|
@ -471,10 +471,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.17.2 (2019-09-27)"
|
#define Log_PLATFORM_VERSION "SWAD 19.17.3 (2019-09-28)"
|
||||||
#define CSS_FILE "swad19.15.css"
|
#define CSS_FILE "swad19.15.css"
|
||||||
#define JS_FILE "swad19.15.js"
|
#define JS_FILE "swad19.15.js"
|
||||||
/*
|
/*
|
||||||
|
Version 19.17.3: Sep 28, 2019 Code refactoring removing matches and games. (246446 lines)
|
||||||
Version 19.17.2: Sep 27, 2019 Code refactoring removing matches and games. (246448 lines)
|
Version 19.17.2: Sep 27, 2019 Code refactoring removing matches and games. (246448 lines)
|
||||||
Version 19.17.1: Sep 27, 2019 Remove associations between matches and groups when removing groups. (246412 lines)
|
Version 19.17.1: Sep 27, 2019 Remove associations between matches and groups when removing groups. (246412 lines)
|
||||||
Version 19.17: Sep 27, 2019 Improvements in the code that deletes a match. (246410 lines)
|
Version 19.17: Sep 27, 2019 Improvements in the code that deletes a match. (246410 lines)
|
||||||
|
|
114
swad_game.c
114
swad_game.c
|
@ -73,16 +73,6 @@ const char *Gam_StrAnswerTypesDB[Gam_NUM_ANS_TYPES] =
|
||||||
#define Gam_MAX_SELECTED_QUESTIONS 1000
|
#define Gam_MAX_SELECTED_QUESTIONS 1000
|
||||||
#define Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS (Gam_MAX_SELECTED_QUESTIONS * (1 + 10 + 1))
|
#define Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS (Gam_MAX_SELECTED_QUESTIONS * (1 + 10 + 1))
|
||||||
|
|
||||||
/*
|
|
||||||
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'gam%';
|
|
||||||
*/
|
|
||||||
const char *GameTables[] =
|
|
||||||
{
|
|
||||||
"gam_questions", // questions in games
|
|
||||||
"gam_games" // the games themselves
|
|
||||||
};
|
|
||||||
#define Gam_NUM_TABLES (sizeof (GameTables) / sizeof (GameTables[0]))
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************* Private types *******************************/
|
/******************************* Private types *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -116,7 +106,6 @@ static void Gam_ResetGame (struct Game *Game);
|
||||||
static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
||||||
|
|
||||||
static void Gam_RemoveGameFromAllTables (long GamCod);
|
static void Gam_RemoveGameFromAllTables (long GamCod);
|
||||||
static void Gam_RemoveGameFromTable (long GamCod,const char *TableName);
|
|
||||||
|
|
||||||
static bool Gam_CheckIfSimilarGameExists (struct Game *Game);
|
static bool Gam_CheckIfSimilarGameExists (struct Game *Game);
|
||||||
|
|
||||||
|
@ -946,9 +935,6 @@ void Gam_RemoveGame (void)
|
||||||
if (!Game.Status.ICanEdit)
|
if (!Game.Status.ICanEdit)
|
||||||
Lay_ShowErrorAndExit ("You can not remove this game.");
|
Lay_ShowErrorAndExit ("You can not remove this game.");
|
||||||
|
|
||||||
/***** Remove all the matches in this game *****/
|
|
||||||
Mch_RemoveMatchInGameFromAllTables (Game.GamCod);
|
|
||||||
|
|
||||||
/***** Remove game from all tables *****/
|
/***** Remove game from all tables *****/
|
||||||
Gam_RemoveGameFromAllTables (Game.GamCod);
|
Gam_RemoveGameFromAllTables (Game.GamCod);
|
||||||
|
|
||||||
|
@ -966,26 +952,42 @@ void Gam_RemoveGame (void)
|
||||||
|
|
||||||
static void Gam_RemoveGameFromAllTables (long GamCod)
|
static void Gam_RemoveGameFromAllTables (long GamCod)
|
||||||
{
|
{
|
||||||
unsigned NumTable;
|
/***** Remove all matches in this game *****/
|
||||||
|
Mch_RemoveMatchesInGameFromAllTables (GamCod);
|
||||||
|
|
||||||
for (NumTable = 0;
|
/***** Remove game question *****/
|
||||||
NumTable < Gam_NUM_TABLES;
|
DB_QueryDELETE ("can not remove game questions",
|
||||||
NumTable++)
|
"DELETE FROM gam_questions WHERE GamCod=%ld",
|
||||||
/* Remove game from table */
|
GamCod);
|
||||||
Gam_RemoveGameFromTable (GamCod,GameTables[NumTable]);
|
|
||||||
|
/***** Remove game *****/
|
||||||
|
DB_QueryDELETE ("can not remove game",
|
||||||
|
"DELETE FROM gam_games WHERE GamCod=%ld",
|
||||||
|
GamCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************* Remove game from table ****************************/
|
/******************** Remove all the games of a course ***********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Gam_RemoveGameFromTable (long GamCod,const char *TableName)
|
void Gam_RemoveGamesCrs (long CrsCod)
|
||||||
{
|
{
|
||||||
/***** Remove game from table *****/
|
/***** Remove all matches in this course *****/
|
||||||
DB_QueryDELETE ("can not remove game from table",
|
Mch_RemoveMatchInCourseFromAllTables (CrsCod);
|
||||||
"DELETE FROM %s WHERE GamCod=%ld",
|
|
||||||
TableName,
|
/***** Remove the questions in games *****/
|
||||||
GamCod);
|
DB_QueryDELETE ("can not remove questions in course games",
|
||||||
|
"DELETE FROM gam_questions"
|
||||||
|
" USING gam_games,gam_questions"
|
||||||
|
" WHERE gam_games.CrsCod=%ld"
|
||||||
|
" AND gam_games.GamCod=gam_questions.GamCod",
|
||||||
|
CrsCod);
|
||||||
|
|
||||||
|
/***** Remove the games *****/
|
||||||
|
DB_QueryDELETE ("can not remove course games",
|
||||||
|
"DELETE FROM gam_games"
|
||||||
|
" WHERE CrsCod=%ld",
|
||||||
|
CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1304,64 +1306,6 @@ bool Gam_CheckIfMatchIsAssociatedToGrp (long MchCod,long GrpCod)
|
||||||
MchCod,GrpCod) != 0);
|
MchCod,GrpCod) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/******************** Remove all the games of a course ***********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Gam_RemoveGamesCrs (long CrsCod)
|
|
||||||
{
|
|
||||||
/***** Remove the matches of games in this course *****/
|
|
||||||
/* Remove matches players */
|
|
||||||
DB_QueryDELETE ("can not remove match players",
|
|
||||||
"DELETE FROM mch_players"
|
|
||||||
" USING gam_games,mch_matches,mch_players"
|
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
|
||||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
|
||||||
" AND mch_matches.MchCod=mch_players.MchCod",
|
|
||||||
CrsCod);
|
|
||||||
|
|
||||||
/* Remove matches from list of matches being played */
|
|
||||||
DB_QueryDELETE ("can not remove matches being played",
|
|
||||||
"DELETE FROM mch_playing"
|
|
||||||
" USING gam_games,mch_matches,mch_playing"
|
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
|
||||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
|
||||||
" AND mch_matches.MchCod=mch_playing.MchCod",
|
|
||||||
CrsCod);
|
|
||||||
|
|
||||||
/* Remove students' answers to match */
|
|
||||||
DB_QueryDELETE ("can not remove students' answers associated to matches",
|
|
||||||
"DELETE FROM mch_answers"
|
|
||||||
" USING gam_games,mch_matches,mch_answers"
|
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
|
||||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
|
||||||
" AND mch_matches.MchCod=mch_answers.MchCod",
|
|
||||||
CrsCod);
|
|
||||||
|
|
||||||
/* Remove groups associated to the match */
|
|
||||||
DB_QueryDELETE ("can not remove the groups associated to matches",
|
|
||||||
"DELETE FROM mch_groups"
|
|
||||||
" USING gam_games,mch_matches,mch_answers"
|
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
|
||||||
" AND gam_games.GamCod=mch_matches.GamCod"
|
|
||||||
" AND mch_matches.MchCod=mch_groups.MchCod",
|
|
||||||
CrsCod);
|
|
||||||
|
|
||||||
/* Remove the matches themselves */
|
|
||||||
DB_QueryDELETE ("can not remove matches",
|
|
||||||
"DELETE FROM mch_matches"
|
|
||||||
" USING gam_games,mch_matches"
|
|
||||||
" WHERE gam_games.CrsCod=%ld"
|
|
||||||
" AND gam_games.GamCod=mch_matches.GamCod",
|
|
||||||
CrsCod);
|
|
||||||
|
|
||||||
/***** Remove the games *****/
|
|
||||||
DB_QueryDELETE ("can not remove games",
|
|
||||||
"DELETE FROM gam_games"
|
|
||||||
" WHERE CrsCod=%ld",
|
|
||||||
CrsCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Get number of questions of a game *********************/
|
/******************* Get number of questions of a game *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -91,13 +91,15 @@ void Gam_FreeListGames (void);
|
||||||
|
|
||||||
void Gam_PutParamGameCod (long GamCod);
|
void Gam_PutParamGameCod (long GamCod);
|
||||||
long Gam_GetParamGameCod (void);
|
long Gam_GetParamGameCod (void);
|
||||||
|
|
||||||
void Gam_AskRemGame (void);
|
void Gam_AskRemGame (void);
|
||||||
void Gam_RemoveGame (void);
|
void Gam_RemoveGame (void);
|
||||||
|
void Gam_RemoveGamesCrs (long CrsCod);
|
||||||
|
|
||||||
void Gam_HideGame (void);
|
void Gam_HideGame (void);
|
||||||
void Gam_UnhideGame (void);
|
void Gam_UnhideGame (void);
|
||||||
void Gam_RecFormGame (void);
|
void Gam_RecFormGame (void);
|
||||||
bool Gam_CheckIfMatchIsAssociatedToGrp (long MchCod,long GrpCod);
|
bool Gam_CheckIfMatchIsAssociatedToGrp (long MchCod,long GrpCod);
|
||||||
void Gam_RemoveGamesCrs (long CrsCod);
|
|
||||||
|
|
||||||
unsigned Gam_GetNumQstsGame (long GamCod);
|
unsigned Gam_GetNumQstsGame (long GamCod);
|
||||||
|
|
||||||
|
|
84
swad_match.c
84
swad_match.c
|
@ -121,7 +121,7 @@ const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
||||||
/*
|
/*
|
||||||
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
||||||
*/
|
*/
|
||||||
const char *MatchTables[] =
|
const char *MatchSecondaryTables[] =
|
||||||
{
|
{
|
||||||
"mch_players", // match players
|
"mch_players", // match players
|
||||||
"mch_playing", // matches being played
|
"mch_playing", // matches being played
|
||||||
|
@ -130,9 +130,9 @@ const char *MatchTables[] =
|
||||||
"mch_times", // times associated to matches
|
"mch_times", // times associated to matches
|
||||||
"mch_groups", // groups associated to matches
|
"mch_groups", // groups associated to matches
|
||||||
"mch_indexes", // indexes associated to matches
|
"mch_indexes", // indexes associated to matches
|
||||||
"mch_matches" // the matches themselves
|
// "mch_matches" // the matches themselves, this table is treated separately
|
||||||
};
|
};
|
||||||
#define Mch_NUM_TABLES (sizeof (MatchTables) / sizeof (MatchTables[0]))
|
#define Mch_NUM_SECONDARY_TABLES (sizeof (MatchSecondaryTables) / sizeof (MatchSecondaryTables[0]))
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Private variables *****************************/
|
/***************************** Private variables *****************************/
|
||||||
|
@ -171,7 +171,8 @@ static Mch_Showing_t Mch_GetShowingFromStr (const char *Str);
|
||||||
|
|
||||||
static void Mch_RemoveMatchFromAllTables (long MchCod);
|
static void Mch_RemoveMatchFromAllTables (long MchCod);
|
||||||
static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName);
|
static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName);
|
||||||
static void Mch_RemoveMatchInGameFromTable (long GamCod,const char *TableName);
|
static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName);
|
||||||
|
static void Mch_RemoveMatchInCourseFromTable (long CrsCod,const char *TableName);
|
||||||
|
|
||||||
static void Mch_PutParamCurrentMchCod (void);
|
static void Mch_PutParamCurrentMchCod (void);
|
||||||
static void Mch_PutParamMchCod (long MchCod);
|
static void Mch_PutParamMchCod (long MchCod);
|
||||||
|
@ -1066,35 +1067,68 @@ static void Mch_RemoveMatchFromAllTables (long MchCod)
|
||||||
{
|
{
|
||||||
unsigned NumTable;
|
unsigned NumTable;
|
||||||
|
|
||||||
|
/***** Remove match from secondary tables *****/
|
||||||
for (NumTable = 0;
|
for (NumTable = 0;
|
||||||
NumTable < Mch_NUM_TABLES;
|
NumTable < Mch_NUM_SECONDARY_TABLES;
|
||||||
NumTable++)
|
NumTable++)
|
||||||
/* Remove match from table */
|
Mch_RemoveMatchFromTable (MchCod,MatchSecondaryTables[NumTable]);
|
||||||
Mch_RemoveMatchFromTable (MchCod,MatchTables[NumTable]);
|
|
||||||
|
/***** Remove match from main table *****/
|
||||||
|
DB_QueryDELETE ("can not remove match",
|
||||||
|
"DELETE FROM mch_matches WHERE MchCod=%ld",
|
||||||
|
MchCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Remove match in game from all tables *******************/
|
/******************** Remove match in game from all tables *******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Mch_RemoveMatchInGameFromAllTables (long GamCod)
|
void Mch_RemoveMatchesInGameFromAllTables (long GamCod)
|
||||||
{
|
{
|
||||||
unsigned NumTable;
|
unsigned NumTable;
|
||||||
|
|
||||||
|
/***** Remove matches from secondary tables *****/
|
||||||
for (NumTable = 0;
|
for (NumTable = 0;
|
||||||
NumTable < Mch_NUM_TABLES;
|
NumTable < Mch_NUM_SECONDARY_TABLES;
|
||||||
NumTable++)
|
NumTable++)
|
||||||
/* Remove match from table */
|
Mch_RemoveMatchesInGameFromTable (GamCod,MatchSecondaryTables[NumTable]);
|
||||||
Mch_RemoveMatchInGameFromTable (GamCod,MatchTables[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 from table ****************************/
|
/******************* 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)
|
static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
||||||
{
|
{
|
||||||
/***** Remove match from table *****/
|
/***** Remove match from secondary table *****/
|
||||||
DB_QueryDELETE ("can not remove match from table",
|
DB_QueryDELETE ("can not remove match from table",
|
||||||
"DELETE FROM %s WHERE MchCod=%ld",
|
"DELETE FROM %s WHERE MchCod=%ld",
|
||||||
TableName,
|
TableName,
|
||||||
|
@ -1102,11 +1136,12 @@ static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Remove all matches in game from table ********************/
|
/************* Remove all matches in game from secondary table ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_RemoveMatchInGameFromTable (long GamCod,const char *TableName)
|
static void Mch_RemoveMatchesInGameFromTable (long GamCod,const char *TableName)
|
||||||
{
|
{
|
||||||
|
/***** Remove matches in game from secondary table *****/
|
||||||
DB_QueryDELETE ("can not remove matches of a game from table",
|
DB_QueryDELETE ("can not remove matches of a game from table",
|
||||||
"DELETE FROM %s"
|
"DELETE FROM %s"
|
||||||
" USING mch_matches,%s"
|
" USING mch_matches,%s"
|
||||||
|
@ -1118,6 +1153,25 @@ static void Mch_RemoveMatchInGameFromTable (long GamCod,const char *TableName)
|
||||||
TableName);
|
TableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********** Remove all matches in course from secondary table ***************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_RemoveMatchInCourseFromTable (long CrsCod,const char *TableName)
|
||||||
|
{
|
||||||
|
/***** Remove matches in course from secondary table *****/
|
||||||
|
DB_QueryDELETE ("can not remove matches of a course 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",
|
||||||
|
TableName,
|
||||||
|
TableName,
|
||||||
|
CrsCod,
|
||||||
|
TableName);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************** Put parameter with current match code *********************/
|
/***************** Put parameter with current match code *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -48,7 +48,8 @@ void Mch_ToggleVisibilResultsMchUsr (void);
|
||||||
void Mch_RequestRemoveMatchTch (void);
|
void Mch_RequestRemoveMatchTch (void);
|
||||||
void Mch_RemoveMatchTch (void);
|
void Mch_RemoveMatchTch (void);
|
||||||
|
|
||||||
void Mch_RemoveMatchInGameFromAllTables (long GamCod);
|
void Mch_RemoveMatchesInGameFromAllTables (long GamCod);
|
||||||
|
void Mch_RemoveMatchInCourseFromAllTables (long CrsCod);
|
||||||
|
|
||||||
void Mch_CreateNewMatchTch (void);
|
void Mch_CreateNewMatchTch (void);
|
||||||
void Mch_RequestStartResumeMatchTch (void);
|
void Mch_RequestStartResumeMatchTch (void);
|
||||||
|
|
Loading…
Reference in New Issue