Version 22.83.4: Mar 28, 2023 Code refactoring in rubrics and exams.

This commit is contained in:
acanas 2023-03-28 11:33:58 +02:00
parent 0350f81df0
commit 7d9f0572bf
8 changed files with 37 additions and 34 deletions

View File

@ -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)

View File

@ -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"

View File

@ -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);
}
/*****************************************************************************/

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);
}
/*****************************************************************************/

View File

@ -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);