Version 22.68: Mar 06, 2023 Code refactoring in parameters. Not finished.

This commit is contained in:
acanas 2023-03-06 23:53:45 +01:00
parent 66cb80668b
commit f40674ed95
68 changed files with 377 additions and 666 deletions

View File

@ -2699,7 +2699,9 @@ int swad__getAttendanceUsers (struct soap *soap,
"Requester must be a teacher");
/***** Query list of attendance users *****/
AttEventIsAsociatedToGrps = Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",Event.AttCod);
AttEventIsAsociatedToGrps = Grp_DB_CheckIfAssociatedToGrps ("att_groups",
Par_AttCod,
Event.AttCod);
NumUsrs = Att_DB_GetListUsrsInAttEvent (&mysql_res,Event.AttCod,AttEventIsAsociatedToGrps);

View File

@ -963,8 +963,7 @@ void Agd_PutParamsMyAgenda (unsigned Past__FutureEvents,
if (NumPage > 1)
Pag_PutHiddenParamPagNum (Pag_MY_AGENDA,NumPage);
if (AgdCodToEdit > 0)
Par_PutHiddenParamLong (NULL,"AgdCod",AgdCodToEdit);
Par_PutParCod (Par_AgdCod,AgdCodToEdit);
}
/*****************************************************************************/

View File

@ -304,7 +304,7 @@ static void Ann_DrawAnAnnouncement (long AnnCod,Ann_Status_t Status,
static void Ann_PutParams (void *AnnCod)
{
Par_PutHiddenParamLong (NULL,"AnnCod",*((long *) AnnCod));
Par_PutParCod (Par_AnnCod,*((long *) AnnCod));
}
/*****************************************************************************/

View File

@ -774,8 +774,7 @@ static void Asg_PutParams (void *Assignments)
if (Assignments)
{
if (((struct Asg_Assignments *) Assignments)->Asg.AsgCod > 0)
Asg_PutParamAsgCod (((struct Asg_Assignments *) Assignments)->Asg.AsgCod);
Par_PutParCod (Par_AsgCod,((struct Asg_Assignments *) Assignments)->Asg.AsgCod);
Par_PutHiddenParamOrder ((unsigned) ((struct Asg_Assignments *) Assignments)->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -1004,16 +1003,6 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/***************** Write parameter with code of assignment *******************/
/*****************************************************************************/
void Asg_PutParamAsgCod (long AsgCod)
{
if (AsgCod > 0)
Par_PutHiddenParamLong (NULL,"AsgCod",AsgCod);
}
/*****************************************************************************/
/************* Ask for confirmation of removing an assignment ****************/
/*****************************************************************************/
@ -1354,8 +1343,10 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod)
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\"%s"
" onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_DB_CheckIfAssociatedToGrps ("asg_groups","AsgCod",AsgCod) ? "" :
" checked=\"checked\"");
Grp_DB_CheckIfAssociatedToGrps ("asg_groups",
Par_AsgCod,
AsgCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();

View File

@ -98,7 +98,6 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr,
long AsgCod,bool GetContent);
void Asg_PutParamAsgCod (long AsgCod);
void Asg_ReqRemAssignment (void);
void Asg_RemoveAssignment (void);
void Asg_HideAssignment (void);

View File

@ -95,7 +95,7 @@ void AsgRsc_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo,
NextAction = (AsgCod > 0) ? ActSeeOneAsg : // Assignment specified
ActSeeAsg; // All assignments
Frm_BeginForm (NextAction);
Asg_PutParamAsgCod (AsgCod);
Par_PutParCod (Par_AsgCod,AsgCod);
// TODO: In the listing of assignments, the page is always the first.
// The page should be that corresponding to the selected assignment.
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],

View File

@ -651,7 +651,7 @@ static void Att_PutParams (void *Events)
if (Events)
{
Att_PutParamAttCod (((struct Att_Events *) Events)->Event.AttCod);
Par_PutParCod (Par_AttCod,((struct Att_Events *) Events)->Event.AttCod);
Par_PutHiddenParamOrder ((unsigned) ((struct Att_Events *) Events)->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -820,13 +820,7 @@ static void Att_FreeListAttEvents (struct Att_Events *Events)
static void Att_PutParamSelectedAttCod (void *Events)
{
if (Events)
Att_PutParamAttCod (((struct Att_Events *) Events)->Event.AttCod);
}
void Att_PutParamAttCod (long AttCod)
{
if (AttCod > 0)
Par_PutHiddenParamLong (NULL,"AttCod",AttCod);
Par_PutParCod (Par_AttCod,((struct Att_Events *) Events)->Event.AttCod);
}
/*****************************************************************************/
@ -1016,7 +1010,7 @@ void Att_RequestCreatOrEditAttEvent (void)
else
{
Frm_BeginForm (ActChgAtt);
Att_PutParamAttCod (Events.Event.AttCod);
Par_PutParCod (Par_AttCod,Events.Event.AttCod);
}
Par_PutHiddenParamOrder ((unsigned) Events.SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
@ -1149,8 +1143,10 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod)
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\"%s"
" onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",AttCod) ? "" :
" checked=\"checked\"");
Grp_DB_CheckIfAssociatedToGrps ("att_groups",
Par_AttCod,
AttCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -1541,7 +1537,7 @@ static void Att_ListAttOnlyMeAsStudent (struct Att_Event *Event)
if (Event->Open)
{
Frm_BeginForm (ActRecAttMe);
Att_PutParamAttCod (Event->AttCod);
Par_PutParCod (Par_AttCod,Event->AttCod);
}
/***** List students (only me) *****/
@ -1621,7 +1617,7 @@ static void Att_ListAttStudents (struct Att_Events *Events)
/* Begin form */
Frm_BeginForm (ActRecAttStd);
Att_PutParamAttCod (Events->Event.AttCod);
Par_PutParCod (Par_AttCod,Events->Event.AttCod);
Grp_PutParamsCodGrps ();
/* Begin table */
@ -1855,7 +1851,7 @@ static void Att_PutLinkAttEvent (struct Att_Event *Event,
{
/***** Begin form *****/
Frm_BeginForm (ActSeeOneAtt);
Att_PutParamAttCod (Event->AttCod);
Par_PutParCod (Par_AttCod,Event->AttCod);
Att_PutParamsCodGrps (Event->AttCod);
/***** Link to view attendance event *****/

View File

@ -90,8 +90,6 @@ bool Att_CheckIfICanEditAttEvents (void);
void Att_RequestCreatOrEditAttEvent (void);
bool Att_GetDataOfAttEventByCod (struct Att_Event *Event);
void Att_PutParamAttCod (long AttCod);
void Att_AskRemAttEvent (void);
void Att_GetAndRemAttEvent (void);
void Att_RemoveAttEventFromDB (long AttCod);

View File

@ -81,7 +81,7 @@ void AttRsc_WriteAttEventInCrsProgram (long AttCod,bool PutFormToGo,
NextAction = (AttCod > 0) ? ActSeeOneAtt : // Attendance events specified
ActSeeAtt; // All attendance events
Frm_BeginForm (NextAction);
Att_PutParamAttCod (AttCod);
Par_PutParCod (Par_AttCod,AttCod);
Att_PutParamsCodGrps (AttCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LM BT_LINK PRG_LNK_%s\"",

View File

@ -89,7 +89,6 @@ static void Ban_PutIconsEditingBanners (__attribute__((unused)) void *Args);
static void Ban_ListBannersForEdition (struct Ban_Banners *Banners);
static void Ban_PutParamBanCodToEdit (void *BanCod);
static void Ban_PutParamBanCod (long BanCod);
static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban,bool Hide);
static void Ban_RenameBanner (struct Ban_Banner *Ban,
@ -509,12 +508,7 @@ static void Ban_ListBannersForEdition (struct Ban_Banners *Banners)
static void Ban_PutParamBanCodToEdit (void *BanCod)
{
if (BanCod)
Ban_PutParamBanCod (*((long *) BanCod));
}
static void Ban_PutParamBanCod (long BanCod)
{
Par_PutHiddenParamLong (NULL,"BanCod",BanCod);
Par_PutParCod (Par_BanCod,*((long *) BanCod));
}
/*****************************************************************************/
@ -987,7 +981,7 @@ void Ban_WriteMenuWithBanners (void)
/* Begin form */
Frm_BeginForm (ActClkBan);
Ban_PutParamBanCod (Banners.Lst[NumBan].BanCod);
Par_PutParCod (Par_BanCod,Banners.Lst[NumBan].BanCod);
Par_PutHiddenParamString (NULL,"URL",Banners.Lst[NumBan].WWW);
/* Banner image */

View File

@ -2075,16 +2075,6 @@ static void Brw_GetDataCurrentGrp (void)
}
}
/*****************************************************************************/
/**************** Write hidden parameter with code of file *******************/
/*****************************************************************************/
void Brw_PutHiddenParamFilCod (long FilCod)
{
if (FilCod > 0)
Par_PutHiddenParamLong (NULL,"FilCod",FilCod);
}
/*****************************************************************************/
/**************** Write parameters related with file browser *****************/
/*****************************************************************************/
@ -2122,7 +2112,7 @@ void Brw_PutParamsFileBrowser (const char *PathInTree,const char *FilFolLnkName,
Par_PutHiddenParamString (NULL,"Path",PathInTree);
if (FilFolLnkName)
Par_PutHiddenParamString (NULL,Brw_FileTypeParamName[FileType],FilFolLnkName);
Brw_PutHiddenParamFilCod (FilCod);
Par_PutParCod (Par_FilCod,FilCod);
}
/*****************************************************************************/
@ -2826,6 +2816,7 @@ static void Brw_ShowFileBrowsersAsgWrkUsr (void)
static void Brw_FormToChangeCrsGrpZone (void)
{
extern const char *Par_CodeStr[];
struct ListCodGrps LstMyGrps;
unsigned NumGrp;
struct GroupData GrpDat;
@ -2858,7 +2849,7 @@ static void Brw_FormToChangeCrsGrpZone (void)
HTM_LI_Begin ("class=\"%s\"",IsCourseZone ? "BROWSER_TITLE" :
"BROWSER_TITLE_LIGHT");
HTM_LABEL_Begin (NULL);
HTM_INPUT_RADIO ("GrpCod",true,
HTM_INPUT_RADIO (Par_CodeStr[Par_GrpCod],true,
"value=\"-1\"%s",
IsCourseZone ? " checked=\"checked\"" : "");
HTM_Txt (Gbl.Hierarchy.Crs.FullName);
@ -2887,7 +2878,7 @@ static void Brw_FormToChangeCrsGrpZone (void)
NULL,
"class=\"ICO25x25\" style=\"margin-left:6px;\"");
HTM_LABEL_Begin (NULL);
HTM_INPUT_RADIO ("GrpCod",true,
HTM_INPUT_RADIO (Par_CodeStr[Par_GrpCod],true,
"value=\"%ld\"%s",
GrpDat.GrpCod,
(IsGroupZone &&

View File

@ -181,7 +181,6 @@ struct Brw_FileMetadata
/*****************************************************************************/
void Brw_GetParAndInitFileBrowser (void);
void Brw_PutHiddenParamFilCod (long FilCod);
void Brw_InitializeFileBrowser (void);
bool Brw_CheckIfExistsFolderAssigmentForAnyUsr (const char *FolderName);
bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,

View File

@ -489,7 +489,7 @@ static void Bld_ListBuildingsForEdition (const struct Bld_Buildings *Buildings)
static void Bld_PutParamBldCod (void *BldCod)
{
if (BldCod)
Par_PutHiddenParamLong (NULL,"BldCod",*((long *) BldCod));
Par_PutParCod (Par_BldCod,*((long *) BldCod));
}
/*****************************************************************************/

View File

@ -958,8 +958,7 @@ static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams,
{
/***** Begin form *****/
Frm_BeginFormAnchor (ActRcvCfe,Anchor);
if (ExaCod > 0) // Existing call for exam
Cfe_PutHiddenParamExaCod (ExaCod);
Par_PutParCod (Par_ExaCod,ExaCod);
}
/***** Begin table *****/
@ -1548,13 +1547,7 @@ bool Cfe_CheckIfICanEditCallsForExams (void)
static void Cfe_PutParamExaCodToEdit (void *ExaCod)
{
if (ExaCod)
Cfe_PutHiddenParamExaCod (*((long *) ExaCod));
}
void Cfe_PutHiddenParamExaCod (long ExaCod)
{
if (ExaCod > 0)
Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod);
Par_PutParCod (Par_ExaCod,*((long *) ExaCod));
}
/*****************************************************************************/

View File

@ -131,8 +131,6 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams);
bool Cfe_CheckIfICanEditCallsForExams (void);
void Cfe_PutHiddenParamExaCod (long ExaCod);
void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr,
long ExaCod,bool GetContent);

View File

@ -91,7 +91,7 @@ void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo,
NextAction = (ExaCod > 0) ? ActSeeOneCfe : // Call for exam specified
ActSeeAllCfe; // All calls for exams
Frm_BeginFormAnchor (NextAction,Anchor);
Cfe_PutHiddenParamExaCod (ExaCod);
Par_PutParCod (Par_ExaCod,ExaCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LM BT_LINK PRG_LNK_%s\"",
The_GetSuffix ());

View File

@ -540,6 +540,7 @@ static void CtrCfg_FreePhotoAttr (char **PhotoAttribution)
static void CtrCfg_Institution (bool PrintView,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Institution;
unsigned NumIns;
@ -547,7 +548,7 @@ static void CtrCfg_Institution (bool PrintView,bool PutForm)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthInsCod" :
Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthInsCod] :
NULL,
Txt_Institution);

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.67.1 (2023-03-06)"
#define Log_PLATFORM_VERSION "SWAD 22.68 (2023-03-06)"
#define CSS_FILE "swad22.57.1.css"
#define JS_FILE "swad22.49.js"
/*
Version 22.68: Mar 06, 2023 Code refactoring in parameters. Not finished. (336887 lines)
Version 22.67.1: Mar 06, 2023 Code refactoring in dates. (337124 lines)
Version 22.67: Mar 04, 2023 Code refactoring in parameters. Not finished. (337118 lines)
Version 22.66.4: Mar 04, 2023 Fixed issues in exams. (337245 lines)

View File

@ -1180,7 +1180,7 @@ void Cty_PutParamCtyCod (long CtyCod)
static void Cty_PutParamOtherCtyCod (void *CtyCod)
{
if (CtyCod)
Par_PutHiddenParamLong (NULL,"OthCtyCod",*((long *) CtyCod));
Par_PutParCod (Par_OthCtyCod,*((long *) CtyCod));
}
/*****************************************************************************/
@ -1413,6 +1413,7 @@ static void Cty_PutParamGoToCty (void *CtyCod)
static void Cty_PutFormToCreateCountry (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
extern const char *Par_CodeStr[];
extern const char *Txt_New_country;
extern const char *Txt_STR_LANG_NAME[1 + Lan_NUM_LANGUAGES];
extern const char *Txt_Create_country;
@ -1443,7 +1444,7 @@ static void Cty_PutFormToCreateCountry (void)
snprintf (StrCtyCod,sizeof (StrCtyCod),"%03ld",Cty_EditingCty->CtyCod);
else
StrCtyCod[0] = '\0';
HTM_INPUT_TEXT ("OthCtyCod",3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE,
HTM_INPUT_TEXT (Par_CodeStr[Par_OthCtyCod],3,StrCtyCod,HTM_DONT_SUBMIT_ON_CHANGE,
"size=\"3\" class=\"INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());

View File

@ -211,6 +211,7 @@ static void CrsCfg_Title (bool PutLink)
static void CrsCfg_Degree (bool PrintView,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Degree;
unsigned NumDeg;
@ -218,7 +219,7 @@ static void CrsCfg_Degree (bool PrintView,bool PutForm)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthDegCod" :
Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthDegCod] :
NULL,
Txt_Degree);

View File

@ -1095,7 +1095,7 @@ static void Deg_ReceiveFormRequestOrCreateDeg (Hie_Status_t Status)
Par_GetParToText ("FullName" ,Deg_EditingDeg->FullName,Cns_HIERARCHY_MAX_BYTES_FULL_NAME);
/* Get degree type */
Deg_EditingDeg->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
Deg_EditingDeg->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod);
/* Get degree WWW */
Par_GetParToText ("WWW",Deg_EditingDeg->WWW,Cns_MAX_BYTES_WWW);
@ -1415,7 +1415,7 @@ void Deg_ChangeDegreeType (void)
Deg_EditingDeg->DegCod = Hie_GetAndCheckParamOtherHieCod (1L);
/* Get the new degree type */
NewDegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
NewDegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod);
/***** Get data of degree *****/
Deg_GetDataOfDegreeByCod (Deg_EditingDeg);

View File

@ -206,6 +206,7 @@ static void DegCfg_Title (bool PutLink)
static void DegCfg_Center (bool PrintView,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Center;
unsigned NumCtr;
@ -213,7 +214,7 @@ static void DegCfg_Center (bool PrintView,bool PutForm)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthCtrCod" :
Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthCtrCod] :
NULL,
Txt_Center);

View File

@ -700,7 +700,7 @@ void DegTyp_RemoveDegreeType (void)
DegTyp_EditingDegreeTypeConstructor ();
/***** Get the code of the degree type *****/
DegTyp_EditingDegTyp->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
DegTyp_EditingDegTyp->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod);
/***** Get data of the degree type from database *****/
if (!DegTyp_GetDataOfDegreeTypeByCod (DegTyp_EditingDegTyp))
@ -729,22 +729,7 @@ void DegTyp_RemoveDegreeType (void)
static void DegTyp_PutParamOtherDegTypCod (void *DegTypCod)
{
if (DegTypCod)
Par_PutHiddenParamLong (NULL,"OthDegTypCod",*((long *) DegTypCod));
}
/*****************************************************************************/
/******************* Get parameter with code of degree type ******************/
/*****************************************************************************/
long DegTyp_GetAndCheckParamOtherDegTypCod (long MinCodAllowed)
{
long DegTypCod;
/***** Get and check parameter with code of degree type *****/
if ((DegTypCod = Par_GetParToLong ("OthDegTypCod")) < MinCodAllowed)
Err_WrongDegTypExit ();
return DegTypCod;
Par_PutParCod (Par_OthDegTypCod,*((long *) DegTypCod));
}
/*****************************************************************************/
@ -825,7 +810,7 @@ void DegTyp_RenameDegreeType (void)
/***** Get parameters from form *****/
/* Get the code of the degree type */
DegTyp_EditingDegTyp->DegTypCod = DegTyp_GetAndCheckParamOtherDegTypCod (1);
DegTyp_EditingDegTyp->DegTypCod = Par_GetAndCheckParCode (Par_OthDegTypCod);
/* Get the new name for the degree type */
Par_GetParToText ("DegTypName",NewNameDegTyp,DegTyp_MAX_BYTES_DEGREE_TYPE_NAME);

View File

@ -83,8 +83,6 @@ void DegTyp_ReceiveFormNewDegreeType (void);
void DegTyp_RemoveDegreeType (void);
long DegTyp_GetAndCheckParamOtherDegTypCod (long MinCodAllowed);
bool DegTyp_GetDataOfDegreeTypeByCod (struct DegTyp_DegreeType *DegTyp);
void DegTyp_RenameDegreeType (void);

View File

@ -556,23 +556,10 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm
static void Dpt_PutParamDptCod (void *DptCod)
{
extern const char *Par_CodeStr[];
if (DptCod)
Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,*((long *) DptCod));
}
/*****************************************************************************/
/******************* Get parameter with code of department *******************/
/*****************************************************************************/
long Dpt_GetAndCheckParamDptCod (long MinCodAllowed)
{
long DptCod;
/***** Get and check parameter with code of department *****/
if ((DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME)) < MinCodAllowed)
Err_WrongDepartmentExit ();
return DptCod;
Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_DptCod],*((long *) DptCod));
}
/*****************************************************************************/
@ -588,7 +575,7 @@ void Dpt_RemoveDepartment (void)
Dpt_EditingDepartmentConstructor ();
/***** Get department code *****/
Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1);
Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod);
/***** Get data of the department from database *****/
Dpt_GetDataOfDepartmentByCod (Dpt_EditingDpt);
@ -623,7 +610,7 @@ void Dpt_ChangeDepartIns (void)
/***** Get parameters from form *****/
/* Get the code of the department */
Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1);
Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod);
/* Get parameter with institution code */
NewInsCod = Par_GetAndCheckParCode (Par_OthInsCod);
@ -698,7 +685,7 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
/***** Get parameters from form *****/
/* Get the code of the department */
Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1);
Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod);
/* Get the new name for the department */
Par_GetParToText (ParamName,NewDptName,MaxBytes);
@ -754,7 +741,7 @@ void Dpt_ChangeDptWWW (void)
/***** Get parameters from form *****/
/* Get the code of the department */
Dpt_EditingDpt->DptCod = Dpt_GetAndCheckParamDptCod (1);
Dpt_EditingDpt->DptCod = Par_GetAndCheckParCode (Par_DptCod);
/* Get the new WWW for the department */
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);

