mirror of https://github.com/acanas/swad-core.git
Version 22.115: May 19, 2023 Generalization of rubric scores.
This commit is contained in:
parent
0bbd73d188
commit
bc17803c4a
19
sql/swad.sql
19
sql/swad.sql
|
@ -1245,14 +1245,6 @@ CREATE TABLE IF NOT EXISTS prj_rubrics (
|
||||||
RubCod INT NOT NULL,
|
RubCod INT NOT NULL,
|
||||||
UNIQUE INDEX(CrsCod,Type,RubCod));
|
UNIQUE INDEX(CrsCod,Type,RubCod));
|
||||||
--
|
--
|
||||||
-- Table prj_scores: stores the rubric criteria scores for each project
|
|
||||||
--
|
|
||||||
CREATE TABLE IF NOT EXISTS prj_scores (
|
|
||||||
PrjCod INT NOT NULL,
|
|
||||||
CriCod INT NOT NULL,
|
|
||||||
Score DOUBLE PRECISION NOT NULL DEFAULT 0,
|
|
||||||
UNIQUE INDEX(PrjCod,CriCod));
|
|
||||||
--
|
|
||||||
-- Table prj_users: stores the users inside projects
|
-- Table prj_users: stores the users inside projects
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS prj_users (
|
CREATE TABLE IF NOT EXISTS prj_users (
|
||||||
|
@ -1332,6 +1324,17 @@ CREATE TABLE IF NOT EXISTS rub_rubrics (
|
||||||
UNIQUE INDEX(RubCod),
|
UNIQUE INDEX(RubCod),
|
||||||
INDEX(CrsCod));
|
INDEX(CrsCod));
|
||||||
--
|
--
|
||||||
|
-- Table rub_scores: stores the rubric criteria scores for each project
|
||||||
|
--
|
||||||
|
CREATE TABLE IF NOT EXISTS rub_scores (
|
||||||
|
Type ENUM('non','asg','prj','cfe','exa','gam','rub','doc','mrk','att','for','svy') NOT NULL DEFAULT 'non',
|
||||||
|
Cod INT NOT NULL,
|
||||||
|
UsrCod INT NOT NULL DEFAULT -1,
|
||||||
|
CriCod INT NOT NULL,
|
||||||
|
EvlCod INT NOT NULL DEFAULT -1,
|
||||||
|
Score DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||||
|
UNIQUE INDEX(Type,Cod,UsrCod,CriCod));
|
||||||
|
--
|
||||||
-- Table ses_params: stores some hidden parameters passed from a page to another using database instead of forms
|
-- Table ses_params: stores some hidden parameters passed from a page to another using database instead of forms
|
||||||
--
|
--
|
||||||
CREATE TABLE IF NOT EXISTS ses_params (
|
CREATE TABLE IF NOT EXISTS ses_params (
|
||||||
|
|
|
@ -629,10 +629,19 @@ 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.
|
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.114 (2023-05-19)"
|
#define Log_PLATFORM_VERSION "SWAD 22.115 (2023-05-19)"
|
||||||
#define CSS_FILE "swad22.107.36.css"
|
#define CSS_FILE "swad22.107.36.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.115: May 19, 2023 Generalization of rubric scores. (337010 lines)
|
||||||
|
1 change necessary in database:
|
||||||
|
CREATE TABLE IF NOT EXISTS rub_scores (Type ENUM('non','asg','prj','cfe','exa','gam','rub','doc','mrk','att','for','svy') NOT NULL DEFAULT 'non',Cod INT NOT NULL,UsrCod INT NOT NULL DEFAULT -1,CriCod INT NOT NULL,EvlCod INT NOT NULL DEFAULT -1,Score DOUBLE PRECISION NOT NULL DEFAULT 0,UNIQUE INDEX(Type,Cod,UsrCod,CriCod));
|
||||||
|
If you want to use MyISAM:
|
||||||
|
ALTER TABLE rub_scores ENGINE=MyISAM;
|
||||||
|
2 changes necessary in database:
|
||||||
|
INSERT INTO rub_scores SELECT 'prj',PrjCod,-1,CriCod,-1,Score FROM prj_scores ORDER BY PrjCod,CriCod;
|
||||||
|
DROP TABLE prj_scores;
|
||||||
|
|
||||||
Version 22.114: May 19, 2023 Check if a rubric is recursive. (336984 lines)
|
Version 22.114: May 19, 2023 Check if a rubric is recursive. (336984 lines)
|
||||||
Version 22.113: May 19, 2023 Check if a rubric is recursive. (336936 lines)
|
Version 22.113: May 19, 2023 Check if a rubric is recursive. (336936 lines)
|
||||||
Version 22.112: May 18, 2023 Code refactoring in options of selectors. (336794 lines)
|
Version 22.112: May 18, 2023 Code refactoring in options of selectors. (336794 lines)
|
||||||
|
|
|
@ -2659,24 +2659,6 @@ mysql> DESCRIBE prj_rubrics;
|
||||||
"RubCod INT NOT NULL,"
|
"RubCod INT NOT NULL,"
|
||||||
"UNIQUE INDEX(CrsCod,Type,RubCod))");
|
"UNIQUE INDEX(CrsCod,Type,RubCod))");
|
||||||
|
|
||||||
/***** Table prj_scores *****/
|
|
||||||
/*
|
|
||||||
mysql> DESCRIBE prj_scores;
|
|
||||||
+--------+--------+------+-----+---------+-------+
|
|
||||||
| Field | Type | Null | Key | Default | Extra |
|
|
||||||
+--------+--------+------+-----+---------+-------+
|
|
||||||
| PrjCod | int | NO | PRI | NULL | |
|
|
||||||
| CriCod | int | NO | PRI | NULL | |
|
|
||||||
| Score | double | NO | | 0 | |
|
|
||||||
+--------+--------+------+-----+---------+-------+
|
|
||||||
3 rows in set (0,00 sec)
|
|
||||||
*/
|
|
||||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS prj_scores ("
|
|
||||||
"PrjCod INT NOT NULL,"
|
|
||||||
"CriCod INT NOT NULL,"
|
|
||||||
"Score DOUBLE PRECISION NOT NULL DEFAULT 0,"
|
|
||||||
"UNIQUE INDEX(PrjCod,CriCod))");
|
|
||||||
|
|
||||||
/***** Table prj_users *****/
|
/***** Table prj_users *****/
|
||||||
/*
|
/*
|
||||||
mysql> DESCRIBE prj_users;
|
mysql> DESCRIBE prj_users;
|
||||||
|
@ -2866,6 +2848,30 @@ mysql> DESCRIBE rub_rubrics;
|
||||||
"UNIQUE INDEX(RubCod),"
|
"UNIQUE INDEX(RubCod),"
|
||||||
"INDEX(CrsCod))");
|
"INDEX(CrsCod))");
|
||||||
|
|
||||||
|
/***** Table rub_scores *****/
|
||||||
|
/*
|
||||||
|
mysql> DESCRIBE rub_scores;
|
||||||
|
+--------+-------------------------------------------------------------------------------+------+-----+---------+-------+
|
||||||
|
| Field | Type | Null | Key | Default | Extra |
|
||||||
|
+--------+-------------------------------------------------------------------------------+------+-----+---------+-------+
|
||||||
|
| Type | enum('non','asg','prj','cfe','exa','gam','rub','doc','mrk','att','for','svy') | NO | PRI | non | |
|
||||||
|
| Cod | int | NO | PRI | NULL | |
|
||||||
|
| UsrCod | int | NO | PRI | -1 | |
|
||||||
|
| CriCod | int | NO | PRI | NULL | |
|
||||||
|
| EvlCod | int | NO | | -1 | |
|
||||||
|
| Score | double | NO | | 0 | |
|
||||||
|
+--------+-------------------------------------------------------------------------------+------+-----+---------+-------+
|
||||||
|
6 rows in set (0,00 sec)
|
||||||
|
*/
|
||||||
|
DB_CreateTable ("CREATE TABLE IF NOT EXISTS rub_scores ("
|
||||||
|
"Type ENUM('non','asg','prj','cfe','exa','gam','rub','doc','mrk','att','for','svy') NOT NULL DEFAULT 'non',"
|
||||||
|
"Cod INT NOT NULL,"
|
||||||
|
"UsrCod INT NOT NULL DEFAULT -1,"
|
||||||
|
"CriCod INT NOT NULL,"
|
||||||
|
"EvlCod INT NOT NULL DEFAULT -1,"
|
||||||
|
"Score DOUBLE PRECISION NOT NULL DEFAULT 0,"
|
||||||
|
"UNIQUE INDEX(Type,Cod,UsrCod,CriCod))");
|
||||||
|
|
||||||
/***** Table ses_params *****/
|
/***** Table ses_params *****/
|
||||||
/*
|
/*
|
||||||
mysql> DESCRIBE ses_params;
|
mysql> DESCRIBE ses_params;
|
||||||
|
|
|
@ -4676,7 +4676,7 @@ void Prj_ChangeCriterionScore (void)
|
||||||
|
|
||||||
/***** Update review *****/
|
/***** Update review *****/
|
||||||
if (Prj_CheckIfICanFillRubric (Prj.PrjCod,WhichRubric))
|
if (Prj_CheckIfICanFillRubric (Prj.PrjCod,WhichRubric))
|
||||||
Prj_DB_UpdateScore (Prj.PrjCod,CriCod,Score);
|
Rub_DB_UpdateScore (Rsc_PROJECT,Prj.PrjCod,-1L,CriCod,Score);
|
||||||
else
|
else
|
||||||
Err_NoPermission ();
|
Err_NoPermission ();
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,6 @@ void PrjCfg_ChangeNETCanCreate (void)
|
||||||
void PrjCfg_ChangeRubricsOfType (void)
|
void PrjCfg_ChangeRubricsOfType (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_configuration_of_the_projects_has_been_updated;
|
extern const char *Txt_The_configuration_of_the_projects_has_been_updated;
|
||||||
struct Prj_Projects Projects;
|
|
||||||
struct Rub_Rubrics Rubrics;
|
struct Rub_Rubrics Rubrics;
|
||||||
PrjCfg_RubricType_t RubricType;
|
PrjCfg_RubricType_t RubricType;
|
||||||
struct PrgCfg_ListRubCods ListRubCods;
|
struct PrgCfg_ListRubCods ListRubCods;
|
||||||
|
@ -361,9 +360,6 @@ void PrjCfg_ChangeRubricsOfType (void)
|
||||||
/***** Get list of rubrics *****/
|
/***** Get list of rubrics *****/
|
||||||
Rub_GetListRubrics (&Rubrics);
|
Rub_GetListRubrics (&Rubrics);
|
||||||
|
|
||||||
/***** Reset projects *****/
|
|
||||||
Prj_ResetPrjsAndReadConfig (&Projects);
|
|
||||||
|
|
||||||
/***** Get parameter with the type of rubric *****/
|
/***** Get parameter with the type of rubric *****/
|
||||||
Par_GetParText ("RubricType",StrType,sizeof (StrType) - 1);
|
Par_GetParText ("RubricType",StrType,sizeof (StrType) - 1);
|
||||||
RubricType = PrjCfg_GetRubricFromString (StrType);
|
RubricType = PrjCfg_GetRubricFromString (StrType);
|
||||||
|
@ -372,7 +368,7 @@ void PrjCfg_ChangeRubricsOfType (void)
|
||||||
PrjCfg_GetListRubCods (&Rubrics,&ListRubCods);
|
PrjCfg_GetListRubCods (&Rubrics,&ListRubCods);
|
||||||
|
|
||||||
/***** Update database *****/
|
/***** Update database *****/
|
||||||
Prj_DB_UpdateRubrics (&Projects,RubricType,&ListRubCods);
|
Prj_DB_UpdateRubrics (RubricType,&ListRubCods);
|
||||||
|
|
||||||
/***** Show confirmation message *****/
|
/***** Show confirmation message *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_configuration_of_the_projects_has_been_updated);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_configuration_of_the_projects_has_been_updated);
|
||||||
|
|
|
@ -226,22 +226,6 @@ void Prj_DB_UpdateReview (const struct Prj_Project *Prj)
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**************** Update score of a criterion in a project *******************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
void Prj_DB_UpdateScore (long PrjCod,long CriCod,double Score)
|
|
||||||
{
|
|
||||||
Str_SetDecimalPointToUS (); // To write the decimal point as a dot
|
|
||||||
DB_QueryREPLACE ("can not save score",
|
|
||||||
"REPLACE INTO prj_scores"
|
|
||||||
" (PrjCod,CriCod,Score)"
|
|
||||||
" VALUES"
|
|
||||||
" (%ld,%ld,%.15lg)",
|
|
||||||
PrjCod,CriCod,Score);
|
|
||||||
Str_SetDecimalPointToLocal (); // Return to local system
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************************** Get projects *******************************/
|
/******************************** Get projects *******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -699,21 +683,6 @@ long Prj_DB_GetCrsOfPrj (long PrjCod)
|
||||||
PrjCod); // Project found...
|
PrjCod); // Project found...
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********************* Get criteria in a given rubric ************************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
double Prj_DB_GetScore (long PrjCod,long CriCod)
|
|
||||||
{
|
|
||||||
return DB_QuerySELECTDouble ("can not get score",
|
|
||||||
"SELECT Score"
|
|
||||||
" FROM prj_scores"
|
|
||||||
" WHERE PrjCod=%ld"
|
|
||||||
" AND CriCod=%ld",
|
|
||||||
PrjCod,
|
|
||||||
CriCod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Get number of courses with projects ********************/
|
/******************** Get number of courses with projects ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -999,8 +968,7 @@ void Prj_DB_UpdateNETCanCreate (const struct Prj_Projects *Projects)
|
||||||
/********* Update rubrics associated to projects for current course **********/
|
/********* Update rubrics associated to projects for current course **********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Prj_DB_UpdateRubrics (const struct Prj_Projects *Projects,
|
void Prj_DB_UpdateRubrics (PrjCfg_RubricType_t RubricType,
|
||||||
PrjCfg_RubricType_t RubricType,
|
|
||||||
const struct PrgCfg_ListRubCods *ListRubCods)
|
const struct PrgCfg_ListRubCods *ListRubCods)
|
||||||
{
|
{
|
||||||
unsigned RubCod;
|
unsigned RubCod;
|
||||||
|
|
|
@ -41,7 +41,6 @@ void Prj_DB_UpdateProject (const struct Prj_Project *Prj);
|
||||||
void Prj_DB_AddUsrToPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,long UsrCod);
|
void Prj_DB_AddUsrToPrj (long PrjCod,Prj_RoleInProject_t RoleInProject,long UsrCod);
|
||||||
void Prj_DB_HideOrUnhideProject (long PrjCod,bool Hide);
|
void Prj_DB_HideOrUnhideProject (long PrjCod,bool Hide);
|
||||||
void Prj_DB_UpdateReview (const struct Prj_Project *Prj);
|
void Prj_DB_UpdateReview (const struct Prj_Project *Prj);
|
||||||
void Prj_DB_UpdateScore (long PrjCod,long CriCod,double Score);
|
|
||||||
|
|
||||||
unsigned Prj_DB_GetListProjects (MYSQL_RES **mysql_res,
|
unsigned Prj_DB_GetListProjects (MYSQL_RES **mysql_res,
|
||||||
const struct Prj_Projects *Projects,
|
const struct Prj_Projects *Projects,
|
||||||
|
@ -54,7 +53,6 @@ unsigned Prj_DB_GetUsrsInPrj (MYSQL_RES **mysql_res,
|
||||||
long PrjCod,Prj_RoleInProject_t RoleInProject);
|
long PrjCod,Prj_RoleInProject_t RoleInProject);
|
||||||
unsigned Prj_DB_GetMyRolesInPrj (MYSQL_RES **mysql_res,long PrjCod);
|
unsigned Prj_DB_GetMyRolesInPrj (MYSQL_RES **mysql_res,long PrjCod);
|
||||||
long Prj_DB_GetCrsOfPrj (long PrjCod);
|
long Prj_DB_GetCrsOfPrj (long PrjCod);
|
||||||
double Prj_DB_GetScore (long PrjCod,long CriCod);
|
|
||||||
unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope);
|
unsigned Prj_DB_GetNumCoursesWithProjects (HieLvl_Level_t Scope);
|
||||||
unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Scope);
|
unsigned Prj_DB_GetNumProjects (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
|
@ -70,8 +68,7 @@ void Prj_DB_RemoveCrsPrjs (long CrsCod);
|
||||||
//----------------------------- Configuration ---------------------------------
|
//----------------------------- Configuration ---------------------------------
|
||||||
|
|
||||||
void Prj_DB_UpdateNETCanCreate (const struct Prj_Projects *Projects);
|
void Prj_DB_UpdateNETCanCreate (const struct Prj_Projects *Projects);
|
||||||
void Prj_DB_UpdateRubrics (const struct Prj_Projects *Projects,
|
void Prj_DB_UpdateRubrics (PrjCfg_RubricType_t RubricType,
|
||||||
PrjCfg_RubricType_t RubricType,
|
|
||||||
const struct PrgCfg_ListRubCods *ListRubCods);
|
const struct PrgCfg_ListRubCods *ListRubCods);
|
||||||
unsigned Prj_DB_GetConfig (MYSQL_RES **mysql_res);
|
unsigned Prj_DB_GetConfig (MYSQL_RES **mysql_res);
|
||||||
unsigned Prj_DB_GetRubricsOfType (MYSQL_RES **mysql_res,
|
unsigned Prj_DB_GetRubricsOfType (MYSQL_RES **mysql_res,
|
||||||
|
|
|
@ -78,6 +78,8 @@ static bool Rub_CheckRubricFieldsReceivedFromForm (const struct Rub_Rubric *Rubr
|
||||||
static void Rub_CreateRubric (struct Rub_Rubric *Rubric);
|
static void Rub_CreateRubric (struct Rub_Rubric *Rubric);
|
||||||
static void Rub_UpdateRubric (struct Rub_Rubric *Rubric);
|
static void Rub_UpdateRubric (struct Rub_Rubric *Rubric);
|
||||||
|
|
||||||
|
static bool Rub_CheckIfRecursiveTree (long RubCod,struct Rub_Node **TOS);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Reset rubrics context ***************************/
|
/*************************** Reset rubrics context ***************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -345,7 +347,7 @@ void Rub_ShowOnlyOneRubric (struct Rub_Rubrics *Rubrics)
|
||||||
{
|
{
|
||||||
extern const char *Hlp_ASSESSMENT_Rubrics;
|
extern const char *Hlp_ASSESSMENT_Rubrics;
|
||||||
extern const char *Txt_Rubric;
|
extern const char *Txt_Rubric;
|
||||||
struct Node *TOS = NULL;
|
struct Rub_Node *TOS = NULL;
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (NULL,Rubrics->Rubric.Title[0] ? Rubrics->Rubric.Title :
|
Box_BoxBegin (NULL,Rubrics->Rubric.Title[0] ? Rubrics->Rubric.Title :
|
||||||
|
@ -788,7 +790,7 @@ void Rub_PutFormsOneRubric (struct Rub_Rubrics *Rubrics,
|
||||||
[Rub_EXISTING_RUBRIC] = &Hlp_ASSESSMENT_Rubrics_edit_rubric,
|
[Rub_EXISTING_RUBRIC] = &Hlp_ASSESSMENT_Rubrics_edit_rubric,
|
||||||
[Rub_NEW_RUBRIC ] = &Hlp_ASSESSMENT_Rubrics_new_rubric,
|
[Rub_NEW_RUBRIC ] = &Hlp_ASSESSMENT_Rubrics_new_rubric,
|
||||||
};
|
};
|
||||||
struct Node *TOS = NULL;
|
struct Rub_Node *TOS = NULL;
|
||||||
|
|
||||||
/***** Begin box *****/
|
/***** Begin box *****/
|
||||||
Box_BoxBegin (NULL,
|
Box_BoxBegin (NULL,
|
||||||
|
@ -1061,7 +1063,7 @@ Handwritten Handwritten |_______| Handwritten
|
||||||
/ | \
|
/ | \
|
||||||
Handwritten Handwritten Handwritten
|
Handwritten Handwritten Handwritten
|
||||||
*/
|
*/
|
||||||
bool Rub_CheckIfRecursiveTree (long RubCod,struct Node **TOS)
|
static bool Rub_CheckIfRecursiveTree (long RubCod,struct Rub_Node **TOS)
|
||||||
{
|
{
|
||||||
bool RecursiveTree;
|
bool RecursiveTree;
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
@ -1077,25 +1079,25 @@ bool Rub_CheckIfRecursiveTree (long RubCod,struct Node **TOS)
|
||||||
/***** Push rubric code in stack *****/
|
/***** Push rubric code in stack *****/
|
||||||
Rub_PushRubCod (TOS,RubCod);
|
Rub_PushRubCod (TOS,RubCod);
|
||||||
|
|
||||||
/* For each criteria in this rubric... */
|
/***** For each criteria in this rubric... *****/
|
||||||
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
||||||
for (NumCriterion = 0;
|
for (NumCriterion = 0;
|
||||||
NumCriterion < NumCriteria;
|
NumCriterion < NumCriteria;
|
||||||
NumCriterion++)
|
NumCriterion++)
|
||||||
{
|
{
|
||||||
/* Get criterion data */
|
/* Get criterion data */
|
||||||
RubCri_GetCriterionDataFromRow (mysql_res,&Criterion);
|
RubCri_GetCriterionDataFromRow (mysql_res,&Criterion);
|
||||||
|
|
||||||
if (Criterion.Link.Type == Rsc_RUBRIC)
|
if (Criterion.Link.Type == Rsc_RUBRIC)
|
||||||
if (Rub_CheckIfRecursiveTree (Criterion.Link.Cod,TOS))
|
if (Rub_CheckIfRecursiveTree (Criterion.Link.Cod,TOS))
|
||||||
{
|
{
|
||||||
RecursiveTree = true;
|
RecursiveTree = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Pop rubric code from stack *****/
|
/***** Pop rubric code from stack *****/
|
||||||
Rub_PopRubCod (TOS);
|
Rub_PopRubCod (TOS);
|
||||||
|
|
|
@ -37,12 +37,6 @@
|
||||||
|
|
||||||
#define RubCri_AFTER_LAST_CRITERION ((unsigned)((1UL << 31) - 1)) // 2^31 - 1, don't change this number because it is used in database
|
#define RubCri_AFTER_LAST_CRITERION ((unsigned)((1UL << 31) - 1)) // 2^31 - 1, don't change this number because it is used in database
|
||||||
|
|
||||||
struct Node
|
|
||||||
{
|
|
||||||
long RubCod;
|
|
||||||
struct Node *Prev;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -78,8 +72,6 @@ void Rub_PutFormsOneRubric (struct Rub_Rubrics *Rubrics,
|
||||||
|
|
||||||
void Rub_ReceiveFormRubric (void);
|
void Rub_ReceiveFormRubric (void);
|
||||||
|
|
||||||
bool Rub_CheckIfRecursiveTree (long RubCod,struct Node **TOS);
|
|
||||||
|
|
||||||
//-------------------------------- Figures ------------------------------------
|
//-------------------------------- Figures ------------------------------------
|
||||||
void Rub_GetAndShowRubricsStats (void);
|
void Rub_GetAndShowRubricsStats (void);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ static void RubCri_ListOneOrMoreCriteriaForEdition (struct Rub_Rubrics *Rubrics,
|
||||||
unsigned NumCriteria,
|
unsigned NumCriteria,
|
||||||
MYSQL_RES *mysql_res);
|
MYSQL_RES *mysql_res);
|
||||||
static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects,
|
static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects,
|
||||||
struct Node **TOS,
|
struct Rub_Node **TOS,
|
||||||
bool ICanFill,
|
bool ICanFill,
|
||||||
unsigned NumCriteria,
|
unsigned NumCriteria,
|
||||||
MYSQL_RES *mysql_res);
|
MYSQL_RES *mysql_res);
|
||||||
|
@ -122,7 +122,8 @@ static void RubCri_WriteWeight (const struct RubCri_Criterion *Criterion);
|
||||||
static void RubCri_WriteTotalLabel (unsigned ColSpan);
|
static void RubCri_WriteTotalLabel (unsigned ColSpan);
|
||||||
static void RubCri_WriteTotalValue (double Total);
|
static void RubCri_WriteTotalValue (double Total);
|
||||||
|
|
||||||
static bool RubCri_ComputeRubricScore (long PrjCod,struct Node **TOS,long RubCod,
|
static bool RubCri_ComputeRubricScore (Rsc_Type_t Type,long Cod,long UsrCod,
|
||||||
|
struct Rub_Node **TOS,long RubCod,
|
||||||
double *RubricScore);
|
double *RubricScore);
|
||||||
|
|
||||||
static void RubCri_PutTableHeadingForCriteria (RubCri_PutColumnForIcons_t PutColumnForIcons,
|
static void RubCri_PutTableHeadingForCriteria (RubCri_PutColumnForIcons_t PutColumnForIcons,
|
||||||
|
@ -575,7 +576,7 @@ void RubCri_ListCriteriaInProject (struct Prj_Projects *Projects,long RubCod,
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
unsigned NumCriteria;
|
unsigned NumCriteria;
|
||||||
struct Node *TOS;
|
struct Rub_Node *TOS;
|
||||||
|
|
||||||
/***** Get data of rubric criteria from database *****/
|
/***** Get data of rubric criteria from database *****/
|
||||||
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
||||||
|
@ -806,7 +807,7 @@ static void RubCri_ListOneOrMoreCriteriaForEdition (struct Rub_Rubrics *Rubrics,
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects,
|
static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects,
|
||||||
struct Node **TOS,
|
struct Rub_Node **TOS,
|
||||||
bool ICanFill,
|
bool ICanFill,
|
||||||
unsigned NumCriteria,
|
unsigned NumCriteria,
|
||||||
MYSQL_RES *mysql_res)
|
MYSQL_RES *mysql_res)
|
||||||
|
@ -854,7 +855,7 @@ static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects
|
||||||
switch (Criterion.Link.Type)
|
switch (Criterion.Link.Type)
|
||||||
{
|
{
|
||||||
case Rsc_NONE:
|
case Rsc_NONE:
|
||||||
CriterionScore = Prj_DB_GetScore (Projects->Prj.PrjCod,Criterion.CriCod);
|
CriterionScore = Rub_DB_GetScore (Rsc_PROJECT,Projects->Prj.PrjCod,-1L,Criterion.CriCod);
|
||||||
if (ICanFill)
|
if (ICanFill)
|
||||||
{
|
{
|
||||||
Frm_BeginFormAnchor (ActChgPrjSco,Anchor);
|
Frm_BeginFormAnchor (ActChgPrjSco,Anchor);
|
||||||
|
@ -875,8 +876,8 @@ static void RubCri_ListOneOrMoreCriteriaInProject (struct Prj_Projects *Projects
|
||||||
HTM_Double2Decimals (CriterionScore);
|
HTM_Double2Decimals (CriterionScore);
|
||||||
break;
|
break;
|
||||||
case Rsc_RUBRIC:
|
case Rsc_RUBRIC:
|
||||||
if (RubCri_ComputeRubricScore (Projects->Prj.PrjCod,TOS,
|
if (RubCri_ComputeRubricScore (Rsc_PROJECT,Projects->Prj.PrjCod,-1L,
|
||||||
Criterion.Link.Cod,
|
TOS,Criterion.Link.Cod,
|
||||||
&CriterionScore))
|
&CriterionScore))
|
||||||
Err_RecursiveRubric ();
|
Err_RecursiveRubric ();
|
||||||
else
|
else
|
||||||
|
@ -1008,7 +1009,8 @@ static void RubCri_WriteTotalValue (double Total)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return true if rubric tree is recursive
|
// Return true if rubric tree is recursive
|
||||||
|
|
||||||
static bool RubCri_ComputeRubricScore (long PrjCod,struct Node **TOS,long RubCod,
|
static bool RubCri_ComputeRubricScore (Rsc_Type_t Type,long Cod,long UsrCod,
|
||||||
|
struct Rub_Node **TOS,long RubCod,
|
||||||
double *RubricScore)
|
double *RubricScore)
|
||||||
{
|
{
|
||||||
bool RecursiveTree;
|
bool RecursiveTree;
|
||||||
|
@ -1029,37 +1031,38 @@ static bool RubCri_ComputeRubricScore (long PrjCod,struct Node **TOS,long RubCod
|
||||||
/***** Push rubric code in stack *****/
|
/***** Push rubric code in stack *****/
|
||||||
Rub_PushRubCod (TOS,RubCod);
|
Rub_PushRubCod (TOS,RubCod);
|
||||||
|
|
||||||
/***** Get data of rubric criteria from database *****/
|
/***** Get data of rubric criteria from database *****/
|
||||||
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
NumCriteria = Rub_DB_GetCriteria (&mysql_res,RubCod);
|
||||||
for (NumCriterion = 0;
|
for (NumCriterion = 0;
|
||||||
NumCriterion < NumCriteria;
|
NumCriterion < NumCriteria;
|
||||||
NumCriterion++)
|
NumCriterion++)
|
||||||
|
{
|
||||||
|
/***** Get criterion data *****/
|
||||||
|
RubCri_GetCriterionDataFromRow (mysql_res,&Criterion);
|
||||||
|
|
||||||
|
/***** Get/compute criterion score *****/
|
||||||
|
CriterionScore = 0.0;
|
||||||
|
switch (Criterion.Link.Type)
|
||||||
{
|
{
|
||||||
/***** Get criterion data *****/
|
case Rsc_NONE:
|
||||||
RubCri_GetCriterionDataFromRow (mysql_res,&Criterion);
|
CriterionScore = Rub_DB_GetScore (Rsc_PROJECT,Cod,UsrCod,Criterion.CriCod);
|
||||||
|
break;
|
||||||
/* Get/compute criterion score */
|
case Rsc_RUBRIC:
|
||||||
CriterionScore = 0.0;
|
if (RubCri_ComputeRubricScore (Type,Cod,UsrCod,
|
||||||
switch (Criterion.Link.Type)
|
TOS,Criterion.Link.Cod,
|
||||||
{
|
&CriterionScore))
|
||||||
case Rsc_NONE:
|
RecursiveTree = true;
|
||||||
CriterionScore = Prj_DB_GetScore (PrjCod,Criterion.CriCod);
|
break;
|
||||||
break;
|
default:
|
||||||
case Rsc_RUBRIC:
|
break;
|
||||||
if (RubCri_ComputeRubricScore (PrjCod,TOS,Criterion.Link.Cod,
|
|
||||||
&CriterionScore))
|
|
||||||
RecursiveTree = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Compute score of this criterion in the child rubric *****/
|
|
||||||
*RubricScore += Criterion.Weight * CriterionScore; // Update weighted sum
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Compute score of this criterion in the child rubric *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
*RubricScore += Criterion.Weight * CriterionScore; // Update weighted sum
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
/***** Pop rubric code from stack *****/
|
/***** Pop rubric code from stack *****/
|
||||||
Rub_PopRubCod (TOS);
|
Rub_PopRubCod (TOS);
|
||||||
|
@ -1072,23 +1075,23 @@ static bool RubCri_ComputeRubricScore (long PrjCod,struct Node **TOS,long RubCod
|
||||||
/********************** Push/pop rubric code in stack ************************/
|
/********************** Push/pop rubric code in stack ************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Rub_PushRubCod (struct Node **TOS,long RubCod)
|
void Rub_PushRubCod (struct Rub_Node **TOS,long RubCod)
|
||||||
{
|
{
|
||||||
struct Node *Node;
|
struct Rub_Node *Node;
|
||||||
|
|
||||||
/***** Save current top of stack *****/
|
/***** Save current top of stack *****/
|
||||||
Node = *TOS;
|
Node = *TOS;
|
||||||
|
|
||||||
/***** Create top of stack node *****/
|
/***** Create top of stack node *****/
|
||||||
if ((*TOS = malloc (sizeof (struct Node))) == NULL)
|
if ((*TOS = malloc (sizeof (struct Rub_Node))) == NULL)
|
||||||
Err_NotEnoughMemoryExit ();
|
Err_NotEnoughMemoryExit ();
|
||||||
(*TOS)->RubCod = RubCod;
|
(*TOS)->RubCod = RubCod;
|
||||||
(*TOS)->Prev = Node; // Link to previous top of stack
|
(*TOS)->Prev = Node; // Link to previous top of stack
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rub_PopRubCod (struct Node **TOS)
|
void Rub_PopRubCod (struct Rub_Node **TOS)
|
||||||
{
|
{
|
||||||
struct Node *Node;
|
struct Rub_Node *Node;
|
||||||
|
|
||||||
if (*TOS)
|
if (*TOS)
|
||||||
{
|
{
|
||||||
|
@ -1108,7 +1111,7 @@ void Rub_PopRubCod (struct Node **TOS)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return true if found
|
// Return true if found
|
||||||
|
|
||||||
bool Rub_FindRubCodInStack (const struct Node *TOS,long RubCod)
|
bool Rub_FindRubCodInStack (const struct Rub_Node *TOS,long RubCod)
|
||||||
{
|
{
|
||||||
while (TOS)
|
while (TOS)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,9 +47,9 @@ void RubCri_ListCriteriaForEdition (struct Rub_Rubrics *Rubrics);
|
||||||
void RubCri_ListCriteriaInProject (struct Prj_Projects *Projects,long RubCod,
|
void RubCri_ListCriteriaInProject (struct Prj_Projects *Projects,long RubCod,
|
||||||
bool ICanFill);
|
bool ICanFill);
|
||||||
|
|
||||||
void Rub_PushRubCod (struct Node **TOS,long RubCod);
|
void Rub_PushRubCod (struct Rub_Node **TOS,long RubCod);
|
||||||
void Rub_PopRubCod (struct Node **TOS);
|
void Rub_PopRubCod (struct Rub_Node **TOS);
|
||||||
bool Rub_FindRubCodInStack (const struct Node *TOS,long RubCod);
|
bool Rub_FindRubCodInStack (const struct Rub_Node *TOS,long RubCod);
|
||||||
|
|
||||||
double RubCri_GetParScore (void);
|
double RubCri_GetParScore (void);
|
||||||
|
|
||||||
|
|
|
@ -825,3 +825,44 @@ void Rub_DB_RemoveCrsRubricCriteria (long CrsCod)
|
||||||
" AND rub_rubrics.RubCod=rub_criteria.RubCod",
|
" AND rub_rubrics.RubCod=rub_criteria.RubCod",
|
||||||
CrsCod);
|
CrsCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/** Update score of a criterion given an assignment/project code and a user **/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Rub_DB_UpdateScore (Rsc_Type_t Type,long Cod,long UsrCod,long CriCod,
|
||||||
|
double Score)
|
||||||
|
{
|
||||||
|
extern const char *Rsc_ResourceTypesDB[Rsc_NUM_TYPES];
|
||||||
|
|
||||||
|
Str_SetDecimalPointToUS (); // To write the decimal point as a dot
|
||||||
|
DB_QueryREPLACE ("can not save score",
|
||||||
|
"REPLACE INTO rub_scores"
|
||||||
|
" (Type,Cod,UsrCod,CriCod,EvlCod,Score)"
|
||||||
|
" VALUES"
|
||||||
|
" ('%s',%ld,%ld,%ld,%ld,%.15lg)",
|
||||||
|
Rsc_ResourceTypesDB[Type],Cod,UsrCod,CriCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,Score);
|
||||||
|
Str_SetDecimalPointToLocal (); // Return to local system
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**** Get score of a criterion given an assignment/project code and a user ***/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
double Rub_DB_GetScore (Rsc_Type_t Type,long Cod,long UsrCod,long CriCod)
|
||||||
|
{
|
||||||
|
extern const char *Rsc_ResourceTypesDB[Rsc_NUM_TYPES];
|
||||||
|
|
||||||
|
return DB_QuerySELECTDouble ("can not get score",
|
||||||
|
"SELECT Score"
|
||||||
|
" FROM rub_scores"
|
||||||
|
" WHERE Type='%s'"
|
||||||
|
" AND Cod=%ld"
|
||||||
|
" AND UsrCod=%ld"
|
||||||
|
" AND CriCod=%ld",
|
||||||
|
Rsc_ResourceTypesDB[Type],
|
||||||
|
Cod,
|
||||||
|
UsrCod,
|
||||||
|
CriCod);
|
||||||
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ unsigned Rub_DB_GetNumRubrics (HieLvl_Level_t Scope);
|
||||||
void Rub_DB_RemoveRubric (long RubCod);
|
void Rub_DB_RemoveRubric (long RubCod);
|
||||||
void Rub_DB_RemoveCrsRubrics (long CrsCod);
|
void Rub_DB_RemoveCrsRubrics (long CrsCod);
|
||||||
|
|
||||||
//--------------------------- Rubric criteria -------------------------------
|
//---------------------------- Rubric criteria --------------------------------
|
||||||
long Rub_DB_CreateCriterion (const struct RubCri_Criterion *Criterion);
|
long Rub_DB_CreateCriterion (const struct RubCri_Criterion *Criterion);
|
||||||
void Rub_DB_UpdateCriterionTitle (const struct RubCri_Criterion *Criterion);
|
void Rub_DB_UpdateCriterionTitle (const struct RubCri_Criterion *Criterion);
|
||||||
void Rub_DB_UpdateCriterionLink (const struct RubCri_Criterion *Criterion);
|
void Rub_DB_UpdateCriterionLink (const struct RubCri_Criterion *Criterion);
|
||||||
|
@ -82,4 +82,10 @@ void Rub_DB_RemoveCriterionFromRubric (const struct RubCri_Criterion *Criterion)
|
||||||
void Rub_DB_RemoveRubricCriteria (long RubCod);
|
void Rub_DB_RemoveRubricCriteria (long RubCod);
|
||||||
void Rub_DB_RemoveCrsRubricCriteria (long CrsCod);
|
void Rub_DB_RemoveCrsRubricCriteria (long CrsCod);
|
||||||
|
|
||||||
|
//----------------------------- Rubric scores ---------------------------------
|
||||||
|
void Rub_DB_UpdateScore (Rsc_Type_t Type,long Cod,long UsrCod,long CriCod,
|
||||||
|
double Score);
|
||||||
|
|
||||||
|
double Rub_DB_GetScore (Rsc_Type_t Type,long Cod,long UsrCod,long CriCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -88,4 +88,11 @@ typedef enum
|
||||||
Rub_NEW_RUBRIC,
|
Rub_NEW_RUBRIC,
|
||||||
} Rub_ExistingNewRubric_t;
|
} Rub_ExistingNewRubric_t;
|
||||||
|
|
||||||
|
/* Stack node to check is a rubric is recursive */
|
||||||
|
struct Rub_Node
|
||||||
|
{
|
||||||
|
long RubCod;
|
||||||
|
struct Rub_Node *Prev;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue