diff --git a/swad_API.c b/swad_API.c index 9f8e6bed..42a73db8 100644 --- a/swad_API.c +++ b/swad_API.c @@ -2169,7 +2169,7 @@ int swad__getGroups (struct soap *soap, (int) MaxStudents; /* Get number of current students */ - getGroupsOut->groupsArray.__ptr[NumRow].numStudents = (int) Grp_CountNumUsrsInGrp (Rol_STD,GrpCod); + getGroupsOut->groupsArray.__ptr[NumRow].numStudents = (int) Grp_DB_CountNumUsrsInGrp (Rol_STD,GrpCod); /* Get whether group is open ('Y') or closed ('N') (row[5]) */ getGroupsOut->groupsArray.__ptr[NumRow].open = (row[5][0] == 'Y') ? 1 : @@ -2343,7 +2343,7 @@ int swad__sendMyGroups (struct soap *soap, (int) MaxStudents; /* Get number of current students */ - SendMyGroupsOut->groupsArray.__ptr[NumRow].numStudents = (int) Grp_CountNumUsrsInGrp (Rol_STD,GrpCod); + SendMyGroupsOut->groupsArray.__ptr[NumRow].numStudents = (int) Grp_DB_CountNumUsrsInGrp (Rol_STD,GrpCod); /* Get whether group is open ('Y') or closed ('N') (row[5]) */ SendMyGroupsOut->groupsArray.__ptr[NumRow].open = (row[5][0] == 'Y') ? 1 : @@ -2846,7 +2846,7 @@ static void API_GetLstGrpsSel (const char *Groups) { Str_GetNextStringUntilComma (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG); Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrp] = Str_ConvertStrCodToLongCod (LongStr); - if (Grp_CheckIfGroupBelongsToCourse (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrp],Gbl.Hierarchy.Crs.CrsCod)) + if (Grp_DB_CheckIfGrpBelongsToCrs (Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrp],Gbl.Hierarchy.Crs.CrsCod)) NumGrp++; } Gbl.Crs.Grps.LstGrpsSel.NumGrps = NumGrp; // Update number of groups @@ -2902,7 +2902,7 @@ int swad__getAttendanceUsers (struct soap *soap, "Requester must be a teacher"); /***** Query list of attendance users *****/ - if (Grp_CheckIfAssociatedToGrps ("att_groups","AttCod",Event.AttCod)) + if (Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",Event.AttCod)) // Event for one or more groups // Subquery: list of users in groups of this attendance event... // ...who have no entry in attendance list of users diff --git a/swad_assignment.c b/swad_assignment.c index c3b8be88..922c9959 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -1264,7 +1264,7 @@ 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_CheckIfAssociatedToGrps ("asg_groups","AsgCod",AsgCod) ? "" : + Grp_DB_CheckIfAssociatedToGrps ("asg_groups","AsgCod",AsgCod) ? "" : " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); diff --git a/swad_attendance.c b/swad_attendance.c index 52d1ca85..d7c7de05 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -1157,7 +1157,7 @@ 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_CheckIfAssociatedToGrps ("att_groups","AttCod",AttCod) ? "" : + Grp_DB_CheckIfAssociatedToGrps ("att_groups","AttCod",AttCod) ? "" : " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); diff --git a/swad_changelog.h b/swad_changelog.h index 84af37ab..87ef1a2a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,14 +602,15 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 20.92 (2021-06-11)" +#define Log_PLATFORM_VERSION "SWAD 20.93 (2021-06-17)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams - Version 20.92: Jun 09, 2021 New modules swad_admin and swad_admin_database for administrators. (313381 lines) + Version 20.93: Jun 17, 2021 Code refactoring. (313382 lines) + Version 20.92: Jun 11, 2021 New modules swad_admin and swad_admin_database for administrators. (313381 lines) Version 20.91.3: Jun 11, 2021 Queries moved to module swad_enrolment_database. (313173 lines) Version 20.91.2: Jun 11, 2021 Queries moved to module swad_enrolment_database. (313143 lines) Version 20.91.1: Jun 10, 2021 Queries moved to module swad_enrolment_database. (313145 lines) diff --git a/swad_exam.c b/swad_exam.c index 0d0f1199..c0047bbf 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -139,7 +139,7 @@ static void Exa_RemoveExamFromAllTables (long ExaCod); static void Exa_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod); static void Exa_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod); -static bool Exa_CheckIfSimilarExamExists (const struct Exa_Exam *Exam); +static bool Exa_DB_CheckIfSimilarExamExists (const struct Exa_Exam *Exam); static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam, char Txt[Cns_MAX_BYTES_TEXT + 1]); @@ -243,73 +243,73 @@ static void Exa_ListAllExams (struct Exa_Exams *Exams) Exa_PutIconsListExams,Exams, Hlp_ASSESSMENT_Exams,Box_NOT_CLOSABLE); - /***** Write links to pages *****/ - Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination, - Exams,-1L); + /***** Write links to pages *****/ + Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination, + Exams,-1L); - if (Exams->Num) - { - /***** Table head *****/ - HTM_TABLE_BeginWideMarginPadding (5); - HTM_TR_Begin (NULL); + if (Exams->Num) + { + /***** Table head *****/ + HTM_TABLE_BeginWideMarginPadding (5); + HTM_TR_Begin (NULL); + if (Exa_CheckIfICanEditExams ()) + HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons + + for (Order = (Exa_Order_t) 0; + Order <= (Exa_Order_t) (Exa_NUM_ORDERS - 1); + Order++) + { + HTM_TH_Begin (1,1,"LM"); + + /* Form to change order */ + Frm_BeginForm (ActSeeAllExa); + Pag_PutHiddenParamPagNum (Pag_EXAMS,Exams->CurrentPage); + Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); + HTM_BUTTON_SUBMIT_Begin (Txt_EXAMS_ORDER_HELP[Order],"BT_LINK TIT_TBL",NULL); + if (Order == Exams->SelectedOrder) + HTM_U_Begin (); + HTM_Txt (Txt_EXAMS_ORDER[Order]); + if (Order == Exams->SelectedOrder) + HTM_U_End (); + HTM_BUTTON_End (); + Frm_EndForm (); + + HTM_TH_End (); + } + + HTM_TH (1,1,"RM",Txt_Sessions); + + HTM_TR_End (); + + /***** Write all exams *****/ + for (NumExam = Pagination.FirstItemVisible; + NumExam <= Pagination.LastItemVisible; + NumExam++) + { + /* Get data of this exam */ + Exam.ExaCod = Exams->Lst[NumExam - 1].ExaCod; + Exa_GetDataOfExamByCod (&Exam); + Exams->ExaCod = Exam.ExaCod; + + /* Show exam */ + Exa_ShowOneExam (Exams, + &Exam, + false); // Do not show only this exam + } + + /***** End table *****/ + HTM_TABLE_End (); + } + else // No exams created + Ale_ShowAlert (Ale_INFO,Txt_No_exams); + + /***** Write again links to pages *****/ + Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination, + Exams,-1L); + + /***** Button to create a new exam *****/ if (Exa_CheckIfICanEditExams ()) - HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons - - for (Order = (Exa_Order_t) 0; - Order <= (Exa_Order_t) (Exa_NUM_ORDERS - 1); - Order++) - { - HTM_TH_Begin (1,1,"LM"); - - /* Form to change order */ - Frm_BeginForm (ActSeeAllExa); - Pag_PutHiddenParamPagNum (Pag_EXAMS,Exams->CurrentPage); - Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order); - HTM_BUTTON_SUBMIT_Begin (Txt_EXAMS_ORDER_HELP[Order],"BT_LINK TIT_TBL",NULL); - if (Order == Exams->SelectedOrder) - HTM_U_Begin (); - HTM_Txt (Txt_EXAMS_ORDER[Order]); - if (Order == Exams->SelectedOrder) - HTM_U_End (); - HTM_BUTTON_End (); - Frm_EndForm (); - - HTM_TH_End (); - } - - HTM_TH (1,1,"RM",Txt_Sessions); - - HTM_TR_End (); - - /***** Write all exams *****/ - for (NumExam = Pagination.FirstItemVisible; - NumExam <= Pagination.LastItemVisible; - NumExam++) - { - /* Get data of this exam */ - Exam.ExaCod = Exams->Lst[NumExam - 1].ExaCod; - Exa_GetDataOfExamByCod (&Exam); - Exams->ExaCod = Exam.ExaCod; - - /* Show exam */ - Exa_ShowOneExam (Exams, - &Exam, - false); // Do not show only this exam - } - - /***** End table *****/ - HTM_TABLE_End (); - } - else // No exams created - Ale_ShowAlert (Ale_INFO,Txt_No_exams); - - /***** Write again links to pages *****/ - Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination, - Exams,-1L); - - /***** Button to create a new exam *****/ - if (Exa_CheckIfICanEditExams ()) - Exa_PutButtonToCreateNewExam (Exams); + Exa_PutButtonToCreateNewExam (Exams); /***** End box *****/ Box_BoxEnd (); @@ -392,7 +392,7 @@ static void Exa_PutButtonToCreateNewExam (struct Exa_Exams *Exams) Frm_BeginForm (ActFrmNewExa); Exa_PutParamsToCreateNewExam (Exams); - Btn_PutConfirmButton (Txt_New_exam); + Btn_PutConfirmButton (Txt_New_exam); Frm_EndForm (); } @@ -506,99 +506,99 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams, /***** Start first row of this exam *****/ HTM_TR_Begin (NULL); - /***** Icons related to this exam *****/ - if (Exa_CheckIfICanEditExams ()) - { - if (ShowOnlyThisExam) - HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\""); - else - HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd); + /***** Icons related to this exam *****/ + if (Exa_CheckIfICanEditExams ()) + { + if (ShowOnlyThisExam) + HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\""); + else + HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd); - /* Icons to remove/edit this exam */ - Exa_PutIconsToRemEditOneExam (Exams,Exam,Anchor); + /* Icons to remove/edit this exam */ + Exa_PutIconsToRemEditOneExam (Exams,Exam,Anchor); + + HTM_TD_End (); + } + + /***** Start/end date/time *****/ + UniqueId++; + for (StartEndTime = (Dat_StartEndTime_t) 0; + StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); + StartEndTime++) + { + if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) + Err_NotEnoughMemoryExit (); + Color = Exam->NumOpenSess ? (Exam->Hidden ? "DATE_GREEN_LIGHT": + "DATE_GREEN") : + (Exam->Hidden ? "DATE_RED_LIGHT": + "DATE_RED"); + if (ShowOnlyThisExam) + HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"", + Id,Color); + else + HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"", + Id,Color,Gbl.RowEvenOdd); + if (Exam->TimeUTC[Dat_START_TIME]) + Dat_WriteLocalDateHMSFromUTC (Id,Exam->TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,true,0x6); + HTM_TD_End (); + free (Id); + } + + /***** Exam title and main data *****/ + if (ShowOnlyThisExam) + HTM_TD_Begin ("class=\"LT\""); + else + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + + /* Exam title */ + Exams->ExaCod = Exam->ExaCod; + HTM_ARTICLE_Begin (Anchor); + Frm_BeginForm (ActSeeExa); + Exa_PutParams (Exams); + HTM_BUTTON_SUBMIT_Begin (Txt_View_exam, + Exam->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT": + "BT_LINK LT ASG_TITLE", + NULL); + HTM_Txt (Exam->Title); + HTM_BUTTON_End (); + Frm_EndForm (); + HTM_ARTICLE_End (); + + /* Number of questions, maximum grade, visibility of results */ + HTM_DIV_Begin ("class=\"%s\"",Exam->Hidden ? "ASG_GRP_LIGHT" : + "ASG_GRP"); + HTM_TxtColonNBSP (Txt_Sets_of_questions); + HTM_Unsigned (Exam->NumSets); + HTM_BR (); + HTM_TxtColonNBSP (Txt_Maximum_grade); + HTM_Double (Exam->MaxGrade); + HTM_BR (); + HTM_TxtColonNBSP (Txt_Result_visibility); + TstVis_ShowVisibilityIcons (Exam->Visibility,Exam->Hidden); + HTM_DIV_End (); + + /***** Number of sessions in exam *****/ + if (ShowOnlyThisExam) + HTM_TD_Begin ("class=\"RT\""); + else + HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + + Exams->ExaCod = Exam->ExaCod; + Frm_BeginForm (ActSeeExa); + Exa_PutParams (Exams); + HTM_BUTTON_SUBMIT_Begin (Txt_Sessions, + Exam->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT" : + "BT_LINK LT ASG_TITLE", + NULL); + if (ShowOnlyThisExam) + HTM_TxtColonNBSP (Txt_Sessions); + HTM_Unsigned (Exam->NumSess); + HTM_BUTTON_End (); + Frm_EndForm (); HTM_TD_End (); - } - - /***** Start/end date/time *****/ - UniqueId++; - for (StartEndTime = (Dat_StartEndTime_t) 0; - StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1); - StartEndTime++) - { - if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) - Err_NotEnoughMemoryExit (); - Color = Exam->NumOpenSess ? (Exam->Hidden ? "DATE_GREEN_LIGHT": - "DATE_GREEN") : - (Exam->Hidden ? "DATE_RED_LIGHT": - "DATE_RED"); - if (ShowOnlyThisExam) - HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"", - Id,Color); - else - HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"", - Id,Color,Gbl.RowEvenOdd); - if (Exam->TimeUTC[Dat_START_TIME]) - Dat_WriteLocalDateHMSFromUTC (Id,Exam->TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,true,0x6); - HTM_TD_End (); - free (Id); - } - - /***** Exam title and main data *****/ - if (ShowOnlyThisExam) - HTM_TD_Begin ("class=\"LT\""); - else - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - - /* Exam title */ - Exams->ExaCod = Exam->ExaCod; - HTM_ARTICLE_Begin (Anchor); - Frm_BeginForm (ActSeeExa); - Exa_PutParams (Exams); - HTM_BUTTON_SUBMIT_Begin (Txt_View_exam, - Exam->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT": - "BT_LINK LT ASG_TITLE", - NULL); - HTM_Txt (Exam->Title); - HTM_BUTTON_End (); - Frm_EndForm (); - HTM_ARTICLE_End (); - - /* Number of questions, maximum grade, visibility of results */ - HTM_DIV_Begin ("class=\"%s\"",Exam->Hidden ? "ASG_GRP_LIGHT" : - "ASG_GRP"); - HTM_TxtColonNBSP (Txt_Sets_of_questions); - HTM_Unsigned (Exam->NumSets); - HTM_BR (); - HTM_TxtColonNBSP (Txt_Maximum_grade); - HTM_Double (Exam->MaxGrade); - HTM_BR (); - HTM_TxtColonNBSP (Txt_Result_visibility); - TstVis_ShowVisibilityIcons (Exam->Visibility,Exam->Hidden); - HTM_DIV_End (); - - /***** Number of sessions in exam *****/ - if (ShowOnlyThisExam) - HTM_TD_Begin ("class=\"RT\""); - else - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - - Exams->ExaCod = Exam->ExaCod; - Frm_BeginForm (ActSeeExa); - Exa_PutParams (Exams); - HTM_BUTTON_SUBMIT_Begin (Txt_Sessions, - Exam->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT" : - "BT_LINK LT ASG_TITLE", - NULL); - if (ShowOnlyThisExam) - HTM_TxtColonNBSP (Txt_Sessions); - HTM_Unsigned (Exam->NumSess); - HTM_BUTTON_End (); - Frm_EndForm (); - - HTM_TD_End (); /***** End 1st row of this exam *****/ HTM_TR_End (); @@ -606,28 +606,28 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams, /***** Start 2nd row of this exam *****/ HTM_TR_Begin (NULL); - /***** Author of the exam *****/ - if (ShowOnlyThisExam) - HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); - else - HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Exa_WriteAuthor (Exam); - HTM_TD_End (); + /***** Author of the exam *****/ + if (ShowOnlyThisExam) + HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); + else + HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Exa_WriteAuthor (Exam); + HTM_TD_End (); - /***** Text of the exam *****/ - if (ShowOnlyThisExam) - HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); - else - HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Exa_GetExamTxtFromDB (Exam->ExaCod,Txt); - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML - Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links - HTM_DIV_Begin ("class=\"PAR %s\"",Exam->Hidden ? "DAT_LIGHT" : - "DAT"); - HTM_Txt (Txt); - HTM_DIV_End (); - HTM_TD_End (); + /***** Text of the exam *****/ + if (ShowOnlyThisExam) + HTM_TD_Begin ("colspan=\"2\" class=\"LT\""); + else + HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + Exa_DB_GetExamTxt (Exam->ExaCod,Txt); + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML + Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links + HTM_DIV_Begin ("class=\"PAR %s\"",Exam->Hidden ? "DAT_LIGHT" : + "DAT"); + HTM_Txt (Txt); + HTM_DIV_End (); + HTM_TD_End (); /***** End 2nd row of this exam *****/ HTM_TR_End (); @@ -994,10 +994,10 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam) Str_Copy (Exam->Title,row[6],sizeof (Exam->Title) - 1); /* Get number of sets */ - Exam->NumSets = ExaSet_GetNumSetsExam (Exam->ExaCod); + Exam->NumSets = Exa_DB_GetNumSetsExam (Exam->ExaCod); /* Get number of questions */ - Exam->NumQsts = ExaSet_GetNumQstsExam (Exam->ExaCod); + Exam->NumQsts = Exa_DB_GetNumQstsExam (Exam->ExaCod); /* Get number of sessions */ Exam->NumSess = ExaSes_GetNumSessionsInExam (Exam->ExaCod); @@ -1062,7 +1062,7 @@ void Exa_FreeListExams (struct Exa_Exams *Exams) /********************** Get exam text from database **************************/ /*****************************************************************************/ -void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) +void Exa_DB_GetExamTxt (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]) { /***** Get text of exam from database *****/ DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get exam text", @@ -1157,7 +1157,7 @@ void Exa_RemoveExam (void) static void Exa_RemoveExamFromAllTables (long ExaCod) { /***** Remove all sessions in this exam *****/ - ExaSes_RemoveSessionsInExamFromAllTables (ExaCod); + Exa_DB_RemoveSessionsInExamFromAllTables (ExaCod); /***** Remove exam questions *****/ DB_QueryDELETE ("can not remove exam questions", @@ -1191,7 +1191,7 @@ void Exa_RemoveCrsExams (long CrsCod) ExaPrn_RemoveCrsPrints (CrsCod); /***** Remove all sessions in the course *****/ - ExaSes_RemoveSessionInCourseFromAllTables (CrsCod); + Exa_DB_RemoveSessionInCourseFromAllTables (CrsCod); /***** Remove media associated to test questions in the course *****/ Exa_RemoveAllMedFilesFromStemOfAllQstsInCrs (CrsCod); @@ -1375,7 +1375,7 @@ void Exa_UnhideExam (void) /******************* Check if the title of an exam exists *******************/ /*****************************************************************************/ -static bool Exa_CheckIfSimilarExamExists (const struct Exa_Exam *Exam) +static bool Exa_DB_CheckIfSimilarExamExists (const struct Exa_Exam *Exam) { /***** Get number of exams with a field value from database *****/ return (DB_QueryCOUNT ("can not get similar exams", @@ -1444,7 +1444,7 @@ void Exa_PutFormsOneExam (struct Exa_Exams *Exams, if (ItsANewExam) Txt[0] = '\0'; else - Exa_GetExamTxtFromDB (Exam->ExaCod,Txt); + Exa_DB_GetExamTxt (Exam->ExaCod,Txt); /***** Put form to create/edit an exam *****/ Exa_PutFormEditionExam (Exams,Exam,Txt,ItsANewExam); @@ -1485,82 +1485,82 @@ void Exa_PutFormEditionExam (struct Exa_Exams *Exams, ActChgExa); Exa_PutParams (Exams); - /***** Begin box and table *****/ - if (ItsANewExam) - Box_BoxTableBegin (NULL,Txt_New_exam, - NULL,NULL, - Hlp_ASSESSMENT_Exams_new_exam,Box_NOT_CLOSABLE,2); - else - Box_BoxTableBegin (NULL, - Exam->Title[0] ? Exam->Title : - Txt_Edit_exam, - NULL,NULL, - Hlp_ASSESSMENT_Exams_edit_exam,Box_NOT_CLOSABLE,2); + /***** Begin box and table *****/ + if (ItsANewExam) + Box_BoxTableBegin (NULL,Txt_New_exam, + NULL,NULL, + Hlp_ASSESSMENT_Exams_new_exam,Box_NOT_CLOSABLE,2); + else + Box_BoxTableBegin (NULL, + Exam->Title[0] ? Exam->Title : + Txt_Edit_exam, + NULL,NULL, + Hlp_ASSESSMENT_Exams_edit_exam,Box_NOT_CLOSABLE,2); - /***** Exam title *****/ - HTM_TR_Begin (NULL); + /***** Exam title *****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Title",Txt_Title); + /* Label */ + Frm_LabelColumn ("RT","Title",Txt_Title); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_TEXT ("Title",Exa_MAX_CHARS_TITLE,Exam->Title, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Title\" required=\"required\"" - " class=\"TITLE_DESCRIPTION_WIDTH\""); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_INPUT_TEXT ("Title",Exa_MAX_CHARS_TITLE,Exam->Title, + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Title\" required=\"required\"" + " class=\"TITLE_DESCRIPTION_WIDTH\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Maximum grade *****/ - HTM_TR_Begin (NULL); + /***** Maximum grade *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Maximum_grade); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Maximum_grade); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_FLOAT ("MaxGrade",0.0,DBL_MAX,0.01,Exam->MaxGrade,false, - "required=\"required\""); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_FLOAT ("MaxGrade",0.0,DBL_MAX,0.01,Exam->MaxGrade,false, + "required=\"required\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Visibility of results *****/ - HTM_TR_Begin (NULL); + /***** Visibility of results *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Result_visibility); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Result_visibility); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LB\""); - TstVis_PutVisibilityCheckboxes (Exam->Visibility); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LB\""); + TstVis_PutVisibilityCheckboxes (Exam->Visibility); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Exam text *****/ - HTM_TR_Begin (NULL); + /***** Exam text *****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Txt",Txt_Description); + /* Label */ + Frm_LabelColumn ("RT","Txt",Txt_Description); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\" rows=\"5\"" - " class=\"TITLE_DESCRIPTION_WIDTH\""); - HTM_Txt (Txt); - HTM_TEXTAREA_End (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\" rows=\"5\"" + " class=\"TITLE_DESCRIPTION_WIDTH\""); + HTM_Txt (Txt); + HTM_TEXTAREA_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** End table, send button and end box *****/ - if (ItsANewExam) - Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_exam); - else - Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes); + /***** End table, send button and end box *****/ + if (ItsANewExam) + Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_exam); + else + Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes); /***** End form *****/ Frm_EndForm (); @@ -1653,7 +1653,7 @@ static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam) if (Exam->Title[0]) // If there's an exam title { /* If title of exam was in database... */ - if (Exa_CheckIfSimilarExamExists (Exam)) + if (Exa_DB_CheckIfSimilarExamExists (Exam)) { NewExamIsCorrect = false; Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_an_exam_with_the_title_X, @@ -1749,7 +1749,7 @@ bool Exa_CheckIfEditable (const struct Exa_Exam *Exam) /*****************************************************************************/ // Returns the number of courses with exams in this location -unsigned Exa_GetNumCoursesWithExams (HieLvl_Level_t Scope) +unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope) { /***** Get number of courses with exams from database *****/ switch (Scope) @@ -1819,7 +1819,7 @@ unsigned Exa_GetNumCoursesWithExams (HieLvl_Level_t Scope) /*****************************************************************************/ // Returns the number of exams in this location -unsigned Exa_GetNumExams (HieLvl_Level_t Scope) +unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope) { /***** Get number of exams from database *****/ switch (Scope) @@ -1888,7 +1888,7 @@ unsigned Exa_GetNumExams (HieLvl_Level_t Scope) /************* Get average number of questions per course exam ***************/ /*****************************************************************************/ -double Exa_GetNumQstsPerCrsExam (HieLvl_Level_t Scope) +double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Scope) { /***** Get number of questions per exam from database *****/ switch (Scope) diff --git a/swad_exam.h b/swad_exam.h index 407503e8..130ca79e 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -68,7 +68,7 @@ void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam); void Exa_GetDataOfExamByFolder (struct Exa_Exam *Exam); void Exa_FreeListExams (struct Exa_Exams *Exams); -void Exa_GetExamTxtFromDB (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); +void Exa_DB_GetExamTxt (long ExaCod,char Txt[Cns_MAX_BYTES_TEXT + 1]); void Exa_AskRemExam (void); void Exa_RemoveExam (void); @@ -91,8 +91,8 @@ void Exa_ReceiveFormExam (void); bool Exa_CheckIfEditable (const struct Exa_Exam *Exam); -unsigned Exa_GetNumCoursesWithExams (HieLvl_Level_t Scope); -unsigned Exa_GetNumExams (HieLvl_Level_t Scope); -double Exa_GetNumQstsPerCrsExam (HieLvl_Level_t Scope); +unsigned Exa_DB_GetNumCoursesWithExams (HieLvl_Level_t Scope); +unsigned Exa_DB_GetNumExams (HieLvl_Level_t Scope); +double Exa_DB_GetNumQstsPerCrsExam (HieLvl_Level_t Scope); #endif diff --git a/swad_exam_log.c b/swad_exam_log.c index 5a348e95..4f0ebdd7 100644 --- a/swad_exam_log.c +++ b/swad_exam_log.c @@ -336,170 +336,168 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print) NULL,NULL, NULL,Box_CLOSABLE,2); - /***** Begin table *****/ - HTM_TABLE_BeginWideMarginPadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (2); - /***** Write heading *****/ - HTM_TR_Begin (NULL); + /***** Write heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RB",Txt_Click); + HTM_TH (1,1,"LB",Txt_Date_and_time); + HTM_TH (1,1,"LB",Txt_Action); + HTM_TH (1,1,"RB",Txt_Question); + HTM_TH (1,1,"CB",Txt_EXAM_Open); + HTM_TH (1,1,"LB",Txt_IP); + HTM_TH (1,1,"LB",Txt_Session); + HTM_TH (1,1,"LB",Txt_Web_browser); + HTM_TR_End (); - HTM_TH (1,1,"RB",Txt_Click); - HTM_TH (1,1,"LB",Txt_Date_and_time); - HTM_TH (1,1,"LB",Txt_Action); - HTM_TH (1,1,"RB",Txt_Question); - HTM_TH (1,1,"CB",Txt_EXAM_Open); - HTM_TH (1,1,"LB",Txt_IP); - HTM_TH (1,1,"LB",Txt_Session); - HTM_TH (1,1,"LB",Txt_Web_browser); - - HTM_TR_End (); - - /***** Write clicks *****/ - for (NumClick = 0; - NumClick < NumClicks; - NumClick++) - { - Gbl.RowEvenOdd = NumClick % 2; - - /***** Get row *****/ - row = mysql_fetch_row (mysql_res); - - /* Get code of action (row[0]) */ - ActCod = Str_ConvertStrToUnsigned (row[0]); - if (ActCod < ExaLog_NUM_ACTIONS) - Action = (ExaLog_Action_t) ActCod; - else - Action = ExaLog_UNKNOWN_ACTION; - - /* Get question index (row[1]) */ - QstInd = (int) Str_ConvertStrCodToLongCod (row[1]); - - /* Get if the user could answer (row[2]) */ - UsrCouldAnswer = (row[2][0] == 'Y'); - - /* Get click time (row[3] holds the UTC time) */ - ClickTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); - - /* Get IP (row[4]) */ - Str_Copy (IP,row[4],sizeof (IP) - 1); - - /* Get session id (row[5]) */ - Str_Copy (SessionId,row[5] ? row[5] : // This row has a user agent stored in database - "=", - sizeof (SessionId) - 1); - - /* Get session id (row[6]) */ - if (asprintf (&UserAgent,"%s",row[6] ? row[6] : - "=") < 0) - Err_NotEnoughMemoryExit (); - - /***** Set color of row depending on action *****/ - if (UsrCouldAnswer) - switch (Action) + /***** Write clicks *****/ + for (NumClick = 0; + NumClick < NumClicks; + NumClick++) { - case ExaLog_START_EXAM: - case ExaLog_RESUME_EXAM: - case ExaLog_FINISH_EXAM: - Class = "DAT_SMALL_N"; - break; - case ExaLog_ANSWER_QUESTION: - Class = "DAT_SMALL"; - break; - default: - Class = "DAT_SMALL_LIGHT"; - break; + Gbl.RowEvenOdd = NumClick % 2; + + /***** Get row *****/ + row = mysql_fetch_row (mysql_res); + + /* Get code of action (row[0]) */ + ActCod = Str_ConvertStrToUnsigned (row[0]); + if (ActCod < ExaLog_NUM_ACTIONS) + Action = (ExaLog_Action_t) ActCod; + else + Action = ExaLog_UNKNOWN_ACTION; + + /* Get question index (row[1]) */ + QstInd = (int) Str_ConvertStrCodToLongCod (row[1]); + + /* Get if the user could answer (row[2]) */ + UsrCouldAnswer = (row[2][0] == 'Y'); + + /* Get click time (row[3] holds the UTC time) */ + ClickTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); + + /* Get IP (row[4]) */ + Str_Copy (IP,row[4],sizeof (IP) - 1); + + /* Get session id (row[5]) */ + Str_Copy (SessionId,row[5] ? row[5] : // This row has a user agent stored in database + "=", + sizeof (SessionId) - 1); + + /* Get session id (row[6]) */ + if (asprintf (&UserAgent,"%s",row[6] ? row[6] : + "=") < 0) + Err_NotEnoughMemoryExit (); + + /***** Set color of row depending on action *****/ + if (UsrCouldAnswer) + switch (Action) + { + case ExaLog_START_EXAM: + case ExaLog_RESUME_EXAM: + case ExaLog_FINISH_EXAM: + Class = "DAT_SMALL_N"; + break; + case ExaLog_ANSWER_QUESTION: + Class = "DAT_SMALL"; + break; + default: + Class = "DAT_SMALL_LIGHT"; + break; + } + else // Closed or not accesible exam print + Class = "DAT_SMALL_LIGHT"; + + /***** Write row *****/ + HTM_TR_Begin (NULL); + + /* Write number of click */ + HTM_TD_Begin ("class=\"RT COLOR%u %s\"", + Gbl.RowEvenOdd,UsrCouldAnswer ? "DAT_SMALL" : + "DAT_SMALL_LIGHT"); + HTM_Unsigned (NumClick + 1); + HTM_TD_End (); + + /* Write click time */ + if (asprintf (&Id,"click_date_%u",NumClick) < 0) + Err_NotEnoughMemoryExit (); + HTM_TD_Begin ("id=\"%s\" class=\"LT COLOR%u %s\"",Id,Gbl.RowEvenOdd,Class); + Dat_WriteLocalDateHMSFromUTC (Id,ClickTimeUTC, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,true,0x7); + free (Id); + HTM_TD_End (); + + /* Write action */ + HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); + HTM_Txt (Txt_EXAM_LOG_ACTIONS[Action]); + HTM_TD_End (); + + /* Write number of question */ + HTM_TD_Begin ("class=\"RT COLOR%u %s\"",Gbl.RowEvenOdd,Class); + if (QstInd >= 0) + HTM_Unsigned ((unsigned) QstInd + 1); + HTM_TD_End (); + + /* Write if exam print was open and accesible to answer */ + HTM_TD_Begin ("class=\"CT COLOR%u %s\"", + Gbl.RowEvenOdd,UsrCouldAnswer ? "DAT_SMALL_GREEN" : + "DAT_SMALL_RED"); + HTM_Txt (UsrCouldAnswer ? "✓" : + "✗"); + HTM_TD_End (); + + /* Write IP */ + HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); + Length = strlen (IP); + if (Length > 6) + { + sprintf (Anonymized,"%c%c%c…%c%c%c", + IP[0], + IP[1], + IP[2], + IP[Length - 3], + IP[Length - 2], + IP[Length - 1]); + HTM_Txt (Anonymized); + } + else + HTM_Txt (IP); + HTM_TD_End (); + + /* Write session id */ + HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); + if (SessionId[0]) + { + Length = strlen (SessionId); + if (Length > 6) + { + sprintf (Anonymized,"%c%c%c…%c%c%c", + SessionId[0], + SessionId[1], + SessionId[2], + SessionId[Length - 3], + SessionId[Length - 2], + SessionId[Length - 1]); + HTM_Txt (Anonymized); + } + else + HTM_Txt (SessionId); + } + HTM_TD_End (); + + /* Write user agent (row[6]) */ + HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); + if (UserAgent[0]) + HTM_Txt (UserAgent); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Free user agent *****/ + free (UserAgent); } - else // Closed or not accesible exam print - Class = "DAT_SMALL_LIGHT"; - - /***** Write row *****/ - HTM_TR_Begin (NULL); - - /* Write number of click */ - HTM_TD_Begin ("class=\"RT COLOR%u %s\"", - Gbl.RowEvenOdd,UsrCouldAnswer ? "DAT_SMALL" : - "DAT_SMALL_LIGHT"); - HTM_Unsigned (NumClick + 1); - HTM_TD_End (); - - /* Write click time */ - if (asprintf (&Id,"click_date_%u",NumClick) < 0) - Err_NotEnoughMemoryExit (); - HTM_TD_Begin ("id=\"%s\" class=\"LT COLOR%u %s\"",Id,Gbl.RowEvenOdd,Class); - Dat_WriteLocalDateHMSFromUTC (Id,ClickTimeUTC, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); - free (Id); - HTM_TD_End (); - - /* Write action */ - HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); - HTM_Txt (Txt_EXAM_LOG_ACTIONS[Action]); - HTM_TD_End (); - - /* Write number of question */ - HTM_TD_Begin ("class=\"RT COLOR%u %s\"",Gbl.RowEvenOdd,Class); - if (QstInd >= 0) - HTM_Unsigned ((unsigned) QstInd + 1); - HTM_TD_End (); - - /* Write if exam print was open and accesible to answer */ - HTM_TD_Begin ("class=\"CT COLOR%u %s\"", - Gbl.RowEvenOdd,UsrCouldAnswer ? "DAT_SMALL_GREEN" : - "DAT_SMALL_RED"); - HTM_Txt (UsrCouldAnswer ? "✓" : - "✗"); - HTM_TD_End (); - - /* Write IP */ - HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); - Length = strlen (IP); - if (Length > 6) - { - sprintf (Anonymized,"%c%c%c…%c%c%c", - IP[0], - IP[1], - IP[2], - IP[Length - 3], - IP[Length - 2], - IP[Length - 1]); - HTM_Txt (Anonymized); - } - else - HTM_Txt (IP); - HTM_TD_End (); - - /* Write session id */ - HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); - if (SessionId[0]) - { - Length = strlen (SessionId); - if (Length > 6) - { - sprintf (Anonymized,"%c%c%c…%c%c%c", - SessionId[0], - SessionId[1], - SessionId[2], - SessionId[Length - 3], - SessionId[Length - 2], - SessionId[Length - 1]); - HTM_Txt (Anonymized); - } - else - HTM_Txt (SessionId); - } - HTM_TD_End (); - - /* Write user agent (row[6]) */ - HTM_TD_Begin ("class=\"LT COLOR%u %s\"",Gbl.RowEvenOdd,Class); - if (UserAgent[0]) - HTM_Txt (UserAgent); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Free user agent *****/ - free (UserAgent); - } /***** End table and box *****/ Box_BoxTableEnd (); diff --git a/swad_exam_print.c b/swad_exam_print.c index 2a7d37ee..a0a65d76 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -146,9 +146,9 @@ static void ExaPrn_GetAnswerFromDB (struct ExaPrn_Print *Print,long QstCod, static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print, unsigned QstInd); -static void ExaPrn_GetNumQstsNotBlank (struct ExaPrn_Print *Print); -static void ExaPrn_ComputeTotalScoreOfPrint (struct ExaPrn_Print *Print); -static void ExaPrn_UpdatePrintInDB (const struct ExaPrn_Print *Print); +static unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod); +static double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod); +static void Exa_DB_UpdatePrint (const struct ExaPrn_Print *Print); /*****************************************************************************/ /**************************** Reset exam print *******************************/ @@ -679,34 +679,29 @@ static void ExaPrn_ShowExamPrintToFillIt (struct Exa_Exams *Exams, NULL,NULL, Hlp_ASSESSMENT_Exams_answer_exam,Box_NOT_CLOSABLE); - /***** Heading *****/ - /* Institution, degree and course */ - Lay_WriteHeaderClassPhoto (false,false, - Gbl.Hierarchy.Ins.InsCod, - Gbl.Hierarchy.Deg.DegCod, - Gbl.Hierarchy.Crs.CrsCod); + /***** Heading *****/ + /* Institution, degree and course */ + Lay_WriteHeaderClassPhoto (false,false, + Gbl.Hierarchy.Ins.InsCod, + Gbl.Hierarchy.Deg.DegCod, + Gbl.Hierarchy.Crs.CrsCod); - /***** Show user and time *****/ - /* Begin table */ - HTM_TABLE_BeginWideMarginPadding (10); + /***** Show user and time *****/ + HTM_TABLE_BeginWideMarginPadding (10); + ExaRes_ShowExamResultUser (&Gbl.Usrs.Me.UsrDat); + HTM_TABLE_End (); - /* User */ - ExaRes_ShowExamResultUser (&Gbl.Usrs.Me.UsrDat); + /***** Exam description *****/ + ExaPrn_GetAndWriteDescription (Exam->ExaCod); - /* End table */ - HTM_TABLE_End (); - - /* Exam description */ - ExaPrn_GetAndWriteDescription (Exam->ExaCod); - - if (Print->NumQsts.All) - { - /***** Show table with questions to answer *****/ - HTM_DIV_Begin ("id=\"examprint\""); // Used for AJAX based refresh - ExaPrn_ShowTableWithQstsToFill (Exams,Print); - HTM_DIV_End (); // Used for AJAX based refresh - } + if (Print->NumQsts.All) + { + /***** Show table with questions to answer *****/ + HTM_DIV_Begin ("id=\"examprint\""); // Used for AJAX based refresh + ExaPrn_ShowTableWithQstsToFill (Exams,Print); + HTM_DIV_End (); // Used for AJAX based refresh + } /***** End box *****/ Box_BoxEnd (); @@ -721,14 +716,14 @@ static void ExaPrn_GetAndWriteDescription (long ExaCod) char Txt[Cns_MAX_BYTES_TEXT + 1]; /***** Get description from database *****/ - Exa_GetExamTxtFromDB (ExaCod,Txt); + Exa_DB_GetExamTxt (ExaCod,Txt); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, // Convert from HTML to rigorous HTML Txt,Cns_MAX_BYTES_TEXT,false); Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links /***** Write description *****/ HTM_DIV_Begin ("class=\"EXA_PRN_DESC DAT_SMALL\""); - HTM_Txt (Txt); + HTM_Txt (Txt); HTM_DIV_End (); } @@ -746,24 +741,24 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (10); - /***** Write one row for each question *****/ - for (QstInd = 0; - QstInd < Print->NumQsts.All; - QstInd++) - { - /* Create test question */ - Tst_QstConstructor (&Question); - Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; + /***** Write one row for each question *****/ + for (QstInd = 0; + QstInd < Print->NumQsts.All; + QstInd++) + { + /* Create test question */ + Tst_QstConstructor (&Question); + Question.QstCod = Print->PrintedQuestions[QstInd].QstCod; - /* Get question from database */ - ExaSet_GetQstDataFromDB (&Question); + /* Get question from database */ + ExaSet_GetQstDataFromDB (&Question); - /* Write question and answers */ - ExaPrn_WriteQstAndAnsToFill (Print,QstInd,&Question); + /* Write question and answers */ + ExaPrn_WriteQstAndAnsToFill (Print,QstInd,&Question); - /* Destroy test question */ - Tst_QstDestructor (&Question); - } + /* Destroy test question */ + Tst_QstDestructor (&Question); + } /***** End table *****/ HTM_TABLE_End (); @@ -771,7 +766,7 @@ static void ExaPrn_ShowTableWithQstsToFill (struct Exa_Exams *Exams, /***** Form to end/close this exam print *****/ Frm_BeginFormId (ActEndExaPrn,"finished"); ExaSes_PutParamsEdit (Exams); - Btn_PutCreateButton (Txt_I_have_finished); + Btn_PutCreateButton (Txt_I_have_finished); Frm_EndForm (); } @@ -800,38 +795,38 @@ static void ExaPrn_WriteQstAndAnsToFill (const struct ExaPrn_Print *Print, /***** Title for this set *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"2\" class=\"COLOR0\""); - ExaSet_WriteSetTitle (&CurrentSet); - HTM_TD_End (); + HTM_TD_Begin ("colspan=\"2\" class=\"COLOR0\""); + ExaSet_WriteSetTitle (&CurrentSet); + HTM_TD_End (); HTM_TR_End (); } /***** Begin row *****/ HTM_TR_Begin (NULL); - /***** Number of question and answer type *****/ - HTM_TD_Begin ("class=\"RT\""); - Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); - Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); - HTM_TD_End (); + /***** Number of question and answer type *****/ + HTM_TD_Begin ("class=\"RT\""); + Tst_WriteNumQst (QstInd + 1,"BIG_INDEX"); + Tst_WriteAnswerType (Question->Answer.Type,"DAT_SMALL"); + HTM_TD_End (); - /***** Stem, media and answers *****/ - HTM_TD_Begin ("class=\"LT\""); + /***** Stem, media and answers *****/ + HTM_TD_Begin ("class=\"LT\""); - /* Stem */ - Tst_WriteQstStem (Question->Stem,"TEST_TXT",true); + /* Stem */ + Tst_WriteQstStem (Question->Stem,"TEST_TXT",true); - /* Media */ - Med_ShowMedia (&Question->Media, - "TEST_MED_SHOW_CONT", - "TEST_MED_SHOW"); + /* Media */ + Med_ShowMedia (&Question->Media, + "TEST_MED_SHOW_CONT", + "TEST_MED_SHOW"); - /* Answers */ - Frm_BeginFormNoAction (); // Form that can not be submitted, to avoid enter key to send it - ExaPrn_WriteAnswersToFill (Print,QstInd,Question); - Frm_EndForm (); + /* Answers */ + Frm_BeginFormNoAction (); // Form that can not be submitted, to avoid enter key to send it + ExaPrn_WriteAnswersToFill (Print,QstInd,Question); + Frm_EndForm (); - HTM_TD_End (); + HTM_TD_End (); /***** End row *****/ HTM_TR_End (); @@ -950,48 +945,48 @@ static void ExaPrn_WriteChoAnsToFill (const struct ExaPrn_Print *Print, /***** Begin table *****/ HTM_TABLE_BeginPadding (2); - for (NumOpt = 0; - NumOpt < Question->Answer.NumOptions; - NumOpt++) - { - /***** Indexes are 0 1 2 3... if no shuffle - or 3 1 0 2... (example) if shuffle *****/ - HTM_TR_Begin (NULL); + for (NumOpt = 0; + NumOpt < Question->Answer.NumOptions; + NumOpt++) + { + /***** Indexes are 0 1 2 3... if no shuffle + or 3 1 0 2... (example) if shuffle *****/ + HTM_TR_Begin (NULL); - /***** Write selectors and letter of this option *****/ - /* Initially user has not answered the question ==> initially all the answers will be blank. - If the user does not confirm the submission of their exam ==> - ==> the exam may be half filled ==> the answers displayed will be those selected by the user. */ - HTM_TD_Begin ("class=\"LT\""); - snprintf (Id,sizeof (Id),"Ans%010u",QstInd); - HTM_TxtF ("Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" : - "checkbox", - Id,NumOpt,Indexes[NumOpt], - UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" : - ""); - ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,(int) NumOpt); - HTM_Txt (" />"); - HTM_TD_End (); + /***** Write selectors and letter of this option *****/ + /* Initially user has not answered the question ==> initially all the answers will be blank. + If the user does not confirm the submission of their exam ==> + ==> the exam may be half filled ==> the answers displayed will be those selected by the user. */ + HTM_TD_Begin ("class=\"LT\""); + snprintf (Id,sizeof (Id),"Ans%010u",QstInd); + HTM_TxtF ("Answer.Type == Tst_ANS_UNIQUE_CHOICE ? "radio" : + "checkbox", + Id,NumOpt,Indexes[NumOpt], + UsrAnswers[Indexes[NumOpt]] ? " checked=\"checked\"" : + ""); + ExaPrn_WriteJSToUpdateExamPrint (Print,QstInd,Id,(int) NumOpt); + HTM_Txt (" />"); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LT\""); - HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt); - HTM_TxtF ("%c) ",'a' + (char) NumOpt); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LT\""); + HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt); + HTM_TxtF ("%c) ",'a' + (char) NumOpt); + HTM_LABEL_End (); + HTM_TD_End (); - /***** Write the option text *****/ - HTM_TD_Begin ("class=\"LT\""); - HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt); - HTM_Txt (Question->Answer.Options[Indexes[NumOpt]].Text); - HTM_LABEL_End (); - Med_ShowMedia (&Question->Answer.Options[Indexes[NumOpt]].Media, - "TEST_MED_SHOW_CONT", - "TEST_MED_SHOW"); - HTM_TD_End (); + /***** Write the option text *****/ + HTM_TD_Begin ("class=\"LT\""); + HTM_LABEL_Begin ("for=\"Ans%010u_%u\" class=\"TEST_TXT\"",QstInd,NumOpt); + HTM_Txt (Question->Answer.Options[Indexes[NumOpt]].Text); + HTM_LABEL_End (); + Med_ShowMedia (&Question->Answer.Options[Indexes[NumOpt]].Media, + "TEST_MED_SHOW_CONT", + "TEST_MED_SHOW"); + HTM_TD_End (); - HTM_TR_End (); - } + HTM_TR_End (); + } /***** End table *****/ HTM_TABLE_End (); @@ -1110,9 +1105,9 @@ void ExaPrn_ReceivePrintAnswer (void) ExaPrn_ComputeScoreAndStoreQuestionOfPrint (&Print,QstInd); /* Update exam print in database */ - ExaPrn_GetNumQstsNotBlank (&Print); - ExaPrn_ComputeTotalScoreOfPrint (&Print); - ExaPrn_UpdatePrintInDB (&Print); + Print.NumQsts.NotBlank = Exa_DB_GetNumQstsNotBlankInPrint (Print.PrnCod); + Print.Score.All = Exa_DB_ComputeTotalScoreOfPrint (Print.PrnCod); + Exa_DB_UpdatePrint (&Print); /***** Show table with questions to answer *****/ ExaPrn_ShowTableWithQstsToFill (&Exams,&Print); @@ -1128,7 +1123,7 @@ void ExaPrn_ReceivePrintAnswer (void) /***** Form to end/close this exam print *****/ Frm_BeginForm (ActEndExaPrn); ExaSes_PutParamsEdit (&Exams); - Btn_PutCreateButton (Txt_Continue); + Btn_PutCreateButton (Txt_Continue); Frm_EndForm (); } } @@ -1485,37 +1480,35 @@ static void ExaPrn_StoreOneQstOfPrintInDB (const struct ExaPrn_Print *Print, /************ Get number of questions not blank in an exam print *************/ /*****************************************************************************/ -static void ExaPrn_GetNumQstsNotBlank (struct ExaPrn_Print *Print) +static unsigned Exa_DB_GetNumQstsNotBlankInPrint (long PrnCod) { - /***** Count number of questions not blank in exam print in database *****/ - Print->NumQsts.NotBlank = (unsigned) + return (unsigned) DB_QueryCOUNT ("can not get number of questions not blank", "SELECT COUNT(*)" " FROM exa_print_questions" " WHERE PrnCod=%ld" " AND Answers<>''", - Print->PrnCod); + PrnCod); } /*****************************************************************************/ -/***************** Compute score of questions of an exam print ***************/ +/************* Compute total score of questions of an exam print *************/ /*****************************************************************************/ -static void ExaPrn_ComputeTotalScoreOfPrint (struct ExaPrn_Print *Print) +static double Exa_DB_ComputeTotalScoreOfPrint (long PrnCod) { - /***** Compute total score of exam print *****/ - Print->Score.All = DB_QuerySELECTDouble ("can not get score of exam print", - "SELECT SUM(Score)" - " FROM exa_print_questions" - " WHERE PrnCod=%ld", - Print->PrnCod); + return DB_QuerySELECTDouble ("can not get score of exam print", + "SELECT SUM(Score)" + " FROM exa_print_questions" + " WHERE PrnCod=%ld", + PrnCod); } /*****************************************************************************/ /********************** Update exam print in database ************************/ /*****************************************************************************/ -static void ExaPrn_UpdatePrintInDB (const struct ExaPrn_Print *Print) +static void Exa_DB_UpdatePrint (const struct ExaPrn_Print *Print) { /***** Update exam print in database *****/ Str_SetDecimalPointToUS (); // To print the floating point as a dot diff --git a/swad_exam_result.c b/swad_exam_result.c index 7ab8f8ae..c00baa11 100644 --- a/swad_exam_result.c +++ b/swad_exam_result.c @@ -576,29 +576,37 @@ static void ExaRes_ShowResultsBegin (struct Exa_Exams *Exams, { extern const char *Hlp_ASSESSMENT_Exams_results; - /***** Begin box *****/ + /***** Begin section *****/ HTM_SECTION_Begin (ExaRes_RESULTS_BOX_ID); - Box_BoxBegin ("100%",Title, - NULL,NULL, - Hlp_ASSESSMENT_Exams_results,Box_NOT_CLOSABLE); - /***** List exams to select *****/ - if (ListExamsToSelect) - ExaRes_ListExamsToSelect (Exams); + /***** Begin box *****/ + Box_BoxBegin ("100%",Title, + NULL,NULL, + Hlp_ASSESSMENT_Exams_results,Box_NOT_CLOSABLE); - /***** Begin session results table *****/ - HTM_SECTION_Begin (ExaRes_RESULTS_TABLE_ID); - HTM_TABLE_BeginWidePadding (5); + /***** List exams to select *****/ + if (ListExamsToSelect) + ExaRes_ListExamsToSelect (Exams); + + /***** Begin session results section *****/ + HTM_SECTION_Begin (ExaRes_RESULTS_TABLE_ID); + + /* Begin session results table */ + HTM_TABLE_BeginWidePadding (5); } static void ExaRes_ShowResultsEnd (void) { - /***** End session results table *****/ - HTM_TABLE_End (); - HTM_SECTION_End (); + /* End session results table */ + HTM_TABLE_End (); - /***** End box *****/ - Box_BoxEnd (); + /***** End session results section *****/ + HTM_SECTION_End (); + + /***** End box *****/ + Box_BoxEnd (); + + /***** End section *****/ HTM_SECTION_End (); } @@ -621,78 +629,76 @@ static void ExaRes_ListExamsToSelect (struct Exa_Exams *Exams) /***** Begin box *****/ Box_BoxBegin (NULL,Txt_Exams, - NULL,NULL, - NULL,Box_CLOSABLE); + NULL,NULL, + NULL,Box_CLOSABLE); - /***** Begin form to update the results - depending on the exams selected *****/ - Frm_StartFormAnchor (Gbl.Action.Act,ExaRes_RESULTS_TABLE_ID); - Grp_PutParamsCodGrps (); - Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected); + /***** Begin form to update the results + depending on the exams selected *****/ + Frm_StartFormAnchor (Gbl.Action.Act,ExaRes_RESULTS_TABLE_ID); + Grp_PutParamsCodGrps (); + Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected); - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,2,NULL,NULL); + HTM_TH (1,1,"LM",Txt_Exam); + HTM_TR_End (); - HTM_TH (1,2,NULL,NULL); - HTM_TH (1,1,"LM",Txt_Exam); + /***** List the sessions *****/ + for (NumExam = 0, UniqueId = 1, Gbl.RowEvenOdd = 0; + NumExam < Exams->Num; + NumExam++, UniqueId++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) + { + /* Get data of this exam */ + Exam.ExaCod = Exams->Lst[NumExam].ExaCod; + Exa_GetDataOfExamByCod (&Exam); + Exams->ExaCod = Exam.ExaCod; - HTM_TR_End (); + /* Write a row for this session */ + HTM_TR_Begin (NULL); - /***** List the sessions *****/ - for (NumExam = 0, UniqueId = 1, Gbl.RowEvenOdd = 0; - NumExam < Exams->Num; - NumExam++, UniqueId++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd) - { - /* Get data of this exam */ - Exam.ExaCod = Exams->Lst[NumExam].ExaCod; - Exa_GetDataOfExamByCod (&Exam); - Exams->ExaCod = Exam.ExaCod; + HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd); + HTM_INPUT_CHECKBOX ("ExaCod",HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Gam%u\" value=\"%ld\"%s", + NumExam,Exams->Lst[NumExam].ExaCod, + Exams->Lst[NumExam].Selected ? " checked=\"checked\"" : + ""); + HTM_TD_End (); - /* Write a row for this session */ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); + HTM_LABEL_Begin ("for=\"Gam%u\"",NumExam); + HTM_TxtF ("%u:",NumExam + 1); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd); - HTM_INPUT_CHECKBOX ("ExaCod",HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Gam%u\" value=\"%ld\"%s", - NumExam,Exams->Lst[NumExam].ExaCod, - Exams->Lst[NumExam].Selected ? " checked=\"checked\"" : - ""); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Txt (Exam.Title); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - HTM_LABEL_Begin ("for=\"Gam%u\"",NumExam); - HTM_TxtF ("%u:",NumExam + 1); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TR_End (); + } - HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Txt (Exam.Title); - HTM_TD_End (); + /***** Put button to refresh *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); - } + HTM_TD_Begin ("colspan=\"3\" class=\"CM\""); + HTM_BUTTON_Animated_Begin (Txt_Update_results, + The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme], + NULL); + Ico_PutCalculateIconWithText (Txt_Update_results); + HTM_BUTTON_End (); + HTM_TD_End (); - /***** Put button to refresh *****/ - HTM_TR_Begin (NULL); + HTM_TR_End (); - HTM_TD_Begin ("colspan=\"3\" class=\"CM\""); - HTM_BUTTON_Animated_Begin (Txt_Update_results, - The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme], - NULL); - Ico_PutCalculateIconWithText (Txt_Update_results); - HTM_BUTTON_End (); - HTM_TD_End (); + /***** End table *****/ + HTM_TABLE_End (); - HTM_TR_End (); - - /***** End table *****/ - HTM_TABLE_End (); - - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); /***** End box *****/ Box_BoxEnd (); @@ -721,45 +727,39 @@ static void ExaRes_ShowHeaderResults (Usr_MeOrOther_t MeOrOther) /***** First row *****/ HTM_TR_Begin (NULL); - - HTM_TH (3,2,"CT LINE_BOTTOM",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex : - Usr_SEX_UNKNOWN]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_START_TIME]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME ]); - HTM_TH (3,1,"LT LINE_BOTTOM",Txt_Session); - HTM_TH (1,3,"CT LINE_LEFT",Txt_Questions); - HTM_TH (1,5,"CT LINE_LEFT",Txt_Valid_answers); - HTM_TH (1,2,"CT LINE_LEFT",Txt_Score); - HTM_TH (3,1,"RT LINE_BOTTOM LINE_LEFT",Txt_Grade); - HTM_TH (3,1,"LINE_BOTTOM LINE_LEFT",NULL); - + HTM_TH (3,2,"CT LINE_BOTTOM",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex : + Usr_SEX_UNKNOWN]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_START_TIME]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_START_END_TIME[Dat_END_TIME ]); + HTM_TH (3,1,"LT LINE_BOTTOM",Txt_Session); + HTM_TH (1,3,"CT LINE_LEFT",Txt_Questions); + HTM_TH (1,5,"CT LINE_LEFT",Txt_Valid_answers); + HTM_TH (1,2,"CT LINE_LEFT",Txt_Score); + HTM_TH (3,1,"RT LINE_BOTTOM LINE_LEFT",Txt_Grade); + HTM_TH (3,1,"LINE_BOTTOM LINE_LEFT",NULL); HTM_TR_End (); /***** Second row *****/ HTM_TR_Begin (NULL); - - HTM_TH (2,1,"RT LINE_BOTTOM LINE_LEFT",Txt_total); - HTM_TH (2,1,"RT LINE_BOTTOM",Txt_QUESTIONS_valid); - HTM_TH (2,1,"RT LINE_BOTTOM",Txt_QUESTIONS_invalid); - HTM_TH (1,1,"RT LINE_LEFT",Txt_ANSWERS_correct); - HTM_TH (1,3,"CT",Txt_ANSWERS_wrong); - HTM_TH (1,1,"RT",Txt_ANSWERS_blank); - HTM_TH (1,1,"RT LINE_LEFT",Txt_total); - HTM_TH (1,1,"RT",Txt_average); - + HTM_TH (2,1,"RT LINE_BOTTOM LINE_LEFT",Txt_total); + HTM_TH (2,1,"RT LINE_BOTTOM",Txt_QUESTIONS_valid); + HTM_TH (2,1,"RT LINE_BOTTOM",Txt_QUESTIONS_invalid); + HTM_TH (1,1,"RT LINE_LEFT",Txt_ANSWERS_correct); + HTM_TH (1,3,"CT",Txt_ANSWERS_wrong); + HTM_TH (1,1,"RT",Txt_ANSWERS_blank); + HTM_TH (1,1,"RT LINE_LEFT",Txt_total); + HTM_TH (1,1,"RT",Txt_average); HTM_TR_End (); /***** Third row *****/ HTM_TR_Begin (NULL); - - HTM_TH (1,1,"RT LINE_BOTTOM LINE_LEFT","{pi=1}"); - HTM_TH (1,1,"RT LINE_BOTTOM","{-1≤pi<0}"); - HTM_TH (1,1,"RT LINE_BOTTOM","{pi=0}"); - HTM_TH (1,1,"RT LINE_BOTTOM","{0<pi<1}"); - HTM_TH (1,1,"RT LINE_BOTTOM","{pi=0}"); - HTM_TH (1,1,"RT LINE_BOTTOM LINE_LEFT","Σpi"); - HTM_TH (1,1,"RT LINE_BOTTOM","-1≤p≤1"); - + HTM_TH (1,1,"RT LINE_BOTTOM LINE_LEFT","{pi=1}"); + HTM_TH (1,1,"RT LINE_BOTTOM","{-1≤pi<0}"); + HTM_TH (1,1,"RT LINE_BOTTOM","{pi=0}"); + HTM_TH (1,1,"RT LINE_BOTTOM","{0<pi<1}"); + HTM_TH (1,1,"RT LINE_BOTTOM","{pi=0}"); + HTM_TH (1,1,"RT LINE_BOTTOM LINE_LEFT","Σpi"); + HTM_TH (1,1,"RT LINE_BOTTOM","-1≤p≤1"); HTM_TR_End (); } @@ -979,16 +979,16 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams, Err_NotEnoughMemoryExit (); HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"", Id,Gbl.RowEvenOdd); - Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,false,0x7); + Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,false,0x7); HTM_TD_End (); free (Id); } /* Write session title */ HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Txt (Session.Title); + HTM_Txt (Session.Title); HTM_TD_End (); /* Get and accumulate questions and score */ @@ -1011,159 +1011,159 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams, /* Write total number of questions */ HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - HTM_Unsigned (Print.NumQsts.All); - else - Ico_PutIconNotVisible (); + if (ICanView.Score) + HTM_Unsigned (Print.NumQsts.All); + else + Ico_PutIconNotVisible (); HTM_TD_End (); /* Valid questions */ HTM_TD_Begin ("class=\"DAT_GREEN RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Total) - HTM_Unsigned (Print.NumQsts.Valid.Total); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Total) + HTM_Unsigned (Print.NumQsts.Valid.Total); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); /* Invalid questions */ HTM_TD_Begin ("class=\"DAT_RED RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - NumQstsInvalid = Print.NumQsts.All - Print.NumQsts.Valid.Total; - if (NumQstsInvalid) - HTM_Unsigned (NumQstsInvalid); + if (ICanView.Score) + { + NumQstsInvalid = Print.NumQsts.All - Print.NumQsts.Valid.Total; + if (NumQstsInvalid) + HTM_Unsigned (NumQstsInvalid); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write number of correct questions */ HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Correct) - HTM_Unsigned (Print.NumQsts.Valid.Correct); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Correct) + HTM_Unsigned (Print.NumQsts.Valid.Correct); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write number of wrong questions */ HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Negative) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Negative); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Negative) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Negative); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Zero) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Zero); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Zero) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Zero); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Wrong.Positive) - HTM_Unsigned (Print.NumQsts.Valid.Wrong.Positive); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Wrong.Positive) + HTM_Unsigned (Print.NumQsts.Valid.Wrong.Positive); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write number of blank questions */ HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - if (Print.NumQsts.Valid.Blank) - HTM_Unsigned (Print.NumQsts.Valid.Blank); + if (ICanView.Score) + { + if (Print.NumQsts.Valid.Blank) + HTM_Unsigned (Print.NumQsts.Valid.Blank); + else + HTM_Light0 (); + } else - HTM_Light0 (); - } - else - Ico_PutIconNotVisible (); + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write score valid (taking into account only valid questions) */ HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - HTM_Double2Decimals (Print.Score.Valid); - HTM_Txt ("/"); - HTM_Unsigned (Print.NumQsts.Valid.Total); - } - else - Ico_PutIconNotVisible (); + if (ICanView.Score) + { + HTM_Double2Decimals (Print.Score.Valid); + HTM_Txt ("/"); + HTM_Unsigned (Print.NumQsts.Valid.Total); + } + else + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write average score per question (taking into account only valid questions) */ HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - HTM_Double2Decimals (Print.NumQsts.Valid.Total ? Print.Score.Valid / - (double) Print.NumQsts.Valid.Total : - 0.0); - else - Ico_PutIconNotVisible (); + if (ICanView.Score) + HTM_Double2Decimals (Print.NumQsts.Valid.Total ? Print.Score.Valid / + (double) Print.NumQsts.Valid.Total : + 0.0); + else + Ico_PutIconNotVisible (); HTM_TD_End (); /* Write grade over maximum grade (taking into account only valid questions) */ HTM_TD_Begin ("class=\"DAT RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Score) - { - Grade = TstPrn_ComputeGrade (Print.NumQsts.Valid.Total,Print.Score.Valid,Exam.MaxGrade); - TstPrn_ShowGrade (Grade,Exam.MaxGrade); - TotalGrade += Grade; - } - else - Ico_PutIconNotVisible (); + if (ICanView.Score) + { + Grade = TstPrn_ComputeGrade (Print.NumQsts.Valid.Total,Print.Score.Valid,Exam.MaxGrade); + TstPrn_ShowGrade (Grade,Exam.MaxGrade); + TotalGrade += Grade; + } + else + Ico_PutIconNotVisible (); HTM_TD_End (); /* Link to show this result */ HTM_TD_Begin ("class=\"RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanView.Result) - { - Exams->ExaCod = Session.ExaCod; - Exams->SesCod = Session.SesCod; - switch (MeOrOther) + if (ICanView.Result) { - case Usr_ME: - Frm_BeginForm (ActSeeOneExaResMe); - ExaSes_PutParamsEdit (Exams); - break; - case Usr_OTHER: - Frm_BeginForm (ActSeeOneExaResOth); - ExaSes_PutParamsEdit (Exams); - Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); - break; + Exams->ExaCod = Session.ExaCod; + Exams->SesCod = Session.SesCod; + switch (MeOrOther) + { + case Usr_ME: + Frm_BeginForm (ActSeeOneExaResMe); + ExaSes_PutParamsEdit (Exams); + break; + case Usr_OTHER: + Frm_BeginForm (ActSeeOneExaResOth); + ExaSes_PutParamsEdit (Exams); + Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EnUsrCod); + break; + } + Ico_PutIconLink ("tasks.svg",Txt_Result); + Frm_EndForm (); } - Ico_PutIconLink ("tasks.svg",Txt_Result); - Frm_EndForm (); - } - else - Ico_PutIconNotVisible (); + else + Ico_PutIconNotVisible (); HTM_TD_End (); HTM_TR_End (); @@ -1222,95 +1222,95 @@ static void ExaRes_ShowResultsSummaryRow (unsigned NumResults, /***** Start row *****/ HTM_TR_Begin (NULL); - /***** Row title *****/ - HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - HTM_TxtColonNBSP (Txt_Sessions); - HTM_Unsigned (NumResults); - HTM_TD_End (); + /***** Row title *****/ + HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + HTM_TxtColonNBSP (Txt_Sessions); + HTM_Unsigned (NumResults); + HTM_TD_End (); - /***** Write total number of questions *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Unsigned (NumTotalQsts->All); - HTM_TD_End (); + /***** Write total number of questions *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Unsigned (NumTotalQsts->All); + HTM_TD_End (); - /***** Write total number of valid questions *****/ - HTM_TD_Begin ("class=\"DAT_GREEN RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Total) - HTM_Unsigned (NumTotalQsts->Valid.Total); - else - HTM_Light0 (); - HTM_TD_End (); + /***** Write total number of valid questions *****/ + HTM_TD_Begin ("class=\"DAT_GREEN RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Total) + HTM_Unsigned (NumTotalQsts->Valid.Total); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write total number of invalid questions *****/ - HTM_TD_Begin ("class=\"DAT_RED RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - NumTotalQstsInvalid = NumTotalQsts->All - NumTotalQsts->Valid.Total; - if (NumTotalQstsInvalid) - HTM_Unsigned (NumTotalQstsInvalid); - else - HTM_Light0 (); - HTM_TD_End (); + /***** Write total number of invalid questions *****/ + HTM_TD_Begin ("class=\"DAT_RED RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + NumTotalQstsInvalid = NumTotalQsts->All - NumTotalQsts->Valid.Total; + if (NumTotalQstsInvalid) + HTM_Unsigned (NumTotalQstsInvalid); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write number of correct questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Correct) - HTM_Unsigned (NumTotalQsts->Valid.Correct); - else - HTM_Light0 (); - HTM_TD_End (); + /***** Write number of correct questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Correct) + HTM_Unsigned (NumTotalQsts->Valid.Correct); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write number of wrong questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Negative) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Negative); - else - HTM_Light0 (); - HTM_TD_End (); + /***** Write number of wrong questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Negative) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Negative); + else + HTM_Light0 (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Zero) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Zero); - else - HTM_Light0 (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Zero) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Zero); + else + HTM_Light0 (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Wrong.Positive) - HTM_Unsigned (NumTotalQsts->Valid.Wrong.Positive); - else - HTM_Light0 (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Wrong.Positive) + HTM_Unsigned (NumTotalQsts->Valid.Wrong.Positive); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write number of blank questions *****/ - HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - if (NumTotalQsts->Valid.Blank) - HTM_Unsigned (NumTotalQsts->Valid.Blank); - else - HTM_Light0 (); - HTM_TD_End (); + /***** Write number of blank questions *****/ + HTM_TD_Begin ("class=\"DAT_N RT LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + if (NumTotalQsts->Valid.Blank) + HTM_Unsigned (NumTotalQsts->Valid.Blank); + else + HTM_Light0 (); + HTM_TD_End (); - /***** Write total valid score *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (TotalScore->Valid); - HTM_Txt ("/"); - HTM_Unsigned (NumTotalQsts->Valid.Total); - HTM_TD_End (); + /***** Write total valid score *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (TotalScore->Valid); + HTM_Txt ("/"); + HTM_Unsigned (NumTotalQsts->Valid.Total); + HTM_TD_End (); - /***** Write average valid score per valid question *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (NumTotalQsts->Valid.Total ? TotalScore->Valid / - (double) NumTotalQsts->Valid.Total : - 0.0); - HTM_TD_End (); + /***** Write average valid score per valid question *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (NumTotalQsts->Valid.Total ? TotalScore->Valid / + (double) NumTotalQsts->Valid.Total : + 0.0); + HTM_TD_End (); - /***** Write total grade *****/ - HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_Double2Decimals (TotalGrade); - HTM_TD_End (); + /***** Write total grade *****/ + HTM_TD_Begin ("class=\"DAT_N RM LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_Double2Decimals (TotalGrade); + HTM_TD_End (); - /***** Last cell *****/ - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); - HTM_TD_End (); + /***** Last cell *****/ + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LINE_BOTTOM LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd); + HTM_TD_End (); /***** End row *****/ HTM_TR_End (); @@ -1448,47 +1448,49 @@ static void ExaRes_ShowExamResult (const struct Exa_Exam *Exam, Box_BoxBegin (NULL,Session->Title, NULL,NULL, Hlp_ASSESSMENT_Exams_results,Box_NOT_CLOSABLE); - Lay_WriteHeaderClassPhoto (false,false, - Gbl.Hierarchy.Ins.InsCod, - Gbl.Hierarchy.Deg.DegCod, - Gbl.Hierarchy.Crs.CrsCod); - /***** Check user data *****/ - /* Get data of the user who answered the exam print */ - if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat, - Usr_DONT_GET_PREFS, - Usr_DONT_GET_ROLE_IN_CURRENT_CRS)) - Err_WrongUserExit (); - if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat)) - Err_NoPermissionExit (); + /***** Header *****/ + Lay_WriteHeaderClassPhoto (false,false, + Gbl.Hierarchy.Ins.InsCod, + Gbl.Hierarchy.Deg.DegCod, + Gbl.Hierarchy.Crs.CrsCod); - /***** Begin table *****/ - HTM_TABLE_BeginWideMarginPadding (10); + /***** Check user data *****/ + /* Get data of the user who answered the exam print */ + if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat, + Usr_DONT_GET_PREFS, + Usr_DONT_GET_ROLE_IN_CURRENT_CRS)) + Err_WrongUserExit (); + if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat)) + Err_NoPermissionExit (); - /***** User *****/ - ExaRes_ShowExamResultUser (UsrDat); + /***** Begin table *****/ + HTM_TABLE_BeginWideMarginPadding (10); - /***** Start/end time (for user in this exam print) *****/ - ExaRes_ShowExamResultTime (Print); + /* User */ + ExaRes_ShowExamResultUser (UsrDat); - /***** Number of questions *****/ - ExaRes_ShowExamResultNumQsts (Print,ICanView); + /* Start/end time (for user in this exam print) */ + ExaRes_ShowExamResultTime (Print); - /***** Number of answers *****/ - ExaRes_ShowExamResultNumAnss (Print,ICanView); + /* Number of questions */ + ExaRes_ShowExamResultNumQsts (Print,ICanView); - /***** Score *****/ - ExaRes_ShowExamResultScore (Print,ICanView); + /* Number of answers */ + ExaRes_ShowExamResultNumAnss (Print,ICanView); - /***** Grade *****/ - ExaRes_ShowExamResultGrade (Exam,Print,ICanView); + /* Score */ + ExaRes_ShowExamResultScore (Print,ICanView); - /***** Write answers and solutions *****/ - if (ICanView->Result) - ExaRes_ShowExamAnswers (UsrDat,Print,Visibility); + /* Grade */ + ExaRes_ShowExamResultGrade (Exam,Print,ICanView); - /***** End table *****/ - HTM_TABLE_End (); + /* Answers and solutions */ + if (ICanView->Result) + ExaRes_ShowExamAnswers (UsrDat,Print,Visibility); + + /***** End table *****/ + HTM_TABLE_End (); /***** End box *****/ Box_BoxEnd (); @@ -1668,20 +1670,20 @@ static void ExaRes_ShowExamResultTime (struct ExaPrn_Print *Print) /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_START_END_TIME[StartEndTime]); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_START_END_TIME[StartEndTime]); + HTM_TD_End (); - /***** Time *****/ - if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0) - Err_NotEnoughMemoryExit (); - HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id); - Dat_WriteLocalDateHMSFromUTC (Id,Print->TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); - HTM_TD_End (); - free (Id); + /***** Time *****/ + if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0) + Err_NotEnoughMemoryExit (); + HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id); + Dat_WriteLocalDateHMSFromUTC (Id,Print->TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,true,0x7); + HTM_TD_End (); + free (Id); /***** Row end *****/ HTM_TR_End (); @@ -1702,40 +1704,40 @@ static void ExaRes_ShowExamResultNumQsts (struct ExaPrn_Print *Print, /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Questions); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Questions); + HTM_TD_End (); - /***** Number of questions *****/ - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView->Result) - { - HTM_TxtF ("%u",Print->NumQsts.All); - if (Print->NumQsts.All != Print->NumQsts.Valid.Total) - { - HTM_Txt (" ("); + /***** Number of questions *****/ + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView->Result) + { + HTM_TxtF ("%u",Print->NumQsts.All); + if (Print->NumQsts.All != Print->NumQsts.Valid.Total) + { + HTM_Txt (" ("); - /* Valid questions */ - HTM_SPAN_Begin ("class=\"DAT_GREEN\""); - HTM_TxtColonNBSP (Txt_QUESTIONS_valid); - HTM_Unsigned (Print->NumQsts.Valid.Total); - HTM_SPAN_End (); + /* Valid questions */ + HTM_SPAN_Begin ("class=\"DAT_GREEN\""); + HTM_TxtColonNBSP (Txt_QUESTIONS_valid); + HTM_Unsigned (Print->NumQsts.Valid.Total); + HTM_SPAN_End (); - HTM_TxtF ("; "); + HTM_TxtF ("; "); - /* Invalid questions */ - HTM_SPAN_Begin ("class=\"DAT_RED\""); - HTM_TxtColonNBSP (Txt_QUESTIONS_invalid); - HTM_Unsigned (Print->NumQsts.All - Print->NumQsts.Valid.Total); - HTM_SPAN_End (); + /* Invalid questions */ + HTM_SPAN_Begin ("class=\"DAT_RED\""); + HTM_TxtColonNBSP (Txt_QUESTIONS_invalid); + HTM_Unsigned (Print->NumQsts.All - Print->NumQsts.Valid.Total); + HTM_SPAN_End (); - HTM_Txt (")"); - } - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + HTM_Txt (")"); + } + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); /***** Row end *****/ HTM_TR_End (); @@ -1756,27 +1758,27 @@ static void ExaRes_ShowExamResultNumAnss (struct ExaPrn_Print *Print, /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Valid_answers); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Valid_answers); + HTM_TD_End (); - /***** Number of answers *****/ - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView->Score) - HTM_TxtF ("%s(pi=1): %u; " - "%s(-1≤pi<0): %u; " - "%s(pi=0): %u; " - "%s(0<pi<1): %u; " - "%s(pi=0): %u", - Txt_ANSWERS_correct,Print->NumQsts.Valid.Correct, - Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Negative, - Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Zero, - Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Positive, - Txt_ANSWERS_blank ,Print->NumQsts.Valid.Blank); - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + /***** Number of answers *****/ + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView->Score) + HTM_TxtF ("%s(pi=1): %u; " + "%s(-1≤pi<0): %u; " + "%s(pi=0): %u; " + "%s(0<pi<1): %u; " + "%s(pi=0): %u", + Txt_ANSWERS_correct,Print->NumQsts.Valid.Correct, + Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Negative, + Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Zero, + Txt_ANSWERS_wrong ,Print->NumQsts.Valid.Wrong.Positive, + Txt_ANSWERS_blank ,Print->NumQsts.Valid.Blank); + else + Ico_PutIconNotVisible (); + HTM_TD_End (); /***** Row end *****/ HTM_TR_End (); @@ -1795,39 +1797,39 @@ static void ExaRes_ShowExamResultScore (struct ExaPrn_Print *Print, /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Score); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Score); + HTM_TD_End (); - /***** Score *****/ - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView->Score) - { - /* Score counting all questions */ - if (Print->NumQsts.All == Print->NumQsts.Valid.Total) - HTM_STRONG_Begin (); - HTM_Double2Decimals (Print->Score.All); - HTM_Txt ("/"); - HTM_Unsigned (Print->NumQsts.All); - if (Print->NumQsts.All == Print->NumQsts.Valid.Total) - HTM_STRONG_End (); + /***** Score *****/ + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView->Score) + { + /* Score counting all questions */ + if (Print->NumQsts.All == Print->NumQsts.Valid.Total) + HTM_STRONG_Begin (); + HTM_Double2Decimals (Print->Score.All); + HTM_Txt ("/"); + HTM_Unsigned (Print->NumQsts.All); + if (Print->NumQsts.All == Print->NumQsts.Valid.Total) + HTM_STRONG_End (); - /* Scoure counting only valid questions */ - if (Print->NumQsts.All != Print->NumQsts.Valid.Total) - { - HTM_Txt ("; "); - HTM_TxtColonNBSP (Txt_valid_score); - HTM_STRONG_Begin (); - HTM_Double2Decimals (Print->Score.Valid); - HTM_Txt ("/"); - HTM_Unsigned (Print->NumQsts.Valid.Total); - HTM_STRONG_End (); - } - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + /* Scoure counting only valid questions */ + if (Print->NumQsts.All != Print->NumQsts.Valid.Total) + { + HTM_Txt ("; "); + HTM_TxtColonNBSP (Txt_valid_score); + HTM_STRONG_Begin (); + HTM_Double2Decimals (Print->Score.Valid); + HTM_Txt ("/"); + HTM_Unsigned (Print->NumQsts.Valid.Total); + HTM_STRONG_End (); + } + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); /***** Row end *****/ HTM_TR_End (); @@ -1847,35 +1849,35 @@ static void ExaRes_ShowExamResultGrade (const struct Exa_Exam *Exam, /***** Row begin *****/ HTM_TR_Begin (NULL); - /***** Label *****/ - HTM_TD_Begin ("class=\"DAT_N RT\""); - HTM_TxtColon (Txt_Grade); - HTM_TD_End (); + /***** Label *****/ + HTM_TD_Begin ("class=\"DAT_N RT\""); + HTM_TxtColon (Txt_Grade); + HTM_TD_End (); - /***** Grade *****/ - HTM_TD_Begin ("class=\"DAT LB\""); - if (ICanView->Score) - { - /* Grade counting all questions */ - if (Print->NumQsts.All == Print->NumQsts.Valid.Total) - HTM_STRONG_Begin (); - TstPrn_ComputeAndShowGrade (Print->NumQsts.All,Print->Score.All,Exam->MaxGrade); - if (Print->NumQsts.All == Print->NumQsts.Valid.Total) - HTM_STRONG_End (); + /***** Grade *****/ + HTM_TD_Begin ("class=\"DAT LB\""); + if (ICanView->Score) + { + /* Grade counting all questions */ + if (Print->NumQsts.All == Print->NumQsts.Valid.Total) + HTM_STRONG_Begin (); + TstPrn_ComputeAndShowGrade (Print->NumQsts.All,Print->Score.All,Exam->MaxGrade); + if (Print->NumQsts.All == Print->NumQsts.Valid.Total) + HTM_STRONG_End (); - /* Grade counting only valid questions */ - if (Print->NumQsts.All != Print->NumQsts.Valid.Total) - { - HTM_Txt ("; "); - HTM_TxtColonNBSP (Txt_valid_grade); - HTM_STRONG_Begin (); - TstPrn_ComputeAndShowGrade (Print->NumQsts.Valid.Total,Print->Score.Valid,Exam->MaxGrade); - HTM_STRONG_End (); - } - } - else - Ico_PutIconNotVisible (); - HTM_TD_End (); + /* Grade counting only valid questions */ + if (Print->NumQsts.All != Print->NumQsts.Valid.Total) + { + HTM_Txt ("; "); + HTM_TxtColonNBSP (Txt_valid_grade); + HTM_STRONG_Begin (); + TstPrn_ComputeAndShowGrade (Print->NumQsts.Valid.Total,Print->Score.Valid,Exam->MaxGrade); + HTM_STRONG_End (); + } + } + else + Ico_PutIconNotVisible (); + HTM_TD_End (); /***** Row end *****/ HTM_TR_End (); @@ -1978,54 +1980,54 @@ static void ExaRes_WriteQstAndAnsExam (struct UsrData *UsrDat, /***** Begin row *****/ HTM_TR_Begin (NULL); - /***** Number of question and answer type *****/ - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd + 1,ClassNumQst[Question->Validity]); - Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); - HTM_TD_End (); + /***** Number of question and answer type *****/ + HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + Tst_WriteNumQst (QstInd + 1,ClassNumQst[Question->Validity]); + Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); + HTM_TD_End (); - /***** Stem, media and answers *****/ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + /***** Stem, media and answers *****/ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - /* Stem */ - Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], - ICanView[TstVis_VISIBLE_QST_ANS_TXT]); + /* Stem */ + Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], + ICanView[TstVis_VISIBLE_QST_ANS_TXT]); - /* Media */ - if (ICanView[TstVis_VISIBLE_QST_ANS_TXT]) - Med_ShowMedia (&Question->Media, - "TEST_MED_SHOW_CONT", - "TEST_MED_SHOW"); + /* Media */ + if (ICanView[TstVis_VISIBLE_QST_ANS_TXT]) + Med_ShowMedia (&Question->Media, + "TEST_MED_SHOW_CONT", + "TEST_MED_SHOW"); - /* Answers */ - ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],Question); - TstPrn_WriteAnswersExam (UsrDat,&Print->PrintedQuestions[QstInd],Question, - ICanView, - ClassTxt[Question->Validity], - ClassFeedback[Question->Validity]); + /* Answers */ + ExaPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],Question); + TstPrn_WriteAnswersExam (UsrDat,&Print->PrintedQuestions[QstInd],Question, + ICanView, + ClassTxt[Question->Validity], + ClassFeedback[Question->Validity]); - /* Write score retrieved from database */ - if (ICanView[TstVis_VISIBLE_EACH_QST_SCORE]) - { - HTM_DIV_Begin ("class=\"DAT_SMALL LM\""); - HTM_TxtColonNBSP (Txt_Score); - HTM_SPAN_Begin ("class=\"%s\"", - Print->PrintedQuestions[QstInd].StrAnswers[0] ? - (Print->PrintedQuestions[QstInd].Score > 0 ? "ANS_OK" : // Correct/semicorrect - "ANS_BAD") : // Wrong - "ANS_0"); // Blank answer - HTM_Double2Decimals (Print->PrintedQuestions[QstInd].Score); - if (Question->Validity == Tst_INVALID_QUESTION) - HTM_TxtF (" (%s)",Txt_Invalid_question); - HTM_SPAN_End (); - HTM_DIV_End (); - } + /* Write score retrieved from database */ + if (ICanView[TstVis_VISIBLE_EACH_QST_SCORE]) + { + HTM_DIV_Begin ("class=\"DAT_SMALL LM\""); + HTM_TxtColonNBSP (Txt_Score); + HTM_SPAN_Begin ("class=\"%s\"", + Print->PrintedQuestions[QstInd].StrAnswers[0] ? + (Print->PrintedQuestions[QstInd].Score > 0 ? "ANS_OK" : // Correct/semicorrect + "ANS_BAD") : // Wrong + "ANS_0"); // Blank answer + HTM_Double2Decimals (Print->PrintedQuestions[QstInd].Score); + if (Question->Validity == Tst_INVALID_QUESTION) + HTM_TxtF (" (%s)",Txt_Invalid_question); + HTM_SPAN_End (); + HTM_DIV_End (); + } - /* Question feedback */ - if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) - Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); + /* Question feedback */ + if (ICanView[TstVis_VISIBLE_FEEDBACK_TXT]) + Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); - HTM_TD_End (); + HTM_TD_End (); /***** End row *****/ HTM_TR_End (); diff --git a/swad_exam_session.c b/swad_exam_session.c index f19f5624..afea27cd 100644 --- a/swad_exam_session.c +++ b/swad_exam_session.c @@ -107,8 +107,8 @@ static void ExaSes_ListOneOrMoreSessionsResultTch (struct Exa_Exams *Exams, static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res, struct ExaSes_Session *Session); -static void ExaSes_RemoveSessionFromAllTables (long SesCod); -static void ExaSes_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char *TableName); +static void Exa_DB_RemoveSessionFromAllTables (long SesCod); +static void Exa_DB_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char *TableName); static void ExaSes_PutFormSession (const struct ExaSes_Session *Session); static void ExaSes_ShowLstGrpsToCreateSession (long SesCod); @@ -116,8 +116,8 @@ static void ExaSes_ShowLstGrpsToCreateSession (long SesCod); static void ExaSes_CreateSession (struct ExaSes_Session *Session); static void ExaSes_UpdateSession (struct ExaSes_Session *Session); -static void ExaSes_CreateGrps (long SesCod); -static void ExaSes_RemoveGroups (long SesCod); +static void Exa_DB_CreateGrpsAssociatedToExamSession (long SesCod,const struct ListCodGrps *LstGrpsSel); +static void Exa_DB_RemoveGrpsAssociatedToExamSession (long SesCod); /*****************************************************************************/ /***************************** Reset exam session ****************************/ @@ -385,65 +385,67 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams, /***** Reset session *****/ ExaSes_ResetSession (&Session); - /***** Write the heading *****/ + /***** Begin table with sessions *****/ HTM_TABLE_BeginWidePadding (2); - ExaSes_ListOneOrMoreSessionsHeading (ICanEditSessions); - /***** Write rows *****/ - for (NumSession = 0, UniqueId = 1; - NumSession < NumSessions; - NumSession++, UniqueId++) - { - Gbl.RowEvenOdd = NumSession % 2; + /***** Write the heading *****/ + ExaSes_ListOneOrMoreSessionsHeading (ICanEditSessions); - /***** Get exam session data from row *****/ - ExaSes_GetSessionDataFromRow (mysql_res,&Session); - - if (ExaSes_CheckIfICanListThisSessionBasedOnGrps (Session.SesCod)) + /***** Write rows *****/ + for (NumSession = 0, UniqueId = 1; + NumSession < NumSessions; + NumSession++, UniqueId++) { - /***** Build anchor string *****/ - if (asprintf (&Anchor,"evt_%ld_%ld",Exam->ExaCod,Session.SesCod) < 0) - Err_NotEnoughMemoryExit (); + Gbl.RowEvenOdd = NumSession % 2; - /***** Begin row for this exam session ****/ - HTM_TR_Begin (NULL); + /***** Get exam session data from row *****/ + ExaSes_GetSessionDataFromRow (mysql_res,&Session); - /* Icons */ - if (ICanEditSessions) - if (ExaSes_CheckIfICanEditThisSession (&Session)) - ExaSes_ListOneOrMoreSessionsIcons (Exams,&Session,Anchor); - - /* Session participant */ - ExaSes_ListOneOrMoreSessionsAuthor (&Session); - - /* Start/end date/time */ - ExaSes_ListOneOrMoreSessionsTimes (&Session,UniqueId); - - /* Title and groups */ - ExaSes_ListOneOrMoreSessionsTitleGrps (Exams,Exam,&Session,Anchor); - - /* Session result visible? */ - ExaSes_ListOneOrMoreSessionsResult (Exams,&Session); - - /***** End row for this session ****/ - HTM_TR_End (); - - /***** For to edit this session ****/ - if (Session.SesCod == EvtCodToBeEdited) + if (ExaSes_CheckIfICanListThisSessionBasedOnGrps (Session.SesCod)) { + /***** Build anchor string *****/ + if (asprintf (&Anchor,"evt_%ld_%ld",Exam->ExaCod,Session.SesCod) < 0) + Err_NotEnoughMemoryExit (); + + /***** Begin row for this exam session ****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"6\" class=\"CT COLOR%u\"",Gbl.RowEvenOdd); - ExaSes_PutFormSession (&Session); // Form to edit existing session - HTM_TD_End (); + + /* Icons */ + if (ICanEditSessions) + if (ExaSes_CheckIfICanEditThisSession (&Session)) + ExaSes_ListOneOrMoreSessionsIcons (Exams,&Session,Anchor); + + /* Session participant */ + ExaSes_ListOneOrMoreSessionsAuthor (&Session); + + /* Start/end date/time */ + ExaSes_ListOneOrMoreSessionsTimes (&Session,UniqueId); + + /* Title and groups */ + ExaSes_ListOneOrMoreSessionsTitleGrps (Exams,Exam,&Session,Anchor); + + /* Session result visible? */ + ExaSes_ListOneOrMoreSessionsResult (Exams,&Session); + + /***** End row for this session ****/ HTM_TR_End (); + + /***** For to edit this session ****/ + if (Session.SesCod == EvtCodToBeEdited) + { + HTM_TR_Begin (NULL); + HTM_TD_Begin ("colspan=\"6\" class=\"CT COLOR%u\"",Gbl.RowEvenOdd); + ExaSes_PutFormSession (&Session); // Form to edit existing session + HTM_TD_End (); + HTM_TR_End (); + } + + /***** Free anchor string *****/ + free (Anchor); } - - /***** Free anchor string *****/ - free (Anchor); } - } - /***** End table *****/ + /***** End table with sessions *****/ HTM_TABLE_End (); } @@ -461,16 +463,16 @@ static void ExaSes_ListOneOrMoreSessionsHeading (bool ICanEditSessions) /***** Start row *****/ HTM_TR_Begin (NULL); - /***** Column for icons *****/ - if (ICanEditSessions) - HTM_TH_Empty (1); + /***** Column for icons *****/ + if (ICanEditSessions) + HTM_TH_Empty (1); - /***** The rest of columns *****/ - HTM_TH (1,1,"LT",Txt_ROLES_SINGUL_Abc[Rol_TCH][Usr_SEX_UNKNOWN]); - HTM_TH (1,1,"LT",Txt_START_END_TIME[Exa_ORDER_BY_START_DATE]); - HTM_TH (1,1,"LT",Txt_START_END_TIME[Exa_ORDER_BY_END_DATE ]); - HTM_TH (1,1,"LT",Txt_Session); - HTM_TH (1,1,"CT",Txt_Results); + /***** The rest of columns *****/ + HTM_TH (1,1,"LT",Txt_ROLES_SINGUL_Abc[Rol_TCH][Usr_SEX_UNKNOWN]); + HTM_TH (1,1,"LT",Txt_START_END_TIME[Exa_ORDER_BY_START_DATE]); + HTM_TH (1,1,"LT",Txt_START_END_TIME[Exa_ORDER_BY_END_DATE ]); + HTM_TH (1,1,"LT",Txt_Session); + HTM_TH (1,1,"CT",Txt_Results); /***** End row *****/ HTM_TR_End (); @@ -533,27 +535,27 @@ static void ExaSes_ListOneOrMoreSessionsIcons (struct Exa_Exams *Exams, const struct ExaSes_Session *Session, const char *Anchor) { - /***** Begin cell *****/ - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); - Exams->ExaCod = Session->ExaCod; Exams->SesCod = Session->SesCod; - /***** Icon to remove the exam session *****/ - Ico_PutContextualIconToRemove (ActReqRemExaSes,NULL, - ExaSes_PutParamsEdit,Exams); + /***** Begin cell *****/ + HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); - /***** Icon to hide/unhide the exam session *****/ - if (Session->Hidden) - Ico_PutContextualIconToUnhide (ActUnhExaSes,Anchor, + /***** Icon to remove the exam session *****/ + Ico_PutContextualIconToRemove (ActReqRemExaSes,NULL, ExaSes_PutParamsEdit,Exams); - else - Ico_PutContextualIconToHide (ActHidExaSes,Anchor, - ExaSes_PutParamsEdit,Exams); - /***** Icon to edit the exam session *****/ - Ico_PutContextualIconToEdit (ActEdiOneExaSes,Anchor, - ExaSes_PutParamsEdit,Exams); + /***** Icon to hide/unhide the exam session *****/ + if (Session->Hidden) + Ico_PutContextualIconToUnhide (ActUnhExaSes,Anchor, + ExaSes_PutParamsEdit,Exams); + else + Ico_PutContextualIconToHide (ActHidExaSes,Anchor, + ExaSes_PutParamsEdit,Exams); + + /***** Icon to edit the exam session *****/ + Ico_PutContextualIconToEdit (ActEdiOneExaSes,Anchor, + ExaSes_PutParamsEdit,Exams); /***** End cell *****/ HTM_TD_End (); @@ -567,7 +569,7 @@ static void ExaSes_ListOneOrMoreSessionsAuthor (const struct ExaSes_Session *Ses { /***** Session author (teacher) *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - Usr_WriteAuthor1Line (Session->UsrCod,Session->Hidden); + Usr_WriteAuthor1Line (Session->UsrCod,Session->Hidden); HTM_TD_End (); } @@ -587,17 +589,17 @@ static void ExaSes_ListOneOrMoreSessionsTimes (const struct ExaSes_Session *Sess StartEndTime++) { Color = Session->Open ? (Session->Hidden ? "DATE_GREEN_LIGHT": - "DATE_GREEN") : - (Session->Hidden ? "DATE_RED_LIGHT": - "DATE_RED"); + "DATE_GREEN") : + (Session->Hidden ? "DATE_RED_LIGHT": + "DATE_RED"); if (asprintf (&Id,"exa_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0) Err_NotEnoughMemoryExit (); HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"", Id,Color,Gbl.RowEvenOdd); - Dat_WriteLocalDateHMSFromUTC (Id,Session->TimeUTC[StartEndTime], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, - true,true,true,0x6); + Dat_WriteLocalDateHMSFromUTC (Id,Session->TimeUTC[StartEndTime], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK, + true,true,true,0x6); HTM_TD_End (); free (Id); } @@ -617,34 +619,34 @@ static void ExaSes_ListOneOrMoreSessionsTitleGrps (struct Exa_Exams *Exams, HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - /***** Session title *****/ - HTM_ARTICLE_Begin (Anchor); - if (ExaSes_CheckIfICanAnswerThisSession (Exam,Session)) - { - Frm_BeginForm (ActSeeExaPrn); - Exa_PutParams (Exams); - ExaSes_PutParamSesCod (Session->SesCod); - HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play : - Txt_Resume, - Session->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT": - "BT_LINK LT ASG_TITLE", - NULL); - HTM_Txt (Session->Title); - HTM_BUTTON_End (); - Frm_EndForm (); - } - else - { - HTM_SPAN_Begin ("class=\"%s\"",Session->Hidden ? "LT ASG_TITLE_LIGHT": - "LT ASG_TITLE"); - HTM_Txt (Session->Title); - HTM_SPAN_End (); - } - HTM_ARTICLE_End (); + /***** Session title *****/ + HTM_ARTICLE_Begin (Anchor); + if (ExaSes_CheckIfICanAnswerThisSession (Exam,Session)) + { + Frm_BeginForm (ActSeeExaPrn); + Exa_PutParams (Exams); + ExaSes_PutParamSesCod (Session->SesCod); + HTM_BUTTON_SUBMIT_Begin (Gbl.Usrs.Me.Role.Logged == Rol_STD ? Txt_Play : + Txt_Resume, + Session->Hidden ? "BT_LINK LT ASG_TITLE_LIGHT": + "BT_LINK LT ASG_TITLE", + NULL); + HTM_Txt (Session->Title); + HTM_BUTTON_End (); + Frm_EndForm (); + } + else + { + HTM_SPAN_Begin ("class=\"%s\"",Session->Hidden ? "LT ASG_TITLE_LIGHT": + "LT ASG_TITLE"); + HTM_Txt (Session->Title); + HTM_SPAN_End (); + } + HTM_ARTICLE_End (); - /***** Groups whose students can answer this exam session *****/ - if (Gbl.Crs.Grps.NumGrps) - ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (Session); + /***** Groups whose students can answer this exam session *****/ + if (Gbl.Crs.Grps.NumGrps) + ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (Session); HTM_TD_End (); } @@ -682,35 +684,35 @@ static void ExaSes_GetAndWriteNamesOfGrpsAssociatedToSession (const struct ExaSe /***** Write heading *****/ HTM_DIV_Begin ("class=\"%s\"",Session->Hidden ? "ASG_GRP_LIGHT": "ASG_GRP"); - HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group : - Txt_Groups); + HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group : + Txt_Groups); - /***** Write groups *****/ - if (NumGrps) // Groups found... - { - /* Get and write the group types and names */ - for (NumGrp = 0; - NumGrp < NumGrps; - NumGrp++) - { - /* Get next group */ - row = mysql_fetch_row (mysql_res); + /***** Write groups *****/ + if (NumGrps) // Groups found... + { + /* Get and write the group types and names */ + for (NumGrp = 0; + NumGrp < NumGrps; + NumGrp++) + { + /* Get next group */ + row = mysql_fetch_row (mysql_res); - /* Write group type name and group name */ - HTM_TxtF ("%s %s",row[0],row[1]); + /* Write group type name and group name */ + HTM_TxtF ("%s %s",row[0],row[1]); - if (NumGrps >= 2) - { - if (NumGrp == NumGrps - 2) - HTM_TxtF (" %s ",Txt_and); - if (NumGrps >= 3) - if (NumGrp < NumGrps - 2) - HTM_Txt (", "); - } - } - } - else - HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); + if (NumGrps >= 2) + { + if (NumGrp == NumGrps - 2) + HTM_TxtF (" %s ",Txt_and); + if (NumGrps >= 3) + if (NumGrp < NumGrps - 2) + HTM_Txt (", "); + } + } + } + else + HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_DIV_End (); @@ -727,20 +729,20 @@ static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams, { HTM_TD_Begin ("class=\"DAT CT COLOR%u\"",Gbl.RowEvenOdd); - switch (Gbl.Usrs.Me.Role.Logged) - { - case Rol_STD: - ExaSes_ListOneOrMoreSessionsResultStd (Exams,Session); - break; - case Rol_NET: - case Rol_TCH: - case Rol_SYS_ADM: - ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session); - break; - default: - Err_WrongRoleExit (); - break; - } + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_STD: + ExaSes_ListOneOrMoreSessionsResultStd (Exams,Session); + break; + case Rol_NET: + case Rol_TCH: + case Rol_SYS_ADM: + ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session); + break; + default: + Err_WrongRoleExit (); + break; + } HTM_TD_End (); } @@ -833,7 +835,7 @@ void ExaSes_ToggleVisResultsSesUsr (void) " WHERE exa_sessions.SesCod=%ld" " AND exa_sessions.ExaCod=%ld" // Extra check " AND exa_sessions.ExaCod=exa_exams.ExaCod" - " AND exa_exams.CrsCod=%ld", // Extra check + " AND exa_exams.CrsCod=%ld", // Extra check Session.ShowUsrResults ? 'Y' : 'N', Session.SesCod, @@ -960,7 +962,7 @@ void ExaSes_RemoveSession (void) Err_NoPermissionExit (); /***** Remove the exam session from all database tables *****/ - ExaSes_RemoveSessionFromAllTables (Session.SesCod); + Exa_DB_RemoveSessionFromAllTables (Session.SesCod); /***** Write message *****/ Ale_ShowAlert (Ale_SUCCESS,Txt_Session_X_removed, @@ -978,7 +980,7 @@ void ExaSes_RemoveSession (void) /******************* Remove exam session from all tables *********************/ /*****************************************************************************/ -static void ExaSes_RemoveSessionFromAllTables (long SesCod) +static void Exa_DB_RemoveSessionFromAllTables (long SesCod) { /* To delete orphan exam prints: // DELETE FROM exa_print_questions WHERE PrnCod IN (SELECT PrnCod FROM exa_prints WHERE SesCod NOT IN (SELECT SesCod FROM exa_sessions)); @@ -1017,7 +1019,7 @@ static void ExaSes_RemoveSessionFromAllTables (long SesCod) /**************** Remove exam session in exam from all tables ****************/ /*****************************************************************************/ -void ExaSes_RemoveSessionsInExamFromAllTables (long ExaCod) +void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod) { /***** Remove exam prints in this session *****/ /* @@ -1060,7 +1062,7 @@ void ExaSes_RemoveSessionsInExamFromAllTables (long ExaCod) /*************** Remove exam session in course from all tables ***************/ /*****************************************************************************/ -void ExaSes_RemoveSessionInCourseFromAllTables (long CrsCod) +void Exa_DB_RemoveSessionInCourseFromAllTables (long CrsCod) { /***** Remove exam prints in this course *****/ /* @@ -1112,13 +1114,13 @@ void ExaSes_RemoveSessionInCourseFromAllTables (long CrsCod) /************* Remove user from secondary exam session tables ****************/ /*****************************************************************************/ -void ExaSes_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod) +void Exa_DB_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod) { /***** Remove student from secondary tables *****/ - ExaSes_RemoveUsrSesResultsInCrs (UsrCod,CrsCod,"exa_prints"); + Exa_DB_RemoveUsrSesResultsInCrs (UsrCod,CrsCod,"exa_prints"); } -static void ExaSes_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char *TableName) +static void Exa_DB_RemoveUsrSesResultsInCrs (long UsrCod,long CrsCod,const char *TableName) { /***** Remove sessions in course from secondary table *****/ DB_QueryDELETE ("can not remove sessions of a user from table", @@ -1301,50 +1303,50 @@ static void ExaSes_PutFormSession (const struct ExaSes_Session *Session) /***** Begin section for a new exam session *****/ HTM_SECTION_Begin (ExaSes_NEW_SESSION_SECTION_ID); - /***** Begin form *****/ - Frm_BeginForm (ItsANewSession ? ActNewExaSes : // New session - ActChgExaSes); // Existing session - Exa_PutParamExamCod (Session->ExaCod); - if (!ItsANewSession) // Existing session - ExaSes_PutParamSesCod (Session->SesCod); + /***** Begin form *****/ + Frm_BeginForm (ItsANewSession ? ActNewExaSes : // New session + ActChgExaSes); // Existing session + Exa_PutParamExamCod (Session->ExaCod); + if (!ItsANewSession) // Existing session + ExaSes_PutParamSesCod (Session->SesCod); - /***** Begin box and table *****/ - Box_BoxTableBegin (NULL,ItsANewSession ? Txt_New_session : - Session->Title, - NULL,NULL, - Hlp_ASSESSMENT_Exams_sessions,Box_NOT_CLOSABLE,2); + /***** Begin box and table *****/ + Box_BoxTableBegin (NULL,ItsANewSession ? Txt_New_session : + Session->Title, + NULL,NULL, + Hlp_ASSESSMENT_Exams_sessions,Box_NOT_CLOSABLE,2); - /***** Session title *****/ - HTM_TR_Begin (NULL); + /***** Session title *****/ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Title",Txt_Title); + /* Label */ + Frm_LabelColumn ("RT","Title",Txt_Title); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_TEXT ("Title",ExaSes_MAX_CHARS_TITLE,Session->Title, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Title\" size=\"45\" required=\"required\""); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_INPUT_TEXT ("Title",ExaSes_MAX_CHARS_TITLE,Session->Title, + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Title\" size=\"45\" required=\"required\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Start and end dates *****/ - Dat_PutFormStartEndClientLocalDateTimes (Session->TimeUTC, - Dat_FORM_SECONDS_OFF, - SetHMS); + /***** Start and end dates *****/ + Dat_PutFormStartEndClientLocalDateTimes (Session->TimeUTC, + Dat_FORM_SECONDS_OFF, + SetHMS); - /***** Groups *****/ - ExaSes_ShowLstGrpsToCreateSession (Session->SesCod); + /***** Groups *****/ + ExaSes_ShowLstGrpsToCreateSession (Session->SesCod); - /***** End table, send button and end box *****/ - if (ItsANewSession) - Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_session); - else - Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes); + /***** End table, send button and end box *****/ + if (ItsANewSession) + Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_session); + else + Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes); - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); /***** End section for a new exam session *****/ HTM_SECTION_End (); @@ -1369,42 +1371,42 @@ static void ExaSes_ShowLstGrpsToCreateSession (long SesCod) /***** Begin box and table *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Groups); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Groups); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LT\""); - Box_BoxTableBegin ("95%",NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE,0); + HTM_TD_Begin ("class=\"LT\""); + Box_BoxTableBegin ("95%",NULL, + NULL,NULL, + NULL,Box_NOT_CLOSABLE,0); - /***** First row: checkbox to select the whole course *****/ - HTM_TR_Begin (NULL); + /***** First row: checkbox to select the whole course *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); - HTM_LABEL_Begin (NULL); - HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"WholeCrs\" value=\"Y\"%s" - " onclick=\"uncheckChildren(this,'GrpCods')\"", - Grp_CheckIfAssociatedToGrps ("exa_groups","SesCod",SesCod) ? "" : - " checked=\"checked\""); - HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); - HTM_LABEL_End (); - HTM_TD_End (); + HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\""); + 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 ("exa_groups","SesCod",SesCod) ? "" : + " checked=\"checked\""); + HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); + HTM_LABEL_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** List the groups for each group type *****/ - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], - Grp_EXA_EVENT,SesCod); + /***** List the groups for each group type *****/ + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) + Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], + Grp_EXA_EVENT,SesCod); - /***** End table and box *****/ - Box_BoxTableEnd (); - HTM_TD_End (); + /***** End table and box *****/ + Box_BoxTableEnd (); + HTM_TD_End (); HTM_TR_End (); } @@ -1423,7 +1425,7 @@ void ExaSes_PutButtonNewSession (struct Exa_Exams *Exams,long ExaCod) Exams->ExaCod = ExaCod; Frm_StartFormAnchor (ActReqNewExaSes,ExaSes_NEW_SESSION_SECTION_ID); Exa_PutParams (Exams); - Btn_PutConfirmButton (Txt_New_session); + Btn_PutConfirmButton (Txt_New_session); Frm_EndForm (); } @@ -1599,7 +1601,7 @@ static void ExaSes_CreateSession (struct ExaSes_Session *Session) /***** Create groups associated to the exam session *****/ if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) - ExaSes_CreateGrps (Session->SesCod); + Exa_DB_CreateGrpsAssociatedToExamSession (Session->SesCod,&Gbl.Crs.Grps.LstGrpsSel); } /*****************************************************************************/ @@ -1633,22 +1635,22 @@ static void ExaSes_UpdateSession (struct ExaSes_Session *Session) Gbl.Hierarchy.Crs.CrsCod); /***** Update groups associated to the exam session *****/ - ExaSes_RemoveGroups (Session->SesCod); // Remove all groups associated to this session + Exa_DB_RemoveGrpsAssociatedToExamSession (Session->SesCod); // Remove all groups associated to this session if (Gbl.Crs.Grps.LstGrpsSel.NumGrps) - ExaSes_CreateGrps (Session->SesCod); // Associate new groups + Exa_DB_CreateGrpsAssociatedToExamSession (Session->SesCod,&Gbl.Crs.Grps.LstGrpsSel); // Associate new groups } /*****************************************************************************/ /*************** Create groups associated to an exam session *****************/ /*****************************************************************************/ -static void ExaSes_CreateGrps (long SesCod) +static void Exa_DB_CreateGrpsAssociatedToExamSession (long SesCod,const struct ListCodGrps *LstGrpsSel) { unsigned NumGrpSel; /***** Create groups associated to the exam session *****/ for (NumGrpSel = 0; - NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps; + NumGrpSel < LstGrpsSel->NumGrps; NumGrpSel++) /* Create group */ DB_QueryINSERT ("can not associate a group to an exam session", @@ -1657,14 +1659,14 @@ static void ExaSes_CreateGrps (long SesCod) " VALUES" " (%ld,%ld)", SesCod, - Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]); + LstGrpsSel->GrpCods[NumGrpSel]); } /*****************************************************************************/ /******************** Remove all groups from one session *********************/ /*****************************************************************************/ -static void ExaSes_RemoveGroups (long SesCod) +static void Exa_DB_RemoveGrpsAssociatedToExamSession (long SesCod) { /***** Remove all groups from one session *****/ DB_QueryDELETE ("can not remove groups associated to a session", @@ -1677,7 +1679,7 @@ static void ExaSes_RemoveGroups (long SesCod) /******************** Remove one group from all sessions *********************/ /*****************************************************************************/ -void ExaSes_RemoveGroup (long GrpCod) +void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod) { /***** Remove group from all the sessions *****/ DB_QueryDELETE ("can not remove group" @@ -1691,7 +1693,7 @@ void ExaSes_RemoveGroup (long GrpCod) /**************** Remove groups of one type from all sessions ****************/ /*****************************************************************************/ -void ExaSes_RemoveGroupsOfType (long GrpTypCod) +void Exa_DB_RemoveGroupsOfTypeAssociatedToExamSessions (long GrpTypCod) { /***** Remove group from all the sessions *****/ DB_QueryDELETE ("can not remove groups of a type" diff --git a/swad_exam_session.h b/swad_exam_session.h index 7cdecf62..03e758e9 100644 --- a/swad_exam_session.h +++ b/swad_exam_session.h @@ -61,9 +61,9 @@ void ExaSes_ToggleVisResultsSesUsr (void); void ExaSes_RequestRemoveSession (void); void ExaSes_RemoveSession (void); -void ExaSes_RemoveSessionsInExamFromAllTables (long ExaCod); -void ExaSes_RemoveSessionInCourseFromAllTables (long CrsCod); -void ExaSes_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod); +void Exa_DB_RemoveSessionsInExamFromAllTables (long ExaCod); +void Exa_DB_RemoveSessionInCourseFromAllTables (long CrsCod); +void Exa_DB_RemoveUsrFromSessionTablesInCrs (long UsrCod,long CrsCod); void ExaSes_HideSession (void); void ExaSes_UnhideSession (void); @@ -79,8 +79,8 @@ void ExaSes_PutButtonNewSession (struct Exa_Exams *Exams,long ExaCod); void ExaSes_RequestCreatOrEditSession (void); void ExaSes_ReceiveFormSession (void); -void ExaSes_RemoveGroup (long GrpCod); -void ExaSes_RemoveGroupsOfType (long GrpTypCod); +void Exa_DB_RemoveGrpAssociatedToExamSessions (long GrpCod); +void Exa_DB_RemoveGroupsOfTypeAssociatedToExamSessions (long GrpTypCod); unsigned ExaSes_GetNumSessionsInExam (long ExaCod); unsigned ExaSes_GetNumOpenSessionsInExam (long ExaCod); diff --git a/swad_exam_set.c b/swad_exam_set.c index 4b6096eb..e2a2898e 100644 --- a/swad_exam_set.c +++ b/swad_exam_set.c @@ -81,9 +81,9 @@ extern struct Globals Gbl; static void ExaSet_PutParamsOneQst (void *Exams); -static unsigned ExaSet_GetNumQstsInSet (long SetCod); +static unsigned Exa_DB_GetNumQstsInSet (long SetCod); -static bool ExaSet_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, +static bool Exa_DB_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, const char Title[ExaSet_MAX_BYTES_TITLE + 1]); static void ExaSet_PutFormNewSet (struct Exa_Exams *Exams, @@ -96,20 +96,20 @@ static bool ExaSet_CheckSetTitleReceivedFromForm (const struct ExaSet_Set *Set, static void ExaSet_CreateSet (struct ExaSet_Set *Set); static void ExaSet_UpdateSet (const struct ExaSet_Set *Set); -static void ExaSet_UpdateSetTitleDB (const struct ExaSet_Set *Set, - const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]); -static void ExaSet_UpdateNumQstsToExamDB (const struct ExaSet_Set *Set, - unsigned NumQstsToPrint); +static void Exa_DB_UpdateSetTitle (const struct ExaSet_Set *Set, + const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]); +static void Exa_DB_UpdateNumQstsToExam (const struct ExaSet_Set *Set, + unsigned NumQstsToPrint); static void ExaSet_PutParamSetCod (long SetCod); static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod); static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd); -static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod); +static unsigned Exa_DB_GetMaxSetIndexInExam (long ExaCod); -static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd); -static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd); +static unsigned Exa_DB_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd); +static unsigned Exa_DB_GetNextSetIndexInExam (long ExaCod,unsigned SetInd); static void ExaSet_ListSetQuestions (struct Exa_Exams *Exams, const struct Exa_Exam *Exam, @@ -189,7 +189,7 @@ long ExaSet_GetParamSetCod (void) /********************* Get number of questions in a set **********************/ /*****************************************************************************/ -static unsigned ExaSet_GetNumQstsInSet (long SetCod) +static unsigned Exa_DB_GetNumQstsInSet (long SetCod) { /***** Get number of questions in set from database *****/ return (unsigned) @@ -266,7 +266,7 @@ void ExaSet_GetDataOfSetByCod (struct ExaSet_Set *Set) /************** Check if the title of a set of questions exists **************/ /*****************************************************************************/ -static bool ExaSet_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, +static bool Exa_DB_CheckIfSimilarSetExists (const struct ExaSet_Set *Set, const char Title[ExaSet_MAX_BYTES_TITLE + 1]) { /***** Get number of set of questions with a field value from database *****/ @@ -301,51 +301,51 @@ static void ExaSet_PutFormNewSet (struct Exa_Exams *Exams, Frm_BeginForm (ActNewExaSet); Exa_PutParams (Exams); - /***** Begin box and table *****/ - Box_BoxTableBegin (NULL,Txt_New_set_of_questions, - NULL,NULL, - NULL,Box_NOT_CLOSABLE,2); + /***** Begin box and table *****/ + Box_BoxTableBegin (NULL,Txt_New_set_of_questions, + NULL,NULL, + NULL,Box_NOT_CLOSABLE,2); - /***** Table heading *****/ - ExaSet_PutTableHeadingForSets (); + /***** Table heading *****/ + ExaSet_PutTableHeadingForSets (); - /***** Begin row *****/ - HTM_TR_Begin (NULL); + /***** Begin row *****/ + HTM_TR_Begin (NULL); - /***** Empty column for buttons *****/ - HTM_TD_Begin ("class=\"BM\""); - HTM_TD_End (); + /***** Empty column for buttons *****/ + HTM_TD_Begin ("class=\"BM\""); + HTM_TD_End (); - /***** Index *****/ - HTM_TD_Begin ("class=\"RM\""); - Tst_WriteNumQst (MaxSetInd + 1,"BIG_INDEX"); - HTM_TD_End (); + /***** Index *****/ + HTM_TD_Begin ("class=\"RM\""); + Tst_WriteNumQst (MaxSetInd + 1,"BIG_INDEX"); + HTM_TD_End (); - /***** Title *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set->Title, - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Title\" required=\"required\"" - " class=\"TITLE_DESCRIPTION_WIDTH\""); - HTM_TD_End (); + /***** Title *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set->Title, + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Title\" required=\"required\"" + " class=\"TITLE_DESCRIPTION_WIDTH\""); + HTM_TD_End (); - /***** Current number of questions in set *****/ - HTM_TD_Begin ("class=\"RM\""); - HTM_Unsigned (0); // New set ==> no questions yet - HTM_TD_End (); + /***** Current number of questions in set *****/ + HTM_TD_Begin ("class=\"RM\""); + HTM_Unsigned (0); // New set ==> no questions yet + HTM_TD_End (); - /***** Number of questions to appear in the exam *****/ - HTM_TD_Begin ("class=\"RM\""); - HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set->NumQstsToPrint, - HTM_DONT_SUBMIT_ON_CHANGE,false, - "class=\"INPUT_LONG\" required=\"required\""); - HTM_TD_End (); + /***** Number of questions to appear in the exam *****/ + HTM_TD_Begin ("class=\"RM\""); + HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set->NumQstsToPrint, + HTM_DONT_SUBMIT_ON_CHANGE,false, + "class=\"INPUT_LONG\" required=\"required\""); + HTM_TD_End (); - /***** End row *****/ - HTM_TR_End (); + /***** End row *****/ + HTM_TR_End (); - /***** End table, send button and end box *****/ - Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_set_of_questions); + /***** End table, send button and end box *****/ + Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_set_of_questions); /***** End form *****/ Frm_EndForm (); @@ -427,7 +427,7 @@ static bool ExaSet_CheckSetTitleReceivedFromForm (const struct ExaSet_Set *Set, if (strcmp (Set->Title,NewTitle)) // Different titles { /* If title of set was in database... */ - if (ExaSet_CheckIfSimilarSetExists (Set,NewTitle)) + if (Exa_DB_CheckIfSimilarSetExists (Set,NewTitle)) { NewTitleIsCorrect = false; Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_a_set_of_questions_in_this_exam_with_the_title_X, @@ -478,7 +478,7 @@ void ExaSet_ChangeSetTitle (void) if (ExaSet_CheckSetTitleReceivedFromForm (&Set,NewTitle)) { /* Update the table changing old title by new title */ - ExaSet_UpdateSetTitleDB (&Set,NewTitle); + Exa_DB_UpdateSetTitle (&Set,NewTitle); /* Update title */ Str_Copy (Set.Title,NewTitle,sizeof (Set.Title) - 1); @@ -525,7 +525,7 @@ void ExaSet_ChangeNumQstsToExam (void) if (NumQstsToPrint != Set.NumQstsToPrint) { /* Update the table changing old number by new number */ - ExaSet_UpdateNumQstsToExamDB (&Set,NumQstsToPrint); + Exa_DB_UpdateNumQstsToExam (&Set,NumQstsToPrint); /* Update title */ Set.NumQstsToPrint = NumQstsToPrint; @@ -546,7 +546,7 @@ static void ExaSet_CreateSet (struct ExaSet_Set *Set) unsigned MaxSetInd; /***** Get maximum set index *****/ - MaxSetInd = ExaSet_GetMaxSetIndexInExam (Set->ExaCod); + MaxSetInd = Exa_DB_GetMaxSetIndexInExam (Set->ExaCod); /***** Create a new exam *****/ Set->SetCod = @@ -595,8 +595,8 @@ static void ExaSet_UpdateSet (const struct ExaSet_Set *Set) /************************ Update set title in database ***********************/ /*****************************************************************************/ -static void ExaSet_UpdateSetTitleDB (const struct ExaSet_Set *Set, - const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]) +static void Exa_DB_UpdateSetTitle (const struct ExaSet_Set *Set, + const char NewTitle[ExaSet_MAX_BYTES_TITLE + 1]) { /***** Update set of questions changing old title by new title *****/ DB_QueryUPDATE ("can not update the title of a set of questions", @@ -613,8 +613,8 @@ static void ExaSet_UpdateSetTitleDB (const struct ExaSet_Set *Set, /****** Update number of questions to appear in exam print in database *******/ /*****************************************************************************/ -static void ExaSet_UpdateNumQstsToExamDB (const struct ExaSet_Set *Set, - unsigned NumQstsToPrint) +static void Exa_DB_UpdateNumQstsToExam (const struct ExaSet_Set *Set, + unsigned NumQstsToPrint) { /***** Update set of questions changing old number by new number *****/ DB_QueryUPDATE ("can not update the number of questions to appear in exam print", @@ -631,7 +631,7 @@ static void ExaSet_UpdateNumQstsToExamDB (const struct ExaSet_Set *Set, /******************* Get number of questions of an exam *********************/ /*****************************************************************************/ -unsigned ExaSet_GetNumSetsExam (long ExaCod) +unsigned Exa_DB_GetNumSetsExam (long ExaCod) { /***** Get number of sets in an exam from database *****/ return (unsigned) @@ -646,7 +646,7 @@ unsigned ExaSet_GetNumSetsExam (long ExaCod) /******************* Get number of questions of an exam *********************/ /*****************************************************************************/ -unsigned ExaSet_GetNumQstsExam (long ExaCod) +unsigned Exa_DB_GetNumQstsExam (long ExaCod) { /***** Get total number of questions to appear in exam print *****/ return DB_QuerySELECTUnsigned ("can not get number of questions in an exam print", @@ -688,7 +688,7 @@ void ExaSet_RequestCreatOrEditSet (void) /***** Get exam data from database *****/ Exa_GetDataOfExamByCod (&Exam); Exams.ExaCod = Exam.ExaCod; - Exa_GetExamTxtFromDB (Exam.ExaCod,Txt); + Exa_DB_GetExamTxt (Exam.ExaCod,Txt); /***** Get set data *****/ if (ItsANewSet) @@ -828,7 +828,7 @@ static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd) // Question index can be 1, 2, 3... // Return 0 if no questions -static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod) +static unsigned Exa_DB_GetMaxSetIndexInExam (long ExaCod) { /***** Get maximum set index in an exam from database *****/ return DB_QuerySELECTUnsigned ("can not get max set index", @@ -844,7 +844,7 @@ static unsigned ExaSet_GetMaxSetIndexInExam (long ExaCod) // Input set index can be 1, 2, 3... n-1 // Return set index will be 1, 2, 3... n if previous set exists, or 0 if no previous set -static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd) +static unsigned Exa_DB_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd) { /***** Get previous set index in an exam from database *****/ // Although indexes are always continuous... @@ -864,7 +864,7 @@ static unsigned ExaSet_GetPrevSetIndexInExam (long ExaCod,unsigned SetInd) // Input set index can be 0, 1, 2, 3... n-1 // Return set index will be 1, 2, 3... n if next set exists, or big number if no next set -static unsigned ExaSet_GetNextSetIndexInExam (long ExaCod,unsigned SetInd) +static unsigned Exa_DB_GetNextSetIndexInExam (long ExaCod,unsigned SetInd) { /***** Get next set index in an exam from database *****/ // Although indexes are always continuous... @@ -895,7 +895,7 @@ void ExaSet_ListExamSets (struct Exa_Exams *Exams, bool ICanEditSets = Exa_CheckIfEditable (Exam); /***** Get maximum set index *****/ - MaxSetInd = ExaSet_GetMaxSetIndexInExam (Exam->ExaCod); + MaxSetInd = Exa_DB_GetMaxSetIndexInExam (Exam->ExaCod); /***** Get data of set of questions from database *****/ NumSets = (unsigned) @@ -1007,162 +1007,164 @@ static void ExaSet_ListOneOrMoreSetsForEdition (struct Exa_Exams *Exams, if (!NumSets) return; - /***** Write the heading *****/ + /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (5); - ExaSet_PutTableHeadingForSets (); - /***** Write rows *****/ - for (NumSet = 0; - NumSet < NumSets; - NumSet++) - { - Gbl.RowEvenOdd = NumSet % 2; + /***** Write the heading *****/ + ExaSet_PutTableHeadingForSets (); - /***** Create set of questions *****/ - ExaSet_ResetSet (&Set); - - /***** Get set data *****/ - row = mysql_fetch_row (mysql_res); - /* - row[0] SetCod - row[1] SetInd - row[2] NumQstsToPrint - row[3] Title - */ - /* Get set code (row[0]) */ - Set.SetCod = Str_ConvertStrCodToLongCod (row[0]); - - /* Get set index (row[1]) */ - Set.SetInd = Str_ConvertStrToUnsigned (row[1]); - snprintf (StrSetInd,sizeof (Set.SetInd),"%u",Set.SetInd); - - /* Get number of questions to exam (row[2]) */ - Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]); - - /* Get the title of the set (row[3]) */ - Str_Copy (Set.Title,row[3],sizeof (Set.Title) - 1); - - /* Initialize context */ - Exams->SetCod = Set.SetCod; - Exams->SetInd = Set.SetInd; - - /***** Build anchor string *****/ - Frm_SetAnchorStr (Set.SetCod,&Anchor); - - /***** Begin first row *****/ - HTM_TR_Begin (NULL); - - /***** Icons *****/ - HTM_TD_Begin ("rowspan=\"2\" class=\"BT%u\"",Gbl.RowEvenOdd); - - /* Put icon to remove the set */ - if (ICanEditSets) - Ico_PutContextualIconToRemove (ActReqRemExaSet,NULL, - ExaSet_PutParamsOneSet,Exams); - else - Ico_PutIconRemovalNotAllowed (); - - /* Put icon to move up the question */ - if (ICanEditSets && Set.SetInd > 1) + /***** Write rows *****/ + for (NumSet = 0; + NumSet < NumSets; + NumSet++) { - Lay_PutContextualLinkOnlyIcon (ActUp_ExaSet,Anchor, - ExaSet_PutParamsOneSet,Exams, - "arrow-up.svg", - Str_BuildStringStr (Txt_Move_up_X, - StrSetInd)); - Str_FreeString (); + Gbl.RowEvenOdd = NumSet % 2; + + /***** Create set of questions *****/ + ExaSet_ResetSet (&Set); + + /***** Get set data *****/ + row = mysql_fetch_row (mysql_res); + /* + row[0] SetCod + row[1] SetInd + row[2] NumQstsToPrint + row[3] Title + */ + /* Get set code (row[0]) */ + Set.SetCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Get set index (row[1]) */ + Set.SetInd = Str_ConvertStrToUnsigned (row[1]); + snprintf (StrSetInd,sizeof (Set.SetInd),"%u",Set.SetInd); + + /* Get number of questions to exam (row[2]) */ + Set.NumQstsToPrint = Str_ConvertStrToUnsigned (row[2]); + + /* Get the title of the set (row[3]) */ + Str_Copy (Set.Title,row[3],sizeof (Set.Title) - 1); + + /* Initialize context */ + Exams->SetCod = Set.SetCod; + Exams->SetInd = Set.SetInd; + + /***** Build anchor string *****/ + Frm_SetAnchorStr (Set.SetCod,&Anchor); + + /***** Begin first row *****/ + HTM_TR_Begin (NULL); + + /***** Icons *****/ + HTM_TD_Begin ("rowspan=\"2\" class=\"BT%u\"",Gbl.RowEvenOdd); + + /* Put icon to remove the set */ + if (ICanEditSets) + Ico_PutContextualIconToRemove (ActReqRemExaSet,NULL, + ExaSet_PutParamsOneSet,Exams); + else + Ico_PutIconRemovalNotAllowed (); + + /* Put icon to move up the question */ + if (ICanEditSets && Set.SetInd > 1) + { + Lay_PutContextualLinkOnlyIcon (ActUp_ExaSet,Anchor, + ExaSet_PutParamsOneSet,Exams, + "arrow-up.svg", + Str_BuildStringStr (Txt_Move_up_X, + StrSetInd)); + Str_FreeString (); + } + else + Ico_PutIconOff ("arrow-up.svg",Txt_Movement_not_allowed); + + /* Put icon to move down the set */ + if (ICanEditSets && Set.SetInd < MaxSetInd) + { + Lay_PutContextualLinkOnlyIcon (ActDwnExaSet,Anchor, + ExaSet_PutParamsOneSet,Exams, + "arrow-down.svg", + Str_BuildStringStr (Txt_Move_down_X, + StrSetInd)); + Str_FreeString (); + } + else + Ico_PutIconOff ("arrow-down.svg",Txt_Movement_not_allowed); + + HTM_TD_End (); + + /***** Index *****/ + HTM_TD_Begin ("rowspan=\"2\" class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + Tst_WriteNumQst (Set.SetInd,"BIG_INDEX"); + HTM_TD_End (); + + /***** Title *****/ + HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + HTM_ARTICLE_Begin (Anchor); + if (ICanEditSets) + { + Frm_StartFormAnchor (ActChgTitExaSet,Anchor); + ExaSet_PutParamsOneSet (Exams); + HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set.Title, + HTM_SUBMIT_ON_CHANGE, + "id=\"Title\" required=\"required\"" + " class=\"TITLE_DESCRIPTION_WIDTH\""); + Frm_EndForm (); + } + else + { + HTM_SPAN_Begin ("class=\"EXA_SET_TITLE\""); + HTM_Txt (Set.Title); + HTM_SPAN_End (); + } + HTM_ARTICLE_End (); + HTM_TD_End (); + + /***** Current number of questions in set *****/ + HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); + HTM_Unsigned (Exa_DB_GetNumQstsInSet (Set.SetCod)); + HTM_SPAN_End (); + HTM_TD_End (); + + /***** Number of questions to appear in exam print *****/ + HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); + if (ICanEditSets) + { + Frm_StartFormAnchor (ActChgNumQstExaSet,Anchor); + ExaSet_PutParamsOneSet (Exams); + HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set.NumQstsToPrint, + HTM_SUBMIT_ON_CHANGE,false, + "class=\"INPUT_LONG\" required=\"required\""); + Frm_EndForm (); + } + else + { + HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); + HTM_Unsigned (Set.NumQstsToPrint); + HTM_SPAN_End (); + } + HTM_TD_End (); + + /***** End first row *****/ + HTM_TR_End (); + + /***** Begin second row *****/ + HTM_TR_Begin (NULL); + + /***** Questions *****/ + HTM_TD_Begin ("colspan=\"3\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); + + /* List questions */ + ExaSet_ListSetQuestions (Exams,Exam,&Set); + + HTM_TD_End (); + + /***** End second row *****/ + HTM_TR_End (); + + /***** Free anchor string *****/ + Frm_FreeAnchorStr (Anchor); } - else - Ico_PutIconOff ("arrow-up.svg",Txt_Movement_not_allowed); - - /* Put icon to move down the set */ - if (ICanEditSets && Set.SetInd < MaxSetInd) - { - Lay_PutContextualLinkOnlyIcon (ActDwnExaSet,Anchor, - ExaSet_PutParamsOneSet,Exams, - "arrow-down.svg", - Str_BuildStringStr (Txt_Move_down_X, - StrSetInd)); - Str_FreeString (); - } - else - Ico_PutIconOff ("arrow-down.svg",Txt_Movement_not_allowed); - - HTM_TD_End (); - - /***** Index *****/ - HTM_TD_Begin ("rowspan=\"2\" class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (Set.SetInd,"BIG_INDEX"); - HTM_TD_End (); - - /***** Title *****/ - HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - HTM_ARTICLE_Begin (Anchor); - if (ICanEditSets) - { - Frm_StartFormAnchor (ActChgTitExaSet,Anchor); - ExaSet_PutParamsOneSet (Exams); - HTM_INPUT_TEXT ("Title",ExaSet_MAX_CHARS_TITLE,Set.Title, - HTM_SUBMIT_ON_CHANGE, - "id=\"Title\" required=\"required\"" - " class=\"TITLE_DESCRIPTION_WIDTH\""); - Frm_EndForm (); - } - else - { - HTM_SPAN_Begin ("class=\"EXA_SET_TITLE\""); - HTM_Txt (Set.Title); - HTM_SPAN_End (); - } - HTM_ARTICLE_End (); - HTM_TD_End (); - - /***** Current number of questions in set *****/ - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); - HTM_Unsigned (ExaSet_GetNumQstsInSet (Set.SetCod)); - HTM_SPAN_End (); - HTM_TD_End (); - - /***** Number of questions to appear in exam print *****/ - HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - if (ICanEditSets) - { - Frm_StartFormAnchor (ActChgNumQstExaSet,Anchor); - ExaSet_PutParamsOneSet (Exams); - HTM_INPUT_LONG ("NumQstsToPrint",0,UINT_MAX,(long) Set.NumQstsToPrint, - HTM_SUBMIT_ON_CHANGE,false, - "class=\"INPUT_LONG\" required=\"required\""); - Frm_EndForm (); - } - else - { - HTM_SPAN_Begin ("class=\"EXA_SET_NUM_QSTS\""); - HTM_Unsigned (Set.NumQstsToPrint); - HTM_SPAN_End (); - } - HTM_TD_End (); - - /***** End first row *****/ - HTM_TR_End (); - - /***** Begin second row *****/ - HTM_TR_Begin (NULL); - - /***** Questions *****/ - HTM_TD_Begin ("colspan=\"3\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - - /* List questions */ - ExaSet_ListSetQuestions (Exams,Exam,&Set); - - HTM_TD_End (); - - /***** End second row *****/ - HTM_TR_End (); - - /***** Free anchor string *****/ - Frm_FreeAnchorStr (Anchor); - } /***** End table *****/ HTM_TABLE_End (); @@ -1182,12 +1184,12 @@ static void ExaSet_PutTableHeadingForSets (void) /***** Begin row *****/ HTM_TR_Begin (NULL); - /***** Header cells *****/ - HTM_TH_Empty (1); - HTM_TH (1,1,"RB",Txt_No_INDEX); - HTM_TH (1,1,"LB",Txt_Set_of_questions); - HTM_TH (1,1,"RB",Txt_Number_of_questions); - HTM_TH (1,1,"RB",Txt_Number_of_questions_to_show); + /***** Header cells *****/ + HTM_TH_Empty (1); + HTM_TH (1,1,"RB",Txt_No_INDEX); + HTM_TH (1,1,"LB",Txt_Set_of_questions); + HTM_TH (1,1,"RB",Txt_Number_of_questions); + HTM_TH (1,1,"RB",Txt_Number_of_questions_to_show); /***** End row *****/ HTM_TR_End (); @@ -1239,67 +1241,70 @@ static void ExaSet_ListOneOrMoreQuestionsForEdition (struct Exa_Exams *Exams, [Tst_VALID_QUESTION ] = Txt_Valid_question, }; - /***** Write the heading *****/ + /***** Begin table *****/ HTM_TABLE_BeginWideMarginPadding (5); - HTM_TR_Begin (NULL); - HTM_TH_Empty (1); - - HTM_TH (1,1,"CT",Txt_No_INDEX); - HTM_TH (1,1,"CT",Txt_Question); - - HTM_TR_End (); - - /***** Write rows *****/ - for (QstInd = 0; - QstInd < NumQsts; - QstInd++) - { - Gbl.RowEvenOdd = QstInd % 2; - - /***** Create test question *****/ - Tst_QstConstructor (&Question); - - /***** Get question data *****/ - /* Get question code */ - Exams->QstCod = Question.QstCod = DB_GetNextCode (mysql_res); - ExaSet_GetQstDataFromDB (&Question); - - /***** Build anchor string *****/ - Frm_SetAnchorStr (Exams->QstCod,&Anchor); - - /***** Begin row *****/ + /***** Write the heading *****/ HTM_TR_Begin (NULL); - /***** Icons *****/ - HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + HTM_TH_Empty (1); - /* Put icon to remove the question */ - if (ICanEditQuestions) - Ico_PutContextualIconToRemove (ActReqRemSetQst,NULL, - ExaSet_PutParamsOneQst,Exams); - else - Ico_PutIconRemovalNotAllowed (); + HTM_TH (1,1,"CT",Txt_No_INDEX); + HTM_TH (1,1,"CT",Txt_Question); - /* Put icon to cancel the question */ - Lay_PutContextualLinkOnlyIcon (NextAction[Question.Validity],Anchor, - ExaSet_PutParamsOneQst,Exams, - Icon[Question.Validity], - Title[Question.Validity]); - HTM_TD_End (); - - /***** List question *****/ - ExaSet_ListQuestionForEdition (&Question,QstInd + 1,Anchor); - - /***** End row *****/ HTM_TR_End (); - /***** Free anchor string *****/ - Frm_FreeAnchorStr (Anchor); + /***** Write rows *****/ + for (QstInd = 0; + QstInd < NumQsts; + QstInd++) + { + Gbl.RowEvenOdd = QstInd % 2; - /***** Destroy test question *****/ - Tst_QstDestructor (&Question); - } + /***** Create test question *****/ + Tst_QstConstructor (&Question); + + /***** Get question data *****/ + /* Get question code */ + Exams->QstCod = Question.QstCod = DB_GetNextCode (mysql_res); + ExaSet_GetQstDataFromDB (&Question); + + /***** Build anchor string *****/ + Frm_SetAnchorStr (Exams->QstCod,&Anchor); + + /***** Begin row *****/ + HTM_TR_Begin (NULL); + + /***** Icons *****/ + HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd); + + /* Put icon to remove the question */ + if (ICanEditQuestions) + Ico_PutContextualIconToRemove (ActReqRemSetQst,NULL, + ExaSet_PutParamsOneQst,Exams); + else + Ico_PutIconRemovalNotAllowed (); + + /* Put icon to cancel the question */ + Lay_PutContextualLinkOnlyIcon (NextAction[Question.Validity],Anchor, + ExaSet_PutParamsOneQst,Exams, + Icon[Question.Validity], + Title[Question.Validity]); + + HTM_TD_End (); + + /***** List question *****/ + ExaSet_ListQuestionForEdition (&Question,QstInd + 1,Anchor); + + /***** End row *****/ + HTM_TR_End (); + + /***** Free anchor string *****/ + Frm_FreeAnchorStr (Anchor); + + /***** Destroy test question *****/ + Tst_QstDestructor (&Question); + } /***** End table *****/ HTM_TABLE_End (); @@ -1521,32 +1526,32 @@ static void ExaSet_ListQuestionForEdition (struct Tst_Question *Question, /***** Number of question and answer type (row[1]) *****/ HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd); - Tst_WriteNumQst (QstInd,ClassNumQst[Question->Validity]); - Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); + Tst_WriteNumQst (QstInd,ClassNumQst[Question->Validity]); + Tst_WriteAnswerType (Question->Answer.Type,ClassAnswerType[Question->Validity]); HTM_TD_End (); /***** Write stem (row[3]) and media *****/ HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd); - HTM_ARTICLE_Begin (Anchor); + HTM_ARTICLE_Begin (Anchor); - /* Write stem */ - Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], - true); // Visible + /* Write stem */ + Tst_WriteQstStem (Question->Stem,ClassTxt[Question->Validity], + true); // Visible - /* Show media */ - Med_ShowMedia (&Question->Media, - "TEST_MED_EDIT_LIST_CONT", - "TEST_MED_EDIT_LIST"); + /* Show media */ + Med_ShowMedia (&Question->Media, + "TEST_MED_EDIT_LIST_CONT", + "TEST_MED_EDIT_LIST"); - /* Show feedback */ - Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); + /* Show feedback */ + Tst_WriteQstFeedback (Question->Feedback,ClassFeedback[Question->Validity]); - /* Show answers */ - Tst_WriteAnswersBank (Question, - ClassTxt[Question->Validity], - ClassFeedback[Question->Validity]); + /* Show answers */ + Tst_WriteAnswersBank (Question, + ClassTxt[Question->Validity], + ClassFeedback[Question->Validity]); - HTM_ARTICLE_End (); + HTM_ARTICLE_End (); HTM_TD_End (); } @@ -1862,7 +1867,7 @@ void ExaSet_MoveUpSet (void) if (SetIndBottom > 1) { /* Indexes of sets to be exchanged */ - SetIndTop = ExaSet_GetPrevSetIndexInExam (Exam.ExaCod,SetIndBottom); + SetIndTop = Exa_DB_GetPrevSetIndexInExam (Exam.ExaCod,SetIndBottom); if (SetIndTop == 0) Err_ShowErrorAndExit ("Wrong set index."); @@ -1907,13 +1912,13 @@ void ExaSet_MoveDownSet (void) SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod); /***** Get maximum set index *****/ - MaxSetInd = ExaSet_GetMaxSetIndexInExam (Exam.ExaCod); + MaxSetInd = Exa_DB_GetMaxSetIndexInExam (Exam.ExaCod); /***** Move down set *****/ if (SetIndTop < MaxSetInd) { /* Indexes of sets to be exchanged */ - SetIndBottom = ExaSet_GetNextSetIndexInExam (Exam.ExaCod,SetIndTop); + SetIndBottom = Exa_DB_GetNextSetIndexInExam (Exam.ExaCod,SetIndTop); if (SetIndBottom == ExaSet_AFTER_LAST_SET) Err_ShowErrorAndExit ("Wrong set index."); @@ -2290,18 +2295,18 @@ void ExaSet_WriteSetTitle (const struct ExaSet_Set *Set) /***** Begin table *****/ HTM_TABLE_BeginWide (); - /***** Title *****/ - HTM_TD_Begin ("class=\"EXA_SET_TITLE\""); - HTM_Txt (Set->Title); - HTM_TD_End (); + /***** Title *****/ + HTM_TD_Begin ("class=\"EXA_SET_TITLE\""); + HTM_Txt (Set->Title); + HTM_TD_End (); - /***** Number of questions to appear in exam print *****/ - HTM_TD_Begin ("class=\"EXA_SET_NUM_QSTS\""); - HTM_Unsigned (Set->NumQstsToPrint); - HTM_NBSP (); - HTM_Txt (Set->NumQstsToPrint == 1 ? Txt_question : - Txt_questions); - HTM_TD_End (); + /***** Number of questions to appear in exam print *****/ + HTM_TD_Begin ("class=\"EXA_SET_NUM_QSTS\""); + HTM_Unsigned (Set->NumQstsToPrint); + HTM_NBSP (); + HTM_Txt (Set->NumQstsToPrint == 1 ? Txt_question : + Txt_questions); + HTM_TD_End (); /***** End table *****/ HTM_TABLE_End (); diff --git a/swad_exam_set.h b/swad_exam_set.h index 2bb7f1ae..ce12fed2 100644 --- a/swad_exam_set.h +++ b/swad_exam_set.h @@ -48,8 +48,8 @@ void ExaSet_ReceiveFormSet (void); void ExaSet_ChangeSetTitle (void); void ExaSet_ChangeNumQstsToExam (void); -unsigned ExaSet_GetNumSetsExam (long ExaCod); -unsigned ExaSet_GetNumQstsExam (long ExaCod); +unsigned Exa_DB_GetNumSetsExam (long ExaCod); +unsigned Exa_DB_GetNumQstsExam (long ExaCod); void ExaSet_RequestCreatOrEditSet (void); void ExaSet_ReqSelectQstsToAddToSet (void); diff --git a/swad_figure.c b/swad_figure.c index b8f2c432..5afb3ad1 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -203,7 +203,6 @@ static void Fig_GetAndShowNumUsrsPerIconSet (void); static void Fig_GetAndShowNumUsrsPerMenu (void); static void Fig_GetAndShowNumUsrsPerTheme (void); static void Fig_GetAndShowNumUsrsPerSideColumns (void); -unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery); /*****************************************************************************/ /************************** Show use of the platform *************************/ @@ -229,45 +228,46 @@ static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType) /***** Form to show statistic *****/ Frm_BeginForm (ActSeeUseGbl); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Figures, - NULL,NULL, - Hlp_ANALYTICS_Figures,Box_NOT_CLOSABLE); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Figures, + NULL,NULL, + Hlp_ANALYTICS_Figures,Box_NOT_CLOSABLE); - /***** Compute stats for anywhere, degree or course? *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColonNBSP (Txt_Scope); - Gbl.Scope.Allowed = 1 << HieLvl_SYS | - 1 << HieLvl_CTY | - 1 << HieLvl_INS | - 1 << HieLvl_CTR | - 1 << HieLvl_DEG | - 1 << HieLvl_CRS; - Gbl.Scope.Default = HieLvl_SYS; - Sco_GetScope ("ScopeFig"); - Sco_PutSelectorScope ("ScopeFig",HTM_DONT_SUBMIT_ON_CHANGE); - HTM_LABEL_End (); - HTM_BR (); + /***** Compute stats for anywhere, degree or course? *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColonNBSP (Txt_Scope); + Gbl.Scope.Allowed = 1 << HieLvl_SYS | + 1 << HieLvl_CTY | + 1 << HieLvl_INS | + 1 << HieLvl_CTR | + 1 << HieLvl_DEG | + 1 << HieLvl_CRS; + Gbl.Scope.Default = HieLvl_SYS; + Sco_GetScope ("ScopeFig"); + Sco_PutSelectorScope ("ScopeFig",HTM_DONT_SUBMIT_ON_CHANGE); + HTM_LABEL_End (); - /***** Type of statistic *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColonNBSP (Txt_Statistic); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"FigureType\""); - for (FigType = (Fig_FigureType_t) 0; - FigType <= (Fig_FigureType_t) (Fig_NUM_FIGURES - 1); - FigType++) - { - FigureTypeUnsigned = (unsigned) FigType; - HTM_OPTION (HTM_Type_UNSIGNED,&FigureTypeUnsigned, - FigType == SelectedFigureType,false, - "%s",Txt_FIGURE_TYPES[FigType]); - } - HTM_SELECT_End (); - HTM_LABEL_End (); + HTM_BR (); - /***** Send button and end box *****/ - Box_BoxWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Show_statistic); + /***** Type of statistic *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColonNBSP (Txt_Statistic); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"FigureType\""); + for (FigType = (Fig_FigureType_t) 0; + FigType <= (Fig_FigureType_t) (Fig_NUM_FIGURES - 1); + FigType++) + { + FigureTypeUnsigned = (unsigned) FigType; + HTM_OPTION (HTM_Type_UNSIGNED,&FigureTypeUnsigned, + FigType == SelectedFigureType,false, + "%s",Txt_FIGURE_TYPES[FigType]); + } + HTM_SELECT_End (); + HTM_LABEL_End (); + + /***** Send button and end box *****/ + Box_BoxWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Show_statistic); /***** End form *****/ Frm_EndForm (); @@ -400,26 +400,26 @@ static void Fig_GetAndShowUsersStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_users,Box_NOT_CLOSABLE,2); - /***** Write heading *****/ - HTM_TR_Begin (NULL); + /***** Write heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Users); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_Average_number_of_courses_to_which_a_user_belongs); + HTM_TH (1,1,"RM",Txt_Average_number_of_users_belonging_to_a_course); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Users); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_Average_number_of_courses_to_which_a_user_belongs); - HTM_TH (1,1,"RM",Txt_Average_number_of_users_belonging_to_a_course); + /***** Figures *****/ + Fig_GetAndShowNumUsrsInCrss (Rol_STD); // Students + Fig_GetAndShowNumUsrsInCrss (Rol_NET); // Non-editing teachers + Fig_GetAndShowNumUsrsInCrss (Rol_TCH); // Teachers + Fig_GetAndShowNumUsrsInCrss (Rol_UNK); // Any user in courses - HTM_TR_End (); + /***** Separator *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,4,"SEPAR_ROW",NULL); + HTM_TR_End (); - Fig_GetAndShowNumUsrsInCrss (Rol_STD); // Students - Fig_GetAndShowNumUsrsInCrss (Rol_NET); // Non-editing teachers - Fig_GetAndShowNumUsrsInCrss (Rol_TCH); // Teachers - Fig_GetAndShowNumUsrsInCrss (Rol_UNK); // Any user in courses - - HTM_TR_Begin (NULL); - HTM_TH (1,4,"SEPAR_ROW",NULL); - HTM_TR_End (); - - Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (); // Users not beloging to any course + Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (); // Users not beloging to any course /***** End table and box *****/ Box_BoxTableEnd (); @@ -450,23 +450,23 @@ static void Fig_GetAndShowNumUsrsInCrss (Rol_Role_t Role) /***** Write the total number of users *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Txt ((Role == Rol_UNK) ? Txt_Total : - Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Txt ((Role == Rol_UNK) ? Txt_Total : + Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); + HTM_TD_End (); - /* Number of users in courses */ - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current,Cod,Roles)); - HTM_TD_End (); + /* Number of users in courses */ + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Unsigned (Usr_GetCachedNumUsrsInCrss (Gbl.Scope.Current,Cod,Roles)); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Double2Decimals (Usr_GetCachedNumCrssPerUsr (Gbl.Scope.Current,Cod,Role)); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Double2Decimals (Usr_GetCachedNumCrssPerUsr (Gbl.Scope.Current,Cod,Role)); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Double2Decimals (Usr_GetCachedNumUsrsPerCrs (Gbl.Scope.Current,Cod,Role)); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Double2Decimals (Usr_GetCachedNumUsrsPerCrs (Gbl.Scope.Current,Cod,Role)); + HTM_TD_End (); HTM_TR_End (); } @@ -483,21 +483,21 @@ static void Fig_GetAndShowNumUsrsNotBelongingToAnyCrs (void) /***** Write the total number of users not belonging to any course *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Txt (Txt_ROLES_PLURAL_Abc[Rol_GST][Usr_SEX_UNKNOWN]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Txt (Txt_ROLES_PLURAL_Abc[Rol_GST][Usr_SEX_UNKNOWN]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Unsigned (Usr_GetCachedNumUsrsNotBelongingToAnyCrs ()); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Unsigned (Usr_GetCachedNumUsrsNotBelongingToAnyCrs ()); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Double2Decimals (0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Double2Decimals (0.0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s\"",Class); - HTM_Double2Decimals (0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s\"",Class); + HTM_Double2Decimals (0.0); + HTM_TD_End (); HTM_TR_End (); } @@ -523,51 +523,49 @@ static void Fig_GetAndShowUsersRanking (void) NULL,NULL, Hlp_ANALYTICS_Figures_ranking,Box_NOT_CLOSABLE,2); - /***** Write heading *****/ - HTM_TR_Begin (NULL); + /***** Write heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"CM",Txt_Clicks); + HTM_TH (1,1,"CM",Txt_Clicks_per_day); + HTM_TH (1,1,"CM",Txt_Timeline); + HTM_TH (1,1,"CM",Txt_Followers); + HTM_TH (1,1,"CM",Txt_Downloads); + HTM_TH (1,1,"CM",Txt_Forums); + HTM_TH (1,1,"CM",Txt_Messages); + HTM_TR_End (); - HTM_TH (1,1,"CM",Txt_Clicks); - HTM_TH (1,1,"CM",Txt_Clicks_per_day); - HTM_TH (1,1,"CM",Txt_Timeline); - HTM_TH (1,1,"CM",Txt_Followers); - HTM_TH (1,1,"CM",Txt_Downloads); - HTM_TH (1,1,"CM",Txt_Forums); - HTM_TH (1,1,"CM",Txt_Messages); + /***** Rankings *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingClicks (); + HTM_TD_End (); - /***** Rankings *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingClicksPerDay (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingClicks (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingSocPub (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingClicksPerDay (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Fol_GetAndShowRankingFollowers (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingSocPub (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingFileViews (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Fol_GetAndShowRankingFollowers (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingForPst (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingFileViews (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + Prf_GetAndShowRankingMsgSnt (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingForPst (); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT LT\""); - Prf_GetAndShowRankingMsgSnt (); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -589,16 +587,16 @@ static void Fig_GetAndShowHierarchyStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_hierarchy,Box_NOT_CLOSABLE,2); - Fig_WriteHeadHierarchy (); - Fig_GetAndShowHierarchyWithInss (); - Fig_GetAndShowHierarchyWithCtrs (); - Fig_GetAndShowHierarchyWithDegs (); - Fig_GetAndShowHierarchyWithCrss (); - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - Fig_GetAndShowHierarchyWithUsrs (Role); - Fig_GetAndShowHierarchyTotal (); + Fig_WriteHeadHierarchy (); + Fig_GetAndShowHierarchyWithInss (); + Fig_GetAndShowHierarchyWithCtrs (); + Fig_GetAndShowHierarchyWithDegs (); + Fig_GetAndShowHierarchyWithCrss (); + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + Fig_GetAndShowHierarchyWithUsrs (Role); + Fig_GetAndShowHierarchyTotal (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -618,37 +616,37 @@ static void Fig_WriteHeadHierarchy (void) HTM_TR_Begin (NULL); - HTM_TH_Empty (1); + HTM_TH_Empty (1); - HTM_TH_Begin (1,1,"RM"); - Ico_PutIcon ("globe.svg",Txt_Countries,"CONTEXT_ICO_x16"); - HTM_BR (); - HTM_Txt (Txt_Countries); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + Ico_PutIcon ("globe.svg",Txt_Countries,"CONTEXT_ICO_x16"); + HTM_BR (); + HTM_Txt (Txt_Countries); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - Ico_PutIcon ("university.svg",Txt_Institutions,"CONTEXT_ICO_x16"); - HTM_BR (); - HTM_Txt (Txt_Institutions); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + Ico_PutIcon ("university.svg",Txt_Institutions,"CONTEXT_ICO_x16"); + HTM_BR (); + HTM_Txt (Txt_Institutions); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - Ico_PutIcon ("building.svg",Txt_Centers,"CONTEXT_ICO_x16"); - HTM_BR (); - HTM_Txt (Txt_Centers); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + Ico_PutIcon ("building.svg",Txt_Centers,"CONTEXT_ICO_x16"); + HTM_BR (); + HTM_Txt (Txt_Centers); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - Ico_PutIcon ("graduation-cap.svg",Txt_Degrees,"CONTEXT_ICO_x16"); - HTM_BR (); - HTM_Txt (Txt_Degrees); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + Ico_PutIcon ("graduation-cap.svg",Txt_Degrees,"CONTEXT_ICO_x16"); + HTM_BR (); + HTM_Txt (Txt_Degrees); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - Ico_PutIcon ("chalkboard-teacher.svg",Txt_Courses,"CONTEXT_ICO_x16"); - HTM_BR (); - HTM_Txt (Txt_Courses); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + Ico_PutIcon ("chalkboard-teacher.svg",Txt_Courses,"CONTEXT_ICO_x16"); + HTM_BR (); + HTM_Txt (Txt_Courses); + HTM_TH_End (); HTM_TR_End (); } @@ -993,18 +991,18 @@ static void Fig_ShowHierarchyRow (const char *Text1,const char *Text2, /***** Start row *****/ HTM_TR_Begin (NULL); - /***** Write text *****/ - HTM_TD_Begin ("class=\"%s RM\"",ClassTxt); - HTM_Txt (Text1); - HTM_Txt (Text2); - HTM_TD_End (); + /***** Write text *****/ + HTM_TD_Begin ("class=\"%s RM\"",ClassTxt); + HTM_Txt (Text1); + HTM_Txt (Text2); + HTM_TD_End (); - /***** Write number of countries *****/ - Fig_ShowHierarchyCell (ClassTxt,NumCtys); - Fig_ShowHierarchyCell (ClassTxt,NumInss); - Fig_ShowHierarchyCell (ClassTxt,NumCtrs); - Fig_ShowHierarchyCell (ClassTxt,NumDegs); - Fig_ShowHierarchyCell (ClassTxt,NumCrss); + /***** Write number of countries *****/ + Fig_ShowHierarchyCell (ClassTxt,NumCtys); + Fig_ShowHierarchyCell (ClassTxt,NumInss); + Fig_ShowHierarchyCell (ClassTxt,NumCtrs); + Fig_ShowHierarchyCell (ClassTxt,NumDegs); + Fig_ShowHierarchyCell (ClassTxt,NumCrss); /***** End row *****/ HTM_TR_End (); @@ -1014,10 +1012,10 @@ static void Fig_ShowHierarchyCell (const char *ClassTxt,int Num) { /***** Write number *****/ HTM_TD_Begin ("class=\"%s RM\"",ClassTxt); - if (Num >= 0) - HTM_Unsigned ((unsigned) Num); - else // < 0 ==> do not show number - HTM_Hyphen (); + if (Num >= 0) + HTM_Unsigned ((unsigned) Num); + else // < 0 ==> do not show number + HTM_Hyphen (); HTM_TD_End (); } @@ -1036,26 +1034,26 @@ static void Fig_GetAndShowInstitutionsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_institutions,Box_NOT_CLOSABLE); - /***** Form to select type of list used to display degree photos *****/ - Usr_GetAndUpdatePrefsAboutUsrList (); - Figures.Scope = Gbl.Scope.Current; - Figures.FigureType = Fig_INSTITS; - Usr_ShowFormsToSelectUsrListType (Fig_PutHiddenParamFigures,&Figures); + /***** Form to select type of list used to display degree photos *****/ + Usr_GetAndUpdatePrefsAboutUsrList (); + Figures.Scope = Gbl.Scope.Current; + Figures.FigureType = Fig_INSTITS; + Usr_ShowFormsToSelectUsrListType (Fig_PutHiddenParamFigures,&Figures); - /***** Institutions ordered by number of centers *****/ - Fig_GetAndShowInssOrderedByNumCtrs (); + /***** Institutions ordered by number of centers *****/ + Fig_GetAndShowInssOrderedByNumCtrs (); - /***** Institutions ordered by number of degrees *****/ - Fig_GetAndShowInssOrderedByNumDegs (); + /***** Institutions ordered by number of degrees *****/ + Fig_GetAndShowInssOrderedByNumDegs (); - /***** Institutions ordered by number of courses *****/ - Fig_GetAndShowInssOrderedByNumCrss (); + /***** Institutions ordered by number of courses *****/ + Fig_GetAndShowInssOrderedByNumCrss (); - /***** Institutions ordered by number of users in courses *****/ - Fig_GetAndShowInssOrderedByNumUsrsInCrss (); + /***** Institutions ordered by number of users in courses *****/ + Fig_GetAndShowInssOrderedByNumUsrsInCrss (); - /***** Institutions ordered by number of users who claim to belong to them *****/ - Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (); + /***** Institutions ordered by number of users who claim to belong to them *****/ + Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (); /***** End box *****/ Box_BoxEnd (); @@ -1077,55 +1075,55 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void) NULL,NULL, NULL,Box_NOT_CLOSABLE,2); - /***** Get institutions ordered by number of centers *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers" - " GROUP BY InsCod" - " ORDER BY N DESC"); - break; - case HieLvl_CTY: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ins_instits," - "ctr_centers" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - case HieLvl_CTR: - case HieLvl_DEG: - case HieLvl_CRS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers" - " WHERE InsCod=%ld" - " GROUP BY InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Ins.InsCod); - break; - default: - Err_WrongScopeExit (); - break; - } + /***** Get institutions ordered by number of centers *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers" + " GROUP BY InsCod" + " ORDER BY N DESC"); + break; + case HieLvl_CTY: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ins_instits," + "ctr_centers" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Cty.CtyCod); + break; + case HieLvl_INS: + case HieLvl_CTR: + case HieLvl_DEG: + case HieLvl_CRS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers" + " WHERE InsCod=%ld" + " GROUP BY InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Ins.InsCod); + break; + default: + Err_WrongScopeExit (); + break; + } - /***** Show institutions *****/ - Fig_ShowInss (&mysql_res,NumInss,Txt_Centers); + /***** Show institutions *****/ + Fig_ShowInss (&mysql_res,NumInss,Txt_Centers); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); /***** End table and box *****/ Box_BoxTableEnd (); @@ -1147,61 +1145,61 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void) NULL,NULL, NULL,Box_NOT_CLOSABLE,2); - /***** Get institutions ordered by number of degrees *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees" - " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" - " GROUP BY InsCod" - " ORDER BY N DESC"); - break; - case HieLvl_CTY: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ins_instits," - "ctr_centers," - "deg_degrees" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - case HieLvl_CTR: - case HieLvl_DEG: - case HieLvl_CRS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Ins.InsCod); - break; - default: - Err_WrongScopeExit (); - break; - } + /***** Get institutions ordered by number of degrees *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees" + " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" + " GROUP BY InsCod" + " ORDER BY N DESC"); + break; + case HieLvl_CTY: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ins_instits," + "ctr_centers," + "deg_degrees" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Cty.CtyCod); + break; + case HieLvl_INS: + case HieLvl_CTR: + case HieLvl_DEG: + case HieLvl_CRS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Ins.InsCod); + break; + default: + Err_WrongScopeExit (); + break; + } - /***** Show institutions *****/ - Fig_ShowInss (&mysql_res,NumInss,Txt_Degrees); + /***** Show institutions *****/ + Fig_ShowInss (&mysql_res,NumInss,Txt_Degrees); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); /***** End table and box *****/ Box_BoxTableEnd (); @@ -1223,67 +1221,67 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void) NULL,NULL, NULL,Box_NOT_CLOSABLE,2); - /***** Get institutions ordered by number of courses *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees," - "crs_courses" - " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " GROUP BY InsCod" - " ORDER BY N DESC"); - break; - case HieLvl_CTY: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - case HieLvl_CTR: - case HieLvl_DEG: - case HieLvl_CRS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees," - "crs_courses" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Ins.InsCod); - break; - default: - Err_WrongScopeExit (); - break; - } + /***** Get institutions ordered by number of courses *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees," + "crs_courses" + " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " GROUP BY InsCod" + " ORDER BY N DESC"); + break; + case HieLvl_CTY: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Cty.CtyCod); + break; + case HieLvl_INS: + case HieLvl_CTR: + case HieLvl_DEG: + case HieLvl_CRS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees," + "crs_courses" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Ins.InsCod); + break; + default: + Err_WrongScopeExit (); + break; + } - /***** Show institutions *****/ - Fig_ShowInss (&mysql_res,NumInss,Txt_Courses); + /***** Show institutions *****/ + Fig_ShowInss (&mysql_res,NumInss,Txt_Courses); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); /***** End table and box *****/ Box_BoxTableEnd (); @@ -1305,73 +1303,73 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void) NULL,NULL, NULL,Box_NOT_CLOSABLE,2); - /***** Get institutions ordered by number of users in courses *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users" - " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " GROUP BY InsCod" - " ORDER BY N DESC"); - break; - case HieLvl_CTY: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - case HieLvl_CTR: - case HieLvl_DEG: - case HieLvl_CRS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ctr_centers.InsCod," // row[0] - "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " GROUP BY ctr_centers.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Ins.InsCod); - break; - default: - Err_WrongScopeExit (); - break; - } + /***** Get institutions ordered by number of users in courses *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users" + " WHERE ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " GROUP BY InsCod" + " ORDER BY N DESC"); + break; + case HieLvl_CTY: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Cty.CtyCod); + break; + case HieLvl_INS: + case HieLvl_CTR: + case HieLvl_DEG: + case HieLvl_CRS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT ctr_centers.InsCod," // row[0] + "COUNT(DISTINCT crs_users.UsrCod) AS N" // row[1] + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " GROUP BY ctr_centers.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Ins.InsCod); + break; + default: + Err_WrongScopeExit (); + break; + } - /***** Show institutions *****/ - Fig_ShowInss (&mysql_res,NumInss,Txt_Users); + /***** Show institutions *****/ + Fig_ShowInss (&mysql_res,NumInss,Txt_Users); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); /***** End table and box *****/ Box_BoxTableEnd (); @@ -1394,56 +1392,56 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void) NULL,NULL, NULL,Box_NOT_CLOSABLE,2); - /***** Get institutions ordered by number of users who claim to belong to them *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM usr_data" - " WHERE InsCod>0" - " GROUP BY InsCod" - " ORDER BY N DESC"); - break; - case HieLvl_CTY: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT usr_data.InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM ins_instits,usr_data" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=usr_data.InsCod" - " GROUP BY usr_data.InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - case HieLvl_CTR: - case HieLvl_DEG: - case HieLvl_CRS: - NumInss = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT InsCod," // row[0] - "COUNT(*) AS N" // row[1] - " FROM usr_data" - " WHERE InsCod=%ld" - " GROUP BY InsCod" - " ORDER BY N DESC", - Gbl.Hierarchy.Ins.InsCod); - break; - default: - Err_WrongScopeExit (); - NumInss = 0; // Not reached. Initialized to avoid warning. - break; - } + /***** Get institutions ordered by number of users who claim to belong to them *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM usr_data" + " WHERE InsCod>0" + " GROUP BY InsCod" + " ORDER BY N DESC"); + break; + case HieLvl_CTY: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT usr_data.InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM ins_instits,usr_data" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=usr_data.InsCod" + " GROUP BY usr_data.InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Cty.CtyCod); + break; + case HieLvl_INS: + case HieLvl_CTR: + case HieLvl_DEG: + case HieLvl_CRS: + NumInss = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get institutions", + "SELECT InsCod," // row[0] + "COUNT(*) AS N" // row[1] + " FROM usr_data" + " WHERE InsCod=%ld" + " GROUP BY InsCod" + " ORDER BY N DESC", + Gbl.Hierarchy.Ins.InsCod); + break; + default: + Err_WrongScopeExit (); + NumInss = 0; // Not reached. Initialized to avoid warning. + break; + } - /***** Show institutions *****/ - Fig_ShowInss (&mysql_res,NumInss,Txt_Users); + /***** Show institutions *****/ + Fig_ShowInss (&mysql_res,NumInss,Txt_Users); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); /***** End table and box *****/ Box_BoxTableEnd (); @@ -1488,9 +1486,9 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, /***** Write link to institution *****/ HTM_TD_Begin ("class=\"%s CM\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - Ins_DrawInstitutionLogoWithLink (&Ins,40); - HTM_BR (); - HTM_Unsigned (NumberThisRow); + Ins_DrawInstitutionLogoWithLink (&Ins,40); + HTM_BR (); + HTM_Unsigned (NumberThisRow); HTM_TD_End (); if ((++NumIns % Gbl.Usrs.ClassPhoto.Cols) == 0) @@ -1506,12 +1504,9 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, case Usr_LIST_AS_LISTING: /***** Draw institutions as a list *****/ HTM_TR_Begin (NULL); - - HTM_TH_Empty (1); - - HTM_TH (1,1,"LM",Txt_Institution); - HTM_TH (1,1,"RM",TxtFigure); - + HTM_TH_Empty (1); + HTM_TH (1,1,"LM",Txt_Institution); + HTM_TH (1,1,"RM",TxtFigure); HTM_TR_End (); for (NumIns = 1, NumOrder = 1, NumberLastRow = 0; @@ -1523,35 +1518,35 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, HTM_TR_Begin (NULL); - /***** Number of order *****/ - if (NumberThisRow != NumberLastRow) - NumOrder = NumIns; - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumOrder); - HTM_TD_End (); + /***** Number of order *****/ + if (NumberThisRow != NumberLastRow) + NumOrder = NumIns; + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumOrder); + HTM_TD_End (); - /***** Write link to institution *****/ - HTM_TD_Begin ("class=\"%s LM\"", - The_ClassFormInBox[Gbl.Prefs.Theme]); - /* Icon and name of this institution */ - Frm_BeginForm (ActSeeInsInf); - Ins_PutParamInsCod (Ins.InsCod); - HTM_BUTTON_SUBMIT_Begin (Ins.ShrtName,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL); - if (Gbl.Usrs.Listing.WithPhotos) - { - Lgo_DrawLogo (HieLvl_INS,Ins.InsCod,Ins.ShrtName, - 40,NULL,true); - HTM_NBSP (); - } - HTM_Txt (Ins.FullName); - HTM_BUTTON_End (); - Frm_EndForm (); - HTM_TD_End (); + /***** Write link to institution *****/ + HTM_TD_Begin ("class=\"%s LM\"", + The_ClassFormInBox[Gbl.Prefs.Theme]); + /* Icon and name of this institution */ + Frm_BeginForm (ActSeeInsInf); + Ins_PutParamInsCod (Ins.InsCod); + HTM_BUTTON_SUBMIT_Begin (Ins.ShrtName,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL); + if (Gbl.Usrs.Listing.WithPhotos) + { + Lgo_DrawLogo (HieLvl_INS,Ins.InsCod,Ins.ShrtName, + 40,NULL,true); + HTM_NBSP (); + } + HTM_Txt (Ins.FullName); + HTM_BUTTON_End (); + Frm_EndForm (); + HTM_TD_End (); - /***** Write statistic *****/ - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumberThisRow); - HTM_TD_End (); + /***** Write statistic *****/ + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumberThisRow); + HTM_TD_End (); HTM_TR_End (); @@ -1639,38 +1634,38 @@ static void Fig_GetAndShowFileBrowsersStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_folders_and_files,Box_NOT_CLOSABLE); - /***** Write sizes of all file zones *****/ - HTM_TABLE_BeginCenterPadding (2); - Fig_WriteStatsExpTreesTableHead1 (); - for (NumStat = 0; - NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; - NumStat++) - Fig_WriteRowStatsFileBrowsers1 (Txt_STAT_COURSE_FILE_ZONES[NumStat], - StatCrsFileZones[NumStat], - &SizeOfFileZones[NumStat]); - HTM_TABLE_End (); + /***** Write sizes of all file zones *****/ + HTM_TABLE_BeginCenterPadding (2); + Fig_WriteStatsExpTreesTableHead1 (); + for (NumStat = 0; + NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; + NumStat++) + Fig_WriteRowStatsFileBrowsers1 (Txt_STAT_COURSE_FILE_ZONES[NumStat], + StatCrsFileZones[NumStat], + &SizeOfFileZones[NumStat]); + HTM_TABLE_End (); - /***** Write sizes of all file zones per course *****/ - HTM_TABLE_BeginCenterPadding (2); - Fig_WriteStatsExpTreesTableHead2 (); - for (NumStat = 0; - NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; - NumStat++) - Fig_WriteRowStatsFileBrowsers2 (Txt_STAT_COURSE_FILE_ZONES[NumStat], - StatCrsFileZones[NumStat], - &SizeOfFileZones[NumStat]); - HTM_TABLE_End (); + /***** Write sizes of all file zones per course *****/ + HTM_TABLE_BeginCenterPadding (2); + Fig_WriteStatsExpTreesTableHead2 (); + for (NumStat = 0; + NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; + NumStat++) + Fig_WriteRowStatsFileBrowsers2 (Txt_STAT_COURSE_FILE_ZONES[NumStat], + StatCrsFileZones[NumStat], + &SizeOfFileZones[NumStat]); + HTM_TABLE_End (); - /***** Write sizes of all file zones per user *****/ - HTM_TABLE_BeginCenterPadding (2); - Fig_WriteStatsExpTreesTableHead3 (); - for (NumStat = 0; - NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; - NumStat++) - Fig_WriteRowStatsFileBrowsers3 (Txt_STAT_COURSE_FILE_ZONES[NumStat], - StatCrsFileZones[NumStat], - &SizeOfFileZones[NumStat]); - HTM_TABLE_End (); + /***** Write sizes of all file zones per user *****/ + HTM_TABLE_BeginCenterPadding (2); + Fig_WriteStatsExpTreesTableHead3 (); + for (NumStat = 0; + NumStat < Fig_NUM_STAT_CRS_FILE_ZONES; + NumStat++) + Fig_WriteRowStatsFileBrowsers3 (Txt_STAT_COURSE_FILE_ZONES[NumStat], + StatCrsFileZones[NumStat], + &SizeOfFileZones[NumStat]); + HTM_TABLE_End (); /***** End box *****/ Box_BoxEnd (); @@ -2645,16 +2640,14 @@ static void Fig_WriteStatsExpTreesTableHead1 (void) extern const char *Txt_Size; HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_File_zones); - HTM_TH (1,1,"RM",Txt_Courses); - HTM_TH (1,1,"RM",Txt_Groups); - HTM_TH (1,1,"RM",Txt_Users); - HTM_TH (1,1,"RM",Txt_Max_levels); - HTM_TH (1,1,"RM",Txt_Folders); - HTM_TH (1,1,"RM",Txt_Files); - HTM_TH (1,1,"RM",Txt_Size); - + HTM_TH (1,1,"LM",Txt_File_zones); + HTM_TH (1,1,"RM",Txt_Courses); + HTM_TH (1,1,"RM",Txt_Groups); + HTM_TH (1,1,"RM",Txt_Users); + HTM_TH (1,1,"RM",Txt_Max_levels); + HTM_TH (1,1,"RM",Txt_Folders); + HTM_TH (1,1,"RM",Txt_Files); + HTM_TH (1,1,"RM",Txt_Size); HTM_TR_End (); } @@ -2668,25 +2661,25 @@ static void Fig_WriteStatsExpTreesTableHead2 (void) HTM_TR_Begin (NULL); - HTM_TH (1,1,"LM",Txt_File_zones); + HTM_TH (1,1,"LM",Txt_File_zones); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Folders); - HTM_BR (); - HTM_Txt (Txt_course); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Folders); + HTM_BR (); + HTM_Txt (Txt_course); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Files); - HTM_BR (); - HTM_Txt (Txt_course); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Files); + HTM_BR (); + HTM_Txt (Txt_course); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Size); - HTM_BR (); - HTM_Txt (Txt_course); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Size); + HTM_BR (); + HTM_Txt (Txt_course); + HTM_TH_End (); HTM_TR_End (); } @@ -2701,25 +2694,25 @@ static void Fig_WriteStatsExpTreesTableHead3 (void) HTM_TR_Begin (NULL); - HTM_TH (1,1,"LM",Txt_File_zones); + HTM_TH (1,1,"LM",Txt_File_zones); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Folders); - HTM_BR (); - HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Folders); + HTM_BR (); + HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Files); - HTM_BR (); - HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Files); + HTM_BR (); + HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); + HTM_TH_End (); - HTM_TH_Begin (1,1,"RM"); - HTM_TxtF ("%s/",Txt_Size); - HTM_BR (); - HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); - HTM_TH_End (); + HTM_TH_Begin (1,1,"RM"); + HTM_TxtF ("%s/",Txt_Size); + HTM_BR (); + HTM_Txt (Txt_user[Usr_SEX_UNKNOWN]); + HTM_TH_End (); HTM_TR_End (); } @@ -2761,37 +2754,37 @@ static void Fig_WriteRowStatsFileBrowsers1 (const char *NameOfFileZones, HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s LM\"",Class); - HTM_Txt (NameOfFileZones); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s LM\"",Class); + HTM_Txt (NameOfFileZones); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumCrss); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumCrss); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumGrps); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumGrps); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumUsrs); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumUsrs); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Unsigned (SizeOfFileZones->MaxLevels); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Unsigned (SizeOfFileZones->MaxLevels); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_UnsignedLong (SizeOfFileZones->NumFolders); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_UnsignedLong (SizeOfFileZones->NumFolders); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_UnsignedLong (SizeOfFileZones->NumFiles); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_UnsignedLong (SizeOfFileZones->NumFiles); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (FileSizeStr); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (FileSizeStr); + HTM_TD_End (); HTM_TR_End (); } @@ -2830,21 +2823,21 @@ static void Fig_WriteRowStatsFileBrowsers2 (const char *NameOfFileZones, HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s LM\"",Class); - HTM_Txt (NameOfFileZones); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s LM\"",Class); + HTM_Txt (NameOfFileZones); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumFoldersPerCrs); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumFoldersPerCrs); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumFilesPerCrs); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumFilesPerCrs); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (FileSizePerCrsStr); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (FileSizePerCrsStr); + HTM_TD_End (); HTM_TR_End (); } @@ -2883,21 +2876,21 @@ static void Fig_WriteRowStatsFileBrowsers3 (const char *NameOfFileZones, HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s LM\"",Class); - HTM_Txt (NameOfFileZones); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s LM\"",Class); + HTM_Txt (NameOfFileZones); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumFoldersPerUsr); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumFoldersPerUsr); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (StrNumFilesPerUsr); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (StrNumFilesPerUsr); + HTM_TD_End (); - HTM_TD_Begin ("class=\"%s RM\"",Class); - HTM_Txt (FileSizePerUsrStr); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RM\"",Class); + HTM_Txt (FileSizePerUsrStr); + HTM_TD_End (); HTM_TR_End (); } @@ -2922,37 +2915,35 @@ static void Fig_GetAndShowOERsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_open_educational_resources_oer,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_License); - HTM_TH (1,1,"RM",Txt_Number_of_private_files); - HTM_TH (1,1,"RM",Txt_Number_of_public_files); - - HTM_TR_End (); - - for (License = (Brw_License_t) 0; - License <= (Brw_License_t) (Brw_NUM_LICENSES - 1); - License++) - { - Fig_GetNumberOfOERsFromDB (Gbl.Scope.Current,License,NumFiles); - + /***** Write table heading *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_LICENSES[License]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_UnsignedLong (NumFiles[0]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_UnsignedLong (NumFiles[1]); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_License); + HTM_TH (1,1,"RM",Txt_Number_of_private_files); + HTM_TH (1,1,"RM",Txt_Number_of_public_files); HTM_TR_End (); - } + + for (License = (Brw_License_t) 0; + License <= (Brw_License_t) (Brw_NUM_LICENSES - 1); + License++) + { + Fig_GetNumberOfOERsFromDB (Gbl.Scope.Current,License,NumFiles); + + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_LICENSES[License]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_UnsignedLong (NumFiles[0]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_UnsignedLong (NumFiles[1]); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -3134,31 +3125,29 @@ static void Fig_GetAndShowCourseProgramStats (void) // TODO: Change function fro NULL,NULL, Hlp_ANALYTICS_Figures_course_programs,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_program_items); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_program_items); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_items_BR_per_course); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_program_items); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_program_items); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_items_BR_per_course); + /***** Write number of assignments *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumItems); + HTM_TD_End (); - /***** Write number of assignments *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithItems); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumItems); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumItemsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithItems); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumItemsPerCourse); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3192,36 +3181,34 @@ static void Fig_GetAndShowAssignmentsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_assignments,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_assignments); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_assignments); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_ASSIG_BR_per_course); + HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_assignments); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_assignments); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_ASSIG_BR_per_course); - HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + /***** Write number of assignments *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumAssignments); + HTM_TD_End (); - /***** Write number of assignments *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithAssignments); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumAssignments); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumAssignmentsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithAssignments); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNotif); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumAssignmentsPerCourse); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNotif); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3253,31 +3240,29 @@ static void Fig_GetAndShowProjectsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_projects,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_projects); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_projects); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_projects_BR_per_course); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_projects); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_projects); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_projects_BR_per_course); + /***** Write number of projects *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumProjects); + HTM_TD_End (); - /***** Write number of projects *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithProjects); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumProjects); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumProjectsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithProjects); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumProjectsPerCourse); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3310,121 +3295,119 @@ static void Fig_GetAndShowTestsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_tests,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Type_of_BR_answers); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_BR_with_test_BR_questions); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_exportable_BR_test_BR_questions); + HTM_TH (1,1,"RM",Txt_Number_BR_of_test_BR_questions); + HTM_TH (1,1,"RM",Txt_Average_BR_number_BR_of_test_BR_questions_BR_per_course); + HTM_TH (1,1,"RM",Txt_Number_of_BR_times_that_BR_questions_BR_have_been_BR_responded); + HTM_TH (1,1,"RM",Txt_Average_BR_number_of_BR_times_that_BR_questions_BR_have_been_BR_responded_BR_per_course); + HTM_TH (1,1,"RM",Txt_Average_BR_number_of_BR_times_that_BR_a_question_BR_has_been_BR_responded); + HTM_TH (1,1,"RM",Txt_Average_BR_score_BR_per_question); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Type_of_BR_answers); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_BR_with_test_BR_questions); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_exportable_BR_test_BR_questions); - HTM_TH (1,1,"RM",Txt_Number_BR_of_test_BR_questions); - HTM_TH (1,1,"RM",Txt_Average_BR_number_BR_of_test_BR_questions_BR_per_course); - HTM_TH (1,1,"RM",Txt_Number_of_BR_times_that_BR_questions_BR_have_been_BR_responded); - HTM_TH (1,1,"RM",Txt_Average_BR_number_of_BR_times_that_BR_questions_BR_have_been_BR_responded_BR_per_course); - HTM_TH (1,1,"RM",Txt_Average_BR_number_of_BR_times_that_BR_a_question_BR_has_been_BR_responded); - HTM_TH (1,1,"RM",Txt_Average_BR_score_BR_per_question); + for (AnsType = (Tst_AnswerType_t) 0; + AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); + AnsType++) + { + /***** Get the stats about test questions from this location *****/ + Tst_GetTestStats (AnsType,&Stats); - HTM_TR_End (); + /***** Write number of assignments *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_TST_STR_ANSWER_TYPES[AnsType]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (Stats.NumCoursesWithQuestions); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_TxtF ("%u (%.1lf%%)", + Stats.NumCoursesWithPluggableQuestions, + Stats.NumCoursesWithQuestions ? (double) Stats.NumCoursesWithPluggableQuestions * 100.0 / + (double) Stats.NumCoursesWithQuestions : + 0.0); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (Stats.NumQsts); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (Stats.AvgQstsPerCourse); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_UnsignedLong (Stats.NumHits); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (Stats.AvgHitsPerCourse); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (Stats.AvgHitsPerQuestion); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (Stats.AvgScorePerQuestion); + HTM_TD_End (); + + HTM_TR_End (); + } - for (AnsType = (Tst_AnswerType_t) 0; - AnsType <= (Tst_AnswerType_t) (Tst_NUM_ANS_TYPES - 1); - AnsType++) - { /***** Get the stats about test questions from this location *****/ - Tst_GetTestStats (AnsType,&Stats); + Tst_GetTestStats (Tst_ANS_UNKNOWN,&Stats); /***** Write number of assignments *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_TST_STR_ANSWER_TYPES[AnsType]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); + HTM_Txt (Txt_Total); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (Stats.NumCoursesWithQuestions); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (Stats.NumCoursesWithQuestions); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_TxtF ("%u (%.1lf%%)", - Stats.NumCoursesWithPluggableQuestions, - Stats.NumCoursesWithQuestions ? (double) Stats.NumCoursesWithPluggableQuestions * 100.0 / - (double) Stats.NumCoursesWithQuestions : - 0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_TxtF ("%u (%.1f%%)", + Stats.NumCoursesWithPluggableQuestions, + Stats.NumCoursesWithQuestions ? (double) Stats.NumCoursesWithPluggableQuestions * 100.0 / + (double) Stats.NumCoursesWithQuestions : + 0.0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (Stats.NumQsts); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (Stats.NumQsts); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (Stats.AvgQstsPerCourse); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (Stats.AvgQstsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_UnsignedLong (Stats.NumHits); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_UnsignedLong (Stats.NumHits); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (Stats.AvgHitsPerCourse); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (Stats.AvgHitsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (Stats.AvgHitsPerQuestion); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (Stats.AvgHitsPerQuestion); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (Stats.AvgScorePerQuestion); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (Stats.AvgScorePerQuestion); + HTM_TD_End (); HTM_TR_End (); - } - - /***** Get the stats about test questions from this location *****/ - Tst_GetTestStats (Tst_ANS_UNKNOWN,&Stats); - - /***** Write number of assignments *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); - HTM_Txt (Txt_Total); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (Stats.NumCoursesWithQuestions); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_TxtF ("%u (%.1f%%)", - Stats.NumCoursesWithPluggableQuestions, - Stats.NumCoursesWithQuestions ? (double) Stats.NumCoursesWithPluggableQuestions * 100.0 / - (double) Stats.NumCoursesWithQuestions : - 0.0); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (Stats.NumQsts); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (Stats.AvgQstsPerCourse); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_UnsignedLong (Stats.NumHits); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (Stats.AvgHitsPerCourse); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (Stats.AvgHitsPerQuestion); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (Stats.AvgScorePerQuestion); - HTM_TD_End (); - - HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3446,8 +3429,8 @@ static void Fig_GetAndShowExamsStats (void) double NumExamsPerCourse = 0.0; /***** Get the number of exams from this location *****/ - if ((NumExams = Exa_GetNumExams (Gbl.Scope.Current))) - if ((NumCoursesWithExams = Exa_GetNumCoursesWithExams (Gbl.Scope.Current)) != 0) + if ((NumExams = Exa_DB_GetNumExams (Gbl.Scope.Current))) + if ((NumCoursesWithExams = Exa_DB_GetNumCoursesWithExams (Gbl.Scope.Current)) != 0) NumExamsPerCourse = (double) NumExams / (double) NumCoursesWithExams; /***** Begin box and table *****/ @@ -3455,31 +3438,29 @@ static void Fig_GetAndShowExamsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_exams,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_exams); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_exams); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_exams_BR_per_course); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_exams); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_exams); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_exams_BR_per_course); + /***** Write number of exams *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumExams); + HTM_TD_End (); - /***** Write number of exams *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithExams); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumExams); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumExamsPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithExams); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumExamsPerCourse); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3510,31 +3491,29 @@ static void Fig_GetAndShowGamesStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_games,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_games); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_games); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_games_BR_per_course); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_games); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_games); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_games_BR_per_course); + /***** Write number of games *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumGames); + HTM_TD_End (); - /***** Write number of games *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithGames); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumGames); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumGamesPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithGames); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumGamesPerCourse); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3568,25 +3547,175 @@ static void Fig_GetAndShowTimelineActivityStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_timeline,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Type); + HTM_TH (1,1,"RM",Txt_Number_of_posts); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + HTM_TH (1,1,"RM",Txt_Number_of_posts_BR_per_user); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Type); - HTM_TH (1,1,"RM",Txt_Number_of_posts); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - HTM_TH (1,1,"RM",Txt_Number_of_posts_BR_per_user); + /***** Get total number of users *****/ + NumUsrsTotal = Usr_GetTotalNumberOfUsers (); - HTM_TR_End (); + /***** Get total number of following/followers from database *****/ + for (NoteType = (Tml_Not_NoteType_t) 0; + NoteType <= (Tml_Not_NoteType_t) (TL_NOT_NUM_NOTE_TYPES - 1); + NoteType++) + { + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(*)," // row[0] + "COUNT(DISTINCT UsrCod)" // row[1] + " FROM tml_notes WHERE NoteType=%u", + NoteType); + break; + case HieLvl_CTY: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] + "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "tml_notes" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=tml_notes.UsrCod" + " AND tml_notes.NoteType=%u", + Gbl.Hierarchy.Cty.CtyCod, + (unsigned) NoteType); + break; + case HieLvl_INS: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] + "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "tml_notes" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=tml_notes.UsrCod" + " AND tml_notes.NoteType=%u", + Gbl.Hierarchy.Ins.InsCod, + (unsigned) NoteType); + break; + case HieLvl_CTR: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] + "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] + " FROM deg_degrees," + "crs_courses," + "crs_users," + "tml_notes" + " WHERE deg_degrees.CtrCod=%ld" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=tml_notes.UsrCod" + " AND tml_notes.NoteType=%u", + Gbl.Hierarchy.Ctr.CtrCod, + (unsigned) NoteType); + break; + case HieLvl_DEG: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] + "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] + " FROM crs_courses," + "crs_users," + "tml_notes" + " WHERE crs_courses.DegCod=%ld" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=tml_notes.UsrCod" + " AND tml_notes.NoteType=%u", + Gbl.Hierarchy.Deg.DegCod, + (unsigned) NoteType); + break; + case HieLvl_CRS: + NumRows = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get number of social notes", + "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] + "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] + " FROM crs_users," + "tml_notes" + " WHERE crs_users.CrsCod=%ld" + " AND crs_users.UsrCod=tml_notes.UsrCod" + " AND tml_notes.NoteType=%u", + Gbl.Hierarchy.Crs.CrsCod, + (unsigned) NoteType); + break; + default: + Err_WrongScopeExit (); + NumRows = 0; // Initialized to avoid warning + break; + } + NumNotes = 0; + NumUsrs = 0; - /***** Get total number of users *****/ - NumUsrsTotal = Usr_GetTotalNumberOfUsers (); + if (NumRows) + { + /***** Get number of social notes and number of users *****/ + row = mysql_fetch_row (mysql_res); - /***** Get total number of following/followers from database *****/ - for (NoteType = (Tml_Not_NoteType_t) 0; - NoteType <= (Tml_Not_NoteType_t) (TL_NOT_NUM_NOTE_TYPES - 1); - NoteType++) - { + /* Get number of social notes */ + if (row[0]) + if (sscanf (row[0],"%u",&NumNotes) != 1) + NumNotes = 0; + + /* Get number of users */ + if (row[1]) + if (sscanf (row[1],"%u",&NumUsrs) != 1) + NumUsrs = 0; + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + + /***** Write number of social notes and number of users *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_TIMELINE_NOTE[NoteType]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNotes); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } + + /***** Get and write totals *****/ switch (Gbl.Scope.Current) { case HieLvl_SYS: @@ -3594,8 +3723,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) DB_QuerySELECT (&mysql_res,"can not get number of social notes", "SELECT COUNT(*)," // row[0] "COUNT(DISTINCT UsrCod)" // row[1] - " FROM tml_notes WHERE NoteType=%u", - NoteType); + " FROM tml_notes"); break; case HieLvl_CTY: NumRows = (unsigned) @@ -3603,20 +3731,18 @@ static void Fig_GetAndShowTimelineActivityStats (void) "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "tml_notes" " WHERE ins_instits.CtyCod=%ld" " AND ins_instits.InsCod=ctr_centers.InsCod" " AND ctr_centers.CtrCod=deg_degrees.CtrCod" " AND deg_degrees.DegCod=crs_courses.DegCod" " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod" - " AND tml_notes.NoteType=%u", - Gbl.Hierarchy.Cty.CtyCod, - (unsigned) NoteType); + " AND crs_users.UsrCod=tml_notes.UsrCod", + Gbl.Hierarchy.Cty.CtyCod); break; case HieLvl_INS: NumRows = (unsigned) @@ -3624,18 +3750,16 @@ static void Fig_GetAndShowTimelineActivityStats (void) "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" + "deg_degrees," + "crs_courses," + "crs_users," + "tml_notes" " WHERE ctr_centers.InsCod=%ld" " AND ctr_centers.CtrCod=deg_degrees.CtrCod" " AND deg_degrees.DegCod=crs_courses.DegCod" " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod" - " AND tml_notes.NoteType=%u", - Gbl.Hierarchy.Ins.InsCod, - (unsigned) NoteType); + " AND crs_users.UsrCod=tml_notes.UsrCod", + Gbl.Hierarchy.Ins.InsCod); break; case HieLvl_CTR: NumRows = (unsigned) @@ -3643,16 +3767,14 @@ static void Fig_GetAndShowTimelineActivityStats (void) "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] " FROM deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" + "crs_courses," + "crs_users," + "tml_notes" " WHERE deg_degrees.CtrCod=%ld" " AND deg_degrees.DegCod=crs_courses.DegCod" " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod" - " AND tml_notes.NoteType=%u", - Gbl.Hierarchy.Ctr.CtrCod, - (unsigned) NoteType); + " AND crs_users.UsrCod=tml_notes.UsrCod", + Gbl.Hierarchy.Ctr.CtrCod); break; case HieLvl_DEG: NumRows = (unsigned) @@ -3660,14 +3782,12 @@ static void Fig_GetAndShowTimelineActivityStats (void) "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] " FROM crs_courses," - "crs_users," - "tml_notes" + "crs_users," + "tml_notes" " WHERE crs_courses.DegCod=%ld" " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod" - " AND tml_notes.NoteType=%u", - Gbl.Hierarchy.Deg.DegCod, - (unsigned) NoteType); + " AND crs_users.UsrCod=tml_notes.UsrCod", + Gbl.Hierarchy.Deg.DegCod); break; case HieLvl_CRS: NumRows = (unsigned) @@ -3675,12 +3795,10 @@ static void Fig_GetAndShowTimelineActivityStats (void) "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] " FROM crs_users," - "tml_notes" + "tml_notes" " WHERE crs_users.CrsCod=%ld" - " AND crs_users.UsrCod=tml_notes.UsrCod" - " AND tml_notes.NoteType=%u", - Gbl.Hierarchy.Crs.CrsCod, - (unsigned) NoteType); + " AND crs_users.UsrCod=tml_notes.UsrCod", + Gbl.Hierarchy.Crs.CrsCod); break; default: Err_WrongScopeExit (); @@ -3692,7 +3810,7 @@ static void Fig_GetAndShowTimelineActivityStats (void) if (NumRows) { - /***** Get number of social notes and number of users *****/ + /* Get number of social notes and number of users */ row = mysql_fetch_row (mysql_res); /* Get number of social notes */ @@ -3706,177 +3824,36 @@ static void Fig_GetAndShowTimelineActivityStats (void) NumUsrs = 0; } - /***** Free structure that stores the query result *****/ + /* Free structure that stores the query result */ DB_FreeMySQLResult (&mysql_res); - /***** Write number of social notes and number of users *****/ + /* Write totals */ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_TIMELINE_NOTE[NoteType]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); + HTM_Txt (Txt_Total); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNotes); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (NumNotes); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (NumUsrs); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs : - 0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs : + 0.0); + HTM_TD_End (); HTM_TR_End (); - } - - /***** Get and write totals *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(*)," // row[0] - "COUNT(DISTINCT UsrCod)" // row[1] - " FROM tml_notes"); - break; - case HieLvl_CTY: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] - "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod", - Gbl.Hierarchy.Cty.CtyCod); - break; - case HieLvl_INS: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] - "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod", - Gbl.Hierarchy.Ins.InsCod); - break; - case HieLvl_CTR: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] - "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] - " FROM deg_degrees," - "crs_courses," - "crs_users," - "tml_notes" - " WHERE deg_degrees.CtrCod=%ld" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod", - Gbl.Hierarchy.Ctr.CtrCod); - break; - case HieLvl_DEG: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] - "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] - " FROM crs_courses," - "crs_users," - "tml_notes" - " WHERE crs_courses.DegCod=%ld" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=tml_notes.UsrCod", - Gbl.Hierarchy.Deg.DegCod); - break; - case HieLvl_CRS: - NumRows = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get number of social notes", - "SELECT COUNT(DISTINCT tml_notes.NotCod)," // row[0] - "COUNT(DISTINCT tml_notes.UsrCod)" // row[1] - " FROM crs_users," - "tml_notes" - " WHERE crs_users.CrsCod=%ld" - " AND crs_users.UsrCod=tml_notes.UsrCod", - Gbl.Hierarchy.Crs.CrsCod); - break; - default: - Err_WrongScopeExit (); - NumRows = 0; // Initialized to avoid warning - break; - } - NumNotes = 0; - NumUsrs = 0; - - if (NumRows) - { - /* Get number of social notes and number of users */ - row = mysql_fetch_row (mysql_res); - - /* Get number of social notes */ - if (row[0]) - if (sscanf (row[0],"%u",&NumNotes) != 1) - NumNotes = 0; - - /* Get number of users */ - if (row[1]) - if (sscanf (row[1],"%u",&NumUsrs) != 1) - NumUsrs = 0; - } - - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); - - /* Write totals */ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); - HTM_Txt (Txt_Total); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (NumNotes); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (NumUsrs); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (NumUsrs ? (double) NumNotes / (double) NumUsrs : - 0.0); - HTM_TD_End (); - - HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -3911,273 +3888,271 @@ static void Fig_GetAndShowFollowStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_followed_followers,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Users); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Users); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + /***** Get total number of users *****/ + NumUsrsTotal = Usr_GetTotalNumberOfUsers (); - HTM_TR_End (); - - /***** Get total number of users *****/ - NumUsrsTotal = Usr_GetTotalNumberOfUsers (); - - /***** Get total number of following/followers from database *****/ - for (Fol = 0; - Fol < 2; - Fol++) - { - switch (Gbl.Scope.Current) + /***** Get total number of following/followers from database *****/ + for (Fol = 0; + Fol < 2; + Fol++) { - case HieLvl_SYS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT %s)" - " FROM usr_follow", - FieldDB[Fol]); - break; - case HieLvl_CTY: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT usr_follow.%s)" - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s", - FieldDB[Fol], - Gbl.Hierarchy.Cty.CtyCod, - FieldDB[Fol]); - break; - case HieLvl_INS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT usr_follow.%s)" - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s", - FieldDB[Fol], - Gbl.Hierarchy.Ins.InsCod, - FieldDB[Fol]); - break; - case HieLvl_CTR: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT usr_follow.%s)" - " FROM deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE deg_degrees.CtrCod=%ld" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s", - FieldDB[Fol], - Gbl.Hierarchy.Ctr.CtrCod, - FieldDB[Fol]); - break; - case HieLvl_DEG: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT usr_follow.%s)" - " FROM crs_courses," - "crs_users," - "usr_follow" - " WHERE crs_courses.DegCod=%ld" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s", - FieldDB[Fol], - Gbl.Hierarchy.Deg.DegCod, - FieldDB[Fol]); - break; - case HieLvl_CRS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the total number of following/followers", - "SELECT COUNT(DISTINCT usr_follow.%s)" - " FROM crs_users," - "usr_follow" - " WHERE crs_users.CrsCod=%ld" - " AND crs_users.UsrCod=usr_follow.%s", - FieldDB[Fol], - Gbl.Hierarchy.Crs.CrsCod, - FieldDB[Fol]); - break; - default: - Err_WrongScopeExit (); - NumUsrs = 0; // Not reached. Initialized to av oid warning - break; + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT %s)" + " FROM usr_follow", + FieldDB[Fol]); + break; + case HieLvl_CTY: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT usr_follow.%s)" + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s", + FieldDB[Fol], + Gbl.Hierarchy.Cty.CtyCod, + FieldDB[Fol]); + break; + case HieLvl_INS: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT usr_follow.%s)" + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s", + FieldDB[Fol], + Gbl.Hierarchy.Ins.InsCod, + FieldDB[Fol]); + break; + case HieLvl_CTR: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT usr_follow.%s)" + " FROM deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE deg_degrees.CtrCod=%ld" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s", + FieldDB[Fol], + Gbl.Hierarchy.Ctr.CtrCod, + FieldDB[Fol]); + break; + case HieLvl_DEG: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT usr_follow.%s)" + " FROM crs_courses," + "crs_users," + "usr_follow" + " WHERE crs_courses.DegCod=%ld" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s", + FieldDB[Fol], + Gbl.Hierarchy.Deg.DegCod, + FieldDB[Fol]); + break; + case HieLvl_CRS: + NumUsrs = (unsigned) + DB_QueryCOUNT ("can not get the total number of following/followers", + "SELECT COUNT(DISTINCT usr_follow.%s)" + " FROM crs_users," + "usr_follow" + " WHERE crs_users.CrsCod=%ld" + " AND crs_users.UsrCod=usr_follow.%s", + FieldDB[Fol], + Gbl.Hierarchy.Crs.CrsCod, + FieldDB[Fol]); + break; + default: + Err_WrongScopeExit (); + NumUsrs = 0; // Not reached. Initialized to av oid warning + break; + } + + /***** Write number of followed / followers *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Fol == 0 ? Txt_Followed : + Txt_Followers); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); } - /***** Write number of followed / followers *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Fol == 0 ? Txt_Followed : - Txt_Followers); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - - HTM_TR_End (); - } - - /***** Write number of followed/followers per follower/followed *****/ - for (Fol = 0; - Fol < 2; - Fol++) - { - switch (Gbl.Scope.Current) + /***** Write number of followed/followers per follower/followed *****/ + for (Fol = 0; + Fol < 2; + Fol++) { - case HieLvl_SYS: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(%s) AS N" - " FROM usr_follow" - " GROUP BY %s) AS F", - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - case HieLvl_CTY: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s" - " GROUP BY %s) AS F", - FieldDB[Fol], - Gbl.Hierarchy.Cty.CtyCod, - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - case HieLvl_INS: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s" - " GROUP BY %s) AS F", - FieldDB[Fol], - Gbl.Hierarchy.Ins.InsCod, - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - case HieLvl_CTR: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" - " FROM deg_degrees," - "crs_courses," - "crs_users," - "usr_follow" - " WHERE deg_degrees.CtrCod=%ld" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s" - " GROUP BY %s) AS F", - FieldDB[Fol], - Gbl.Hierarchy.Ctr.CtrCod, - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - case HieLvl_DEG: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" - " FROM crs_courses," - "crs_users," - "usr_follow" - " WHERE crs_courses.DegCod=%ld" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_follow.%s" - " GROUP BY %s) AS F", - FieldDB[Fol], - Gbl.Hierarchy.Deg.DegCod, - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - case HieLvl_CRS: - Average = DB_QuerySELECTDouble ("can not get number of questions" - " per survey", - "SELECT AVG(N)" - " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" - " FROM crs_users," - "usr_follow" - " WHERE crs_users.CrsCod=%ld" - " AND crs_users.UsrCod=usr_follow.%s" - " GROUP BY %s) AS F", - FieldDB[Fol], - Gbl.Hierarchy.Crs.CrsCod, - FieldDB[Fol], - FieldDB[1 - Fol]); - break; - default: - Err_WrongScopeExit (); - Average = 0.0; // Not reached - break; + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(%s) AS N" + " FROM usr_follow" + " GROUP BY %s) AS F", + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + case HieLvl_CTY: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s" + " GROUP BY %s) AS F", + FieldDB[Fol], + Gbl.Hierarchy.Cty.CtyCod, + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + case HieLvl_INS: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s" + " GROUP BY %s) AS F", + FieldDB[Fol], + Gbl.Hierarchy.Ins.InsCod, + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + case HieLvl_CTR: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" + " FROM deg_degrees," + "crs_courses," + "crs_users," + "usr_follow" + " WHERE deg_degrees.CtrCod=%ld" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s" + " GROUP BY %s) AS F", + FieldDB[Fol], + Gbl.Hierarchy.Ctr.CtrCod, + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + case HieLvl_DEG: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" + " FROM crs_courses," + "crs_users," + "usr_follow" + " WHERE crs_courses.DegCod=%ld" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_follow.%s" + " GROUP BY %s) AS F", + FieldDB[Fol], + Gbl.Hierarchy.Deg.DegCod, + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + case HieLvl_CRS: + Average = DB_QuerySELECTDouble ("can not get number of questions" + " per survey", + "SELECT AVG(N)" + " FROM (SELECT COUNT(DISTINCT usr_follow.%s) AS N" + " FROM crs_users," + "usr_follow" + " WHERE crs_users.CrsCod=%ld" + " AND crs_users.UsrCod=usr_follow.%s" + " GROUP BY %s) AS F", + FieldDB[Fol], + Gbl.Hierarchy.Crs.CrsCod, + FieldDB[Fol], + FieldDB[1 - Fol]); + break; + default: + Err_WrongScopeExit (); + Average = 0.0; // Not reached + break; + } + + /***** Write number of followed per follower *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_FollowPerFollow[Fol]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (Average); + HTM_TD_End (); + + HTM_TD_Empty (1); + + HTM_TR_End (); } - /***** Write number of followed per follower *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_FollowPerFollow[Fol]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (Average); - HTM_TD_End (); - - HTM_TD_Empty (1); - - HTM_TR_End (); - } - /***** End table and box *****/ Box_BoxTableEnd (); } @@ -4212,84 +4187,82 @@ static void Fig_GetAndShowForumStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_forums,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH_Begin (1,1,"BT"); + Ico_PutIcon ("comments.svg",Txt_Scope,"ICO16x16"); + HTM_TH_End (); + HTM_TH (1,1,"LT",Txt_Forums); + HTM_TH (1,1,"RT",Txt_Number_of_forums); + HTM_TH (1,1,"RT",Txt_Number_of_threads); + HTM_TH (1,1,"RT",Txt_Number_of_posts); + HTM_TH (1,1,"RT",Txt_Number_of_BR_notifications); + HTM_TH (1,1,"RT",Txt_Number_of_threads_BR_per_forum); + HTM_TH (1,1,"RT",Txt_Number_of_posts_BR_per_thread); + HTM_TH (1,1,"RT",Txt_Number_of_posts_BR_per_forum); + HTM_TR_End (); - HTM_TH_Begin (1,1,"BT"); - Ico_PutIcon ("comments.svg",Txt_Scope,"ICO16x16"); - HTM_TH_End (); - HTM_TH (1,1,"LT",Txt_Forums); - HTM_TH (1,1,"RT",Txt_Number_of_forums); - HTM_TH (1,1,"RT",Txt_Number_of_threads); - HTM_TH (1,1,"RT",Txt_Number_of_posts); - HTM_TH (1,1,"RT",Txt_Number_of_BR_notifications); - HTM_TH (1,1,"RT",Txt_Number_of_threads_BR_per_forum); - HTM_TH (1,1,"RT",Txt_Number_of_posts_BR_per_thread); - HTM_TH (1,1,"RT",Txt_Number_of_posts_BR_per_forum); + /***** Write a row for each type of forum *****/ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM__SWAD__USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM__SWAD__TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); + break; + case HieLvl_CTY: + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); + break; + case HieLvl_INS: + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); + break; + case HieLvl_CTR: + Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); + break; + case HieLvl_DEG: + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); + break; + case HieLvl_CRS: + Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); + Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); + break; + default: + Err_WrongScopeExit (); + break; + } - HTM_TR_End (); - - /***** Write a row for each type of forum *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_GLOBAL_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM__SWAD__USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM__SWAD__TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,-1L,&FiguresForum); - break; - case HieLvl_CTY: - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,Gbl.Hierarchy.Cty.CtyCod,-1L,-1L,-1L,-1L,&FiguresForum); - break; - case HieLvl_INS: - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_INSTIT_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,Gbl.Hierarchy.Ins.InsCod,-1L,-1L,-1L,&FiguresForum); - break; - case HieLvl_CTR: - Fig_ShowStatOfAForumType (For_FORUM_CENTER_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_CENTER_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,Gbl.Hierarchy.Ctr.CtrCod,-1L,-1L,&FiguresForum); - break; - case HieLvl_DEG: - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_DEGREE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,Gbl.Hierarchy.Deg.DegCod,-1L,&FiguresForum); - break; - case HieLvl_CRS: - Fig_ShowStatOfAForumType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); - Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum); - break; - default: - Err_WrongScopeExit (); - break; - } - - Fig_WriteForumTotalStats (&FiguresForum); + Fig_WriteForumTotalStats (&FiguresForum); /***** End table and box *****/ Box_BoxTableEnd (); @@ -4396,8 +4369,8 @@ static void Fig_WriteForumTitleAndStats (For_ForumType_t ForumType, char *ForumName; /***** Compute number of forums, number of threads and number of posts *****/ - NumForums = For_GetNumTotalForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod); - NumThreads = For_GetNumTotalThrsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod); + NumForums = For_DB_GetNumTotalForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod); + NumThreads = For_DB_GetNumTotalThrsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod); NumPosts = For_GetNumTotalPstsInForumsOfType (ForumType,CtyCod,InsCod,CtrCod,DegCod,CrsCod,&NumUsrsToBeNotifiedByEMail); /***** Compute number of threads per forum, number of posts per forum and number of posts per thread *****/ @@ -4417,46 +4390,46 @@ static void Fig_WriteForumTitleAndStats (For_ForumType_t ForumType, /***** Write forum name and stats *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"BT\""); - if (asprintf (&ForumName,"%s%s", - ForumName1,ForumName2) < 0) - Err_NotEnoughMemoryExit (); - Ico_PutIcon (Icon,ForumName,"ICO16x16"); - free (ForumName); - HTM_TD_End (); + HTM_TD_Begin ("class=\"BT\""); + if (asprintf (&ForumName,"%s%s", + ForumName1,ForumName2) < 0) + Err_NotEnoughMemoryExit (); + Ico_PutIcon (Icon,ForumName,"ICO16x16"); + free (ForumName); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LT\""); - HTM_Txt (ForumName1); - HTM_Txt (ForumName2); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT\""); + HTM_Txt (ForumName1); + HTM_Txt (ForumName2); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Unsigned (NumForums); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Unsigned (NumForums); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Unsigned (NumThreads); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Unsigned (NumThreads); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Unsigned (NumPosts); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Unsigned (NumPosts); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Unsigned (NumUsrsToBeNotifiedByEMail); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Unsigned (NumUsrsToBeNotifiedByEMail); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Double2Decimals (NumThrsPerForum); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Double2Decimals (NumThrsPerForum); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Double2Decimals (NumPostsPerThread); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Double2Decimals (NumPostsPerThread); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RT\""); - HTM_Double2Decimals (NumPostsPerForum); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RT\""); + HTM_Double2Decimals (NumPostsPerForum); + HTM_TD_End (); HTM_TR_End (); } @@ -4486,40 +4459,40 @@ static void Fig_WriteForumTotalStats (struct Fig_FiguresForum *FiguresForum) /***** Write forum name and stats *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP\" style=\"width:20px;\""); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP\" style=\"width:20px;\""); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); - HTM_Txt (Txt_Total); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); + HTM_Txt (Txt_Total); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (FiguresForum->NumForums); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (FiguresForum->NumForums); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (FiguresForum->NumThreads); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (FiguresForum->NumThreads); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (FiguresForum->NumPosts); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (FiguresForum->NumPosts); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (FiguresForum->NumUsrsToBeNotifiedByEMail); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (FiguresForum->NumUsrsToBeNotifiedByEMail); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (NumThrsPerForum); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (NumThrsPerForum); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (NumPostsPerThread); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (NumPostsPerThread); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Double2Decimals (NumPostsPerForum); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Double2Decimals (NumPostsPerForum); + HTM_TD_End (); HTM_TR_End (); } @@ -4556,207 +4529,205 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void) NULL,NULL, Hlp_ANALYTICS_Figures_notifications,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Event); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + HTM_TH (1,1,"RM",Txt_Number_of_events); + HTM_TH (1,1,"RM",Txt_Number_of_emails); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Event); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - HTM_TH (1,1,"RM",Txt_Number_of_events); - HTM_TH (1,1,"RM",Txt_Number_of_emails); + /***** Get total number of users *****/ + NumUsrsTotal = Usr_GetTotalNumberOfUsers (); - HTM_TR_End (); + /***** Get total number of users who want to be + notified by email on some event, from database *****/ + NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent = + Usr_DB_GetNumUsrsWhoChoseAnOption ("usr_data.EmailNtfEvents<>0"); - /***** Get total number of users *****/ - NumUsrsTotal = Usr_GetTotalNumberOfUsers (); + /***** For each notify event... *****/ + for (NotifyEvent = (Ntf_NotifyEvent_t) 1; + NotifyEvent <= (Ntf_NotifyEvent_t) (Ntf_NUM_NOTIFY_EVENTS - 1); + NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN + { + /* Get the number of users who want to be notified by email on this event, from database */ + if (asprintf (&SubQuery,"((usr_data.EmailNtfEvents & %u)<>0)", + (1 << NotifyEvent)) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[NotifyEvent] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); - /***** Get total number of users who want to be - notified by email on some event, from database *****/ - NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent = - Fig_GetNumUsrsWhoChoseAnOption ("usr_data.EmailNtfEvents<>0"); + /* Get number of notifications by email from database */ + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(NumEvents)," // row[0] + "SUM(NumMails)" // row[1] + " FROM sta_notifications" + " WHERE NotifyEvent=%u", + (unsigned) NotifyEvent); + break; + case HieLvl_CTY: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(sta_notifications.NumEvents)," // row[0] + "SUM(sta_notifications.NumMails)" // row[1] + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "sta_notifications" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=sta_notifications.DegCod" + " AND sta_notifications.NotifyEvent=%u", + Gbl.Hierarchy.Cty.CtyCod, + (unsigned) NotifyEvent); + break; + case HieLvl_INS: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(sta_notifications.NumEvents)," // row[0] + "SUM(sta_notifications.NumMails)" // row[1] + " FROM ctr_centers," + "deg_degrees," + "sta_notifications" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=sta_notifications.DegCod" + " AND sta_notifications.NotifyEvent=%u", + Gbl.Hierarchy.Ins.InsCod, + (unsigned) NotifyEvent); + break; + case HieLvl_CTR: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(sta_notifications.NumEvents)," // row[0] + "SUM(sta_notifications.NumMails)" // row[1] + " FROM deg_degrees," + "sta_notifications" + " WHERE deg_degrees.CtrCod=%ld" + " AND deg_degrees.DegCod=sta_notifications.DegCod" + " AND sta_notifications.NotifyEvent=%u", + Gbl.Hierarchy.Ctr.CtrCod, + (unsigned) NotifyEvent); + break; + case HieLvl_DEG: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(NumEvents)," // row[0] + "SUM(NumMails)" // row[1] + " FROM sta_notifications" + " WHERE DegCod=%ld" + " AND NotifyEvent=%u", + Gbl.Hierarchy.Deg.DegCod, + (unsigned) NotifyEvent); + break; + case HieLvl_CRS: + DB_QuerySELECT (&mysql_res,"can not get the number" + " of notifications by email", + "SELECT SUM(NumEvents)," // row[0] + "SUM(NumMails)" // row[1] + " FROM sta_notifications" + " WHERE CrsCod=%ld" + " AND NotifyEvent=%u", + Gbl.Hierarchy.Crs.CrsCod, + (unsigned) NotifyEvent); + break; + default: + Err_WrongScopeExit (); + break; + } - /***** For each notify event... *****/ - for (NotifyEvent = (Ntf_NotifyEvent_t) 1; - NotifyEvent <= (Ntf_NotifyEvent_t) (Ntf_NUM_NOTIFY_EVENTS - 1); - NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN - { - /* Get the number of users who want to be notified by email on this event, from database */ - if (asprintf (&SubQuery,"((usr_data.EmailNtfEvents & %u)<>0)", - (1 << NotifyEvent)) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[NotifyEvent] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); + row = mysql_fetch_row (mysql_res); - /* Get number of notifications by email from database */ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(NumEvents)," // row[0] - "SUM(NumMails)" // row[1] - " FROM sta_notifications" - " WHERE NotifyEvent=%u", - (unsigned) NotifyEvent); - break; - case HieLvl_CTY: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(sta_notifications.NumEvents)," // row[0] - "SUM(sta_notifications.NumMails)" // row[1] - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "sta_notifications" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=sta_notifications.DegCod" - " AND sta_notifications.NotifyEvent=%u", - Gbl.Hierarchy.Cty.CtyCod, - (unsigned) NotifyEvent); - break; - case HieLvl_INS: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(sta_notifications.NumEvents)," // row[0] - "SUM(sta_notifications.NumMails)" // row[1] - " FROM ctr_centers," - "deg_degrees," - "sta_notifications" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=sta_notifications.DegCod" - " AND sta_notifications.NotifyEvent=%u", - Gbl.Hierarchy.Ins.InsCod, - (unsigned) NotifyEvent); - break; - case HieLvl_CTR: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(sta_notifications.NumEvents)," // row[0] - "SUM(sta_notifications.NumMails)" // row[1] - " FROM deg_degrees," - "sta_notifications" - " WHERE deg_degrees.CtrCod=%ld" - " AND deg_degrees.DegCod=sta_notifications.DegCod" - " AND sta_notifications.NotifyEvent=%u", - Gbl.Hierarchy.Ctr.CtrCod, - (unsigned) NotifyEvent); - break; - case HieLvl_DEG: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(NumEvents)," // row[0] - "SUM(NumMails)" // row[1] - " FROM sta_notifications" - " WHERE DegCod=%ld" - " AND NotifyEvent=%u", - Gbl.Hierarchy.Deg.DegCod, - (unsigned) NotifyEvent); - break; - case HieLvl_CRS: - DB_QuerySELECT (&mysql_res,"can not get the number" - " of notifications by email", - "SELECT SUM(NumEvents)," // row[0] - "SUM(NumMails)" // row[1] - " FROM sta_notifications" - " WHERE CrsCod=%ld" - " AND NotifyEvent=%u", - Gbl.Hierarchy.Crs.CrsCod, - (unsigned) NotifyEvent); - break; - default: - Err_WrongScopeExit (); - break; - } + /* Get number of events notified */ + if (row[0]) + { + if (sscanf (row[0],"%u",&NumEvents[NotifyEvent]) != 1) + Err_ShowErrorAndExit ("Error when getting the number of notifications by email."); + } + else + NumEvents[NotifyEvent] = 0; - row = mysql_fetch_row (mysql_res); + /* Get number of mails sent */ + if (row[1]) + { + if (sscanf (row[1],"%u",&NumMails[NotifyEvent]) != 1) + Err_ShowErrorAndExit ("Error when getting the number of emails to notify events3."); + } + else + NumMails[NotifyEvent] = 0; - /* Get number of events notified */ - if (row[0]) - { - if (sscanf (row[0],"%u",&NumEvents[NotifyEvent]) != 1) - Err_ShowErrorAndExit ("Error when getting the number of notifications by email."); - } - else - NumEvents[NotifyEvent] = 0; + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); - /* Get number of mails sent */ - if (row[1]) - { - if (sscanf (row[1],"%u",&NumMails[NotifyEvent]) != 1) - Err_ShowErrorAndExit ("Error when getting the number of emails to notify events3."); - } - else - NumMails[NotifyEvent] = 0; + /* Update total number of events and mails */ + NumEventsTotal += NumEvents[NotifyEvent]; + NumMailsTotal += NumMails [NotifyEvent]; + } - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); + /***** Write number of users who want to be notified by email on each event *****/ + for (NotifyEvent = (Ntf_NotifyEvent_t) 1; + NotifyEvent <= (Ntf_NotifyEvent_t) (Ntf_NUM_NOTIFY_EVENTS - 1); + NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN + { + HTM_TR_Begin (NULL); - /* Update total number of events and mails */ - NumEventsTotal += NumEvents[NotifyEvent]; - NumMailsTotal += NumMails [NotifyEvent]; - } + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_NOTIFY_EVENTS_PLURAL[NotifyEvent]); + HTM_TD_End (); - /***** Write number of users who want to be notified by email on each event *****/ - for (NotifyEvent = (Ntf_NotifyEvent_t) 1; - NotifyEvent <= (Ntf_NotifyEvent_t) (Ntf_NUM_NOTIFY_EVENTS - 1); - NotifyEvent++) // 0 is reserved for Ntf_EVENT_UNKNOWN - { + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[NotifyEvent]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[NotifyEvent] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumEvents[NotifyEvent]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMails[NotifyEvent]); + HTM_TD_End (); + + HTM_TR_End (); + } + + /***** Write total number of users who want to be notified by email on some event *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_NOTIFY_EVENTS_PLURAL[NotifyEvent]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); + HTM_Txt (Txt_Total); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[NotifyEvent]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[NotifyEvent] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumEvents[NotifyEvent]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (NumEventsTotal); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMails[NotifyEvent]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); + HTM_Unsigned (NumMailsTotal); + HTM_TD_End (); HTM_TR_End (); - } - - /***** Write total number of users who want to be notified by email on some event *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP LM\""); - HTM_Txt (Txt_Total); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrsTotalWhoWantToBeNotifiedByEMailAboutSomeEvent * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (NumEventsTotal); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT_N LINE_TOP RM\""); - HTM_Unsigned (NumMailsTotal); - HTM_TD_End (); - - HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -4800,41 +4771,39 @@ static void Fig_GetAndShowNoticesStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_notices,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_NOTICE_Active_BR_notices); + HTM_TH (1,1,"RM",Txt_NOTICE_Obsolete_BR_notices); + HTM_TH (1,1,"RM",Txt_NOTICE_Deleted_BR_notices); + HTM_TH (1,1,"RM",Txt_Total); + HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_NOTICE_Active_BR_notices); - HTM_TH (1,1,"RM",Txt_NOTICE_Obsolete_BR_notices); - HTM_TH (1,1,"RM",Txt_NOTICE_Deleted_BR_notices); - HTM_TH (1,1,"RM",Txt_Total); - HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + /***** Write number of notices *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNotices[Not_ACTIVE_NOTICE]); + HTM_TD_End (); - /***** Write number of notices *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNotices[Not_OBSOLETE_NOTICE]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNotices[Not_ACTIVE_NOTICE]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNoticesDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNotices[Not_OBSOLETE_NOTICE]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RM\""); + HTM_Unsigned ( NumTotalNotices); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNoticesDeleted); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumTotalNotifications); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N RM\""); - HTM_Unsigned ( NumTotalNotices); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumTotalNotifications); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -4872,65 +4841,63 @@ static void Fig_GetAndShowMsgsStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_messages,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Messages); + HTM_TH (1,1,"RM",Txt_MSGS_Not_deleted); + HTM_TH (1,1,"RM",Txt_MSGS_Deleted); + HTM_TH (1,1,"RM",Txt_Total); + HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Messages); - HTM_TH (1,1,"RM",Txt_MSGS_Not_deleted); - HTM_TH (1,1,"RM",Txt_MSGS_Deleted); - HTM_TH (1,1,"RM",Txt_Total); - HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + /***** Write number of messages *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_MSGS_Sent); + HTM_TD_End (); - /***** Write number of messages *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMsgsSentNotDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_MSGS_Sent); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMsgsSentDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMsgsSentNotDeleted); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RM\""); + HTM_Unsigned (NumMsgsSentNotDeleted + NumMsgsSentDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMsgsSentDeleted); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Hyphen (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N RM\""); - HTM_Unsigned (NumMsgsSentNotDeleted + NumMsgsSentDeleted); - HTM_TD_End (); + HTM_TR_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Hyphen (); - HTM_TD_End (); + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_MSGS_Received); + HTM_TD_End (); - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMsgsReceivedNotDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_MSGS_Received); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMsgsReceivedAndDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMsgsReceivedNotDeleted); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT_N RM\""); + HTM_Unsigned (NumMsgsReceivedNotDeleted + NumMsgsReceivedAndDeleted); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMsgsReceivedAndDeleted); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumMsgsReceivedAndNotified); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT_N RM\""); - HTM_Unsigned (NumMsgsReceivedNotDeleted + NumMsgsReceivedAndDeleted); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumMsgsReceivedAndNotified); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -4958,49 +4925,47 @@ static void Fig_GetAndShowAgendasStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_agendas,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_events); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + HTM_TH (1,1,"RM",Txt_Number_of_events_per_user); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_events); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - HTM_TH (1,1,"RM",Txt_Number_of_events_per_user); + /***** Number of agenda events *****/ + NumEvents = Agd_DB_GetNumEvents (Gbl.Scope.Current); - HTM_TR_End (); + /***** Number of users with agenda events *****/ + NumUsrs = Agd_DB_GetNumUsrsWithEvents (Gbl.Scope.Current); - /***** Number of agenda events *****/ - NumEvents = Agd_DB_GetNumEvents (Gbl.Scope.Current); + /***** Get total number of users in current scope *****/ + NumUsrsTotal = Usr_GetTotalNumberOfUsers (); - /***** Number of users with agenda events *****/ - NumUsrs = Agd_DB_GetNumUsrsWithEvents (Gbl.Scope.Current); + /***** Write number of users who have chosen each language *****/ + HTM_TR_Begin (NULL); - /***** Get total number of users in current scope *****/ - NumUsrsTotal = Usr_GetTotalNumberOfUsers (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumEvents); + HTM_TD_End (); - /***** Write number of users who have chosen each language *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumEvents); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / + (double) NumUsrsTotal : + 0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumUsrs ? (double) NumEvents / + (double) NumUsrs : + 0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs * 100.0 / - (double) NumUsrsTotal : - 0); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumUsrs ? (double) NumEvents / - (double) NumUsrs : - 0); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -5039,41 +5004,39 @@ static void Fig_GetAndShowSurveysStats (void) NULL,NULL, Hlp_ANALYTICS_Figures_surveys,Box_NOT_CLOSABLE,2); - /***** Write table heading *****/ - HTM_TR_Begin (NULL); + /***** Write table heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"RM",Txt_Number_of_BR_surveys); + HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_surveys); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_surveys_BR_per_course); + HTM_TH (1,1,"RM",Txt_Average_number_BR_of_questions_BR_per_survey); + HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + HTM_TR_End (); - HTM_TH (1,1,"RM",Txt_Number_of_BR_surveys); - HTM_TH (1,1,"RM",Txt_Number_of_BR_courses_with_BR_surveys); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_surveys_BR_per_course); - HTM_TH (1,1,"RM",Txt_Average_number_BR_of_questions_BR_per_survey); - HTM_TH (1,1,"RM",Txt_Number_of_BR_notifications); + /***** Write number of surveys *****/ + HTM_TR_Begin (NULL); - HTM_TR_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumSurveys); + HTM_TD_End (); - /***** Write number of surveys *****/ - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumCoursesWithSurveys); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumSurveys); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumSurveysPerCourse); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumCoursesWithSurveys); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Double2Decimals (NumQstsPerSurvey); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumSurveysPerCourse); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumNotif); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Double2Decimals (NumQstsPerSurvey); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumNotif); - HTM_TD_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -5096,18 +5059,18 @@ static void Fig_GetAndShowNumUsrsPerPrivacy (void) NULL,NULL, Hlp_ANALYTICS_Figures_privacy,Box_NOT_CLOSABLE,2); - /***** Privacy for photo *****/ - Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Photo, - "PhotoVisibility", - Pri_PHOTO_ALLOWED_VIS); + /***** Privacy for photo *****/ + Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Photo, + "PhotoVisibility", + Pri_PHOTO_ALLOWED_VIS); - /***** Privacy for public profile *****/ - Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Basic_public_profile, - "BaPrfVisibility", - Pri_BASIC_PROFILE_ALLOWED_VIS); - Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Extended_public_profile, - "ExPrfVisibility", - Pri_EXTENDED_PROFILE_ALLOWED_VIS); + /***** Privacy for public profile *****/ + Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Basic_public_profile, + "BaPrfVisibility", + Pri_BASIC_PROFILE_ALLOWED_VIS); + Fig_GetAndShowNumUsrsPerPrivacyForAnObject (Txt_Extended_public_profile, + "ExPrfVisibility", + Pri_EXTENDED_PROFILE_ALLOWED_VIS); /***** End table and box *****/ Box_BoxTableEnd (); @@ -5132,11 +5095,9 @@ static void Fig_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject, /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",TxtObject); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - + HTM_TH (1,1,"LM",TxtObject); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); /***** For each privacy option... *****/ @@ -5149,7 +5110,7 @@ static void Fig_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject, if (asprintf (&SubQuery,"usr_data.%s='%s'", FieldName,Pri_VisibilityDB[Visibility]) < 0) Err_NotEnoughMemoryExit (); - NumUsrs[Visibility] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); + NumUsrs[Visibility] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); free (SubQuery); /* Update total number of users */ @@ -5164,19 +5125,19 @@ static void Fig_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject, { HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_PRIVACY_OPTIONS[Visibility]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_PRIVACY_OPTIONS[Visibility]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[Visibility]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[Visibility]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Visibility] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Visibility] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); HTM_TR_End (); } @@ -5219,54 +5180,52 @@ static void Fig_GetAndShowNumUsrsPerCookies (void) NULL,NULL, Hlp_ANALYTICS_Figures_cookies,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Cookies); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each option... *****/ - for (i = 0; - i < 2; - i++) - { - /* Get number of users who have chosen this menu from database */ - if (asprintf (&SubQuery,"usr_data.ThirdPartyCookies='%c'", - AcceptedInDB[i]) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[i] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[i]; - } - - /***** Write number of users who have chosen each option *****/ - for (i = 0; - i < 2; - i++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"%s CM\"",AcceptedClass[i]); - HTM_Txt (AcceptedSymbol[i]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[i]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[i] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Cookies); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each option... *****/ + for (i = 0; + i < 2; + i++) + { + /* Get number of users who have chosen this menu from database */ + if (asprintf (&SubQuery,"usr_data.ThirdPartyCookies='%c'", + AcceptedInDB[i]) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[i] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[i]; + } + + /***** Write number of users who have chosen each option *****/ + for (i = 0; + i < 2; + i++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s CM\"",AcceptedClass[i]); + HTM_Txt (AcceptedSymbol[i]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[i]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[i] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5295,54 +5254,52 @@ static void Fig_GetAndShowNumUsrsPerLanguage (void) NULL,NULL, Hlp_ANALYTICS_Figures_language,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Language); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each language... *****/ - for (Lan = (Lan_Language_t) 1; - Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; - Lan++) - { - /* Get the number of users who have chosen this language from database */ - if (asprintf (&SubQuery,"usr_data.Language='%s'", - Lan_STR_LANG_ID[Lan]) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[Lan] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[Lan]; - } - - /***** Write number of users who have chosen each language *****/ - for (Lan = (Lan_Language_t) 1; - Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; - Lan++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Txt_STR_LANG_NAME[Lan]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[Lan]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Lan] * 100.0 / - (double) NumUsrsTotal : - 0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Language); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each language... *****/ + for (Lan = (Lan_Language_t) 1; + Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; + Lan++) + { + /* Get the number of users who have chosen this language from database */ + if (asprintf (&SubQuery,"usr_data.Language='%s'", + Lan_STR_LANG_ID[Lan]) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[Lan] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[Lan]; + } + + /***** Write number of users who have chosen each language *****/ + for (Lan = (Lan_Language_t) 1; + Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; + Lan++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_Txt (Txt_STR_LANG_NAME[Lan]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[Lan]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Lan] * 100.0 / + (double) NumUsrsTotal : + 0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5373,64 +5330,62 @@ static void Fig_GetAndShowNumUsrsPerFirstDayOfWeek (void) NULL,NULL, Hlp_ANALYTICS_Figures_calendar,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); + /***** Heading row *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"LM",Txt_Calendar); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + HTM_TR_End (); - HTM_TH (1,1,"LM",Txt_Calendar); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); + /***** For each day... *****/ + for (FirstDayOfWeek = 0; // Monday + FirstDayOfWeek <= 6; // Sunday + FirstDayOfWeek++) + if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) + { + /* Get number of users who have chosen this first day of week from database */ + if (asprintf (&SubQuery,"usr_data.FirstDayOfWeek=%u", + (unsigned) FirstDayOfWeek) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[FirstDayOfWeek] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); - HTM_TR_End (); + /* Update total number of users */ + NumUsrsTotal += NumUsrs[FirstDayOfWeek]; + } - /***** For each day... *****/ - for (FirstDayOfWeek = 0; // Monday - FirstDayOfWeek <= 6; // Sunday - FirstDayOfWeek++) - if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) - { - /* Get number of users who have chosen this first day of week from database */ - if (asprintf (&SubQuery,"usr_data.FirstDayOfWeek=%u", - (unsigned) FirstDayOfWeek) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[FirstDayOfWeek] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); + /***** Write number of users who have chosen each first day of week *****/ + for (FirstDayOfWeek = 0; // Monday + FirstDayOfWeek <= 6; // Sunday + FirstDayOfWeek++) + if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) + { + HTM_TR_Begin (NULL); - /* Update total number of users */ - NumUsrsTotal += NumUsrs[FirstDayOfWeek]; - } + HTM_TD_Begin ("class=\"CM\""); + if (asprintf (&Icon,"first-day-of-week-%u.png", + FirstDayOfWeek) < 0) + Err_NotEnoughMemoryExit (); + Ico_PutIcon (Icon, + Str_BuildStringStr (Txt_First_day_of_the_week_X, + Txt_DAYS_SMALL[FirstDayOfWeek]), + "ICO40x40"); + Str_FreeString (); + free (Icon); + HTM_TD_End (); - /***** Write number of users who have chosen each first day of week *****/ - for (FirstDayOfWeek = 0; // Monday - FirstDayOfWeek <= 6; // Sunday - FirstDayOfWeek++) - if (Cal_DayIsValidAsFirstDayOfWeek[FirstDayOfWeek]) - { - HTM_TR_Begin (NULL); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[FirstDayOfWeek]); + HTM_TD_End (); - HTM_TD_Begin ("class=\"CM\""); - if (asprintf (&Icon,"first-day-of-week-%u.png", - FirstDayOfWeek) < 0) - Err_NotEnoughMemoryExit (); - Ico_PutIcon (Icon, - Str_BuildStringStr (Txt_First_day_of_the_week_X, - Txt_DAYS_SMALL[FirstDayOfWeek]), - "ICO40x40"); - Str_FreeString (); - free (Icon); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[FirstDayOfWeek] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[FirstDayOfWeek]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[FirstDayOfWeek] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - - HTM_TR_End (); - } + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5457,55 +5412,53 @@ static void Fig_GetAndShowNumUsrsPerDateFormat (void) NULL,NULL, Hlp_ANALYTICS_Figures_dates,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Format); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each format... *****/ - for (Format = (Dat_Format_t) 0; - Format <= (Dat_Format_t) (Dat_NUM_OPTIONS_FORMAT - 1); - Format++) - { - /* Get number of users who have chosen this date format from database */ - if (asprintf (&SubQuery,"usr_data.DateFormat=%u", - (unsigned) Format) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[Format] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[Format]; - } - - /***** Write number of users who have chosen each date format *****/ - for (Format = (Dat_Format_t) 0; - Format <= (Dat_Format_t) (Dat_NUM_OPTIONS_FORMAT - 1); - Format++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"DAT_N LM\""); - Dat_PutSpanDateFormat (Format); - Dat_PutScriptDateFormat (Format); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[Format]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Format] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Format); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each format... *****/ + for (Format = (Dat_Format_t) 0; + Format <= (Dat_Format_t) (Dat_NUM_OPTIONS_FORMAT - 1); + Format++) + { + /* Get number of users who have chosen this date format from database */ + if (asprintf (&SubQuery,"usr_data.DateFormat=%u", + (unsigned) Format) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[Format] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[Format]; + } + + /***** Write number of users who have chosen each date format *****/ + for (Format = (Dat_Format_t) 0; + Format <= (Dat_Format_t) (Dat_NUM_OPTIONS_FORMAT - 1); + Format++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"DAT_N LM\""); + Dat_PutSpanDateFormat (Format); + Dat_PutScriptDateFormat (Format); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[Format]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Format] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5535,59 +5488,57 @@ static void Fig_GetAndShowNumUsrsPerIconSet (void) NULL,NULL, Hlp_ANALYTICS_Figures_icons,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Icons); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each icon set... *****/ - for (IconSet = (Ico_IconSet_t) 0; - IconSet <= (Ico_IconSet_t) (Ico_NUM_ICON_SETS - 1); - IconSet++) - { - /* Get the number of users who have chosen this icon set from database */ - if (asprintf (&SubQuery,"usr_data.IconSet='%s'", - Ico_IconSetId[IconSet]) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[IconSet] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[IconSet]; - } - - /***** Write number of users who have chosen each icon set *****/ - for (IconSet = (Ico_IconSet_t) 0; - IconSet <= (Ico_IconSet_t) (Ico_NUM_ICON_SETS - 1); - IconSet++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"LM\""); - if (asprintf (&URL,"%s/%s", - Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[IconSet]) < 0) - Err_NotEnoughMemoryExit (); - HTM_IMG (URL,"cog.svg",Ico_IconSetNames[IconSet], - "class=\"ICO40x40\""); - free (URL); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[IconSet]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[IconSet] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Icons); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each icon set... *****/ + for (IconSet = (Ico_IconSet_t) 0; + IconSet <= (Ico_IconSet_t) (Ico_NUM_ICON_SETS - 1); + IconSet++) + { + /* Get the number of users who have chosen this icon set from database */ + if (asprintf (&SubQuery,"usr_data.IconSet='%s'", + Ico_IconSetId[IconSet]) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[IconSet] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[IconSet]; + } + + /***** Write number of users who have chosen each icon set *****/ + for (IconSet = (Ico_IconSet_t) 0; + IconSet <= (Ico_IconSet_t) (Ico_NUM_ICON_SETS - 1); + IconSet++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"LM\""); + if (asprintf (&URL,"%s/%s", + Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[IconSet]) < 0) + Err_NotEnoughMemoryExit (); + HTM_IMG (URL,"cog.svg",Ico_IconSetNames[IconSet], + "class=\"ICO40x40\""); + free (URL); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[IconSet]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[IconSet] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5616,54 +5567,52 @@ static void Fig_GetAndShowNumUsrsPerMenu (void) NULL,NULL, Hlp_ANALYTICS_Figures_menu,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Menu); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each menu... *****/ - for (Menu = (Mnu_Menu_t) 0; - Menu <= (Mnu_Menu_t) (Mnu_NUM_MENUS - 1); - Menu++) - { - /* Get number of users who have chosen this menu from database */ - if (asprintf (&SubQuery,"usr_data.Menu=%u", - (unsigned) Menu) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[Menu] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[Menu]; - } - - /***** Write number of users who have chosen each menu *****/ - for (Menu = (Mnu_Menu_t) 0; - Menu <= (Mnu_Menu_t) (Mnu_NUM_MENUS - 1); - Menu++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"CM\""); - Ico_PutIcon (Mnu_MenuIcons[Menu],Txt_MENU_NAMES[Menu],"ICO40x40"); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[Menu]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Menu] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Menu); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each menu... *****/ + for (Menu = (Mnu_Menu_t) 0; + Menu <= (Mnu_Menu_t) (Mnu_NUM_MENUS - 1); + Menu++) + { + /* Get number of users who have chosen this menu from database */ + if (asprintf (&SubQuery,"usr_data.Menu=%u", + (unsigned) Menu) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[Menu] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[Menu]; + } + + /***** Write number of users who have chosen each menu *****/ + for (Menu = (Mnu_Menu_t) 0; + Menu <= (Mnu_Menu_t) (Mnu_NUM_MENUS - 1); + Menu++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"CM\""); + Ico_PutIcon (Mnu_MenuIcons[Menu],Txt_MENU_NAMES[Menu],"ICO40x40"); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[Menu]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Menu] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5693,59 +5642,57 @@ static void Fig_GetAndShowNumUsrsPerTheme (void) NULL,NULL, Hlp_ANALYTICS_Figures_theme,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"LM",Txt_Theme_SKIN); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each theme... *****/ - for (Theme = (The_Theme_t) 0; - Theme <= (The_Theme_t) (The_NUM_THEMES - 1); - Theme++) - { - /* Get number of users who have chosen this theme from database */ - if (asprintf (&SubQuery,"usr_data.Theme='%s'", - The_ThemeId[Theme]) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[Theme] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[Theme]; - } - - /***** Write number of users who have chosen each theme *****/ - for (Theme = (The_Theme_t) 0; - Theme <= (The_Theme_t) (The_NUM_THEMES - 1); - Theme++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"CM\""); - if (asprintf (&URL,"%s/%s", - Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Theme]) < 0) - Err_NotEnoughMemoryExit (); - HTM_IMG (URL,"theme_32x20.gif",The_ThemeNames[Theme], - "style=\"width:40px;height:25px;\""); - free (URL); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[Theme]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Theme] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"LM",Txt_Theme_SKIN); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each theme... *****/ + for (Theme = (The_Theme_t) 0; + Theme <= (The_Theme_t) (The_NUM_THEMES - 1); + Theme++) + { + /* Get number of users who have chosen this theme from database */ + if (asprintf (&SubQuery,"usr_data.Theme='%s'", + The_ThemeId[Theme]) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[Theme] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[Theme]; + } + + /***** Write number of users who have chosen each theme *****/ + for (Theme = (The_Theme_t) 0; + Theme <= (The_Theme_t) (The_NUM_THEMES - 1); + Theme++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"CM\""); + if (asprintf (&URL,"%s/%s", + Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Theme]) < 0) + Err_NotEnoughMemoryExit (); + HTM_IMG (URL,"theme_32x20.gif",The_ThemeNames[Theme], + "style=\"width:40px;height:25px;\""); + free (URL); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[Theme]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[Theme] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -5774,163 +5721,58 @@ static void Fig_GetAndShowNumUsrsPerSideColumns (void) NULL,NULL, Hlp_ANALYTICS_Figures_columns,Box_NOT_CLOSABLE,2); - /***** Heading row *****/ - HTM_TR_Begin (NULL); - - HTM_TH (1,1,"CM",Txt_Columns); - HTM_TH (1,1,"RM",Txt_Number_of_users); - HTM_TH (1,1,"RM",Txt_PERCENT_of_users); - - HTM_TR_End (); - - /***** For each language... *****/ - for (SideCols = 0; - SideCols <= Lay_SHOW_BOTH_COLUMNS; - SideCols++) - { - /* Get the number of users who have chosen this layout of columns from database */ - if (asprintf (&SubQuery,"usr_data.SideCols=%u", - SideCols) < 0) - Err_NotEnoughMemoryExit (); - NumUsrs[SideCols] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery); - free (SubQuery); - - /* Update total number of users */ - NumUsrsTotal += NumUsrs[SideCols]; - } - - /***** Write number of users who have chosen this layout of columns *****/ - for (SideCols = 0; - SideCols <= Lay_SHOW_BOTH_COLUMNS; - SideCols++) - { + /***** Heading row *****/ HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"CM\""); - if (asprintf (&Icon,"layout%u%u_32x20.gif", - SideCols >> 1,SideCols & 1) < 0) - Err_NotEnoughMemoryExit (); - HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols], - "style=\"width:40px;height:25px;\""); - free (Icon); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Unsigned (NumUsrs[SideCols]); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT RM\""); - HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[SideCols] * 100.0 / - (double) NumUsrsTotal : - 0.0); - HTM_TD_End (); - + HTM_TH (1,1,"CM",Txt_Columns); + HTM_TH (1,1,"RM",Txt_Number_of_users); + HTM_TH (1,1,"RM",Txt_PERCENT_of_users); HTM_TR_End (); - } + + /***** For each language... *****/ + for (SideCols = 0; + SideCols <= Lay_SHOW_BOTH_COLUMNS; + SideCols++) + { + /* Get the number of users who have chosen this layout of columns from database */ + if (asprintf (&SubQuery,"usr_data.SideCols=%u", + SideCols) < 0) + Err_NotEnoughMemoryExit (); + NumUsrs[SideCols] = Usr_DB_GetNumUsrsWhoChoseAnOption (SubQuery); + free (SubQuery); + + /* Update total number of users */ + NumUsrsTotal += NumUsrs[SideCols]; + } + + /***** Write number of users who have chosen this layout of columns *****/ + for (SideCols = 0; + SideCols <= Lay_SHOW_BOTH_COLUMNS; + SideCols++) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"CM\""); + if (asprintf (&Icon,"layout%u%u_32x20.gif", + SideCols >> 1,SideCols & 1) < 0) + Err_NotEnoughMemoryExit (); + HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols], + "style=\"width:40px;height:25px;\""); + free (Icon); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Unsigned (NumUsrs[SideCols]); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT RM\""); + HTM_Percentage (NumUsrsTotal ? (double) NumUsrs[SideCols] * 100.0 / + (double) NumUsrsTotal : + 0.0); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table and box *****/ Box_BoxTableEnd (); } - -/*****************************************************************************/ -/************** Get number of users who have chosen an option ****************/ -/*****************************************************************************/ - -unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery) - { - unsigned NumUsrs; - - /***** Get the number of users who have chosen - this privacy option from database *****/ - switch (Gbl.Scope.Current) - { - case HieLvl_SYS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(*)" - " FROM usr_data WHERE %s", - SubQuery); - break; - case HieLvl_CTY: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(DISTINCT usr_data.UsrCod)" - " FROM ins_instits," - "ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_data" - " WHERE ins_instits.CtyCod=%ld" - " AND ins_instits.InsCod=ctr_centers.InsCod" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_data.UsrCod" - " AND %s", - Gbl.Hierarchy.Cty.CtyCod,SubQuery); - break; - case HieLvl_INS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(DISTINCT usr_data.UsrCod)" - " FROM ctr_centers," - "deg_degrees," - "crs_courses," - "crs_users," - "usr_data" - " WHERE ctr_centers.InsCod=%ld" - " AND ctr_centers.CtrCod=deg_degrees.CtrCod" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_data.UsrCod" - " AND %s", - Gbl.Hierarchy.Ins.InsCod,SubQuery); - break; - case HieLvl_CTR: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(DISTINCT usr_data.UsrCod)" - " FROM deg_degrees," - "crs_courses," - "crs_users," - "usr_data" - " WHERE deg_degrees.CtrCod=%ld" - " AND deg_degrees.DegCod=crs_courses.DegCod" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_data.UsrCod" - " AND %s", - Gbl.Hierarchy.Ctr.CtrCod,SubQuery); - break; - case HieLvl_DEG: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(DISTINCT usr_data.UsrCod)" - " FROM crs_courses," - "crs_users," - "usr_data" - " WHERE crs_courses.DegCod=%ld" - " AND crs_courses.CrsCod=crs_users.CrsCod" - " AND crs_users.UsrCod=usr_data.UsrCod" - " AND %s", - Gbl.Hierarchy.Deg.DegCod,SubQuery); - break; - case HieLvl_CRS: - NumUsrs = (unsigned) - DB_QueryCOUNT ("can not get the number of users who have chosen an option", - "SELECT COUNT(DISTINCT usr_data.UsrCod)" - " FROM crs_users," - "usr_data" - " WHERE crs_users.CrsCod=%ld" - " AND crs_users.UsrCod=usr_data.UsrCod" - " AND %s", - Gbl.Hierarchy.Crs.CrsCod,SubQuery); - break; - default: - Err_WrongScopeExit (); - NumUsrs = 0; // Not reached. Initialized to avoid warning. - break; - } - - return NumUsrs; - } diff --git a/swad_file_browser.c b/swad_file_browser.c index d650c9b8..32635a6f 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -60,6 +60,7 @@ #include "swad_profile.h" #include "swad_project.h" #include "swad_role.h" +#include "swad_setting.h" #include "swad_string.h" #include "swad_timeline.h" #include "swad_timeline_note.h" @@ -1291,7 +1292,6 @@ static void Brw_PutIconShowFigure (__attribute__((unused)) void *Args); static void Brw_PutButtonToShowEdit (void); static void Brw_WriteTopBeforeShowingFileBrowser (void); static void Brw_UpdateLastAccess (void); -static void Brw_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod); static void Brw_WriteSubtitleOfFileBrowser (void); static void Brw_InitHiddenLevels (void); static void Brw_ShowAndStoreSizeOfFileTree (void); @@ -1386,9 +1386,9 @@ static bool Brw_GetIfExpandedTree (const char Path[PATH_MAX + 1]); static long Brw_GetCodForExpandedFolders (void); static long Brw_GetWorksUsrCodForExpandedFolders (void); -static void Brw_RemoveExpiredClipboards (void); -static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, - long MyUsrCod,long WorksUsrCod); +static void Brw_DB_RemoveExpiredClipboards (void); +static void Brw_DB_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, + long MyUsrCod,long WorksUsrCod); static void Brw_PasteClipboard (void); static unsigned Brw_NumLevelsInPath (const char Path[PATH_MAX + 1]); static bool Brw_PasteTreeIntoFolder (unsigned Level, @@ -1415,7 +1415,7 @@ static void Brw_WriteSmallLinkToDownloadFile (const char *URL, static bool Brw_GetParamPublicFile (void); static Brw_License_t Brw_GetParLicense (void); static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata); -static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata); +static unsigned Brw_DB_GetFileViewsFromNonLoggedUsrs (long FilCod); static unsigned Brw_GetFileViewsFromMe (long FilCod); static void Brw_UpdateFileViews (unsigned NumViews,long FilCod); static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]); @@ -2863,8 +2863,8 @@ bool Brw_UpdateFoldersAssigmentsIfExistForAllUsrs (const char *OldFolderName,con else // Success { /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Brw_ADMI_ASG_USR,UsrCod,-1L); - Brw_RemoveAffectedClipboards (Brw_ADMI_ASG_CRS,-1L,UsrCod); + Brw_DB_RemoveAffectedClipboards (Brw_ADMI_ASG_USR,UsrCod,-1L); + Brw_DB_RemoveAffectedClipboards (Brw_ADMI_ASG_CRS,-1L,UsrCod); /* Rename affected expanded folders */ snprintf (OldPath,sizeof (OldPath),"%s/%s", @@ -3145,32 +3145,32 @@ static void Brw_ShowFileBrowserProject (void) NULL,NULL, Hlp_ASSESSMENT_Projects,Box_NOT_CLOSABLE); - /***** Show the project *****/ - Prj_ShowOneUniqueProject (&Prj); + /***** Show the project *****/ + Prj_ShowOneUniqueProject (&Prj); - /***** Show project file browsers *****/ - if (Brw_CheckIfICanViewProjectFiles (Prj.PrjCod)) - { - Brw_WriteTopBeforeShowingFileBrowser (); - - if (Brw_CheckIfICanViewProjectDocuments (Prj.PrjCod)) + /***** Show project file browsers *****/ + if (Brw_CheckIfICanViewProjectFiles (Prj.PrjCod)) { - /***** Show the tree with the project documents *****/ - Gbl.FileBrowser.Type = Brw_ADMI_DOC_PRJ; - Brw_InitializeFileBrowser (); - Brw_ShowFileBrowser (); - } + Brw_WriteTopBeforeShowingFileBrowser (); - if (Brw_CheckIfICanViewProjectAssessment (Prj.PrjCod)) - { - /***** Show the tree with the project assessment *****/ - Gbl.FileBrowser.Type = Brw_ADMI_ASS_PRJ; - Brw_InitializeFileBrowser (); - Brw_ShowFileBrowser (); + if (Brw_CheckIfICanViewProjectDocuments (Prj.PrjCod)) + { + /***** Show the tree with the project documents *****/ + Gbl.FileBrowser.Type = Brw_ADMI_DOC_PRJ; + Brw_InitializeFileBrowser (); + Brw_ShowFileBrowser (); + } + + if (Brw_CheckIfICanViewProjectAssessment (Prj.PrjCod)) + { + /***** Show the tree with the project assessment *****/ + Gbl.FileBrowser.Type = Brw_ADMI_ASS_PRJ; + Brw_InitializeFileBrowser (); + Brw_ShowFileBrowser (); + } } - } - else - Ale_ShowAlert (Ale_WARNING,"You have no access to project files."); + else + Ale_ShowAlert (Ale_WARNING,"You have no access to project files."); /***** End box *****/ Box_BoxEnd (); @@ -3201,41 +3201,43 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void) Brw_PutIconShowFigure,NULL, Hlp_FILES_Homework_for_teachers,Box_NOT_CLOSABLE,0); - /***** List the assignments and works of the selected users *****/ - Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; - while (*Ptr) - { - Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod, - Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); - Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); - if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat, - Usr_DONT_GET_PREFS, - Usr_GET_ROLE_IN_CURRENT_CRS)) - if (Usr_CheckIfICanViewAsgWrk (&Gbl.Usrs.Other.UsrDat)) - { - Gbl.Usrs.Other.UsrDat.Accepted = - Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); + /***** List the assignments and works of the selected users *****/ + Ptr = Gbl.Usrs.Selected.List[Rol_UNK]; + while (*Ptr) + { + Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EnUsrCod, + Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); + Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat, + Usr_DONT_GET_PREFS, + Usr_GET_ROLE_IN_CURRENT_CRS)) + if (Usr_CheckIfICanViewAsgWrk (&Gbl.Usrs.Other.UsrDat)) + { + Gbl.Usrs.Other.UsrDat.Accepted = + Usr_CheckIfUsrHasAcceptedInCurrentCrs (&Gbl.Usrs.Other.UsrDat); - /***** Show a row with the data of the owner of the works *****/ - HTM_TR_Begin (NULL); - Brw_ShowDataOwnerAsgWrk (&Gbl.Usrs.Other.UsrDat); + /***** Show a row with the data of the owner of the works *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LT\""); + Brw_ShowDataOwnerAsgWrk (&Gbl.Usrs.Other.UsrDat); - /***** Show the tree with the assignments *****/ - Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; - Brw_InitializeFileBrowser (); - Brw_ShowFileBrowser (); + HTM_TD_Begin ("class=\"LT\""); - /***** Show the tree with the works *****/ - Gbl.FileBrowser.Type = Brw_ADMI_WRK_CRS; - Brw_InitializeFileBrowser (); - Brw_ShowFileBrowser (); + /* Show the tree with the assignments */ + Gbl.FileBrowser.Type = Brw_ADMI_ASG_CRS; + Brw_InitializeFileBrowser (); + Brw_ShowFileBrowser (); - HTM_TD_End (); - HTM_TR_End (); - } - } + /* Show the tree with the works */ + Gbl.FileBrowser.Type = Brw_ADMI_WRK_CRS; + Brw_InitializeFileBrowser (); + Brw_ShowFileBrowser (); + + HTM_TD_End (); + + HTM_TR_End (); + } + } /***** End table and box *****/ Box_BoxTableEnd (); @@ -3292,58 +3294,59 @@ static void Brw_FormToChangeCrsGrpZone (void) Frm_BeginForm (Brw_ActChgZone[Gbl.FileBrowser.Type]); Brw_PutHiddenParamFullTreeIfSelected (&Gbl.FileBrowser.FullTree); - /***** List start *****/ - HTM_UL_Begin ("class=\"LIST_LEFT\""); + /***** List start *****/ + HTM_UL_Begin ("class=\"LIST_LEFT\""); - /***** Select the complete course, not a group *****/ - HTM_LI_Begin ("class=\"%s\"",IsCourseZone ? "BROWSER_TITLE" : - "BROWSER_TITLE_LIGHT"); - HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("GrpCod",true, - "value=\"-1\"%s", - IsCourseZone ? " checked=\"checked\"" : ""); - HTM_Txt (Gbl.Hierarchy.Crs.FullName); - HTM_LABEL_End (); - HTM_LI_End (); - - /***** List my groups for unique selection *****/ - if (Gbl.Crs.Grps.NumGrps) // This course has groups? - { - for (NumGrp = 0; - NumGrp < LstMyGrps.NumGrps; - NumGrp++) - { - /* Get next group */ - GrpDat.GrpCod = LstMyGrps.GrpCods[NumGrp]; - Grp_GetDataOfGroupByCod (&GrpDat); - - /* Select this group */ - HTM_LI_Begin ("class=\"%s\"", - (IsGroupZone && - GrpDat.GrpCod == Gbl.Crs.Grps.GrpCod) ? "BROWSER_TITLE" : - "BROWSER_TITLE_LIGHT"); - HTM_IMG (Cfg_URL_ICON_PUBLIC, - NumGrp < LstMyGrps.NumGrps - 1 ? "submid20x20.gif" : - "subend20x20.gif", - NULL, - "class=\"ICO25x25\" style=\"margin-left:6px;\""); - HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("GrpCod",true, - "value=\"%ld\"%s", - GrpDat.GrpCod, - (IsGroupZone && - GrpDat.GrpCod == Gbl.Crs.Grps.GrpCod) ? " checked=\"checked\"" : ""); - HTM_TxtF ("%s %s",GrpDat.GrpTypName,GrpDat.GrpName); - HTM_LABEL_End (); + /***** Select the complete course, not a group *****/ + HTM_LI_Begin ("class=\"%s\"",IsCourseZone ? "BROWSER_TITLE" : + "BROWSER_TITLE_LIGHT"); + HTM_LABEL_Begin (NULL); + HTM_INPUT_RADIO ("GrpCod",true, + "value=\"-1\"%s", + IsCourseZone ? " checked=\"checked\"" : ""); + HTM_Txt (Gbl.Hierarchy.Crs.FullName); + HTM_LABEL_End (); HTM_LI_End (); - } - /***** Free memory with the list of groups I belong to *****/ - Grp_FreeListCodGrp (&LstMyGrps); - } + /***** List my groups for unique selection *****/ + if (Gbl.Crs.Grps.NumGrps) // This course has groups? + { + for (NumGrp = 0; + NumGrp < LstMyGrps.NumGrps; + NumGrp++) + { + /* Get next group */ + GrpDat.GrpCod = LstMyGrps.GrpCods[NumGrp]; + Grp_GetDataOfGroupByCod (&GrpDat); - /***** End list and form *****/ - HTM_UL_End (); + /* Select this group */ + HTM_LI_Begin ("class=\"%s\"", + (IsGroupZone && + GrpDat.GrpCod == Gbl.Crs.Grps.GrpCod) ? "BROWSER_TITLE" : + "BROWSER_TITLE_LIGHT"); + HTM_IMG (Cfg_URL_ICON_PUBLIC, + NumGrp < LstMyGrps.NumGrps - 1 ? "submid20x20.gif" : + "subend20x20.gif", + NULL, + "class=\"ICO25x25\" style=\"margin-left:6px;\""); + HTM_LABEL_Begin (NULL); + HTM_INPUT_RADIO ("GrpCod",true, + "value=\"%ld\"%s", + GrpDat.GrpCod, + (IsGroupZone && + GrpDat.GrpCod == Gbl.Crs.Grps.GrpCod) ? " checked=\"checked\"" : + ""); + HTM_TxtF ("%s %s",GrpDat.GrpTypName,GrpDat.GrpName); + HTM_LABEL_End (); + HTM_LI_End (); + } + + /***** Free memory with the list of groups I belong to *****/ + Grp_FreeListCodGrp (&LstMyGrps); + } + + /***** End list and form *****/ + HTM_UL_End (); Frm_EndForm (); } @@ -3677,39 +3680,41 @@ static void Brw_ShowFileBrowser (void) snprintf (FileBrowserSectionId,sizeof (FileBrowserSectionId), "file_browser_%u",Gbl.FileBrowser.Id); HTM_SECTION_Begin (FileBrowserSectionId); - Box_BoxBegin ("100%",Brw_TitleOfFileBrowser[Gbl.FileBrowser.Type], - Brw_PutIconsFileBrowser,NULL, - Brw_HelpOfFileBrowser[Gbl.FileBrowser.Type],Box_NOT_CLOSABLE); - /***** Subtitle *****/ - Brw_WriteSubtitleOfFileBrowser (); + Box_BoxBegin ("100%",Brw_TitleOfFileBrowser[Gbl.FileBrowser.Type], + Brw_PutIconsFileBrowser,NULL, + Brw_HelpOfFileBrowser[Gbl.FileBrowser.Type],Box_NOT_CLOSABLE); - /***** List recursively the directory *****/ - HTM_TABLE_Begin ("BROWSER_TABLE"); - Str_Copy (Gbl.FileBrowser.FilFolLnk.Path, - Brw_RootFolderInternalNames[Gbl.FileBrowser.Type], - sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1); - Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".", - sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1); - Brw_SetFullPathInTree (); - Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER; - if (Brw_WriteRowFileBrowser (0,"1", - false, // Tree not contracted - Brw_ICON_TREE_NOTHING)) - Brw_ListDir (1,"1", - false, // Tree not contracted - Gbl.FileBrowser.Priv.PathRootFolder, - Brw_RootFolderInternalNames[Gbl.FileBrowser.Type]); - HTM_TABLE_End (); + /***** Subtitle *****/ + Brw_WriteSubtitleOfFileBrowser (); - /***** Show and store number of documents found *****/ - Brw_ShowAndStoreSizeOfFileTree (); + /***** List recursively the directory *****/ + HTM_TABLE_Begin ("BROWSER_TABLE"); + Str_Copy (Gbl.FileBrowser.FilFolLnk.Path, + Brw_RootFolderInternalNames[Gbl.FileBrowser.Type], + sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1); + Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".", + sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1); + Brw_SetFullPathInTree (); + Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER; + if (Brw_WriteRowFileBrowser (0,"1", + false, // Tree not contracted + Brw_ICON_TREE_NOTHING)) + Brw_ListDir (1,"1", + false, // Tree not contracted + Gbl.FileBrowser.Priv.PathRootFolder, + Brw_RootFolderInternalNames[Gbl.FileBrowser.Type]); + HTM_TABLE_End (); - /***** Put button to show / edit *****/ - Brw_PutButtonToShowEdit (); + /***** Show and store number of documents found *****/ + Brw_ShowAndStoreSizeOfFileTree (); + + /***** Put button to show / edit *****/ + Brw_PutButtonToShowEdit (); + + /***** End box *****/ + Box_BoxEnd (); - /***** End box *****/ - Box_BoxEnd (); HTM_SECTION_End (); } @@ -3772,7 +3777,7 @@ static void Brw_PutButtonToShowEdit (void) { Frm_BeginForm (Brw_ActFromAdmToSee[Gbl.FileBrowser.Type]); Brw_PutHiddenParamFullTreeIfSelected (&Gbl.FileBrowser.FullTree); - Btn_PutConfirmButton (Txt_View); + Btn_PutConfirmButton (Txt_View); Frm_EndForm (); } break; @@ -3781,7 +3786,7 @@ static void Brw_PutButtonToShowEdit (void) { Frm_BeginForm (Brw_ActFromSeeToAdm[Gbl.FileBrowser.Type]); Brw_PutHiddenParamFullTreeIfSelected (&Gbl.FileBrowser.FullTree); - Btn_PutConfirmButton (Txt_Edit); + Btn_PutConfirmButton (Txt_Edit); Frm_EndForm (); } break; @@ -3799,18 +3804,18 @@ static void Brw_WriteTopBeforeShowingFileBrowser (void) /***** Contextual menu *****/ Mnu_ContextMenuBegin (); - Brw_PutCheckboxFullTree (); // Checkbox to show the full tree - if (Brw_GetIfBriefcaseFileBrowser ()) - { - if (Gbl.Action.Act != ActReqRemOldBrf) - Brw_PutLinkToAskRemOldFiles (); // Remove old files - } - else if (Brw_GetIfCrsAssigWorksFileBrowser ()) - { - if (!Gbl.FileBrowser.ZIP.CreateZIP) - ZIP_PutLinkToCreateZIPAsgWrk (); // Create a zip file with the - // works of the selected users - } + Brw_PutCheckboxFullTree (); // Checkbox to show the full tree + if (Brw_GetIfBriefcaseFileBrowser ()) + { + if (Gbl.Action.Act != ActReqRemOldBrf) + Brw_PutLinkToAskRemOldFiles (); // Remove old files + } + else if (Brw_GetIfCrsAssigWorksFileBrowser ()) + { + if (!Gbl.FileBrowser.ZIP.CreateZIP) + ZIP_PutLinkToCreateZIPAsgWrk (); // Create a zip file with the + // works of the selected users + } Mnu_ContextMenuEnd (); /***** Initialize hidden levels *****/ @@ -3858,7 +3863,7 @@ static void Brw_UpdateLastAccess (void) if (Gbl.Action.Act == ActChgToSeeDocCrs || Gbl.Action.Act == ActChgToAdmDocCrs || Gbl.Action.Act == ActChgToAdmTch) // Update group of last access to a documents/teachers zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastDowGrpCod",-1L); + Set_DB_UpdateGrpLastAccZone ("LastDowGrpCod",-1L); break; case Brw_SHOW_DOC_GRP: case Brw_ADMI_DOC_GRP: @@ -3866,50 +3871,33 @@ static void Brw_UpdateLastAccess (void) if (Gbl.Action.Act == ActChgToSeeDocCrs || Gbl.Action.Act == ActChgToAdmDocCrs || Gbl.Action.Act == ActChgToAdmTch) // Update group of last access to a documents/teachers zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastDowGrpCod",Gbl.Crs.Grps.GrpCod); + Set_DB_UpdateGrpLastAccZone ("LastDowGrpCod",Gbl.Crs.Grps.GrpCod); break; case Brw_ADMI_SHR_CRS: if (Gbl.Action.Act == ActChgToAdmSha) // Update group of last access to a shared files zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastComGrpCod",-1L); + Set_DB_UpdateGrpLastAccZone ("LastComGrpCod",-1L); break; case Brw_ADMI_SHR_GRP: if (Gbl.Action.Act == ActChgToAdmSha) // Update group of last access to a shared files zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastComGrpCod",Gbl.Crs.Grps.GrpCod); + Set_DB_UpdateGrpLastAccZone ("LastComGrpCod",Gbl.Crs.Grps.GrpCod); break; case Brw_SHOW_MRK_CRS: case Brw_ADMI_MRK_CRS: if (Gbl.Action.Act == ActChgToSeeMrk || Gbl.Action.Act == ActChgToAdmMrk) // Update group of last access to a marks zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastAssGrpCod",-1L); + Set_DB_UpdateGrpLastAccZone ("LastAssGrpCod",-1L); break; case Brw_SHOW_MRK_GRP: case Brw_ADMI_MRK_GRP: if (Gbl.Action.Act == ActChgToSeeMrk || Gbl.Action.Act == ActChgToAdmMrk) // Update group of last access to a marks zone only when user changes zone - Brw_UpdateGrpLastAccZone ("LastAssGrpCod",Gbl.Crs.Grps.GrpCod); + Set_DB_UpdateGrpLastAccZone ("LastAssGrpCod",Gbl.Crs.Grps.GrpCod); break; default: break; } } -/*****************************************************************************/ -/*********** Update the group of my last access to a common zone *************/ -/*****************************************************************************/ - -static void Brw_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod) - { - /***** Update the group of my last access to a common zone *****/ - DB_QueryUPDATE ("can not update the group of the last access to a file browser", - "UPDATE crs_user_settings" - " SET %s=%ld" - " WHERE UsrCod=%ld" - " AND CrsCod=%ld", - FieldNameDB,GrpCod, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Hierarchy.Crs.CrsCod); - } - /*****************************************************************************/ /*********************** Write title of a file browser ***********************/ /*****************************************************************************/ @@ -4076,7 +4064,7 @@ static void Brw_WriteSubtitleOfFileBrowser (void) if (Subtitle[0]) { HTM_DIV_Begin ("class=\"BROWSER_SUBTITLE\""); - HTM_Txt (Subtitle); + HTM_Txt (Subtitle); HTM_DIV_End (); } } @@ -4112,35 +4100,35 @@ static void Brw_ShowAndStoreSizeOfFileTree (void) HTM_DIV_Begin ("class=\"DAT CM\""); - if (Brw_FileBrowserIsEditable[Gbl.FileBrowser.Type]) - { - Fil_WriteFileSizeFull ((double) Gbl.FileBrowser.Size.TotalSiz,FileSizeStr); - HTM_TxtF ("%u %s; %lu %s; %lu %s; %s", - Gbl.FileBrowser.Size.NumLevls, - Gbl.FileBrowser.Size.NumLevls == 1 ? Txt_level : - Txt_levels , - Gbl.FileBrowser.Size.NumFolds, - Gbl.FileBrowser.Size.NumFolds == 1 ? Txt_folder : - Txt_folders, - Gbl.FileBrowser.Size.NumFiles, - Gbl.FileBrowser.Size.NumFiles == 1 ? Txt_file : - Txt_files, - FileSizeStr); - - if (Gbl.FileBrowser.Size.MaxQuota) + if (Brw_FileBrowserIsEditable[Gbl.FileBrowser.Type]) { - Fil_WriteFileSizeBrief ((double) Gbl.FileBrowser.Size.MaxQuota,FileSizeStr); - HTM_TxtF (" (%.1f%% %s %s)", - 100.0 * ((double) Gbl.FileBrowser.Size.TotalSiz / - (double) Gbl.FileBrowser.Size.MaxQuota), - Txt_of_PART_OF_A_TOTAL, + Fil_WriteFileSizeFull ((double) Gbl.FileBrowser.Size.TotalSiz,FileSizeStr); + HTM_TxtF ("%u %s; %lu %s; %lu %s; %s", + Gbl.FileBrowser.Size.NumLevls, + Gbl.FileBrowser.Size.NumLevls == 1 ? Txt_level : + Txt_levels , + Gbl.FileBrowser.Size.NumFolds, + Gbl.FileBrowser.Size.NumFolds == 1 ? Txt_folder : + Txt_folders, + Gbl.FileBrowser.Size.NumFiles, + Gbl.FileBrowser.Size.NumFiles == 1 ? Txt_file : + Txt_files, FileSizeStr); - } - Brw_StoreSizeOfFileTreeInDB (); - } - else - HTM_NBSP (); // Blank to occupy the same space as the text for the browser size + if (Gbl.FileBrowser.Size.MaxQuota) + { + Fil_WriteFileSizeBrief ((double) Gbl.FileBrowser.Size.MaxQuota,FileSizeStr); + HTM_TxtF (" (%.1f%% %s %s)", + 100.0 * ((double) Gbl.FileBrowser.Size.TotalSiz / + (double) Gbl.FileBrowser.Size.MaxQuota), + Txt_of_PART_OF_A_TOTAL, + FileSizeStr); + } + + Brw_StoreSizeOfFileTreeInDB (); + } + else + HTM_NBSP (); // Blank to occupy the same space as the text for the browser size HTM_DIV_End (); } @@ -5300,7 +5288,7 @@ static long Brw_GetGrpLastAccZone (const char *FieldNameDB) /***** Check if group exists (it's possible that this group has been removed after my last access to it) *****/ if (GrpCod >= 0) - if (Grp_CheckIfGroupExists (GrpCod)) + if (Grp_DB_CheckIfGroupExists (GrpCod)) /* Check if I belong to this group (it's possible that I have been removed from this group after my last access to it) */ if (Grp_GetIfIBelongToGrp (GrpCod)) return GrpCod; @@ -5653,44 +5641,45 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,const char *RowId, } /***** Indentation depending on level, icon, and file/folder name *****/ - /* Start column */ + /* Begin column */ HTM_TD_Begin ("class=\"NO_BR LM COLOR%u\" style=\"width:99%%;\"",Gbl.RowEvenOdd); - HTM_TABLE_Begin (NULL); - HTM_TR_Begin (NULL); + HTM_TABLE_Begin (NULL); + HTM_TR_Begin (NULL); - /* Indent depending on level */ - if (Level) - Brw_IndentAndWriteIconExpandContract (Level,FileBrowserId,RowId,IconThisRow); + /* Indent depending on level */ + if (Level) + Brw_IndentAndWriteIconExpandContract (Level,FileBrowserId,RowId,IconThisRow); - /* Put icon to show/hide file or folder */ - if (AdminDocsZone || AdminMarks) - { - if (RowSetAsHidden) // this row is marked as hidden - Brw_PutIconShow (Anchor); - else // this row is not marked as hidden - Brw_PutIconHide (Anchor); - } + /* Put icon to show/hide file or folder */ + if (AdminDocsZone || AdminMarks) + { + if (RowSetAsHidden) // this row is marked as hidden + Brw_PutIconShow (Anchor); + else // this row is not marked as hidden + Brw_PutIconHide (Anchor); + } - /***** File or folder icon *****/ - if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER) - /* Icon with folder */ - Brw_PutIconFolder (Level,FileBrowserId,RowId,IconThisRow); - else // File or link - /* Icon with file type or link */ - Brw_PutIconFileWithLinkToViewMetadata (&FileMetadata); + /***** File or folder icon *****/ + if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER) + /* Icon with folder */ + Brw_PutIconFolder (Level,FileBrowserId,RowId,IconThisRow); + else // File or link + /* Icon with file type or link */ + Brw_PutIconFileWithLinkToViewMetadata (&FileMetadata); - /* Check if is a new file or folder */ - // If our last access was before the last modify ==> indicate the file is new by putting a blinking star - if (Gbl.Usrs.Me.TimeLastAccToThisFileBrowser < FileMetadata.Time) - Brw_PutIconNewFileOrFolder (); + /* Check if is a new file or folder */ + // If our last access was before the last modify ==> indicate the file is new by putting a blinking star + if (Gbl.Usrs.Me.TimeLastAccToThisFileBrowser < FileMetadata.Time) + Brw_PutIconNewFileOrFolder (); - /* File or folder name */ - Brw_WriteFileName (Level,FileMetadata.IsPublic); + /* File or folder name */ + Brw_WriteFileName (Level,FileMetadata.IsPublic); + + HTM_TR_End (); + HTM_TABLE_End (); /* End column */ - HTM_TR_End (); - HTM_TABLE_End (); HTM_TD_End (); if (AdminMarks) @@ -5708,10 +5697,10 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,const char *RowId, { /***** Put icon to download ZIP of folder *****/ HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - if (Gbl.Usrs.Me.Role.Logged >= Rol_STD && // Only ZIP folders if I am student, teacher... - !SeeMarks && // Do not ZIP folders when seeing marks - !(SeeDocsZone && RowSetAsHidden)) // When seeing docs, if folder is not hidden (this could happen for Level == 0) - Brw_PutButtonToDownloadZIPOfAFolder (); + if (Gbl.Usrs.Me.Role.Logged >= Rol_STD && // Only ZIP folders if I am student, teacher... + !SeeMarks && // Do not ZIP folders when seeing marks + !(SeeDocsZone && RowSetAsHidden)) // When seeing docs, if folder is not hidden (this could happen for Level == 0) + Brw_PutButtonToDownloadZIPOfAFolder (); HTM_TD_End (); } else // File or link @@ -5804,25 +5793,25 @@ static void Brw_PutIconRemove (void) { HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - if (Brw_GetIfICanEditFileOrFolder ()) // Can I remove this? - switch (Gbl.FileBrowser.FilFolLnk.Type) - { - case Brw_IS_FILE: - case Brw_IS_LINK: - /***** Form to remove a file or link *****/ - Ico_PutContextualIconToRemove (Brw_ActAskRemoveFile[Gbl.FileBrowser.Type],NULL, - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); - break; - case Brw_IS_FOLDER: - /***** Form to remove a folder *****/ - Ico_PutContextualIconToRemove (Brw_ActRemoveFolder[Gbl.FileBrowser.Type],NULL, - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); - break; - default: - break; - } - else - Ico_PutIconRemovalNotAllowed (); + if (Brw_GetIfICanEditFileOrFolder ()) // Can I remove this? + switch (Gbl.FileBrowser.FilFolLnk.Type) + { + case Brw_IS_FILE: + case Brw_IS_LINK: + /***** Form to remove a file or link *****/ + Ico_PutContextualIconToRemove (Brw_ActAskRemoveFile[Gbl.FileBrowser.Type],NULL, + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + break; + case Brw_IS_FOLDER: + /***** Form to remove a folder *****/ + Ico_PutContextualIconToRemove (Brw_ActRemoveFolder[Gbl.FileBrowser.Type],NULL, + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + break; + default: + break; + } + else + Ico_PutIconRemovalNotAllowed (); HTM_TD_End (); } @@ -5835,9 +5824,9 @@ static void Brw_PutIconCopy (void) { HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - /***** Form to copy into the clipboard *****/ - Ico_PutContextualIconToCopy (Brw_ActCopy[Gbl.FileBrowser.Type], - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + /***** Form to copy into the clipboard *****/ + Ico_PutContextualIconToCopy (Brw_ActCopy[Gbl.FileBrowser.Type], + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); HTM_TD_End (); } @@ -5852,19 +5841,19 @@ static void Brw_PutIconPaste (unsigned Level) HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER) // Can't paste in a file or link - { - /* Icon to paste */ - if (Brw_CheckIfCanPasteIn (Level)) + if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER) // Can't paste in a file or link { - /***** Form to paste the content of the clipboard *****/ - Ico_PutContextualIconToPaste (Brw_ActPaste[Gbl.FileBrowser.Type], - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + /* Icon to paste */ + if (Brw_CheckIfCanPasteIn (Level)) + { + /***** Form to paste the content of the clipboard *****/ + Ico_PutContextualIconToPaste (Brw_ActPaste[Gbl.FileBrowser.Type], + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + } + else + /* Icon to paste inactive */ + Ico_PutIconOff ("paste.svg",Txt_Copy_not_allowed); } - else - /* Icon to paste inactive */ - Ico_PutIconOff ("paste.svg",Txt_Copy_not_allowed); - } HTM_TD_End (); } @@ -5878,40 +5867,40 @@ static void Brw_IndentAndWriteIconExpandContract (unsigned Level, Brw_IconTree_t IconThisRow) { HTM_TD_Begin ("class=\"LM\""); - HTM_TABLE_Begin (NULL); - HTM_TR_Begin (NULL); - Brw_IndentDependingOnLevel (Level); + HTM_TABLE_Begin (NULL); + HTM_TR_Begin (NULL); + Brw_IndentDependingOnLevel (Level); - /***** Icon to expand/contract *****/ - HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - switch (IconThisRow) - { - case Brw_ICON_TREE_NOTHING: - Ico_PutIcon ("tr16x16.gif","","ICO20x20"); - break; - case Brw_ICON_TREE_EXPAND: - /***** Visible icon to expand folder *****/ - Brw_PutIconToExpandFolder (FileBrowserId,RowId, - false); // Visible + /***** Icon to expand/contract *****/ + HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); + switch (IconThisRow) + { + case Brw_ICON_TREE_NOTHING: + Ico_PutIcon ("tr16x16.gif","","ICO20x20"); + break; + case Brw_ICON_TREE_EXPAND: + /***** Visible icon to expand folder *****/ + Brw_PutIconToExpandFolder (FileBrowserId,RowId, + false); // Visible - /***** Hidden icon to contract folder *****/ - Brw_PutIconToContractFolder (FileBrowserId,RowId, - true); // Hidden - break; - case Brw_ICON_TREE_CONTRACT: - /***** Hidden icon to expand folder *****/ - Brw_PutIconToExpandFolder (FileBrowserId,RowId, - true); // Hidden + /***** Hidden icon to contract folder *****/ + Brw_PutIconToContractFolder (FileBrowserId,RowId, + true); // Hidden + break; + case Brw_ICON_TREE_CONTRACT: + /***** Hidden icon to expand folder *****/ + Brw_PutIconToExpandFolder (FileBrowserId,RowId, + true); // Hidden - /***** Visible icon to contract folder *****/ - Brw_PutIconToContractFolder (FileBrowserId,RowId, - false); // Visible - break; - } - HTM_TD_End (); + /***** Visible icon to contract folder *****/ + Brw_PutIconToContractFolder (FileBrowserId,RowId, + false); // Visible + break; + } + HTM_TD_End (); - HTM_TR_End (); - HTM_TABLE_End (); + HTM_TR_End (); + HTM_TABLE_End (); HTM_TD_End (); } @@ -5928,7 +5917,7 @@ static void Brw_IndentDependingOnLevel (unsigned Level) i++) { HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - Ico_PutIcon ("tr16x16.gif","","ICO20x20"); + Ico_PutIcon ("tr16x16.gif","","ICO20x20"); HTM_TD_End (); } } @@ -5957,7 +5946,7 @@ static void Brw_PutIconToExpandFolder (const char *FileBrowserId,const char *Row FileBrowserId, JavaScriptFuncToExpandFolder); // JavaScript function to unhide rows Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - Ico_PutIconLink ("caret-right.svg",Txt_Expand); + Ico_PutIconLink ("caret-right.svg",Txt_Expand); Frm_EndForm (); /***** End container *****/ @@ -5988,7 +5977,7 @@ static void Brw_PutIconToContractFolder (const char *FileBrowserId,const char *R FileBrowserId, JavaScriptFuncToContractFolder); // JavaScript function to hide rows Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - Ico_PutIconLink ("caret-down.svg",Txt_Contract); + Ico_PutIconLink ("caret-down.svg",Txt_Contract); Frm_EndForm (); /***** End container *****/ @@ -6002,8 +5991,8 @@ static void Brw_PutIconToContractFolder (const char *FileBrowserId,const char *R static void Brw_PutIconShow (const char *Anchor) { HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - Ico_PutContextualIconToUnhide (Brw_ActShow[Gbl.FileBrowser.Type],Anchor, - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + Ico_PutContextualIconToUnhide (Brw_ActShow[Gbl.FileBrowser.Type],Anchor, + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); HTM_TD_End (); } @@ -6014,8 +6003,8 @@ static void Brw_PutIconShow (const char *Anchor) static void Brw_PutIconHide (const char *Anchor) { HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - Ico_PutContextualIconToHide (Brw_ActHide[Gbl.FileBrowser.Type],Anchor, - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); + Ico_PutContextualIconToHide (Brw_ActHide[Gbl.FileBrowser.Type],Anchor, + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk); HTM_TD_End (); } @@ -6046,64 +6035,64 @@ static void Brw_PutIconFolder (unsigned Level, { bool ICanCreate; - /***** Start cell *****/ + /***** Begin cell *****/ HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - /***** Put icon to create a new file or folder *****/ - if ((ICanCreate = Brw_CheckIfICanCreateIntoFolder (Level))) // I can create a new file or folder - { - if (IconSubtree == Brw_ICON_TREE_EXPAND) + /***** Put icon to create a new file or folder *****/ + if ((ICanCreate = Brw_CheckIfICanCreateIntoFolder (Level))) // I can create a new file or folder { - /***** Visible icon with folder closed *****/ - Brw_PutIconFolderWithPlus (FileBrowserId,RowId, - false, // Closed - false); // Visible + if (IconSubtree == Brw_ICON_TREE_EXPAND) + { + /***** Visible icon with folder closed *****/ + Brw_PutIconFolderWithPlus (FileBrowserId,RowId, + false, // Closed + false); // Visible - /***** Hidden icon with folder open *****/ - Brw_PutIconFolderWithPlus (FileBrowserId,RowId, - true, // Open - true); // Hidden + /***** Hidden icon with folder open *****/ + Brw_PutIconFolderWithPlus (FileBrowserId,RowId, + true, // Open + true); // Hidden + } + else + { + /***** Hidden icon with folder closed *****/ + Brw_PutIconFolderWithPlus (FileBrowserId,RowId, + false, // Closed + true); // Hidden + + /***** Visible icon with folder open *****/ + Brw_PutIconFolderWithPlus (FileBrowserId,RowId, + true, // Open + false); // Visible + } } - else + else // I can't create a new file or folder { - /***** Hidden icon with folder closed *****/ - Brw_PutIconFolderWithPlus (FileBrowserId,RowId, - false, // Closed - true); // Hidden + if (IconSubtree == Brw_ICON_TREE_EXPAND) + { + /***** Visible icon with folder closed *****/ + Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, + false, // Closed + false); // Visible - /***** Visible icon with folder open *****/ - Brw_PutIconFolderWithPlus (FileBrowserId,RowId, - true, // Open - false); // Visible - } - } - else // I can't create a new file or folder - { - if (IconSubtree == Brw_ICON_TREE_EXPAND) - { - /***** Visible icon with folder closed *****/ - Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, - false, // Closed - false); // Visible + /***** Hidden icon with folder open *****/ + Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, + true, // Open + true); // Hidden + } + else + { + /***** Hidden icon with folder closed *****/ + Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, + false, // Closed + true); // Hidden - /***** Hidden icon with folder open *****/ - Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, - true, // Open - true); // Hidden + /***** Visible icon with folder open *****/ + Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, + true, // Open + false); // Visible + } } - else - { - /***** Hidden icon with folder closed *****/ - Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, - false, // Closed - true); // Hidden - - /***** Visible icon with folder open *****/ - Brw_PutIconFolderWithoutPlus (FileBrowserId,RowId, - true, // Open - false); // Visible - } - } /***** End cell *****/ HTM_TD_End (); @@ -6119,21 +6108,16 @@ static void Brw_PutIconFolderWithoutPlus (const char *FileBrowserId,const char * extern const char *Txt_Folder; /***** Begin container *****/ - if (Hidden) - HTM_DIV_Begin ("id=\"folder_%s_%s_%s\" style=\"display:none;\"", - Open ? "open" : - "closed", - FileBrowserId,RowId); - else - HTM_DIV_Begin ("id=\"folder_%s_%s_%s\"", - Open ? "open" : - "closed", - FileBrowserId,RowId); + HTM_DIV_Begin (Hidden ? "id=\"folder_%s_%s_%s\" style=\"display:none;\"" : + "id=\"folder_%s_%s_%s\"", + Open ? "open" : + "closed", + FileBrowserId,RowId); - /***** Icon *****/ - Ico_PutIcon (Open ? "folder-open-yellow.png" : - "folder-yellow.png", - Txt_Folder,"CONTEXT_OPT CONTEXT_ICO_16x16"); + /***** Icon *****/ + Ico_PutIcon (Open ? "folder-open-yellow.png" : + "folder-yellow.png", + Txt_Folder,"CONTEXT_OPT CONTEXT_ICO_16x16"); /***** End container *****/ HTM_DIV_End (); @@ -6147,21 +6131,16 @@ static void Brw_PutIconFolderWithPlus (const char *FileBrowserId,const char *Row bool Open,bool Hidden) { /***** Begin container *****/ - if (Hidden) - HTM_DIV_Begin ("id=\"folder_%s_%s_%s\" style=\"display:none;\"", - Open ? "open" : - "closed", - FileBrowserId,RowId); - else - HTM_DIV_Begin ("id=\"folder_%s_%s_%s\"", - Open ? "open" : - "closed", - FileBrowserId,RowId); + HTM_DIV_Begin (Hidden ? "id=\"folder_%s_%s_%s\" style=\"display:none;\"" : + "id=\"folder_%s_%s_%s\"", + Open ? "open" : + "closed", + FileBrowserId,RowId); - /***** Form and icon *****/ - Ico_PutContextualIconToCreateInFolder (Brw_ActFormCreate[Gbl.FileBrowser.Type], - Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk, - Open); + /***** Form and icon *****/ + Ico_PutContextualIconToCreateInFolder (Brw_ActFormCreate[Gbl.FileBrowser.Type], + Brw_PutImplicitParamsFileBrowser,&Gbl.FileBrowser.FilFolLnk, + Open); /***** End container *****/ HTM_DIV_End (); @@ -6177,7 +6156,7 @@ static void Brw_PutIconNewFileOrFolder (void) /***** Icon that indicates new file *****/ HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - Ico_PutIcon ("star16x16.gif",Txt_New_FILE_OR_FOLDER,"ICO20x20"); + Ico_PutIcon ("star16x16.gif",Txt_New_FILE_OR_FOLDER,"ICO20x20"); HTM_TD_End (); } @@ -6191,19 +6170,19 @@ static void Brw_PutIconFileWithLinkToViewMetadata (struct FileMetadata *FileMeta /***** Start cell *****/ HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - /***** Begin form *****/ - Frm_BeginForm (Brw_ActReqDatFile[Gbl.FileBrowser.Type]); - Brw_PutParamsFileBrowser (NULL, // Not used - NULL, // Not used - Brw_IS_UNKNOWN, // Not used - FileMetadata->FilCod); + /***** Begin form *****/ + Frm_BeginForm (Brw_ActReqDatFile[Gbl.FileBrowser.Type]); + Brw_PutParamsFileBrowser (NULL, // Not used + NULL, // Not used + Brw_IS_UNKNOWN, // Not used + FileMetadata->FilCod); - /***** Icon depending on the file extension *****/ - Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, - "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO_16x16",true); + /***** Icon depending on the file extension *****/ + Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, + "CONTEXT_OPT ICO_HIGHLIGHT CONTEXT_ICO_16x16",true); - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); /***** End cell *****/ HTM_TD_End (); @@ -6308,85 +6287,82 @@ static void Brw_WriteFileName (unsigned Level,bool IsPublic) ICanEditFileOrFolder = Brw_GetIfICanEditFileOrFolder (); /***** Start cell *****/ - if (Gbl.FileBrowser.Clipboard.IsThisFile) - HTM_TD_Begin ("class=\"%s LM LIGHT_GREEN\" style=\"width:99%%;\"", - Gbl.FileBrowser.TxtStyle); - else - HTM_TD_Begin ("class=\"%s LM\" style=\"width:99%%;\"", - Gbl.FileBrowser.TxtStyle); + HTM_TD_Begin (Gbl.FileBrowser.Clipboard.IsThisFile ? "class=\"%s LM LIGHT_GREEN\" style=\"width:99%%;\"" : + "class=\"%s LM\" style=\"width:99%%;\"", + Gbl.FileBrowser.TxtStyle); - HTM_DIV_Begin ("class=\"FILENAME\""); + HTM_DIV_Begin ("class=\"FILENAME\""); - /***** Form to rename folder *****/ - if (ICanEditFileOrFolder) // Can I rename this folder? - { - Frm_BeginForm (Brw_ActRenameFolder[Gbl.FileBrowser.Type]); - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - } + /***** Form to rename folder *****/ + if (ICanEditFileOrFolder) // Can I rename this folder? + { + Frm_BeginForm (Brw_ActRenameFolder[Gbl.FileBrowser.Type]); + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); + } - /***** Write name of the folder *****/ - HTM_NBSP (); - if (ICanEditFileOrFolder) // Can I rename this folder? - { - HTM_INPUT_TEXT ("NewFolderName",Brw_MAX_CHARS_FOLDER,Gbl.FileBrowser.FilFolLnk.Name, - HTM_SUBMIT_ON_CHANGE, - "class=\"%s %s\"", - Gbl.FileBrowser.InputStyle, - Gbl.FileBrowser.Clipboard.IsThisFile ? "LIGHT_GREEN" : - Gbl.ColorRows[Gbl.RowEvenOdd]); - Frm_EndForm (); - } - else - { - if ((Level == 1) && - (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || - Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) - HTM_SPAN_Begin ("title=\"%s\"",Gbl.FileBrowser.Asg.Title); - HTM_STRONG_Begin (); - HTM_Txt (FileNameToShow); - HTM_STRONG_End (); - HTM_NBSP (); - if ((Level == 1) && - (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || - Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) - HTM_SPAN_End (); - } + /***** Write name of the folder *****/ + HTM_NBSP (); + if (ICanEditFileOrFolder) // Can I rename this folder? + { + HTM_INPUT_TEXT ("NewFolderName",Brw_MAX_CHARS_FOLDER,Gbl.FileBrowser.FilFolLnk.Name, + HTM_SUBMIT_ON_CHANGE, + "class=\"%s %s\"", + Gbl.FileBrowser.InputStyle, + Gbl.FileBrowser.Clipboard.IsThisFile ? "LIGHT_GREEN" : + Gbl.ColorRows[Gbl.RowEvenOdd]); + Frm_EndForm (); + } + else + { + if ((Level == 1) && + (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || + Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) + HTM_SPAN_Begin ("title=\"%s\"",Gbl.FileBrowser.Asg.Title); - /***** End cell *****/ - HTM_DIV_End (); + HTM_STRONG_Begin (); + HTM_Txt (FileNameToShow); + HTM_STRONG_End (); + HTM_NBSP (); + + if ((Level == 1) && + (Gbl.FileBrowser.Type == Brw_ADMI_ASG_USR || + Gbl.FileBrowser.Type == Brw_ADMI_ASG_CRS)) + HTM_SPAN_End (); + } + + /***** End cell *****/ + HTM_DIV_End (); HTM_TD_End (); } else // File or link { - if (Gbl.FileBrowser.Clipboard.IsThisFile) - HTM_TD_Begin ("class=\"%s LM LIGHT_GREEN\" style=\"width:99%%;\"", - Gbl.FileBrowser.TxtStyle); - else - HTM_TD_Begin ("class=\"%s LM\" style=\"width:99%%;\"", - Gbl.FileBrowser.TxtStyle); + HTM_TD_Begin (Gbl.FileBrowser.Clipboard.IsThisFile ? "class=\"%s LM LIGHT_GREEN\" style=\"width:99%%;\"" : + "class=\"%s LM\" style=\"width:99%%;\"", + Gbl.FileBrowser.TxtStyle); - HTM_NBSP (); + HTM_NBSP (); - Frm_BeginForm (Brw_ActDowFile[Gbl.FileBrowser.Type]); - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); + Frm_BeginForm (Brw_ActDowFile[Gbl.FileBrowser.Type]); + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /* Link to the form and to the file */ - if (asprintf (&Class,"BT_LINK FILENAME %s",Gbl.FileBrowser.TxtStyle) < 0) - Err_NotEnoughMemoryExit (); - HTM_BUTTON_SUBMIT_Begin ((Gbl.FileBrowser.Type == Brw_SHOW_MRK_CRS || - Gbl.FileBrowser.Type == Brw_SHOW_MRK_GRP) ? Txt_Check_marks_in_the_file : - Txt_Download, - Class,NULL); - HTM_Txt (FileNameToShow); - HTM_BUTTON_End (); - free (Class); - Frm_EndForm (); + /* Link to the form and to the file */ + if (asprintf (&Class,"BT_LINK FILENAME %s",Gbl.FileBrowser.TxtStyle) < 0) + Err_NotEnoughMemoryExit (); + HTM_BUTTON_SUBMIT_Begin ((Gbl.FileBrowser.Type == Brw_SHOW_MRK_CRS || + Gbl.FileBrowser.Type == Brw_SHOW_MRK_GRP) ? Txt_Check_marks_in_the_file : + Txt_Download, + Class,NULL); + HTM_Txt (FileNameToShow); + HTM_BUTTON_End (); + free (Class); - /* Put icon to make public/private file */ - if (IsPublic) - Ico_PutIconOff ("unlock.svg", - Txt_Public_open_educational_resource_OER_for_everyone); + Frm_EndForm (); + + /* Put icon to make public/private file */ + if (IsPublic) + Ico_PutIconOff ("unlock.svg", + Txt_Public_open_educational_resource_OER_for_everyone); HTM_TD_End (); } @@ -6457,35 +6433,35 @@ static void Brw_WriteDatesAssignment (void) "ASG_LST_DATE_RED", Gbl.RowEvenOdd); - if (Gbl.FileBrowser.Asg.AsgCod > 0) - { - UniqueId++; + if (Gbl.FileBrowser.Asg.AsgCod > 0) + { + UniqueId++; - /***** Write start date *****/ - if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_SPAN_Begin ("id=\"%s\"",Id); - Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,false,0x7); - HTM_SPAN_End (); - free (Id); + /***** Write start date *****/ + if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_SPAN_Begin ("id=\"%s\"",Id); + Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,false,0x7); + HTM_SPAN_End (); + free (Id); - /***** Arrow *****/ - HTM_Txt ("→"); + /***** Arrow *****/ + HTM_Txt ("→"); - /***** Write end date *****/ - if (asprintf (&Id,"asg_end_date_%u",UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_SPAN_Begin ("id=\"%s\"",Id); - Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME], - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,false,false,0x7); - HTM_SPAN_End (); - free (Id); - } - else - HTM_TxtF (" (%s)",Txt_unknown_assignment); + /***** Write end date *****/ + if (asprintf (&Id,"asg_end_date_%u",UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_SPAN_Begin ("id=\"%s\"",Id); + Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME], + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,false,false,0x7); + HTM_SPAN_End (); + free (Id); + } + else + HTM_TxtF (" (%s)",Txt_unknown_assignment); /***** End table cell *****/ HTM_TD_End (); @@ -6508,26 +6484,26 @@ static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata) FileSizeStr[0] = '\0'; HTM_TD_Begin ("class=\"%s RM COLOR%u\"", Gbl.FileBrowser.TxtStyle,Gbl.RowEvenOdd); - HTM_TxtF (" %s",FileSizeStr); + HTM_TxtF (" %s",FileSizeStr); HTM_TD_End (); /***** Write the date *****/ HTM_TD_Begin ("class=\"%s RM COLOR%u\"", Gbl.FileBrowser.TxtStyle,Gbl.RowEvenOdd); - HTM_NBSP (); - if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FILE || - Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_LINK) - { - UniqueId++; - if (asprintf (&Id,"filedate%u",UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_SPAN_Begin ("id=\"%s\"",Id); - HTM_SPAN_End (); - Dat_WriteLocalDateHMSFromUTC (Id,FileMetadata->Time, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,false,0x6); - free (Id); - } + HTM_NBSP (); + if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FILE || + Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_LINK) + { + UniqueId++; + if (asprintf (&Id,"filedate%u",UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); + Dat_WriteLocalDateHMSFromUTC (Id,FileMetadata->Time, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,false,0x6); + free (Id); + } HTM_TD_End (); } @@ -6554,11 +6530,12 @@ static void Brw_WriteFileOrFolderPublisher (unsigned Level,long UsrCod) } HTM_TD_Begin ("class=\"BM%u\"",Gbl.RowEvenOdd); - if (ShowUsr) - /***** Show photo *****/ - Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO15x20B",Pho_ZOOM,false); - else - Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo,"PHOTO15x20B"); + + if (ShowUsr) + /***** Show photo *****/ + Pho_ShowUsrPhotoIfAllowed (&UsrDat,"PHOTO15x20B",Pho_ZOOM,false); + else + Ico_PutIcon ("usr_bl.jpg",Txt_Unknown_or_without_photo,"PHOTO15x20B"); HTM_TD_End (); @@ -6642,9 +6619,9 @@ void Brw_RemFileFromTree (void) Gbl.FileBrowser.FilFolLnk.Full); /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Message of confirmation of removing */ Ale_ShowAlert (Ale_SUCCESS,Txt_FILE_X_removed, @@ -6695,9 +6672,9 @@ void Brw_RemFolderFromTree (void) else { /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Message of confirmation of successfull removing */ Ale_ShowAlert (Ale_SUCCESS,Txt_Folder_X_removed, @@ -6757,8 +6734,9 @@ void Brw_RemSubtreeInFileBrowser (void) Brw_RemoveChildrenOfFolderFromDB (Gbl.FileBrowser.FilFolLnk.Full); /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Remove affected expanded folders */ Brw_RemoveAffectedExpandedFolders (Gbl.FileBrowser.FilFolLnk.Full); @@ -6810,7 +6788,7 @@ void Brw_CopyFromFileBrowser (void) Brw_GetParAndInitFileBrowser (); /***** Remove old clipboards (from all users) *****/ - Brw_RemoveExpiredClipboards (); // Someone must do this work. Let's do it whenever a user click in a copy button + Brw_DB_RemoveExpiredClipboards (); // Someone must do this work. Let's do it whenever a user click in a copy button /***** Put the path in the clipboard *****/ if (Brw_GetMyClipboard ()) @@ -7733,7 +7711,7 @@ static long Brw_GetWorksUsrCodForExpandedFolders (void) /************* Remove expired expanded folders (from all users) **************/ /*****************************************************************************/ -void Brw_RemoveExpiredExpandedFolders (void) +void Brw_DB_RemoveExpiredExpandedFolders (void) { /***** Remove all expired clipboards *****/ DB_QueryDELETE ("can not remove old expanded folders", @@ -7746,7 +7724,7 @@ void Brw_RemoveExpiredExpandedFolders (void) /****************** Remove expired clipboards (from all users) ***************/ /*****************************************************************************/ -static void Brw_RemoveExpiredClipboards (void) +static void Brw_DB_RemoveExpiredClipboards (void) { /***** Remove all expired clipboards *****/ DB_QueryDELETE ("can not remove old paths from clipboard", @@ -7759,8 +7737,8 @@ static void Brw_RemoveExpiredClipboards (void) /********* Remove clipboards with paths from a course or from a user *********/ /*****************************************************************************/ -static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, - long MyUsrCod,long WorksUsrCod) +static void Brw_DB_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, + long MyUsrCod,long WorksUsrCod) { /***** Remove clipboards associated to a file browser from a course or from a user *****/ @@ -7887,8 +7865,9 @@ void Brw_PasteIntoFileBrowser (void) Brw_PasteClipboard (); /***** Remove the affected clipboards *****/ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); } else /***** Write message ******/ @@ -8092,7 +8071,7 @@ static void Brw_PasteClipboard (void) Brw_GetFileMetadataByCod (&FileMetadata); /* Notify only is destination folder is visible */ - if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata)) + if (!Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata)) switch (Gbl.FileBrowser.Type) { case Brw_ADMI_DOC_CRS: @@ -8441,23 +8420,25 @@ static void Brw_PutFormToCreateAFolder (const char FileNameToShow[NAME_MAX + 1]) Frm_BeginForm (Brw_ActCreateFolder[Gbl.FileBrowser.Type]); Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Create_folder, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - Ale_ShowAlert (Ale_INFO,Txt_You_can_create_a_new_folder_inside_the_folder_X, - FileNameToShow); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Create_folder, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Folder *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColonNBSP (Txt_Folder); - HTM_INPUT_TEXT ("NewFolderName",Brw_MAX_CHARS_FOLDER,"", - HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"30\" required=\"required\""); - HTM_LABEL_End (); + /* Alert */ + Ale_ShowAlert (Ale_INFO,Txt_You_can_create_a_new_folder_inside_the_folder_X, + FileNameToShow); - /***** Send button and end box *****/ - Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_folder); + /* Folder */ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColonNBSP (Txt_Folder); + HTM_INPUT_TEXT ("NewFolderName",Brw_MAX_CHARS_FOLDER,"", + HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"30\" required=\"required\""); + HTM_LABEL_End (); + + /***** Send button and end box *****/ + Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_folder); /***** End form *****/ Frm_EndForm (); @@ -8477,53 +8458,53 @@ static void Brw_PutFormToUploadFilesUsingDropzone (const char *FileNameToShow) /***** Begin box *****/ HTM_DIV_Begin ("id=\"dropzone-upload\""); - Box_BoxBegin ("95%",Txt_Upload_files, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + Box_BoxBegin ("95%",Txt_Upload_files, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Help message *****/ - Ale_ShowAlert (Ale_INFO,Txt_or_you_can_upload_new_files_to_the_folder_X, - FileNameToShow); + /***** Help message *****/ + Ale_ShowAlert (Ale_INFO,Txt_or_you_can_upload_new_files_to_the_folder_X, + FileNameToShow); - /***** Form to upload files using the library Dropzone.js *****/ - // Use min-height:125px; or other number to stablish the height? - Gbl.Form.Num++; - HTM_TxtF ("
", - Cfg_URL_SWAD_CGI, - Lan_STR_LANG_ID[Gbl.Prefs.Language], - Cfg_URL_ICON_PUBLIC); - Par_PutHiddenParamLong (NULL,"act",Act_GetActCod (Brw_ActUploadFileDropzone[Gbl.FileBrowser.Type])); - Par_PutHiddenParamString (NULL,"ses",Gbl.Session.Id); - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); + /***** Form to upload files using the library Dropzone.js *****/ + // Use min-height:125px; or other number to stablish the height? + Gbl.Form.Num++; + HTM_TxtF ("", + Cfg_URL_SWAD_CGI, + Lan_STR_LANG_ID[Gbl.Prefs.Language], + Cfg_URL_ICON_PUBLIC); + Par_PutHiddenParamLong (NULL,"act",Act_GetActCod (Brw_ActUploadFileDropzone[Gbl.FileBrowser.Type])); + Par_PutHiddenParamString (NULL,"ses",Gbl.Session.Id); + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - HTM_DIV_Begin ("class=\"dz-message\""); - HTM_SPAN_Begin ("class=\"DAT_LIGHT\""); - HTM_Txt (Txt_Select_one_or_more_files_from_your_computer_or_drag_and_drop_here); - HTM_SPAN_End (); - HTM_DIV_End (); + HTM_DIV_Begin ("class=\"dz-message\""); + HTM_SPAN_Begin ("class=\"DAT_LIGHT\""); + HTM_Txt (Txt_Select_one_or_more_files_from_your_computer_or_drag_and_drop_here); + HTM_SPAN_End (); + HTM_DIV_End (); - HTM_Txt ("
"); + HTM_Txt (""); - /***** Put button to refresh file browser after upload *****/ - Frm_BeginForm (Brw_ActRefreshAfterUploadFiles[Gbl.FileBrowser.Type]); - Brw_PutParamsFileBrowser (NULL, // Not used - NULL, // Not used - Brw_IS_UNKNOWN, // Not used - -1L); // Not used + /***** Put button to refresh file browser after upload *****/ + Frm_BeginForm (Brw_ActRefreshAfterUploadFiles[Gbl.FileBrowser.Type]); + Brw_PutParamsFileBrowser (NULL, // Not used + NULL, // Not used + Brw_IS_UNKNOWN, // Not used + -1L); // Not used - /***** Button to send *****/ - Btn_PutConfirmButton (Txt_Done); + /***** Button to send *****/ + Btn_PutConfirmButton (Txt_Done); - /***** End form *****/ - Frm_EndForm (); + /***** End form *****/ + Frm_EndForm (); - /***** End box *****/ - Box_BoxEnd (); + /***** End box *****/ + Box_BoxEnd (); HTM_DIV_End (); } @@ -8538,27 +8519,30 @@ static void Brw_PutFormToUploadOneFileClassic (const char *FileNameToShow) /***** Begin box *****/ HTM_DIV_Begin ("id=\"classic-upload\" style=\"display:none;\""); - Box_BoxBegin (NULL,Txt_Upload_file, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + Box_BoxBegin (NULL,Txt_Upload_file, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Help message *****/ - Ale_ShowAlert (Ale_INFO,Txt_or_you_can_upload_a_new_file_to_the_folder_X, - FileNameToShow); + /***** Help message *****/ + Ale_ShowAlert (Ale_INFO,Txt_or_you_can_upload_a_new_file_to_the_folder_X, + FileNameToShow); - /***** Form to upload one files using the classic way *****/ - Frm_BeginForm (Brw_ActUploadFileClassic[Gbl.FileBrowser.Type]); - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"*", - HTM_DONT_SUBMIT_ON_CHANGE, - NULL); + /***** Form to upload one files using the classic way *****/ + Frm_BeginForm (Brw_ActUploadFileClassic[Gbl.FileBrowser.Type]); + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /* Button to send */ - Btn_PutCreateButton (Txt_Upload_file); - Frm_EndForm (); + /* File */ + HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"*", + HTM_DONT_SUBMIT_ON_CHANGE, + NULL); - /***** End box *****/ - Box_BoxEnd (); + /* Button to send */ + Btn_PutCreateButton (Txt_Upload_file); + + Frm_EndForm (); + + /***** End box *****/ + Box_BoxEnd (); HTM_DIV_End (); } @@ -8575,17 +8559,17 @@ static void Brw_PutFormToPasteAFileOrFolder (const char *FileNameToShow) Frm_BeginForm (Brw_ActPaste[Gbl.FileBrowser.Type]); Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Paste, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Paste, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Help message *****/ - Ale_ShowAlert (Ale_INFO,Txt_or_you_can_make_a_file_copy_to_the_folder_X, - FileNameToShow); + /***** Help message *****/ + Ale_ShowAlert (Ale_INFO,Txt_or_you_can_make_a_file_copy_to_the_folder_X, + FileNameToShow); - /***** Send button and end box *****/ - Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Paste); + /***** Send button and end box *****/ + Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Paste); /***** End form *****/ Frm_EndForm (); @@ -8609,51 +8593,53 @@ static void Brw_PutFormToCreateALink (const char *FileNameToShow) Frm_BeginForm (Brw_ActCreateLink[Gbl.FileBrowser.Type]); Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Create_link, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Create_link, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Help message *****/ - Ale_ShowAlert (Ale_INFO,Txt_or_you_can_create_a_new_link_inside_the_folder_X, - FileNameToShow); + /***** Help message *****/ + Ale_ShowAlert (Ale_INFO,Txt_or_you_can_create_a_new_link_inside_the_folder_X, + FileNameToShow); - /***** URL *****/ - HTM_TABLE_Begin (NULL); - HTM_TR_Begin (NULL); + /***** URL *****/ + HTM_TABLE_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","NewLinkURL",Txt_URL); + HTM_TR_Begin (NULL); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_URL ("NewLinkURL","",HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"30\" required=\"required\""); - HTM_TD_End (); + /* Label */ + Frm_LabelColumn ("RT","NewLinkURL",Txt_URL); - HTM_TR_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_INPUT_URL ("NewLinkURL","",HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"30\" required=\"required\""); + HTM_TD_End (); - /***** Link name *****/ - HTM_TR_Begin (NULL); + HTM_TR_End (); - /* Label */ - if (asprintf (&Label,"%s (%s): ",Txt_Save_as,Txt_optional) < 0) - Err_NotEnoughMemoryExit (); - Frm_LabelColumn ("RT","NewLinkName",Label); - free (Label); + /***** Link name *****/ + HTM_TR_Begin (NULL); - /* Data */ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("NewLinkName",Brw_MAX_CHARS_FOLDER,"", - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"NewLinkName\" size=\"30\""); - HTM_TD_End (); + /* Label */ + if (asprintf (&Label,"%s (%s): ",Txt_Save_as,Txt_optional) < 0) + Err_NotEnoughMemoryExit (); + Frm_LabelColumn ("RT","NewLinkName",Label); + free (Label); - HTM_TR_End (); - HTM_TABLE_End (); + /* Data */ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_TEXT ("NewLinkName",Brw_MAX_CHARS_FOLDER,"", + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"NewLinkName\" size=\"30\""); + HTM_TD_End (); - /***** Send button and end box *****/ - Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_link); + HTM_TR_End (); + + HTM_TABLE_End (); + + /***** Send button and end box *****/ + Box_BoxWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_link); /***** End form *****/ Frm_EndForm (); @@ -8706,9 +8692,9 @@ void Brw_RecFolderFileBrowser (void) else { /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Add path where new file is created to table of expanded folders */ Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.FilFolLnk.Full); @@ -8834,9 +8820,9 @@ void Brw_RenFolderFileBrowser (void) NewPathInTree); /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Remove affected expanded folders */ Brw_RenameAffectedExpandedFolders (Gbl.FileBrowser.Type, @@ -9016,9 +9002,9 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) else { /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Add path where new file is created to table of expanded folders */ Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.FilFolLnk.Full); @@ -9055,7 +9041,7 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType) Mrk_AddMarksToDB (FileMetadata.FilCod,&Marks); /* Notify new file */ - if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata)) + if (!Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata)) switch (Gbl.FileBrowser.Type) { case Brw_ADMI_DOC_CRS: @@ -9199,9 +9185,9 @@ void Brw_RecLinkFileBrowser (void) else { /* Remove affected clipboards */ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /* Add path where new file is created to table of expanded folders */ Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.FilFolLnk.Full); @@ -9227,7 +9213,7 @@ void Brw_RecLinkFileBrowser (void) Brw_GetFileMetadataByCod (&FileMetadata); /* Notify new file */ - if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata)) + if (!Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata)) switch (Gbl.FileBrowser.Type) { case Brw_ADMI_DOC_CRS: @@ -9344,9 +9330,9 @@ void Brw_SetDocumentAsVisible (void) Brw_ChangeFileOrFolderHiddenInDB (Gbl.FileBrowser.FilFolLnk.Full,false); /***** Remove the affected clipboards *****/ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /***** Show again the file browser *****/ Brw_ShowAgainFileBrowserOrWorks (); @@ -9368,9 +9354,9 @@ void Brw_SetDocumentAsHidden (void) Brw_ChangeFileOrFolderHiddenInDB (Gbl.FileBrowser.FilFolLnk.Full,true); /***** Remove the affected clipboards *****/ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /***** Show again the file browser *****/ Brw_ShowAgainFileBrowserOrWorks (); @@ -9420,7 +9406,7 @@ bool Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_FileType_t FileType,const cha /******** Check if a file / folder from the documents zone is hidden *********/ /*****************************************************************************/ -bool Brw_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata) +bool Brw_DB_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata) { /***** Get if a file or folder is under a hidden folder from database *****/ /* @@ -9507,20 +9493,20 @@ void Brw_ShowFileMetadata (void) { case Brw_SHOW_DOC_INS: if (Gbl.Usrs.Me.Role.Logged < Rol_INS_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_CTR: if (Gbl.Usrs.Me.Role.Logged < Rol_CTR_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_DEG: if (Gbl.Usrs.Me.Role.Logged < Rol_DEG_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_CRS: case Brw_SHOW_DOC_GRP: if (Gbl.Usrs.Me.Role.Logged < Rol_TCH) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; default: break; @@ -9600,192 +9586,192 @@ void Brw_ShowFileMetadata (void) NULL,NULL, NULL,2); - /***** Link to download the file *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("colspan=\"2\" class=\"FILENAME_TXT CM\""); - Brw_WriteBigLinkToDownloadFile (URL,&FileMetadata,FileNameToShow); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Filename *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Filename); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT LB\""); - Brw_WriteSmallLinkToDownloadFile (URL,&FileMetadata,FileNameToShow); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Publisher's data *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Uploaded_by); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT LB\""); - if (FileHasPublisher) - { - /* Show photo */ - Pho_ShowUsrPhotoIfAllowed (&PublisherUsrDat,"PHOTO15x20",Pho_ZOOM,false); - - /* Write name */ - HTM_NBSP (); - HTM_Txt (PublisherUsrDat.FullName); - } - else - /* Unknown publisher */ - HTM_Txt (Txt_ROLES_SINGUL_Abc[Rol_UNK][Usr_SEX_UNKNOWN]); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Free memory used for publisher's data *****/ - if (FileMetadata.PublisherUsrCod > 0) - Usr_UsrDataDestructor (&PublisherUsrDat); - - /***** Write the file size *****/ - Fil_WriteFileSizeFull ((double) FileMetadata.Size,FileSizeStr); - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_File_size); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Txt (FileSizeStr); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Write the date *****/ - HTM_TR_Begin (NULL); - - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Date_of_creation); - HTM_TD_End (); - - HTM_TD_Begin ("id=\"filedate\" class=\"DAT LB\""); - Dat_WriteLocalDateHMSFromUTC ("filedate",FileMetadata.Time, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Private or public? *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT","PublicFile",Txt_Availability); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LT\""); - if (ICanChangePublic) // I can change file to public - { - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"PublicFile\" name=\"PublicFile\" class=\"PUBLIC_FILE\""); - HTM_OPTION (HTM_Type_STRING,"N", - !FileMetadata.IsPublic,false, - "%s",Txt_Private_available_to_certain_users_identified); - HTM_OPTION (HTM_Type_STRING,"Y", - FileMetadata.IsPublic,false, - "%s",Txt_Public_open_educational_resource_OER_for_everyone); - HTM_SELECT_End (); - } - else // I can not edit file properties - HTM_Txt (FileMetadata.IsPublic ? Txt_Public_open_educational_resource_OER_for_everyone : - Txt_Private_available_to_certain_users_identified); - HTM_TD_End (); - - HTM_TR_End (); - - /***** License *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT","License",Txt_License); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LT\""); - if (ICanEdit) // I can edit file properties - { - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"License\" name=\"License\" class=\"LICENSE\""); - for (License = (Brw_License_t) 0; - License <= (Brw_License_t) (Brw_NUM_LICENSES - 1); - License++) - { - LicenseUnsigned = (unsigned) License; - HTM_OPTION (HTM_Type_UNSIGNED,&LicenseUnsigned, - License == FileMetadata.License,false, - "%s",Txt_LICENSES[License]); - } - HTM_SELECT_End (); - } - else // I can not edit file properties - HTM_Txt (Txt_LICENSES[FileMetadata.License]); - HTM_TD_End (); - - HTM_TR_End (); - - /***** Write my number of views *****/ - if (Gbl.Usrs.Me.Logged) - { + /***** Link to download the file *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_My_views); - HTM_TD_End (); - - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (FileMetadata.NumMyViews); - HTM_TD_End (); + HTM_TD_Begin ("colspan=\"2\" class=\"FILENAME_TXT CM\""); + Brw_WriteBigLinkToDownloadFile (URL,&FileMetadata,FileNameToShow); + HTM_TD_End (); HTM_TR_End (); - } - /***** Write number of identificated views *****/ - HTM_TR_Begin (NULL); + /***** Filename *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Identified_views); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Filename); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_TxtF ("%u ",FileMetadata.NumViewsFromLoggedUsrs); - HTM_TxtF ("(%u %s)", - FileMetadata.NumLoggedUsrs, - FileMetadata.NumLoggedUsrs == 1 ? Txt_user[Usr_SEX_UNKNOWN] : - Txt_users[Usr_SEX_UNKNOWN]); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + Brw_WriteSmallLinkToDownloadFile (URL,&FileMetadata,FileNameToShow); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /***** Write number of public views *****/ - HTM_TR_Begin (NULL); + /***** Publisher's data *****/ + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtColon (Txt_Public_views); - HTM_TD_End (); + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Uploaded_by); + HTM_TD_End (); - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (FileMetadata.NumPublicViews); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LB\""); + if (FileHasPublisher) + { + /* Show photo */ + Pho_ShowUsrPhotoIfAllowed (&PublisherUsrDat,"PHOTO15x20",Pho_ZOOM,false); - HTM_TR_End (); + /* Write name */ + HTM_NBSP (); + HTM_Txt (PublisherUsrDat.FullName); + } + else + /* Unknown publisher */ + HTM_Txt (Txt_ROLES_SINGUL_Abc[Rol_UNK][Usr_SEX_UNKNOWN]); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Free memory used for publisher's data *****/ + if (FileMetadata.PublisherUsrCod > 0) + Usr_UsrDataDestructor (&PublisherUsrDat); + + /***** Write the file size *****/ + Fil_WriteFileSizeFull ((double) FileMetadata.Size,FileSizeStr); + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_File_size); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Txt (FileSizeStr); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Write the date *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Date_of_creation); + HTM_TD_End (); + + HTM_TD_Begin ("id=\"filedate\" class=\"DAT LB\""); + Dat_WriteLocalDateHMSFromUTC ("filedate",FileMetadata.Time, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,true,0x7); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Private or public? *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT","PublicFile",Txt_Availability); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LT\""); + if (ICanChangePublic) // I can change file to public + { + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"PublicFile\" name=\"PublicFile\" class=\"PUBLIC_FILE\""); + HTM_OPTION (HTM_Type_STRING,"N", + !FileMetadata.IsPublic,false, + "%s",Txt_Private_available_to_certain_users_identified); + HTM_OPTION (HTM_Type_STRING,"Y", + FileMetadata.IsPublic,false, + "%s",Txt_Public_open_educational_resource_OER_for_everyone); + HTM_SELECT_End (); + } + else // I can not edit file properties + HTM_Txt (FileMetadata.IsPublic ? Txt_Public_open_educational_resource_OER_for_everyone : + Txt_Private_available_to_certain_users_identified); + HTM_TD_End (); + + HTM_TR_End (); + + /***** License *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT","License",Txt_License); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LT\""); + if (ICanEdit) // I can edit file properties + { + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"License\" name=\"License\" class=\"LICENSE\""); + for (License = (Brw_License_t) 0; + License <= (Brw_License_t) (Brw_NUM_LICENSES - 1); + License++) + { + LicenseUnsigned = (unsigned) License; + HTM_OPTION (HTM_Type_UNSIGNED,&LicenseUnsigned, + License == FileMetadata.License,false, + "%s",Txt_LICENSES[License]); + } + HTM_SELECT_End (); + } + else // I can not edit file properties + HTM_Txt (Txt_LICENSES[FileMetadata.License]); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Write my number of views *****/ + if (Gbl.Usrs.Me.Logged) + { + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_My_views); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (FileMetadata.NumMyViews); + HTM_TD_End (); + + HTM_TR_End (); + } + + /***** Write number of identificated views *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Identified_views); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_TxtF ("%u ",FileMetadata.NumViewsFromLoggedUsrs); + HTM_TxtF ("(%u %s)", + FileMetadata.NumLoggedUsrs, + FileMetadata.NumLoggedUsrs == 1 ? Txt_user[Usr_SEX_UNKNOWN] : + Txt_users[Usr_SEX_UNKNOWN]); + HTM_TD_End (); + + HTM_TR_End (); + + /***** Write number of public views *****/ + HTM_TR_Begin (NULL); + + HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtColon (Txt_Public_views); + HTM_TD_End (); + + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (FileMetadata.NumPublicViews); + HTM_TD_End (); + + HTM_TR_End (); /***** End box *****/ if (ICanEdit) // I can edit file properties { - /* End table, send button and end box */ - Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_file_properties); + /* End table, send button and end box */ + Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_file_properties); /* End form */ Frm_EndForm (); @@ -9907,20 +9893,20 @@ void Brw_DownloadFile (void) { case Brw_SHOW_DOC_INS: if (Gbl.Usrs.Me.Role.Logged < Rol_INS_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_CTR: if (Gbl.Usrs.Me.Role.Logged < Rol_CTR_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_DEG: if (Gbl.Usrs.Me.Role.Logged < Rol_DEG_ADM) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; case Brw_SHOW_DOC_CRS: case Brw_SHOW_DOC_GRP: if (Gbl.Usrs.Me.Role.Logged < Rol_TCH) - ICanView = !Brw_CheckIfFileOrFolderIsHidden (&FileMetadata); + ICanView = !Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata); break; default: break; @@ -10113,22 +10099,27 @@ static void Brw_WriteBigLinkToDownloadFile (const char *URL, /* Form to see marks */ Frm_BeginForm (Gbl.FileBrowser.Type == Brw_SHOW_MRK_CRS ? ActSeeMyMrkCrs : ActSeeMyMrkGrp); - Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata->FilFolLnk.Path, - sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1); - Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata->FilFolLnk.Name, - sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1); - Gbl.FileBrowser.FilFolLnk.Type = FileMetadata->FilFolLnk.Type; - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /* Link begin */ - HTM_BUTTON_SUBMIT_Begin (Txt_Check_marks_in_the_file,"BT_LINK FILENAME_TXT",NULL); - Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, - "ICO40x40",false); + Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata->FilFolLnk.Path, + sizeof (Gbl.FileBrowser.FilFolLnk.Path) - 1); + Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata->FilFolLnk.Name, + sizeof (Gbl.FileBrowser.FilFolLnk.Name) - 1); + Gbl.FileBrowser.FilFolLnk.Type = FileMetadata->FilFolLnk.Type; + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); + + /* Begin link */ + HTM_BUTTON_SUBMIT_Begin (Txt_Check_marks_in_the_file,"BT_LINK FILENAME_TXT",NULL); + + Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, + "ICO40x40",false); + + /* Name of the file of marks, link end and form end */ + HTM_TxtF (" %s ",FileNameToShow); + Ico_PutIcon ("grades32x32.gif",Txt_Check_marks_in_the_file,"ICO40x40"); + + /* End link */ + HTM_BUTTON_End (); - /* Name of the file of marks, link end and form end */ - HTM_TxtF (" %s ",FileNameToShow); - Ico_PutIcon ("grades32x32.gif",Txt_Check_marks_in_the_file,"ICO40x40"); - HTM_BUTTON_End (); Frm_EndForm (); } else @@ -10139,10 +10130,10 @@ static void Brw_WriteBigLinkToDownloadFile (const char *URL, /* Put anchor and filename */ HTM_A_Begin ("href=\"%s\" class=\"FILENAME_TXT\" title=\"%s\" target=\"_blank\"", URL,Title); - Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, - "ICO40x40",false); - HTM_TxtF (" %s ",FileNameToShow); - Ico_PutIcon ("download.svg",Title,"ICO40x40"); + Brw_PutIconFile (FileMetadata->FilFolLnk.Type,FileMetadata->FilFolLnk.Name, + "ICO40x40",false); + HTM_TxtF (" %s ",FileNameToShow); + Ico_PutIcon ("download.svg",Title,"ICO40x40"); HTM_A_End (); } } @@ -10171,14 +10162,16 @@ static void Brw_WriteSmallLinkToDownloadFile (const char *URL, Gbl.FileBrowser.FilFolLnk.Type = FileMetadata->FilFolLnk.Type; Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - /* Link begin */ - HTM_BUTTON_SUBMIT_Begin (Txt_Check_marks_in_the_file,"BT_LINK DAT",NULL); + /* Begin link */ + HTM_BUTTON_SUBMIT_Begin (Txt_Check_marks_in_the_file,"BT_LINK DAT",NULL); - /* Name of the file of marks */ - HTM_Txt (FileNameToShow); + /* Name of the file of marks */ + HTM_Txt (FileNameToShow); - /* Link end and form end */ - HTM_BUTTON_End (); + /* End link */ + HTM_BUTTON_End (); + + /* End form */ Frm_EndForm (); } else @@ -10186,7 +10179,7 @@ static void Brw_WriteSmallLinkToDownloadFile (const char *URL, /* Put anchor and filename */ HTM_A_Begin ("href=\"%s\" class=\"DAT\" title=\"%s\" target=\"_blank\"", URL,FileNameToShow); - HTM_Txt (FileNameToShow); + HTM_Txt (FileNameToShow); HTM_A_End (); } } @@ -10304,9 +10297,9 @@ void Brw_ChgFileMetadata (void) Brw_ChangeFilePublicInDB (&FileMetadata,PublicFileAfterEdition,License); /***** Remove the affected clipboards *****/ - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); /***** Insert file into public social activity *****/ if (!PublicFileBeforeEdition && @@ -10738,7 +10731,7 @@ void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata) Brw_GetFileViewsFromLoggedUsrs (FileMetadata); /***** Get file views from non logged users *****/ - Brw_GetFileViewsFromNonLoggedUsrs (FileMetadata); + FileMetadata->NumPublicViews = Brw_DB_GetFileViewsFromNonLoggedUsrs (FileMetadata->FilCod); /***** Get number of my views *****/ if (Gbl.Usrs.Me.Logged) @@ -10779,7 +10772,7 @@ void Brw_UpdateMyFileViews (long FilCod) /******************** Get number of file views from a user *******************/ /*****************************************************************************/ -unsigned Brw_GetNumFileViewsUsr (long UsrCod) +unsigned Brw_DB_GetNumFileViewsUsr (long UsrCod) { /***** Get number of filw views *****/ return DB_QuerySELECTUnsigned ("can not get number of file views", @@ -10835,22 +10828,18 @@ static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata) } /*****************************************************************************/ -/****************** Get file views from non logged users *********************/ +/******************** Get number of public views of a file *******************/ /*****************************************************************************/ -/* - Input: FileMetadata->FilCod - Output: FileMetadata->NumPublicViews -*/ -static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata) + +static unsigned Brw_DB_GetFileViewsFromNonLoggedUsrs (long FilCod) { - /***** Get number of public views *****/ - FileMetadata->NumPublicViews = + return DB_QuerySELECTUnsigned ("can not get number of public views of a file", "SELECT SUM(NumViews)" " FROM brw_views" " WHERE FilCod=%ld" " AND UsrCod<=0", - FileMetadata->FilCod); + FilCod); } /*****************************************************************************/ @@ -10937,7 +10926,7 @@ static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]) /*********************** Get number of files from a user *********************/ /*****************************************************************************/ -unsigned Brw_GetNumFilesUsr (long UsrCod) +unsigned Brw_DB_GetNumFilesUsr (long UsrCod) { /***** Get current number of files published by a user from database *****/ return (unsigned) @@ -10955,7 +10944,7 @@ unsigned Brw_GetNumFilesUsr (long UsrCod) /******************* Get number of public files from a user ******************/ /*****************************************************************************/ -unsigned Brw_GetNumPublicFilesUsr (long UsrCod) +unsigned Brw_DB_GetNumPublicFilesUsr (long UsrCod) { /***** Get current number of public files published by a user from database *****/ return (unsigned) @@ -11735,7 +11724,7 @@ void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod) long GrpCod; /***** Query database *****/ - NumGrps = Grp_GetGrpsOfType (GrpTypCod,&mysql_res); + NumGrps = Grp_DB_GetGrpsOfType (GrpTypCod,&mysql_res); for (NumGrp = 0; NumGrp < NumGrps; NumGrp++) @@ -11918,45 +11907,43 @@ void Brw_ListDocsFound (MYSQL_RES **mysql_res,unsigned NumDocs, NULL,Box_NOT_CLOSABLE,2); Str_FreeString (); - /***** Write heading *****/ - HTM_TR_Begin (NULL); + /***** Write heading *****/ + HTM_TR_Begin (NULL); + HTM_TH (1,1,"BM",NULL); + HTM_TH (1,1,"LM",Txt_Institution); + HTM_TH (1,1,"LM",Txt_Center); + HTM_TH (1,1,"LM",Txt_Degree); + HTM_TH (1,1,"LM",Txt_Course); + HTM_TH (1,1,"LM",Txt_File_zone); + HTM_TH (1,1,"LM",Txt_Document); + HTM_TR_End (); - HTM_TH (1,1,"BM",NULL); - HTM_TH (1,1,"LM",Txt_Institution); - HTM_TH (1,1,"LM",Txt_Center); - HTM_TH (1,1,"LM",Txt_Degree); - HTM_TH (1,1,"LM",Txt_Course); - HTM_TH (1,1,"LM",Txt_File_zone); - HTM_TH (1,1,"LM",Txt_Document); + /***** List documents found *****/ + for (NumDoc = 1; + NumDoc <= NumDocs; + NumDoc++) + { + /* Get next course */ + row = mysql_fetch_row (*mysql_res); - HTM_TR_End (); + /* Write data of this course */ + Brw_WriteRowDocData (&NumDocsNotHidden,row); + } - /***** List documents found *****/ - for (NumDoc = 1; - NumDoc <= NumDocs; - NumDoc++) - { - /* Get next course */ - row = mysql_fetch_row (*mysql_res); + /***** Write footer *****/ + HTM_TR_Begin (NULL); - /* Write data of this course */ - Brw_WriteRowDocData (&NumDocsNotHidden,row); - } + /* Number of documents not hidden found */ + HTM_TH_Begin (1,7,"CM"); + HTM_Txt ("("); + NumDocsHidden = NumDocs - NumDocsNotHidden; + HTM_TxtF ("%u %s", + NumDocsHidden,NumDocsHidden == 1 ? Txt_hidden_document : + Txt_hidden_documents); + HTM_Txt (")"); + HTM_TH_End (); - /***** Write footer *****/ - HTM_TR_Begin (NULL); - - /* Number of documents not hidden found */ - HTM_TH_Begin (1,7,"CM"); - HTM_Txt ("("); - NumDocsHidden = NumDocs - NumDocsNotHidden; - HTM_TxtF ("%u %s", - NumDocsHidden,NumDocsHidden == 1 ? Txt_hidden_document : - Txt_hidden_documents); - HTM_Txt (")"); - HTM_TH_End (); - - HTM_TR_End (); + HTM_TR_End (); /***** End table and box *****/ Box_BoxTableEnd (); @@ -12013,7 +12000,7 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row) FileMetadata.FilCod = Str_ConvertStrCodToLongCod (row[0]); Brw_GetFileMetadataByCod (&FileMetadata); - if (!Brw_CheckIfFileOrFolderIsHidden (&FileMetadata)) + if (!Brw_DB_CheckIfFileOrFolderIsHidden (&FileMetadata)) { /***** Get institution code (row[2]) *****/ InsCod = Str_ConvertStrCodToLongCod (row[2]); @@ -12041,183 +12028,183 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row) HTM_TR_Begin (NULL); - /***** Write number of document in this search *****/ - HTM_TD_Begin ("class=\"RT DAT %s\"",BgColor); - HTM_Unsigned (++(*NumDocsNotHidden)); - HTM_TD_End (); + /***** Write number of document in this search *****/ + HTM_TD_Begin ("class=\"RT DAT %s\"",BgColor); + HTM_Unsigned (++(*NumDocsNotHidden)); + HTM_TD_End (); - /***** Write institution logo, institution short name *****/ - HTM_TD_Begin ("class=\"LT %s\"",BgColor); - if (InsCod > 0) - { - Frm_BeginFormGoTo (ActSeeInsInf); - Deg_PutParamDegCod (InsCod); - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (InsShortName), - "BT_LINK LT DAT",NULL); - Hie_FreeGoToMsg (); - Lgo_DrawLogo (HieLvl_INS,InsCod,InsShortName,20,"BT_LINK LT",true); - HTM_TxtF (" %s",InsShortName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - HTM_TD_End (); + /***** Write institution logo, institution short name *****/ + HTM_TD_Begin ("class=\"LT %s\"",BgColor); + if (InsCod > 0) + { + Frm_BeginFormGoTo (ActSeeInsInf); + Deg_PutParamDegCod (InsCod); + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (InsShortName), + "BT_LINK LT DAT",NULL); + Hie_FreeGoToMsg (); + Lgo_DrawLogo (HieLvl_INS,InsCod,InsShortName,20,"BT_LINK LT",true); + HTM_TxtF (" %s",InsShortName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + HTM_TD_End (); - /***** Write center logo, center short name *****/ - HTM_TD_Begin ("class=\"LT %s\"",BgColor); - if (CtrCod > 0) - { - Frm_BeginFormGoTo (ActSeeCtrInf); - Deg_PutParamDegCod (CtrCod); - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (CtrShortName), - "BT_LINK LT DAT",NULL); - Hie_FreeGoToMsg (); - Lgo_DrawLogo (HieLvl_CTR,CtrCod,CtrShortName,20,"LT",true); - HTM_TxtF (" %s",CtrShortName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - HTM_TD_End (); + /***** Write center logo, center short name *****/ + HTM_TD_Begin ("class=\"LT %s\"",BgColor); + if (CtrCod > 0) + { + Frm_BeginFormGoTo (ActSeeCtrInf); + Deg_PutParamDegCod (CtrCod); + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (CtrShortName), + "BT_LINK LT DAT",NULL); + Hie_FreeGoToMsg (); + Lgo_DrawLogo (HieLvl_CTR,CtrCod,CtrShortName,20,"LT",true); + HTM_TxtF (" %s",CtrShortName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + HTM_TD_End (); - /***** Write degree logo, degree short name *****/ - HTM_TD_Begin ("class=\"LT %s\"",BgColor); - if (DegCod > 0) - { - Frm_BeginFormGoTo (ActSeeDegInf); - Deg_PutParamDegCod (DegCod); - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (DegShortName), - "BT_LINK LT DAT",NULL); - Hie_FreeGoToMsg (); - Lgo_DrawLogo (HieLvl_DEG,DegCod,DegShortName,20,"LT",true); - HTM_TxtF (" %s",DegShortName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - HTM_TD_End (); + /***** Write degree logo, degree short name *****/ + HTM_TD_Begin ("class=\"LT %s\"",BgColor); + if (DegCod > 0) + { + Frm_BeginFormGoTo (ActSeeDegInf); + Deg_PutParamDegCod (DegCod); + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (DegShortName), + "BT_LINK LT DAT",NULL); + Hie_FreeGoToMsg (); + Lgo_DrawLogo (HieLvl_DEG,DegCod,DegShortName,20,"LT",true); + HTM_TxtF (" %s",DegShortName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + HTM_TD_End (); - /***** Write course short name *****/ - HTM_TD_Begin ("class=\"LT %s\"",BgColor); - if (CrsCod > 0) - { - Frm_BeginFormGoTo (ActSeeCrsInf); - Crs_PutParamCrsCod (CrsCod); - HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (CrsShortName),"BT_LINK DAT",NULL); - Hie_FreeGoToMsg (); - HTM_Txt (CrsShortName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - HTM_TD_End (); + /***** Write course short name *****/ + HTM_TD_Begin ("class=\"LT %s\"",BgColor); + if (CrsCod > 0) + { + Frm_BeginFormGoTo (ActSeeCrsInf); + Crs_PutParamCrsCod (CrsCod); + HTM_BUTTON_SUBMIT_Begin (Hie_BuildGoToMsg (CrsShortName),"BT_LINK DAT",NULL); + Hie_FreeGoToMsg (); + HTM_Txt (CrsShortName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + HTM_TD_End (); - /***** Write file zone *****/ - switch (FileMetadata.FileBrowser) - { - case Brw_ADMI_DOC_INS: - case Brw_ADMI_DOC_CTR: - case Brw_ADMI_DOC_DEG: - case Brw_ADMI_DOC_CRS: - case Brw_ADMI_DOC_GRP: - Title = Txt_Documents_area; - break; - case Brw_ADMI_TCH_CRS: - case Brw_ADMI_TCH_GRP: - Title = Txt_Teachers_files_area; - break; - case Brw_ADMI_SHR_INS: - case Brw_ADMI_SHR_CTR: - case Brw_ADMI_SHR_DEG: - case Brw_ADMI_SHR_CRS: - case Brw_ADMI_SHR_GRP: - Title = Txt_Shared_files_area; - break; - case Brw_ADMI_ASG_USR: - Title = Txt_Assignments_area; - break; - case Brw_ADMI_WRK_USR: - Title = Txt_Works_area; - break; - case Brw_ADMI_DOC_PRJ: - Title = Txt_Project_documents; - break; - case Brw_ADMI_ASS_PRJ: - Title = Txt_Project_assessment; - break; - case Brw_ADMI_MRK_CRS: - case Brw_ADMI_MRK_GRP: - Title = Txt_Marks_area; - break; - case Brw_ADMI_BRF_USR: - Title = Txt_Temporary_private_storage_area; - break; - default: - Title = ""; - break; - } + /***** Write file zone *****/ + switch (FileMetadata.FileBrowser) + { + case Brw_ADMI_DOC_INS: + case Brw_ADMI_DOC_CTR: + case Brw_ADMI_DOC_DEG: + case Brw_ADMI_DOC_CRS: + case Brw_ADMI_DOC_GRP: + Title = Txt_Documents_area; + break; + case Brw_ADMI_TCH_CRS: + case Brw_ADMI_TCH_GRP: + Title = Txt_Teachers_files_area; + break; + case Brw_ADMI_SHR_INS: + case Brw_ADMI_SHR_CTR: + case Brw_ADMI_SHR_DEG: + case Brw_ADMI_SHR_CRS: + case Brw_ADMI_SHR_GRP: + Title = Txt_Shared_files_area; + break; + case Brw_ADMI_ASG_USR: + Title = Txt_Assignments_area; + break; + case Brw_ADMI_WRK_USR: + Title = Txt_Works_area; + break; + case Brw_ADMI_DOC_PRJ: + Title = Txt_Project_documents; + break; + case Brw_ADMI_ASS_PRJ: + Title = Txt_Project_assessment; + break; + case Brw_ADMI_MRK_CRS: + case Brw_ADMI_MRK_GRP: + Title = Txt_Marks_area; + break; + case Brw_ADMI_BRF_USR: + Title = Txt_Temporary_private_storage_area; + break; + default: + Title = ""; + break; + } - HTM_TD_Begin ("class=\"DAT LT %s\"",BgColor); - HTM_Txt (Title); - HTM_TD_End (); + HTM_TD_Begin ("class=\"DAT LT %s\"",BgColor); + HTM_Txt (Title); + HTM_TD_End (); - /***** Get the name of the file to show *****/ - Brw_GetFileNameToShow (FileMetadata.FilFolLnk.Type, - FileMetadata.FilFolLnk.Name, - FileNameToShow); + /***** Get the name of the file to show *****/ + Brw_GetFileNameToShow (FileMetadata.FilFolLnk.Type, + FileMetadata.FilFolLnk.Name, + FileNameToShow); - /***** Write file name using path (row[1]) *****/ - HTM_TD_Begin ("class=\"DAT_N LT %s\"",BgColor); + /***** Write file name using path (row[1]) *****/ + HTM_TD_Begin ("class=\"DAT_N LT %s\"",BgColor); - /* Begin form */ - Action = Brw_ActReqDatFile[Brw_FileBrowserForFoundDocs[FileMetadata.FileBrowser]]; + /* Begin form */ + Action = Brw_ActReqDatFile[Brw_FileBrowserForFoundDocs[FileMetadata.FileBrowser]]; - if (CrsCod > 0) - { - Frm_BeginFormGoTo (Action); - Crs_PutParamCrsCod (CrsCod); // Go to course - if (GrpCod > 0) - Grp_PutParamGrpCod (&GrpCod); - } - else if (DegCod > 0) - { - Frm_BeginFormGoTo (Action); - Deg_PutParamDegCod (DegCod); // Go to degree - } - else if (CtrCod > 0) - { - Frm_BeginFormGoTo (Action); - Ctr_PutParamCtrCod (CtrCod); // Go to center - } - else if (InsCod > 0) - { - Frm_BeginFormGoTo (Action); - Ins_PutParamInsCod (InsCod); // Go to institution - } - else - Frm_BeginForm (Action); + if (CrsCod > 0) + { + Frm_BeginFormGoTo (Action); + Crs_PutParamCrsCod (CrsCod); // Go to course + if (GrpCod > 0) + Grp_PutParamGrpCod (&GrpCod); + } + else if (DegCod > 0) + { + Frm_BeginFormGoTo (Action); + Deg_PutParamDegCod (DegCod); // Go to degree + } + else if (CtrCod > 0) + { + Frm_BeginFormGoTo (Action); + Ctr_PutParamCtrCod (CtrCod); // Go to center + } + else if (InsCod > 0) + { + Frm_BeginFormGoTo (Action); + Ins_PutParamInsCod (InsCod); // Go to institution + } + else + Frm_BeginForm (Action); - /* Parameters to go to file / folder */ - if (FileMetadata.FilFolLnk.Type == Brw_IS_FOLDER) - Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); - else - Brw_PutParamsFileBrowser (NULL, // Not used - NULL, // Not used - Brw_IS_UNKNOWN, // Not used - FileMetadata.FilCod); + /* Parameters to go to file / folder */ + if (FileMetadata.FilFolLnk.Type == Brw_IS_FOLDER) + Brw_PutImplicitParamsFileBrowser (&Gbl.FileBrowser.FilFolLnk); + else + Brw_PutParamsFileBrowser (NULL, // Not used + NULL, // Not used + Brw_IS_UNKNOWN, // Not used + FileMetadata.FilCod); - /* File or folder icon */ - HTM_BUTTON_SUBMIT_Begin (FileNameToShow,"BT_LINK LT DAT_N",NULL); - if (FileMetadata.FilFolLnk.Type == Brw_IS_FOLDER) - /* Icon with folder */ - Ico_PutIcon ("folder-yellow.png",Txt_Folder,"CONTEXT_ICO_16x16"); - else - /* Icon with file type or link */ - Brw_PutIconFile (FileMetadata.FilFolLnk.Type,FileMetadata.FilFolLnk.Name, - "CONTEXT_ICO_16x16",false); - HTM_TxtF (" %s",FileNameToShow); - HTM_BUTTON_End (); + /* File or folder icon */ + HTM_BUTTON_SUBMIT_Begin (FileNameToShow,"BT_LINK LT DAT_N",NULL); + if (FileMetadata.FilFolLnk.Type == Brw_IS_FOLDER) + /* Icon with folder */ + Ico_PutIcon ("folder-yellow.png",Txt_Folder,"CONTEXT_ICO_16x16"); + else + /* Icon with file type or link */ + Brw_PutIconFile (FileMetadata.FilFolLnk.Type,FileMetadata.FilFolLnk.Name, + "CONTEXT_ICO_16x16",false); + HTM_TxtF (" %s",FileNameToShow); + HTM_BUTTON_End (); - /* End form */ - Frm_EndForm (); + /* End form */ + Frm_EndForm (); - HTM_TD_End (); + HTM_TD_End (); HTM_TR_End (); Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; @@ -12258,30 +12245,30 @@ void Brw_AskRemoveOldFiles (void) Frm_BeginForm (ActRemOldBrf); Brw_PutHiddenParamFullTreeIfSelected (&Gbl.FileBrowser.FullTree); - /***** Begin box *****/ - Box_BoxBegin (NULL,Txt_Remove_old_files, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); + /***** Begin box *****/ + Box_BoxBegin (NULL,Txt_Remove_old_files, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Form to request number of months (to remove files older) *****/ - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_TxtF ("%s ",Txt_Remove_files_older_than_PART_1_OF_2); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"Months\""); - for (Months = Brw_MIN_MONTHS_TO_REMOVE_OLD_FILES; - Months <= Brw_MAX_MONTHS_IN_BRIEFCASE; - Months++) - HTM_OPTION (HTM_Type_UNSIGNED,&Months, - Months == Brw_DEF_MONTHS_TO_REMOVE_OLD_FILES,false, - "%u",Months); - HTM_SELECT_End (); - HTM_NBSP (); - HTM_TxtF (Txt_Remove_files_older_than_PART_2_OF_2, - Cfg_PLATFORM_SHORT_NAME); - HTM_LABEL_End (); + /***** Form to request number of months (to remove files older) *****/ + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_TxtF ("%s ",Txt_Remove_files_older_than_PART_1_OF_2); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"Months\""); + for (Months = Brw_MIN_MONTHS_TO_REMOVE_OLD_FILES; + Months <= Brw_MAX_MONTHS_IN_BRIEFCASE; + Months++) + HTM_OPTION (HTM_Type_UNSIGNED,&Months, + Months == Brw_DEF_MONTHS_TO_REMOVE_OLD_FILES,false, + "%u",Months); + HTM_SELECT_End (); + HTM_NBSP (); + HTM_TxtF (Txt_Remove_files_older_than_PART_2_OF_2, + Cfg_PLATFORM_SHORT_NAME); + HTM_LABEL_End (); - /***** Send button and end box *****/ - Box_BoxWithButtonEnd (Btn_REMOVE_BUTTON,Txt_Remove); + /***** Send button and end box *****/ + Box_BoxWithButtonEnd (Btn_REMOVE_BUTTON,Txt_Remove); /***** End form *****/ Frm_EndForm (); @@ -12355,9 +12342,9 @@ static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects * if (Removed->NumFiles || Removed->NumLinks || Removed->NumFolds) // If anything has been changed - Brw_RemoveAffectedClipboards (Gbl.FileBrowser.Type, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Usrs.Other.UsrDat.UsrCod); + Brw_DB_RemoveAffectedClipboards (Gbl.FileBrowser.Type, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Usrs.Other.UsrDat.UsrCod); } /*****************************************************************************/ diff --git a/swad_file_browser.h b/swad_file_browser.h index e8d76ee5..e2baa20d 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -217,7 +217,7 @@ void Brw_RecLinkFileBrowser (void); void Brw_SetDocumentAsVisible (void); void Brw_SetDocumentAsHidden (void); bool Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_FileType_t FileType,const char *Path); -bool Brw_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata); +bool Brw_DB_CheckIfFileOrFolderIsHidden (struct FileMetadata *FileMetadata); void Brw_ShowFileMetadata (void); void Brw_DownloadFile (void); void Brw_GetLinkToDownloadFile (const char *PathInTree,const char *FileName,char *URL); @@ -228,9 +228,9 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata); bool Brw_GetFileTypeSizeAndDate (struct FileMetadata *FileMetadata); void Brw_GetAndUpdateFileViews (struct FileMetadata *FileMetadata); void Brw_UpdateMyFileViews (long FilCod); -unsigned Brw_GetNumFileViewsUsr (long UsrCod); -unsigned Brw_GetNumFilesUsr (long UsrCod); -unsigned Brw_GetNumPublicFilesUsr (long UsrCod); +unsigned Brw_DB_GetNumFileViewsUsr (long UsrCod); +unsigned Brw_DB_GetNumFilesUsr (long UsrCod); +unsigned Brw_DB_GetNumPublicFilesUsr (long UsrCod); long Brw_GetCodForFiles (void); void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod, @@ -246,7 +246,7 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType, bool Brw_CheckIfICanViewProjectFiles (long PrjCod); -void Brw_RemoveExpiredExpandedFolders (void); +void Brw_DB_RemoveExpiredExpandedFolders (void); void Brw_CalcSizeOfDir (char *Path); diff --git a/swad_firewall.c b/swad_firewall.c index 1da74bbe..fb66129e 100644 --- a/swad_firewall.c +++ b/swad_firewall.c @@ -59,7 +59,7 @@ extern struct Globals Gbl; /****************************** Private prototypes ***************************/ /*****************************************************************************/ -static void Fir_BanIP (void); +static void Fir_DB_BanIP (void); static void Fir_WriteHTML (const char *Title,const char *H1); @@ -67,7 +67,7 @@ static void Fir_WriteHTML (const char *Title,const char *H1); /************************** Log access into firewall *************************/ /*****************************************************************************/ -void Fir_LogAccess (void) +void Fir_DB_LogAccess (void) { /***** Log access in firewall recent log *****/ DB_QueryINSERT ("can not log access into firewall_log", @@ -82,7 +82,7 @@ void Fir_LogAccess (void) /********************** Remove old clicks from firewall **********************/ /*****************************************************************************/ -void Fir_PurgeFirewall (void) +void Fir_DB_PurgeFirewall (void) { /***** Remove old clicks *****/ DB_QueryDELETE ("can not purge firewall log", @@ -150,7 +150,7 @@ void Fir_CheckFirewallAndExitIfTooManyRequests (void) if (NumClicks > Fw_MAX_CLICKS_IN_INTERVAL) { /* Ban this IP */ - Fir_BanIP (); + Fir_DB_BanIP (); /* Return status 429 Too Many Requests */ fprintf (stdout,"Content-Type: text/html; charset=windows-1252\n" @@ -169,7 +169,7 @@ void Fir_CheckFirewallAndExitIfTooManyRequests (void) /********************************* Ban an IP *********************************/ /*****************************************************************************/ -static void Fir_BanIP (void) +static void Fir_DB_BanIP (void) { /***** Insert IP into table of banned IPs *****/ DB_QueryINSERT ("can not ban IP", diff --git a/swad_firewall.h b/swad_firewall.h index efec23af..da946de2 100644 --- a/swad_firewall.h +++ b/swad_firewall.h @@ -35,8 +35,8 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Fir_LogAccess (void); -void Fir_PurgeFirewall (void); +void Fir_DB_LogAccess (void); +void Fir_DB_PurgeFirewall (void); void Fir_CheckFirewallAndExitIfBanned (void); void Fir_CheckFirewallAndExitIfTooManyRequests (void); diff --git a/swad_forum.c b/swad_forum.c index 23c0b1c2..6a2639aa 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -298,11 +298,11 @@ static const unsigned PermissionThreadDeletion[For_NUM_TYPES_FORUM] = /***************************** Private prototypes ***************************/ /*****************************************************************************/ -static bool For_GetIfForumPstExists (long PstCod); +static bool For_DB_GetIfForumPstExists (long PstCod); -static bool For_GetIfPstIsEnabled (long PstCod); -static void For_DeletePstFromDisabledPstTable (long PstCod); -static void For_InsertPstIntoBannedPstTable (long PstCod); +static bool For_DB_GetIfPstIsEnabled (long PstCod); +static void For_DB_RemovePstFromDisabledPstTable (long PstCod); +static void For_DB_InsertPstIntoBannedPstTable (long PstCod); static long For_InsertForumPst (long ThrCod,long UsrCod, const char *Subject,const char *Content, @@ -310,24 +310,24 @@ static long For_InsertForumPst (long ThrCod,long UsrCod, static bool For_RemoveForumPst (long PstCod,long MedCod); static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod); -static long For_InsertForumThread (const struct For_Forums *Forums, - long FirstPstCod); +static long For_DB_InsertForumThread (const struct For_Forums *Forums, + long FirstPstCod); static void For_RemoveThreadOnly (long ThrCod); static void For_RemoveThreadAndItsPsts (long ThrCod); static void For_GetThrSubject (long ThrCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]); -static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod); -static void For_UpdateThrLastPst (long ThrCod,long LastPstCod); +static void For_DB_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod); +static void For_DB_UpdateThrLastPst (long ThrCod,long LastPstCod); static long For_GetLastPstCod (long ThrCod); -static void For_UpdateThrReadTime (long ThrCod, - time_t CreatTimeUTCOfTheMostRecentPostRead); -static unsigned For_GetNumOfReadersOfThr (long ThrCod); -static unsigned For_GetNumOfWritersInThr (long ThrCod); -static unsigned For_GetNumPstsInThr (long ThrCod); -static unsigned For_GetNumMyPstInThr (long ThrCod); +static void For_DB_UpdateThrReadTime (long ThrCod, + time_t CreatTimeUTCOfTheMostRecentPostRead); +static unsigned For_DB_GetNumOfReadersOfThr (long ThrCod); +static unsigned For_DB_GetNumOfWritersInThr (long ThrCod); +static unsigned For_DB_GetNumPstsInThr (long ThrCod); +static unsigned For_DB_GetNumMyPstInThr (long ThrCod); static time_t For_GetThrReadTime (long ThrCod); -static void For_DeleteThrFromReadThrs (long ThrCod); +static void For_DB_RemoveThrFromReadThrs (long ThrCod); static void For_ShowPostsOfAThread (struct For_Forums *Forums, Ale_AlertType_t AlertType,const char *Message); static void For_PutIconNewPost (void *Forums); @@ -381,7 +381,7 @@ static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum, static unsigned For_GetNumOfThreadsInForumNewerThan (const struct For_Forum *Forum, const char *Time); static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr); -static unsigned For_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time); +static unsigned For_DB_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time); static void For_WriteNumberOfThrs (unsigned NumThrs); static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums, @@ -452,7 +452,7 @@ void For_EnablePost (void) For_GetParamsForums (&Forums); /***** Delete post from table of disabled posts *****/ - For_DeletePstFromDisabledPstTable (Forums.PstCod); + For_DB_RemovePstFromDisabledPstTable (Forums.PstCod); /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -477,10 +477,10 @@ void For_DisablePost (void) For_GetParamsForums (&Forums); /***** Check if post really exists, if it has not been removed *****/ - if (For_GetIfForumPstExists (Forums.PstCod)) + if (For_DB_GetIfForumPstExists (Forums.PstCod)) { /***** Insert post into table of banned posts *****/ - For_InsertPstIntoBannedPstTable (Forums.PstCod); + For_DB_InsertPstIntoBannedPstTable (Forums.PstCod); /***** Show forum list again *****/ For_ShowForumList (&Forums); @@ -499,7 +499,7 @@ void For_DisablePost (void) /******************** Get if a forum post exists in database *****************/ /*****************************************************************************/ -static bool For_GetIfForumPstExists (long PstCod) +static bool For_DB_GetIfForumPstExists (long PstCod) { /***** Get if a forum post exists from database *****/ return (DB_QueryCOUNT ("can not check if a post of a forum already existed", @@ -513,24 +513,25 @@ static bool For_GetIfForumPstExists (long PstCod) /*********************** Get if a forum post is enabled **********************/ /*****************************************************************************/ -static bool For_GetIfPstIsEnabled (long PstCod) +static bool For_DB_GetIfPstIsEnabled (long PstCod) { - if (PstCod > 0) - /***** Get if post is disabled from database *****/ - return (DB_QueryCOUNT ("can not check if a post of a forum is disabled", - "SELECT COUNT(*)" - " FROM for_disabled" - " WHERE PstCod=%ld", - PstCod) == 0); // Post is enabled if it does not appear in table of disabled posts - else + /***** Trivial check: post code should be > 0 *****/ + if (PstCod <= 0) return false; + + /***** Get if post is disabled from database *****/ + return (DB_QueryCOUNT ("can not check if a post of a forum is disabled", + "SELECT COUNT(*)" + " FROM for_disabled" + " WHERE PstCod=%ld", + PstCod) == 0); // Post is enabled if it does not appear in table of disabled posts } /*****************************************************************************/ -/****************** Delete post from table of disabled posts *****************/ +/****************** Remove post from table of disabled posts *****************/ /*****************************************************************************/ -static void For_DeletePstFromDisabledPstTable (long PstCod) +static void For_DB_RemovePstFromDisabledPstTable (long PstCod) { /***** Remove post from disabled posts table *****/ DB_QueryDELETE ("can not unban a post of a forum", @@ -543,7 +544,7 @@ static void For_DeletePstFromDisabledPstTable (long PstCod) /****************** Insert post into table of banned posts *******************/ /*****************************************************************************/ -static void For_InsertPstIntoBannedPstTable (long PstCod) +static void For_DB_InsertPstIntoBannedPstTable (long PstCod) { /***** Remove post from banned posts table *****/ DB_QueryREPLACE ("can not ban a post of a forum", @@ -612,11 +613,11 @@ static bool For_RemoveForumPst (long PstCod,long MedCod) PstCod); /***** Delete the post from the table of disabled forum posts *****/ - For_DeletePstFromDisabledPstTable (PstCod); + For_DB_RemovePstFromDisabledPstTable (PstCod); /***** Update the last post of the thread *****/ if (!ThreadDeleted) - For_UpdateThrLastPst (ThrCod,For_GetLastPstCod (ThrCod)); + For_DB_UpdateThrLastPst (ThrCod,For_GetLastPstCod (ThrCod)); return ThreadDeleted; } @@ -667,8 +668,8 @@ static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod) /*****************************************************************************/ // Returns the code of the new inserted thread -static long For_InsertForumThread (const struct For_Forums *Forums, - long FirstPstCod) +static long For_DB_InsertForumThread (const struct For_Forums *Forums, + long FirstPstCod) { /***** Insert new thread in the database *****/ return @@ -690,7 +691,7 @@ static long For_InsertForumThread (const struct For_Forums *Forums, static void For_RemoveThreadOnly (long ThrCod) { /***** Indicate that this thread has not been read by anyone *****/ - For_DeleteThrFromReadThrs (ThrCod); + For_DB_RemoveThrFromReadThrs (ThrCod); /***** Remove thread code from thread clipboard *****/ For_DB_RemoveThrCodFromThrClipboard (ThrCod); @@ -798,7 +799,7 @@ void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum) /********* Modify the codes of the first and last posts of a thread **********/ /*****************************************************************************/ -static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod) +static void For_DB_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long LastPstCod) { /***** Update the code of the first and last posts of a thread *****/ DB_QueryUPDATE ("can not update a thread of a forum", @@ -815,7 +816,7 @@ static void For_UpdateThrFirstAndLastPst (long ThrCod,long FirstPstCod,long Last /************** Modify the code of the last post of a thread *****************/ /*****************************************************************************/ -static void For_UpdateThrLastPst (long ThrCod,long LastPstCod) +static void For_DB_UpdateThrLastPst (long ThrCod,long LastPstCod) { /***** Update the code of the last post of a thread *****/ DB_QueryUPDATE ("can not update a thread of a forum", @@ -858,8 +859,8 @@ static long For_GetLastPstCod (long ThrCod) // Note that database is not updated with the current time, // but with the creation time of the most recent post in this thread read by me. -static void For_UpdateThrReadTime (long ThrCod, - time_t CreatTimeUTCOfTheMostRecentPostRead) +static void For_DB_UpdateThrReadTime (long ThrCod, + time_t CreatTimeUTCOfTheMostRecentPostRead) { /***** Insert or replace pair ThrCod-UsrCod in for_read *****/ DB_QueryREPLACE ("can not update the status of reading" @@ -877,7 +878,7 @@ static void For_UpdateThrReadTime (long ThrCod, /**************** Get number of users that have read a thread ****************/ /*****************************************************************************/ -static unsigned For_GetNumOfReadersOfThr (long ThrCod) +static unsigned For_DB_GetNumOfReadersOfThr (long ThrCod) { /***** Get number of distinct readers of a thread from database *****/ return (unsigned) @@ -892,7 +893,7 @@ static unsigned For_GetNumOfReadersOfThr (long ThrCod) /********** Get number of users that have write posts in a thread ************/ /*****************************************************************************/ -static unsigned For_GetNumOfWritersInThr (long ThrCod) +static unsigned For_DB_GetNumOfWritersInThr (long ThrCod) { /***** Get number of distinct writers in a thread from database *****/ return DB_QueryCOUNT ("can not get the number of writers in a thread of a forum", @@ -906,7 +907,7 @@ static unsigned For_GetNumOfWritersInThr (long ThrCod) /********************** Get number of posts in a thread **********************/ /*****************************************************************************/ -static unsigned For_GetNumPstsInThr (long ThrCod) +static unsigned For_DB_GetNumPstsInThr (long ThrCod) { /***** Get number of posts in a thread from database *****/ return (unsigned) @@ -921,7 +922,7 @@ static unsigned For_GetNumPstsInThr (long ThrCod) /************** Get whether there are posts of mine in a thread **************/ /*****************************************************************************/ -static unsigned For_GetNumMyPstInThr (long ThrCod) +static unsigned For_DB_GetNumMyPstInThr (long ThrCod) { /***** Get if I have write posts in a thread from database *****/ return (unsigned) @@ -938,7 +939,7 @@ static unsigned For_GetNumMyPstInThr (long ThrCod) /*********************** Get number of posts from a user *********************/ /*****************************************************************************/ -unsigned For_GetNumPostsUsr (long UsrCod) +unsigned For_DB_GetNumPostsUsr (long UsrCod) { /***** Get number of posts from a user from database *****/ return DB_QueryCOUNT ("can not get number of forum posts from a user", @@ -982,12 +983,12 @@ static time_t For_GetThrReadTime (long ThrCod) } /*****************************************************************************/ -/********************* Delete thread read status for a thread ****************/ +/********************* Remove thread read status for a thread ****************/ /*****************************************************************************/ -static void For_DeleteThrFromReadThrs (long ThrCod) +static void For_DB_RemoveThrFromReadThrs (long ThrCod) { - /***** Delete pairs ThrCod-UsrCod in for_read for a thread *****/ + /***** Remove pairs ThrCod-UsrCod in for_read for a thread *****/ DB_QueryDELETE ("can not remove the status of reading" " of a thread of a forum", "DELETE FROM for_read" @@ -1046,142 +1047,143 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums, /***** Show alert after action *****/ HTM_SECTION_Begin (For_FORUM_POSTS_SECTION_ID); - Ale_ShowAlerts (For_FORUM_POSTS_SECTION_ID); // Possible pending alerts - if (Message) - if (Message[0]) - Ale_ShowAlert (AlertType,Message); - /***** Begin box *****/ - snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s", - Txt_Thread,Thread.Subject); - Box_BoxBegin (NULL,FrameTitle, - For_PutIconNewPost,Forums, - Hlp_COMMUNICATION_Forums_posts,Box_NOT_CLOSABLE); + Ale_ShowAlerts (For_FORUM_POSTS_SECTION_ID); // Possible pending alerts + if (Message) + if (Message[0]) + Ale_ShowAlert (AlertType,Message); - /***** Get posts of a thread from database *****/ - NumPsts = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get posts of a thread", - "SELECT PstCod," // row[0] - "UNIX_TIMESTAMP(CreatTime)" // row[1] - " FROM for_posts" - " WHERE ThrCod=%ld" - " ORDER BY PstCod", - Thread.ThrCod); + /***** Begin box *****/ + snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s", + Txt_Thread,Thread.Subject); + Box_BoxBegin (NULL,FrameTitle, + For_PutIconNewPost,Forums, + Hlp_COMMUNICATION_Forums_posts,Box_NOT_CLOSABLE); - LastSubject[0] = '\0'; - if (NumPsts) // If there are posts... - { - /***** Check if I can moderate posts in forum *****/ - switch (Forums->Forum.Type) - { - case For_FORUM_GLOBAL_USRS: - case For_FORUM_GLOBAL_TCHS: - case For_FORUM__SWAD__USRS: - case For_FORUM__SWAD__TCHS: - ICanModerateForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); - break; - case For_FORUM_INSTIT_USRS: - case For_FORUM_INSTIT_TCHS: - ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM); - break; - case For_FORUM_CENTER_USRS: - case For_FORUM_CENTER_TCHS: - ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM); - break; - case For_FORUM_DEGREE_USRS: - case For_FORUM_DEGREE_TCHS: - case For_FORUM_COURSE_TCHS: - ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM); - break; - case For_FORUM_COURSE_USRS: - ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH); - break; - default: - ICanModerateForum = false; - break; - } + /***** Get posts of a thread from database *****/ + NumPsts = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get posts of a thread", + "SELECT PstCod," // row[0] + "UNIX_TIMESTAMP(CreatTime)" // row[1] + " FROM for_posts" + " WHERE ThrCod=%ld" + " ORDER BY PstCod", + Thread.ThrCod); - /***** Compute variables related to pagination *****/ - PaginationPsts.NumItems = NumPsts; - PaginationPsts.CurrentPage = (int) Forums->CurrentPagePsts; - Pag_CalculatePagination (&PaginationPsts); - PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID; - Forums->CurrentPagePsts = (unsigned) PaginationPsts.CurrentPage; + LastSubject[0] = '\0'; + if (NumPsts) // If there are posts... + { + /***** Check if I can moderate posts in forum *****/ + switch (Forums->Forum.Type) + { + case For_FORUM_GLOBAL_USRS: + case For_FORUM_GLOBAL_TCHS: + case For_FORUM__SWAD__USRS: + case For_FORUM__SWAD__TCHS: + ICanModerateForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); + break; + case For_FORUM_INSTIT_USRS: + case For_FORUM_INSTIT_TCHS: + ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM); + break; + case For_FORUM_CENTER_USRS: + case For_FORUM_CENTER_TCHS: + ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM); + break; + case For_FORUM_DEGREE_USRS: + case For_FORUM_DEGREE_TCHS: + case For_FORUM_COURSE_TCHS: + ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM); + break; + case For_FORUM_COURSE_USRS: + ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH); + break; + default: + ICanModerateForum = false; + break; + } - /***** Write links to pages *****/ - Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, - Forums,Thread.ThrCod); + /***** Compute variables related to pagination *****/ + PaginationPsts.NumItems = NumPsts; + PaginationPsts.CurrentPage = (int) Forums->CurrentPagePsts; + Pag_CalculatePagination (&PaginationPsts); + PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID; + Forums->CurrentPagePsts = (unsigned) PaginationPsts.CurrentPage; - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); + /***** Write links to pages *****/ + Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, + Forums,Thread.ThrCod); - /***** Show posts from this page, the author and the date of last reply *****/ - mysql_data_seek (mysql_res,(my_ulonglong) (PaginationPsts.FirstItemVisible - 1)); - for (NumRow = PaginationPsts.FirstItemVisible; - NumRow <= PaginationPsts.LastItemVisible; - NumRow++) - { - row = mysql_fetch_row (mysql_res); + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); - if (sscanf (row[0],"%ld",&Forums->PstCod) != 1) - Err_WrongPostExit (); + /***** Show posts from this page, the author and the date of last reply *****/ + mysql_data_seek (mysql_res,(my_ulonglong) (PaginationPsts.FirstItemVisible - 1)); + for (NumRow = PaginationPsts.FirstItemVisible; + NumRow <= PaginationPsts.LastItemVisible; + NumRow++) + { + row = mysql_fetch_row (mysql_res); - CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]); + if (sscanf (row[0],"%ld",&Forums->PstCod) != 1) + Err_WrongPostExit (); - NumPst = NumRow; - NewPst = (CreatTimeUTC > ReadTimeUTC); + CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]); - if (NewPst && NumRow == PaginationPsts.LastItemVisible) - /* Update for_read table indicating that this thread page and previous ones - have been read and have no new posts for the current user - (even if any previous pages have been no read actually). - Note that database is not updated with the current time, - but with the creation time of the most recent post - in this page of threads. */ - For_UpdateThrReadTime (Thread.ThrCod, - CreatTimeUTC); + NumPst = NumRow; + NewPst = (CreatTimeUTC > ReadTimeUTC); - /* Show post */ - For_ShowAForumPost (Forums,NumPst, - (NumRow == NumPsts),LastSubject, - NewPst,ICanModerateForum); + if (NewPst && NumRow == PaginationPsts.LastItemVisible) + /* Update for_read table indicating that this thread page and previous ones + have been read and have no new posts for the current user + (even if any previous pages have been no read actually). + Note that database is not updated with the current time, + but with the creation time of the most recent post + in this page of threads. */ + For_DB_UpdateThrReadTime (Thread.ThrCod,CreatTimeUTC); - /* Mark possible notification as seen */ - switch (Forums->Forum.Type) - { - case For_FORUM_COURSE_TCHS: - case For_FORUM_COURSE_USRS: - Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_POST_COURSE, - Forums->PstCod,Gbl.Hierarchy.Crs.CrsCod, - Gbl.Usrs.Me.UsrDat.UsrCod); - break; - default: - break; - } - if (Thread.NumMyPosts) - Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY, - Forums->PstCod,-1L, - Gbl.Usrs.Me.UsrDat.UsrCod); - } + /* Show post */ + For_ShowAForumPost (Forums,NumPst, + (NumRow == NumPsts),LastSubject, + NewPst,ICanModerateForum); - /***** End table *****/ - HTM_TABLE_End (); + /* Mark possible notification as seen */ + switch (Forums->Forum.Type) + { + case For_FORUM_COURSE_TCHS: + case For_FORUM_COURSE_USRS: + Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_POST_COURSE, + Forums->PstCod,Gbl.Hierarchy.Crs.CrsCod, + Gbl.Usrs.Me.UsrDat.UsrCod); + break; + default: + break; + } + if (Thread.NumMyPosts) + Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY, + Forums->PstCod,-1L, + Gbl.Usrs.Me.UsrDat.UsrCod); + } - /***** Write again links to pages *****/ - Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, - Forums,Thread.ThrCod); - } + /***** End table *****/ + HTM_TABLE_End (); - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); + /***** Write again links to pages *****/ + Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts, + Forums,Thread.ThrCod); + } - /***** Form to write a new post in the thread *****/ - HTM_SECTION_Begin (For_NEW_POST_SECTION_ID); - For_WriteFormForumPst (Forums,true,LastSubject); - HTM_SECTION_End (); + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + + /***** Form to write a new post in the thread *****/ + HTM_SECTION_Begin (For_NEW_POST_SECTION_ID); + For_WriteFormForumPst (Forums,true,LastSubject); + HTM_SECTION_End (); + + /***** End box *****/ + Box_BoxEnd (); - /***** End box *****/ - Box_BoxEnd (); HTM_SECTION_End (); } @@ -1245,7 +1247,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums, Med_MediaConstructor (&Media); /***** Check if post is enabled *****/ - Enabled = For_GetIfPstIsEnabled (Forums->PstCod); + Enabled = For_DB_GetIfPstIsEnabled (Forums->PstCod); /***** Get data of post *****/ For_GetPstData (Forums->PstCod,&UsrDat.UsrCod,&CreatTimeUTC, @@ -1257,37 +1259,37 @@ static void For_ShowAForumPost (struct For_Forums *Forums, HTM_TR_Begin (NULL); - /***** Put an icon with post status *****/ - HTM_TD_Begin ("class=\"CONTEXT_COL %s\"", - NewPst ? "MSG_TIT_BG_NEW" : - "MSG_TIT_BG"); - Ico_PutIcon (NewPst ? "envelope.svg" : - "envelope-open-text.svg", - NewPst ? Txt_MSG_New : - Txt_MSG_Open, - "ICO16x16"); - HTM_TD_End (); + /***** Put an icon with post status *****/ + HTM_TD_Begin ("class=\"CONTEXT_COL %s\"", + NewPst ? "MSG_TIT_BG_NEW" : + "MSG_TIT_BG"); + Ico_PutIcon (NewPst ? "envelope.svg" : + "envelope-open-text.svg", + NewPst ? Txt_MSG_New : + Txt_MSG_Open, + "ICO16x16"); + HTM_TD_End (); - /***** Write post number *****/ - Msg_WriteMsgNumber ((unsigned long) PstNum,NewPst); + /***** Write post number *****/ + Msg_WriteMsgNumber ((unsigned long) PstNum,NewPst); - /***** Write date *****/ - Msg_WriteMsgDate (CreatTimeUTC,NewPst ? "MSG_TIT_BG_NEW" : - "MSG_TIT_BG"); + /***** Write date *****/ + Msg_WriteMsgDate (CreatTimeUTC,NewPst ? "MSG_TIT_BG_NEW" : + "MSG_TIT_BG"); - /***** Write subject *****/ - HTM_TD_Begin ("class=\"%s LT\"",NewPst ? "MSG_TIT_BG_NEW" : - "MSG_TIT_BG"); - if (Enabled) - { - if (Subject[0]) - HTM_Txt (Subject); - else - HTM_TxtF ("[%s]",Txt_no_subject); - } - else - HTM_TxtF ("[%s]",Txt_FORUM_Post_banned); - HTM_TD_End (); + /***** Write subject *****/ + HTM_TD_Begin ("class=\"%s LT\"",NewPst ? "MSG_TIT_BG_NEW" : + "MSG_TIT_BG"); + if (Enabled) + { + if (Subject[0]) + HTM_Txt (Subject); + else + HTM_TxtF ("[%s]",Txt_no_subject); + } + else + HTM_TxtF ("[%s]",Txt_FORUM_Post_banned); + HTM_TD_End (); HTM_TR_End (); HTM_TR_Begin (NULL); @@ -1301,12 +1303,12 @@ static void For_ShowAForumPost (struct For_Forums *Forums, For_ActionsEnbPstFor[Forums->Forum.Type], For_FORUM_POSTS_SECTION_ID); For_PutParamsForum (Forums); - Ico_PutIconLink (Enabled ? "eye-green.svg" : - "eye-slash-red.svg", - Str_BuildStringLong (Enabled ? Txt_FORUM_Post_X_allowed_Click_to_ban_it : - Txt_FORUM_Post_X_banned_Click_to_unban_it, - (long) PstNum)); - Str_FreeString (); + Ico_PutIconLink (Enabled ? "eye-green.svg" : + "eye-slash-red.svg", + Str_BuildStringLong (Enabled ? Txt_FORUM_Post_X_allowed_Click_to_ban_it : + Txt_FORUM_Post_X_banned_Click_to_unban_it, + (long) PstNum)); + Str_FreeString (); Frm_EndForm (); } else @@ -1612,160 +1614,160 @@ static void For_ShowForumList (struct For_Forums *Forums) For_PutIconsForums,NULL, Hlp_COMMUNICATION_Forums,Box_NOT_CLOSABLE); - /***** Put a form to select which forums *****/ - For_PutFormWhichForums (Forums); + /***** Put a form to select which forums *****/ + For_PutFormWhichForums (Forums); - /***** Start list *****/ - HTM_UL_Begin ("class=\"LIST_TREE\""); + /***** Start list *****/ + HTM_UL_Begin ("class=\"LIST_TREE\""); - /***** Links to global forums *****/ - For_WriteLinksToGblForums (Forums,IsLastItemInLevel); - switch (Forums->ForumSet) - { - case For_ONLY_CURRENT_FORUMS: - if (Gbl.Hierarchy.Ins.InsCod > 0) + /***** Links to global forums *****/ + For_WriteLinksToGblForums (Forums,IsLastItemInLevel); + switch (Forums->ForumSet) { - if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) - ICanSeeInsForum = true; - else - ICanSeeInsForum = Usr_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod); - } - else - ICanSeeInsForum = false; - - /***** Links to forums about the platform *****/ - For_WriteLinksToPlatformForums (Forums,!ICanSeeInsForum,IsLastItemInLevel); - - if (ICanSeeInsForum) - { - if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) - ICanSeeCtrForum = true; - else - ICanSeeCtrForum = Usr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod); - - /***** Links to forums of current institution *****/ - if (For_WriteLinksToInsForums (Forums,Gbl.Hierarchy.Ins.InsCod, - true, - IsLastItemInLevel) > 0) - if (ICanSeeCtrForum) - { - if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) - ICanSeeDegForum = true; - else - ICanSeeDegForum = Usr_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod); - - /***** Links to forums of current center *****/ - if (For_WriteLinksToCtrForums (Forums, - Gbl.Hierarchy.Ctr.CtrCod, - true, - IsLastItemInLevel) > 0) - if (ICanSeeDegForum) - /***** Links to forums of current degree *****/ - if (For_WriteLinksToDegForums (Forums, - Gbl.Hierarchy.Deg.DegCod, - true, - IsLastItemInLevel) > 0) - if (Gbl.Usrs.Me.IBelongToCurrentCrs || - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) - /***** Links to forums of current degree *****/ - For_WriteLinksToCrsForums (Forums, - Gbl.Hierarchy.Crs.CrsCod, - true, - IsLastItemInLevel); - } - } - break; - case For_ALL_MY_FORUMS: - /***** Links to forums about the platform *****/ - For_WriteLinksToPlatformForums (Forums,(Gbl.Usrs.Me.MyInss.Num == 0),IsLastItemInLevel); - - /***** Links to forums of users from my institutions, the degrees in each institution and the courses in each degree *****/ - for (NumMyIns = 0; - NumMyIns < Gbl.Usrs.Me.MyInss.Num; - NumMyIns++) - { - InsCod = Gbl.Usrs.Me.MyInss.Inss[NumMyIns].InsCod; - - /* Links to forums of this institution */ - For_WriteLinksToInsForums (Forums, - InsCod, - (NumMyIns == Gbl.Usrs.Me.MyInss.Num - 1), - IsLastItemInLevel); - - /* Get my centers in this institution from database */ - NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, - InsCod,&mysql_resCtr); - for (NumCtr = 0; - NumCtr < NumCtrs; - NumCtr++) - { - /* Get next center */ - row = mysql_fetch_row (mysql_resCtr); - CtrCod = Str_ConvertStrCodToLongCod (row[0]); - - /* Links to forums of this center */ - if (For_WriteLinksToCtrForums (Forums, - CtrCod, - (NumCtr == NumCtrs - 1), - IsLastItemInLevel) > 0) + case For_ONLY_CURRENT_FORUMS: + if (Gbl.Hierarchy.Ins.InsCod > 0) { - /* Get my degrees in this institution from database */ - if ((NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, - CtrCod, - &mysql_resDeg)) > 0) // Degrees found in this center - for (NumDeg = 0; - NumDeg < NumDegs; - NumDeg++) + if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) + ICanSeeInsForum = true; + else + ICanSeeInsForum = Usr_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod); + } + else + ICanSeeInsForum = false; + + /***** Links to forums about the platform *****/ + For_WriteLinksToPlatformForums (Forums,!ICanSeeInsForum,IsLastItemInLevel); + + if (ICanSeeInsForum) + { + if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) + ICanSeeCtrForum = true; + else + ICanSeeCtrForum = Usr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod); + + /***** Links to forums of current institution *****/ + if (For_WriteLinksToInsForums (Forums,Gbl.Hierarchy.Ins.InsCod, + true, + IsLastItemInLevel) > 0) + if (ICanSeeCtrForum) { - /* Get next degree */ - row = mysql_fetch_row (mysql_resDeg); - DegCod = Str_ConvertStrCodToLongCod (row[0]); + if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) + ICanSeeDegForum = true; + else + ICanSeeDegForum = Usr_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod); - /* Links to forums of this degree */ - if (For_WriteLinksToDegForums (Forums, - DegCod, - (NumDeg == NumDegs - 1), + /***** Links to forums of current center *****/ + if (For_WriteLinksToCtrForums (Forums, + Gbl.Hierarchy.Ctr.CtrCod, + true, IsLastItemInLevel) > 0) - { - /* Get my courses in this degree from database */ - NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, - DegCod, - &mysql_resCrs); - for (NumCrs = 0; - NumCrs < NumCrss; - NumCrs++) - { - /* Get next course */ - row = mysql_fetch_row (mysql_resCrs); - CrsCod = Str_ConvertStrCodToLongCod (row[0]); + if (ICanSeeDegForum) + /***** Links to forums of current degree *****/ + if (For_WriteLinksToDegForums (Forums, + Gbl.Hierarchy.Deg.DegCod, + true, + IsLastItemInLevel) > 0) + if (Gbl.Usrs.Me.IBelongToCurrentCrs || + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) + /***** Links to forums of current degree *****/ + For_WriteLinksToCrsForums (Forums, + Gbl.Hierarchy.Crs.CrsCod, + true, + IsLastItemInLevel); + } + } + break; + case For_ALL_MY_FORUMS: + /***** Links to forums about the platform *****/ + For_WriteLinksToPlatformForums (Forums,(Gbl.Usrs.Me.MyInss.Num == 0),IsLastItemInLevel); - /* Links to forums of this course */ - For_WriteLinksToCrsForums (Forums, - CrsCod, - (NumCrs == NumCrss - 1), - IsLastItemInLevel); + /***** Links to forums of users from my institutions, the degrees in each institution and the courses in each degree *****/ + for (NumMyIns = 0; + NumMyIns < Gbl.Usrs.Me.MyInss.Num; + NumMyIns++) + { + InsCod = Gbl.Usrs.Me.MyInss.Inss[NumMyIns].InsCod; + + /* Links to forums of this institution */ + For_WriteLinksToInsForums (Forums, + InsCod, + (NumMyIns == Gbl.Usrs.Me.MyInss.Num - 1), + IsLastItemInLevel); + + /* Get my centers in this institution from database */ + NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, + InsCod,&mysql_resCtr); + for (NumCtr = 0; + NumCtr < NumCtrs; + NumCtr++) + { + /* Get next center */ + row = mysql_fetch_row (mysql_resCtr); + CtrCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Links to forums of this center */ + if (For_WriteLinksToCtrForums (Forums, + CtrCod, + (NumCtr == NumCtrs - 1), + IsLastItemInLevel) > 0) + { + /* Get my degrees in this institution from database */ + if ((NumDegs = Usr_GetDegsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, + CtrCod, + &mysql_resDeg)) > 0) // Degrees found in this center + for (NumDeg = 0; + NumDeg < NumDegs; + NumDeg++) + { + /* Get next degree */ + row = mysql_fetch_row (mysql_resDeg); + DegCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Links to forums of this degree */ + if (For_WriteLinksToDegForums (Forums, + DegCod, + (NumDeg == NumDegs - 1), + IsLastItemInLevel) > 0) + { + /* Get my courses in this degree from database */ + NumCrss = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod, + DegCod, + &mysql_resCrs); + for (NumCrs = 0; + NumCrs < NumCrss; + NumCrs++) + { + /* Get next course */ + row = mysql_fetch_row (mysql_resCrs); + CrsCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Links to forums of this course */ + For_WriteLinksToCrsForums (Forums, + CrsCod, + (NumCrs == NumCrss - 1), + IsLastItemInLevel); + } + + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_resCrs); + } } - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_resCrs); - } + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_resDeg); } + } /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_resDeg); + DB_FreeMySQLResult (&mysql_resCtr); } - } + break; + default: + break; + } - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_resCtr); - } - break; - default: - break; - } - - /***** End list *****/ - HTM_UL_End (); + /***** End list *****/ + HTM_UL_End (); /***** End box *****/ Box_BoxEnd (); @@ -1795,26 +1797,27 @@ static void For_PutFormWhichForums (const struct For_Forums *Forums) - only the forums of current institution/degree/course *****/ Frm_BeginForm (ActSeeFor); Dat_PutHiddenParamOrder (Forums->ThreadsOrder); - HTM_DIV_Begin ("class=\"SEL_BELOW_TITLE\""); - HTM_UL_Begin (NULL); + HTM_DIV_Begin ("class=\"SEL_BELOW_TITLE\""); + HTM_UL_Begin (NULL); - for (ForumSet = (For_ForumSet_t) 0; - ForumSet <= (For_ForumSet_t) (For_NUM_FORUM_SETS - 1); - ForumSet++) - { - HTM_LI_Begin (NULL); - HTM_LABEL_Begin (NULL); - HTM_INPUT_RADIO ("ForumSet",true, - "value=\"%u\"%s", - (unsigned) ForumSet, - (ForumSet == Forums->ForumSet) ? " checked=\"checked\"" : - ""); - HTM_Txt (Txt_FORUM_WHICH_FORUM[ForumSet]); - HTM_LABEL_End (); - HTM_LI_End (); - } - HTM_UL_End (); - HTM_DIV_End (); + for (ForumSet = (For_ForumSet_t) 0; + ForumSet <= (For_ForumSet_t) (For_NUM_FORUM_SETS - 1); + ForumSet++) + { + HTM_LI_Begin (NULL); + HTM_LABEL_Begin (NULL); + HTM_INPUT_RADIO ("ForumSet",true, + "value=\"%u\"%s", + (unsigned) ForumSet, + (ForumSet == Forums->ForumSet) ? " checked=\"checked\"" : + ""); + HTM_Txt (Txt_FORUM_WHICH_FORUM[ForumSet]); + HTM_LABEL_End (); + HTM_LI_End (); + } + + HTM_UL_End (); + HTM_DIV_End (); Frm_EndForm (); } @@ -2090,87 +2093,89 @@ static void For_WriteLinkToForum (const struct For_Forums *Forums, HTM_LI_Begin (Highlight ? "class=\"LIGHT_BLUE\"" : NULL); - /***** Indent forum title *****/ - Lay_IndentDependingOnLevel (Level,IsLastItemInLevel); + /***** Indent forum title *****/ + Lay_IndentDependingOnLevel (Level,IsLastItemInLevel); - /***** Write paste button used to move a thread in clipboard to this forum *****/ - if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted... - { - /* Check if thread to move is yet in current forum */ - if (For_DB_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum)) - Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16"); - else - { - Frm_StartFormAnchor (For_ActionsPasThrFor[Forum->Type], - For_FORUM_THREADS_SECTION_ID); - For_PutAllHiddenParamsForum (1, // Page of threads = first - 1, // Page of posts = first - Forums->ForumSet, - Forums->ThreadsOrder, - Forum->Location, - Forums->Thread.ToMove, - -1L); - Ico_PutIconPaste (); - Frm_EndForm (); - } - } + /***** Write paste button used to move a thread in clipboard to this forum *****/ + if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted... + { + /* Check if thread to move is yet in current forum */ + if (For_DB_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum)) + Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16"); + else + { + Frm_StartFormAnchor (For_ActionsPasThrFor[Forum->Type], + For_FORUM_THREADS_SECTION_ID); + For_PutAllHiddenParamsForum (1, // Page of threads = first + 1, // Page of posts = first + Forums->ForumSet, + Forums->ThreadsOrder, + Forum->Location, + Forums->Thread.ToMove, + -1L); + Ico_PutIconPaste (); + Frm_EndForm (); + } + } - /***** Write link to forum *****/ - Frm_StartFormAnchor (For_ActionsSeeFor[Forum->Type], - For_FORUM_THREADS_SECTION_ID); - For_PutAllHiddenParamsForum (1, // Page of threads = first - 1, // Page of posts = first - Forums->ForumSet, - Forums->ThreadsOrder, - Forum->Location, - -1L, - -1L); + /***** Write link to forum *****/ + Frm_StartFormAnchor (For_ActionsSeeFor[Forum->Type], + For_FORUM_THREADS_SECTION_ID); + For_PutAllHiddenParamsForum (1, // Page of threads = first + 1, // Page of posts = first + Forums->ForumSet, + Forums->ThreadsOrder, + Forum->Location, + -1L, + -1L); - HTM_BUTTON_SUBMIT_Begin (Act_GetActionText (For_ActionsSeeFor[Forum->Type]), - Class,NULL); - For_SetForumName (Forum,ForumName,Gbl.Prefs.Language,true); - switch (Forum->Type) - { - case For_FORUM_GLOBAL_USRS: - case For_FORUM_GLOBAL_TCHS: - Ico_PutIcon ("comments.svg",ForumName,"ICO16x16"); - break; - case For_FORUM__SWAD__USRS: - case For_FORUM__SWAD__TCHS: - Ico_PutIcon ("swad64x64.png",ForumName,"ICO16x16"); - break; - case For_FORUM_INSTIT_USRS: - case For_FORUM_INSTIT_TCHS: - Lgo_DrawLogo (HieLvl_INS,Forum->Location,ForumName,16,NULL,true); - break; - case For_FORUM_CENTER_USRS: - case For_FORUM_CENTER_TCHS: - Lgo_DrawLogo (HieLvl_CTR,Forum->Location,ForumName,16,NULL,true); - break; - case For_FORUM_DEGREE_USRS: - case For_FORUM_DEGREE_TCHS: - Lgo_DrawLogo (HieLvl_DEG,Forum->Location,ForumName,16,NULL,true); - break; - case For_FORUM_COURSE_USRS: - case For_FORUM_COURSE_TCHS: - Ico_PutIcon ("chalkboard-teacher.svg",ForumName,"ICO16x16"); - break; - default: - break; - } - HTM_TxtF (" %s",ForumName); + HTM_BUTTON_SUBMIT_Begin (Act_GetActionText (For_ActionsSeeFor[Forum->Type]), + Class,NULL); - /***** Write total number of threads and posts in this forum *****/ - if (NumThrs) - For_WriteNumberOfThrs (NumThrs); + For_SetForumName (Forum,ForumName,Gbl.Prefs.Language,true); + switch (Forum->Type) + { + case For_FORUM_GLOBAL_USRS: + case For_FORUM_GLOBAL_TCHS: + Ico_PutIcon ("comments.svg",ForumName,"ICO16x16"); + break; + case For_FORUM__SWAD__USRS: + case For_FORUM__SWAD__TCHS: + Ico_PutIcon ("swad64x64.png",ForumName,"ICO16x16"); + break; + case For_FORUM_INSTIT_USRS: + case For_FORUM_INSTIT_TCHS: + Lgo_DrawLogo (HieLvl_INS,Forum->Location,ForumName,16,NULL,true); + break; + case For_FORUM_CENTER_USRS: + case For_FORUM_CENTER_TCHS: + Lgo_DrawLogo (HieLvl_CTR,Forum->Location,ForumName,16,NULL,true); + break; + case For_FORUM_DEGREE_USRS: + case For_FORUM_DEGREE_TCHS: + Lgo_DrawLogo (HieLvl_DEG,Forum->Location,ForumName,16,NULL,true); + break; + case For_FORUM_COURSE_USRS: + case For_FORUM_COURSE_TCHS: + Ico_PutIcon ("chalkboard-teacher.svg",ForumName,"ICO16x16"); + break; + default: + break; + } + HTM_TxtF (" %s",ForumName); - /***** End row *****/ - HTM_BUTTON_End (); - Frm_EndForm (); + /***** Write total number of threads and posts in this forum *****/ + if (NumThrs) + For_WriteNumberOfThrs (NumThrs); - /***** Put link to register students *****/ - if (Forum->Type == For_FORUM_COURSE_USRS) - Enr_PutButtonInlineToRegisterStds (Forum->Location); + /***** End row *****/ + HTM_BUTTON_End (); + + Frm_EndForm (); + + /***** Put link to register students *****/ + if (Forum->Type == For_FORUM_COURSE_USRS) + Enr_PutButtonInlineToRegisterStds (Forum->Location); HTM_LI_End (); } @@ -2369,7 +2374,7 @@ static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr { /***** Get the number of posts in thread with a modify time > newest read time for me (row[0]) *****/ row = mysql_fetch_row (mysql_res); - NumUnreadPosts = For_GetNumOfPostsInThrNewerThan (ThrCod,row[0]); + NumUnreadPosts = For_DB_GetNumOfPostsInThrNewerThan (ThrCod,row[0]); } /***** Free structure that stores the query result *****/ @@ -2382,7 +2387,7 @@ static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr /**** Get number of posts in thread with a modify time > a specified time ****/ /*****************************************************************************/ -static unsigned For_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time) +static unsigned For_DB_GetNumOfPostsInThrNewerThan (long ThrCod,const char *Time) { /***** Get the number of posts in thread with a modify time > a specified time from database *****/ return (unsigned) @@ -2520,83 +2525,85 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums /***** Show alert after action *****/ HTM_SECTION_Begin (For_FORUM_THREADS_SECTION_ID); - if (Message) - if (Message[0]) - Ale_ShowAlert (AlertType,Message); - /***** Begin box for threads of this forum *****/ - snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",Txt_Forum,ForumName); - Box_BoxBegin (NULL,FrameTitle, - For_PutIconNewThread,Forums, - Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE); + if (Message) + if (Message[0]) + Ale_ShowAlert (AlertType,Message); - /***** List the threads *****/ - if (NumThrs) - { - /***** Write links to all the pages in the listing of threads *****/ - Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs, - Forums,-1L); + /***** Begin box for threads of this forum *****/ + snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",Txt_Forum,ForumName); + Box_BoxBegin (NULL,FrameTitle, + For_PutIconNewThread,Forums, + Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE); - /***** Heading row *****/ - HTM_TABLE_BeginWideMarginPadding (2); - HTM_TR_Begin (NULL); + /***** List the threads *****/ + if (NumThrs) + { + /***** Write links to all the pages in the listing of threads *****/ + Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs, + Forums,-1L); - HTM_TH (1,1,"BT",NULL); - HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons - HTM_TH (1,1,"LM",Txt_MSG_Subject); + /***** Heading row *****/ + HTM_TABLE_BeginWideMarginPadding (2); + HTM_TR_Begin (NULL); - for (Order = Dat_START_TIME; - Order <= Dat_END_TIME; - Order++) - { - HTM_TH_Begin (1,2,"CM"); + HTM_TH (1,1,"BT",NULL); + HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons + HTM_TH (1,1,"LM",Txt_MSG_Subject); - Frm_StartFormAnchor (For_ActionsSeeFor[Forums->Forum.Type], - For_FORUM_THREADS_SECTION_ID); - For_PutAllHiddenParamsForum (Forums->CurrentPageThrs, // Page of threads = current - 1, // Page of posts = first - Forums->ForumSet, - Order, - Forums->Forum.Location, - -1L, - -1L); - HTM_BUTTON_SUBMIT_Begin (Txt_FORUM_THREAD_HELP_ORDER[Order],"BT_LINK TIT_TBL",NULL); - if (Order == Forums->ThreadsOrder) - HTM_U_Begin (); - HTM_Txt (Txt_FORUM_THREAD_ORDER[Order]); - if (Order == Forums->ThreadsOrder) - HTM_U_End (); - HTM_BUTTON_End (); - Frm_EndForm (); + for (Order = Dat_START_TIME; + Order <= Dat_END_TIME; + Order++) + { + HTM_TH_Begin (1,2,"CM"); - HTM_TH_End (); - } + Frm_StartFormAnchor (For_ActionsSeeFor[Forums->Forum.Type], + For_FORUM_THREADS_SECTION_ID); + For_PutAllHiddenParamsForum (Forums->CurrentPageThrs, // Page of threads = current + 1, // Page of posts = first + Forums->ForumSet, + Order, + Forums->Forum.Location, + -1L, + -1L); + HTM_BUTTON_SUBMIT_Begin (Txt_FORUM_THREAD_HELP_ORDER[Order],"BT_LINK TIT_TBL",NULL); + if (Order == Forums->ThreadsOrder) + HTM_U_Begin (); + HTM_Txt (Txt_FORUM_THREAD_ORDER[Order]); + if (Order == Forums->ThreadsOrder) + HTM_U_End (); + HTM_BUTTON_End (); + Frm_EndForm (); - HTM_TH (1,1,"RM",Txt_Number_BR_msgs); - HTM_TH (1,1,"RM",Txt_Unread_BR_msgs); - HTM_TH (1,1,"RM",Txt_WriBRters); - HTM_TH (1,1,"RM",Txt_ReaBRders); + HTM_TH_End (); + } - HTM_TR_End (); + HTM_TH (1,1,"RM",Txt_Number_BR_msgs); + HTM_TH (1,1,"RM",Txt_Unread_BR_msgs); + HTM_TH (1,1,"RM",Txt_WriBRters); + HTM_TH (1,1,"RM",Txt_ReaBRders); - /***** List the threads *****/ - For_ListForumThrs (Forums,ThrCods,Forums->Thread.Current,&PaginationThrs); + HTM_TR_End (); - /***** End table *****/ - HTM_TABLE_End (); + /***** List the threads *****/ + For_ListForumThrs (Forums,ThrCods,Forums->Thread.Current,&PaginationThrs); - /***** Write links to all the pages in the listing of threads *****/ - Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs, - Forums,-1L); - } + /***** End table *****/ + HTM_TABLE_End (); - /***** Put a form to write the first post of a new thread *****/ - HTM_SECTION_Begin (For_NEW_THREAD_SECTION_ID); - For_WriteFormForumPst (Forums,false,NULL); - HTM_SECTION_End (); + /***** Write links to all the pages in the listing of threads *****/ + Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs, + Forums,-1L); + } + + /***** Put a form to write the first post of a new thread *****/ + HTM_SECTION_Begin (For_NEW_THREAD_SECTION_ID); + For_WriteFormForumPst (Forums,false,NULL); + HTM_SECTION_End (); + + /***** End box with threads of this forum ****/ + Box_BoxEnd (); - /***** End box with threads of this forum ****/ - Box_BoxEnd (); HTM_SECTION_End (); } @@ -2631,8 +2638,12 @@ static void For_PutAllHiddenParamsNewThread (void *Forums) /********************** Get number of forums of a type ***********************/ /*****************************************************************************/ -unsigned For_GetNumTotalForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod) +unsigned For_DB_GetNumTotalForumsOfType (For_ForumType_t ForumType, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod) { /***** Get number of forums of a type from database *****/ switch (ForumType) @@ -2881,8 +2892,12 @@ unsigned For_GetNumTotalForumsOfType (For_ForumType_t ForumType, /*********** Get total number of threads in forums of this type **************/ /*****************************************************************************/ -unsigned For_GetNumTotalThrsInForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod) +unsigned For_DB_GetNumTotalThrsInForumsOfType (For_ForumType_t ForumType, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod) { /***** Get total number of threads in forums of this type from database *****/ switch (ForumType) @@ -3160,7 +3175,11 @@ static unsigned For_GetNumThrsInForum (const struct For_Forum *Forum) /*****************************************************************************/ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod, unsigned *NumUsrsToBeNotifiedByEMail) { MYSQL_RES *mysql_res; @@ -3718,23 +3737,23 @@ static void For_GetThreadData (struct For_Thread *Thr) for (Order = Dat_START_TIME; Order <= Dat_END_TIME; Order++) - Thr->Enabled[Order] = For_GetIfPstIsEnabled (Thr->PstCod[Order]); + Thr->Enabled[Order] = For_DB_GetIfPstIsEnabled (Thr->PstCod[Order]); // Thr->Enabled[Order] = true; /***** Get number of posts in this thread *****/ - Thr->NumPosts = For_GetNumPstsInThr (Thr->ThrCod); + Thr->NumPosts = For_DB_GetNumPstsInThr (Thr->ThrCod); /***** Get number of unread (by me) posts in this thread *****/ Thr->NumUnreadPosts = For_GetNumOfUnreadPostsInThr (Thr->ThrCod,Thr->NumPosts); /***** Get number of posts that I have written in this thread *****/ - Thr->NumMyPosts = For_GetNumMyPstInThr (Thr->ThrCod); + Thr->NumMyPosts = For_DB_GetNumMyPstInThr (Thr->ThrCod); /***** Get number of users who have write posts in this thread *****/ - Thr->NumWriters = For_GetNumOfWritersInThr (Thr->ThrCod); + Thr->NumWriters = For_DB_GetNumOfWritersInThr (Thr->ThrCod); /***** Get number of users who have read this thread *****/ - Thr->NumReaders = For_GetNumOfReadersOfThr (Thr->ThrCod); + Thr->NumReaders = For_DB_GetNumOfReadersOfThr (Thr->ThrCod); } /*****************************************************************************/ @@ -4052,37 +4071,37 @@ static void For_WriteFormForumPst (struct For_Forums *Forums, /***** Subject and content *****/ HTM_TABLE_BeginCenterPadding (2); - // If writing a reply to a message of an existing thread ==> write subject - /* Subject */ - HTM_TR_Begin (NULL); + // If writing a reply to a message of an existing thread ==> write subject + /* Subject */ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Subject",Txt_MSG_Subject); + /* Label */ + Frm_LabelColumn ("RT","Subject",Txt_MSG_Subject); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_INPUT_TEXT ("Subject",Cns_MAX_CHARS_SUBJECT, - IsReply ? Subject : - "", - HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Subject\" class=\"MSG_SUBJECT\" required=\"required\""); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_INPUT_TEXT ("Subject",Cns_MAX_CHARS_SUBJECT, + IsReply ? Subject : + "", + HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Subject\" class=\"MSG_SUBJECT\" required=\"required\""); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); - /* Content */ - HTM_TR_Begin (NULL); + /* Content */ + HTM_TR_Begin (NULL); - /* Label */ - Frm_LabelColumn ("RT","Content",Txt_MSG_Content); + /* Label */ + Frm_LabelColumn ("RT","Content",Txt_MSG_Content); - /* Data */ - HTM_TD_Begin ("class=\"LT\""); - HTM_TEXTAREA_Begin ("id=\"Content\" name=\"Content\" class=\"MSG_CONTENT\" rows=\"10\""); - HTM_TEXTAREA_End (); - HTM_TD_End (); + /* Data */ + HTM_TD_Begin ("class=\"LT\""); + HTM_TEXTAREA_Begin ("id=\"Content\" name=\"Content\" class=\"MSG_CONTENT\" rows=\"10\""); + HTM_TEXTAREA_End (); + HTM_TD_End (); - HTM_TR_End (); + HTM_TR_End (); HTM_TABLE_End (); @@ -4159,20 +4178,20 @@ void For_ReceiveForumPost (void) Subject,Content,&Media); /***** Modify last message of the thread *****/ - For_UpdateThrLastPst (Forums.Thread.Current,PstCod); + For_DB_UpdateThrLastPst (Forums.Thread.Current,PstCod); } else // This post is the first of a new thread { /***** Create new thread with unknown first and last message codes *****/ Forums.Thread.Current = - Forums.Thread.Selected = For_InsertForumThread (&Forums,-1L); + Forums.Thread.Selected = For_DB_InsertForumThread (&Forums,-1L); /***** Create first (and last) message of the thread *****/ PstCod = For_InsertForumPst (Forums.Thread.Current,Gbl.Usrs.Me.UsrDat.UsrCod, Subject,Content,&Media); /***** Update first and last posts of new thread *****/ - For_UpdateThrFirstAndLastPst (Forums.Thread.Current,PstCod,PstCod); + For_DB_UpdateThrFirstAndLastPst (Forums.Thread.Current,PstCod,PstCod); } /***** Free media *****/ @@ -4266,7 +4285,7 @@ void For_RemovePost (void) /***** Check if I can remove the post *****/ /* Check if the message really exists, if it has not been removed */ - if (!For_GetIfForumPstExists (Forums.PstCod)) + if (!For_DB_GetIfForumPstExists (Forums.PstCod)) Err_WrongPostExit (); /* Check if I am the author of the message */ @@ -4340,19 +4359,19 @@ void For_RequestRemoveThread (void) /***** Show question and button to remove the thread *****/ HTM_SECTION_Begin (For_REMOVE_THREAD_SECTION_ID); - if (Subject[0]) - Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type], - For_FORUM_THREADS_SECTION_ID,NULL, - For_PutAllHiddenParamsRemThread,&Forums, - Btn_REMOVE_BUTTON,Txt_Remove_thread, - Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread_X, - Subject); - else - Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type], - For_FORUM_THREADS_SECTION_ID,NULL, - For_PutAllHiddenParamsRemThread,&Forums, - Btn_REMOVE_BUTTON,Txt_Remove_thread, - Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread); + if (Subject[0]) + Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type], + For_FORUM_THREADS_SECTION_ID,NULL, + For_PutAllHiddenParamsRemThread,&Forums, + Btn_REMOVE_BUTTON,Txt_Remove_thread, + Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread_X, + Subject); + else + Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type], + For_FORUM_THREADS_SECTION_ID,NULL, + For_PutAllHiddenParamsRemThread,&Forums, + Btn_REMOVE_BUTTON,Txt_Remove_thread, + Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread); HTM_SECTION_End (); /***** Show the threads again *****/ @@ -4549,6 +4568,7 @@ static bool For_DB_CheckIfThrBelongsToForum (long ThrCod,const struct For_Forum sprintf (SubQuery," AND for_threads.Location=%ld",Forum->Location); else SubQuery[0] = '\0'; + return (DB_QueryCOUNT ("can not get if a thread belong to current forum", "SELECT COUNT(*)" " FROM for_threads" diff --git a/swad_forum.h b/swad_forum.h index 438f5865..a8cd4e6b 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -122,7 +122,7 @@ void For_DisablePost (void); void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum); -unsigned For_GetNumPostsUsr (long UsrCod); +unsigned For_DB_GetNumPostsUsr (long UsrCod); void For_DB_RemoveUsrFromReadThrs (long UsrCod); void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], @@ -142,12 +142,24 @@ void For_SetForumName (const struct For_Forum *Forum, Lan_Language_t Language,bool UseHTMLEntities); void For_ShowForumTheads (void); -unsigned For_GetNumTotalForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod); -unsigned For_GetNumTotalThrsInForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod); +unsigned For_DB_GetNumTotalForumsOfType (For_ForumType_t ForumType, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod); +unsigned For_DB_GetNumTotalThrsInForumsOfType (For_ForumType_t ForumType, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod); unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType, - long CtyCod,long InsCod,long CtrCod,long DegCod,long CrsCod, + long CtyCod, + long InsCod, + long CtrCod, + long DegCod, + long CrsCod, unsigned *NumUsrsToBeNotifiedByEMail); void For_ShowThreadPosts (void); diff --git a/swad_group.c b/swad_group.c index add74995..50a4d877 100644 --- a/swad_group.c +++ b/swad_group.c @@ -107,13 +107,13 @@ static void Grp_PutIconToCreateNewGroup (void); static void Grp_PutCheckboxAllGrps (Grp_WhichGroups_t GroupsSelectableByStdsOrNETs); -static void Grp_LockTables (void); -static void Grp_UnlockTables (void); +static void Grp_DB_LockTables (void); +static void Grp_DB_UnlockTables (void); static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType); static void Grp_DestructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **AlreadyExistsGroupOfType); static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod); -static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod); +static void Grp_DB_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod); static void Grp_ListGroupTypesForEdition (void); static void Grp_PutIconsEditingGroupTypes (__attribute__((unused)) void *Args); @@ -123,8 +123,8 @@ static void Grp_WriteHeadingGroupTypes (void); static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms); static void Grp_WriteHeadingGroups (void); -static bool Grp_CheckIfAssociatedToGrp (const char *Table,const char *Field, - long Cod,long GrpCod); +static bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, + long Cod,long GrpCod); static void Grp_PutIconToEditGroups (__attribute__((unused)) void *Args); static void Grp_ShowWarningToStdsToChangeGrps (void); @@ -137,20 +137,20 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp); static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight); static void Grp_PutFormToCreateGroupType (void); static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms); -static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod); +static unsigned Grp_DB_CountNumGrpsInThisCrsOfType (long GrpTypCod); static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp); static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod); -static long Grp_GetTypeOfGroupOfAGroup (long GrpCod); -static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod); -static bool Grp_CheckIfIBelongToGrpsOfType (long GrpTypCod); +static long Grp_DB_GetTypeOfGroupOfAGroup (long GrpCod); +static unsigned Grp_DB_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod); +static bool Grp_DB_CheckIfIBelongToGrpsOfType (long GrpTypCod); static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,long UsrCod, struct ListCodGrps *LstGrps); static bool Grp_CheckIfGrpIsInList (long GrpCod,struct ListCodGrps *LstGrps); static bool Grp_CheckIfOpenTimeInTheFuture (time_t OpenTimeUTC); -static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod); -static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod); -static void Grp_CreateGroupType (void); -static void Grp_CreateGroup (void); +static bool Grp_DB_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod); +static bool Grp_DB_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod); +static long Grp_DB_CreateGroupType (const struct GroupType *GrpTyp); +static void Grp_DB_CreateGroup (void); static void Grp_AskConfirmRemGrpTypWithGrps (unsigned NumGrps); static void Grp_AskConfirmRemGrp (void); @@ -237,16 +237,16 @@ static void Grp_ReqEditGroupsInternal0 (void) static void Grp_ReqEditGroupsInternal1 (Ale_AlertType_t AlertTypeGroupTypes, const char *AlertTextGroupTypes) { - /***** Get list of groups types and groups in this course *****/ - Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ALL_GROUP_TYPES); + /***** Get list of groups types and groups in this course *****/ + Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ALL_GROUP_TYPES); - /***** Show optional alert *****/ - if (AlertTextGroupTypes) - if (AlertTextGroupTypes[0]) - Ale_ShowAlert (AlertTypeGroupTypes,AlertTextGroupTypes); + /***** Show optional alert *****/ + if (AlertTextGroupTypes) + if (AlertTextGroupTypes[0]) + Ale_ShowAlert (AlertTypeGroupTypes,AlertTextGroupTypes); - /***** Put form to edit group types *****/ - Grp_EditGroupTypes (); + /***** Put form to edit group types *****/ + Grp_EditGroupTypes (); /***** End groups types section *****/ HTM_SECTION_End (); @@ -260,20 +260,20 @@ static void Grp_ReqEditGroupsInternal2 (Ale_AlertType_t AlertTypeGroups, { struct Roo_Rooms Rooms; - /***** Reset rooms context *****/ - Roo_ResetRooms (&Rooms); + /***** Reset rooms context *****/ + Roo_ResetRooms (&Rooms); - /***** Show optional alert *****/ - if (AlertTextGroups) - if (AlertTextGroups[0]) - Ale_ShowAlert (AlertTypeGroups,AlertTextGroups); + /***** Show optional alert *****/ + if (AlertTextGroups) + if (AlertTextGroups[0]) + Ale_ShowAlert (AlertTypeGroups,AlertTextGroups); - /***** Get list of rooms in this center *****/ - Roo_GetListRooms (&Rooms,Roo_ONLY_SHRT_NAME); + /***** Get list of rooms in this center *****/ + Roo_GetListRooms (&Rooms,Roo_ONLY_SHRT_NAME); - /***** Put form to edit groups *****/ - if (Gbl.Crs.Grps.GrpTypes.Num) // If there are group types... - Grp_EditGroups (&Rooms); + /***** Put form to edit groups *****/ + if (Gbl.Crs.Grps.GrpTypes.Num) // If there are group types... + Grp_EditGroups (&Rooms); /***** End groups section *****/ HTM_SECTION_End (); @@ -300,15 +300,15 @@ static void Grp_EditGroupTypes (void) Grp_PutIconsEditingGroupTypes,NULL, Hlp_USERS_Groups,Box_NOT_CLOSABLE); - /***** Put a form to create a new group type *****/ - Grp_PutFormToCreateGroupType (); + /***** Put a form to create a new group type *****/ + Grp_PutFormToCreateGroupType (); - /***** Forms to edit current group types *****/ - if (Gbl.Crs.Grps.GrpTypes.Num) // Group types found... - Grp_ListGroupTypesForEdition (); - else // No group types found in this course - Ale_ShowAlert (Ale_INFO,Txt_There_are_no_types_of_group_in_the_course_X, - Gbl.Hierarchy.Crs.ShrtName); + /***** Forms to edit current group types *****/ + if (Gbl.Crs.Grps.GrpTypes.Num) // Group types found... + Grp_ListGroupTypesForEdition (); + else // No group types found in this course + Ale_ShowAlert (Ale_INFO,Txt_There_are_no_types_of_group_in_the_course_X, + Gbl.Hierarchy.Crs.ShrtName); /***** End box *****/ Box_BoxEnd (); @@ -329,15 +329,15 @@ static void Grp_EditGroups (const struct Roo_Rooms *Rooms) Grp_PutIconsEditingGroups,NULL, Hlp_USERS_Groups,Box_NOT_CLOSABLE); - /***** Put a form to create a new group *****/ - Grp_PutFormToCreateGroup (Rooms); + /***** Put a form to create a new group *****/ + Grp_PutFormToCreateGroup (Rooms); - /***** Forms to edit current groups *****/ - if (Gbl.Crs.Grps.GrpTypes.NumGrpsTotal) // If there are groups... - Grp_ListGroupsForEdition (Rooms); - else // There are group types, but there aren't groups - Ale_ShowAlert (Ale_INFO,Txt_No_groups_have_been_created_in_the_course_X, - Gbl.Hierarchy.Crs.ShrtName); + /***** Forms to edit current groups *****/ + if (Gbl.Crs.Grps.GrpTypes.NumGrpsTotal) // If there are groups... + Grp_ListGroupsForEdition (Rooms); + else // There are group types, but there aren't groups + Ale_ShowAlert (Ale_INFO,Txt_No_groups_have_been_created_in_the_course_X, + Gbl.Hierarchy.Crs.ShrtName); /***** End box *****/ Box_BoxEnd (); @@ -413,12 +413,12 @@ void Grp_ShowFormToSelectSeveralGroups (void (*FuncParams) (void *Args),void *Ar /***** List the groups for each group type *****/ HTM_TABLE_BeginWidePadding (2); - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - Grp_ListGrpsForMultipleSelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], - GroupsSelectableByStdsOrNETs); + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) + Grp_ListGrpsForMultipleSelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], + GroupsSelectableByStdsOrNETs); HTM_TABLE_End (); /***** Free list of groups types and groups in this course *****/ @@ -426,12 +426,12 @@ void Grp_ShowFormToSelectSeveralGroups (void (*FuncParams) (void *Args),void *Ar /***** Submit button *****/ HTM_DIV_Begin ("class=\"CM\" style=\"padding-top:12px;\""); - HTM_BUTTON_Animated_Begin (Txt_Update_users, - The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme], - Gbl.Action.Act == ActReqMsgUsr ? "CopyMessageToHiddenFields();" : - NULL); - Ico_PutCalculateIconWithText (Txt_Update_users); - HTM_BUTTON_End (); + HTM_BUTTON_Animated_Begin (Txt_Update_users, + The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme], + Gbl.Action.Act == ActReqMsgUsr ? "CopyMessageToHiddenFields();" : + NULL); + Ico_PutCalculateIconWithText (Txt_Update_users); + HTM_BUTTON_End (); HTM_DIV_End (); /***** End form *****/ @@ -470,15 +470,15 @@ static void Grp_PutCheckboxAllGrps (Grp_WhichGroups_t GroupsSelectableByStdsOrNE } HTM_DIV_Begin ("class=\"CONTEXT_OPT\""); - HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); - HTM_INPUT_CHECKBOX ("AllGroups",HTM_DONT_SUBMIT_ON_CHANGE, - "value=\"Y\"%s", - ICanSelUnselGroup ? (Gbl.Usrs.ClassPhoto.AllGroups ? " checked=\"checked\"" - " onclick=\"togglecheckChildren(this,'GrpCods')\"" : - " onclick=\"togglecheckChildren(this,'GrpCods')\"") : - " disabled=\"disabled\""); - HTM_TxtF (" %s",Txt_All_groups); - HTM_LABEL_End (); + HTM_LABEL_Begin ("class=\"%s\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + HTM_INPUT_CHECKBOX ("AllGroups",HTM_DONT_SUBMIT_ON_CHANGE, + "value=\"Y\"%s", + ICanSelUnselGroup ? (Gbl.Usrs.ClassPhoto.AllGroups ? " checked=\"checked\"" + " onclick=\"togglecheckChildren(this,'GrpCods')\"" : + " onclick=\"togglecheckChildren(this,'GrpCods')\"") : + " disabled=\"disabled\""); + HTM_TxtF (" %s",Txt_All_groups); + HTM_LABEL_End (); HTM_DIV_End (); } @@ -784,7 +784,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant) bool ChangesMade = false; /***** Lock tables to make the inscription atomic *****/ - Grp_LockTables (); + Grp_DB_LockTables (); /***** Get list of groups types and groups in this course *****/ Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); @@ -892,7 +892,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant) if (LstGrpsIWant->GrpCods[NumGrpIWant] == LstGrpsIBelong.GrpCods[NumGrpIBelong]) RegisterMeInThisGrp = false; if (RegisterMeInThisGrp) - Grp_AddUsrToGroup (&Gbl.Usrs.Me.UsrDat,LstGrpsIWant->GrpCods[NumGrpIWant]); + Grp_DB_AddUsrToGroup (&Gbl.Usrs.Me.UsrDat,LstGrpsIWant->GrpCods[NumGrpIWant]); } ChangesMade = true; @@ -902,7 +902,7 @@ bool Grp_ChangeMyGrpsAtomically (struct ListCodGrps *LstGrpsIWant) Grp_FreeListCodGrp (&LstGrpsIBelong); /***** Unlock tables after changes in my groups *****/ - Grp_UnlockTables (); + Grp_DB_UnlockTables (); /***** Free list of groups types and groups in this course *****/ Grp_FreeListGrpTypesAndGrps (); @@ -924,7 +924,7 @@ void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants) /***** Lock tables to make the inscription atomic *****/ if (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs == Rol_STD) - Grp_LockTables (); + Grp_DB_LockTables (); /***** Get list of groups types and groups in this course *****/ Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); @@ -958,7 +958,7 @@ void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants) if (LstGrpsUsrWants->GrpCods[NumGrpUsrWants] == LstGrpsUsrBelongs.GrpCods[NumGrpUsrBelongs]) RegisterUsrInThisGrp = false; if (RegisterUsrInThisGrp) - Grp_AddUsrToGroup (&Gbl.Usrs.Other.UsrDat,LstGrpsUsrWants->GrpCods[NumGrpUsrWants]); + Grp_DB_AddUsrToGroup (&Gbl.Usrs.Other.UsrDat,LstGrpsUsrWants->GrpCods[NumGrpUsrWants]); } /***** Free memory with the list of groups which user belonged to *****/ @@ -966,7 +966,7 @@ void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants) /***** Unlock tables after changes in groups *****/ if (Gbl.Usrs.Other.UsrDat.Roles.InCurrentCrs == Rol_STD) - Grp_UnlockTables (); + Grp_DB_UnlockTables (); /***** Free list of groups types and groups in this course *****/ Grp_FreeListGrpTypesAndGrps (); @@ -976,7 +976,7 @@ void Grp_ChangeGrpsOtherUsrAtomically (struct ListCodGrps *LstGrpsUsrWants) /*********** Lock tables to make the registration in groups atomic ***********/ /*****************************************************************************/ -static void Grp_LockTables (void) +static void Grp_DB_LockTables (void) { DB_Query ("can not lock tables to change user's groups", "LOCK TABLES " @@ -993,7 +993,7 @@ static void Grp_LockTables (void) /*********** Unlock tables after changes in registration in groups ***********/ /*****************************************************************************/ -static void Grp_UnlockTables (void) +static void Grp_DB_UnlockTables (void) { Gbl.DB.LockedTables = false; // Set to false before the following unlock... // ...to not retry the unlock if error in unlocking @@ -1030,7 +1030,7 @@ bool Grp_CheckIfSelectionGrpsSingleEnrolmentIsValid (Rol_Role_t Role,struct List SelectionValid && NumCodGrp < LstGrps->NumGrps; NumCodGrp++) { - GrpTypCod = Grp_GetTypeOfGroupOfAGroup (LstGrps->GrpCods[NumCodGrp]); + GrpTypCod = Grp_DB_GetTypeOfGroupOfAGroup (LstGrps->GrpCods[NumCodGrp]); MultipleEnrolment = Grp_GetMultipleEnrolmentOfAGroupType (GrpTypCod); if (!MultipleEnrolment) @@ -1151,7 +1151,7 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr if (!AlreadyRegisteredInGrp) // If the user does not belong to the selected group { - Grp_AddUsrToGroup (UsrDat,LstGrps->GrpCods[NumGrpSel]); + Grp_DB_AddUsrToGroup (UsrDat,LstGrps->GrpCods[NumGrpSel]); Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_has_been_enroled_in_the_group_of_type_Y_Z, UsrDat->FullName,Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps[NumGrpThisType].GrpName); @@ -1289,7 +1289,7 @@ static void Grp_RemoveUsrFromGroup (long UsrCod,long GrpCod) /*********************** Register a user in a group **************************/ /*****************************************************************************/ -static void Grp_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod) +static void Grp_DB_AddUsrToGroup (struct UsrData *UsrDat,long GrpCod) { /***** Register in group *****/ DB_QueryINSERT ("can not add a user to a group", @@ -1318,107 +1318,109 @@ static void Grp_ListGroupTypesForEdition (void) unsigned UniqueId; char Id[32]; - /***** Write heading *****/ + /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); - Grp_WriteHeadingGroupTypes (); - /***** List group types with forms for edition *****/ - for (NumGrpTyp = 0, UniqueId=1; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++, UniqueId++) - { - HTM_TR_Begin (NULL); + /***** Write heading *****/ + Grp_WriteHeadingGroupTypes (); - /* Put icon to remove group type */ - HTM_TD_Begin ("class=\"BM\""); - Ico_PutContextualIconToRemove (ActReqRemGrpTyp,Grp_GROUP_TYPES_SECTION_ID, - Grp_PutParamGrpTypCod,&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); - HTM_TD_End (); + /***** List group types with forms for edition *****/ + for (NumGrpTyp = 0, UniqueId=1; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++, UniqueId++) + { + HTM_TR_Begin (NULL); - /* Name of group type */ - HTM_TD_Begin ("class=\"LM\""); - Frm_StartFormAnchor (ActRenGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); - HTM_INPUT_TEXT ("GrpTypName",Grp_MAX_CHARS_GROUP_TYPE_NAME, - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, - HTM_SUBMIT_ON_CHANGE, - "size=\"12\""); - Frm_EndForm (); - HTM_TD_End (); + /* Put icon to remove group type */ + HTM_TD_Begin ("class=\"BM\""); + Ico_PutContextualIconToRemove (ActReqRemGrpTyp,Grp_GROUP_TYPES_SECTION_ID, + Grp_PutParamGrpTypCod,&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); + HTM_TD_End (); - /* Is it mandatory to register in any group? */ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActChgMdtGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"MandatoryEnrolment\"" - " style=\"width:150px;\""); - HTM_OPTION (HTM_Type_STRING,"N", - !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, - "%s",Txt_It_is_optional_to_choose_a_group); - HTM_OPTION (HTM_Type_STRING,"Y", - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, - "%s",Txt_It_is_mandatory_to_choose_a_group); - HTM_SELECT_End (); - Frm_EndForm (); - HTM_TD_End (); + /* Name of group type */ + HTM_TD_Begin ("class=\"LM\""); + Frm_StartFormAnchor (ActRenGrpTyp,Grp_GROUP_TYPES_SECTION_ID); + Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); + HTM_INPUT_TEXT ("GrpTypName",Grp_MAX_CHARS_GROUP_TYPE_NAME, + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, + HTM_SUBMIT_ON_CHANGE, + "size=\"12\""); + Frm_EndForm (); + HTM_TD_End (); - /* Is it possible to register in multiple groups? */ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActChgMulGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"MultipleEnrolment\"" - " style=\"width:150px;\""); - HTM_OPTION (HTM_Type_STRING,"N", - !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, - "%s",Txt_A_student_can_only_belong_to_one_group); - HTM_OPTION (HTM_Type_STRING,"Y", - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, - "%s",Txt_A_student_can_belong_to_several_groups); - HTM_SELECT_End (); - Frm_EndForm (); - HTM_TD_End (); + /* Is it mandatory to register in any group? */ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActChgMdtGrpTyp,Grp_GROUP_TYPES_SECTION_ID); + Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"MandatoryEnrolment\"" + " style=\"width:150px;\""); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, + "%s",Txt_It_is_optional_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MandatoryEnrolment,false, + "%s",Txt_It_is_mandatory_to_choose_a_group); + HTM_SELECT_End (); + Frm_EndForm (); + HTM_TD_End (); - /* Open time */ - HTM_TD_Begin ("class=\"LM\""); - Frm_StartFormAnchor (ActChgTimGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); - HTM_TABLE_BeginCenterPadding (2); - HTM_TR_Begin (NULL); + /* Is it possible to register in multiple groups? */ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActChgMulGrpTyp,Grp_GROUP_TYPES_SECTION_ID); + Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"MultipleEnrolment\"" + " style=\"width:150px;\""); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, + "%s",Txt_A_student_can_only_belong_to_one_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MultipleEnrolment,false, + "%s",Txt_A_student_can_belong_to_several_groups); + HTM_SELECT_End (); + Frm_EndForm (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LM\" style=\"width:16px;\""); - Ico_PutIcon ("clock.svg", - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? Txt_The_groups_will_automatically_open : - Txt_The_groups_will_not_automatically_open, - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? "CONTEXT_ICO_16x16" : - "ICO_HIDDEN CONTEXT_ICO_16x16"); - HTM_TD_End (); + /* Open time */ + HTM_TD_Begin ("class=\"LM\""); + Frm_StartFormAnchor (ActChgTimGrpTyp,Grp_GROUP_TYPES_SECTION_ID); + Grp_PutParamGrpTypCod (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod); + HTM_TABLE_BeginCenterPadding (2); + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LM\""); - snprintf (Id,sizeof (Id),"open_time_%u",UniqueId); - Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id, - "Open", - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC, - Gbl.Now.Date.Year, - Gbl.Now.Date.Year + 1, - Dat_FORM_SECONDS_ON, - Dat_HMS_DO_NOT_SET, // Don't set hour, minute and second - true); // Submit on change - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\" style=\"width:16px;\""); + Ico_PutIcon ("clock.svg", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? Txt_The_groups_will_automatically_open : + Txt_The_groups_will_not_automatically_open, + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].MustBeOpened ? "CONTEXT_ICO_16x16" : + "ICO_HIDDEN CONTEXT_ICO_16x16"); + HTM_TD_End (); - HTM_TR_End (); - HTM_TABLE_End (); - Frm_EndForm (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\""); + snprintf (Id,sizeof (Id),"open_time_%u",UniqueId); + Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id, + "Open", + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].OpenTimeUTC, + Gbl.Now.Date.Year, + Gbl.Now.Date.Year + 1, + Dat_FORM_SECONDS_ON, + Dat_HMS_DO_NOT_SET, // Don't set hour, minute and second + true); // Submit on change + HTM_TD_End (); - /* Number of groups of this type */ - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Unsigned (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps); - HTM_TD_End (); + HTM_TR_End (); + HTM_TABLE_End (); + Frm_EndForm (); + HTM_TD_End (); - HTM_TR_End (); - } + /* Number of groups of this type */ + HTM_TD_Begin ("class=\"DAT CM\""); + HTM_Unsigned (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps); + HTM_TD_End (); + + HTM_TR_End (); + } /***** End table *****/ HTM_TABLE_End (); @@ -1468,16 +1470,16 @@ static void Grp_WriteHeadingGroupTypes (void) HTM_TR_Begin (NULL); - HTM_TH (1,1,"BM",NULL); - HTM_TH_Begin (1,1,"CM"); - HTM_Txt (Txt_Type_of_group); - HTM_BR (); - HTM_TxtF ("(%s)",Txt_eg_Lectures_Practicals); - HTM_TH_End (); - HTM_TH (1,1,"CM",Txt_Mandatory_enrolment); - HTM_TH (1,1,"CM",Txt_Multiple_enrolment); - HTM_TH (1,1,"CM",Txt_Opening_of_groups); - HTM_TH (1,1,"CM",Txt_Number_of_BR_groups); + HTM_TH (1,1,"BM",NULL); + HTM_TH_Begin (1,1,"CM"); + HTM_Txt (Txt_Type_of_group); + HTM_BR (); + HTM_TxtF ("(%s)",Txt_eg_Lectures_Practicals); + HTM_TH_End (); + HTM_TH (1,1,"CM",Txt_Mandatory_enrolment); + HTM_TH (1,1,"CM",Txt_Multiple_enrolment); + HTM_TH (1,1,"CM",Txt_Opening_of_groups); + HTM_TH (1,1,"CM",Txt_Number_of_BR_groups); HTM_TR_End (); } @@ -1504,149 +1506,151 @@ static void Grp_ListGroupsForEdition (const struct Roo_Rooms *Rooms) Rol_Role_t Role; char StrMaxStudents[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - /***** Write heading *****/ + /***** Begin table *****/ HTM_TABLE_BeginWidePadding (2); - Grp_WriteHeadingGroups (); - /***** List the groups *****/ - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - { - GrpTyp = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp]; - for (NumGrpThisType = 0; - NumGrpThisType < GrpTyp->NumGrps; - NumGrpThisType++) - { - Grp = &(GrpTyp->LstGrps[NumGrpThisType]); + /***** Write heading *****/ + Grp_WriteHeadingGroups (); - HTM_TR_Begin (NULL); + /***** List the groups *****/ + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + { + GrpTyp = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp]; + for (NumGrpThisType = 0; + NumGrpThisType < GrpTyp->NumGrps; + NumGrpThisType++) + { + Grp = &(GrpTyp->LstGrps[NumGrpThisType]); - /***** Icon to remove group *****/ - HTM_TD_Begin ("class=\"BM\""); - Ico_PutContextualIconToRemove (ActReqRemGrp,Grp_GROUPS_SECTION_ID, - Grp_PutParamGrpCod,&Grp->GrpCod); - HTM_TD_End (); + HTM_TR_Begin (NULL); - /***** Icon to open/close group *****/ - HTM_TD_Begin ("class=\"BM\""); - Frm_StartFormAnchor (Grp->Open ? ActCloGrp : - ActOpeGrp, - Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - Ico_PutIconLink (Grp->Open ? "unlock.svg" : - "lock.svg", - Str_BuildStringStr (Grp->Open ? Txt_Group_X_open_click_to_close_it : - Txt_Group_X_closed_click_to_open_it, - Grp->GrpName)); - Str_FreeString (); - Frm_EndForm (); - HTM_TD_End (); + /***** Icon to remove group *****/ + HTM_TD_Begin ("class=\"BM\""); + Ico_PutContextualIconToRemove (ActReqRemGrp,Grp_GROUPS_SECTION_ID, + Grp_PutParamGrpCod,&Grp->GrpCod); + HTM_TD_End (); - /***** Icon to activate file zones for this group *****/ - HTM_TD_Begin ("class=\"BM\""); - Frm_StartFormAnchor (Grp->FileZones ? ActDisFilZonGrp : - ActEnaFilZonGrp, - Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - Ico_PutIconLink (Grp->FileZones ? "folder-open-green.svg" : - "folder-red.svg", - Str_BuildStringStr (Grp->FileZones ? Txt_File_zones_of_the_group_X_enabled_click_to_disable_them : - Txt_File_zones_of_the_group_X_disabled_click_to_enable_them, - Grp->GrpName)); - Str_FreeString (); - Frm_EndForm (); - HTM_TD_End (); + /***** Icon to open/close group *****/ + HTM_TD_Begin ("class=\"BM\""); + Frm_StartFormAnchor (Grp->Open ? ActCloGrp : + ActOpeGrp, + Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + Ico_PutIconLink (Grp->Open ? "unlock.svg" : + "lock.svg", + Str_BuildStringStr (Grp->Open ? Txt_Group_X_open_click_to_close_it : + Txt_Group_X_closed_click_to_open_it, + Grp->GrpName)); + Str_FreeString (); + Frm_EndForm (); + HTM_TD_End (); - /***** Group type *****/ - /* Start selector */ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActChgGrpTyp,Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"GrpTypCod\" style=\"width:100px;\""); + /***** Icon to activate file zones for this group *****/ + HTM_TD_Begin ("class=\"BM\""); + Frm_StartFormAnchor (Grp->FileZones ? ActDisFilZonGrp : + ActEnaFilZonGrp, + Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + Ico_PutIconLink (Grp->FileZones ? "folder-open-green.svg" : + "folder-red.svg", + Str_BuildStringStr (Grp->FileZones ? Txt_File_zones_of_the_group_X_enabled_click_to_disable_them : + Txt_File_zones_of_the_group_X_disabled_click_to_enable_them, + Grp->GrpName)); + Str_FreeString (); + Frm_EndForm (); + HTM_TD_End (); - /* Options for group types */ - for (NumTipGrpAux = 0; - NumTipGrpAux < Gbl.Crs.Grps.GrpTypes.Num; - NumTipGrpAux++) - { - GrpTypAux = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumTipGrpAux]; - HTM_OPTION (HTM_Type_LONG,&GrpTypAux->GrpTypCod, - GrpTypAux->GrpTypCod == GrpTyp->GrpTypCod,false, - "%s",GrpTypAux->GrpTypName); - } + /***** Group type *****/ + /* Start selector */ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActChgGrpTyp,Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"GrpTypCod\" style=\"width:100px;\""); - /* End selector */ - HTM_SELECT_End (); - Frm_EndForm (); - HTM_TD_End (); + /* Options for group types */ + for (NumTipGrpAux = 0; + NumTipGrpAux < Gbl.Crs.Grps.GrpTypes.Num; + NumTipGrpAux++) + { + GrpTypAux = &Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumTipGrpAux]; + HTM_OPTION (HTM_Type_LONG,&GrpTypAux->GrpTypCod, + GrpTypAux->GrpTypCod == GrpTyp->GrpTypCod,false, + "%s",GrpTypAux->GrpTypName); + } - /***** Group name *****/ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActRenGrp,Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - HTM_INPUT_TEXT ("GrpName",Grp_MAX_CHARS_GROUP_NAME,Grp->GrpName, - HTM_SUBMIT_ON_CHANGE, - "size=\"20\""); - Frm_EndForm (); - HTM_TD_End (); + /* End selector */ + HTM_SELECT_End (); + Frm_EndForm (); + HTM_TD_End (); - /***** Room *****/ - /* Start selector */ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActChgGrpRoo,Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, - "name=\"RooCod\" style=\"width:100px;\""); + /***** Group name *****/ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActRenGrp,Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + HTM_INPUT_TEXT ("GrpName",Grp_MAX_CHARS_GROUP_NAME,Grp->GrpName, + HTM_SUBMIT_ON_CHANGE, + "size=\"20\""); + Frm_EndForm (); + HTM_TD_End (); - /* Option for no assigned room */ - HTM_OPTION (HTM_Type_STRING,"-1", - Grp->Room.RooCod < 0,false, - "%s",Txt_No_assigned_room); + /***** Room *****/ + /* Start selector */ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActChgGrpRoo,Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, + "name=\"RooCod\" style=\"width:100px;\""); - /* Option for another room */ - HTM_OPTION (HTM_Type_STRING,"0", - Grp->Room.RooCod == 0,false, - "%s",Txt_Another_room); + /* Option for no assigned room */ + HTM_OPTION (HTM_Type_STRING,"-1", + Grp->Room.RooCod < 0,false, + "%s",Txt_No_assigned_room); - /* Options for rooms */ - for (NumRoo = 0; - NumRoo < Rooms->Num; - NumRoo++) - HTM_OPTION (HTM_Type_LONG,&Rooms->Lst[NumRoo].RooCod, - Rooms->Lst[NumRoo].RooCod == Grp->Room.RooCod,false, - "%s",Rooms->Lst[NumRoo].ShrtName); + /* Option for another room */ + HTM_OPTION (HTM_Type_STRING,"0", + Grp->Room.RooCod == 0,false, + "%s",Txt_Another_room); - /* End selector */ - HTM_SELECT_End (); - Frm_EndForm (); - HTM_TD_End (); + /* Options for rooms */ + for (NumRoo = 0; + NumRoo < Rooms->Num; + NumRoo++) + HTM_OPTION (HTM_Type_LONG,&Rooms->Lst[NumRoo].RooCod, + Rooms->Lst[NumRoo].RooCod == Grp->Room.RooCod,false, + "%s",Rooms->Lst[NumRoo].ShrtName); - /***** Current number of users in this group *****/ - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - { - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Int (Grp->NumUsrs[Role]); - HTM_TD_End (); - } + /* End selector */ + HTM_SELECT_End (); + Frm_EndForm (); + HTM_TD_End (); - /***** Maximum number of students of the group (row[3]) *****/ - HTM_TD_Begin ("class=\"CM\""); - Frm_StartFormAnchor (ActChgMaxStdGrp,Grp_GROUPS_SECTION_ID); - Grp_PutParamGrpCod (&Grp->GrpCod); - Grp_WriteMaxStds (StrMaxStudents,Grp->MaxStudents); - HTM_INPUT_TEXT ("MaxStudents",Cns_MAX_DECIMAL_DIGITS_UINT,StrMaxStudents, - HTM_SUBMIT_ON_CHANGE, - "size=\"3\""); - Frm_EndForm (); - HTM_TD_End (); + /***** Current number of users in this group *****/ + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + { + HTM_TD_Begin ("class=\"DAT CM\""); + HTM_Int (Grp->NumUsrs[Role]); + HTM_TD_End (); + } - HTM_TR_End (); - } - } + /***** Maximum number of students of the group (row[3]) *****/ + HTM_TD_Begin ("class=\"CM\""); + Frm_StartFormAnchor (ActChgMaxStdGrp,Grp_GROUPS_SECTION_ID); + Grp_PutParamGrpCod (&Grp->GrpCod); + Grp_WriteMaxStds (StrMaxStudents,Grp->MaxStudents); + HTM_INPUT_TEXT ("MaxStudents",Cns_MAX_DECIMAL_DIGITS_UINT,StrMaxStudents, + HTM_SUBMIT_ON_CHANGE, + "size=\"3\""); + Frm_EndForm (); + HTM_TD_End (); + + HTM_TR_End (); + } + } /***** End table *****/ HTM_TABLE_End (); @@ -1668,21 +1672,21 @@ static void Grp_WriteHeadingGroups (void) HTM_TR_Begin (NULL); - HTM_TH (1,1,"BM",NULL); - HTM_TH (1,1,"BM",NULL); - HTM_TH (1,1,"BM",NULL); - HTM_TH (1,1,"CM",Txt_Type_BR_of_group); - HTM_TH_Begin (1,1,"CM"); - HTM_Txt (Txt_Group_name); - HTM_BR (); - HTM_TxtF ("(%s)",Txt_eg_A_B); - HTM_TH_End (); - HTM_TH (1,1,"CM",Txt_Room); - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - HTM_TH (1,1,"CM",Txt_ROLES_PLURAL_BRIEF_Abc[Role]); - HTM_TH (1,1,"CM",Txt_Max_BR_students); + HTM_TH (1,1,"BM",NULL); + HTM_TH (1,1,"BM",NULL); + HTM_TH (1,1,"BM",NULL); + HTM_TH (1,1,"CM",Txt_Type_BR_of_group); + HTM_TH_Begin (1,1,"CM"); + HTM_Txt (Txt_Group_name); + HTM_BR (); + HTM_TxtF ("(%s)",Txt_eg_A_B); + HTM_TH_End (); + HTM_TH (1,1,"CM",Txt_Room); + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + HTM_TH (1,1,"CM",Txt_ROLES_PLURAL_BRIEF_Abc[Role]); + HTM_TH (1,1,"CM",Txt_Max_BR_students); HTM_TR_End (); } @@ -1730,31 +1734,31 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, IBelongToThisGroup = Grp_CheckIfGrpIsInList (Grp->GrpCod,&LstGrpsIBelong); if (Cod > 0) // Cod == -1L means new item, assignment, event, survey, exam event or match - AssociatedToGrp = Grp_CheckIfAssociatedToGrp (AssociationsToGrps[WhichIsAssociatedToGrp].Table, - AssociationsToGrps[WhichIsAssociatedToGrp].Field, - Cod,Grp->GrpCod); + AssociatedToGrp = Grp_DB_CheckIfAssociatedToGrp (AssociationsToGrps[WhichIsAssociatedToGrp].Table, + AssociationsToGrps[WhichIsAssociatedToGrp].Field, + Cod,Grp->GrpCod); else AssociatedToGrp = false; /* Put checkbox to select the group */ HTM_TR_Begin (NULL); - if (IBelongToThisGroup) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Grp%ld\" value=\"%ld\"%s%s" - " onclick=\"uncheckParent(this,'WholeCrs')\"", - Grp->GrpCod,Grp->GrpCod, - AssociatedToGrp ? " checked=\"checked\"" : - "", - (IBelongToThisGroup || - Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? "" : - " disabled=\"disabled\""); - HTM_TD_End (); + if (IBelongToThisGroup) + HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); + else + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Grp%ld\" value=\"%ld\"%s%s" + " onclick=\"uncheckParent(this,'WholeCrs')\"", + Grp->GrpCod,Grp->GrpCod, + AssociatedToGrp ? " checked=\"checked\"" : + "", + (IBelongToThisGroup || + Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? "" : + " disabled=\"disabled\""); + HTM_TD_End (); - Grp_WriteRowGrp (Grp,IBelongToThisGroup); + Grp_WriteRowGrp (Grp,IBelongToThisGroup); HTM_TR_End (); } @@ -1763,13 +1767,12 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, Grp_FreeListCodGrp (&LstGrpsIBelong); } - /*****************************************************************************/ /************ Check if an assignment is associated to a group ****************/ /*****************************************************************************/ -static bool Grp_CheckIfAssociatedToGrp (const char *Table,const char *Field, - long Cod,long GrpCod) +static bool Grp_DB_CheckIfAssociatedToGrp (const char *Table,const char *Field, + long Cod,long GrpCod) { /***** Get if an assignment, attendance event, survey, exam event or match is associated to a given group from database *****/ @@ -1789,7 +1792,7 @@ static bool Grp_CheckIfAssociatedToGrp (const char *Table,const char *Field, /*** is associated to any group ***/ /*****************************************************************************/ -bool Grp_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod) +bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod) { /***** Trivial check *****/ if (Cod <= 0) // Assignment, attendance event, survey, exam event or match code @@ -1865,15 +1868,15 @@ void Grp_ShowLstGrpsToChgMyGrps (void) /***** List the groups the user belongs to for change *****/ HTM_TABLE_BeginWidePadding (2); - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) // If there are groups of this type - { - ICanChangeMyGrps |= Grp_ListGrpsForChangeMySelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], - &NumGrpsThisTypeIBelong); - NumGrpsIBelong += NumGrpsThisTypeIBelong; - } + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) // If there are groups of this type + { + ICanChangeMyGrps |= Grp_ListGrpsForChangeMySelection (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp], + &NumGrpsThisTypeIBelong); + NumGrpsIBelong += NumGrpsThisTypeIBelong; + } HTM_TABLE_End (); /***** End form *****/ @@ -1894,7 +1897,7 @@ void Grp_ShowLstGrpsToChgMyGrps (void) if (ICanEdit) { Frm_BeginForm (ActReqEdiGrp); - Btn_PutConfirmButton (Txt_Create_group); + Btn_PutConfirmButton (Txt_Create_group); Frm_EndForm (); } } @@ -1938,7 +1941,7 @@ static void Grp_ShowWarningToStdsToChangeGrps (void) // If there are groups of this type... if (GrpTyp->NumGrps) // If I don't belong to any group - if (!Grp_CheckIfIBelongToGrpsOfType (GrpTyp->GrpTypCod)) // Fast check (not necesary, but avoid slow check) + if (!Grp_DB_CheckIfIBelongToGrpsOfType (GrpTyp->GrpTypCod)) // Fast check (not necesary, but avoid slow check) // If there is any group of this type available if (Grp_GetIfAvailableGrpTyp (GrpTyp->GrpTypCod)) // Slow check { @@ -2148,12 +2151,12 @@ void Grp_ShowLstGrpsToChgOtherUsrsGrps (long UsrCod) NULL,NULL, Hlp_USERS_Groups,Box_NOT_CLOSABLE,0); - /***** List to select the groups the user belongs to *****/ - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) - Grp_ListGrpsToAddOrRemUsrs (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],UsrCod); + /***** List to select the groups the user belongs to *****/ + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) + Grp_ListGrpsToAddOrRemUsrs (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],UsrCod); /***** End table and box *****/ Box_BoxTableEnd (); @@ -2196,26 +2199,26 @@ static void Grp_ListGrpsToAddOrRemUsrs (struct GroupType *GrpTyp,long UsrCod) /* Start row */ HTM_TR_Begin (NULL); - /* Start cell for checkbox */ - if (UsrBelongsToThisGroup) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); + /* Start cell for checkbox */ + if (UsrBelongsToThisGroup) + HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); + else + HTM_TD_Begin ("class=\"LM\""); - /* Put checkbox to select the group */ - // Always checkbox, not radio, because the role in the form may be teacher, - // so if he/she is registered as teacher, he/she can belong to several groups - snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod); - HTM_INPUT_CHECKBOX (StrGrpCod,HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Grp%ld\" value=\"%ld\"%s", - Grp->GrpCod,Grp->GrpCod, - UsrBelongsToThisGroup ? " checked=\"checked\"" : ""); // I can not register + /* Put checkbox to select the group */ + // Always checkbox, not radio, because the role in the form may be teacher, + // so if he/she is registered as teacher, he/she can belong to several groups + snprintf (StrGrpCod,sizeof (StrGrpCod),"GrpCod%ld",GrpTyp->GrpTypCod); + HTM_INPUT_CHECKBOX (StrGrpCod,HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Grp%ld\" value=\"%ld\"%s", + Grp->GrpCod,Grp->GrpCod, + UsrBelongsToThisGroup ? " checked=\"checked\"" : ""); // I can not register - /* End cell for checkbox */ - HTM_TD_End (); + /* End cell for checkbox */ + HTM_TD_End (); - /* Write cell for group */ - Grp_WriteRowGrp (Grp,UsrBelongsToThisGroup); + /* Write cell for group */ + Grp_WriteRowGrp (Grp,UsrBelongsToThisGroup); /* End row */ HTM_TR_End (); @@ -2300,19 +2303,19 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, /* Put checkbox to select the group */ HTM_TR_Begin (NULL); - if (IBelongToThisGroup) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Grp%ld\" value=\"%ld\"%s%s", - Grp->GrpCod,Grp->GrpCod, - Checked ? " checked=\"checked\"" : "", - ICanSelUnselGroup ? " onclick=\"checkParent(this,'AllGroups')\"" : - " disabled=\"disabled\""); - HTM_TD_End (); + if (IBelongToThisGroup) + HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); + else + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Grp%ld\" value=\"%ld\"%s%s", + Grp->GrpCod,Grp->GrpCod, + Checked ? " checked=\"checked\"" : "", + ICanSelUnselGroup ? " onclick=\"checkParent(this,'AllGroups')\"" : + " disabled=\"disabled\""); + HTM_TD_End (); - Grp_WriteRowGrp (Grp,IBelongToThisGroup); + Grp_WriteRowGrp (Grp,IBelongToThisGroup); HTM_TR_End (); } @@ -2343,42 +2346,42 @@ static void Grp_ListGrpsForMultipleSelection (struct GroupType *GrpTyp, HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, - "id=\"Grp%ld\" value=\"%ld\"%s" - " onclick=\"checkParent(this,'AllGroups')\"", - -GrpTyp->GrpTypCod,-GrpTyp->GrpTypCod, - ICanSelUnselGroup ? (Checked ? " checked=\"checked\"" : "") : - " disabled=\"disabled\""); - HTM_TD_End (); - - /* Column closed/open */ - HTM_TD_Begin ("class=\"LM\""); - HTM_TD_End (); - - /* Group name = students with no group */ - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_LABEL_Begin ("for=\"Grp%ld\"",-GrpTyp->GrpTypCod); - HTM_Txt (Txt_users_with_no_group); - HTM_LABEL_End (); - HTM_TD_End (); - - /* Room */ - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_TD_End (); - - /* Number of students who don't belong to any group of this type */ - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - { - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Unsigned (Grp_CountNumUsrsInNoGrpsOfType (Role,GrpTyp->GrpTypCod)); + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_CHECKBOX ("GrpCods",HTM_DONT_SUBMIT_ON_CHANGE, + "id=\"Grp%ld\" value=\"%ld\"%s" + " onclick=\"checkParent(this,'AllGroups')\"", + -GrpTyp->GrpTypCod,-GrpTyp->GrpTypCod, + ICanSelUnselGroup ? (Checked ? " checked=\"checked\"" : "") : + " disabled=\"disabled\""); HTM_TD_End (); - } - /* Last empty columns for max. students and vacants */ - HTM_TD_Empty (2); + /* Column closed/open */ + HTM_TD_Begin ("class=\"LM\""); + HTM_TD_End (); + + /* Group name = students with no group */ + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_LABEL_Begin ("for=\"Grp%ld\"",-GrpTyp->GrpTypCod); + HTM_Txt (Txt_users_with_no_group); + HTM_LABEL_End (); + HTM_TD_End (); + + /* Room */ + HTM_TD_Begin ("class=\"DAT LM\""); + HTM_TD_End (); + + /* Number of students who don't belong to any group of this type */ + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + { + HTM_TD_Begin ("class=\"DAT CM\""); + HTM_Unsigned (Grp_DB_CountNumUsrsInNoGrpsOfType (Role,GrpTyp->GrpTypCod)); + HTM_TD_End (); + } + + /* Last empty columns for max. students and vacants */ + HTM_TD_Empty (2); HTM_TR_End (); } @@ -2401,38 +2404,38 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp) /***** Name of group type *****/ HTM_TR_Begin (NULL); - HTM_TD_Begin ("colspan=\"9\" class=\"GRP_TITLE LM\""); - HTM_BR (); - HTM_Txt (GrpTyp->GrpTypName); - if (GrpTyp->MustBeOpened) - { - UniqueId++; - if (asprintf (&Id,"open_time_%u",UniqueId) < 0) - Err_NotEnoughMemoryExit (); - HTM_BR (); - HTM_TxtColonNBSP (Txt_Opening_of_groups); - HTM_SPAN_Begin ("id=\"%s\"",Id); - HTM_SPAN_End (); - Dat_WriteLocalDateHMSFromUTC (Id,GrpTyp->OpenTimeUTC, - Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); - free (Id); - } - HTM_TD_End (); + HTM_TD_Begin ("colspan=\"9\" class=\"GRP_TITLE LM\""); + HTM_BR (); + HTM_Txt (GrpTyp->GrpTypName); + if (GrpTyp->MustBeOpened) + { + UniqueId++; + if (asprintf (&Id,"open_time_%u",UniqueId) < 0) + Err_NotEnoughMemoryExit (); + HTM_BR (); + HTM_TxtColonNBSP (Txt_Opening_of_groups); + HTM_SPAN_Begin ("id=\"%s\"",Id); + HTM_SPAN_End (); + Dat_WriteLocalDateHMSFromUTC (Id,GrpTyp->OpenTimeUTC, + Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, + true,true,true,0x7); + free (Id); + } + HTM_TD_End (); HTM_TR_End (); /***** Head row with title of each column *****/ HTM_TR_Begin (NULL); - HTM_TH_Empty (2); - HTM_TH (1,1,"LM",Txt_Group); - HTM_TH (1,1,"LM",Txt_Room); - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - HTM_TH (1,1,"CM",Txt_ROLES_PLURAL_BRIEF_Abc[Role]); - HTM_TH (1,1,"CM",Txt_Max_BR_students); - HTM_TH (1,1,"CM",Txt_Vacants); + HTM_TH_Empty (2); + HTM_TH (1,1,"LM",Txt_Group); + HTM_TH (1,1,"LM",Txt_Room); + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + HTM_TH (1,1,"CM",Txt_ROLES_PLURAL_BRIEF_Abc[Role]); + HTM_TH (1,1,"CM",Txt_Max_BR_students); + HTM_TH (1,1,"CM",Txt_Vacants); HTM_TR_End (); } @@ -2463,21 +2466,17 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) HTM_TD_End (); /***** Group name *****/ - if (Highlight) - HTM_TD_Begin ("class=\"LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"LM\""); - HTM_LABEL_Begin ("for=\"Grp%ld\" class=\"DAT\"",Grp->GrpCod); - HTM_Txt (Grp->GrpName); - HTM_LABEL_End (); + HTM_TD_Begin (Highlight ? "class=\"LM LIGHT_BLUE\"" : + "class=\"LM\""); + HTM_LABEL_Begin ("for=\"Grp%ld\" class=\"DAT\"",Grp->GrpCod); + HTM_Txt (Grp->GrpName); + HTM_LABEL_End (); HTM_TD_End (); /***** Room *****/ - if (Highlight) - HTM_TD_Begin ("class=\"DAT LM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"DAT LM\""); - HTM_Txt (Grp->Room.ShrtName); + HTM_TD_Begin (Highlight ? "class=\"DAT LM LIGHT_BLUE\"" : + "class=\"DAT LM\""); + HTM_Txt (Grp->Room.ShrtName); HTM_TD_End (); /***** Current number of users in this group *****/ @@ -2485,34 +2484,28 @@ static void Grp_WriteRowGrp (struct Group *Grp,bool Highlight) Role >= Rol_STD; Role--) { - if (Highlight) - HTM_TD_Begin ("class=\"DAT CM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Int (Grp->NumUsrs[Role]); + HTM_TD_Begin (Highlight ? "class=\"DAT CM LIGHT_BLUE\"" : + "class=\"DAT CM\""); + HTM_Int (Grp->NumUsrs[Role]); HTM_TD_End (); } /***** Max. number of students in this group *****/ - if (Highlight) - HTM_TD_Begin ("class=\"DAT CM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"DAT CM\""); - Grp_WriteMaxStds (StrMaxStudents,Grp->MaxStudents); - HTM_TxtF ("%s ",StrMaxStudents); + HTM_TD_Begin (Highlight ? "class=\"DAT CM LIGHT_BLUE\"" : + "class=\"DAT CM\""); + Grp_WriteMaxStds (StrMaxStudents,Grp->MaxStudents); + HTM_TxtF ("%s ",StrMaxStudents); HTM_TD_End (); /***** Vacants in this group *****/ - if (Highlight) - HTM_TD_Begin ("class=\"DAT CM LIGHT_BLUE\""); - else - HTM_TD_Begin ("class=\"DAT CM\""); - if (Grp->MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP) - { - Vacant = (int) Grp->MaxStudents - (int) Grp->NumUsrs[Rol_STD]; - HTM_Unsigned (Vacant > 0 ? (unsigned) Vacant : - 0); - } + HTM_TD_Begin (Highlight ? "class=\"DAT CM LIGHT_BLUE\"" : + "class=\"DAT CM\""); + if (Grp->MaxStudents <= Grp_MAX_STUDENTS_IN_A_GROUP) + { + Vacant = (int) Grp->MaxStudents - (int) Grp->NumUsrs[Rol_STD]; + HTM_Unsigned (Vacant > 0 ? (unsigned) Vacant : + 0); + } HTM_TD_End (); } @@ -2531,97 +2524,101 @@ static void Grp_PutFormToCreateGroupType (void) extern const char *Txt_The_groups_will_not_automatically_open; extern const char *Txt_Create_type_of_group; - /***** Begin form *****/ + /***** Begin section *****/ HTM_SECTION_Begin (Grp_NEW_GROUP_TYPE_SECTION_ID); - Frm_StartFormAnchor (ActNewGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - /***** Begin box *****/ - Box_BoxTableBegin (NULL,Txt_New_type_of_group, - NULL,NULL, - NULL,Box_NOT_CLOSABLE,2); + /***** Begin form *****/ + Frm_StartFormAnchor (ActNewGrpTyp,Grp_GROUP_TYPES_SECTION_ID); - /***** Write heading *****/ - Grp_WriteHeadingGroupTypes (); + /***** Begin box *****/ + Box_BoxTableBegin (NULL,Txt_New_type_of_group, + NULL,NULL, + NULL,Box_NOT_CLOSABLE,2); - HTM_TR_Begin (NULL); + /***** Write heading *****/ + Grp_WriteHeadingGroupTypes (); - /***** Column to remove group type, disabled here *****/ - HTM_TD_Begin ("class=\"BM\""); - HTM_TD_End (); + HTM_TR_Begin (NULL); - /***** Name of group type *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_INPUT_TEXT ("GrpTypName",Grp_MAX_CHARS_GROUP_TYPE_NAME, - Gbl.Crs.Grps.GrpTyp.GrpTypName,HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"12\" required=\"required\""); - HTM_TD_End (); + /***** Column to remove group type, disabled here *****/ + HTM_TD_Begin ("class=\"BM\""); + HTM_TD_End (); - /***** Is it mandatory to register in any groups of this type? *****/ - HTM_TD_Begin ("class=\"CM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"MandatoryEnrolment\" style=\"width:150px;\""); - HTM_OPTION (HTM_Type_STRING,"N", - !Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, - "%s",Txt_It_is_optional_to_choose_a_group); - HTM_OPTION (HTM_Type_STRING,"Y", - Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, - "%s",Txt_It_is_mandatory_to_choose_a_group); - HTM_SELECT_End (); - HTM_TD_End (); + /***** Name of group type *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_INPUT_TEXT ("GrpTypName",Grp_MAX_CHARS_GROUP_TYPE_NAME, + Gbl.Crs.Grps.GrpTyp.GrpTypName,HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"12\" required=\"required\""); + HTM_TD_End (); - /***** Is it possible to register in multiple groups of this type? *****/ - HTM_TD_Begin ("class=\"CM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"MultipleEnrolment\" style=\"width:150px;\""); - HTM_OPTION (HTM_Type_STRING,"N", - !Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, - "%s",Txt_A_student_can_only_belong_to_one_group); - HTM_OPTION (HTM_Type_STRING,"Y", - Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, - "%s",Txt_A_student_can_belong_to_several_groups); - HTM_SELECT_End (); - HTM_TD_End (); + /***** Is it mandatory to register in any groups of this type? *****/ + HTM_TD_Begin ("class=\"CM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"MandatoryEnrolment\" style=\"width:150px;\""); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, + "%s",Txt_It_is_optional_to_choose_a_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment,false, + "%s",Txt_It_is_mandatory_to_choose_a_group); + HTM_SELECT_End (); + HTM_TD_End (); - /***** Open time *****/ - HTM_TD_Begin ("class=\"LM\""); - HTM_TABLE_BeginPadding (2); - HTM_TR_Begin (NULL); + /***** Is it possible to register in multiple groups of this type? *****/ + HTM_TD_Begin ("class=\"CM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"MultipleEnrolment\" style=\"width:150px;\""); + HTM_OPTION (HTM_Type_STRING,"N", + !Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, + "%s",Txt_A_student_can_only_belong_to_one_group); + HTM_OPTION (HTM_Type_STRING,"Y", + Gbl.Crs.Grps.GrpTyp.MultipleEnrolment,false, + "%s",Txt_A_student_can_belong_to_several_groups); + HTM_SELECT_End (); + HTM_TD_End (); - HTM_TD_Begin ("class=\"LM\" style=\"width:20px;\""); - Ico_PutIcon ("clock.svg", - Gbl.Crs.Grps.GrpTyp.MustBeOpened ? Txt_The_groups_will_automatically_open : - Txt_The_groups_will_not_automatically_open, - Gbl.Crs.Grps.GrpTyp.MustBeOpened ? "CONTEXT_ICO_16x16" : - "ICO_HIDDEN CONTEXT_ICO_16x16"); - HTM_TD_End (); + /***** Open time *****/ + HTM_TD_Begin ("class=\"LM\""); + HTM_TABLE_BeginPadding (2); + HTM_TR_Begin (NULL); - HTM_TD_Begin ("class=\"LM\""); - Dat_WriteFormClientLocalDateTimeFromTimeUTC ("open_time", - "Open", - Gbl.Crs.Grps.GrpTyp.OpenTimeUTC, - Gbl.Now.Date.Year, - Gbl.Now.Date.Year + 1, - Dat_FORM_SECONDS_ON, - Dat_HMS_DO_NOT_SET, // Don't set hour, minute and second - false); // Don't submit on change - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\" style=\"width:20px;\""); + Ico_PutIcon ("clock.svg", + Gbl.Crs.Grps.GrpTyp.MustBeOpened ? Txt_The_groups_will_automatically_open : + Txt_The_groups_will_not_automatically_open, + Gbl.Crs.Grps.GrpTyp.MustBeOpened ? "CONTEXT_ICO_16x16" : + "ICO_HIDDEN CONTEXT_ICO_16x16"); + HTM_TD_End (); - HTM_TR_End (); - HTM_TABLE_End (); - HTM_TD_End (); + HTM_TD_Begin ("class=\"LM\""); + Dat_WriteFormClientLocalDateTimeFromTimeUTC ("open_time", + "Open", + Gbl.Crs.Grps.GrpTyp.OpenTimeUTC, + Gbl.Now.Date.Year, + Gbl.Now.Date.Year + 1, + Dat_FORM_SECONDS_ON, + Dat_HMS_DO_NOT_SET, // Don't set hour, minute and second + false); // Don't submit on change + HTM_TD_End (); - /***** Number of groups of this type *****/ - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Unsigned (0); // It's a new group type ==> 0 groups - HTM_TD_End (); + HTM_TR_End (); + HTM_TABLE_End (); + HTM_TD_End (); - HTM_TR_End (); + /***** Number of groups of this type *****/ + HTM_TD_Begin ("class=\"DAT CM\""); + HTM_Unsigned (0); // It's a new group type ==> 0 groups + HTM_TD_End (); - /***** End table, send button and end box *****/ - Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_type_of_group); + HTM_TR_End (); - /***** End form *****/ - Frm_EndForm (); + /***** End table, send button and end box *****/ + Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_type_of_group); + + /***** End form *****/ + Frm_EndForm (); + + /***** End section *****/ HTM_SECTION_End (); } @@ -2642,111 +2639,115 @@ static void Grp_PutFormToCreateGroup (const struct Roo_Rooms *Rooms) Rol_Role_t Role; char StrMaxStudents[Cns_MAX_DECIMAL_DIGITS_UINT + 1]; - /***** Begin form *****/ + /***** Begin section *****/ HTM_SECTION_Begin (Grp_NEW_GROUP_SECTION_ID); - Frm_StartFormAnchor (ActNewGrp,Grp_GROUPS_SECTION_ID); - /***** Begin box and table *****/ - Box_BoxTableBegin (NULL,Txt_New_group, - NULL,NULL, - NULL,Box_NOT_CLOSABLE,2); + /***** Begin form *****/ + Frm_StartFormAnchor (ActNewGrp,Grp_GROUPS_SECTION_ID); - /***** Write heading *****/ - Grp_WriteHeadingGroups (); + /***** Begin box and table *****/ + Box_BoxTableBegin (NULL,Txt_New_group, + NULL,NULL, + NULL,Box_NOT_CLOSABLE,2); - HTM_TR_Begin (NULL); + /***** Write heading *****/ + Grp_WriteHeadingGroups (); - /***** Empty column to remove *****/ - HTM_TD_Begin ("class=\"BM\""); - HTM_TD_End (); + HTM_TR_Begin (NULL); - /***** Disabled icon to open group *****/ - HTM_TD_Begin ("class=\"BM\""); - Ico_PutIconOff ("lock.svg",Txt_Group_closed); - HTM_TD_End (); + /***** Empty column to remove *****/ + HTM_TD_Begin ("class=\"BM\""); + HTM_TD_End (); - /***** Disabled icon for archive zone *****/ - HTM_TD_Begin ("class=\"BM\""); - Ico_PutIconOff ("folder-red.svg",Txt_File_zones_disabled); - HTM_TD_End (); + /***** Disabled icon to open group *****/ + HTM_TD_Begin ("class=\"BM\""); + Ico_PutIconOff ("lock.svg",Txt_Group_closed); + HTM_TD_End (); - /***** Group type *****/ - /* Start selector */ - HTM_TD_Begin ("class=\"CM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"GrpTypCod\" style=\"width:100px;\""); + /***** Disabled icon for archive zone *****/ + HTM_TD_Begin ("class=\"BM\""); + Ico_PutIconOff ("folder-red.svg",Txt_File_zones_disabled); + HTM_TD_End (); - /* Options for group types */ - for (NumGrpTyp = 0; - NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; - NumGrpTyp++) - HTM_OPTION (HTM_Type_LONG,&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod, - Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod == - Gbl.Crs.Grps.GrpTyp.GrpTypCod,false, - "%s",Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); + /***** Group type *****/ + /* Start selector */ + HTM_TD_Begin ("class=\"CM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"GrpTypCod\" style=\"width:100px;\""); - /* End selector */ - HTM_SELECT_End (); - HTM_TD_End (); + /* Options for group types */ + for (NumGrpTyp = 0; + NumGrpTyp < Gbl.Crs.Grps.GrpTypes.Num; + NumGrpTyp++) + HTM_OPTION (HTM_Type_LONG,&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod, + Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod == + Gbl.Crs.Grps.GrpTyp.GrpTypCod,false, + "%s",Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName); - /***** Group name *****/ - HTM_TD_Begin ("class=\"CM\""); - HTM_INPUT_TEXT ("GrpName",Grp_MAX_CHARS_GROUP_NAME,Gbl.Crs.Grps.GrpName, - HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"20\" required=\"required\""); - HTM_TD_End (); + /* End selector */ + HTM_SELECT_End (); + HTM_TD_End (); - /***** Room *****/ - /* Start selector */ - HTM_TD_Begin ("class=\"CM\""); - HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, - "name=\"RooCod\" style=\"width:100px;\""); + /***** Group name *****/ + HTM_TD_Begin ("class=\"CM\""); + HTM_INPUT_TEXT ("GrpName",Grp_MAX_CHARS_GROUP_NAME,Gbl.Crs.Grps.GrpName, + HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"20\" required=\"required\""); + HTM_TD_End (); - /* Option for no assigned room */ - HTM_OPTION (HTM_Type_STRING,"-1",Gbl.Crs.Grps.RooCod < 0,false, - "%s",Txt_No_assigned_room); + /***** Room *****/ + /* Start selector */ + HTM_TD_Begin ("class=\"CM\""); + HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE, + "name=\"RooCod\" style=\"width:100px;\""); - /* Option for another room */ - HTM_OPTION (HTM_Type_STRING,"0",Gbl.Crs.Grps.RooCod == 0,false, - "%s",Txt_Another_room); + /* Option for no assigned room */ + HTM_OPTION (HTM_Type_STRING,"-1",Gbl.Crs.Grps.RooCod < 0,false, + "%s",Txt_No_assigned_room); - /* Options for rooms */ - for (NumRoo = 0; - NumRoo < Rooms->Num; - NumRoo++) - HTM_OPTION (HTM_Type_LONG,&Rooms->Lst[NumRoo].RooCod, - Rooms->Lst[NumRoo].RooCod == Gbl.Crs.Grps.RooCod,false, - "%s",Rooms->Lst[NumRoo].ShrtName); + /* Option for another room */ + HTM_OPTION (HTM_Type_STRING,"0",Gbl.Crs.Grps.RooCod == 0,false, + "%s",Txt_Another_room); - /* End selector */ - HTM_SELECT_End (); - HTM_TD_End (); + /* Options for rooms */ + for (NumRoo = 0; + NumRoo < Rooms->Num; + NumRoo++) + HTM_OPTION (HTM_Type_LONG,&Rooms->Lst[NumRoo].RooCod, + Rooms->Lst[NumRoo].RooCod == Gbl.Crs.Grps.RooCod,false, + "%s",Rooms->Lst[NumRoo].ShrtName); - /***** Current number of users in this group *****/ - for (Role = Rol_TCH; - Role >= Rol_STD; - Role--) - { - HTM_TD_Begin ("class=\"DAT CM\""); - HTM_Unsigned (0); - HTM_TD_End (); - } + /* End selector */ + HTM_SELECT_End (); + HTM_TD_End (); - /***** Maximum number of students *****/ - HTM_TD_Begin ("class=\"CM\""); - Grp_WriteMaxStds (StrMaxStudents,Gbl.Crs.Grps.MaxStudents); - HTM_INPUT_TEXT ("MaxStudents",Cns_MAX_DECIMAL_DIGITS_UINT,StrMaxStudents, - HTM_DONT_SUBMIT_ON_CHANGE, - "size=\"3\""); - HTM_TD_End (); + /***** Current number of users in this group *****/ + for (Role = Rol_TCH; + Role >= Rol_STD; + Role--) + { + HTM_TD_Begin ("class=\"DAT CM\""); + HTM_Unsigned (0); + HTM_TD_End (); + } - HTM_TR_End (); + /***** Maximum number of students *****/ + HTM_TD_Begin ("class=\"CM\""); + Grp_WriteMaxStds (StrMaxStudents,Gbl.Crs.Grps.MaxStudents); + HTM_INPUT_TEXT ("MaxStudents",Cns_MAX_DECIMAL_DIGITS_UINT,StrMaxStudents, + HTM_DONT_SUBMIT_ON_CHANGE, + "size=\"3\""); + HTM_TD_End (); - /***** End table, send button and end box *****/ - Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_group); + HTM_TR_End (); - /***** End form *****/ - Frm_EndForm (); + /***** End table, send button and end box *****/ + Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_group); + + /***** End form *****/ + Frm_EndForm (); + + /***** End section *****/ HTM_SECTION_End (); } @@ -2871,7 +2872,6 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) /* Initialize pointer to the list of groups of this type */ Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].LstGrps = NULL; - } } @@ -2955,7 +2955,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) if (GrpTyp->NumGrps) // If there are groups of this type... { /***** Query database *****/ - GrpTyp->NumGrps = Grp_GetGrpsOfType (GrpTyp->GrpTypCod,&mysql_res); + GrpTyp->NumGrps = Grp_DB_GetGrpsOfType (GrpTyp->GrpTypCod,&mysql_res); if (GrpTyp->NumGrps > 0) // Groups found... { /***** Create list with groups of this type *****/ @@ -2994,7 +2994,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes) for (Role = Rol_TCH; Role >= Rol_STD; Role--) - Grp->NumUsrs[Role] = Grp_CountNumUsrsInGrp (Role,Grp->GrpCod); + Grp->NumUsrs[Role] = Grp_DB_CountNumUsrsInGrp (Role,Grp->GrpCod); /* Get maximum number of students in group (row[4]) */ Grp->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[4]); @@ -3051,7 +3051,7 @@ void Grp_FreeListGrpTypesAndGrps (void) /*********** Query the number of groups that hay in this course **************/ /*****************************************************************************/ -unsigned Grp_CountNumGrpsInCurrentCrs (void) +unsigned Grp_DB_CountNumGrpsInCurrentCrs (void) { /***** Get number of group in current course from database *****/ return (unsigned) @@ -3068,7 +3068,7 @@ unsigned Grp_CountNumGrpsInCurrentCrs (void) /****************** Count number of groups in a group type *******************/ /*****************************************************************************/ -static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod) +static unsigned Grp_DB_CountNumGrpsInThisCrsOfType (long GrpTypCod) { /***** Get number of groups of a type from database *****/ return (unsigned) @@ -3083,7 +3083,7 @@ static unsigned Grp_CountNumGrpsInThisCrsOfType (long GrpTypCod) /******************** Get groups of a type in this course ********************/ /*****************************************************************************/ -unsigned Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res) +unsigned Grp_DB_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res) { /***** Get groups of a type from database *****/ // Don't use INNER JOIN because there are groups without assigned room @@ -3133,7 +3133,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp) GrpTyp->MandatoryEnrolment = (row[1][0] == 'Y'); GrpTyp->MultipleEnrolment = (row[2][0] == 'Y'); GrpTyp->MustBeOpened = (row[3][0] == 'Y'); - GrpTyp->OpenTimeUTC = Dat_GetUNIXTimeFromStr (row[4]); + GrpTyp->OpenTimeUTC = Dat_GetUNIXTimeFromStr (row[4]); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -3245,10 +3245,9 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat) /* Get maximum number of students (row[7]) */ GrpDat->MaxStudents = Grp_ConvertToNumMaxStdsGrp (row[7]); - /* Get whether group is open or closed (row[8]) */ - GrpDat->Open = (row[8][0] == 'Y'); - - /* Get whether group has file zones (row[9]) */ + /* Get whether group is open or closed (row[8]), + and whether group has file zones (row[9]) */ + GrpDat->Open = (row[8][0] == 'Y'); GrpDat->FileZones = (row[9][0] == 'Y'); } @@ -3261,7 +3260,7 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat) /********************** Get the type of group of a group *********************/ /*****************************************************************************/ -static long Grp_GetTypeOfGroupOfAGroup (long GrpCod) +static long Grp_DB_GetTypeOfGroupOfAGroup (long GrpCod) { long GrpTypCod; @@ -3281,7 +3280,7 @@ static long Grp_GetTypeOfGroupOfAGroup (long GrpCod) /******************** Check if a group exists in database ********************/ /*****************************************************************************/ -bool Grp_CheckIfGroupExists (long GrpCod) +bool Grp_DB_CheckIfGroupExists (long GrpCod) { /***** Get if a group exists from database *****/ return (DB_QueryCOUNT ("can not check if a group exists", @@ -3295,7 +3294,7 @@ bool Grp_CheckIfGroupExists (long GrpCod) /******************* Check if a group belongs to a course ********************/ /*****************************************************************************/ -bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod) +bool Grp_DB_CheckIfGrpBelongsToCrs (long GrpCod,long CrsCod) { /***** Get if a group exists from database *****/ return (DB_QueryCOUNT ("can not check if a group belongs to a course", @@ -3312,7 +3311,7 @@ bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod) /********************* Count number of users in a group **********************/ /*****************************************************************************/ -unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod) +unsigned Grp_DB_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod) { /***** Get number of students in a group from database *****/ return (unsigned) @@ -3336,7 +3335,7 @@ unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod) /*** Count # of users of current course not belonging to groups of a type ****/ /*****************************************************************************/ -static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod) +static unsigned Grp_DB_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod) { /***** Get number of users not belonging to groups of a type ******/ return (unsigned) @@ -3361,7 +3360,7 @@ static unsigned Grp_CountNumUsrsInNoGrpsOfType (Rol_Role_t Role,long GrpTypCod) /********* Check if I belong to any groups of a given type I belong **********/ /*****************************************************************************/ -static bool Grp_CheckIfIBelongToGrpsOfType (long GrpTypCod) +static bool Grp_DB_CheckIfIBelongToGrpsOfType (long GrpTypCod) { /***** Get a group which I belong to from database *****/ return (DB_QueryCOUNT ("can not check if you belong to a group type", @@ -3399,13 +3398,13 @@ bool Grp_GetIfIBelongToGrp (long GrpCod) /***** 3. Slow check: Get if I belong to a group from database *****/ Gbl.Cache.IBelongToGrp.GrpCod = GrpCod; Gbl.Cache.IBelongToGrp.IBelong = - (DB_QueryCOUNT ("can not check if you belong to a group", - "SELECT COUNT(*)" - " FROM grp_users" - " WHERE GrpCod=%ld" - " AND UsrCod=%ld", - GrpCod, - Gbl.Usrs.Me.UsrDat.UsrCod) != 0); + (DB_QueryCOUNT ("can not check if you belong to a group", + "SELECT COUNT(*)" + " FROM grp_users" + " WHERE GrpCod=%ld" + " AND UsrCod=%ld", + GrpCod, + Gbl.Usrs.Me.UsrDat.UsrCod) != 0); return Gbl.Cache.IBelongToGrp.IBelong; } @@ -3471,23 +3470,23 @@ bool Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (const struct UsrData *UsrDat) /* Check if user shares any group with me */ Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.UsrCod = UsrDat->UsrCod; Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares = - (DB_QueryCOUNT ("can not check if a user shares any group" - " in the current course with you", - "SELECT COUNT(*)" - " FROM grp_users" - " WHERE UsrCod=%ld" - " AND GrpCod IN" - " (SELECT grp_users.GrpCod" - " FROM grp_users," - "grp_groups," - "grp_types" - " WHERE grp_users.UsrCod=%ld" - " AND grp_users.GrpCod=grp_groups.GrpCod" - " AND grp_groups.GrpTypCod=grp_types.GrpTypCod" - " AND grp_types.CrsCod=%ld)", - UsrDat->UsrCod, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Hierarchy.Crs.CrsCod) != 0); + (DB_QueryCOUNT ("can not check if a user shares any group" + " in the current course with you", + "SELECT COUNT(*)" + " FROM grp_users" + " WHERE UsrCod=%ld" + " AND GrpCod IN" + " (SELECT grp_users.GrpCod" + " FROM grp_users," + "grp_groups," + "grp_types" + " WHERE grp_users.UsrCod=%ld" + " AND grp_users.GrpCod=grp_groups.GrpCod" + " AND grp_groups.GrpTypCod=grp_types.GrpTypCod" + " AND grp_types.CrsCod=%ld)", + UsrDat->UsrCod, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Hierarchy.Crs.CrsCod) != 0); return Gbl.Cache.UsrSharesAnyOfMyGrpsInCurrentCrs.Shares; } @@ -3795,7 +3794,7 @@ void Grp_ReceiveFormNewGrpTyp (void) if (Gbl.Crs.Grps.GrpTyp.GrpTypName[0]) // If there's a group type name { /***** If name of group type was in database... *****/ - if (Grp_CheckIfGroupTypeNameExists (Gbl.Crs.Grps.GrpTyp.GrpTypName,-1L)) + if (Grp_DB_CheckIfGroupTypeNameExists (Gbl.Crs.Grps.GrpTyp.GrpTypName,-1L)) { AlertType = Ale_WARNING; snprintf (AlertTxt,sizeof (AlertTxt), @@ -3804,7 +3803,7 @@ void Grp_ReceiveFormNewGrpTyp (void) } else // Add new group type to database { - Grp_CreateGroupType (); + Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_DB_CreateGroupType (&Gbl.Crs.Grps.GrpTyp); AlertType = Ale_SUCCESS; snprintf (AlertTxt,sizeof (AlertTxt), @@ -3870,7 +3869,7 @@ void Grp_ReceiveFormNewGrp (void) if (Gbl.Crs.Grps.GrpName[0]) // If there's a group name { /***** If name of group was in database... *****/ - if (Grp_CheckIfGroupNameExists (Gbl.Crs.Grps.GrpTyp.GrpTypCod,Gbl.Crs.Grps.GrpName,-1L)) + if (Grp_DB_CheckIfGroupNameExists (Gbl.Crs.Grps.GrpTyp.GrpTypCod,Gbl.Crs.Grps.GrpName,-1L)) { AlertType = Ale_WARNING; snprintf (AlertTxt,sizeof (AlertTxt), @@ -3879,7 +3878,7 @@ void Grp_ReceiveFormNewGrp (void) } else // Add new group to database { - Grp_CreateGroup (); + Grp_DB_CreateGroup (); /* Write success message */ AlertType = Ale_SUCCESS; @@ -3911,7 +3910,7 @@ void Grp_ReceiveFormNewGrp (void) /******************* Check if name of group type exists **********************/ /*****************************************************************************/ -static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod) +static bool Grp_DB_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCod) { /***** Get number of group types with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name of type of group" @@ -3928,7 +3927,7 @@ static bool Grp_CheckIfGroupTypeNameExists (const char *GrpTypName,long GrpTypCo /************************ Check if name of group exists **********************/ /*****************************************************************************/ -static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod) +static bool Grp_DB_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long GrpCod) { /***** Get number of groups with a type and a name from database *****/ return (DB_QueryCOUNT ("can not check if the name of group already existed", @@ -3944,10 +3943,10 @@ static bool Grp_CheckIfGroupNameExists (long GrpTypCod,const char *GrpName,long /************************** Create a new group type **************************/ /*****************************************************************************/ -static void Grp_CreateGroupType (void) +static long Grp_DB_CreateGroupType (const struct GroupType *GrpTyp) { /***** Create a new group type *****/ - Gbl.Crs.Grps.GrpTyp.GrpTypCod = + return DB_QueryINSERTandReturnCode ("can not create type of group", "INSERT INTO grp_types" " (CrsCod,GrpTypName," @@ -3956,21 +3955,21 @@ static void Grp_CreateGroupType (void) " (%ld,'%s'," "'%c','%c','%c',FROM_UNIXTIME(%ld))", Gbl.Hierarchy.Crs.CrsCod, - Gbl.Crs.Grps.GrpTyp.GrpTypName, - Gbl.Crs.Grps.GrpTyp.MandatoryEnrolment ? 'Y' : - 'N', - Gbl.Crs.Grps.GrpTyp.MultipleEnrolment ? 'Y' : - 'N', - Gbl.Crs.Grps.GrpTyp.MustBeOpened ? 'Y' : - 'N', - (long) Gbl.Crs.Grps.GrpTyp.OpenTimeUTC); + GrpTyp->GrpTypName, + GrpTyp->MandatoryEnrolment ? 'Y' : + 'N', + GrpTyp->MultipleEnrolment ? 'Y' : + 'N', + GrpTyp->MustBeOpened ? 'Y' : + 'N', + (long) GrpTyp->OpenTimeUTC); } /*****************************************************************************/ /***************************** Create a new group ****************************/ /*****************************************************************************/ -static void Grp_CreateGroup (void) +static void Grp_DB_CreateGroup (void) { /***** Create a new group *****/ DB_QueryINSERT ("can not create group", @@ -3997,7 +3996,7 @@ void Grp_ReqRemGroupType (void) Err_WrongGrpTypExit (); /***** Check if this group type has groups *****/ - if ((NumGrps = Grp_CountNumGrpsInThisCrsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod))) // Group type has groups ==> Ask for confirmation + if ((NumGrps = Grp_DB_CountNumGrpsInThisCrsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod))) // Group type has groups ==> Ask for confirmation Grp_AskConfirmRemGrpTypWithGrps (NumGrps); else // Group type has no groups ==> remove directly Grp_RemoveGroupTypeCompletely (); @@ -4070,7 +4069,7 @@ static void Grp_AskConfirmRemGrp (void) Grp_GetDataOfGroupByCod (&GrpDat); /***** Count number of students in group *****/ - NumStds = Grp_CountNumUsrsInGrp (Rol_STD,Gbl.Crs.Grps.GrpCod); + NumStds = Grp_DB_CountNumUsrsInGrp (Rol_STD,Gbl.Crs.Grps.GrpCod); /***** Show the form to edit group types again *****/ Grp_ReqEditGroupsInternal0 (); @@ -4420,7 +4419,7 @@ void Grp_ChangeGroupType (void) Grp_GetDataOfGroupByCod (&GrpDat); /***** If group was in database... *****/ - if (Grp_CheckIfGroupNameExists (NewGrpTypCod,GrpDat.GrpName,-1L)) + if (Grp_DB_CheckIfGroupNameExists (NewGrpTypCod,GrpDat.GrpName,-1L)) { /* Create warning message */ AlertType = Ale_WARNING; @@ -4776,7 +4775,7 @@ void Grp_RenameGroupType (void) if (strcmp (Gbl.Crs.Grps.GrpTyp.GrpTypName,NewNameGrpTyp)) // Different names { /***** If group type was in database... *****/ - if (Grp_CheckIfGroupTypeNameExists (NewNameGrpTyp,Gbl.Crs.Grps.GrpTyp.GrpTypCod)) + if (Grp_DB_CheckIfGroupTypeNameExists (NewNameGrpTyp,Gbl.Crs.Grps.GrpTyp.GrpTypCod)) { AlertType = Ale_WARNING; snprintf (AlertTxt,sizeof (AlertTxt), @@ -4862,7 +4861,7 @@ void Grp_RenameGroup (void) if (strcmp (GrpDat.GrpName,NewNameGrp)) // Different names { /***** If group was in database... *****/ - if (Grp_CheckIfGroupNameExists (GrpDat.GrpTypCod,NewNameGrp,Gbl.Crs.Grps.GrpCod)) + if (Grp_DB_CheckIfGroupNameExists (GrpDat.GrpTypCod,NewNameGrp,Gbl.Crs.Grps.GrpCod)) { AlertType = Ale_WARNING; snprintf (AlertTxt,sizeof (AlertTxt), diff --git a/swad_group.h b/swad_group.h index 718bec5d..5e502648 100644 --- a/swad_group.h +++ b/swad_group.h @@ -184,7 +184,7 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp, Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp, long Cod); -bool Grp_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod); +bool Grp_DB_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod); void Grp_ReqRegisterInGrps (void); void Grp_ShowLstGrpsToChgMyGrps (void); void Grp_ShowLstGrpsToChgOtherUsrsGrps (long UsrCod); @@ -193,12 +193,12 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes); void Grp_FreeListGrpTypesAndGrps (void); void Grp_OpenGroupsAutomatically (void); void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes); -unsigned Grp_CountNumGrpsInCurrentCrs (void); -unsigned Grp_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res); +unsigned Grp_DB_CountNumGrpsInCurrentCrs (void); +unsigned Grp_DB_GetGrpsOfType (long GrpTypCod,MYSQL_RES **mysql_res); void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat); -bool Grp_CheckIfGroupExists (long GrpCod); -bool Grp_CheckIfGroupBelongsToCourse (long GrpCod,long CrsCod); -unsigned Grp_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod); +bool Grp_DB_CheckIfGroupExists (long GrpCod); +bool Grp_DB_CheckIfGrpBelongsToCrs (long GrpCod,long CrsCod); +unsigned Grp_DB_CountNumUsrsInGrp (Rol_Role_t Role,long GrpCod); void Grp_FlushCacheIBelongToGrp (void); bool Grp_GetIfIBelongToGrp (long GrpCod); diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 60bdcc52..9d781e79 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -617,7 +617,7 @@ void Hie_InitHierarchy (void) /***** Count number of groups in current course (used in some actions) *****/ - Gbl.Crs.Grps.NumGrps = Grp_CountNumGrpsInCurrentCrs (); + Gbl.Crs.Grps.NumGrps = Grp_DB_CountNumGrpsInCurrentCrs (); } } diff --git a/swad_indicator.c b/swad_indicator.c index 19af4ecf..4edd770d 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -1451,7 +1451,7 @@ void Ind_ComputeAndStoreIndicatorsCrs (long CrsCod,int NumIndicatorsFromDB, IndicatorsCrs->NumIndicators++; /***** Indicator #3: information about online tutoring *****/ - IndicatorsCrs->NumThreads = For_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod); + IndicatorsCrs->NumThreads = For_DB_GetNumTotalThrsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod); IndicatorsCrs->NumPosts = For_GetNumTotalPstsInForumsOfType (For_FORUM_COURSE_USRS,-1L,-1L,-1L,-1L,CrsCod,&(IndicatorsCrs->NumUsrsToBeNotifiedByEMail)); IndicatorsCrs->NumMsgsSentByTchs = Msg_GetNumMsgsSentByTchsCrs (CrsCod); IndicatorsCrs->ThereIsOnlineTutoring = (IndicatorsCrs->NumThreads != 0) || diff --git a/swad_layout.c b/swad_layout.c index 9c0cfa42..3c477c15 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1436,11 +1436,11 @@ void Lay_RefreshNotifsAndConnected (void) if (!(Gbl.PID % 11)) Ntf_SendPendingNotifByEMailToAllUsrs (); // Send pending notifications by email else if (!(Gbl.PID % 19)) - Fir_PurgeFirewall (); // Remove old clicks from firewall + Fir_DB_PurgeFirewall (); // Remove old clicks from firewall else if (!(Gbl.PID % 23)) Fil_RemoveOldTmpFiles (Cfg_PATH_FILE_BROWSER_TMP_PUBLIC ,Cfg_TIME_TO_DELETE_BROWSER_TMP_FILES ,false); // Remove the oldest temporary public directories used for downloading else if (!(Gbl.PID % 101)) - Brw_RemoveExpiredExpandedFolders (); // Remove old expanded folders (from all users) + Brw_DB_RemoveExpiredExpandedFolders (); // Remove old expanded folders (from all users) else if (!(Gbl.PID % 103)) Set_RemoveOldSettingsFromIP (); // Remove old settings from IP else if (!(Gbl.PID % 107)) diff --git a/swad_main.c b/swad_main.c index 516383a0..d0bc44d4 100644 --- a/swad_main.c +++ b/swad_main.c @@ -117,7 +117,7 @@ int main (void) /***** Mitigate DoS attacks *****/ Fir_CheckFirewallAndExitIfBanned (); - Fir_LogAccess (); + Fir_DB_LogAccess (); Fir_CheckFirewallAndExitIfTooManyRequests (); Hie_InitHierarchy (); diff --git a/swad_mark.c b/swad_mark.c index e3270ed9..c4e3cf7f 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -614,7 +614,7 @@ void Mrk_ShowMyMarks (void) /* Select a random student from the course */ if (Gbl.Crs.Grps.GrpCod > 0) // Group zone { - if (Grp_CountNumUsrsInGrp (Rol_STD,Gbl.Crs.Grps.GrpCod)) // If there are students in this group + if (Grp_DB_CountNumUsrsInGrp (Rol_STD,Gbl.Crs.Grps.GrpCod)) // If there are students in this group { Gbl.Usrs.Other.UsrDat.UsrCod = Usr_GetRamdomStdFromGrp (Gbl.Crs.Grps.GrpCod); UsrDat = &Gbl.Usrs.Other.UsrDat; diff --git a/swad_match.c b/swad_match.c index 0ee4695c..0a485e52 100644 --- a/swad_match.c +++ b/swad_match.c @@ -1594,7 +1594,7 @@ 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_CheckIfAssociatedToGrps ("mch_groups","MchCod",MchCod) ? "" : + Grp_DB_CheckIfAssociatedToGrps ("mch_groups","MchCod",MchCod) ? "" : " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); diff --git a/swad_profile.c b/swad_profile.c index dad78558..cc9254f3 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -578,8 +578,8 @@ static void Prf_ShowNumFilesCurrentlyPublished (const struct UsrData *UsrDat) unsigned NumPublicFiles; /***** Number of files currently published *****/ - if ((NumFiles = Brw_GetNumFilesUsr (UsrDat->UsrCod))) - NumPublicFiles = Brw_GetNumPublicFilesUsr (UsrDat->UsrCod); + if ((NumFiles = Brw_DB_GetNumFilesUsr (UsrDat->UsrCod))) + NumPublicFiles = Brw_DB_GetNumPublicFilesUsr (UsrDat->UsrCod); else NumPublicFiles = 0; @@ -1177,7 +1177,7 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod) Prf_ResetUsrFigures (&UsrFigures); /***** Get number of file views from database *****/ - UsrFigures.NumFileViews = (long) Brw_GetNumFileViewsUsr (UsrCod); + UsrFigures.NumFileViews = (long) Brw_DB_GetNumFileViewsUsr (UsrCod); /***** Update number of file views in user's figures *****/ if (Prf_CheckIfUsrFiguresExists (UsrCod)) @@ -1206,7 +1206,7 @@ static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod) Prf_ResetUsrFigures (&UsrFigures); /***** Get number of forum posts from database *****/ - UsrFigures.NumForPst = For_GetNumPostsUsr (UsrCod); + UsrFigures.NumForPst = For_DB_GetNumPostsUsr (UsrCod); /***** Update number of forum posts in user's figures *****/ if (Prf_CheckIfUsrFiguresExists (UsrCod)) diff --git a/swad_report.c b/swad_report.c index 838fe50b..551227d4 100644 --- a/swad_report.c +++ b/swad_report.c @@ -655,8 +655,8 @@ static void Rep_WriteSectionUsrFigures (const struct Rep_Report *Report) fprintf (Gbl.F.Rep,""); /***** Number of files currently published *****/ - if ((NumFiles = Brw_GetNumFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod))) - NumPublicFiles = Brw_GetNumPublicFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod); + if ((NumFiles = Brw_DB_GetNumFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod))) + NumPublicFiles = Brw_DB_GetNumPublicFilesUsr (Gbl.Usrs.Me.UsrDat.UsrCod); else NumPublicFiles = 0; fprintf (Gbl.F.Rep,"
  • " diff --git a/swad_setting.c b/swad_setting.c index a94fb764..df7f89a1 100644 --- a/swad_setting.c +++ b/swad_setting.c @@ -428,6 +428,22 @@ void Set_DB_InsertUsrInCrsSettings (long UsrCod,long CrsCod) 'N'); } +/*****************************************************************************/ +/******** Update the group of my last access to a file browser zone **********/ +/*****************************************************************************/ + +void Set_DB_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod) + { + DB_QueryUPDATE ("can not update the group of the last access to a file browser", + "UPDATE crs_user_settings" + " SET %s=%ld" + " WHERE UsrCod=%ld" + " AND CrsCod=%ld", + FieldNameDB,GrpCod, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Hierarchy.Crs.CrsCod); + } + /*****************************************************************************/ /****************** Remove a user from a courses setting *********************/ /*****************************************************************************/ diff --git a/swad_setting.h b/swad_setting.h index a6a60305..e3220083 100644 --- a/swad_setting.h +++ b/swad_setting.h @@ -59,6 +59,9 @@ void Set_BeginOneSettingSelector (void); void Set_EndOneSettingSelector (void); void Set_DB_InsertUsrInCrsSettings (long UsrCod,long CrsCod); + +void Set_DB_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod); + void Set_DB_RemUsrFromCrsSettings (long UsrCod,long CrsCod); void Set_DB_RemUsrFromAllCrssSettings (long UsrCod); void Set_DB_RemAllUsrsFromCrsSettings (long CrsCod); diff --git a/swad_survey.c b/swad_survey.c index 4c05cc73..7c0c0f15 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -2155,7 +2155,7 @@ 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_CheckIfAssociatedToGrps ("svy_groups","SvyCod",SvyCod) ? "" : + Grp_DB_CheckIfAssociatedToGrps ("svy_groups","SvyCod",SvyCod) ? "" : " checked=\"checked\""); HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName); HTM_LABEL_End (); diff --git a/swad_user.c b/swad_user.c index 20b15de2..6a9ed94b 100644 --- a/swad_user.c +++ b/swad_user.c @@ -10386,3 +10386,95 @@ unsigned Usr_DB_GetOldUsrs (MYSQL_RES **mysql_res,time_t SecondsWithoutAccess) " FROM crs_users)", (unsigned long long) SecondsWithoutAccess); } + +/*****************************************************************************/ +/************** Get number of users who have chosen an option ****************/ +/*****************************************************************************/ + +unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery) + { + switch (Gbl.Scope.Current) + { + case HieLvl_SYS: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(*)" + " FROM usr_data WHERE %s", + SubQuery); + case HieLvl_CTY: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(DISTINCT usr_data.UsrCod)" + " FROM ins_instits," + "ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_data" + " WHERE ins_instits.CtyCod=%ld" + " AND ins_instits.InsCod=ctr_centers.InsCod" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_data.UsrCod" + " AND %s", + Gbl.Hierarchy.Cty.CtyCod,SubQuery); + case HieLvl_INS: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(DISTINCT usr_data.UsrCod)" + " FROM ctr_centers," + "deg_degrees," + "crs_courses," + "crs_users," + "usr_data" + " WHERE ctr_centers.InsCod=%ld" + " AND ctr_centers.CtrCod=deg_degrees.CtrCod" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_data.UsrCod" + " AND %s", + Gbl.Hierarchy.Ins.InsCod,SubQuery); + case HieLvl_CTR: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(DISTINCT usr_data.UsrCod)" + " FROM deg_degrees," + "crs_courses," + "crs_users," + "usr_data" + " WHERE deg_degrees.CtrCod=%ld" + " AND deg_degrees.DegCod=crs_courses.DegCod" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_data.UsrCod" + " AND %s", + Gbl.Hierarchy.Ctr.CtrCod,SubQuery); + case HieLvl_DEG: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(DISTINCT usr_data.UsrCod)" + " FROM crs_courses," + "crs_users," + "usr_data" + " WHERE crs_courses.DegCod=%ld" + " AND crs_courses.CrsCod=crs_users.CrsCod" + " AND crs_users.UsrCod=usr_data.UsrCod" + " AND %s", + Gbl.Hierarchy.Deg.DegCod,SubQuery); + case HieLvl_CRS: + return (unsigned) + DB_QueryCOUNT ("can not get the number of users who have chosen an option", + "SELECT COUNT(DISTINCT usr_data.UsrCod)" + " FROM crs_users," + "usr_data" + " WHERE crs_users.CrsCod=%ld" + " AND crs_users.UsrCod=usr_data.UsrCod" + " AND %s", + Gbl.Hierarchy.Crs.CrsCod,SubQuery); + default: + Err_WrongScopeExit (); + return 0; // Not reached + } + + return 0; // Not reached + } diff --git a/swad_user.h b/swad_user.h index 4af46f3d..3973fd13 100644 --- a/swad_user.h +++ b/swad_user.h @@ -554,4 +554,6 @@ Usr_Who_t Usr_GetHiddenParamWho (void); unsigned Usr_DB_GetOldUsrs (MYSQL_RES **mysql_res,time_t SecondsWithoutAccess); +unsigned Usr_DB_GetNumUsrsWhoChoseAnOption (const char *SubQuery); + #endif