View File

@ -51,8 +51,6 @@ typedef enum
} Dpt_Order_t;
#define Dpt_ORDER_DEFAULT Dpt_ORDER_BY_DEPARTMENT
#define Dpt_PARAM_DPT_COD_NAME "DptCod"
struct Dpt_Departments
{
unsigned Num; // Number of departments
@ -68,7 +66,6 @@ void Dpt_SeeDepts (void);
void Dpt_EditDepartments (void);
void Dpt_FreeListDepartments (struct Dpt_Departments *Departments);
void Dpt_GetDataOfDepartmentByCod (struct Dpt_Department *Dpt);
long Dpt_GetAndCheckParamDptCod (long MinCodAllowed);
void Dpt_RemoveDepartment (void);
void Dpt_ChangeDepartIns (void);
void Dpt_RenameDepartShort (void);

View File

@ -198,7 +198,7 @@ void Exa_SeeAllExams (void)
Exa_ResetExams (&Exams);
/***** Get parameters *****/
Exa_GetParams (&Exams);
Exa_GetParams (&Exams,false); // Don't check exam code
/***** Show all exams *****/
Exa_ListAllExams (&Exams);
@ -413,9 +413,7 @@ void Exa_SeeOneExam (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
/***** Get exam data *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -718,8 +716,7 @@ void Exa_PutParams (void *Exams)
if (Exams)
{
if (((struct Exa_Exams *) Exams)->Exam.ExaCod > 0)
Exa_PutParamExamCod (((struct Exa_Exams *) Exams)->Exam.ExaCod);
Par_PutParCod (Par_ExaCod,((struct Exa_Exams *) Exams)->Exam.ExaCod);
Exa_PutHiddenParamOrder (((struct Exa_Exams *) Exams)->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -727,38 +724,24 @@ void Exa_PutParams (void *Exams)
}
}
/*****************************************************************************/
/******************** Write parameter with code of exam **********************/
/*****************************************************************************/
void Exa_PutParamExamCod (long ExaCod)
{
if (ExaCod > 0)
Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod);
}
/*****************************************************************************/
/********************* Get parameter with code of exam ***********************/
/*****************************************************************************/
long Exa_GetParamExamCod (void)
{
/***** Get code of exam *****/
return Par_GetParToLong ("ExaCod");
}
/*****************************************************************************/
/******************* Get parameters used to edit an exam **********************/
/*****************************************************************************/
void Exa_GetParams (struct Exa_Exams *Exams)
void Exa_GetParams (struct Exa_Exams *Exams,bool CheckExaCod)
{
long (*GetExaCo[2]) (Par_Code_t ParamCode) =
{
[false] = Par_GetParCode,
[true ] = Par_GetAndCheckParCode,
};
/***** Get other parameters *****/
Exams->SelectedOrder = Exa_GetParamOrder ();
Exams->CurrentPage = Pag_GetParamPagNum (Pag_EXAMS);
/***** Get exam code *****/
Exams->Exam.ExaCod = Exa_GetParamExamCod ();
Exams->Exam.ExaCod = GetExaCo[CheckExaCod] (Par_ExaCod);
}
/*****************************************************************************/
@ -829,6 +812,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
{
extern const char *Par_CodeStr[];
unsigned MaxSizeListExaCodsSelected;
unsigned NumExam;
const char *Ptr;
@ -841,7 +825,8 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
Err_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of exams selected *****/
Par_GetParMultiToText ("ExaCod",Exams->ExaCodsSelected,MaxSizeListExaCodsSelected);
Par_GetParMultiToText (Par_CodeStr[Par_ExaCod],Exams->ExaCodsSelected,
MaxSizeListExaCodsSelected);
/***** Set which exams will be shown as selected (checkboxes on) *****/
if (Exams->ExaCodsSelected[0]) // Some exams selected
@ -1005,9 +990,7 @@ void Exa_AskRemExam (void)
Exa_ResetExam (&Exams.Exam);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
/***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -1041,8 +1024,7 @@ void Exa_RemoveExam (void)
Exa_ResetExam (&Exams.Exam);
/***** Get exam code *****/
if ((Exams.Exam.ExaCod = Exa_GetParamExamCod ()) <= 0)
Err_WrongExamExit ();
Exams.Exam.ExaCod = Par_GetAndCheckParCode (Par_ExaCod);
/***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -1230,9 +1212,7 @@ static void Exa_HideUnhideExam (bool Hide)
Exa_ResetExam (&Exams.Exam);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
/***** Get data of the exam from database *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -1264,7 +1244,7 @@ void Exa_RequestCreatOrEditExam (void)
ExaSet_ResetSet (&Set);
/***** Get parameters *****/
Exa_GetParams (&Exams);
Exa_GetParams (&Exams,false); // Don't check exam code
ItsANewExam = (Exams.Exam.ExaCod <= 0);
/***** Get exam data *****/
@ -1437,7 +1417,7 @@ void Exa_ReceiveFormExam (void)
ExaSet_ResetSet (&Set);
/***** Get parameters *****/
Exa_GetParams (&Exams);
Exa_GetParams (&Exams,false); // Don't check exam code
ItsANewExam = (Exams.Exam.ExaCod <= 0);
/***** Get all current exam data from database *****/

View File

@ -52,9 +52,7 @@ void Exa_ShowOnlyOneExamEnd (void);
void Exa_SetCurrentExaCod (long ExaCod);
void Exa_PutParams (void *Exams);
void Exa_PutParamExamCod (long ExaCod);
long Exa_GetParamExamCod (void);
void Exa_GetParams (struct Exa_Exams *Exams);
void Exa_GetParams (struct Exa_Exams *Exams,bool CheckExaCod);
void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder);
void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams);

View File

@ -971,7 +971,7 @@ void ExaPrn_ReceivePrintAnswer (void)
ExaSes_ResetSession (&Session);
/***** Get session code *****/
Print.SesCod = ExaSes_GetParamSesCod ();
Print.SesCod = Par_GetAndCheckParCode (Par_SesCod);
/***** Get print data *****/
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;

View File

