diff --git a/swad_changelog.h b/swad_changelog.h index 5cc7ec271..e157fa00f 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -236,13 +236,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.251.2 (2017-07-16)" +#define Log_PLATFORM_VERSION "SWAD 16.251.3 (2017-07-18)" #define CSS_FILE "swad16.235.1.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 16.251.3: Jul 18, 2017 Listing games for remote control. Not finished. (227148 lines) Version 16.251.2: Jul 16, 2017 Listing games for remote control. Not finished. (227062 lines) 1 change necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1667','es','N','Añadir tests a juego'); diff --git a/swad_global.c b/swad_global.c index 91904052f..17e8e990c 100644 --- a/swad_global.c +++ b/swad_global.c @@ -402,6 +402,9 @@ void Gbl_InitializeGlobals (void) Gbl.Test.Tags.All = false; Gbl.Test.Tags.List = NULL; + /* Games for remote control */ + Gbl.Games.ListQuestions = NULL; + /* Public activity */ Gbl.Social.WhichUsrs = Soc_DEFAULT_WHICH_USRS; diff --git a/swad_global.h b/swad_global.h index dbd04baa0..fbac7f61c 100644 --- a/swad_global.h +++ b/swad_global.h @@ -719,6 +719,7 @@ struct Globals long GamCodToEdit; // Used as parameter in contextual links long GamQstCodToEdit; // Used as parameter in contextual links unsigned CurrentPage; + char *ListQuestions; } Games; struct { diff --git a/swad_remote_control.c b/swad_remote_control.c index d738d1c54..2947d2487 100644 --- a/swad_remote_control.c +++ b/swad_remote_control.c @@ -79,6 +79,9 @@ struct GameQuestion char ListAnsTypes[Rmt_MAX_BYTES_LIST_ANSWER_TYPES + 1]; }; +#define Rmt_MAX_SELECTED_QUESTIONS 1000 +#define Rmt_MAX_BYTES_LIST_SELECTED_QUESTIONS (Rmt_MAX_SELECTED_QUESTIONS * (1 + 10 + 1)) + /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ @@ -145,6 +148,11 @@ static unsigned Rmt_GetNextQuestionIndexInGame (long GamCod); static void Rmt_ListGameQuestions (struct Game *Game,struct GameQuestion *GameQst); static void Rmt_PutIconToAddNewQuestions (void); static void Rmt_PutButtonToAddNewQuestions (void); + +static void Rmt_AllocateListSelectedQuestions (void); +static void Rmt_FreeListsSelectedQuestions (void); +static unsigned Rmt_CountNumQuestionsInList (void); + static void Rmt_WriteQstStem (const char *Stem); static void Rmt_WriteAnswersOfAQst (struct Game *Game,struct GameQuestion *GameQst,bool PutFormAnswerGame); static void Rmt_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs); @@ -3146,7 +3154,76 @@ static void Rmt_PutButtonToAddNewQuestions (void) void Rmt_AddTstQuestionsToGame (void) { - Ale_ShowAlert (Ale_WARNING,"Under development...."); // TODO: Write this function + extern const char *Txt_You_must_select_one_ore_more_questions; + + /***** Get selected questions *****/ + /* Allocate space for selected question codes */ + Rmt_AllocateListSelectedQuestions (); + + /* Get question codes */ + Par_GetParMultiToText ("QstCods",Gbl.Games.ListQuestions, + Rmt_MAX_BYTES_LIST_SELECTED_QUESTIONS); + + /* Check number of questions */ + if (Rmt_CountNumQuestionsInList () == 0) // If no questions selected... + { // ...write warning alert + Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_questions); + + // TODO: Show form again!!! + } + + /* Free space for selected question codes */ + Rmt_FreeListsSelectedQuestions (); + } + +/*****************************************************************************/ +/****************** Allocate memory for list of questions ********************/ +/*****************************************************************************/ + +static void Rmt_AllocateListSelectedQuestions (void) + { + if (!Gbl.Games.ListQuestions) + { + if ((Gbl.Games.ListQuestions = (char *) malloc (Rmt_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL) + Lay_ShowErrorAndExit ("Not enough memory to store list of questions."); + Gbl.Games.ListQuestions[0] = '\0'; + } + } + +/*****************************************************************************/ +/*********** Free memory used by list of selected question codes *************/ +/*****************************************************************************/ + +static void Rmt_FreeListsSelectedQuestions (void) + { + if (Gbl.Games.ListQuestions) + { + free ((void *) Gbl.Games.ListQuestions); + Gbl.Games.ListQuestions = NULL; + } + } + +/*****************************************************************************/ +/**** Count the number of questions in the list of selected question codes ***/ +/*****************************************************************************/ + +static unsigned Rmt_CountNumQuestionsInList (void) + { + const char *Ptr; + unsigned NumQuestions = 0; + char LongStr[1+ 10 + 1]; + long QstCod; + + /***** Go over the list Gbl.Test.ListAnsTypes counting the number of types of answer *****/ + Ptr = Gbl.Games.ListQuestions; + while (*Ptr) + { + Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,1 + 10); + if (sscanf (LongStr,"%ld",&QstCod) != 1) + Lay_ShowErrorAndExit ("Wrong question code."); + NumQuestions++; + } + return NumQuestions; } /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index 1d5f75bbd..26573beea 100644 --- a/swad_text.c +++ b/swad_text.c @@ -54665,6 +54665,27 @@ const char *Txt_You_must_select_a_T_F_answer = "You must select a T/F answer."; // Necessita de tradução #endif +const char *Txt_You_must_select_one_ore_more_questions = +#if L==1 + "Heu de seleccionar una o més preguntes."; +#elif L==2 + "Sie müssen eine oder mehrere Fragen auswählen."; +#elif L==3 + "You must select one or more questions."; +#elif L==4 + "Debe seleccionar una o más preguntas."; +#elif L==5 + "Vous devez sélectionner une ou plusieurs questions."; +#elif L==6 + "Debe seleccionar una o más preguntas."; // Okoteve traducción +#elif L==7 + "Devi selezionare una o più domande."; +#elif L==8 + "Musisz wybrać jedno lub więcej pytań."; +#elif L==9 + "Você deve selecionar uma ou mais perguntas."; +#endif + const char *Txt_You_must_select_one_ore_more_recipients = #if L==1 "Debe seleccionar uno o más destinatarios."; // Necessita traduccio