diff --git a/swad_changelog.h b/swad_changelog.h
index 8ac960780..c4e03bb79 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.196.1 (2020-04-25)"
+#define Log_PLATFORM_VERSION "SWAD 19.197 (2020-04-26)"
#define CSS_FILE "swad19.193.1.css"
#define JS_FILE "swad19.193.1.js"
/*
+ Version 19.197: Apr 26, 2020 Ask user to remove set of questions. (298954 lines)
Version 19.196.1: Apr 25, 2020 Changes in edition of exams. (298857 lines)
Version 19.196: Apr 25, 2020 Changes in edition of sets of questions. (298866 lines)
Version 19.195.1: Apr 25, 2020 Translation of messages related to sets of questions. (298840 lines)
diff --git a/swad_exam.c b/swad_exam.c
index d2f025633..05a984a62 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_PutParamsOneSet (void *Exams);
+static void ExaSet_PutParamsOneSet (void *Exams);
static void Exa_PutParamsOneQst (void *Exams);
static void Exa_PutHiddenParamOrder (Exa_Order_t SelectedOrder);
static Exa_Order_t Exa_GetParamOrder (void);
@@ -168,6 +168,8 @@ static void ExaSet_UpdateSet (struct ExaSet_Set *Set);
static void Exa_CreateExam (struct Exa_Exam *Exam,const char *Txt);
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_GetMaxSetIndexInExam (long ExaCod);
@@ -484,7 +486,7 @@ void Exa_SeeOneExam (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam *****/
+ /***** Get exam data *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Show exam *****/
@@ -773,15 +775,15 @@ static void Exa_PutFormsToRemEditOneExam (struct Exa_Exams *Exams,
}
/*****************************************************************************/
-/************** Put parameter to move/remove one set of questions ****************/
+/************ Put parameter to move/remove one set of questions **************/
/*****************************************************************************/
-static void Exa_PutParamsOneSet (void *Exams)
+static void ExaSet_PutParamsOneSet (void *Exams)
{
if (Exams)
{
Exa_PutParams (Exams);
- Exa_PutParamSetInd (((struct Exa_Exams *) Exams)->SetInd);
+ ExaSet_PutParamSetCod (((struct Exa_Exams *) Exams)->SetCod);
}
}
@@ -1043,10 +1045,14 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRows;
+ char StrSetInd[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
- /***** Get data of set from database *****/
+ /***** Get data of set of questions from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get set data",
- "SELECT SetInd" // row[0]
+ "SELECT SetCod," // row[0]
+ "SetInd," // row[1]
+ "NumQstsToExam," // row[2]
+ "Title" // row[3]
" FROM exa_sets"
" WHERE SetCod=%ld"
" AND ExaCod=%ld", // Extra check
@@ -1055,9 +1061,27 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set)
{
/* Get row */
row = mysql_fetch_row (mysql_res);
+ /*
+ row[0] SetCod
+ row[1] SetInd
+ row[2] NumQstsToExam
+ row[3] Title
+ */
+ /* Get set code (row[0]) */
+ Set->SetCod = Str_ConvertStrCodToLongCod (row[0]);
- /* Get index of the set (row[0]) */
- Set->SetInd = Str_ConvertStrToUnsigned (row[0]);
+ /* Get set index (row[1]) */
+ Set->SetInd = Str_ConvertStrToUnsigned (row[1]);
+ snprintf (StrSetInd,sizeof (Set->SetInd),
+ "%u",
+ Set->SetInd);
+
+ /* Get set index (row[2]) */
+ Set->NumQstsToExam = Str_ConvertStrToUnsigned (row[2]);
+
+ /* Get the title of the set (row[3]) */
+ Str_Copy (Set->Title,row[3],
+ ExaSet_MAX_BYTES_TITLE);
}
else
/* Initialize to empty set */
@@ -1077,7 +1101,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
MYSQL_ROW row;
unsigned long NumRows;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get exam data",
"SELECT exa_exams.ExaCod," // row[0]
"exa_exams.CrsCod," // row[1]
@@ -1633,7 +1657,7 @@ void ExaSet_RecFormSet (void)
ExaSet_UpdateSet (&Set); // Update set data in database
}
- /***** Put form to create/edit an exam and show sets *****/
+ /***** Show current exam and its sets *****/
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
false); // It's not a new exam
}
@@ -1828,7 +1852,7 @@ void Exa_RecFormExam (void)
Exa_UpdateExam (&Exam,Txt); // Update exam data in database
}
- /***** Put form to create/edit an exam and show sets *****/
+ /***** Show current exam and its sets *****/
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
ItsANewExam); // It's not a new exam
}
@@ -2054,12 +2078,6 @@ void ExaSet_RequestCreatOrEditSet (void)
/***** Put form to edit the exam created or updated *****/
Exa_PutFormEditionExam (&Exams,&Exam,Txt,
false); // No new exam
-
- /***** Show sets of the exam ready to be edited *****/
- ExaSet_ListExamSets (&Exams,&Exam,&Set);
-
- /* Show questions of the exam ready to be edited */
- // Exa_ListExamQuestions (&Exams,&Exam);
}
/*****************************************************************************/
@@ -2083,7 +2101,7 @@ void Exa_RequestNewQuestion (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -2123,7 +2141,7 @@ void Exa_ListQuestionsToSelect (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -2141,9 +2159,9 @@ void Exa_ListQuestionsToSelect (void)
/**************** Write parameter with index of set of questions *****************/
/*****************************************************************************/
-void Exa_PutParamSetInd (unsigned SetInd)
+static void ExaSet_PutParamSetCod (long SetCod)
{
- Par_PutHiddenParamUnsigned (NULL,"SetInd",SetInd);
+ Par_PutHiddenParamUnsigned (NULL,"SetCod",SetCod);
}
/*****************************************************************************/
@@ -2359,13 +2377,13 @@ static void ExaSet_ListExamSets (struct Exa_Exams *Exams,
/***** Get maximum set index *****/
MaxSetInd = ExaSet_GetMaxSetIndexInExam (Exam->ExaCod);
- /***** Get data of set of questionss from database *****/
+ /***** Get data of set of questions from database *****/
NumSets = (unsigned)
- DB_QuerySELECT (&mysql_res,"can not get exam set of questionss",
- "SELECT exa_sets.SetCod," // row[0]
- "exa_sets.SetInd," // row[1]
- "exa_sets.NumQstsToExam," // row[2]
- "exa_sets.Title" // row[3]
+ DB_QuerySELECT (&mysql_res,"can not get sets of questions",
+ "SELECT SetCod," // row[0]
+ "SetInd," // row[1]
+ "NumQstsToExam," // row[2]
+ "Title" // row[3]
" FROM exa_sets"
" WHERE ExaCod=%ld"
" ORDER BY SetInd",
@@ -2383,7 +2401,7 @@ static void ExaSet_ListExamSets (struct Exa_Exams *Exams,
Exam->ExaCod,MaxSetInd,
NumSets,mysql_res,
ICanEditSets);
- else // This exam has no sets
+ else // This exam has no sets
Ale_ShowAlert (Ale_INFO,Txt_This_exam_has_no_sets_of_questions);
/***** Free structure that stores the query result *****/
@@ -2519,8 +2537,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
if (ICanEditSets)
{
Frm_StartForm (ActReqRemExaSet);
- Exa_PutParams (Exams);
- Exa_PutParamQstInd (Set.SetInd);
+ ExaSet_PutParamsOneSet (Exams);
Ico_PutIconRemove ();
Frm_EndForm ();
}
@@ -2531,7 +2548,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
if (ICanEditSets && Set.SetInd > 1)
{
Lay_PutContextualLinkOnlyIcon (ActUp_ExaSet,NULL,
- Exa_PutParamsOneSet,Exams,
+ ExaSet_PutParamsOneSet,Exams,
"arrow-up.svg",
Str_BuildStringStr (Txt_Move_up_X,
StrSetInd));
@@ -2544,7 +2561,7 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams,
if (ICanEditSets && Set.SetInd < MaxSetInd)
{
Lay_PutContextualLinkOnlyIcon (ActDwnExaSet,NULL,
- Exa_PutParamsOneSet,Exams,
+ ExaSet_PutParamsOneSet,Exams,
"arrow-down.svg",
Str_BuildStringStr (Txt_Move_down_X,
StrSetInd));
@@ -2881,7 +2898,7 @@ void Exa_AddQuestionsToExam (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -2990,6 +3007,46 @@ static unsigned Exa_CountNumQuestionsInList (const struct Exa_Exams *Exams)
void ExaSet_RequestRemoveSet (void)
{
+ extern const char *Txt_Do_you_really_want_to_remove_the_set_of_questions_X;
+ extern const char *Txt_Remove_set_of_questions;
+ struct Exa_Exams Exams;
+ struct Exa_Exam Exam;
+ struct ExaSet_Set Set;
+
+ /***** Reset exams context *****/
+ Exa_ResetExams (&Exams);
+
+ /***** Reset exam and set *****/
+ Exa_ResetExam (&Exam);
+ ExaSet_ResetSet (&Set);
+
+ /***** Get parameters *****/
+ Exa_GetParams (&Exams);
+ if (Exams.ExaCod <= 0)
+ Lay_WrongExamExit ();
+ Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
+ Set.SetCod = ExaSet_GetParamSetCod ();
+ if (Set.SetCod <= 0)
+ Lay_WrongSetExit ();
+
+ /***** Get exam data from database *****/
+ Exa_GetDataOfExamByCod (&Exam);
+ if (!Exa_CheckIfEditable (&Exam))
+ Lay_NoPermissionExit ();
+
+ /***** Get set data from database *****/
+ ExaSet_GetDataOfSetByCod (&Set);
+
+ /***** Show question and button to remove question *****/
+ Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL,
+ ExaSet_PutParamsOneSet,&Exams,
+ Btn_REMOVE_BUTTON,Txt_Remove_set_of_questions,
+ Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_set_of_questions_X,
+ Set.Title);
+
+ /***** Show current exam and its sets *****/
+ Exa_PutFormsOneExam (&Exams,&Exam,&Set,
+ false); // It's not a new exam
}
/*****************************************************************************/
@@ -3000,7 +3057,6 @@ void ExaSet_RemoveSet (void)
{
}
-
/*****************************************************************************/
/************ Move up position of a set of questions in an exam **************/
/*****************************************************************************/
@@ -3041,7 +3097,7 @@ void Exa_RequestRemoveQst (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -3091,7 +3147,7 @@ void Exa_RemoveQst (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -3162,7 +3218,7 @@ void Exa_MoveUpQst (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -3224,7 +3280,7 @@ void Exa_MoveDownQst (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Check if exam has events *****/
@@ -3368,7 +3424,7 @@ void Exa_RequestNewEvent (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Show exam *****/
diff --git a/swad_exam.h b/swad_exam.h
index 463d168f9..ecd1e9a1b 100644
--- a/swad_exam.h
+++ b/swad_exam.h
@@ -162,7 +162,6 @@ void ExaSet_RequestCreatOrEditSet (void);
void Exa_RequestNewQuestion (void);
void Exa_ListQuestionsToSelect (void);
-void Exa_PutParamSetInd (unsigned SetInd);
void Exa_PutParamQstInd (unsigned QstInd);
unsigned Exa_GetParamQstInd (void);
long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd);
diff --git a/swad_exam_event.c b/swad_exam_event.c
index 500f17486..2bf3125dc 100644
--- a/swad_exam_event.c
+++ b/swad_exam_event.c
@@ -381,7 +381,7 @@ void ExaEvt_GetDataOfEventByCod (struct ExaEvt_Event *Event)
unsigned long NumRows;
Dat_StartEndTime_t StartEndTime;
- /***** Get data of exam event from database *****/
+ /***** Get exam data event from database *****/
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get events",
"SELECT EvtCod," // row[ 0]
"ExaCod," // row[ 1]
@@ -1300,7 +1300,7 @@ void ExaEvt_GetAndCheckParameters (struct Exa_Exams *Exams,
if ((Event->EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
Lay_WrongEventExit ();
- /***** Get data of exam and event from database *****/
+ /***** Get exam data and event from database *****/
Exa_GetDataOfExamByCod (Exam);
ExaEvt_GetDataOfEventByCod (Event);
diff --git a/swad_exam_result.c b/swad_exam_result.c
index 33fd65501..6a0303338 100644
--- a/swad_exam_result.c
+++ b/swad_exam_result.c
@@ -169,7 +169,7 @@ void ExaRes_ShowMyExaResultsInExa (void)
Lay_WrongExamExit ();
Exam.ExaCod = Exams.ExaCod;
- /***** Get data of exam from database *****/
+ /***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exam);
/***** Exam begin *****/
@@ -472,7 +472,7 @@ void ExaRes_ShowAllExaResultsInEvt (void)
if ((Event.EvtCod = ExaEvt_GetParamEvtCod ()) <= 0)
Lay_WrongEventExit ();
- /***** Get data of exam and event *****/
+ /***** Get exam data and event *****/
Exa_GetDataOfExamByCod (&Exam);
ExaEvt_GetDataOfEventByCod (&Event);
diff --git a/swad_layout.c b/swad_layout.c
index 8c31f2f42..3927b329e 100644
--- a/swad_layout.c
+++ b/swad_layout.c
@@ -1493,6 +1493,15 @@ void Lay_WrongExamExit (void)
Lay_ShowErrorAndExit ("Wrong exam.");
}
+/*****************************************************************************/
+/********* Write error message and exit when wrong set of questions **********/
+/*****************************************************************************/
+
+void Lay_WrongSetExit (void)
+ {
+ Lay_ShowErrorAndExit ("Wrong set of questions.");
+ }
+
/*****************************************************************************/
/************** Write error message and exit when wrong event ****************/
/*****************************************************************************/
diff --git a/swad_layout.h b/swad_layout.h
index 05b17b03b..1afc9a085 100644
--- a/swad_layout.h
+++ b/swad_layout.h
@@ -74,6 +74,7 @@ void Lay_WrongScopeExit (void);
void Lay_WrongOrderExit (void);
void Lay_WrongTypeOfViewExit (void);
void Lay_WrongExamExit (void);
+void Lay_WrongSetExit (void);
void Lay_WrongEventExit (void);
void Lay_NoPermissionExit (void);
void Lay_ShowErrorAndExit (const char *Txt);
diff --git a/swad_text.c b/swad_text.c
index 9842279e1..790e28ea6 100644
--- a/swad_text.c
+++ b/swad_text.c
@@ -9438,6 +9438,27 @@ const char *Txt_Do_you_really_want_to_remove_the_selected_questions =
"Você realmente deseja remover as perguntas selecionadas?";
#endif
+const char *Txt_Do_you_really_want_to_remove_the_set_of_questions_X = // Warning: it is very important to include %s in the following sentences
+#if L==1 // ca
+ "¿De veres voleu eliminar el conjunt de preguntes %s?";
+#elif L==2 // de
+ "Wollen Sie die Satz von Fragen %s wirklich entfernen?";
+#elif L==3 // en
+ "Do you really want to remove the set of questions %s?";
+#elif L==4 // es
+ "¿Realmente desea eliminar el conjunto de preguntas %s?";
+#elif L==5 // fr
+ "Voulez-vous vraiment supprimer l'ensemble de questions %s?";
+#elif L==6 // gn
+ "¿Realmente desea eliminar el conjunto de preguntas %s?"; // Okoteve traducción
+#elif L==7 // it
+ "Vuoi realmente rimuovere il set di domande %s?";
+#elif L==8 // pl
+ "Czy na pewno chcesz usunac zestaw pytań %s?";
+#elif L==9 // pt
+ "Você realmente deseja remover o conjunto de perguntas %s?";
+#endif
+
const char *Txt_Do_you_really_want_to_remove_the_survey_X = // Warning: it is very important to include %s in the following sentences
#if L==1 // ca
"Realment voleu eliminar l'enquesta %s?";
@@ -34099,6 +34120,27 @@ const char *Txt_Remove_record_field =
"Remover campo de cartão";
#endif
+const char *Txt_Remove_set_of_questions =
+#if L==1 // ca
+ "Eliminar conjunt de preguntes";
+#elif L==2 // de
+ "Entfernen Satz von Fragen";
+#elif L==3 // en
+ "Remove set of questions";
+#elif L==4 // es
+ "Eliminar conjunto de preguntas";
+#elif L==5 // fr
+ "Supprimer ensemble de questions";
+#elif L==6 // gn
+ "Eliminar conjunto de preguntas"; // Okoteve traducción
+#elif L==7 // it
+ "Rimuovere set di domande";
+#elif L==8 // pl
+ "Usuń zestaw pytań";
+#elif L==9 // pt
+ "Remover conjunto de perguntas";
+#endif
+
const char *Txt_Remove_survey =
#if L==1 // ca
"Eliminar enquesta";