@ -32,6 +32,7 @@
#include "swad_exam_database.h"
#include "swad_exam_resource.h"
#include "swad_form.h"
#include "swad_parameter.h"
#include "swad_program_database.h"
/*****************************************************************************/
@ -48,7 +49,7 @@ void ExaRsc_GetLinkToExam (void)
Exa_ResetExams (&Exams);
/***** Get parameters *****/
Exa_GetParams (&Exams);
Exa_GetParams (&Exams,true);
/***** Get exam title *****/
ExaRsc_GetTitleFromExaCod (Exams.Exam.ExaCod,Title,sizeof (Title) - 1);
@ -84,7 +85,7 @@ void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo,
NextAction = (ExaCod > 0) ? ActSeeExa : // Exam specified
ActSeeAllExa; // All exams
Frm_BeginForm (NextAction);
Exa_PutParamExamCod (ExaCod);
Par_PutParCod (Par_ExaCod,ExaCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LM BT_LINK PRG_LNK_%s\"",
The_GetSuffix ());

View File

@ -194,9 +194,7 @@ void ExaRes_ShowMyResultsInExa (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
/***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -244,11 +242,8 @@ void ExaRes_ShowMyResultsInSes (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0)
Err_WrongExamSessionExit ();
Exa_GetParams (&Exams,true);
Session.SesCod = Par_GetAndCheckParCode (Par_SesCod);
Exa_GetDataOfExamByCod (&Exams.Exam);
ExaSes_GetDataOfSessionByCod (&Session);
@ -393,9 +388,7 @@ void ExaRes_ShowAllResultsInExa (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
Exa_GetDataOfExamByCod (&Exams.Exam);
/***** Exam begin *****/
@ -463,11 +456,8 @@ void ExaRes_ShowAllResultsInSes (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0)
Err_WrongExamSessionExit ();
Exa_GetParams (&Exams,true);
Session.SesCod = Par_GetAndCheckParCode (Par_SesCod);
/***** Get exam data and session *****/
Exa_GetDataOfExamByCod (&Exams.Exam);
@ -570,6 +560,7 @@ static void ExaRes_ShowResultsEnd (void)
static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Exams;
extern const char *Txt_Exam;
extern const char *Txt_Update_results;
@ -614,7 +605,7 @@ static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams)
HTM_TD_Begin ("class=\"CT DAT_%s %s\"",
The_GetSuffix (),
The_GetColorRows ());
HTM_INPUT_CHECKBOX ("ExaCod",HTM_DONT_SUBMIT_ON_CHANGE,
HTM_INPUT_CHECKBOX (Par_CodeStr[Par_ExaCod],HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Gam%u\" value=\"%ld\"%s",
NumExam,Exams->Lst[NumExam].ExaCod,
Exams->Lst[NumExam].Selected ? " checked=\"checked\"" :

View File

@ -521,7 +521,7 @@ static void ExaSes_ListOneOrMoreSessionsTitleGrps (struct Exa_Exams *Exams,
{
Frm_BeginForm (ActSeeExaPrn);
Exa_PutParams (Exams);
ExaSes_PutParamSesCod (Session->SesCod);
Par_PutParCod (Par_SesCod,Session->SesCod);
HTM_BUTTON_Submit_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play :
Txt_Resume,
"class=\"LT BT_LINK %s_%s\"",
@ -926,19 +926,10 @@ void ExaSes_PutParamsEdit (void *Exams)
if (Exams)
{
Exa_PutParams (Exams);
ExaSes_PutParamSesCod (((struct Exa_Exams *) Exams)->SesCod);
Par_PutParCod (Par_SesCod,((struct Exa_Exams *) Exams)->SesCod);
}
}
/*****************************************************************************/
/**************** Write parameter with code of exam session ******************/
/*****************************************************************************/
void ExaSes_PutParamSesCod (long SesCod)
{
Par_PutHiddenParamLong (NULL,"SesCod",SesCod);
}
/*****************************************************************************/
/************************** Get and check parameters *************************/
/*****************************************************************************/
@ -947,12 +938,9 @@ void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams,
struct ExaSes_Session *Session)
{
/***** Get parameters *****/
Exa_GetParams (Exams);
if (Exams->Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (Exams,true);
Grp_GetParamWhichGroups ();
if ((Session->SesCod = ExaSes_GetParamSesCod ()) <= 0)
Err_WrongExamSessionExit ();
Session->SesCod = Par_GetAndCheckParCode (Par_SesCod);
/***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exams->Exam);
@ -966,16 +954,6 @@ void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams,
Exams->SesCod = Session->SesCod;
}
/*****************************************************************************/
/**************** Get parameter with code of exam session ********************/
/*****************************************************************************/
long ExaSes_GetParamSesCod (void)
{
/***** Get code of exam session *****/
return Par_GetParToLong ("SesCod");
}
/*****************************************************************************/
/* Put a big button to play exam session (start a new session) as a teacher **/
/*****************************************************************************/
@ -1000,9 +978,9 @@ static void ExaSes_PutFormSession (const struct ExaSes_Session *Session)
/***** Begin form *****/
Frm_BeginForm (ItsANewSession ? ActNewExaSes : // New session
ActChgExaSes); // Existing session
Exa_PutParamExamCod (Session->ExaCod);
Par_PutParCod (Par_ExaCod,Session->ExaCod);
if (!ItsANewSession) // Existing session
ExaSes_PutParamSesCod (Session->SesCod);
Par_PutParCod (Par_SesCod,Session->SesCod);
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,ItsANewSession ? Txt_New_session :
@ -1084,8 +1062,10 @@ static void ExaSes_ShowLstGrpsToCreateSession (long SesCod)
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\"%s"
" onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_DB_CheckIfAssociatedToGrps ("exa_groups","SesCod",SesCod) ? "" :
" checked=\"checked\"");
Grp_DB_CheckIfAssociatedToGrps ("exa_groups",
Par_SesCod,
SesCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s&nbsp;%s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -1140,11 +1120,9 @@ void ExaSes_RequestCreatOrEditSes (void)
ExaSes_ResetSession (&Session);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
Grp_GetParamWhichGroups ();
Session.SesCod = ExaSes_GetParamSesCod ();
Session.SesCod = Par_GetParCode (Par_SesCod);
ItsANewSession = (Session.SesCod <= 0);
/***** Get exam data from database *****/
@ -1188,11 +1166,9 @@ void ExaSes_ReceiveFormSession (void)
ExaSes_ResetSession (&Session);
/***** Get main parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
Grp_GetParamWhichGroups ();
Session.SesCod = ExaSes_GetParamSesCod ();
Session.SesCod = Par_GetParCode (Par_SesCod);
ItsANewSession = (Session.SesCod <= 0);
/***** Get exam data from database *****/

View File

@ -64,10 +64,8 @@ void ExaSes_HideSession (void);
void ExaSes_UnhideSession (void);
void ExaSes_PutParamsEdit (void *Exams);
void ExaSes_PutParamSesCod (long SesCod);
void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams,
struct ExaSes_Session *Session);
long ExaSes_GetParamSesCod (void);
void ExaSes_PutButtonNewSession (struct Exa_Exams *Exams);
void ExaSes_RequestCreatOrEditSes (void);

View File

@ -116,9 +116,6 @@ static void ExaSet_ChangeValidityQst (Qst_Validity_t Valid);
static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
struct ExaSet_Set *Set);
static long ExaSet_GetParamQstCod (void);
static void ExaSet_PutParamQstCod (void *QstCod); // Should be a pointer to long
static void ExaSet_ExchangeSets (long ExaCod,
unsigned SetIndTop,unsigned SetIndBottom);
@ -145,17 +142,7 @@ void ExaSet_PutParamsOneSet (void *Exams)
static void ExaSet_PutParamsOneQst (void *Exams)
{
ExaSet_PutParamsOneSet (Exams);
ExaSet_PutParamQstCod (&(((struct Exa_Exams *) Exams)->QstCod));
}
/*****************************************************************************/
/********************** Get parameter with code of set ***********************/
/*****************************************************************************/
long ExaSet_GetParamSetCod (void)
{
/***** Get code of set *****/
return Par_GetParToLong ("SetCod");
Qst_PutParamQstCod (&(((struct Exa_Exams *) Exams)->QstCod));
}
/*****************************************************************************/
@ -295,11 +282,9 @@ void ExaSet_ReceiveFormSet (void)
ExaSet_ResetSet (&Set);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (&Exams,true);
Set.ExaCod = Exams.Exam.ExaCod;
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
Exams.SetCod = Set.SetCod = Par_GetParCode (Par_SesCod);
ItsANewSet = (Set.SetCod <= 0);
/***** Get exam data from database *****/
@ -516,10 +501,8 @@ void ExaSet_RequestCreatOrEditSet (void)
ExaSet_ResetSet (&Set);
/***** Get parameters *****/
Exa_GetParams (&Exams);
if (Exams.Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
Exa_GetParams (&Exams,true);
Exams.SetCod = Set.SetCod = Par_GetParCode (Par_SesCod);
ItsANewSet = (Set.SetCod <= 0);
/***** Get exam data from database *****/
@ -1548,8 +1531,8 @@ void ExaSet_RequestRemoveQstFromSet (void)
/***** Get and check parameters *****/
ExaSet_GetAndCheckParameters (&Exams,&Set);
/***** Get question index *****/
Exams.QstCod = ExaSet_GetParamQstCod ();
/***** Get question code *****/
Exams.QstCod = Par_GetAndCheckParCode (Par_QstCod);
/***** Build anchor string *****/
Frm_SetAnchorStr (Set.SetCod,&Anchor);
@ -1588,8 +1571,8 @@ void ExaSet_RemoveQstFromSet (void)
/***** Get and check parameters *****/
ExaSet_GetAndCheckParameters (&Exams,&Set);
/***** Get question index *****/
QstCod = ExaSet_GetParamQstCod ();
/***** Get question code *****/
QstCod = Par_GetAndCheckParCode (Par_QstCod);
/***** Remove media associated to question *****/
ExaSet_RemoveMediaFromStemOfQst (QstCod,Set.SetCod);
@ -1669,8 +1652,8 @@ static void ExaSet_ChangeValidityQst (Qst_Validity_t Validity)
/***** Get and check parameters *****/
ExaSet_GetAndCheckParameters (&Exams,&Set);
/***** Get question index *****/
QstCod = ExaSet_GetParamQstCod ();
/***** Get question code *****/
QstCod = Par_GetAndCheckParCode (Par_QstCod);
/***** Validate/unvalidate question *****/
Exa_DB_ChangeValidityQst (QstCod,Set.SetCod,Exams.Exam.ExaCod,Gbl.Hierarchy.Crs.CrsCod,
@ -1689,12 +1672,9 @@ static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
struct ExaSet_Set *Set)
{
/***** Get parameters *****/
Exa_GetParams (Exams);
if (Exams->Exam.ExaCod <= 0)
Err_WrongExamExit ();
Exa_GetParams (Exams,true);
Grp_GetParamWhichGroups ();
if ((Set->SetCod = ExaSet_GetParamSetCod ()) <= 0)
Err_WrongSetExit ();
Set->SetCod = Par_GetAndCheckParCode (Par_SesCod);
/***** Get exam data from database *****/
Exa_GetDataOfExamByCod (&Exams->Exam);
@ -1708,27 +1688,6 @@ static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
Exams->SetCod = Set->SetCod;
}
/*****************************************************************************/
/************ Get the parameter with the code of a test question *************/
/*****************************************************************************/
static long ExaSet_GetParamQstCod (void)
{
/***** Get code of test question *****/
return Par_GetParToLong ("QstCod");
}
/*****************************************************************************/
/************ Put parameter with question code to edit, remove... ************/
/*****************************************************************************/
static void ExaSet_PutParamQstCod (void *QstCod) // Should be a pointer to long
{
if (QstCod)
if (*((long *) QstCod) > 0) // If question exists
Par_PutHiddenParamLong (NULL,"QstCod",*((long *) QstCod));
}
/*****************************************************************************/
/*********** Exchange the order of two consecutive sets in an exam ***********/
/*****************************************************************************/

View File

@ -36,7 +36,6 @@
/*****************************************************************************/
void ExaSet_PutParamsOneSet (void *Exams);
long ExaSet_GetParamSetCod (void);
void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set);

View File

@ -330,8 +330,6 @@ static void For_PutParamsForum (void *Forums);
static void For_PutParamForumSet (For_ForumSet_t ForumSet);
static void For_PutParamForumLocation (long Location);
static void For_PutHiddenParamThrCod (long ThrCod);
static void For_PutHiddenParamPstCod (long PstCod);
static void For_PutIconsForums (__attribute__((unused)) void *Args);
static void For_PutFormWhichForums (const struct For_Forums *Forums);
@ -1143,8 +1141,8 @@ void For_PutAllHiddenParamsForum (unsigned NumPageThreads,
For_PutParamForumSet (ForumSet);
Par_PutHiddenParamOrder ((unsigned) Order);
For_PutParamForumLocation (Location);
For_PutHiddenParamThrCod (ThrCod);
For_PutHiddenParamPstCod (PstCod);
Par_PutParCod (Par_ThrCod,ThrCod);
Par_PutParCod (Par_PstCod,PstCod);
}
/*****************************************************************************/
@ -1169,26 +1167,6 @@ static void For_PutParamForumLocation (long Location)
Par_PutHiddenParamLong (NULL,"Location",Location);
}
/*****************************************************************************/
/************ Write a form parameter to specify a thread code ****************/
/*****************************************************************************/
static void For_PutHiddenParamThrCod (long ThrCod)
{
if (ThrCod > 0)
Par_PutHiddenParamLong (NULL,"ThrCod",ThrCod);
}
/*****************************************************************************/
/************* Write a form parameter to specify a post code *****************/
/*****************************************************************************/
static void For_PutHiddenParamPstCod (long PstCod)
{
if (PstCod > 0)
Par_PutHiddenParamLong (NULL,"PstCod",PstCod);
}
/*****************************************************************************/
/************************** Show list of available forums ********************/
/*****************************************************************************/
@ -2462,10 +2440,10 @@ void For_GetParamsForums (struct For_Forums *Forums)
/***** Get optional parameter with code of a selected thread *****/
Forums->Thread.Current =
Forums->Thread.Selected = Par_GetParToLong ("ThrCod");
Forums->Thread.Selected = Par_GetParCode (Par_ThrCod);
/***** Get optional parameter with code of a selected post *****/
Forums->PstCod = Par_GetParToLong ("PstCod");
Forums->PstCod = Par_GetParCode (Par_PstCod);
/***** Get which forums I want to see *****/
Forums->ForumSet = (For_ForumSet_t)

View File

@ -786,7 +786,7 @@ void Gam_PutParams (void *Games)
if (Games)
{
if (((struct Gam_Games *) Games)->Game.GamCod > 0)
Gam_PutParamGameCod (((struct Gam_Games *) Games)->Game.GamCod);
Gam_PutParamGamCod (((struct Gam_Games *) Games)->Game.GamCod);
Gam_PutHiddenParamOrder (((struct Gam_Games *) Games)->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -798,20 +798,12 @@ void Gam_PutParams (void *Games)
/******************** Write parameter with code of game **********************/
/*****************************************************************************/
void Gam_PutParamGameCod (long GamCod)
void Gam_PutParamGamCod (long GamCod)
{
extern const char *Par_CodeStr[];
if (GamCod > 0)
Par_PutHiddenParamLong (NULL,"GamCod",GamCod);
}
/*****************************************************************************/
/********************* Get parameter with code of game ***********************/
/*****************************************************************************/
long Gam_GetParamGameCod (void)
{
/***** Get code of game *****/
return Par_GetParToLong ("GamCod");
Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_GamCod],GamCod);
}
/*****************************************************************************/
@ -825,7 +817,7 @@ long Gam_GetParams (struct Gam_Games *Games)
Games->CurrentPage = Pag_GetParamPagNum (Pag_GAMES);
/***** Get game code *****/
return Gam_GetParamGameCod ();
return Par_GetParCode (Par_GamCod);
}
/*****************************************************************************/
@ -896,6 +888,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
void Gam_GetListSelectedGamCods (struct Gam_Games *Games)
{
extern const char *Par_CodeStr[];
unsigned MaxSizeListGamCodsSelected;
unsigned NumGame;
const char *Ptr;
@ -915,7 +908,8 @@ void Gam_GetListSelectedGamCods (struct Gam_Games *Games)
Err_NotEnoughMemoryExit ();
/***** Get parameter multiple with list of games selected *****/
Par_GetParMultiToText ("GamCod",Games->GamCodsSelected,MaxSizeListGamCodsSelected);
Par_GetParMultiToText (Par_CodeStr[Par_GamCod],Games->GamCodsSelected,
MaxSizeListGamCodsSelected);
/***** Set which games will be shown as selected (checkboxes on) *****/
if (Games->GamCodsSelected[0]) // Some games selected
@ -1104,8 +1098,7 @@ void Gam_RemoveGame (void)
Gam_ResetGame (&Games.Game);
/***** Get game code *****/
if ((Games.Game.GamCod = Gam_GetParamGameCod ()) <= 0)
Err_WrongGameExit ();
Games.Game.GamCod = Par_GetAndCheckParCode (Par_GamCod);
/***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Games.Game);

View File

@ -119,8 +119,7 @@ void Gam_ShowOnlyOneGameEnd (void);
void Gam_SetCurrentGamCod (long GamCod);
void Gam_PutParams (void *Games);
void Gam_PutParamGameCod (long GamCod);
long Gam_GetParamGameCod (void);
void Gam_PutParamGamCod (long GamCod);
long Gam_GetParams (struct Gam_Games *Games);
void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder);

View File

@ -85,7 +85,7 @@ void GamRsc_WriteGameInCrsProgram (long GamCod,bool PutFormToGo,
NextAction = (GamCod > 0) ? ActSeeGam : // Game specified
ActSeeAllGam; // All games
Frm_BeginForm (NextAction);
Gam_PutParamGameCod (GamCod);
Gam_PutParamGamCod (GamCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LM BT_LINK PRG_LNK_%s\"",
The_GetSuffix ());

View File

@ -1620,14 +1620,14 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,
static const struct
{
const char *Table;
const char *Field;
Par_Code_t ParamCode;
} AssociationsToGrps[Grp_NUM_ASSOCIATIONS_TO_GROUPS] =
{
[Grp_ASSIGNMENT] = {"asg_groups","AsgCod"},
[Grp_ATT_EVENT ] = {"att_groups","AttCod"},
[Grp_SURVEY ] = {"svy_groups","SvyCod"},
[Grp_EXA_EVENT ] = {"exa_groups","SesCod"},
[Grp_MATCH ] = {"mch_groups","MchCod"},
[Grp_ASSIGNMENT] = {"asg_groups",Par_AsgCod},
[Grp_ATT_EVENT ] = {"att_groups",Par_AttCod},
[Grp_SURVEY ] = {"svy_groups",Par_SvyCod},
[Grp_EXA_EVENT ] = {"exa_groups",Par_SesCod},
[Grp_MATCH ] = {"mch_groups",Par_MchCod},
};
struct ListCodGrps LstGrpsIBelong;
unsigned NumGrpThisType;
@ -1652,7 +1652,7 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,
if (Cod > 0) // Cod == -1L means new item, assignment, event, survey, exam event or match
AssociatedToGrp = Grp_DB_CheckIfAssociatedToGrp (AssociationsToGrps[WhichIsAssociatedToGrp].Table,
AssociationsToGrps[WhichIsAssociatedToGrp].Field,
AssociationsToGrps[WhichIsAssociatedToGrp].ParamCode,
Cod,Grp->GrpCod);
else
AssociatedToGrp = false;
@ -4177,7 +4177,7 @@ void Grp_RenameGroup (void)
static void Grp_PutParamGrpTypCod (void *GrpTypCod)
{
if (GrpTypCod)
Par_PutHiddenParamLong (NULL,"GrpTypCod",*((long *) GrpTypCod));
Par_PutParCod (Par_GrpTypCod,*((long *) GrpTypCod));
}
/*****************************************************************************/
@ -4187,7 +4187,7 @@ static void Grp_PutParamGrpTypCod (void *GrpTypCod)
void Grp_PutParamGrpCod (void *GrpCod)
{
if (GrpCod)
Par_PutHiddenParamLong (NULL,"GrpCod",*((long *) GrpCod));
Par_PutParCod (Par_GrpCod,*((long *) GrpCod));
}
/*****************************************************************************/

View File

@ -32,7 +32,7 @@
#include "swad_database.h"
#include "swad_error.h"
#include "swad_global.h"
#include "swad_group.h"
#include "swad_group_database.h"
/*****************************************************************************/
/************* External global variables from others modules *****************/
@ -679,9 +679,11 @@ long Grp_DB_GetGrpTypeFromGrp (long GrpCod)
/*********** exam session or match is associated to a given group ************/
/*****************************************************************************/
bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field,
bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,Par_Code_t ParamCode,
long Cod,long GrpCod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
return
DB_QueryEXISTS ("can not check if associated to a group",
"SELECT EXISTS"
@ -690,7 +692,7 @@ bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field,
" WHERE %s=%ld"
" AND GrpCod=%ld)",
Table,
Field,Cod,
Par_CodeStr[ParamCode],Cod,
GrpCod);
}
@ -699,8 +701,10 @@ bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field,
/************ exam session or match is associated to any group **************/
/*****************************************************************************/
bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod)
bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,Par_Code_t ParamCode,long Cod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
/***** Trivial check *****/
if (Cod <= 0) // Assignment, attendance event, survey, exam event or match code
return false;
@ -714,7 +718,7 @@ bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Co
" FROM %s"
" WHERE %s=%ld)",
Table,
Field,Cod);
Par_CodeStr[ParamCode],Cod);
}
/*****************************************************************************/

