Version 20.78.2: May 20, 2021 Code formatting in games and matches.

This commit is contained in:
acanas 2021-05-20 18:44:13 +02:00
parent a6dae83d81
commit b206217046
7 changed files with 1134 additions and 1106 deletions

View File

@ -27,6 +27,7 @@
#define _GNU_SOURCE // For asprintf #define _GNU_SOURCE // For asprintf
#include <stdio.h> // For asprintf #include <stdio.h> // For asprintf
#include <stdlib.h> // For free
#include "swad_agenda.h" #include "swad_agenda.h"
#include "swad_agenda_database.h" #include "swad_agenda_database.h"

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/ */
#define Log_PLATFORM_VERSION "SWAD 20.78.1 (2021-05-20)" #define Log_PLATFORM_VERSION "SWAD 20.78.2 (2021-05-20)"
#define CSS_FILE "swad20.45.css" #define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js" #define JS_FILE "swad20.69.1.js"
/* /*
TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.78.2: May 20, 2021 Code formatting in games and matches. (311326 lines)
Version 20.78.1: May 20, 2021 Fixed bug in matches. Reported by Jesús Garrido Alcázar. (311317 lines) Version 20.78.1: May 20, 2021 Fixed bug in matches. Reported by Jesús Garrido Alcázar. (311317 lines)
Version 20.78: May 19, 2021 New module swad_chat_database for database queries related to chat. (311327 lines) Version 20.78: May 19, 2021 New module swad_chat_database for database queries related to chat. (311327 lines)
Version 20.77: May 18, 2021 New module swad_banner_database for database queries related to banners. (311249 lines) Version 20.77: May 18, 2021 New module swad_banner_database for database queries related to banners. (311249 lines)

View File

@ -3501,8 +3501,8 @@ static void Fig_GetAndShowGamesStats (void)
double NumGamesPerCourse = 0.0; double NumGamesPerCourse = 0.0;
/***** Get the number of games from this location *****/ /***** Get the number of games from this location *****/
if ((NumGames = Gam_GetNumGames (Gbl.Scope.Current))) if ((NumGames = Gam_DB_GetNumGames (Gbl.Scope.Current)))
if ((NumCoursesWithGames = Gam_GetNumCoursesWithGames (Gbl.Scope.Current)) != 0) if ((NumCoursesWithGames = Gam_DB_GetNumCoursesWithGames (Gbl.Scope.Current)) != 0)
NumGamesPerCourse = (double) NumGames / (double) NumCoursesWithGames; NumGamesPerCourse = (double) NumGames / (double) NumCoursesWithGames;
/***** Begin box and table *****/ /***** Begin box and table *****/

View File

