From 7d9f0572bf8e7ef70fc9cf9bcd7d09e8a8ef21e7 Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 28 Mar 2023 11:33:58 +0200 Subject: [PATCH] Version 22.83.4: Mar 28, 2023 Code refactoring in rubrics and exams. --- swad_changelog.h | 3 ++- swad_department_database.c | 11 ++++++----- swad_exam_database.c | 17 +++++++++-------- swad_exam_database.h | 6 +++--- swad_exam_set.c | 8 ++++---- swad_rubric_criteria.c | 8 ++++---- swad_rubric_database.c | 14 +++++++------- swad_rubric_database.h | 4 ++-- 8 files changed, 37 insertions(+), 34 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 6293fba3..061738ed 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen. */ -#define Log_PLATFORM_VERSION "SWAD 22.83.3 (2023-03-27)" +#define Log_PLATFORM_VERSION "SWAD 22.83.4 (2023-03-28)" #define CSS_FILE "swad22.78.15.css" #define JS_FILE "swad22.49.js" /* + Version 22.83.4: Mar 28, 2023 Code refactoring in rubrics and exams. (338221 lines) Version 22.83.3: Mar 27, 2023 Changes in rubric criteria. (338218 lines) Version 22.83.2: Mar 27, 2023 Changes in rubric criteria. (338189 lines) Version 22.83.1: Mar 27, 2023 Changes in rubric criteria. (338297 lines) diff --git a/swad_department_database.c b/swad_department_database.c index 8d29e48c..c5bbfbef 100644 --- a/swad_department_database.c +++ b/swad_department_database.c @@ -128,11 +128,12 @@ unsigned Dpt_DB_GetDepartmentDataByCod (MYSQL_RES **mysql_res,long DptCod) " AND crs_users.Role=%u" " GROUP BY dpt_departments.DptCod)" " UNION " - "(SELECT InsCod," // row[0] - "ShortName," // row[1] - "FullName," // row[2] - "WWW," // row[3] - "0" // row[4] + "(SELECT DptCod," // row[0] + "InsCod," // row[1] + "ShortName," // row[2] + "FullName," // row[3] + "WWW," // row[4] + "0" // row[5] " FROM dpt_departments" " WHERE DptCod=%ld" " AND DptCod NOT IN" diff --git a/swad_exam_database.c b/swad_exam_database.c index 030c6ad2..3ee79398 100644 --- a/swad_exam_database.c +++ b/swad_exam_database.c @@ -704,14 +704,15 @@ bool Exa_DB_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, /****************** Get set index given exam and set code ********************/ /*****************************************************************************/ -unsigned Exa_DB_GetSetIndFromSetCod (long ExaCod,long SetCod) +unsigned Exa_DB_GetSetIndFromSetCod (const struct ExaSet_Set *Set) { return DB_QuerySELECTUnsigned ("can not get set index", "SELECT SetInd" // row[0] " FROM exa_sets" " WHERE SetCod=%u" " AND ExaCod=%ld", // Extra check - SetCod,ExaCod); + Set->SetCod, + Set->ExaCod); } /*****************************************************************************/ @@ -795,14 +796,14 @@ unsigned Exa_DB_GetNextSetIndexInExam (long ExaCod,unsigned SetInd) /******************* Remove a set of questions from an exam ******************/ /*****************************************************************************/ -void Exa_DB_RemoveSetFromExam (long SetCod,long ExaCod) +void Exa_DB_RemoveSetFromExam (const struct ExaSet_Set *Set) { DB_QueryDELETE ("can not remove set", "DELETE FROM exa_sets" " WHERE SetCod=%ld" " AND ExaCod=%ld", // Extra check - SetCod, - ExaCod); + Set->SetCod, + Set->ExaCod); } /*****************************************************************************/ @@ -1060,7 +1061,7 @@ void Exa_DB_RemoveSetQuestion (long QstCod,long SetCod) /*************** Remove the questions in a set of questions ******************/ /*****************************************************************************/ -void Exa_DB_RemoveAllSetQuestionsFromSet (long SetCod,long ExaCod) +void Exa_DB_RemoveAllSetQuestionsFromSet (const struct ExaSet_Set *Set) { DB_QueryDELETE ("can not remove questions associated to set", "DELETE FROM exa_set_questions" @@ -1069,8 +1070,8 @@ void Exa_DB_RemoveAllSetQuestionsFromSet (long SetCod,long ExaCod) " WHERE exa_set_questions.SetCod=%ld" " AND exa_set_questions.SetCod=exa_sets.SetCod" " AND exa_sets.ExaCod=%ld", // Extra check - SetCod, - ExaCod); + Set->SetCod, + Set->ExaCod); } /*****************************************************************************/ diff --git a/swad_exam_database.h b/swad_exam_database.h index 05f9dd00..b20b88b3 100644 --- a/swad_exam_database.h +++ b/swad_exam_database.h @@ -67,12 +67,12 @@ unsigned Exa_DB_GetExamSets (MYSQL_RES **mysql_res,long ExaCod); unsigned Exa_DB_GetSetDataByCod (MYSQL_RES **mysql_res,long SetCod); bool Exa_DB_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, const char Title[ExaSet_MAX_BYTES_TITLE + 1]); -unsigned Exa_DB_GetSetIndFromSetCod (long ExaCod,long SetCod); +unsigned Exa_DB_GetSetIndFromSetCod (const struct ExaSet_Set *Set); long Exa_DB_GetSetCodFromSetInd (long ExaCod,unsigned SetInd); unsigned Exa_DB_GetMaxSetIndexInExam (long ExaCod); unsigned Exa_DB_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd); unsigned Exa_DB_GetNextSetIndexInExam (long ExaCod,unsigned SetInd); -void Exa_DB_RemoveSetFromExam (long SetCod,long ExaCod); +void Exa_DB_RemoveSetFromExam (const struct ExaSet_Set *Set); void Exa_DB_RemoveAllSetsFromExam (long ExaCod); void Exa_DB_RemoveAllSetsFromCrs (long CrsCod); @@ -91,7 +91,7 @@ unsigned Exa_DB_GetMediaFromStemOfQst (MYSQL_RES **mysql_res,long QstCod,long Se unsigned Exa_DB_GetAllMediaFomStemOfAllQstsFromExam (MYSQL_RES **mysql_res,long ExaCod); unsigned Exa_DB_GetAllMediaFomStemOfAllQstsFromCrs (MYSQL_RES **mysql_res,long CrsCod); void Exa_DB_RemoveSetQuestion (long QstCod,long SetCod); -void Exa_DB_RemoveAllSetQuestionsFromSet (long SetCod,long ExaCod); +void Exa_DB_RemoveAllSetQuestionsFromSet (const struct ExaSet_Set *Set); void Exa_DB_RemoveAllSetQuestionsFromExam (long ExaCod); void Exa_DB_RemoveAllSetQuestionsFromCrs (long CrsCod); diff --git a/swad_exam_set.c b/swad_exam_set.c index 4a60bf67..672ecf3a 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -1354,10 +1354,10 @@ void ExaSet_RemoveSet (void) /***** Remove the set from all tables *****/ /* Remove questions associated to set */ - Exa_DB_RemoveAllSetQuestionsFromSet (Set.SetCod,Set.ExaCod); + Exa_DB_RemoveAllSetQuestionsFromSet (&Set); /* Remove the set itself */ - Exa_DB_RemoveSetFromExam (Set.SetCod,Set.ExaCod); + Exa_DB_RemoveSetFromExam (&Set); /* Change indexes of sets greater than this */ Exa_DB_UpdateSetIndexesInExamGreaterThan (Set.ExaCod,Set.SetInd); @@ -1395,7 +1395,7 @@ void ExaSet_MoveUpSet (void) Err_NoPermissionExit (); /***** Get set index *****/ - SetIndBottom = Exa_DB_GetSetIndFromSetCod (Exams.Exam.ExaCod,Set.SetCod); + SetIndBottom = Exa_DB_GetSetIndFromSetCod (&Set); /***** Move up set *****/ if (SetIndBottom > 1) @@ -1442,7 +1442,7 @@ void ExaSet_MoveDownSet (void) Err_NoPermissionExit (); /***** Get set index *****/ - SetIndTop = Exa_DB_GetSetIndFromSetCod (Exams.Exam.ExaCod,Set.SetCod); + SetIndTop = Exa_DB_GetSetIndFromSetCod (&Set); /***** Get maximum set index *****/ MaxSetInd = Exa_DB_GetMaxSetIndexInExam (Exams.Exam.ExaCod); diff --git a/swad_rubric_criteria.c b/swad_rubric_criteria.c index e0dbba5f..e26d0ca6 100644 --- a/swad_rubric_criteria.c +++ b/swad_rubric_criteria.c @@ -839,8 +839,8 @@ void RubCri_ResetCriterion (struct RubCri_Criterion *Criterion) // Default values minimum/maximum criterion values static double RubCri_DefaultValues[RubCri_NUM_VALUES] = { - [RubCri_MIN] = 0.0, - [RubCri_MAX] = 0.1, + [RubCri_MIN] = 0.0, + [RubCri_MAX] = 10.0, }; RubCri_ValueRange_t ValueRange; @@ -919,10 +919,10 @@ void RubCri_RemoveCriterion (void) // Exa_DB_RemoveAllSetQuestionsFromSet (Criterion.CriCod,Criterion.RubCod); /* Remove the criterion itself */ - Rub_DB_RemoveCriterionFromRubric (Criterion.CriCod,Criterion.RubCod); + Rub_DB_RemoveCriterionFromRubric (&Criterion); /* Change indexes of criteria greater than this */ - Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (Criterion.RubCod,Criterion.CriInd); + Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (&Criterion); /***** Write message *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Criterion_removed); diff --git a/swad_rubric_database.c b/swad_rubric_database.c index d2a0ecc8..ae950cf2 100644 --- a/swad_rubric_database.c +++ b/swad_rubric_database.c @@ -451,15 +451,15 @@ void Rub_DB_UpdateCriterionWeight (const struct RubCri_Criterion *Criterion) /************ Update indexes of criteria greater than a given one ************/ /*****************************************************************************/ -void Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (long RubCod,unsigned CriInd) +void Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (const struct RubCri_Criterion *Criterion) { DB_QueryUPDATE ("can not update indexes of criteria", "UPDATE rub_criteria" " SET CriInd=CriInd-1" " WHERE RubCod=%ld" " AND CriInd>%u", - RubCod, - CriInd); + Criterion->RubCod, + Criterion->CriInd); } /*****************************************************************************/ @@ -773,14 +773,14 @@ double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Scope) /*********************** Remove criterion from a rubric **********************/ /*****************************************************************************/ -void Rub_DB_RemoveCriterionFromRubric (long CriCod,long RubCod) +void Rub_DB_RemoveCriterionFromRubric (const struct RubCri_Criterion *Criterion) { DB_QueryDELETE ("can not remove rubric criterion", "DELETE FROM rub_criteria" " WHERE CriCod=%ld" - " AND RubCod=%ld", - CriCod, - RubCod); + " AND RubCod=%ld", // Extra check + Criterion->CriCod, + Criterion->RubCod); } /*****************************************************************************/ diff --git a/swad_rubric_database.h b/swad_rubric_database.h index b7cad3d9..f2c78255 100644 --- a/swad_rubric_database.h +++ b/swad_rubric_database.h @@ -60,7 +60,7 @@ void Rub_DB_UpdateCriterionLink (const struct RubCri_Criterion *Criterion); void Rub_DB_UpdateCriterionValue (const struct RubCri_Criterion *Criterion, RubCri_ValueRange_t ValueRange); void Rub_DB_UpdateCriterionWeight (const struct RubCri_Criterion *Criterion); -void Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (long RubCod,unsigned CriInd); +void Rub_DB_UpdateCriteriaIndexesInRubricGreaterThan (const struct RubCri_Criterion *Criterion); void Rub_DB_UpdateCriterionIndex (long CriInd,long CriCod,long RubCod); void Rub_DB_LockTable (void); @@ -77,7 +77,7 @@ bool Rub_DB_CheckIfSimilarCriterionExists (const struct RubCri_Criterion *Criter double Rub_DB_GetNumCriteriaPerRubric (HieLvl_Level_t Scope); -void Rub_DB_RemoveCriterionFromRubric (long CriCod,long RubCod); +void Rub_DB_RemoveCriterionFromRubric (const struct RubCri_Criterion *Criterion); void Rub_DB_RemoveRubricCriteria (long RubCod); void Rub_DB_RemoveCrsRubricCriteria (long CrsCod);