View File

@ -28,6 +28,7 @@
/*****************************************************************************/
#include "swad_group.h"
#include "swad_parameter.h"
/*****************************************************************************/
/**************************** Public prototypes ******************************/
@ -77,9 +78,9 @@ unsigned Grp_DB_GetNamesGrpsUsrBelongsTo (MYSQL_RES **mysql_res,
long Grp_DB_GetGrpTypeFromGrp (long GrpCod);
bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field,
bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,Par_Code_t ParamCode,
long Cod,long GrpCod);
bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod);
bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,Par_Code_t ParamCode,long Cod);
void Grp_DB_ChangeMandatoryEnrolmentOfAGrpTyp (long GrpTypCod,
bool NewMandatoryEnrolment);

View File

@ -97,6 +97,7 @@ static unsigned Ind_GetAndUpdateNumIndicatorsCrs (long CrsCod);
void Ind_ReqIndicatorsCourses (void)
{
extern const char *Hlp_ANALYTICS_Indicators;
extern const char *Par_CodeStr[];
extern const char *Txt_Scope;
extern const char *Txt_Types_of_degree;
extern const char *Txt_only_if_the_scope_is_X;
@ -143,7 +144,7 @@ void Ind_ReqIndicatorsCourses (void)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT","OthDegTypCod",Txt_Types_of_degree);
Frm_LabelColumn ("RT",Par_CodeStr[Par_OthDegTypCod],Txt_Types_of_degree);
/* Data */
HTM_TD_Begin ("class=\"LT DAT_%s\"",The_GetSuffix ());
@ -159,7 +160,7 @@ void Ind_ReqIndicatorsCourses (void)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",Dpt_PARAM_DPT_COD_NAME,Txt_Department);
Frm_LabelColumn ("RT",Par_CodeStr[Par_DptCod],Txt_Department);
/* Data */
HTM_TD_Begin ("class=\"LT\"");
@ -168,7 +169,7 @@ void Ind_ReqIndicatorsCourses (void)
Err_NotEnoughMemoryExit ();
Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current insitution
Indicators.DptCod, // Selected department
Dpt_PARAM_DPT_COD_NAME, // Parameter name
Par_CodeStr[Par_DptCod], // Parameter name
SelectClass, // Selector class
-1L, // First option
Txt_Any_department, // Text when no department selected
@ -220,8 +221,8 @@ void Ind_ReqIndicatorsCourses (void)
/* Button to show more details */
Frm_BeginForm (ActSeeAllStaCrs);
Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current);
Par_PutHiddenParamLong (NULL,"OthDegTypCod",Indicators.DegTypCod);
Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,Indicators.DptCod);
Par_PutParCod (Par_OthDegTypCod,Indicators.DegTypCod);
Par_PutParCod (Par_DptCod ,Indicators.DptCod );
if (Indicators.StrIndicatorsSelected[0])
Par_PutHiddenParamString (NULL,"Indicators",Indicators.StrIndicatorsSelected);
Btn_PutConfirmButton (Txt_Show_more_details);
@ -253,11 +254,11 @@ static void Ind_GetParamsIndicators (struct Ind_Indicators *Indicators)
/***** Get degree type code *****/
Indicators->DegTypCod = (Gbl.Scope.Current == HieLvl_SYS) ?
DegTyp_GetAndCheckParamOtherDegTypCod (-1L) : // -1L (any degree type) is allowed here
Par_GetParCode (Par_OthDegTypCod) : // -1L (any degree type) is allowed here
-1L;
/***** Get department code *****/
Indicators->DptCod = Dpt_GetAndCheckParamDptCod (-1L); // -1L (any department) is allowed here
Indicators->DptCod = Par_GetParCode (Par_DptCod); // -1L (any department) is allowed here
/***** Get number of indicators *****/
Ind_GetParamNumIndicators (Indicators);
@ -381,11 +382,13 @@ static void Ind_PutButtonToConfirmIWantToSeeBigList (struct Ind_Indicators *Indi
static void Ind_PutParamsConfirmIWantToSeeBigList (void *Indicators)
{
extern const char *Par_CodeStr[];
if (Indicators)
{
Sco_PutParamScope ("ScopeInd",Gbl.Scope.Current);
Par_PutHiddenParamLong (NULL,"OthDegTypCod",((struct Ind_Indicators *) Indicators)->DegTypCod);
Par_PutHiddenParamLong (NULL,Dpt_PARAM_DPT_COD_NAME,((struct Ind_Indicators *) Indicators)->DptCod);
Par_PutParCod (Par_OthDegTypCod,((struct Ind_Indicators *) Indicators)->DegTypCod);
Par_PutParCod (Par_DptCod ,((struct Ind_Indicators *) Indicators)->DptCod );
if (((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected[0])
Par_PutHiddenParamString (NULL,"Indicators",((struct Ind_Indicators *) Indicators)->StrIndicatorsSelected);
Par_PutHiddenParamChar ("ShowBigList",'Y');

View File

@ -306,6 +306,7 @@ static void InsCfg_Map (void)
static void InsCfg_Country (bool PrintView,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Country;
unsigned NumCty;
@ -316,7 +317,7 @@ static void InsCfg_Country (bool PrintView,bool PutForm)
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",PutForm ? "OthCtyCod" :
Frm_LabelColumn ("RT",PutForm ? Par_CodeStr[Par_OthCtyCod] :
NULL,
Txt_Country);

View File

@ -124,7 +124,6 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
struct Mch_Match *Match);
static void Mch_PutParamsPlay (void *MchCod);
static void Mch_PutParamMchCod (long MchCod);
static void Mch_PutFormExistingMatch (struct Gam_Games *Games,
const struct Mch_Match *Match,
@ -632,7 +631,7 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match,
/***** Match title *****/
Frm_BeginForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch :
ActResMch);
Mch_PutParamMchCod (Match->MchCod);
Par_PutParCod (Par_MchCod,Match->MchCod);
HTM_BUTTON_Submit_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play :
Txt_Resume,
@ -1122,7 +1121,7 @@ void Mch_PutParamsEdit (void *Games)
if (Games)
{
Gam_PutParams (Games);
Mch_PutParamMchCod (((struct Gam_Games *) Games)->MchCod.Current);
Par_PutParCod (Par_MchCod,((struct Gam_Games *) Games)->MchCod.Current);
}
}
@ -1133,19 +1132,7 @@ void Mch_PutParamsEdit (void *Games)
static void Mch_PutParamsPlay (void *MchCod)
{
if (MchCod)
{
if (*((long *) MchCod) > 0)
Mch_PutParamMchCod (*((long *) MchCod));
}
}
/*****************************************************************************/
/******************** Write parameter with code of match **********************/
/*****************************************************************************/
static void Mch_PutParamMchCod (long MchCod)
{
Par_PutHiddenParamLong (NULL,"MchCod",MchCod);
Par_PutParCod (Par_MchCod,*((long *) MchCod));
}
/*****************************************************************************/
@ -1163,8 +1150,7 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games,
Gam_GetDataOfGameByCod (&Games->Game);
/* Get match code */
if ((Match->MchCod = Mch_GetParamMchCod ()) <= 0)
Err_WrongMatchExit ();
Match->MchCod = Par_GetAndCheckParCode (Par_MchCod);
Mch_GetDataOfMatchByCod (Match);
/***** Ensure parameters are correct *****/
@ -1178,16 +1164,6 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games,
Games->MchCod.Selected = Match->MchCod;
}
/*****************************************************************************/
/********************* Get parameter with code of match **********************/
/*****************************************************************************/
long Mch_GetParamMchCod (void)
{
/***** Get code of match *****/
return Par_GetParToLong ("MchCod");
}
/*****************************************************************************/
/******************* Put a form to change and existing match *****************/
/*****************************************************************************/
@ -1258,7 +1234,7 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
/***** Begin form *****/
Frm_BeginForm (ActNewMch);
Gam_PutParamGameCod (Game->GamCod);
Gam_PutParamGamCod (Game->GamCod);
Gam_PutParamQstInd (0); // Start by first question in game
/***** Begin box and table *****/
@ -1341,8 +1317,10 @@ static void Mch_ShowLstGrpsToEditMatch (long MchCod)
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\"%s"
" onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_DB_CheckIfAssociatedToGrps ("mch_groups","MchCod",MchCod) ? "" :
" checked=\"checked\"");
Grp_DB_CheckIfAssociatedToGrps ("mch_groups",
Par_MchCod,
MchCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s&nbsp;%s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -1380,8 +1358,7 @@ void Mch_CreateNewMatch (void)
/***** Get form parameters *****/
/* Get match code */
if ((GamCod = Gam_GetParamGameCod ()) < 0)
Err_WrongGameExit ();
GamCod = Par_GetAndCheckParCode (Par_GamCod);
/* Get match title */
Par_GetParToText ("Title",Title,Mch_MAX_BYTES_TITLE);
@ -2621,7 +2598,7 @@ static void Mch_ShowFormColumns (const struct Mch_Match *Match)
/* Begin form */
Frm_BeginForm (ActChgNumColMch);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played
Mch_PutParamNumCols (NumCols); // Number of columns
/* Number of columns */
@ -2666,7 +2643,7 @@ static void Mch_PutCheckboxResult (const struct Mch_Match *Match)
/***** Begin form *****/
Frm_BeginForm (ActChgVisResMchQst);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played
/***** Put icon with link *****/
HTM_BUTTON_Submit_Begin (Txt_View_results,
@ -2704,7 +2681,7 @@ static void Mch_PutIfAnswered (const struct Mch_Match *Match,bool Answered)
{
/* Begin form */
Frm_BeginForm (ActSeeMchAnsQstStd);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played
HTM_BUTTON_Submit_Begin (Txt_View_my_answer,
"class=\"BT_LINK DAT_SMALL_GREEN_%s\""
@ -2749,7 +2726,7 @@ static void Mch_PutIconToRemoveMyAnswer (const struct Mch_Match *Match)
/***** Begin form *****/
Frm_BeginForm (ActRemMchAnsQstStd);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
/***** Put icon with link *****/
@ -3005,7 +2982,7 @@ static void Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match,
is necessary in order to be fast
and not lose clicks due to refresh */
Frm_BeginForm (ActAnsMchQstStd);
Mch_PutParamMchCod (Match->MchCod); // Current match being played
Par_PutParCod (Par_MchCod,Match->MchCod); // Current match being played
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
Mch_PutParamNumOpt (NumOpt); // Number of button
@ -3270,7 +3247,7 @@ static void Mch_PutBigButton (Act_Action_t NextAction,const char *Id,
{
/***** Begin form *****/
Frm_BeginFormId (NextAction,Id);
Mch_PutParamMchCod (MchCod);
Par_PutParCod (Par_MchCod,MchCod);
/***** Put icon with link *****/
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
@ -3365,8 +3342,7 @@ void Mch_GetMatchBeingPlayed (void)
long MchCodBeingPlayed;
/***** Get match code ****/
if ((MchCodBeingPlayed = Mch_GetParamMchCod ()) <= 0)
Err_WrongMatchExit ();
MchCodBeingPlayed = Par_GetAndCheckParCode (Par_MchCod);
Mch_SetMchCodBeingPlayed (MchCodBeingPlayed);
}

View File

@ -116,7 +116,6 @@ void Mch_EditMatch (void);
void Mch_PutParamsEdit (void *Games);
void Mch_GetAndCheckParameters (struct Gam_Games *Games,
struct Mch_Match *Match);
long Mch_GetParamMchCod (void);
void Mch_CreateNewMatch (void);
void Mch_ChangeMatch (void);

View File

@ -213,8 +213,7 @@ void MchRes_ShowMyMchResultsInMch (void)
/***** Get parameters *****/
if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0)
Err_WrongGameExit ();
if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0)
Err_WrongMatchExit ();
Match.MchCod = Par_GetAndCheckParCode (Par_MchCod);
Gam_GetDataOfGameByCod (&Games.Game);
Mch_GetDataOfMatchByCod (&Match);
@ -440,8 +439,7 @@ void MchRes_ShowAllMchResultsInMch (void)
/***** Get parameters *****/
if ((Games.Game.GamCod = Gam_GetParams (&Games)) <= 0)
Err_WrongGameExit ();
if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0)
Err_WrongMatchExit ();
Match.MchCod = Par_GetAndCheckParCode (Par_MchCod);
Gam_GetDataOfGameByCod (&Games.Game);
Mch_GetDataOfMatchByCod (&Match);
@ -535,6 +533,7 @@ static void MchRes_ShowResultsEnd (void)
static void MchRes_ListGamesToSelect (struct Gam_Games *Games)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Games;
extern const char *Txt_Game;
extern const char *Txt_Update_results;
@ -579,7 +578,7 @@ static void MchRes_ListGamesToSelect (struct Gam_Games *Games)
HTM_TD_Begin ("class=\"CT DAT_%s %s\"",
The_GetSuffix (),
The_GetColorRows ());
HTM_INPUT_CHECKBOX ("GamCod",HTM_DONT_SUBMIT_ON_CHANGE,
HTM_INPUT_CHECKBOX (Par_CodeStr[Par_GamCod],HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Gam%u\" value=\"%ld\"%s",
NumGame,Games->Lst[NumGame].GamCod,
Games->Lst[NumGame].Selected ? " checked=\"checked\"" :

View File

@ -93,7 +93,6 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
Not_Status_t Status);
static void Not_PutParams (void *NotCod);
static long Not_GetParamNotCod (void);
/*****************************************************************************/
/***************************** Write a new notice ****************************/
@ -203,8 +202,7 @@ void Not_ListFullNotices (void)
void Not_GetHighLightedNotCod (void)
{
/***** Get notice to be highlighted *****/
Gbl.Crs.Notices.HighlightNotCod = Not_GetParamNotCod ();
Gbl.Crs.Notices.HighlightNotCod = Par_GetParCode (Par_NotCod);
}
/*****************************************************************************/
@ -216,7 +214,7 @@ void Not_HideActiveNotice (void)
long NotCod;
/***** Get the code of the notice to hide *****/
NotCod = Not_GetParamNotCod ();
NotCod = Par_GetAndCheckParCode (Par_NotCod);
/***** Set notice as hidden *****/
Not_DB_ChangeNoticeStatus (NotCod,Not_OBSOLETE_NOTICE);
@ -237,7 +235,7 @@ void Not_RevealHiddenNotice (void)
long NotCod;
/***** Get the code of the notice to reveal *****/
NotCod = Not_GetParamNotCod ();
NotCod = Par_GetAndCheckParCode (Par_NotCod);
/***** Set notice as active *****/
Not_DB_ChangeNoticeStatus (NotCod,Not_ACTIVE_NOTICE);
@ -259,7 +257,7 @@ void Not_RequestRemNotice (void)
long NotCod;
/***** Get the code of the notice to remove *****/
NotCod = Not_GetParamNotCod ();
NotCod = Par_GetAndCheckParCode (Par_NotCod);
/***** Show question and button to remove this notice *****/
/* Begin alert */
@ -287,7 +285,7 @@ void Not_RemoveNotice (void)
long NotCod;
/***** Get the code of the notice to remove *****/
NotCod = Not_GetParamNotCod ();
NotCod = Par_GetAndCheckParCode (Par_NotCod);
/***** Remove notice *****/
/* Copy notice to table of deleted notices */
@ -602,7 +600,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
{
/* Form to view full notice */
Frm_BeginFormAnchor (ActSeeOneNot,Anchor);
Not_PutHiddenParamNotCod (NotCod);
Par_PutParCod (Par_NotCod,NotCod);
HTM_BUTTON_Submit_Begin (Txt_See_full_notice,
"class=\"RT BT_LINK\"");
}
@ -806,26 +804,7 @@ unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif)
static void Not_PutParams (void *NotCod)
{
if (NotCod)
Not_PutHiddenParamNotCod (*((long *) NotCod));
}
/*****************************************************************************/
/*************** Put parameter with the code of a notice *********************/
/*****************************************************************************/
void Not_PutHiddenParamNotCod (long NotCod)
{
Par_PutHiddenParamLong (NULL,"NotCod",NotCod);
}
/*****************************************************************************/
/*************** Get parameter with the code of a notice *********************/
/*****************************************************************************/
static long Not_GetParamNotCod (void)
{
/***** Get notice code *****/
return Par_GetParToLong ("NotCod");
Par_PutParCod (Par_NotCod,*((long *) NotCod));
}
/*****************************************************************************/

View File

@ -71,8 +71,6 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
unsigned Not_GetNumNotices (HieLvl_Level_t Scope,Not_Status_t Status,unsigned *NumNotif);
unsigned Not_GetNumNoticesDeleted (HieLvl_Level_t Scope,unsigned *NumNotif);
void Not_PutHiddenParamNotCod (long NotCod);
//-------------------------------- Figures ------------------------------------
void Not_GetAndShowNoticesStats (void);

View File

@ -714,7 +714,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
/* Begin form */
Action = ActSeeOneCfe;
Frm_BeginFormAnchor (ActSeeOneCfe,Anchor);
Cfe_PutHiddenParamExaCod (Cod);
Par_PutParCod (Par_ExaCod,Cod);
/* Free anchor string */
Frm_FreeAnchorStr (Anchor);
@ -758,9 +758,8 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
break;
}
Frm_BeginForm (Action);
if (GrpCod > 0)
Grp_PutParamGrpCod (&GrpCod);
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
Par_PutParCod (Par_GrpCod,GrpCod);
Par_PutParCod (Par_FilCod,FileMetadata.FilCod);
}
break;
case Ntf_EVENT_TML_COMMENT:
@ -770,7 +769,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
// Cod is the code of the social publishing
Action = ActSeeGblTL;
Frm_BeginForm (Action);
TmlPub_PutHiddenParamPubCod (Cod);
Par_PutParCod (Par_PubCod,Cod);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
Ntf_PutHiddenParamNotifyEvent (NotifyEvent);
break;
@ -804,7 +803,7 @@ static Act_Action_t Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
case Ntf_EVENT_NOTICE:
Action = ActSeeOneNot;
Frm_BeginForm (Action);
Not_PutHiddenParamNotCod (Cod);
Par_PutParCod (Par_NotCod,Cod);
break;
case Ntf_EVENT_MESSAGE:
Action = ActExpRcvMsg;

View File

@ -54,6 +54,36 @@ extern struct Globals Gbl;
const char *Par_SEPARATOR_PARAM_MULTIPLE = "\x0a"; // Must be 1 <= character <= 31
// Parameter name for codes, some of them also used as database fields (so change carefully)
const char *Par_CodeStr[] =
{
[Par_AgdCod ] = "AgdCod",
[Par_AnnCod ] = "AnnCod",
[Par_AsgCod ] = "AsgCod",
[Par_AttCod ] = "AttCod",
[Par_BanCod ] = "BanCod",
[Par_BldCod ] = "BldCod",
[Par_DptCod ] = "DptCod",
[Par_ExaCod ] = "ExaCod",
[Par_FilCod ] = "FilCod",
[Par_GamCod ] = "GamCod",
[Par_GrpCod ] = "GrpCod",
[Par_GrpTypCod ] = "GrpTypCod",
[Par_MchCod ] = "MchCod",
[Par_NotCod ] = "NotCod",
[Par_OthCtrCod ] = "OthCtrCod",
[Par_OthCtyCod ] = "OthCtyCod",
[Par_OthDegCod ] = "OthDegCod",
[Par_OthDegTypCod] = "OthDegTypCod",
[Par_OthInsCod ] = "OthInsCod",
[Par_PstCod ] = "PstCod",
[Par_PubCod ] = "PubCod",
[Par_QstCod ] = "QstCod",
[Par_SesCod ] = "SesCod",
[Par_SvyCod ] = "SvyCod",
[Par_ThrCod ] = "ThrCod",
};
/*****************************************************************************/
/**************************** Private constants ******************************/
/*****************************************************************************/
@ -968,24 +998,6 @@ long Par_GetAndCheckParCodeMin (Par_Code_t ParamCode,long MinCodAllowed)
long Par_GetParCode (Par_Code_t ParamCode)
{
static const char *Par_CodeStr[] =
{
[Par_AgdCod] = "AgdCod",
[Par_AnnCod] = "AnnCod",
[Par_AsgCod] = "AsgCod",
[Par_AttCod] = "AttCod",
[Par_BanCod] = "BanCod",
[Par_BldCod] = "BldCod",
[Par_ExaCod] = "ExaCod",
[Par_FilCod] = "FilCod",
[Par_GrpCod] = "GrpCod",
[Par_GrpTypCod] = "GrpTypCod",
[Par_OthCtrCod] = "OthCtrCod",
[Par_OthCtyCod] = "OthCtyCod",
[Par_OthDegCod] = "OthDegCod",
[Par_OthInsCod] = "OthInsCod",
};
return Par_GetParToLong (Par_CodeStr[ParamCode]);
}
@ -1150,6 +1162,20 @@ void Par_PutHiddenParamUnsignedDisabled (const char *Id,const char *ParamName,un
ParamName,Value);
}
/*****************************************************************************/
/******************** Put the value of a code parameter **********************/
/*****************************************************************************/
void Par_PutParCod (Par_Code_t ParamCode,long Cod)
{
extern const char *Par_CodeStr[];
// <0 => not specified => don't write parameter
if (Cod >= 0) // 0 => another country, institution, centre...
// >0 => a given country, institution, centre...
Par_PutHiddenParamLong (NULL,Par_CodeStr[ParamCode],Cod);
}
/*****************************************************************************/
/************************* Put a long hidden parameter ***********************/
/*****************************************************************************/

View File

@ -71,14 +71,25 @@ typedef enum
Par_AttCod,
Par_BanCod,
Par_BldCod,
Par_DptCod,
Par_ExaCod,
Par_FilCod,
Par_GamCod,
Par_GrpCod,
Par_GrpTypCod,
Par_MchCod,
Par_NotCod,
Par_OthCtrCod,
Par_OthCtyCod,
Par_OthDegCod,
Par_OthDegTypCod,
Par_OthInsCod,
Par_PstCod,
Par_PubCod,
Par_QstCod,
Par_SesCod,
Par_SvyCod,
Par_ThrCod,
} Par_Code_t;
/*****************************************************************************/
@ -118,6 +129,7 @@ void Par_ReplaceSeparatorMultipleByComma (char *Str);
void Par_PutHiddenParamUnsigned (const char *Id,const char *ParamName,unsigned Value);
void Par_PutHiddenParamUnsignedDisabled (const char *Id,const char *ParamName,unsigned Value);
void Par_PutParCod (Par_Code_t ParamCode,long Cod);
void Par_PutHiddenParamLong (const char *Id,const char *ParamName,long Value);
void Par_PutHiddenParamChar (const char *ParamName,char Value);
void Par_PutHiddenParamString (const char *Id,const char *ParamName,

View File

@ -3740,6 +3740,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects,
{
extern const char *Hlp_ASSESSMENT_Projects_new_project;
extern const char *Hlp_ASSESSMENT_Projects_edit_project;
extern const char *Par_CodeStr[];
extern const char *Txt_New_project;
extern const char *Txt_Edit_project;
extern const char *Txt_Data;
@ -3825,7 +3826,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects,
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT",Dpt_PARAM_DPT_COD_NAME,Txt_Department);
Frm_LabelColumn ("RT",Par_CodeStr[Par_DptCod],Txt_Department);
/* Data */
HTM_TD_Begin ("class=\"LT\"");
@ -3834,7 +3835,7 @@ static void Prj_PutFormProject (struct Prj_Projects *Projects,
Err_NotEnoughMemoryExit ();
Dpt_WriteSelectorDepartment (Gbl.Hierarchy.Ins.InsCod, // Departments in current institution
Projects->Prj.DptCod, // Selected department
Dpt_PARAM_DPT_COD_NAME, // Parameter name
Par_CodeStr[Par_DptCod], // Parameter name
SelectClass, // Selector class
0, // First option
Txt_Another_department, // Text when no department selected
@ -4031,6 +4032,7 @@ void Prj_FreeMemProject (struct Prj_Project *Prj)
void Prj_ReceiveFormProject (void)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Created_new_project_X;
extern const char *Txt_The_project_has_been_modified;
struct Prj_Projects Projects;
@ -4069,7 +4071,7 @@ void Prj_ReceiveFormProject (void)
Par_GetParToText ("Title",Projects.Prj.Title,Prj_MAX_BYTES_TITLE);
/* Get department */
Projects.Prj.DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME);
Projects.Prj.DptCod = Par_GetParToLong (Par_CodeStr[Par_DptCod]);
/* Get whether the project is assigned */
Projects.Prj.Assigned = (Par_GetParToBool ("Assigned")) ? Prj_ASSIGNED :

View File

@ -1817,11 +1817,11 @@ void Qst_ShowFormEditOneQst (void)
Qst_QstConstructor (&Question);
/***** Get question data *****/
Question.QstCod = Qst_GetParamQstCod ();
if (Question.QstCod > 0) // Question already exists in the database
PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question);
else // New question
Question.QstCod = Par_GetParCode (Par_QstCod);
if (Question.QstCod <= 0) // New question
PutFormToEditQuestion = true;
else
PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question);
/***** Put form to edit question *****/
if (PutFormToEditQuestion)
@ -2724,7 +2724,7 @@ void Qst_GetQstFromForm (struct Qst_Question *Question)
unsigned NumCorrectAns;
/***** Get question code *****/
Question->QstCod = Qst_GetParamQstCod ();
Question->QstCod = Par_GetParCode (Par_QstCod);
/***** Get answer type *****/
Question->Answer.Type = (Qst_AnswerType_t)
@ -3330,9 +3330,7 @@ void Qst_RequestRemoveOneQst (void)
/***** Get main parameters from form *****/
/* Get the question code */
Questions.Question.QstCod = Qst_GetParamQstCod ();
if (Questions.Question.QstCod <= 0)
Err_WrongQuestionExit ();
Questions.Question.QstCod = Par_GetAndCheckParCode (Par_QstCod);
/* Get a parameter that indicates whether it's necessary
to continue listing the rest of questions */
@ -3391,9 +3389,7 @@ void Qst_RemoveOneQst (void)
bool EditingOnlyThisQst;
/***** Get the question code *****/
QstCod = Qst_GetParamQstCod ();
if (QstCod <= 0)
Err_WrongQuestionExit ();
QstCod = Par_GetAndCheckParCode (Par_QstCod);
/***** Get a parameter that indicates whether it's necessary
to continue listing the rest of questions ******/
@ -3446,9 +3442,7 @@ void Qst_ChangeShuffleQst (void)
Qst_Constructor (&Questions);
/***** Get the question code *****/
Questions.Question.QstCod = Qst_GetParamQstCod ();
if (Questions.Question.QstCod <= 0)
Err_WrongQuestionExit ();
Questions.Question.QstCod = Par_GetAndCheckParCode (Par_QstCod);
/***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/
EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst");
@ -3474,25 +3468,17 @@ void Qst_ChangeShuffleQst (void)
Qst_Destructor (&Questions);
}
/*****************************************************************************/
/************ Get the parameter with the code of a test question *************/
/*****************************************************************************/
long Qst_GetParamQstCod (void)
{
/***** Get code of test question *****/
return Par_GetParToLong ("QstCod");
}
/*****************************************************************************/
/************ Put parameter with question code to edit, remove... ************/
/*****************************************************************************/
void Qst_PutParamQstCod (void *QstCod) // Should be a pointer to long
{
extern const char *Par_CodeStr[];
if (QstCod)
if (*((long *) QstCod) > 0) // If question exists
Par_PutHiddenParamLong (NULL,"QstCod",*((long *) QstCod));
Par_PutHiddenParamLong (NULL,Par_CodeStr[Par_QstCod],*((long *) QstCod));
}
/*****************************************************************************/

View File

@ -261,7 +261,6 @@ void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod);
void Qst_ChangeShuffleQst (void);
long Qst_GetParamQstCod (void);
void Qst_PutParamQstCod (void *QstCod);
void Qst_InsertOrUpdateQstTagsAnsIntoDB (struct Qst_Question *Question);

