From 979ecb9e9b3b26e013a117224de8f89548e71310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 16 Jul 2017 20:50:01 +0200 Subject: [PATCH] Version 16.251.2 --- swad_action.c | 3 + swad_action.h | 29 +++--- swad_changelog.h | 6 +- swad_remote_control.c | 9 ++ swad_remote_control.h | 2 + swad_test.c | 205 +++++++++++++++++++++++++++++++++++++++--- 6 files changed, 229 insertions(+), 25 deletions(-) diff --git a/swad_action.c b/swad_action.c index c8c82b473..7a9da71b1 100644 --- a/swad_action.c +++ b/swad_action.c @@ -504,6 +504,7 @@ Assessment: NEW. ActShoGam Show game NEW. ActEdiOneGamQst Edit a new question for a game NEW. ActGamLstTstQst List test questions to select one or several questions + NEW. ActAddTstQstToGam Add selected test questions to game NEW. ActRcvGamQst Receive a question of a game NEW. ActReqRemGamQst Request the removal of a question of a game NEW. ActRemGamQst Confirm the removal of a question of a game @@ -1981,6 +1982,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActShoGam */{1661,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_UnhideGame ,NULL}, /* ActEdiOneGamQst */{1662,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RequestEditQuestion ,NULL}, /* ActGamLstTstQst */{1666,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Tst_ListQuestionsToSelect ,NULL}, + /* ActAddTstQstToGam */{1667,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_AddTstQuestionsToGame ,NULL}, /* ActRcvGamQst */{1663,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_ReceiveQst ,NULL}, /* ActReqRemGamQst */{1664,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RequestRemoveQst ,NULL}, /* ActRemGamQst */{1665,-1,TabUnk,ActSeeAllGam ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_THIS_WINDOW,NULL ,Rmt_RemoveQst ,NULL}, @@ -4710,6 +4712,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un ActReqRemGamQst, // #1664 ActRemGamQst, // #1665 ActGamLstTstQst, // #1666 + ActAddTstQstToGam, // #1667 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index c32c0d19f..ff702e24a 100644 --- a/swad_action.h +++ b/swad_action.h @@ -57,9 +57,9 @@ typedef enum typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 90 + 416 + 165 + 172 + 42 + 14 + 97) +#define Act_NUM_ACTIONS (1 + 9 + 43 + 17 + 47 + 33 + 24 + 115 + 91 + 416 + 165 + 172 + 42 + 14 + 97) -#define Act_MAX_ACTION_COD 1666 +#define Act_MAX_ACTION_COD 1667 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 12 @@ -516,19 +516,20 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to #define ActShoGam (ActChgCalCrs1stDay + 76) #define ActEdiOneGamQst (ActChgCalCrs1stDay + 77) #define ActGamLstTstQst (ActChgCalCrs1stDay + 78) -#define ActRcvGamQst (ActChgCalCrs1stDay + 79) -#define ActReqRemGamQst (ActChgCalCrs1stDay + 80) -#define ActRemGamQst (ActChgCalCrs1stDay + 81) +#define ActAddTstQstToGam (ActChgCalCrs1stDay + 79) +#define ActRcvGamQst (ActChgCalCrs1stDay + 80) +#define ActReqRemGamQst (ActChgCalCrs1stDay + 81) +#define ActRemGamQst (ActChgCalCrs1stDay + 82) -#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 82) -#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 83) -#define ActEdiExaAnn (ActChgCalCrs1stDay + 84) -#define ActRcvExaAnn (ActChgCalCrs1stDay + 85) -#define ActPrnExaAnn (ActChgCalCrs1stDay + 86) -#define ActReqRemExaAnn (ActChgCalCrs1stDay + 87) -#define ActRemExaAnn (ActChgCalCrs1stDay + 88) -#define ActHidExaAnn (ActChgCalCrs1stDay + 89) -#define ActShoExaAnn (ActChgCalCrs1stDay + 90) +#define ActSeeOneExaAnn (ActChgCalCrs1stDay + 83) +#define ActSeeDatExaAnn (ActChgCalCrs1stDay + 84) +#define ActEdiExaAnn (ActChgCalCrs1stDay + 85) +#define ActRcvExaAnn (ActChgCalCrs1stDay + 86) +#define ActPrnExaAnn (ActChgCalCrs1stDay + 87) +#define ActReqRemExaAnn (ActChgCalCrs1stDay + 88) +#define ActRemExaAnn (ActChgCalCrs1stDay + 89) +#define ActHidExaAnn (ActChgCalCrs1stDay + 90) +#define ActShoExaAnn (ActChgCalCrs1stDay + 91) /*****************************************************************************/ /******************************** Files tab **********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index e920158f8..5cc7ec271 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -236,13 +236,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.251.1 (2017-07-16)" +#define Log_PLATFORM_VERSION "SWAD 16.251.2 (2017-07-16)" #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.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'); + Version 16.251.1: Jul 16, 2017 Listing games for remote control. Not finished. (226888 lines) Version 16.251: Jul 16, 2017 Listing games for remote control. Not finished. (226867 lines) 19 changes necessary in database: diff --git a/swad_remote_control.c b/swad_remote_control.c index 8f1832ca2..d738d1c54 100644 --- a/swad_remote_control.c +++ b/swad_remote_control.c @@ -3140,6 +3140,15 @@ static void Rmt_PutButtonToAddNewQuestions (void) Act_FormEnd (); } +/*****************************************************************************/ +/******************** Add selected test questions to game ********************/ +/*****************************************************************************/ + +void Rmt_AddTstQuestionsToGame (void) + { + Ale_ShowAlert (Ale_WARNING,"Under development...."); // TODO: Write this function + } + /*****************************************************************************/ /****************** Write the heading of a game question *******************/ /*****************************************************************************/ diff --git a/swad_remote_control.h b/swad_remote_control.h index da33508af..88b5344a4 100644 --- a/swad_remote_control.h +++ b/swad_remote_control.h @@ -113,6 +113,8 @@ void Rmt_RemoveGames (Sco_Scope_t Scope,long Cod); void Rmt_RequestEditQuestion (void); void Rmt_ReceiveQst (void); +void Rmt_AddTstQuestionsToGame (void); + void Rmt_RequestRemoveQst (void); void Rmt_RemoveQst (void); diff --git a/swad_test.c b/swad_test.c index b57063bc1..4342a47b7 100644 --- a/swad_test.c +++ b/swad_test.c @@ -194,7 +194,8 @@ static unsigned long Tst_GetQuestions (MYSQL_RES **mysql_res); static unsigned long Tst_GetQuestionsForTest (MYSQL_RES **mysql_res); static void Tst_ListOneQstToEdit (void); static bool Tst_GetOneQuestionByCod (long QstCod,MYSQL_RES **mysql_res); -static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_res); +static void Tst_ListOneOrMoreQuestionsForEdition (unsigned long NumRows,MYSQL_RES *mysql_res); +static void Tst_ListOneOrMoreQuestionsForSelection (unsigned long NumRows,MYSQL_RES *mysql_res); static void Tst_WriteAnswersOfAQstEdit (long QstCod); static void Tst_WriteAnswersOfAQstViewTest (unsigned NumQst,long QstCod,bool Shuffle); @@ -2598,7 +2599,7 @@ void Tst_ListQuestionsToEdit (void) fprintf (Gbl.F.Out,""); /* Show the table with the questions */ - Tst_ListOneOrMoreQuestions (NumRows,mysql_res); + Tst_ListOneOrMoreQuestionsForEdition (NumRows,mysql_res); } /***** Free structure that stores the query result *****/ @@ -2631,7 +2632,7 @@ void Tst_ListQuestionsToSelect (void) { if ((NumRows = Tst_GetQuestions (&mysql_res)) != 0) // Query database /* Show the table with the questions */ - Tst_ListOneOrMoreQuestions (NumRows,mysql_res); + Tst_ListOneOrMoreQuestionsForSelection (NumRows,mysql_res); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -2951,7 +2952,7 @@ static void Tst_ListOneQstToEdit (void) /***** Query database *****/ if (Tst_GetOneQuestionByCod (Gbl.Test.QstCod,&mysql_res)) /***** Show the question ready to edit it *****/ - Tst_ListOneOrMoreQuestions (1,mysql_res); + Tst_ListOneOrMoreQuestionsForEdition (1,mysql_res); else Lay_ShowErrorAndExit ("Can not get question."); @@ -2997,7 +2998,7 @@ static bool Tst_GetOneQuestionByCod (long QstCod,MYSQL_RES **mysql_res) /****************** List for edition one or more test questions **************/ /*****************************************************************************/ -static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_res) +static void Tst_ListOneOrMoreQuestionsForEdition (unsigned long NumRows,MYSQL_RES *mysql_res) { extern const char *Hlp_ASSESSMENT_Tests; extern const char *Txt_Questions; @@ -3023,12 +3024,12 @@ static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_r /***** Start box *****/ Box_StartBox (NULL,Txt_Questions,Tst_PutIconsTests, - Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); + Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); /***** Write the heading *****/ Tbl_StartTableWideMargin (2); fprintf (Gbl.F.Out,"" - "" + "" "" "%s" "" @@ -3114,9 +3115,11 @@ static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_r if ((Gbl.Test.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) Lay_ShowErrorAndExit ("Wrong code of question."); - /* Write icon to remove the question */ + /***** Icons *****/ fprintf (Gbl.F.Out,"" "",Gbl.RowEvenOdd); + + /* Write icon to remove the question */ Act_FormStart (ActReqRemTstQst); Tst_PutParamQstCod (); if (NumRows == 1) @@ -3125,10 +3128,8 @@ static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_r Tst_WriteParamEditQst (); Ico_PutIconRemove (); Act_FormEnd (); - fprintf (Gbl.F.Out,""); /* Write icon to edit the question */ - fprintf (Gbl.F.Out,"",Gbl.RowEvenOdd); Act_FormStart (ActEdiOneTstQst); Tst_PutParamQstCod (); fprintf (Gbl.F.Out,""); /* Write number of question */ @@ -3280,6 +3282,189 @@ static void Tst_ListOneOrMoreQuestions (unsigned long NumRows,MYSQL_RES *mysql_r Box_EndBox (); } +/*****************************************************************************/ +/****************** List for edition one or more test questions **************/ +/*****************************************************************************/ + +static void Tst_ListOneOrMoreQuestionsForSelection (unsigned long NumRows,MYSQL_RES *mysql_res) + { + extern const char *Hlp_ASSESSMENT_Tests; + extern const char *Txt_Questions; + extern const char *Txt_No_INDEX; + extern const char *Txt_Code; + extern const char *Txt_Date; + extern const char *Txt_Tags; + extern const char *Txt_Type; + extern const char *Txt_TST_STR_ANSWER_TYPES[Tst_NUM_ANS_TYPES]; + extern const char *Txt_Shuffle; + extern const char *Txt_Question; + extern const char *Txt_Today; + extern const char *Txt_Add_questions; + unsigned long NumRow; + MYSQL_ROW row; + unsigned UniqueId; + time_t TimeUTC; + + /***** Start box *****/ + Box_StartBox (NULL,Txt_Questions,NULL, + Hlp_ASSESSMENT_Tests,Box_NOT_CLOSABLE); + + /***** Start form *****/ + Act_FormStart (ActAddTstQstToGam); + + /***** Write the heading *****/ + Tbl_StartTableWideMargin (2); + fprintf (Gbl.F.Out,"" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "" + "%s" + "" + "", + Txt_No_INDEX, + Txt_Code, + Txt_Date, + Txt_Tags, + Txt_Type, + Txt_Shuffle, + Txt_Question); + + /***** Write rows *****/ + for (NumRow = 0, UniqueId = 1; + NumRow < NumRows; + NumRow++, UniqueId++) + { + Gbl.RowEvenOdd = NumRow % 2; + + row = mysql_fetch_row (mysql_res); + /* + row[ 0] QstCod + row[ 1] UNIX_TIMESTAMP(EditTime) + row[ 2] AnsType + row[ 3] Shuffle + row[ 4] Stem + row[ 5] Feedback + row[ 6] ImageName + row[ 7] ImageTitle + row[ 8] ImageURL + row[ 9] NumHits + row[10] NumHitsNotBlank + row[11] Score + */ + /***** Create test question *****/ + Tst_QstConstructor (); + + /* row[0] holds the code of the question */ + if ((Gbl.Test.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) + Lay_ShowErrorAndExit ("Wrong code of question."); + + /***** Icons *****/ + fprintf (Gbl.F.Out,"" + "",Gbl.RowEvenOdd); + + /* Write checkbox to select the question */ + fprintf (Gbl.F.Out,"", + Gbl.Test.QstCod); + + /* Write number of question */ + fprintf (Gbl.F.Out,"" + "%lu " + "", + Gbl.RowEvenOdd,NumRow + 1); + + /* Write question code */ + fprintf (Gbl.F.Out,"" + "%ld " + "", + Gbl.RowEvenOdd,Gbl.Test.QstCod); + + /* Write the date (row[1] has the UTC date-time) */ + TimeUTC = Dat_GetUNIXTimeFromStr (row[1]); + fprintf (Gbl.F.Out,"" + "" + "", + UniqueId,Gbl.RowEvenOdd, + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); + + /* Write the question tags */ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + Tst_GetAndWriteTagsQst (Gbl.Test.QstCod); + fprintf (Gbl.F.Out,""); + + /* Write the question type (row[2]) */ + Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[2]); + fprintf (Gbl.F.Out,"" + "%s " + "", + Gbl.RowEvenOdd, + Txt_TST_STR_ANSWER_TYPES[Gbl.Test.AnswerType]); + + /* Write if shuffle is enabled (row[3]) */ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + + fprintf (Gbl.F.Out,""); + + fprintf (Gbl.F.Out,""); + + /* Write the stem (row[4]), the image (row[6], row[7], row[8]), + the feedback (row[5]) and the answers */ + fprintf (Gbl.F.Out,"", + Gbl.RowEvenOdd); + Tst_WriteQstStem (row[4],"TEST_EDI"); + Img_GetImageNameTitleAndURLFromRow (row[6],row[7],row[8],&Gbl.Test.Image); + Img_ShowImage (&Gbl.Test.Image, + "TEST_IMG_EDIT_LIST_STEM_CONTAINER", + "TEST_IMG_EDIT_LIST_STEM"); + Tst_WriteQstFeedback (row[5],"TEST_EDI_LIGHT"); + Tst_WriteAnswersOfAQstEdit (Gbl.Test.QstCod); + fprintf (Gbl.F.Out,"" + ""); + + /***** Destroy test question *****/ + Tst_QstDestructor (); + } + + /***** End table *****/ + Tbl_EndTable (); + + /***** Button to add questions *****/ + Btn_PutConfirmButton (Txt_Add_questions); + + /***** End form *****/ + Act_FormEnd (); + + /***** End box *****/ + Box_EndBox (); + } + /*****************************************************************************/ /*********** Write hidden parameters for edition of test questions ***********/ /*****************************************************************************/