@ -133,11 +133,11 @@ static void Gam_PutParamsOneQst (void *Games);
static void Gam_PutHiddenParamOrder (Gam_Order_t SelectedOrder); static void Gam_PutHiddenParamOrder (Gam_Order_t SelectedOrder);
static Gam_Order_t Gam_GetParamOrder (void); static Gam_Order_t Gam_GetParamOrder (void);
static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); static void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
static void Gam_RemoveGameFromAllTables (long GamCod); static void Gam_RemoveGameFromAllTables (long GamCod);
static bool Gam_CheckIfSimilarGameExists (const struct Gam_Game *Game); static bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game);
static void Gam_PutFormsEditionGame (struct Gam_Games *Games, static void Gam_PutFormsEditionGame (struct Gam_Games *Games,
struct Gam_Game *Game, struct Gam_Game *Game,
@ -150,11 +150,11 @@ static bool Gam_CheckGameFieldsReceivedFromForm (const struct Gam_Game *Game);
static void Gam_CreateGame (struct Gam_Game *Game,const char *Txt); static void Gam_CreateGame (struct Gam_Game *Game,const char *Txt);
static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt); static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt);
static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd); static void Gam_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd);
static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod); static unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod);
static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod); static unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod);
static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game); static void Gam_ListGameQuestions (struct Gam_Games *Games,struct Gam_Game *Game);
static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games, static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
long GamCod,unsigned NumQsts, long GamCod,unsigned NumQsts,
@ -275,9 +275,12 @@ static void Gam_ListAllGames (struct Gam_Games *Games)
if (Games->Num) if (Games->Num)
{ {
/***** Table head *****/ /***** Begin table *****/
HTM_TABLE_BeginWideMarginPadding (5); HTM_TABLE_BeginWideMarginPadding (5);
/***** Table head *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
if (Gam_CheckIfICanEditGames () || if (Gam_CheckIfICanEditGames () ||
Gam_CheckIfICanListGameQuestions ()) Gam_CheckIfICanListGameQuestions ())
HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons
@ -292,6 +295,7 @@ static void Gam_ListAllGames (struct Gam_Games *Games)
Frm_BeginForm (ActSeeAllGam); Frm_BeginForm (ActSeeAllGam);
Pag_PutHiddenParamPagNum (Pag_GAMES,Games->CurrentPage); Pag_PutHiddenParamPagNum (Pag_GAMES,Games->CurrentPage);
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
HTM_BUTTON_SUBMIT_Begin (Txt_GAMES_ORDER_HELP[Order],"BT_LINK TIT_TBL",NULL); HTM_BUTTON_SUBMIT_Begin (Txt_GAMES_ORDER_HELP[Order],"BT_LINK TIT_TBL",NULL);
if (Order == Games->SelectedOrder) if (Order == Games->SelectedOrder)
HTM_U_Begin (); HTM_U_Begin ();
@ -299,6 +303,7 @@ static void Gam_ListAllGames (struct Gam_Games *Games)
if (Order == Games->SelectedOrder) if (Order == Games->SelectedOrder)
HTM_U_End (); HTM_U_End ();
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();
HTM_TH_End (); HTM_TH_End ();
@ -436,7 +441,9 @@ static void Gam_PutButtonToCreateNewGame (struct Gam_Games *Games)
Frm_BeginForm (ActFrmNewGam); Frm_BeginForm (ActFrmNewGam);
Gam_PutParamsToCreateNewGame (Games); Gam_PutParamsToCreateNewGame (Games);
Btn_PutConfirmButton (Txt_New_game); Btn_PutConfirmButton (Txt_New_game);
Frm_EndForm (); Frm_EndForm ();
} }
@ -673,7 +680,7 @@ static void Gam_ShowOneGame (struct Gam_Games *Games,
HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
else else
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
Gam_GetGameTxtFromDB (Game->GamCod,Txt); Gam_DB_GetGameTxt (Game->GamCod,Txt);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
@ -1061,7 +1068,7 @@ void Gam_GetDataOfGameByCod (struct Gam_Game *Game)
Str_Copy (Game->Title,row[6],sizeof (Game->Title) - 1); Str_Copy (Game->Title,row[6],sizeof (Game->Title) - 1);
/* Get number of questions */ /* Get number of questions */
Game->NumQsts = Gam_GetNumQstsGame (Game->GamCod); Game->NumQsts = Gam_DB_GetNumQstsGame (Game->GamCod);
/* Get number of matches */ /* Get number of matches */
Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod); Game->NumMchs = Mch_GetNumMchsInGame (Game->GamCod);
@ -1126,7 +1133,7 @@ void Gam_FreeListGames (struct Gam_Games *Games)
/********************** Get game text from database ************************/ /********************** Get game text from database ************************/
/*****************************************************************************/ /*****************************************************************************/
static void Gam_GetGameTxtFromDB (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) static void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
/***** Get text of game from database *****/ /***** Get text of game from database *****/
DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get game text", DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get game text",
@ -1331,7 +1338,7 @@ void Gam_UnhideGame (void)
/******************* Check if the title of a game exists *******************/ /******************* Check if the title of a game exists *******************/
/*****************************************************************************/ /*****************************************************************************/
static bool Gam_CheckIfSimilarGameExists (const struct Gam_Game *Game) static bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game)
{ {
/***** Get number of games with a field value from database *****/ /***** Get number of games with a field value from database *****/
return (DB_QueryCOUNT ("can not get similar games", return (DB_QueryCOUNT ("can not get similar games",
@ -1371,7 +1378,7 @@ void Gam_ListGame (void)
/***** Get game data *****/ /***** Get game data *****/
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
Gam_GetGameTxtFromDB (Game.GamCod,Txt); Gam_DB_GetGameTxt (Game.GamCod,Txt);
/***** Show game *****/ /***** Show game *****/
Gam_ShowOnlyOneGame (&Games,&Game, Gam_ShowOnlyOneGame (&Games,&Game,
@ -1414,7 +1421,7 @@ void Gam_RequestCreatOrEditGame (void)
{ {
/* Get game data from database */ /* Get game data from database */
Gam_GetDataOfGameByCod (&Game); Gam_GetDataOfGameByCod (&Game);
Gam_GetGameTxtFromDB (Game.GamCod,Txt); Gam_DB_GetGameTxt (Game.GamCod,Txt);
} }
/***** Put forms to create/edit a game *****/ /***** Put forms to create/edit a game *****/
@ -1630,7 +1637,7 @@ static bool Gam_CheckGameFieldsReceivedFromForm (const struct Gam_Game *Game)
if (Game->Title[0]) // If there's a game title if (Game->Title[0]) // If there's a game title
{ {
/* If title of game was in database... */ /* If title of game was in database... */
if (Gam_CheckIfSimilarGameExists (Game)) if (Gam_DB_CheckIfSimilarGameExists (Game))
{ {
NewGameIsCorrect = false; NewGameIsCorrect = false;
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_a_game_with_the_title_X, Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_a_game_with_the_title_X,
@ -1711,7 +1718,7 @@ static void Gam_UpdateGame (struct Gam_Game *Game,const char *Txt)
/******************* Get number of questions of a game *********************/ /******************* Get number of questions of a game *********************/
/*****************************************************************************/ /*****************************************************************************/
unsigned Gam_GetNumQstsGame (long GamCod) unsigned Gam_DB_GetNumQstsGame (long GamCod)
{ {
/***** Get nuumber of questions in a game from database *****/ /***** Get nuumber of questions in a game from database *****/
return (unsigned) return (unsigned)
@ -1812,7 +1819,7 @@ unsigned Gam_GetParamQstInd (void)
/********************** Remove answers of a game question ********************/ /********************** Remove answers of a game question ********************/
/*****************************************************************************/ /*****************************************************************************/
static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd) static void Gam_DB_RemAnswersOfAQuestion (long GamCod,unsigned QstInd)
{ {
/***** Remove answers from all matches of this game *****/ /***** Remove answers from all matches of this game *****/
DB_QueryDELETE ("can not remove the answers of a question", DB_QueryDELETE ("can not remove the answers of a question",
@ -1822,7 +1829,8 @@ static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd)
" WHERE mch_matches.GamCod=%ld" // From all matches of this game... " WHERE mch_matches.GamCod=%ld" // From all matches of this game...
" AND mch_matches.MchCod=mch_answers.MchCod" " AND mch_matches.MchCod=mch_answers.MchCod"
" AND mch_answers.QstInd=%u", // ...remove only answers to this question " AND mch_answers.QstInd=%u", // ...remove only answers to this question
GamCod,QstInd); GamCod,
QstInd);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1830,7 +1838,7 @@ static void Gam_RemAnswersOfAQuestion (long GamCod,unsigned QstInd)
/*****************************************************************************/ /*****************************************************************************/
// Return 0 is question is not present in game // Return 0 is question is not present in game
static unsigned Gam_GetQstIndFromQstCod (long GamCod,long QstCod) static unsigned Gam_DB_GetQstIndFromQstCod (long GamCod,long QstCod)
{ {
/***** Get question index in a game given the question code *****/ /***** Get question index in a game given the question code *****/
return DB_QuerySELECTUnsigned ("can not get question index", return DB_QuerySELECTUnsigned ("can not get question index",
@ -1870,7 +1878,7 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd)
// Question index can be 1, 2, 3... // Question index can be 1, 2, 3...
// Return 0 if no questions // Return 0 if no questions
static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod) static unsigned Gam_DB_GetMaxQuestionIndexInGame (long GamCod)
{ {
/***** Get maximum question index in a game from database *****/ /***** Get maximum question index in a game from database *****/
return DB_QuerySELECTUnsigned ("can not get last question index", return DB_QuerySELECTUnsigned ("can not get last question index",
@ -1886,7 +1894,7 @@ static unsigned Gam_GetMaxQuestionIndexInGame (long GamCod)
// Input question index can be 1, 2, 3... n-1 // Input question index can be 1, 2, 3... n-1
// Return question index will be 1, 2, 3... n if previous question exists, or 0 if no previous question // Return question index will be 1, 2, 3... n if previous question exists, or 0 if no previous question
unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd) unsigned Gam_DB_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
{ {
/***** Get previous question index in a game from database *****/ /***** Get previous question index in a game from database *****/
// Although indexes are always continuous... // Although indexes are always continuous...
@ -1906,7 +1914,7 @@ unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd)
// Input question index can be 0, 1, 2, 3... n-1 // Input question index can be 0, 1, 2, 3... n-1
// Return question index will be 1, 2, 3... n if next question exists, or big number if no next question // Return question index will be 1, 2, 3... n if next question exists, or big number if no next question
unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd) unsigned Gam_DB_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
{ {
/***** Get next question index in a game from database *****/ /***** Get next question index in a game from database *****/
// Although indexes are always continuous... // Although indexes are always continuous...
@ -2002,7 +2010,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
return; return;
/***** Get maximum question index *****/ /***** Get maximum question index *****/
MaxQstInd = Gam_GetMaxQuestionIndexInGame (GamCod); // 0 is no questions in game MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (GamCod); // 0 is no questions in game
/***** Write the heading *****/ /***** Write the heading *****/
HTM_TABLE_BeginWideMarginPadding (5); HTM_TABLE_BeginWideMarginPadding (5);
@ -2136,7 +2144,9 @@ static void Gam_PutButtonToAddNewQuestions (struct Gam_Games *Games)
Frm_BeginForm (ActAddOneGamQst); Frm_BeginForm (ActAddOneGamQst);
Gam_PutParams (Games); Gam_PutParams (Games);
Btn_PutConfirmButton (Txt_Add_questions); Btn_PutConfirmButton (Txt_Add_questions);
Frm_EndForm (); Frm_EndForm ();
} }
@ -2194,10 +2204,10 @@ void Gam_AddQstsToGame (void)
Err_WrongQuestionExit (); Err_WrongQuestionExit ();
/* Check if question is already present in game */ /* Check if question is already present in game */
if (Gam_GetQstIndFromQstCod (Game.GamCod,QstCod) == 0) // This question is not yet in this game if (Gam_DB_GetQstIndFromQstCod (Game.GamCod,QstCod) == 0) // This question is not yet in this game
{ {
/* Get current maximum index */ /* Get current maximum index */
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game
/* Insert question in the table of questions */ /* Insert question in the table of questions */
DB_QueryINSERT ("can not add question to game", DB_QueryINSERT ("can not add question to game",
@ -2334,7 +2344,7 @@ void Gam_RemoveQstFromGame (void)
/***** Remove the question from all the tables *****/ /***** Remove the question from all the tables *****/
/* Remove answers from this test question */ /* Remove answers from this test question */
Gam_RemAnswersOfAQuestion (Game.GamCod,QstInd); Gam_DB_RemAnswersOfAQuestion (Game.GamCod,QstInd);
/* Remove the question itself */ /* Remove the question itself */
DB_QueryDELETE ("can not remove a question", DB_QueryDELETE ("can not remove a question",
@ -2407,7 +2417,7 @@ void Gam_MoveUpQst (void)
if (QstIndBottom > 1) // 2, 3, 4... if (QstIndBottom > 1) // 2, 3, 4...
{ {
/* Indexes of questions to be exchanged */ /* Indexes of questions to be exchanged */
QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom); QstIndTop = Gam_DB_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom);
if (QstIndTop == 0) if (QstIndTop == 0)
Err_WrongQuestionIndexExit (); Err_WrongQuestionIndexExit ();
@ -2455,13 +2465,13 @@ void Gam_MoveDownQst (void)
QstIndTop = Gam_GetParamQstInd (); QstIndTop = Gam_GetParamQstInd ();
/***** Get maximum question index *****/ /***** Get maximum question index *****/
MaxQstInd = Gam_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game MaxQstInd = Gam_DB_GetMaxQuestionIndexInGame (Game.GamCod); // 0 is no questions in game
/***** Move down question *****/ /***** Move down question *****/
if (QstIndTop < MaxQstInd) if (QstIndTop < MaxQstInd)
{ {
/* Indexes of questions to be exchanged */ /* Indexes of questions to be exchanged */
QstIndBottom = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop); QstIndBottom = Gam_DB_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop);
if (QstIndBottom == Gam_AFTER_LAST_QUESTION) if (QstIndBottom == Gam_AFTER_LAST_QUESTION)
Err_WrongQuestionIndexExit (); Err_WrongQuestionIndexExit ();
@ -2570,10 +2580,12 @@ void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod)
{ {
extern const char *Txt_New_match; extern const char *Txt_New_match;
Games->GamCod = GamCod;
Frm_StartFormAnchor (ActReqNewMch,Mch_NEW_MATCH_SECTION_ID); Frm_StartFormAnchor (ActReqNewMch,Mch_NEW_MATCH_SECTION_ID);
Games->GamCod = GamCod;
Gam_PutParams (Games); Gam_PutParams (Games);
Btn_PutConfirmButton (Txt_New_match); Btn_PutConfirmButton (Txt_New_match);
Frm_EndForm (); Frm_EndForm ();
} }
@ -2608,7 +2620,7 @@ void Gam_RequestNewMatch (void)
/*****************************************************************************/ /*****************************************************************************/
// Returns the number of courses with games in this location // Returns the number of courses with games in this location
unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope) unsigned Gam_DB_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope)
{ {
/***** Get number of courses with games from database *****/ /***** Get number of courses with games from database *****/
switch (Scope) switch (Scope)
@ -2683,7 +2695,7 @@ unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope)
/*****************************************************************************/ /*****************************************************************************/
// Returns the number of games in this location // Returns the number of games in this location
unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope) unsigned Gam_DB_GetNumGames (Hie_Lvl_Level_t Scope)
{ {
/***** Get number of games from database *****/ /***** Get number of games from database *****/
switch (Scope) switch (Scope)
@ -2754,10 +2766,10 @@ unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope)
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Get average number of questions per course game ***************/ /***************** Get average number of questions per game ******************/
/*****************************************************************************/ /*****************************************************************************/
double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope) double Gam_DB_GetNumQstsPerGame (Hie_Lvl_Level_t Scope)
{ {
/***** Get number of questions per game from database *****/ /***** Get number of questions per game from database *****/
switch (Scope) switch (Scope)

View File

@ -143,7 +143,7 @@ void Gam_RequestCreatOrEditGame (void);
void Gam_ReceiveFormGame (void); void Gam_ReceiveFormGame (void);
unsigned Gam_GetNumQstsGame (long GamCod); unsigned Gam_DB_GetNumQstsGame (long GamCod);
void Gam_ReqSelectQstsToAddToGame (void); void Gam_ReqSelectQstsToAddToGame (void);
void Gam_ListQstsToAddToGame (void); void Gam_ListQstsToAddToGame (void);
@ -151,8 +151,8 @@ void Gam_ListQstsToAddToGame (void);
void Gam_PutParamQstInd (unsigned QstInd); void Gam_PutParamQstInd (unsigned QstInd);
unsigned Gam_GetParamQstInd (void); unsigned Gam_GetParamQstInd (void);
long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd); long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd);
unsigned Gam_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd); unsigned Gam_DB_GetPrevQuestionIndexInGame (long GamCod,unsigned QstInd);
unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd); unsigned Gam_DB_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd);
void Gam_AddQstsToGame (void); void Gam_AddQstsToGame (void);
@ -165,9 +165,9 @@ void Gam_MoveDownQst (void);
void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod); void Gam_PutButtonNewMatch (struct Gam_Games *Games,long GamCod);
void Gam_RequestNewMatch (void); void Gam_RequestNewMatch (void);
unsigned Gam_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope); unsigned Gam_DB_GetNumCoursesWithGames (Hie_Lvl_Level_t Scope);
unsigned Gam_GetNumGames (Hie_Lvl_Level_t Scope); unsigned Gam_DB_GetNumGames (Hie_Lvl_Level_t Scope);
double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope); double Gam_DB_GetNumQstsPerGame (Hie_Lvl_Level_t Scope);
void Gam_ShowTstTagsPresentInAGame (long GamCod); void Gam_ShowTstTagsPresentInAGame (long GamCod);

View File

@ -496,8 +496,10 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
/***** Reset match *****/ /***** Reset match *****/
Mch_ResetMatch (&Match); Mch_ResetMatch (&Match);
/***** Write the heading *****/ /***** Begin table *****/
HTM_TABLE_BeginWidePadding (2); HTM_TABLE_BeginWidePadding (2);
/***** Write the heading *****/
Mch_ListOneOrMoreMatchesHeading (ICanEditMatches); Mch_ListOneOrMoreMatchesHeading (ICanEditMatches);
/***** Write rows *****/ /***** Write rows *****/
@ -740,11 +742,13 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match,
Frm_BeginForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch : Frm_BeginForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch :
ActResMch); ActResMch);
Mch_PutParamMchCod (Match->MchCod); Mch_PutParamMchCod (Match->MchCod);
HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play : HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play :
Txt_Resume, Txt_Resume,
"BT_LINK LT ASG_TITLE",NULL); "BT_LINK LT ASG_TITLE",NULL);
HTM_Txt (Match->Title); HTM_Txt (Match->Title);
HTM_BUTTON_End (); HTM_BUTTON_End ();
Frm_EndForm (); Frm_EndForm ();
/***** Groups whose students can answer this match *****/ /***** Groups whose students can answer this match *****/
@ -785,8 +789,9 @@ static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (const struct Mch_Match
"grp_groups.GrpName", "grp_groups.GrpName",
Match->MchCod); Match->MchCod);
/***** Write heading *****/
HTM_DIV_Begin ("class=\"ASG_GRP\""); HTM_DIV_Begin ("class=\"ASG_GRP\"");
/***** Write heading *****/
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group : HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
Txt_Groups); Txt_Groups);
@ -1576,6 +1581,7 @@ static void Mch_ShowLstGrpsToEditMatch (long MchCod)
HTM_TD_End (); HTM_TD_End ();
HTM_TD_Begin ("class=\"LT\""); HTM_TD_Begin ("class=\"LT\"");
Box_BoxTableBegin ("95%",NULL, Box_BoxTableBegin ("95%",NULL,
NULL,NULL, NULL,NULL,
NULL,Box_NOT_CLOSABLE,0); NULL,Box_NOT_CLOSABLE,0);
@ -1606,7 +1612,9 @@ static void Mch_ShowLstGrpsToEditMatch (long MchCod)
/***** End table and box *****/ /***** End table and box *****/
Box_BoxTableEnd (); Box_BoxTableEnd ();
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
} }
@ -2364,7 +2372,7 @@ static void Mch_SetMatchStatusToPrev (struct Mch_Match *Match)
static void Mch_SetMatchStatusToPrevQst (struct Mch_Match *Match) static void Mch_SetMatchStatusToPrevQst (struct Mch_Match *Match)
{ {
/***** Get index of the previous question *****/ /***** Get index of the previous question *****/
Match->Status.QstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, Match->Status.QstInd = Gam_DB_GetPrevQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
if (Match->Status.QstInd) // Start of questions not reached if (Match->Status.QstInd) // Start of questions not reached
{ {
@ -2427,7 +2435,7 @@ static void Mch_SetMatchStatusToNext (struct Mch_Match *Match)
static void Mch_SetMatchStatusToNextQst (struct Mch_Match *Match) static void Mch_SetMatchStatusToNextQst (struct Mch_Match *Match)
{ {
/***** Get index of the next question *****/ /***** Get index of the next question *****/
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, Match->Status.QstInd = Gam_DB_GetNextQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
/***** Get question code *****/ /***** Get question code *****/
@ -2681,6 +2689,7 @@ static void Mch_WriteNumRespondersQst (struct Mch_Match *Match)
/***** Begin block *****/ /***** Begin block *****/
HTM_DIV_Begin ("class=\"MCH_NUM_ANSWERERS\""); HTM_DIV_Begin ("class=\"MCH_NUM_ANSWERERS\"");
HTM_Txt (Txt_MATCH_respond); HTM_Txt (Txt_MATCH_respond);
HTM_BR (); HTM_BR ();
HTM_STRONG_Begin (); HTM_STRONG_Begin ();
@ -2708,8 +2717,9 @@ static void Mch_WriteNumRespondersQst (struct Mch_Match *Match)
HTM_TxtF ("/%u",Match->Status.NumPlayers); HTM_TxtF ("/%u",Match->Status.NumPlayers);
} }
/***** End block *****/
HTM_STRONG_End (); HTM_STRONG_End ();
/***** End block *****/
HTM_DIV_End (); HTM_DIV_End ();
} }
@ -2959,7 +2969,7 @@ static void Mch_ShowNumQstInMch (const struct Mch_Match *Match)
{ {
extern const char *Txt_MATCH_Start; extern const char *Txt_MATCH_Start;
extern const char *Txt_MATCH_End; extern const char *Txt_MATCH_End;
unsigned NumQsts = Gam_GetNumQstsGame (Match->GamCod); unsigned NumQsts = Gam_DB_GetNumQstsGame (Match->GamCod);
HTM_DIV_Begin ("class=\"MCH_NUM_QST\""); HTM_DIV_Begin ("class=\"MCH_NUM_QST\"");
switch (Match->Status.Showing) switch (Match->Status.Showing)
@ -3208,7 +3218,8 @@ static void Mch_PutIconToRemoveMyAnswer (const struct Mch_Match *Match)
/***** Put icon with link *****/ /***** Put icon with link *****/
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\""); HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
HTM_BUTTON_OnMouseDown_Begin (Txt_Delete_my_answer,"BT_LINK MCH_BUTTON_ON ICO_DARKRED"); HTM_BUTTON_OnMouseDown_Begin (Txt_Delete_my_answer,
"BT_LINK MCH_BUTTON_ON ICO_DARKRED");
HTM_Txt ("<i class=\"fas fa-trash\"></i>"); HTM_Txt ("<i class=\"fas fa-trash\"></i>");
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();
@ -3761,7 +3772,8 @@ static void Mch_PutBigButtonHidden (const char *Icon)
{ {
/***** Put inactive icon *****/ /***** Put inactive icon *****/
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\""); HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
HTM_BUTTON_BUTTON_Begin (NULL,"BT_LINK_OFF MCH_BUTTON_HIDDEN ICO_BLACK",NULL); HTM_BUTTON_BUTTON_Begin (NULL,"BT_LINK_OFF MCH_BUTTON_HIDDEN ICO_BLACK",
NULL);
HTM_TxtF ("<i class=\"%s\"></i>",Icon); HTM_TxtF ("<i class=\"%s\"></i>",Icon);
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();
@ -3776,7 +3788,8 @@ static void Mch_PutBigButtonClose (void)
/***** Put icon with link *****/ /***** Put icon with link *****/
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\""); HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
HTM_BUTTON_BUTTON_Begin (Txt_Close,"BT_LINK MCH_BUTTON_ON ICO_DARKRED","window.close();"); HTM_BUTTON_BUTTON_Begin (Txt_Close,"BT_LINK MCH_BUTTON_ON ICO_DARKRED",
"window.close();");
HTM_TxtF ("<i class=\"%s\"></i>",Mch_ICON_CLOSE); HTM_TxtF ("<i class=\"%s\"></i>",Mch_ICON_CLOSE);
HTM_BUTTON_End (); HTM_BUTTON_End ();
HTM_DIV_End (); HTM_DIV_End ();

View File

@ -28,6 +28,7 @@
#define _GNU_SOURCE // For asprintf #define _GNU_SOURCE // For asprintf
#include <stddef.h> // For NULL #include <stddef.h> // For NULL
#include <stdio.h> // For asprintf #include <stdio.h> // For asprintf
#include <stdlib.h> // For free
#include <string.h> // For string functions #include <string.h> // For string functions
#include "swad_box.h" #include "swad_box.h"