View File

@ -3153,6 +3153,7 @@ static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm)
static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Country;
extern const char *Txt_Another_country;
char *Label;
@ -3169,7 +3170,7 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm)
{
if (asprintf (&Label,"%s*",Txt_Country) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM","OthCtyCod",Label);
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthCtyCod],Label);
free (Label);
}
else
@ -3206,6 +3207,7 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm)
static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutForm)
{
extern const char *Par_CodeStr[];
extern const char *Txt_Date_of_birth;
unsigned CurrentYear = Dat_GetCurrentYear ();
@ -3644,7 +3646,7 @@ static void Rec_GetUsrExtraDataFromRecordForm (struct Usr_Data *UsrDat)
(unsigned long) Usr_SEX_UNKNOWN);
/***** Get country code *****/
UsrDat->CtyCod = Par_GetParToLong ("OthCtyCod");
UsrDat->CtyCod = Par_GetAndCheckParCodeMin (Par_OthCtyCod,0); // 0 (another country) is allowed here
Dat_GetDateFromForm ("BirthDay","BirthMonth","BirthYear",
&(UsrDat->Birthday.Day ),
@ -3754,6 +3756,7 @@ void Rec_ShowMySharedRecordAndMore (void)
static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
{
extern const char *Hlp_PROFILE_Institution;
extern const char *Par_CodeStr[];
extern const char *Txt_Institution_center_and_department;
extern const char *Txt_Institution;
extern const char *Txt_Country;
@ -3824,7 +3827,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
/* Label */
if (asprintf (&Label,"%s*",Txt_Institution) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM","OthInsCod",Label);
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthInsCod],Label);
free (Label);
/* Data */
@ -3867,7 +3870,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
/* Label */
if (asprintf (&Label,"%s*",Txt_Center) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM","OthCtrCod",Label);
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_OthCtrCod],Label);
free (Label);
/* Data */
@ -3908,7 +3911,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
/* Label */
if (asprintf (&Label,"%s*",Txt_Department) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM",Dpt_PARAM_DPT_COD_NAME,Label);
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[Par_DptCod],Label);
free (Label);
/* Data */
@ -3919,7 +3922,7 @@ static void Rec_ShowFormMyInsCtrDpt (bool IAmATeacher)
Err_NotEnoughMemoryExit ();
Dpt_WriteSelectorDepartment (Gbl.Usrs.Me.UsrDat.InsCod, // Departments in my institution
Gbl.Usrs.Me.UsrDat.Tch.DptCod, // Selected department
Dpt_PARAM_DPT_COD_NAME, // Parameter name
Par_CodeStr[Par_DptCod], // Parameter name
SelectClass, // Selector class
-1L, // First option
"", // Text when no department selected
@ -4092,7 +4095,7 @@ void Rec_UpdateMyDepartment (void)
/***** Get my department *****/
/* Get department code */
Dpt.DptCod = Dpt_GetAndCheckParamDptCod (0); // 0 (another department) is allowed here
Dpt.DptCod = Par_GetAndCheckParCodeMin (Par_DptCod,0); // 0 (another department) is allowed here
/* Get institution of department */
if (Dpt.DptCod > 0)

View File

@ -122,8 +122,6 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
struct Svy_Question *SvyQst,
char Stem[Cns_MAX_BYTES_TEXT + 1]);
static void Svy_InitQst (struct Svy_Question *SvyQst);
static void Svy_PutParamQstCod (long QstCod);
static long Svy_GetParamQstCod (void);
static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns);
static void Svy_FreeTextChoiceAnswers (struct Svy_Question *SvyQst,unsigned NumAnswers);
static void Svy_FreeTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns);
@ -409,8 +407,7 @@ void Svy_SeeOneSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Show survey *****/
Svy_ShowOneSurvey (&Surveys,true);
@ -534,7 +531,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
HTM_ARTICLE_Begin (Anchor);
Frm_BeginForm (ActSeeSvy);
Svy_PutParamSvyCod (Surveys->Svy.SvyCod);
Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod);
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -578,7 +575,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\"");
Frm_BeginForm (ActSeeSvy);
Svy_PutParamSvyCod (Surveys->Svy.SvyCod);
Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod);
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -594,7 +591,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\"");
Frm_BeginForm (ActSeeSvy);
Svy_PutParamSvyCod (Surveys->Svy.SvyCod);
Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod);
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -937,8 +934,7 @@ static void Svy_PutParams (void *Surveys)
if (Surveys)
{
if (((struct Svy_Surveys *) Surveys)->Svy.SvyCod > 0)
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Par_PutHiddenParamOrder ((unsigned) ((struct Svy_Surveys *) Surveys)->SelectedOrder);
WhichGroups = Grp_GetParamWhichGroups ();
Grp_PutParamWhichGroups (&WhichGroups);
@ -1408,26 +1404,6 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/******************* Write parameter with code of survey *********************/
/*****************************************************************************/
void Svy_PutParamSvyCod (long SvyCod)
{
if (SvyCod > 0)
Par_PutHiddenParamLong (NULL,"SvyCod",SvyCod);
}
/*****************************************************************************/
/******************** Get parameter with code of survey **********************/
/*****************************************************************************/
long Svy_GetParamSvyCod (void)
{
/***** Get code of survey *****/
return Par_GetParToLong ("SvyCod");
}
/*****************************************************************************/
/*************** Ask for confirmation of removing of a survey ****************/
/*****************************************************************************/
@ -1447,8 +1423,7 @@ void Svy_AskRemSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1484,8 +1459,7 @@ void Svy_RemoveSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1537,8 +1511,7 @@ void Svy_AskResetSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1574,8 +1547,7 @@ void Svy_ResetSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1613,8 +1585,7 @@ void Svy_HideSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1645,8 +1616,7 @@ void Svy_UnhideSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);
@ -1694,7 +1664,7 @@ void Svy_RequestCreatOrEditSvy (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get the code of the survey *****/
ItsANewSurvey = ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0);
ItsANewSurvey = ((Surveys.Svy.SvyCod = Par_GetParCode (Par_SvyCod)) <= 0);
/***** Get from the database the data of the survey *****/
if (ItsANewSurvey)
@ -1956,8 +1926,10 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod)
HTM_LABEL_Begin (NULL);
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\"%s onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_DB_CheckIfAssociatedToGrps ("svy_groups","SvyCod",SvyCod) ? "" :
" checked=\"checked\"");
Grp_DB_CheckIfAssociatedToGrps ("svy_groups",
Par_SvyCod,
SvyCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s&nbsp;%s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -2006,7 +1978,7 @@ void Svy_ReceiveFormSurvey (void)
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
/***** Get the code of the survey *****/
ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) <= 0);
ItsANewSurvey = ((NewSvy.SvyCod = Par_GetParCode (Par_SvyCod)) <= 0);
if (ItsANewSurvey)
NewSvy.Scope = HieLvl_UNK;
@ -2292,11 +2264,10 @@ void Svy_RequestEditQuestion (void)
Stem[0] = '\0';
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/* Get the question code */
SvyQst.QstCod = Svy_GetParamQstCod ();
SvyQst.QstCod = Par_GetParCode (Par_QstCod);
/***** Get other parameters *****/
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
@ -2390,9 +2361,8 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
/***** Begin form *****/
Frm_BeginForm (ActRcvSvyQst);
Svy_PutParamSvyCod (Surveys->Svy.SvyCod);
if (SvyQst->QstCod > 0) // If the question already has assigned a code
Svy_PutParamQstCod (SvyQst->QstCod);
Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod);
Par_PutParCod (Par_QstCod,SvyQst->QstCod);
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (2);
@ -2514,24 +2484,6 @@ static void Svy_InitQst (struct Svy_Question *SvyQst)
SvyQst->AnsChoice[NumAns].Text = NULL;
}
/*****************************************************************************/
/****************** Write parameter with code of question ********************/
/*****************************************************************************/
static void Svy_PutParamQstCod (long QstCod)
{
Par_PutHiddenParamLong (NULL,"QstCod",QstCod);
}
/*****************************************************************************/
/******************* Get parameter with code of question *********************/
/*****************************************************************************/
static long Svy_GetParamQstCod (void)
{
return Par_GetParToLong ("QstCod");
}
/*****************************************************************************/
/******************* Allocate memory for a choice answer *********************/
/*****************************************************************************/
@ -2604,11 +2556,10 @@ void Svy_ReceiveQst (void)
/***** Get parameters from form *****/
/* Get survey code */
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/* Get question code */
SvyQst.QstCod = Svy_GetParamQstCod ();
SvyQst.QstCod = Par_GetParCode (Par_QstCod);
/* Get answer type */
SvyQst.AnswerType = (Svy_AnswerType_t)
@ -2791,7 +2742,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys)
{
/***** Begin form to send answers to survey *****/
Frm_BeginForm (ActAnsSvy);
Svy_PutParamSvyCod (Surveys->Svy.SvyCod);
Par_PutParCod (Par_SvyCod,Surveys->Svy.SvyCod);
}
/***** Write the heading *****/
@ -2919,8 +2870,8 @@ static void Svy_PutParamsToEditQuestion (void *Surveys)
{
if (Surveys)
{
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod);
Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Par_PutParCod (Par_QstCod,((struct Svy_Surveys *) Surveys)->QstCod);
}
}
@ -3144,8 +3095,8 @@ static void Svy_PutParamsRemoveOneQst (void *Surveys)
{
if (Surveys)
{
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod);
Par_PutParCod (Par_SvyCod,((struct Svy_Surveys *) Surveys)->Svy.SvyCod);
Par_PutParCod (Par_QstCod,((struct Svy_Surveys *) Surveys)->QstCod);
}
}
@ -3168,12 +3119,10 @@ void Svy_RequestRemoveQst (void)
/***** Get parameters from form *****/
/* Get survey code */
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/* Get question code */
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0)
Err_WrongQuestionExit ();
SvyQst.QstCod = Par_GetAndCheckParCode (Par_QstCod);
/* Get question index */
SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod);
@ -3208,12 +3157,10 @@ void Svy_RemoveQst (void)
/***** Get parameters from form *****/
/* Get survey code */
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/* Get question code */
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) <= 0)
Err_WrongQuestionExit ();
SvyQst.QstCod = Par_GetAndCheckParCode (Par_QstCod);
/* Get question index */
SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod);
@ -3249,8 +3196,7 @@ void Svy_ReceiveSurveyAnswers (void)
Svy_ResetSurveys (&Surveys);
/***** Get survey code *****/
if ((Surveys.Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
Err_WrongSurveyExit ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get data of the survey from database *****/
Svy_GetDataOfSurveyByCod (&Surveys.Svy);

View File

@ -100,8 +100,6 @@ void Svy_FreeListSurveys (struct Svy_Surveys *Surveys);
void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
char **ContentStr,
long SvyCod,bool GetContent);
void Svy_PutParamSvyCod (long SvyCod);
long Svy_GetParamSvyCod (void);
void Svy_AskRemSurvey (void);
void Svy_RemoveSurvey (void);
void Svy_AskResetSurvey (void);

View File

@ -29,6 +29,7 @@
#include "swad_alert.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_parameter.h"
#include "swad_program_database.h"
#include "swad_survey.h"
#include "swad_survey_database.h"
@ -48,7 +49,7 @@ void SvyRsc_GetLinkToSurvey (void)
Svy_ResetSurveys (&Surveys);
/***** Get survey code *****/
Surveys.Svy.SvyCod = Svy_GetParamSvyCod ();
Surveys.Svy.SvyCod = Par_GetAndCheckParCode (Par_SvyCod);
/***** Get survey title *****/
SvyRsc_GetTitleFromSvyCod (Surveys.Svy.SvyCod,Title,sizeof (Title) - 1);
@ -84,7 +85,7 @@ void SvyRsc_WriteSurveyInCrsProgram (long SvyCod,bool PutFormToGo,
NextAction = (SvyCod > 0) ? ActSeeSvy : // Survey specified
ActSeeAllSvy; // All surveys
Frm_BeginForm (NextAction);
Svy_PutParamSvyCod (SvyCod);
Par_PutParCod (Par_SvyCod,SvyCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[NextAction],
"class=\"LM BT_LINK PRG_LNK_%s\"",
The_GetSuffix ());

View File

@ -134,6 +134,7 @@ mysql> SHOW TABLES LIKE 'tml_%';
#include "swad_global.h"
#include "swad_message.h"
#include "swad_notification.h"
#include "swad_parameter.h"
#include "swad_photo.h"
#include "swad_profile.h"
#include "swad_timeline.h"
@ -225,7 +226,7 @@ void Tml_ShowNoteAndTimelineGbl (struct Tml_Timeline *Timeline)
// This parameter is optional. It can be provided by a notification.
// If > 0 ==> the associated note will be shown highlighted
// get its code from database and show it above the timeline
if ((PubCod = TmlPub_GetParamPubCod ()) > 0)
if ((PubCod = Par_GetParCode (Par_PubCod)) > 0)
{
if ((Not.NotCod = Tml_DB_GetNotCodFromPubCod (PubCod)) > 0)
TmlNot_ShowHighlightedNote (Timeline,&Not);

View File

@ -223,7 +223,7 @@ static void TmlCom_PutFormToWriteNewComm (const struct Tml_Timeline *Timeline,
/***** Begin form to write the post *****/
TmlFrm_BeginForm (Timeline,TmlFrm_RECEIVE_COMM);
TmlNot_PutHiddenParamNotCod (NotCod);
Par_PutParCod (Par_NotCod,NotCod);
/***** Textarea and button *****/
if (asprintf (&ClassTextArea,"Tml_COM_TEXTAREA Tml_COM_WIDTH INPUT_%s",
@ -372,7 +372,7 @@ void TmlCom_ShowHiddenCommsGbl (void)
/***** Get parameters *****/
/* Get note code, identifier and number of comments to get */
NotCod = TmlNot_GetParamNotCod ();
NotCod = Par_GetParCode (Par_NotCod);
Par_GetParToText ("IdComments",IdComms,Frm_MAX_BYTES_ID);
NumInitialCommsToGet = (unsigned) Par_GetParToLong ("NumHidCom");
@ -700,7 +700,7 @@ static void TmlCom_PutFormToRemoveComm (const struct Tml_Timeline *Timeline,
/***** Form to remove publication *****/
/* Begin form */
TmlFrm_BeginForm (Timeline,TmlFrm_REQ_REM_COMM);
TmlPub_PutHiddenParamPubCod (PubCod);
Par_PutParCod (Par_PubCod,PubCod);
/* Icon to remove */
Ico_PutIconLink ("trash.svg",Ico_RED,
@ -764,7 +764,7 @@ static long TmlCom_ReceiveComm (void)
struct TmlPub_Publication Pub;
/***** Get data of note *****/
Not.NotCod = TmlNot_GetParamNotCod ();
Not.NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (&Not);
/***** Trivial check: note code *****/
@ -870,7 +870,7 @@ static void TmlCom_RequestRemovalComm (struct Tml_Timeline *Timeline)
Med_MediaConstructor (&Com.Content.Media);
/***** Get data of comment *****/
Com.PubCod = TmlPub_GetParamPubCod ();
Com.PubCod = Par_GetAndCheckParCode (Par_PubCod);
TmlCom_GetDataOfCommByCod (&Com);
/***** Do some checks *****/
@ -922,7 +922,7 @@ static void TmlCom_PutParamsRemoveComm (void *Timeline)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
else // Global timeline
Usr_PutHiddenParamWho (((struct Tml_Timeline *) Timeline)->Who);
TmlPub_PutHiddenParamPubCod (((struct Tml_Timeline *) Timeline)->PubCod);
Par_PutParCod (Par_PubCod,((struct Tml_Timeline *) Timeline)->PubCod);
}
}
@ -980,7 +980,7 @@ static void TmlCom_RemoveComm (void)
Med_MediaConstructor (&Com.Content.Media);
/***** Get data of comment *****/
Com.PubCod = TmlPub_GetParamPubCod ();
Com.PubCod = Par_GetAndCheckParCode (Par_PubCod);
TmlCom_GetDataOfCommByCod (&Com);
/***** Trivial check 1: publication code *****/

View File

@ -30,6 +30,7 @@
#include "swad_follow.h"
#include "swad_follow_database.h"
#include "swad_global.h"
#include "swad_parameter.h"
#include "swad_timeline.h"
#include "swad_timeline_database.h"
#include "swad_timeline_publication.h"
@ -44,11 +45,11 @@ static const char *Tml_DB_TableFav[TmlUsr_NUM_FAV_SHA] =
[TmlUsr_FAV_UNF_COMM] = "tml_comments_fav",
[TmlUsr_SHA_UNS_NOTE] = NULL, // Not used
};
static const char *Tml_DB_FieldFav[TmlUsr_NUM_FAV_SHA] =
static Par_Code_t Tml_DB_FieldFav[TmlUsr_NUM_FAV_SHA] =
{
[TmlUsr_FAV_UNF_NOTE] = "NotCod",
[TmlUsr_FAV_UNF_COMM] = "PubCod",
[TmlUsr_SHA_UNS_NOTE] = NULL, // Not used
[TmlUsr_FAV_UNF_NOTE] = Par_NotCod,
[TmlUsr_FAV_UNF_COMM] = Par_PubCod,
[TmlUsr_SHA_UNS_NOTE] = Par_NotCod, // Not used
};
static TmlPub_Type_t Tml_DB_PubTypeFav[TmlUsr_NUM_FAV_SHA] =
{
@ -67,7 +68,7 @@ extern struct Globals Gbl;
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static long Tml_DB_GetMedCod (const char *Table,const char *Field,long Cod);
static long Tml_DB_GetMedCod (const char *Table,Par_Code_t ParCod,long Cod);
/*****************************************************************************/
/********************* Get which users to show in timeline *******************/
@ -572,7 +573,7 @@ unsigned Tml_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res)
long Tml_DB_GetMedCodFromPost (long PstCod)
{
return Tml_DB_GetMedCod ("tml_posts","PstCod",PstCod);
return Tml_DB_GetMedCod ("tml_posts",Par_PstCod,PstCod);
}
/*****************************************************************************/
@ -756,7 +757,7 @@ void Tml_DB_InsertCommContent (long PubCod,
long Tml_DB_GetMedCodFromComm (long PubCod)
{
return Tml_DB_GetMedCod ("tml_comments","PubCod",PubCod);
return Tml_DB_GetMedCod ("tml_comments",Par_PubCod,PubCod);
}
/*****************************************************************************/
@ -838,14 +839,16 @@ void Tml_DB_RemoveAllCommsMadeBy (long UsrCod)
/*************** Get code of media associated to post/comment ****************/
/*****************************************************************************/
static long Tml_DB_GetMedCod (const char *Table,const char *Field,long Cod)
static long Tml_DB_GetMedCod (const char *Table,Par_Code_t ParCod,long Cod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
return DB_QuerySELECTCode ("can not get media code",
"SELECT MedCod" // row[0]
" FROM %s"
" WHERE %s=%ld",
Table,
Field,Cod);
Par_CodeStr[ParCod],Cod);
}
/*****************************************************************************/
@ -1131,6 +1134,8 @@ void Tml_DB_RemoveAllPubsPublishedBy (long UsrCod)
bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
return
DB_QueryEXISTS ("can not check if a user has favourited",
"SELECT EXISTS"
@ -1139,7 +1144,7 @@ bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod)
" WHERE %s=%ld"
" AND UsrCod=%ld)",
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha],Cod,UsrCod);
Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod,UsrCod);
}
/*****************************************************************************/
@ -1148,6 +1153,8 @@ bool Tml_DB_CheckIfFavedByUsr (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod)
unsigned Tml_DB_GetNumFavers (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
return (unsigned)
DB_QueryCOUNT ("can not get number of times has been favourited",
"SELECT COUNT(*)"
@ -1155,7 +1162,7 @@ unsigned Tml_DB_GetNumFavers (TmlUsr_FavSha_t FavSha,long Cod,long UsrCod)
" WHERE %s=%ld"
" AND UsrCod<>%ld", // Extra check
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha],Cod,
Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod,
UsrCod); // The author
}
@ -1167,6 +1174,8 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha,
long Cod,long UsrCod,unsigned MaxUsrs,
MYSQL_RES **mysql_res)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get favers",
"SELECT UsrCod" // row[0]
@ -1176,7 +1185,7 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha,
" ORDER BY FavCod"
" LIMIT %u",
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha],Cod,
Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod,
UsrCod,
MaxUsrs);
}
@ -1187,13 +1196,15 @@ unsigned Tml_DB_GetFavers (TmlUsr_FavSha_t FavSha,
void Tml_DB_MarkAsFav (TmlUsr_FavSha_t FavSha,long Cod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
DB_QueryINSERT ("can not favourite comment",
"INSERT IGNORE INTO %s"
" (%s,UsrCod,TimeFav)"
" VALUES"
" (%ld,%ld,NOW())",
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha],
Par_CodeStr[Tml_DB_FieldFav[FavSha]],
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
}
@ -1203,12 +1214,14 @@ void Tml_DB_MarkAsFav (TmlUsr_FavSha_t FavSha,long Cod)
void Tml_DB_UnmarkAsFav (TmlUsr_FavSha_t FavSha,long Cod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
DB_QueryDELETE ("can not unfavourite",
"DELETE FROM %s"
" WHERE %s=%ld"
" AND UsrCod=%ld",
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha],Cod,
Par_CodeStr[Tml_DB_FieldFav[FavSha]],Cod,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
@ -1231,6 +1244,8 @@ void Tml_DB_RemoveAllFavsMadeByUsr (TmlUsr_FavSha_t FavSha,long UsrCod)
void Tml_DB_RemoveAllFavsToPubsBy (TmlUsr_FavSha_t FavSha,long UsrCod)
{
extern const char *Par_CodeStr[]; // Database field name must be equal to code parameter name
DB_QueryDELETE ("can not remove favs",
"DELETE FROM %s"
" USING tml_pubs,"
@ -1242,9 +1257,9 @@ void Tml_DB_RemoveAllFavsToPubsBy (TmlUsr_FavSha_t FavSha,long UsrCod)
Tml_DB_TableFav[FavSha],
UsrCod,
(unsigned) Tml_DB_PubTypeFav[FavSha],
Tml_DB_FieldFav[FavSha],
Par_CodeStr[Tml_DB_FieldFav[FavSha]],
Tml_DB_TableFav[FavSha],
Tml_DB_FieldFav[FavSha]);
Par_CodeStr[Tml_DB_FieldFav[FavSha]]);
}
/*****************************************************************************/

View File

@ -28,6 +28,7 @@
#include "swad_database.h"
#include "swad_global.h"
#include "swad_notification_database.h"
#include "swad_parameter.h"
#include "swad_timeline.h"
#include "swad_timeline_database.h"
#include "swad_timeline_favourite.h"
@ -68,7 +69,7 @@ void TmlFav_ShowAllFaversNoteGbl (void)
struct TmlNot_Note Not;
/***** Get data of note *****/
Not.NotCod = TmlNot_GetParamNotCod ();
Not.NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (&Not);
/***** Write HTML inside DIV with form to fav/unfav *****/
@ -130,7 +131,7 @@ static void TmlFav_FavNote (struct TmlNot_Note *Not)
long OriginalPubCod;
/***** Get data of note *****/
Not->NotCod = TmlNot_GetParamNotCod ();
Not->NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (Not);
/***** Do some checks *****/
@ -160,7 +161,7 @@ static void TmlFav_UnfNote (struct TmlNot_Note *Not)
long OriginalPubCod;
/***** Get data of note *****/
Not->NotCod = TmlNot_GetParamNotCod ();
Not->NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (Not);
/***** Do some checks *****/
@ -203,7 +204,7 @@ void TmlFav_ShowAllFaversComGbl (void)
/***** Get data of comment *****/
Med_MediaConstructor (&Com.Content.Media);
Com.PubCod = TmlPub_GetParamPubCod ();
Com.PubCod = Par_GetAndCheckParCode (Par_PubCod);
TmlCom_GetDataOfCommByCod (&Com);
Med_MediaDestructor (&Com.Content.Media);
@ -267,7 +268,7 @@ static void TmlFav_FavComm (struct TmlCom_Comment *Com)
Med_MediaConstructor (&Com->Content.Media);
/***** Get data of comment *****/
Com->PubCod = TmlPub_GetParamPubCod ();
Com->PubCod = Par_GetAndCheckParCode (Par_PubCod);
TmlCom_GetDataOfCommByCod (Com);
/***** Do some checks *****/
@ -306,7 +307,7 @@ static void TmlFav_UnfComm (struct TmlCom_Comment *Com)
Med_MediaConstructor (&Com->Content.Media);
/***** Get data of comment *****/
Com->PubCod = TmlPub_GetParamPubCod ();
Com->PubCod = Par_GetAndCheckParCode (Par_PubCod);
TmlCom_GetDataOfCommByCod (Com);
/***** Do some checks *****/

View File

@ -625,28 +625,28 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
case TmlNot_INS_DOC_PUB_FILE:
case TmlNot_INS_SHA_PUB_FILE:
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod);
Par_PutParCod (Par_FilCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution
Ins_PutParamInsCod (Not->HieCod); // Go to another institution
break;
case TmlNot_CTR_DOC_PUB_FILE:
case TmlNot_CTR_SHA_PUB_FILE:
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod);
Par_PutParCod (Par_FilCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current center
Ctr_PutParamCtrCod (Not->HieCod); // Go to another center
break;
case TmlNot_DEG_DOC_PUB_FILE:
case TmlNot_DEG_SHA_PUB_FILE:
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod);
Par_PutParCod (Par_FilCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree
Deg_PutParamDegCod (Not->HieCod); // Go to another degree
break;
case TmlNot_CRS_DOC_PUB_FILE:
case TmlNot_CRS_SHA_PUB_FILE:
Frm_BeginForm (Tml_DefaultActions[Not->Type]);
Brw_PutHiddenParamFilCod (Not->Cod);
Par_PutParCod (Par_FilCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (Not->HieCod); // Go to another course
break;
@ -655,7 +655,7 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],
Anchor); // Locate on this specific exam
Frm_FreeAnchorStr (Anchor);
Cfe_PutHiddenParamExaCod (Not->Cod);
Par_PutParCod (Par_ExaCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (Not->HieCod); // Go to another course
break;
@ -677,7 +677,7 @@ static void TmlNot_PutFormGoToAction (const struct TmlNot_Note *Not,
Frm_SetAnchorStr (Not->Cod,&Anchor);
Frm_BeginFormAnchor (Tml_DefaultActions[Not->Type],Anchor);
Frm_FreeAnchorStr (Anchor);
Not_PutHiddenParamNotCod (Not->Cod);
Par_PutParCod (Par_NotCod,Not->Cod);
if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course
Crs_PutParamCrsCod (Not->HieCod); // Go to another course
break;
@ -867,7 +867,7 @@ static void TmlNot_PutFormToRemoveNote (const struct Tml_Timeline *Timeline,
/***** Form to remove publication *****/
/* Begin form */
TmlFrm_BeginForm (Timeline,TmlFrm_REQ_REM_NOTE);
TmlNot_PutHiddenParamNotCod (NotCod);
Par_PutParCod (Par_NotCod,NotCod);
/* Icon to remove */
Ico_PutIconLink ("trash.svg",Ico_RED,
@ -959,25 +959,6 @@ void TmlNot_MarkNotesChildrenOfFolderAsUnavailable (const char *Path)
Path);
}
/*****************************************************************************/
/****************** Put parameter with the code of a note ********************/
/*****************************************************************************/
void TmlNot_PutHiddenParamNotCod (long NotCod)
{
Par_PutHiddenParamLong (NULL,"NotCod",NotCod);
}
/*****************************************************************************/
/****************** Get parameter with the code of a note ********************/
/*****************************************************************************/
long TmlNot_GetParamNotCod (void)
{
/***** Get note code *****/
return Par_GetParToLong ("NotCod");
}
/*****************************************************************************/
/*********************** Request the removal of a note ***********************/
/*****************************************************************************/
@ -1028,7 +1009,7 @@ static void TmlNot_RequestRemovalNote (struct Tml_Timeline *Timeline)
struct TmlNot_Note Not;
/***** Get data of note *****/
Not.NotCod = TmlNot_GetParamNotCod ();
Not.NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (&Not);
/***** Do some checks *****/
@ -1068,7 +1049,7 @@ static void TmlNot_PutParamsRemoveNote (void *Timeline)
Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod);
else // Global timeline
Usr_PutHiddenParamWho (((struct Tml_Timeline *) Timeline)->Who);
TmlNot_PutHiddenParamNotCod (((struct Tml_Timeline *) Timeline)->NotCod);
Par_PutParCod (Par_NotCod,((struct Tml_Timeline *) Timeline)->NotCod);
}
}
@ -1123,7 +1104,7 @@ static void TmlNot_RemoveNote (void)
struct TmlNot_Note Not;
/***** Get data of note *****/
Not.NotCod = TmlNot_GetParamNotCod ();
Not.NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (&Not);
/***** Trivial check 1: note code should be > 0 *****/

