From f0a74dff924e88a3cac700cb5cb41f00789bbc1c Mon Sep 17 00:00:00 2001 From: acanas Date: Fri, 15 May 2020 20:30:46 +0200 Subject: [PATCH] Version19.230.2 --- swad_changelog.h | 4 ++- swad_exam_print.c | 10 +++--- swad_exam_set.c | 81 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 71 insertions(+), 24 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 76f718165..521b699c3 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -548,10 +548,12 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.230.1 (2020-05-15)" +#define Log_PLATFORM_VERSION "SWAD 19.230.2 (2020-05-15)" #define CSS_FILE "swad19.230.1.css" #define JS_FILE "swad19.223.js" /* + Version 19.230.2: May 15, 2020 Changes in layout of exam prints. + Changes in edition of sets of questions. (301026 lines) Version 19.230.1: May 15, 2020 Media in exams are shown occupying 50% instead of 100%. (300985 lines) Version 19.230: May 15, 2020 Code refactoring and bug fixing in exams. (300984 lines) Version 19.229.2: May 14, 2020 Some messages translated in exam results. (301070 lines) diff --git a/swad_exam_print.c b/swad_exam_print.c index 3513b9ea3..b2c1ec30a 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -640,8 +640,6 @@ static void ExaPrn_ShowTableWithQstsToFill (struct ExaPrn_Print *Print) NumQst < Print->NumQsts; NumQst++) { - Gbl.RowEvenOdd = NumQst % 2; - /* Create test question */ Tst_QstConstructor (&Question); Question.QstCod = Print->PrintedQuestions[NumQst].QstCod; @@ -685,23 +683,25 @@ static void ExaPrn_WriteQstAndAnsToFill (struct ExaPrn_Print *Print, /***** Title for this set *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"2\""); + HTM_TD_Begin ("colspan=\"2\" class=\"COLOR%u\"",Gbl.RowEvenOdd); ExaSet_WriteSetTitle (&CurrentSet); HTM_TD_End (); HTM_TR_End (); + + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } /***** Begin row *****/ HTM_TR_Begin (NULL); /***** Number of question and answer type *****/ - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TD_Begin ("class=\"RT\""); Tst_WriteNumQst (NumQst + 1); Tst_WriteAnswerType (Question->Answer.Type); HTM_TD_End (); /***** Stem, media and answers *****/ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TD_Begin ("class=\"LT\""); /* Stem */ Tst_WriteQstStem (Question->Stem,"TEST_EXA",true); diff --git a/swad_exam_set.c b/swad_exam_set.c index 71347f50d..1ab69a91c 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -353,10 +353,6 @@ void ExaSet_ReceiveFormSet (void) struct ExaSet_Set Set; bool ItsANewSet; - /***** Check if I can edit exams *****/ - if (!Exa_CheckIfICanEditExams ()) - Lay_NoPermissionExit (); - /***** Reset exams context *****/ Exa_ResetExams (&Exams); Exa_ResetExam (&Exam); @@ -374,6 +370,10 @@ void ExaSet_ReceiveFormSet (void) Exa_GetDataOfExamByCod (&Exam); Exams.ExaCod = Exam.ExaCod; + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** If I can edit exams ==> receive set from form *****/ ExaSet_ReceiveSetFieldsFromForm (&Set); if (ExaSet_CheckSetTitleReceivedFromForm (&Set,Set.Title)) @@ -458,6 +458,10 @@ void ExaSet_ChangeSetTitle (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Receive new title from form *****/ Par_GetParToText ("Title",NewTitle,ExaSet_MAX_BYTES_TITLE); @@ -499,6 +503,10 @@ void ExaSet_ChangeNumQstsToExam (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Get number of questions in set to appear in exam print *****/ NumQstsToPrint = (unsigned) Par_GetParToUnsignedLong ("NumQstsToPrint", 0, @@ -964,7 +972,8 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams, DB_FreeMySQLResult (&mysql_res); /***** Put forms to create/edit a set *****/ - ExaSet_PutFormNewSet (Exams,Exam,Set,MaxSetInd); + if (ICanEditSets) + ExaSet_PutFormNewSet (Exams,Exam,Set,MaxSetInd); /***** End box *****/ Box_BoxEnd (); @@ -1142,29 +1151,49 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, /***** Title *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); HTM_ARTICLE_Begin (Anchor); - Frm_StartFormAnchor (ActChgTitExaSet,Anchor); - ExaSet_PutParamsOneSet (Exams); - HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set.Title, - HTM_SUBMIT_ON_CHANGE, - "id=\"Title\" required=\"required\"" - " class=\"TITLE_DESCRIPTION_WIDTH\""); - Frm_EndForm (); + if (ICanEditSets) + { + Frm_StartFormAnchor (ActChgTitExaSet,Anchor); + ExaSet_PutParamsOneSet (Exams); + HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set.Title, + HTM_SUBMIT_ON_CHANGE, + "id=\"Title\" required=\"required\"" + " class=\"TITLE_DESCRIPTION_WIDTH\""); + Frm_EndForm (); + } + else + { + HTM_SPAN_Begin ("class=\"EXA_SET_TITLE\""); + HTM_Txt (Set.Title); + HTM_SPAN_End (); + } HTM_ARTICLE_End (); HTM_TD_End (); /***** Current number of questions in set *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); HTM_Unsigned (ExaSet_GetNumQstsInSet (Set.SetCod)); + HTM_SPAN_End (); HTM_TD_End (); /***** Number of questions to appear in exam print *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Frm_StartFormAnchor (ActChgNumQstExaSet,Anchor); - ExaSet_PutParamsOneSet (Exams); - HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set.NumQstsToPrint, - HTM_SUBMIT_ON_CHANGE,false, - "class=\"INPUT_LONG\" required=\"required\""); - Frm_EndForm (); + if (ICanEditSets) + { + Frm_StartFormAnchor (ActChgNumQstExaSet,Anchor); + ExaSet_PutParamsOneSet (Exams); + HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set.NumQstsToPrint, + HTM_SUBMIT_ON_CHANGE,false, + "class=\"INPUT_LONG\" required=\"required\""); + Frm_EndForm (); + } + else + { + HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); + HTM_Unsigned (Set.NumQstsToPrint); + HTM_SPAN_End (); + } HTM_TD_End (); /***** End first row *****/ @@ -1740,6 +1769,10 @@ void ExaSet_RequestRemoveSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Show question and button to remove question *****/ Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL, ExaSet_PutParamsOneSet,&Exams, @@ -1771,6 +1804,10 @@ void ExaSet_RemoveSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Remove the set from all the tables *****/ /* Remove questions associated to set */ DB_QueryDELETE ("can not remove questions associated to set", @@ -1825,6 +1862,10 @@ void ExaSet_MoveUpSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Get set index *****/ SetIndBottom = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod); @@ -1869,6 +1910,10 @@ void ExaSet_MoveDownSet (void) /***** Get and check parameters *****/ ExaSet_GetAndCheckParameters (&Exams,&Exam,&Set); + /***** Check if exam is editable *****/ + if (!Exa_CheckIfEditable (&Exam)) + Lay_NoPermissionExit (); + /***** Get set index *****/ SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);