From 0d015026cfad29178dbdc79e3a396b612907963a Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 27 Apr 2020 19:37:49 +0200 Subject: [PATCH] Version19.204 --- swad_action.c | 8 +- swad_changelog.h | 3 +- swad_exam.c | 385 ++++++++++++++------------------------------- swad_exam.h | 8 +- swad_exam_event.c | 4 +- swad_exam_result.c | 9 +- swad_game.c | 4 +- swad_game.h | 4 +- swad_test.c | 154 ++++++++---------- swad_test.h | 1 + 10 files changed, 203 insertions(+), 377 deletions(-) diff --git a/swad_action.c b/swad_action.c index 31336812..2f7d12e5 100644 --- a/swad_action.c +++ b/swad_action.c @@ -730,8 +730,8 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActReqAddQstExaSet ] = {1885,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,ExaSet_ReqSelectQstsToAddToSet ,NULL}, [ActLstTstQstForSet ] = {1886,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_ListQstsToAddToSet ,NULL}, [ActAddQstToExa ] = {1887,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_AddQstsToSet ,NULL}, - [ActReqRemSetQst ] = {1888,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RequestRemoveQst ,NULL}, - [ActRemExaQst ] = {1889,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveQst ,NULL}, + [ActReqRemSetQst ] = {1888,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RequestRemoveQstFromSet ,NULL}, + [ActRemExaQst ] = {1889,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_RemoveQstFromSet ,NULL}, [ActSeeGam ] = {1650,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_SeeOneGame ,NULL}, @@ -778,8 +778,8 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActAddOneGamQst ] = {1662,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,Gam_ReqSelectQstsToAddToGame ,NULL}, [ActGamLstTstQst ] = {1666,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_ListQstsToAddToGame ,NULL}, [ActAddTstQstToGam ] = {1667,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_AddQstsToGame ,NULL}, - [ActReqRemGamQst ] = {1664,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestRemoveQst ,NULL}, - [ActRemGamQst ] = {1665,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveQst ,NULL}, + [ActReqRemGamQst ] = {1664,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestRemoveQstFromGame ,NULL}, + [ActRemGamQst ] = {1665,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveQstFromGame ,NULL}, [ActUp_GamQst ] = {1668,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_MoveUpQst ,NULL}, [ActDwnGamQst ] = {1669,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_MoveDownQst ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index c92c27f0..c527e24a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -544,10 +544,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.203 (2020-04-27)" +#define Log_PLATFORM_VERSION "SWAD 19.204 (2020-04-27)" #define CSS_FILE "swad19.193.1.css" #define JS_FILE "swad19.193.1.js" /* + Version 19.204: Apr 27, 2020 Remove question from set of questions. (300466 lines) Version 19.203: Apr 27, 2020 List questions in every set of questions. (300606 lines) 3 changes necessary in database: ALTER TABLE exa_questions DROP INDEX SetCod,DROP INDEX SetCod_2; diff --git a/swad_exam.c b/swad_exam.c index 6d5d05ad..7c0c6219 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -130,7 +130,7 @@ static void Exa_PutFormsToRemEditOneExam (struct Exa_Exams *Exams, const struct Exa_Exam *Exam, const char *Anchor); -static void Exa_PutParamsOneQst (void *Exams); +static void ExaSet_PutParamsOneQst (void *Exams); static void Exa_PutHiddenParamOrder (Exa_Order_t SelectedOrder); static Exa_Order_t Exa_GetParamOrder (void); @@ -175,8 +175,6 @@ static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt); static void ExaSet_PutParamSetCod (long SetCod); -static void Exa_RemAnswersOfAQuestion (long ExaCod,unsigned QstInd); - static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod); static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd); @@ -191,7 +189,6 @@ static void ExaSet_ListExamSets (struct Exa_Exams *Exams, static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams, const struct Exa_Exam *Exam, const struct ExaSet_Set *Set); -static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam); static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, const struct Exa_Exam *Exam, unsigned MaxSetInd, @@ -206,10 +203,6 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, unsigned NumQsts, MYSQL_RES *mysql_res, bool ICanEditQuestions); -static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, - long ExaCod,unsigned NumQsts, - MYSQL_RES *mysql_res, - bool ICanEditQuestions); static void Exa_PutIconToAddNewQuestions (void *Exams); static void Exa_PutButtonToAddNewQuestions (struct Exa_Exams *Exams); @@ -239,7 +232,7 @@ void Exa_ResetExams (struct Exa_Exams *Exams) Exams->ExaCod = -1L; // Selected/current exam code Exams->EvtCod = -1L; // Selected/current event code Exams->SetInd = 0; // Current set index - Exams->QstInd = 0; // Current question index + Exams->QstCod = -1L; // Current question code } /*****************************************************************************/ @@ -363,6 +356,7 @@ static void Exa_ListAllExams (struct Exa_Exams *Exams) /* Get data of this exam */ Exam.ExaCod = Exams->Lst[NumExam - 1].ExaCod; Exa_GetDataOfExamByCod (&Exam); + Exams->ExaCod = Exam.ExaCod; /* Show exam */ Exa_ShowOneExam (Exams, @@ -505,10 +499,10 @@ void Exa_SeeOneExam (void) /***** Get exam data *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Show exam *****/ Exa_ShowOnlyOneExam (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new event } @@ -518,16 +512,14 @@ void Exa_SeeOneExam (void) void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams, struct Exa_Exam *Exam, - bool ListExamQuestions, bool PutFormNewMatch) { - Exa_ShowOnlyOneExamBegin (Exams,Exam,ListExamQuestions,PutFormNewMatch); + Exa_ShowOnlyOneExamBegin (Exams,Exam,PutFormNewMatch); Exa_ShowOnlyOneExamEnd (); } void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams, struct Exa_Exam *Exam, - bool ListExamQuestions, bool PutFormNewMatch) { extern const char *Hlp_ASSESSMENT_Exams; @@ -544,12 +536,8 @@ void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams, Exam, true); // Show only this exam - if (ListExamQuestions) - /***** Write questions of this exam *****/ - Exa_ListExamQuestions (Exams,Exam); - else - /***** List events *****/ - ExaEvt_ListEvents (Exams,Exam,PutFormNewMatch); + /***** List events *****/ + ExaEvt_ListEvents (Exams,Exam,PutFormNewMatch); } void Exa_ShowOnlyOneExamEnd (void) @@ -566,14 +554,14 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams, extern const char *Txt_Maximum_grade; extern const char *Txt_Result_visibility; extern const char *Txt_Events; - char *Anchor = NULL; + char *Anchor; static unsigned UniqueId = 0; char *Id; Dat_StartEndTime_t StartEndTime; const char *Color; char Txt[Cns_MAX_BYTES_TEXT + 1]; - /***** Set anchor string *****/ + /***** Build anchor string *****/ Frm_SetAnchorStr (Exam->ExaCod,&Anchor); /***** Begin box and table *****/ @@ -808,13 +796,10 @@ void ExaSet_PutParamsOneSet (void *Exams) /**************** Put parameter to move/remove one question ******************/ /*****************************************************************************/ -static void Exa_PutParamsOneQst (void *Exams) +static void ExaSet_PutParamsOneQst (void *Exams) { - if (Exams) - { - Exa_PutParams (Exams); - Exa_PutParamQstInd (((struct Exa_Exams *) Exams)->QstInd); - } + ExaSet_PutParamsOneSet (Exams); + Tst_PutParamQstCod (&(((struct Exa_Exams *) Exams)->QstCod)); } /*****************************************************************************/ @@ -1287,6 +1272,7 @@ void Exa_AskRemExam (void) /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Show question and button to remove exam *****/ Exams.ExaCod = Exam.ExaCod; @@ -1326,6 +1312,7 @@ void Exa_RemoveExam (void) /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Remove exam from all tables *****/ Exa_RemoveExamFromAllTables (Exam.ExaCod); @@ -1409,6 +1396,7 @@ void Exa_HideExam (void) /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Hide exam *****/ DB_QueryUPDATE ("can not hide exam", @@ -1446,6 +1434,7 @@ void Exa_UnhideExam (void) /***** Get data of the exam from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Show exam *****/ DB_QueryUPDATE ("can not show exam", @@ -1524,8 +1513,11 @@ void Exa_RequestCreatOrEditExam (void) /* Initialize to empty exam */ Exa_ResetExam (&Exam); else + { /* Get exam data from database */ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; + } /***** Put form to create/edit an exam and show sets *****/ Exa_PutFormsOneExam (&Exams,&Exam,&Set,ItsANewExam); @@ -1666,6 +1658,7 @@ void ExaSet_RecFormSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** If I can edit exams ==> receive set from form *****/ ExaSet_ReceiveSetFieldsFromForm (&Set); @@ -1762,7 +1755,9 @@ void ExaSet_ChangeSetTitle (void) /***** Get exam and set data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Receive new title from form *****/ Par_GetParToText ("Title",NewTitle,ExaSet_MAX_BYTES_TITLE); @@ -1816,7 +1811,9 @@ void ExaSet_ChangeNumQstsToExam (void) /***** Get exam and set data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Get number of questions in set to appear in exam *****/ NumQstsToExam = (unsigned) Par_GetParToUnsignedLong ("NumQstsToExam", @@ -2265,6 +2262,7 @@ void ExaSet_RequestCreatOrEditSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; Exa_GetExamTxtFromDB (Exam.ExaCod,Txt); /***** Get set data *****/ @@ -2272,8 +2270,11 @@ void ExaSet_RequestCreatOrEditSet (void) /* Initialize to empty set */ ExaSet_ResetSet (&Set); else + { /* Get set data from database */ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; + } /***** Put form to edit the exam created or updated *****/ Exa_PutFormEditionExam (&Exams,&Exam,Txt, @@ -2315,12 +2316,14 @@ void ExaSet_ReqSelectQstsToAddToSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; Exa_GetExamTxtFromDB (Exam.ExaCod,Txt); if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Show form to select questions for set *****/ Tst_RequestSelectTestsForSet (&Exams); @@ -2365,12 +2368,14 @@ void ExaSet_ListQstsToAddToSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; Exa_GetExamTxtFromDB (Exam.ExaCod,Txt); if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** List several test questions for selection *****/ Tst_ListQuestionsToSelectForSet (&Exams); @@ -2413,22 +2418,6 @@ unsigned Exa_GetParamQstInd (void) return (unsigned) QstInd; } -/*****************************************************************************/ -/********************** Remove answers of an exam question ********************/ -/*****************************************************************************/ - -static void Exa_RemAnswersOfAQuestion (long ExaCod,unsigned QstInd) - { - /***** Remove answers from all events of this exam *****/ - DB_QueryDELETE ("can not remove the answers of a question", - "DELETE FROM exa_answers" - " USING exa_events,exa_answers" - " WHERE exa_events.ExaCod=%ld" // From all events of this exam... - " AND exa_events.EvtCod=exa_answers.EvtCod" - " AND exa_answers.QstInd=%u", // ...remove only answers to this question - ExaCod,QstInd); - } - /*****************************************************************************/ /****************** Get set index given exam and set code ********************/ /*****************************************************************************/ @@ -2784,59 +2773,6 @@ static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams, Box_BoxEnd (); } -/*****************************************************************************/ -/************************ List the questions of an exam ***********************/ -/*****************************************************************************/ - -static void Exa_ListExamQuestions (struct Exa_Exams *Exams,struct Exa_Exam *Exam) - { - extern const char *Hlp_ASSESSMENT_Exams_questions; - extern const char *Txt_Questions; - extern const char *Txt_This_exam_has_no_questions; - MYSQL_RES *mysql_res; - unsigned NumQsts; - bool ICanEditQuestions = Exa_CheckIfEditable (Exam); - - /***** Get data of questions from database *****/ - NumQsts = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get exam questions", - "SELECT QstInd," // row[0] - "QstCod" // row[1] - " FROM exa_questions" - " WHERE ExaCod=%ld" - " ORDER BY QstInd", - Exam->ExaCod); - - /***** Begin box *****/ - Exams->ExaCod = Exam->ExaCod; - if (ICanEditQuestions) - Box_BoxBegin (NULL,Txt_Questions, - Exa_PutIconToAddNewQuestions,Exams, - Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,Txt_Questions, - NULL,NULL, - Hlp_ASSESSMENT_Exams_questions,Box_NOT_CLOSABLE); - - /***** Show table with questions *****/ - if (NumQsts) - Exa_ListOneOrMoreQuestionsForEdition (Exams, - Exam->ExaCod,NumQsts,mysql_res, - ICanEditQuestions); - else // This exam has no questions - Ale_ShowAlert (Ale_INFO,Txt_This_exam_has_no_questions); - - /***** Put button to add a new question in this exam *****/ - if (ICanEditQuestions) // I can edit questions - Exa_PutButtonToAddNewQuestions (Exams); - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - /***** End box *****/ - Box_BoxEnd (); - } - /*****************************************************************************/ /************************* List exam sets for edition ************************/ /*****************************************************************************/ @@ -2855,7 +2791,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, unsigned NumSet; struct ExaSet_Set Set; MYSQL_ROW row; - char *Anchor = NULL; + char *Anchor; char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; /***** Write the heading *****/ @@ -3074,7 +3010,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, MYSQL_ROW row; struct Tst_Question Question; bool QuestionExists; - char *Anchor = NULL; + char *Anchor; /***** Build anchor string *****/ Frm_SetAnchorStr (Exams->SetCod,&Anchor); @@ -3108,7 +3044,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, row[0] QstCod */ /* Get question code (row[0]) */ - Question.QstCod = Str_ConvertStrCodToLongCod (row[0]); + Exams->QstCod = Question.QstCod = Str_ConvertStrCodToLongCod (row[0]); /***** Begin row *****/ HTM_TR_Begin (NULL); @@ -3120,8 +3056,7 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, if (ICanEditQuestions) { Frm_StartForm (ActReqRemSetQst); - ExaSet_PutParamsOneSet (Exams); - Tst_PutParamQstCod (&Question.QstCod); + ExaSet_PutParamsOneQst (Exams); Ico_PutIconRemove (); Frm_EndForm (); } @@ -3153,106 +3088,6 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, Frm_FreeAnchorStr (Anchor); } -/*****************************************************************************/ -/********************* List exam questions for edition ***********************/ -/*****************************************************************************/ - -static void Exa_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, - long ExaCod,unsigned NumQsts, - MYSQL_RES *mysql_res, - bool ICanEditQuestions) - { - extern const char *Txt_Questions; - extern const char *Txt_No_INDEX; - extern const char *Txt_Code; - extern const char *Txt_Tags; - extern const char *Txt_Question; - unsigned NumQst; - MYSQL_ROW row; - struct Tst_Question Question; - unsigned QstInd; - char StrQstInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - bool QuestionExists; - - /***** Write the heading *****/ - HTM_TABLE_BeginWideMarginPadding (2); - HTM_TR_Begin (NULL); - - HTM_TH_Empty (1); - - HTM_TH (1,1,"CT",Txt_No_INDEX); - HTM_TH (1,1,"CT",Txt_Code); - HTM_TH (1,1,"CT",Txt_Tags); - HTM_TH (1,1,"CT",Txt_Question); - - HTM_TR_End (); - - /***** Write rows *****/ - for (NumQst = 0; - NumQst < NumQsts; - NumQst++) - { - Gbl.RowEvenOdd = NumQst % 2; - - /***** Create test question *****/ - Tst_QstConstructor (&Question); - - /***** Get question data *****/ - row = mysql_fetch_row (mysql_res); - /* - row[0] QstInd - row[1] QstCod - */ - - /* Get question index (row[0]) */ - QstInd = Str_ConvertStrToUnsigned (row[0]); - snprintf (StrQstInd,sizeof (StrQstInd), - "%u", - QstInd); - - /* Get question code (row[1]) */ - Question.QstCod = Str_ConvertStrCodToLongCod (row[1]); - - /***** Icons *****/ - Exams->ExaCod = ExaCod; - Exams->QstInd = QstInd; - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); - - /* Put icon to remove the question */ - if (ICanEditQuestions) - { - Frm_StartForm (ActReqRemSetQst); - Exa_PutParams (Exams); - Exa_PutParamQstInd (QstInd); - Ico_PutIconRemove (); - Frm_EndForm (); - } - else - Ico_PutIconRemovalNotAllowed (); - - /* Put icon to edit the question */ - if (ICanEditQuestions) - Ico_PutContextualIconToEdit (ActEdiOneTstQst,NULL, - Tst_PutParamQstCod,&Question.QstCod); - - HTM_TD_End (); - - /***** Question *****/ - QuestionExists = Tst_GetQstDataFromDB (&Question); - Tst_ListQuestionForEdition (&Question,QstInd,QuestionExists,NULL); - - HTM_TR_End (); - - /***** Destroy test question *****/ - Tst_QstDestructor (&Question); - } - - /***** End table *****/ - HTM_TABLE_End (); - } - /*****************************************************************************/ /***************** Put icon to add a new questions to exam *******************/ /*****************************************************************************/ @@ -3320,12 +3155,14 @@ void ExaSet_AddQstsToSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; Exa_GetExamTxtFromDB (Exam.ExaCod,Txt); if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Get selected questions *****/ /* Allocate space for selected question codes */ @@ -3424,11 +3261,13 @@ void ExaSet_RequestRemoveSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Show question and button to remove question *****/ Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL, @@ -3471,11 +3310,13 @@ void ExaSet_RemoveSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Remove the set from all the tables *****/ /* Remove questions associated to set */ @@ -3541,11 +3382,13 @@ void ExaSet_MoveUpSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Get set index *****/ SetIndBottom = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod); @@ -3602,11 +3445,13 @@ void ExaSet_MoveDownSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); /***** Get set data from database *****/ ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; /***** Get set index *****/ SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod); @@ -3642,120 +3487,118 @@ void ExaSet_MoveDownSet (void) /********************** Request the removal of a question ********************/ /*****************************************************************************/ -void Exa_RequestRemoveQst (void) +void ExaSet_RequestRemoveQstFromSet (void) { extern const char *Txt_Do_you_really_want_to_remove_the_question_X; extern const char *Txt_Remove_question; struct Exa_Exams Exams; struct Exa_Exam Exam; - unsigned QstInd; + struct ExaSet_Set Set; + char *Anchor; /***** Reset exams context *****/ Exa_ResetExams (&Exams); - /***** Reset exam *****/ + /***** Reset exam and set *****/ Exa_ResetExam (&Exam); + ExaSet_ResetSet (&Set); /***** Get parameters *****/ Exa_GetParams (&Exams); if (Exams.ExaCod <= 0) Lay_WrongExamExit (); - Exam.ExaCod = Exams.ExaCod; + Set.ExaCod = Exam.ExaCod = Exams.ExaCod; + Set.SetCod = ExaSet_GetParamSetCod (); + if (Set.SetCod <= 0) + Lay_WrongSetExit (); /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); - - /***** Check if exam has events *****/ - if (Exa_CheckIfEditable (&Exam)) - { - /***** Get question index *****/ - QstInd = Exa_GetParamQstInd (); - - /***** Show question and button to remove question *****/ - Exams.ExaCod = Exam.ExaCod; - Exams.QstInd = QstInd; - Ale_ShowAlertAndButton (ActRemExaQst,NULL,NULL, - Exa_PutParamsOneQst,&Exams, - Btn_REMOVE_BUTTON,Txt_Remove_question, - Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_question_X, - QstInd); - } - else + Exams.ExaCod = Exam.ExaCod; + if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); - /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Exam, - true, // List exam questions - false); // Do not put form to start new event + /***** Get set data from database *****/ + ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; + + /***** Get question index *****/ + Exams.QstCod = Tst_GetParamQstCod (); + + /***** Build anchor string *****/ + Frm_SetAnchorStr (Set.SetCod,&Anchor); + + /***** Show question and button to remove question *****/ + Ale_ShowAlertAndButton (ActRemExaQst,Anchor,NULL, + ExaSet_PutParamsOneQst,&Exams, + Btn_REMOVE_BUTTON,Txt_Remove_question, + Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_question_X, + Exams.QstCod); + + /***** Free anchor string *****/ + Frm_FreeAnchorStr (Anchor); + + /***** Show current exam and its sets *****/ + Exa_PutFormsOneExam (&Exams,&Exam,&Set, + false); // It's not a new exam } /*****************************************************************************/ /****************************** Remove a question ****************************/ /*****************************************************************************/ -void Exa_RemoveQst (void) +void ExaSet_RemoveQstFromSet (void) { extern const char *Txt_Question_removed; struct Exa_Exams Exams; struct Exa_Exam Exam; - unsigned QstInd; + struct ExaSet_Set Set; + long QstCod; /***** Reset exams context *****/ Exa_ResetExams (&Exams); - /***** Reset exam *****/ + /***** Reset exam and set *****/ Exa_ResetExam (&Exam); + ExaSet_ResetSet (&Set); /***** Get parameters *****/ Exa_GetParams (&Exams); if (Exams.ExaCod <= 0) Lay_WrongExamExit (); - Exam.ExaCod = Exams.ExaCod; + Set.ExaCod = Exam.ExaCod = Exams.ExaCod; + Set.SetCod = ExaSet_GetParamSetCod (); + if (Set.SetCod <= 0) + Lay_WrongSetExit (); /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); - - /***** Check if exam has events *****/ - if (Exa_CheckIfEditable (&Exam)) - { - /***** Get question index *****/ - QstInd = Exa_GetParamQstInd (); - - /***** Remove the question from all the tables *****/ - /* Remove answers from this test question */ - Exa_RemAnswersOfAQuestion (Exam.ExaCod,QstInd); - - /* Remove the question itself */ - DB_QueryDELETE ("can not remove a question", - "DELETE FROM exa_questions" - " WHERE ExaCod=%ld AND QstInd=%u", - Exam.ExaCod,QstInd); - if (!mysql_affected_rows (&Gbl.mysql)) - Lay_ShowErrorAndExit ("The question to be removed does not exist."); - - /* Change index of questions greater than this */ - DB_QueryUPDATE ("can not update indexes of questions in table of answers", - "UPDATE exa_answers,exa_events" - " SET exa_answers.QstInd=exa_answers.QstInd-1" - " WHERE exa_events.ExaCod=%ld" - " AND exa_events.EvtCod=exa_answers.EvtCod" - " AND exa_answers.QstInd>%u", - Exam.ExaCod,QstInd); - DB_QueryUPDATE ("can not update indexes of questions", - "UPDATE exa_questions SET QstInd=QstInd-1" - " WHERE ExaCod=%ld AND QstInd>%u", - Exam.ExaCod,QstInd); - - /***** Write message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed); - } - else + Exams.ExaCod = Exam.ExaCod; + if (!Exa_CheckIfEditable (&Exam)) Lay_NoPermissionExit (); - /***** Show current exam *****/ - Exa_ShowOnlyOneExam (&Exams,&Exam, - true, // List exam questions - false); // Do not put form to start new event + /***** Get set data from database *****/ + ExaSet_GetDataOfSetByCod (&Set); + Exams.SetCod = Set.SetCod; + + /***** Get question index *****/ + QstCod = Tst_GetParamQstCod (); + + /***** Remove the question from set *****/ + /* Remove the question itself */ + DB_QueryDELETE ("can not remove a question from a set", + "DELETE FROM exa_questions" + " WHERE SetCod=%ld AND QstCod=%ld", + Set.SetCod,QstCod); + if (!mysql_affected_rows (&Gbl.mysql)) + Lay_ShowErrorAndExit ("The question to be removed does not exist."); + + /***** Write message *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed); + + /***** Show current exam and its sets *****/ + Exa_PutFormsOneExam (&Exams,&Exam,&Set, + false); // It's not a new exam } /*****************************************************************************/ @@ -3872,10 +3715,10 @@ void Exa_RequestNewEvent (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Show exam *****/ Exa_ShowOnlyOneExam (&Exams,&Exam, - false, // Do not list exam questions true); // Put form to start new event } diff --git a/swad_exam.h b/swad_exam.h index 2aee1070..a7bb7ae3 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -80,7 +80,7 @@ struct Exa_Exams long SetCod; // Selected/current set code long EvtCod; // Selected/current match code unsigned SetInd; // Current set index - unsigned QstInd; // Current question index + long QstCod; // Current question code }; struct Exa_Exam @@ -121,11 +121,9 @@ void Exa_SeeAllExams (void); void Exa_SeeOneExam (void); void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams, struct Exa_Exam *Exam, - bool ListExamQuestions, bool PutFormNewMatch); void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams, struct Exa_Exam *Exam, - bool ListExamQuestions, bool PutFormNewMatch); void Exa_ShowOnlyOneExamEnd (void); @@ -181,8 +179,8 @@ void ExaSet_RemoveSet (void); void ExaSet_MoveUpSet (void); void ExaSet_MoveDownSet (void); -void Exa_RequestRemoveQst (void); -void Exa_RemoveQst (void); +void ExaSet_RequestRemoveQstFromSet (void); +void ExaSet_RemoveQstFromSet (void); void Exa_PutButtonNewEvent (struct Exa_Exams *Exams,long ExaCod); void Exa_RequestNewEvent (void); diff --git a/swad_exam_event.c b/swad_exam_event.c index 197810d5..465b1cd5 100644 --- a/swad_exam_event.c +++ b/swad_exam_event.c @@ -929,7 +929,6 @@ void ExaEvt_ToggleVisibilResultsEvtUsr (void) /***** Show current exam *****/ Exa_ShowOnlyOneExam (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new exam event } @@ -1070,7 +1069,6 @@ void ExaEvt_RequestRemoveEvent (void) /***** Show current exam *****/ Exa_ShowOnlyOneExam (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new exam event } @@ -1108,7 +1106,6 @@ void ExaEvt_RemoveEvent (void) /***** Show current exam *****/ Exa_ShowOnlyOneExam (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new exam event } @@ -1302,6 +1299,7 @@ void ExaEvt_GetAndCheckParameters (struct Exa_Exams *Exams, /***** Get exam data and event from database *****/ Exa_GetDataOfExamByCod (Exam); + Exams->ExaCod = Exam->ExaCod; ExaEvt_GetDataOfEventByCod (Event); /***** Ensure parameters are correct *****/ diff --git a/swad_exam_result.c b/swad_exam_result.c index 6a030333..9fd8473c 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -171,10 +171,10 @@ void ExaRes_ShowMyExaResultsInExa (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Exam begin *****/ Exa_ShowOnlyOneExamBegin (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new event /***** List my events results in exam *****/ @@ -225,11 +225,11 @@ void ExaRes_ShowMyExaResultsInEvt (void) if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0) Lay_WrongEventExit (); Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; ExaEvt_GetDataOfEventByCod (&Event); /***** Exam begin *****/ Exa_ShowOnlyOneExamBegin (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new event /***** List my events results in event *****/ @@ -377,10 +377,10 @@ void ExaRes_ShowAllExaResultsInExa (void) Lay_WrongExamExit (); Exam.ExaCod = Exams.ExaCod; Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; /***** Exam begin *****/ Exa_ShowOnlyOneExamBegin (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new event /***** List events results in exam *****/ @@ -474,11 +474,11 @@ void ExaRes_ShowAllExaResultsInEvt (void) /***** Get exam data and event *****/ Exa_GetDataOfExamByCod (&Exam); + Exams.ExaCod = Exam.ExaCod; ExaEvt_GetDataOfEventByCod (&Event); /***** Exam begin *****/ Exa_ShowOnlyOneExamBegin (&Exams,&Exam, - false, // Do not list exam questions false); // Do not put form to start new event /***** List events results in event *****/ @@ -627,6 +627,7 @@ static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams) /* Get data of this exam */ Exam.ExaCod = Exams->Lst[NumExam].ExaCod; Exa_GetDataOfExamByCod (&Exam); + Exams->ExaCod = Exam.ExaCod; /* Write a row for this event */ HTM_TR_Begin (NULL); diff --git a/swad_game.c b/swad_game.c index a24c2cd5..6c194d4d 100644 --- a/swad_game.c +++ b/swad_game.c @@ -2266,7 +2266,7 @@ static void Gam_FreeListsSelectedQuestions (struct Gam_Games *Games) /********************** Request the removal of a question ********************/ /*****************************************************************************/ -void Gam_RequestRemoveQst (void) +void Gam_RequestRemoveQstFromGame (void) { extern const char *Txt_Do_you_really_want_to_remove_the_question_X; extern const char *Txt_Remove_question; @@ -2311,7 +2311,7 @@ void Gam_RequestRemoveQst (void) /****************************** Remove a question ****************************/ /*****************************************************************************/ -void Gam_RemoveQst (void) +void Gam_RemoveQstFromGame (void) { extern const char *Txt_Question_removed; struct Gam_Games Games; diff --git a/swad_game.h b/swad_game.h index ef4b07c7..3ed638b6 100644 --- a/swad_game.h +++ b/swad_game.h @@ -149,8 +149,8 @@ unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd); void Gam_AddQstsToGame (void); -void Gam_RequestRemoveQst (void); -void Gam_RemoveQst (void); +void Gam_RequestRemoveQstFromGame (void); +void Gam_RemoveQstFromGame (void); void Gam_MoveUpQst (void); void Gam_MoveDownQst (void); diff --git a/swad_test.c b/swad_test.c index 0374c691..9b2607cc 100644 --- a/swad_test.c +++ b/swad_test.c @@ -155,7 +155,7 @@ static void Tst_ShowFormRequestSelectTestsForSet (struct Exa_Exams *Exams, static void Tst_ShowFormRequestSelectTestsForGame (struct Gam_Games *Games, struct Tst_Test *Test); static bool Tst_CheckIfICanEditTests (void); -static void Tst_PutIconsTests (void *TestPtr); +static void Tst_PutIconsTests (void *Test); static void Tst_PutButtonToAddQuestion (void); static long Tst_GetParamTagCode (void); @@ -252,14 +252,12 @@ static long Tst_GetTagCodFromTagTxt (const char *TagTxt); static long Tst_CreateNewTag (long CrsCod,const char *TagTxt); static void Tst_EnableOrDisableTag (long TagCod,bool TagHidden); -static void Tst_PutParamsRemoveSelectedQsts (void *TestPtr); -static void Tst_PutIconToRemoveOneQst (void *QstCodPtr); -static void Tst_PutParamsRemoveOnlyThisQst (void *QstCodPtr); -static void Tst_PutParamsRemoveOneQstWhileEditing (void *TestPtr); +static void Tst_PutParamsRemoveSelectedQsts (void *Test); +static void Tst_PutIconToRemoveOneQst (void *QstCod); +static void Tst_PutParamsRemoveOnlyThisQst (void *QstCod); +static void Tst_PutParamsRemoveOneQstWhileEditing (void *Test); static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod); -static long Tst_GetQstCod (void); - static void Tst_InsertOrUpdateQstIntoDB (struct Tst_Question *Question); static void Tst_InsertTagsIntoDB (const struct Tst_Question *Question); static void Tst_InsertAnswersIntoDB (struct Tst_Question *Question); @@ -1446,65 +1444,62 @@ static bool Tst_CheckIfICanEditTests (void) /********************* Put contextual icons in tests *************************/ /*****************************************************************************/ -static void Tst_PutIconsTests (void *TestPtr) +static void Tst_PutIconsTests (void *Test) { extern const char *Txt_New_question; - if (TestPtr) + if (Tst_CheckIfICanEditTests ()) { - if (Tst_CheckIfICanEditTests ()) + switch (Gbl.Action.Act) { - switch (Gbl.Action.Act) - { - case ActLstTstQst: // List selected test questions for edition - case ActReqRemSevTstQst: // Request removal of selected questions - case ActReqRemOneTstQst: // Request removal of a question - case ActRemOneTstQst: // Remove a question - case ActChgShfTstQst: // Change shuffle of a question - /***** Put form to remove selected test questions *****/ - Ico_PutContextualIconToRemove (ActReqRemSevTstQst, - Tst_PutParamsRemoveSelectedQsts,TestPtr); - break; - default: - break; - } - - if (Gbl.Action.Act != ActEdiTstQst) - /***** Put form to edit existing test questions *****/ - Ico_PutContextualIconToEdit (ActEdiTstQst,NULL, - NULL,NULL); - - if (Gbl.Action.Act != ActEdiOneTstQst) - /***** Put form to create a new test question *****/ - Ico_PutContextualIconToAdd (ActEdiOneTstQst,NULL, - NULL,NULL, - Txt_New_question); - - /***** Put form to go to test configuration *****/ - Ico_PutContextualIconToConfigure (ActCfgTst, - NULL,NULL); - } - - /***** Put icon to view test exams *****/ - switch (Gbl.Usrs.Me.Role.Logged) - { - case Rol_STD: - Ico_PutContextualIconToShowResults (ActReqSeeMyTstRes,NULL, - NULL,NULL); - break; - case Rol_NET: - case Rol_TCH: - case Rol_SYS_ADM: - Ico_PutContextualIconToShowResults (ActReqSeeUsrTstRes,NULL, - NULL,NULL); + case ActLstTstQst: // List selected test questions for edition + case ActReqRemSevTstQst: // Request removal of selected questions + case ActReqRemOneTstQst: // Request removal of a question + case ActRemOneTstQst: // Remove a question + case ActChgShfTstQst: // Change shuffle of a question + /***** Put form to remove selected test questions *****/ + Ico_PutContextualIconToRemove (ActReqRemSevTstQst, + Tst_PutParamsRemoveSelectedQsts,Test); break; default: break; } - /***** Put icon to show a figure *****/ - Fig_PutIconToShowFigure (Fig_TESTS); + if (Gbl.Action.Act != ActEdiTstQst) + /***** Put form to edit existing test questions *****/ + Ico_PutContextualIconToEdit (ActEdiTstQst,NULL, + NULL,NULL); + + if (Gbl.Action.Act != ActEdiOneTstQst) + /***** Put form to create a new test question *****/ + Ico_PutContextualIconToAdd (ActEdiOneTstQst,NULL, + NULL,NULL, + Txt_New_question); + + /***** Put form to go to test configuration *****/ + Ico_PutContextualIconToConfigure (ActCfgTst, + NULL,NULL); } + + /***** Put icon to view test exams *****/ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + Ico_PutContextualIconToShowResults (ActReqSeeMyTstRes,NULL, + NULL,NULL); + break; + case Rol_NET: + case Rol_TCH: + case Rol_SYS_ADM: + Ico_PutContextualIconToShowResults (ActReqSeeUsrTstRes,NULL, + NULL,NULL); + break; + default: + break; + } + + /***** Put icon to show a figure *****/ + Fig_PutIconToShowFigure (Fig_TESTS); } /*****************************************************************************/ @@ -4057,7 +4052,7 @@ void Tst_ShowFormEditOneQst (void) Tst_QstConstructor (&Question); /***** Get question data *****/ - Question.QstCod = Tst_GetQstCod (); + Question.QstCod = Tst_GetParamQstCod (); if (Question.QstCod > 0) // Question already exists in the database PutFormToEditQuestion = Tst_GetQstDataFromDB (&Question); else // New question @@ -5061,7 +5056,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question) unsigned NumCorrectAns; /***** Get question code *****/ - Question->QstCod = Tst_GetQstCod (); + Question->QstCod = Tst_GetParamQstCod (); /***** Get answer type *****/ Question->Answer.Type = (Tst_AnswerType_t) @@ -5687,17 +5682,10 @@ void Tst_RequestRemoveSelectedQsts (void) /**************** Put parameters to remove selected questions ****************/ /*****************************************************************************/ -static void Tst_PutParamsRemoveSelectedQsts (void *TestPtr) +static void Tst_PutParamsRemoveSelectedQsts (void *Test) { - struct Tst_Test *Test; - - if (TestPtr) - { - Test = (struct Tst_Test *) TestPtr; - - Dat_WriteParamsIniEndDates (); - Tst_WriteParamEditQst (Test); - } + Dat_WriteParamsIniEndDates (); + Tst_WriteParamEditQst ((struct Tst_Test *) Test); } /*****************************************************************************/ @@ -5751,10 +5739,10 @@ void Tst_RemoveSelectedQsts (void) /********************* Put icon to remove one question ***********************/ /*****************************************************************************/ -static void Tst_PutIconToRemoveOneQst (void *QstCodPtr) +static void Tst_PutIconToRemoveOneQst (void *QstCod) { Ico_PutContextualIconToRemove (ActReqRemOneTstQst, - Tst_PutParamsRemoveOnlyThisQst,QstCodPtr); + Tst_PutParamsRemoveOnlyThisQst,QstCod); } /*****************************************************************************/ @@ -5773,7 +5761,7 @@ void Tst_RequestRemoveOneQst (void) /***** Get main parameters from form *****/ /* Get the question code */ - Test.Question.QstCod = Tst_GetQstCod (); + Test.Question.QstCod = Tst_GetParamQstCod (); if (Test.Question.QstCod <= 0) Lay_ShowErrorAndExit ("Wrong code of question."); @@ -5814,11 +5802,11 @@ void Tst_RequestRemoveOneQst (void) /***** Put parameters to remove question when editing only one question ******/ /*****************************************************************************/ -static void Tst_PutParamsRemoveOnlyThisQst (void *QstCodPtr) +static void Tst_PutParamsRemoveOnlyThisQst (void *QstCod) { - if (QstCodPtr) + if (QstCod) { - Tst_PutParamQstCod (QstCodPtr); + Tst_PutParamQstCod (QstCod); Par_PutHiddenParamChar ("OnlyThisQst",'Y'); } } @@ -5827,17 +5815,13 @@ static void Tst_PutParamsRemoveOnlyThisQst (void *QstCodPtr) /***** Put parameters to remove question when editing several questions ******/ /*****************************************************************************/ -static void Tst_PutParamsRemoveOneQstWhileEditing (void *TestPtr) +static void Tst_PutParamsRemoveOneQstWhileEditing (void *Test) { - struct Tst_Test *Test; - - if (TestPtr) + if (Test) { - Test = (struct Tst_Test *) TestPtr; - - Tst_PutParamQstCod (&Test->Question.QstCod); + Tst_PutParamQstCod (&(((struct Tst_Test *) Test)->Question.QstCod)); Dat_WriteParamsIniEndDates (); - Tst_WriteParamEditQst (Test); + Tst_WriteParamEditQst ((struct Tst_Test *) Test); } } @@ -5852,7 +5836,7 @@ void Tst_RemoveOneQst (void) bool EditingOnlyThisQst; /***** Get the question code *****/ - QstCod = Tst_GetQstCod (); + QstCod = Tst_GetParamQstCod (); if (QstCod <= 0) Lay_ShowErrorAndExit ("Wrong code of question."); @@ -5920,7 +5904,7 @@ void Tst_ChangeShuffleQst (void) Tst_TstConstructor (&Test); /***** Get the question code *****/ - Test.Question.QstCod = Tst_GetQstCod (); + Test.Question.QstCod = Tst_GetParamQstCod (); if (Test.Question.QstCod <= 0) Lay_ShowErrorAndExit ("Wrong code of question."); @@ -5958,7 +5942,7 @@ void Tst_ChangeShuffleQst (void) /************ Get the parameter with the code of a test question *************/ /*****************************************************************************/ -static long Tst_GetQstCod (void) +long Tst_GetParamQstCod (void) { /***** Get code of test question *****/ return Par_GetParToLong ("QstCod"); @@ -5976,7 +5960,7 @@ void Tst_PutParamQstCod (void *QstCod) // Should be a pointer to long } /*****************************************************************************/ -/******** Insert or update question, tags and anser in the database **********/ +/******** Insert or update question, tags and answer in the database *********/ /*****************************************************************************/ void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question) diff --git a/swad_test.h b/swad_test.h index fd78e4ce..1838dd38 100644 --- a/swad_test.h +++ b/swad_test.h @@ -223,6 +223,7 @@ void Tst_RemoveOneQst (void); void Tst_ChangeShuffleQst (void); +long Tst_GetParamQstCod (void); void Tst_PutParamQstCod (void *QstCod); void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question);