View File

@ -106,9 +106,6 @@ void TmlNot_StoreAndPublishNoteInternal (TmlNot_Type_t NoteType,long Cod,
void TmlNot_MarkNoteOneFileAsUnavailable (const char *Path);
void TmlNot_MarkNotesChildrenOfFolderAsUnavailable (const char *Path);
void TmlNot_PutHiddenParamNotCod (long NotCod);
long TmlNot_GetParamNotCod (void);
void TmlNot_RequestRemNoteUsr (void);
void TmlNot_RequestRemNoteGbl (void);
void TmlNot_RemoveNoteUsr (void);

View File

@ -506,24 +506,6 @@ void TmlPub_PutLinkToViewOldPubs (void)
HTM_DIV_End ();
}
/*****************************************************************************/
/*************** Put parameter with the code of a publication ****************/
/*****************************************************************************/
void TmlPub_PutHiddenParamPubCod (long PubCod)
{
Par_PutHiddenParamLong (NULL,"PubCod",PubCod);
}
/*****************************************************************************/
/**************** Get parameter with the code of a publication ***************/
/*****************************************************************************/
long TmlPub_GetParamPubCod (void)
{
return Par_GetParToLong ("PubCod");
}
/*****************************************************************************/
/***************** Get data of publication using its code ********************/
/*****************************************************************************/

