mirror of https://github.com/acanas/swad-core.git
Version19.17.2
This commit is contained in:
parent
befebdd2dc
commit
86884a2e7e
|
@ -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.1 (2019-09-27)"
|
#define Log_PLATFORM_VERSION "SWAD 19.17.2 (2019-09-27)"
|
||||||
#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.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)
|
||||||
Version 19.16.8: Sep 27, 2019 Code refactoring. (246387 lines)
|
Version 19.16.8: Sep 27, 2019 Code refactoring. (246387 lines)
|
||||||
|
|
66
swad_game.c
66
swad_game.c
|
@ -73,6 +73,16 @@ 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 *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -105,6 +115,9 @@ 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_RemoveGameFromTable (long GamCod,const char *TableName);
|
||||||
|
|
||||||
static bool Gam_CheckIfSimilarGameExists (struct Game *Game);
|
static bool Gam_CheckIfSimilarGameExists (struct Game *Game);
|
||||||
|
|
||||||
static void Gam_CreateGame (struct Game *Game,const char *Txt);
|
static void Gam_CreateGame (struct Game *Game,const char *Txt);
|
||||||
|
@ -933,28 +946,11 @@ 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 questions in this game *****/
|
|
||||||
DB_QueryDELETE ("can not remove questions of a game",
|
|
||||||
"DELETE FROM gam_questions WHERE GamCod=%ld",
|
|
||||||
Game.GamCod);
|
|
||||||
|
|
||||||
/***** Remove all the matches in this game *****/
|
/***** Remove all the matches in this game *****/
|
||||||
/* Remove groups in matches of the game */
|
Mch_RemoveMatchInGameFromAllTables (Game.GamCod);
|
||||||
DB_QueryDELETE ("can not remove the groups associated to matches of a game",
|
|
||||||
"DELETE FROM mch_groups"
|
|
||||||
" USING mch_matches,mch_groups"
|
|
||||||
" WHERE mch_matches.GamCod=%ld"
|
|
||||||
" AND mch_matches.MchCod=mch_groups.MchCod",
|
|
||||||
Game.GamCod);
|
|
||||||
/* Remove matches of the game */
|
|
||||||
DB_QueryDELETE ("can not remove matches of a game",
|
|
||||||
"DELETE FROM mch_matches WHERE GamCod=%ld",
|
|
||||||
Game.GamCod);
|
|
||||||
|
|
||||||
/***** Remove game *****/
|
/***** Remove game from all tables *****/
|
||||||
DB_QueryDELETE ("can not remove game",
|
Gam_RemoveGameFromAllTables (Game.GamCod);
|
||||||
"DELETE FROM gam_games WHERE GamCod=%ld",
|
|
||||||
Game.GamCod);
|
|
||||||
|
|
||||||
/***** Write message to show the change made *****/
|
/***** Write message to show the change made *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Game_X_removed,
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Game_X_removed,
|
||||||
|
@ -964,6 +960,34 @@ void Gam_RemoveGame (void)
|
||||||
Gam_ListAllGames ();
|
Gam_ListAllGames ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Remove game from all tables *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Gam_RemoveGameFromAllTables (long GamCod)
|
||||||
|
{
|
||||||
|
unsigned NumTable;
|
||||||
|
|
||||||
|
for (NumTable = 0;
|
||||||
|
NumTable < Gam_NUM_TABLES;
|
||||||
|
NumTable++)
|
||||||
|
/* Remove game from table */
|
||||||
|
Gam_RemoveGameFromTable (GamCod,GameTables[NumTable]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************* Remove game from table ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Gam_RemoveGameFromTable (long GamCod,const char *TableName)
|
||||||
|
{
|
||||||
|
/***** Remove game from table *****/
|
||||||
|
DB_QueryDELETE ("can not remove game from table",
|
||||||
|
"DELETE FROM %s WHERE GamCod=%ld",
|
||||||
|
TableName,
|
||||||
|
GamCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************** Hide a game ******************************/
|
/******************************** Hide a game ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1867,7 +1891,7 @@ void Gam_AddTstQuestionsToGame (void)
|
||||||
|
|
||||||
/* Check number of questions */
|
/* Check number of questions */
|
||||||
if (Gam_CountNumQuestionsInList () == 0) // If no questions selected...
|
if (Gam_CountNumQuestionsInList () == 0) // If no questions selected...
|
||||||
{ // ...write warning alert
|
{ // ...write warning alert
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_questions);
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_questions);
|
||||||
|
|
||||||
// TODO: Show form again!!!
|
// TODO: Show form again!!!
|
||||||
|
|
81
swad_match.c
81
swad_match.c
|
@ -118,6 +118,22 @@ const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
||||||
"results",
|
"results",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
||||||
|
*/
|
||||||
|
const char *MatchTables[] =
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
};
|
||||||
|
#define Mch_NUM_TABLES (sizeof (MatchTables) / sizeof (MatchTables[0]))
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Private variables *****************************/
|
/***************************** Private variables *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -155,6 +171,7 @@ 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_PutParamCurrentMchCod (void);
|
static void Mch_PutParamCurrentMchCod (void);
|
||||||
static void Mch_PutParamMchCod (long MchCod);
|
static void Mch_PutParamMchCod (long MchCod);
|
||||||
|
@ -1044,36 +1061,9 @@ void Mch_RemoveMatchTch (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********************** Remove match from all tables *************************/
|
/********************** Remove match from all tables *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*
|
|
||||||
mysql> SELECT table_name FROM information_schema.tables WHERE table_name LIKE 'mch%';
|
|
||||||
+-------------+
|
|
||||||
| table_name |
|
|
||||||
+-------------+
|
|
||||||
| mch_answers |
|
|
||||||
| mch_groups |
|
|
||||||
| mch_indexes |
|
|
||||||
| mch_matches |
|
|
||||||
| mch_players |
|
|
||||||
| mch_playing |
|
|
||||||
| mch_results |
|
|
||||||
| mch_times |
|
|
||||||
+-------------+
|
|
||||||
8 rows in set (0.00 sec)
|
|
||||||
*/
|
|
||||||
static void Mch_RemoveMatchFromAllTables (long MchCod)
|
static void Mch_RemoveMatchFromAllTables (long MchCod)
|
||||||
{
|
{
|
||||||
static const char *MatchTables[] =
|
|
||||||
{
|
|
||||||
"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
|
|
||||||
};
|
|
||||||
#define Mch_NUM_TABLES (sizeof (MatchTables) / sizeof (MatchTables[0]))
|
|
||||||
unsigned NumTable;
|
unsigned NumTable;
|
||||||
|
|
||||||
for (NumTable = 0;
|
for (NumTable = 0;
|
||||||
|
@ -1083,6 +1073,21 @@ static void Mch_RemoveMatchFromAllTables (long MchCod)
|
||||||
Mch_RemoveMatchFromTable (MchCod,MatchTables[NumTable]);
|
Mch_RemoveMatchFromTable (MchCod,MatchTables[NumTable]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Remove match in game from all tables *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Mch_RemoveMatchInGameFromAllTables (long GamCod)
|
||||||
|
{
|
||||||
|
unsigned NumTable;
|
||||||
|
|
||||||
|
for (NumTable = 0;
|
||||||
|
NumTable < Mch_NUM_TABLES;
|
||||||
|
NumTable++)
|
||||||
|
/* Remove match from table */
|
||||||
|
Mch_RemoveMatchInGameFromTable (GamCod,MatchTables[NumTable]);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************ Remove match from table ****************************/
|
/************************ Remove match from table ****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1092,7 +1097,25 @@ static void Mch_RemoveMatchFromTable (long MchCod,const char *TableName)
|
||||||
/***** Remove match from table *****/
|
/***** Remove match from 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,MchCod);
|
TableName,
|
||||||
|
MchCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Remove all matches in game from table ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_RemoveMatchInGameFromTable (long GamCod,const char *TableName)
|
||||||
|
{
|
||||||
|
DB_QueryDELETE ("can not remove matches of a game from table",
|
||||||
|
"DELETE FROM %s"
|
||||||
|
" USING mch_matches,%s"
|
||||||
|
" WHERE mch_matches.GamCod=%ld"
|
||||||
|
" AND mch_matches.MchCod=%s.MchCod",
|
||||||
|
TableName,
|
||||||
|
TableName,
|
||||||
|
GamCod,
|
||||||
|
TableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -48,6 +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_CreateNewMatchTch (void);
|
void Mch_CreateNewMatchTch (void);
|
||||||
void Mch_RequestStartResumeMatchTch (void);
|
void Mch_RequestStartResumeMatchTch (void);
|
||||||
void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
||||||
|
|
Loading…
Reference in New Issue