View File

@ -115,9 +115,6 @@ Tml_TopMessage_t TmlPub_GetTopMessage (TmlPub_Type_t PubType);
void TmlPub_PutLinkToViewNewPubs (void);
void TmlPub_PutLinkToViewOldPubs (void);
void TmlPub_PutHiddenParamPubCod (long PubCod);
long TmlPub_GetParamPubCod (void);
void TmlPub_GetDataOfPubFromNextRow (MYSQL_RES *mysql_res,
struct TmlPub_Publication *Pub);

View File

@ -28,6 +28,7 @@
#include "swad_database.h"
#include "swad_global.h"
#include "swad_notification_database.h"
#include "swad_parameter.h"
#include "swad_timeline.h"
#include "swad_timeline_database.h"
#include "swad_timeline_notification.h"
@ -65,7 +66,7 @@ void TmlSha_ShowAllSharersNoteGbl (void)
struct TmlNot_Note Not;
/***** Get data of note *****/
Not.NotCod = TmlNot_GetParamNotCod ();
Not.NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (&Not);
/***** Write HTML inside DIV with form to share/unshare *****/
@ -106,7 +107,7 @@ static void TmlSha_ShaNote (struct TmlNot_Note *Not)
long OriginalPubCod;
/***** Get data of note *****/
Not->NotCod = TmlNot_GetParamNotCod ();
Not->NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (Not);
/***** Do some checks *****/
@ -164,7 +165,7 @@ static void TmlSha_UnsNote (struct TmlNot_Note *Not)
long OriginalPubCod;
/***** Get data of note *****/
Not->NotCod = TmlNot_GetParamNotCod ();
Not->NotCod = Par_GetAndCheckParCode (Par_NotCod);
TmlNot_GetDataOfNoteByCod (Not);
/***** Do some checks *****/