From f5efd11ecdab7d0bcdaeba4ac8fc2201c443f457 Mon Sep 17 00:00:00 2001 From: acanas Date: Fri, 23 Sep 2022 21:53:35 +0200 Subject: [PATCH] Version 22.23: Sep 23, 2022 New module swad_call_for_exam_resource. --- Makefile | 14 +-- css/{swad22.21.css => swad22.22.1.css} | 11 +- swad_action.c | 4 +- swad_assignment.h | 6 - swad_assignment_resource.h | 8 +- swad_attendance.c | 4 +- swad_attendance.h | 4 +- swad_box.c | 66 ++++++----- swad_call_for_exam.c | 155 ++----------------------- swad_call_for_exam.h | 16 ++- swad_call_for_exam_resource.c | 155 +++++++++++++++++++++++++ swad_call_for_exam_resource.h | 41 +++++++ swad_changelog.h | 6 +- swad_program.c | 2 +- swad_program_resource.c | 85 +++++++------- 15 files changed, 328 insertions(+), 249 deletions(-) rename css/{swad22.21.css => swad22.22.1.css} (99%) create mode 100644 swad_call_for_exam_resource.c create mode 100644 swad_call_for_exam_resource.h diff --git a/Makefile b/Makefile index fb04a0d5..791f1d5f 100644 --- a/Makefile +++ b/Makefile @@ -35,13 +35,13 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \ swad_banner.o swad_banner_database.o swad_box.o swad_browser.o \ swad_browser_database.o swad_building.o swad_building_database.o \ swad_button.o \ - swad_calendar.o swad_call_for_exam.o swad_call_for_exam_database.o \ - swad_center.o swad_center_config.o swad_center_database.o swad_chat.o \ - swad_chat_database.o swad_config.o swad_connected.o \ - swad_connected_database.o swad_cookie.o swad_cookie_database.o \ - swad_country.o swad_country_config.o swad_country_database.o \ - swad_course.o swad_course_config.o swad_course_database.o \ - swad_cryptography.o \ + swad_calendar.o swad_call_for_exam.o swad_call_for_exam_resource.o \ + swad_call_for_exam_database.o swad_center.o swad_center_config.o \ + swad_center_database.o swad_chat.o swad_chat_database.o swad_config.o \ + swad_connected.o swad_connected_database.o swad_cookie.o \ + swad_cookie_database.o swad_country.o swad_country_config.o \ + swad_country_database.o swad_course.o swad_course_config.o \ + swad_course_database.o swad_cryptography.o \ swad_database.o swad_date.o swad_degree.o swad_degree_config.o \ swad_degree_database.o swad_degree_type.o swad_department.o \ swad_department_database.o swad_duplicate.o swad_duplicate_database.o \ diff --git a/css/swad22.21.css b/css/swad22.22.1.css similarity index 99% rename from css/swad22.21.css rename to css/swad22.22.1.css index 1c408216..9a9ba062 100644 --- a/css/swad22.21.css +++ b/css/swad22.22.1.css @@ -2125,7 +2125,8 @@ a:hover img.CENTER_PHOTO_SHOW display:inline-block; box-sizing:border-box; margin:2px 0; - padding:8px 12px 12px 12px; + padding:10px; + /* padding:8px 12px 12px 12px; */ border-radius:2px; box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 2px 1px -2px rgba(0,0,0,0.2), 0 1px 5px 0 rgba(0,0,0,0.12); text-align:center; @@ -3640,7 +3641,13 @@ table.CELLS_PAD_10 > tbody > tr > td {padding:10px;} .MCH_LIMEGREEN {color:#636e00;} .MCH_GREEN {color:#246600;} -.MCH_TCH_STEM_WHITE +.MCH_TCH_STEM_WHITE, +.MCH_TCH_STEM_GREY, +.MCH_TCH_STEM_PURPLE, +.MCH_TCH_STEM_BLUE, +.MCH_TCH_STEM_YELLOW, +.MCH_TCH_STEM_PINK +.MCH_TCH_STEM_DARK { color:#202020; font-size:24pt; diff --git a/swad_action.c b/swad_action.c index c7094a7b..7ee06220 100644 --- a/swad_action.c +++ b/swad_action.c @@ -29,11 +29,13 @@ #include "swad_admin.h" #include "swad_agenda.h" #include "swad_announcement.h" +#include "swad_assignment_resource.h" #include "swad_attendance.h" #include "swad_banner.h" #include "swad_building.h" #include "swad_calendar.h" #include "swad_call_for_exam.h" +#include "swad_call_for_exam_resource.h" #include "swad_center_config.h" #include "swad_config.h" #include "swad_cookie.h" @@ -1425,7 +1427,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActHidAtt ] = {1069,-1,TabUnk,ActSeeAtt ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_HideAttEvent ,NULL}, [ActUnhAtt ] = {1070,-1,TabUnk,ActSeeAtt ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_UnhideAttEvent ,NULL}, [ActSeeOneAtt ] = {1071,-1,TabUnk,ActSeeAtt ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_SeeOneAttEvent ,NULL}, - [ActReqLnkAtt ] = {1938,-1,TabUnk,ActSeeAtt ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_GetLinkToEvent ,NULL}, + [ActReqLnkAtt ] = {1938,-1,TabUnk,ActSeeAtt ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,AttRsc_GetLinkToEvent ,NULL}, [ActRecAttStd ] = {1072,-1,TabUnk,ActSeeAtt ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_RegisterStudentsInAttEvent ,NULL}, [ActRecAttMe ] = {1076,-1,TabUnk,ActSeeAtt ,0x008, 0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Att_RegisterMeAsStdInAttEvent ,NULL}, diff --git a/swad_assignment.h b/swad_assignment.h index 87ef5991..9faeac56 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -112,10 +112,4 @@ unsigned Asg_GetNumAssignments (HieLvl_Level_t Scope,unsigned *NumNotif); //-------------------------------- Figures ------------------------------------ void Asg_GetAndShowAssignmentsStats (void); -//--------------------------- Program resources ------------------------------- -void AsgRsc_GetLinkToAssignment (void); -void AsgRsc_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo, - const char *Icon,const char *IconTitle); -void AsgRsc_GetTitleFromAsgCod (long AsgCod,char *Title,size_t TitleSize); - #endif diff --git a/swad_assignment_resource.h b/swad_assignment_resource.h index 527030cb..e975924f 100644 --- a/swad_assignment_resource.h +++ b/swad_assignment_resource.h @@ -34,9 +34,9 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Asg_GetLinkToAssignment (void); -void Asg_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo, - const char *Icon,const char *IconTitle); -void Asg_GetTitleFromAsgCod (long AsgCod,char *Title,size_t TitleSize); +void AsgRsc_GetLinkToAssignment (void); +void AsgRsc_WriteAssignmentInCrsProgram (long AsgCod,bool PutFormToGo, + const char *Icon,const char *IconTitle); +void AsgRsc_GetTitleFromAsgCod (long AsgCod,char *Title,size_t TitleSize); #endif diff --git a/swad_attendance.c b/swad_attendance.c index 815ab641..e3d6ae90 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -3300,7 +3300,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events, /************************ Get link to attendance event ***********************/ /*****************************************************************************/ -void Att_GetLinkToEvent (void) +void AttRsc_GetLinkToEvent (void) { extern const char *Txt_Link_to_resource_X_copied_into_clipboard; long AttCod; @@ -3329,7 +3329,7 @@ void Att_GetLinkToEvent (void) /*****************************************************************************/ void AttRsc_WriteAttEventInCrsProgram (long AttCod,bool PutFormToGo, - const char *Icon,const char *IconTitle) + const char *Icon,const char *IconTitle) { extern const char *Txt_Actions[Act_NUM_ACTIONS]; char Title[Att_MAX_BYTES_ATTENDANCE_EVENT_TITLE + 1]; diff --git a/swad_attendance.h b/swad_attendance.h index fa1f2485..d8ca11dd 100644 --- a/swad_attendance.h +++ b/swad_attendance.h @@ -110,9 +110,9 @@ void Att_ListUsrsAttendanceCrs (void); void Att_PrintUsrsAttendanceCrs (void); //--------------------------- Program resources ------------------------------- -void Att_GetLinkToEvent (void); +void AttRsc_GetLinkToEvent (void); void AttRsc_WriteAttEventInCrsProgram (long AttCod,bool PutFormToGo, - const char *Icon,const char *IconTitle); + const char *Icon,const char *IconTitle); void AttRsc_GetTitleFromAttCod (long AttCod,char *Title,size_t TitleSize); #endif diff --git a/swad_box.c b/swad_box.c index 87f55de9..550a8c80 100644 --- a/swad_box.c +++ b/swad_box.c @@ -155,40 +155,46 @@ static void Box_BoxInternalBegin (const char *Width,const char *Title, HTM_DIV_Begin ("class=\"%s\"",ClassFrame); /***** Row for left and right icons *****/ - HTM_DIV_Begin ("class=\"FRAME_ICO\""); + if (FunctionToDrawContextualIcons || + HelpLink || + Closable == Box_CLOSABLE) + { + /* Begin row for left and right icons */ + HTM_DIV_Begin ("class=\"FRAME_ICO\""); + + /* Contextual icons at left */ + if (FunctionToDrawContextualIcons) + { + HTM_DIV_Begin ("class=\"FRAME_ICO_LEFT\""); + FunctionToDrawContextualIcons (Args); + HTM_DIV_End (); + } + + /* Icons at right: help and close */ + HTM_DIV_Begin ("class=\"FRAME_ICO_RIGHT\""); + + if (HelpLink) // Link to help + { + HTM_A_Begin ("href=\"%s%s\" target=\"_blank\"",Hlp_WIKI,HelpLink); + Ico_PutDivIcon ("CONTEXT_OPT HLP_HIGHLIGHT", + "question.svg",Ico_BLACK,Txt_Help); + HTM_A_End (); + } + + if (Closable == Box_CLOSABLE) // Icon to close the box + { + HTM_A_Begin ("href=\"\" onclick=\"toggleDisplay('%s');return false;\"", + Gbl.Box.Ids[Gbl.Box.Nested]); + Ico_PutDivIcon ("CONTEXT_OPT HLP_HIGHLIGHT", + "times.svg",Ico_BLACK,Txt_Close); + HTM_A_End (); + } - /* Contextual icons at left */ - if (FunctionToDrawContextualIcons) - { - HTM_DIV_Begin ("class=\"FRAME_ICO_LEFT\""); - FunctionToDrawContextualIcons (Args); HTM_DIV_End (); - } - - /* Icons at right: help and close */ - HTM_DIV_Begin ("class=\"FRAME_ICO_RIGHT\""); - - if (HelpLink) // Link to help - { - HTM_A_Begin ("href=\"%s%s\" target=\"_blank\"",Hlp_WIKI,HelpLink); - Ico_PutDivIcon ("CONTEXT_OPT HLP_HIGHLIGHT", - "question.svg",Ico_BLACK,Txt_Help); - HTM_A_End (); - } - - if (Closable == Box_CLOSABLE) // Icon to close the box - { - HTM_A_Begin ("href=\"\" onclick=\"toggleDisplay('%s');return false;\"", - Gbl.Box.Ids[Gbl.Box.Nested]); - Ico_PutDivIcon ("CONTEXT_OPT HLP_HIGHLIGHT", - "times.svg",Ico_BLACK,Txt_Close); - HTM_A_End (); - } + /* End row for left and right icons */ HTM_DIV_End (); - - /***** End row for left and right icons *****/ - HTM_DIV_End (); + } /***** Frame title *****/ if (Title) diff --git a/swad_call_for_exam.c b/swad_call_for_exam.c index 3d6f1788..c96c6975 100644 --- a/swad_call_for_exam.c +++ b/swad_call_for_exam.c @@ -1,4 +1,4 @@ -// swad_exam_announcement.c: calls for exams +// swad_call_for_exam.c: calls for exams /* SWAD (Shared Workspace At a Distance), @@ -54,12 +54,6 @@ #include "swad_timeline.h" #include "swad_timeline_database.h" -/*****************************************************************************/ -/**************************** Private constants ******************************/ -/*****************************************************************************/ - -#define Cfe_MAX_BYTES_SESSION_AND_DATE (Cfe_MAX_BYTES_SESSION + (2 + Cns_MAX_BYTES_DATE + 7) + 1) - /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ @@ -70,13 +64,8 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static struct Cfe_CallsForExams *Cfe_GetGlobalCallsForExams (void); - static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams); -static void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams); -static void Cfe_FreeMemCallForExam (struct Cfe_CallsForExams *CallsForExams); - static void Cfe_GetExaCodToHighlight (struct Cfe_CallsForExams *CallsForExams); static void Cfe_GetDateToHighlight (struct Cfe_CallsForExams *CallsForExams); @@ -85,27 +74,21 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams, static void Cfe_PutIconToCreateNewCallForExam (__attribute__((unused)) void *Args); static void Cfe_PutButtonToCreateNewCallForExam (void); -static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExams, - long ExaCod); static void Cfe_ShowCallForExam (struct Cfe_CallsForExams *CallsForExams, long ExaCod, Cfe_TypeViewCallForExam_t TypeViewCallForExam, bool HighLight); static void Cfe_PutIconsCallForExam (void *CallsForExams); static void Cfe_PutParamExaCodToEdit (void *ExaCod); -static long Cfe_GetParamExaCod (void); static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *CallsForExams, char **ContentStr); -static void Cfe_BuildSessionAndDate (const struct Cfe_CallsForExams *CallsForExams, - char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]); - /*****************************************************************************/ /******************** Get global calls for exams context *********************/ /*****************************************************************************/ -static struct Cfe_CallsForExams *Cfe_GetGlobalCallsForExams (void) +struct Cfe_CallsForExams *Cfe_GetGlobalCallsForExams (void) { static struct Cfe_CallsForExams Cfe_GlobalCallsForExams; // Used to preserve information between priori and posteriori functions @@ -246,7 +229,7 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams) /* Allocate memory for those parameters of an exam anno. with a lot of text **/ /*****************************************************************************/ -static void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams) +void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams) { if ((CallsForExams->CallForExam.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL) Err_NotEnoughMemoryExit (); @@ -274,7 +257,7 @@ static void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams) /* Free memory of those parameters of an exam announcem. with a lot of text **/ /*****************************************************************************/ -static void Cfe_FreeMemCallForExam (struct Cfe_CallsForExams *CallsForExams) +void Cfe_FreeMemCallForExam (struct Cfe_CallsForExams *CallsForExams) { if (CallsForExams->CallForExam.Place) { @@ -794,8 +777,8 @@ void Cfe_FreeListCallsForExams (struct Cfe_CallsForExams *CallsForExams) /*********** Read the data of a call for exam from the database **************/ /*****************************************************************************/ -static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExams, - long ExaCod) +void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExams, + long ExaCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1565,7 +1548,7 @@ void Cfe_PutHiddenParamExaCod (long ExaCod) /************ Get parameter with the code of a call for exam *****************/ /*****************************************************************************/ -static long Cfe_GetParamExaCod (void) +long Cfe_GetParamExaCod (void) { /* Get notice code */ return Par_GetParToLong ("ExaCod"); @@ -1688,133 +1671,11 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call Err_NotEnoughMemoryExit (); } -/*****************************************************************************/ -/************************ Get link to call for exam **************************/ -/*****************************************************************************/ - -void Cfe_GetLinkToCallForExam (void) - { - extern const char *Txt_Link_to_resource_X_copied_into_clipboard; - struct Cfe_CallsForExams *CallsForExams = Cfe_GetGlobalCallsForExams (); - long ExaCod; - char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; - - /***** Reset calls for exams context *****/ - Cfe_ResetCallsForExams (CallsForExams); - - /***** Get the code of the call for exam *****/ - if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) - Err_WrongCallForExamExit (); - - /***** Get data of call for exam *****/ - Cfe_AllocMemCallForExam (CallsForExams); - Cfe_GetDataCallForExamFromDB (CallsForExams,ExaCod); - - /***** Session and date of the exam *****/ - Cfe_BuildSessionAndDate (CallsForExams,SessionAndDate); - - /***** Copy link to call for exam into resource clipboard *****/ - Prg_DB_CopyToClipboard (PrgRsc_CALL_FOR_EXAM,ExaCod); - - /***** Write sucess message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, - SessionAndDate); - - /***** Free memory of the call for exam *****/ - Cfe_FreeMemCallForExam (CallsForExams); - - /***** Set exam to be highlighted *****/ - CallsForExams->HighlightExaCod = ExaCod; - - /***** Show again the list of calls for exams *****/ - Cfe_ListCallsForExamsEdit (); - } - -/*****************************************************************************/ -/******************* Write call for exam in course program *******************/ -/*****************************************************************************/ - -void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo, - const char *Icon,const char *IconTitle) - { - extern const char *Txt_Actions[Act_NUM_ACTIONS]; - struct Cfe_CallsForExams CallsForExams; - char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; - char *Anchor = NULL; - - /***** Get session and date of the exam *****/ - Cfe_ResetCallsForExams (&CallsForExams); - Cfe_AllocMemCallForExam (&CallsForExams); - Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); - Cfe_BuildSessionAndDate (&CallsForExams,SessionAndDate); - Cfe_FreeMemCallForExam (&CallsForExams); - - /***** Begin form to download file *****/ - if (PutFormToGo) - { - /* Build anchor string */ - Frm_SetAnchorStr (ExaCod,&Anchor); - - /* Begin form */ - Frm_BeginFormAnchor (ActSeeOneCfe,Anchor); - Cfe_PutHiddenParamExaCod (ExaCod); - HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeOneCfe], - "class=\"LM BT_LINK PRG_LNK_%s\"", - The_GetSuffix ()); - - /* Free anchor string */ - Frm_FreeAnchorStr (Anchor); - } - - /***** Icon depending on type ******/ - if (PutFormToGo) - Ico_PutIconLink (Icon,Ico_BLACK,ActSeeOneCfe); - else - Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); - - /***** Write Name of the course and date of exam *****/ - HTM_Txt (SessionAndDate); - - /***** End form to download file *****/ - if (PutFormToGo) - { - /* End form */ - HTM_BUTTON_End (); - - Frm_EndForm (); - } - } - -/*****************************************************************************/ -/************** Get call for exam text from call for exam code ***************/ -/*****************************************************************************/ - -void CfeRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize) - { - extern const char *Txt_Call_for_exam; - struct Cfe_CallsForExams CallsForExams; - char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; - - /***** Reset calls for exams context *****/ - Cfe_ResetCallsForExams (&CallsForExams); - - /***** Get data of call for exam *****/ - Cfe_AllocMemCallForExam (&CallsForExams); - Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); - - /***** Session and date of the exam *****/ - Cfe_BuildSessionAndDate (&CallsForExams,SessionAndDate); - snprintf (Title,TitleSize,"%s: %s",Txt_Call_for_exam,SessionAndDate); - - /***** Free memory of the call for exam *****/ - Cfe_FreeMemCallForExam (&CallsForExams); - } - /*****************************************************************************/ /*********** Build string with session and date of a call for exam ***********/ /*****************************************************************************/ -static void Cfe_BuildSessionAndDate (const struct Cfe_CallsForExams *CallsForExams, +void Cfe_BuildSessionAndDate (const struct Cfe_CallsForExams *CallsForExams, char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]) { char StrExamDate[Cns_MAX_BYTES_DATE + 1]; diff --git a/swad_call_for_exam.h b/swad_call_for_exam.h index e697c9b6..376e0e48 100644 --- a/swad_call_for_exam.h +++ b/swad_call_for_exam.h @@ -96,13 +96,19 @@ struct Cfe_CallsForExams struct Cfe_CallForExam CallForExam; }; +#define Cfe_MAX_BYTES_SESSION_AND_DATE (Cfe_MAX_BYTES_SESSION + (2 + Cns_MAX_BYTES_DATE + 7) + 1) + /*****************************************************************************/ /***************************** Public prototypes *****************************/ /*****************************************************************************/ +struct Cfe_CallsForExams *Cfe_GetGlobalCallsForExams (void); + void Cfe_ResetCallsForExams (struct Cfe_CallsForExams *CallsForExams); void Cfe_PutFrmEditACallForExam (void); +void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams); +void Cfe_FreeMemCallForExam (struct Cfe_CallsForExams *CallsForExams); void Cfe_ReceiveCallForExam1 (void); void Cfe_ReceiveCallForExam2 (void); void Cfe_PrintCallForExam (void); @@ -113,6 +119,8 @@ void Cfe_HideCallForExam (void); void Cfe_UnhideCallForExam (void); void Cfe_FreeListCallsForExams (struct Cfe_CallsForExams *CallsForExams); +void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExams, + long ExaCod); void Cfe_ListCallsForExamsSee (void); void Cfe_ListCallsForExamsEdit (void); @@ -121,15 +129,13 @@ void Cfe_ListCallsForExamsDay (void); void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams); void Cfe_PutHiddenParamExaCod (long ExaCod); +long Cfe_GetParamExaCod (void); void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], char **ContentStr, long ExaCod,bool GetContent); -//--------------------------- Program resources ------------------------------- -void Cfe_GetLinkToCallForExam (void); -void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo, - const char *Icon,const char *IconTitle); -void CfeRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize); +void Cfe_BuildSessionAndDate (const struct Cfe_CallsForExams *CallsForExams, + char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]); #endif diff --git a/swad_call_for_exam_resource.c b/swad_call_for_exam_resource.c new file mode 100644 index 00000000..2e9c9a10 --- /dev/null +++ b/swad_call_for_exam_resource.c @@ -0,0 +1,155 @@ +// swad_call_for_exam_resource.c: links to calls for exams as program resources + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2022 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include "swad_alert.h" +#include "swad_call_for_exam.h" +#include "swad_call_for_exam_resource.h" +#include "swad_error.h" +#include "swad_form.h" +#include "swad_program_database.h" + +/*****************************************************************************/ +/************************ Get link to call for exam **************************/ +/*****************************************************************************/ + +void Cfe_GetLinkToCallForExam (void) + { + extern const char *Txt_Link_to_resource_X_copied_into_clipboard; + struct Cfe_CallsForExams *CallsForExams = Cfe_GetGlobalCallsForExams (); + long ExaCod; + char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; + + /***** Reset calls for exams context *****/ + Cfe_ResetCallsForExams (CallsForExams); + + /***** Get the code of the call for exam *****/ + if ((ExaCod = Cfe_GetParamExaCod ()) <= 0) + Err_WrongCallForExamExit (); + + /***** Get data of call for exam *****/ + Cfe_AllocMemCallForExam (CallsForExams); + Cfe_GetDataCallForExamFromDB (CallsForExams,ExaCod); + + /***** Session and date of the exam *****/ + Cfe_BuildSessionAndDate (CallsForExams,SessionAndDate); + + /***** Copy link to call for exam into resource clipboard *****/ + Prg_DB_CopyToClipboard (PrgRsc_CALL_FOR_EXAM,ExaCod); + + /***** Write sucess message *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, + SessionAndDate); + + /***** Free memory of the call for exam *****/ + Cfe_FreeMemCallForExam (CallsForExams); + + /***** Set exam to be highlighted *****/ + CallsForExams->HighlightExaCod = ExaCod; + + /***** Show again the list of calls for exams *****/ + Cfe_ListCallsForExamsEdit (); + } + +/*****************************************************************************/ +/******************* Write call for exam in course program *******************/ +/*****************************************************************************/ + +void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo, + const char *Icon,const char *IconTitle) + { + extern const char *Txt_Actions[Act_NUM_ACTIONS]; + struct Cfe_CallsForExams CallsForExams; + char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; + char *Anchor = NULL; + + /***** Get session and date of the exam *****/ + Cfe_ResetCallsForExams (&CallsForExams); + Cfe_AllocMemCallForExam (&CallsForExams); + Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); + Cfe_BuildSessionAndDate (&CallsForExams,SessionAndDate); + Cfe_FreeMemCallForExam (&CallsForExams); + + /***** Begin form to download file *****/ + if (PutFormToGo) + { + /* Build anchor string */ + Frm_SetAnchorStr (ExaCod,&Anchor); + + /* Begin form */ + Frm_BeginFormAnchor (ActSeeOneCfe,Anchor); + Cfe_PutHiddenParamExaCod (ExaCod); + HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeOneCfe], + "class=\"LM BT_LINK PRG_LNK_%s\"", + The_GetSuffix ()); + + /* Free anchor string */ + Frm_FreeAnchorStr (Anchor); + } + + /***** Icon depending on type ******/ + if (PutFormToGo) + Ico_PutIconLink (Icon,Ico_BLACK,ActSeeOneCfe); + else + Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); + + /***** Write Name of the course and date of exam *****/ + HTM_Txt (SessionAndDate); + + /***** End form to download file *****/ + if (PutFormToGo) + { + /* End form */ + HTM_BUTTON_End (); + + Frm_EndForm (); + } + } + +/*****************************************************************************/ +/************** Get call for exam text from call for exam code ***************/ +/*****************************************************************************/ + +void CfeRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize) + { + extern const char *Txt_Call_for_exam; + struct Cfe_CallsForExams CallsForExams; + char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE]; + + /***** Reset calls for exams context *****/ + Cfe_ResetCallsForExams (&CallsForExams); + + /***** Get data of call for exam *****/ + Cfe_AllocMemCallForExam (&CallsForExams); + Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod); + + /***** Session and date of the exam *****/ + Cfe_BuildSessionAndDate (&CallsForExams,SessionAndDate); + snprintf (Title,TitleSize,"%s: %s",Txt_Call_for_exam,SessionAndDate); + + /***** Free memory of the call for exam *****/ + Cfe_FreeMemCallForExam (&CallsForExams); + } diff --git a/swad_call_for_exam_resource.h b/swad_call_for_exam_resource.h new file mode 100644 index 00000000..3c98e06c --- /dev/null +++ b/swad_call_for_exam_resource.h @@ -0,0 +1,41 @@ +// swad_call_for_exam_resource.h: links to calls for exams as program resources + +#ifndef _SWAD_CFE_RSC +#define _SWAD_CFE_RSC +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2022 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include // For size_t + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +void Cfe_GetLinkToCallForExam (void); +void CfeRsc_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo, + const char *Icon,const char *IconTitle); +void CfeRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize); + +#endif diff --git a/swad_changelog.h b/swad_changelog.h index ba18bb38..e38db232 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,10 +606,12 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate TODO: Attach pdf files in multimedia. */ -#define Log_PLATFORM_VERSION "SWAD 22.22 (2022-09-23)" -#define CSS_FILE "swad22.21.css" +#define Log_PLATFORM_VERSION "SWAD 22.23 (2022-09-23)" +#define CSS_FILE "swad22.22.1.css" #define JS_FILE "swad21.100.js" /* + Version 22.23: Sep 23, 2022 New module swad_call_for_exam_resource. (331924 lines) + Version 22.22.1: Sep 23, 2022 Changes in layout of course program. (331875 lines) Version 22.22: Sep 23, 2022 Course program open to teachers and students. (331856 lines) Version 22.21: Sep 22, 2022 Changes in layout of course program. (331855 lines) Version 22.20: Sep 22, 2022 Hidden items are not shown in program. (331838 lines) diff --git a/swad_program.c b/swad_program.c index 861b3ecf..0ddc0465 100644 --- a/swad_program.c +++ b/swad_program.c @@ -617,7 +617,7 @@ static void Prg_WriteRowItem (Prg_ListingType_t ListingType, ""); Dat_WriteLocalDateHMSFromUTC (Id,Item->TimeUTC[StartEndTime], Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA, - true,true,true,0x7); + true,true,true,0x6); HTM_DIV_End (); free (Id); } diff --git a/swad_program_resource.c b/swad_program_resource.c index 4cf10475..a70cdc71 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -33,7 +33,7 @@ #include "swad_assignment_resource.h" #include "swad_attendance.h" #include "swad_browser.h" -#include "swad_call_for_exam.h" +#include "swad_call_for_exam_resource.h" #include "swad_error.h" #include "swad_exam.h" #include "swad_form.h" @@ -246,50 +246,55 @@ void PrgRsc_ListItemResources (Prg_ListingType_t ListingType, EditingResourcesOfThisItem = EditingResources[ListingType] && (Item->Hierarchy.ItmCod == SelectedItmCod); - if (asprintf (&Title,Txt_Resources_of_X,Item->Title) < 0) - Err_NotEnoughMemoryExit (); - Box_BoxBegin ("100%",Title, - Editing[ListingType] ? (EditingResourcesOfThisItem ? PrgRsc_PutIconsViewResources : - PrgRsc_PutIconsEditResources) : - NULL, - Editing[ListingType] ? &Item->Hierarchy.ItmCod : - NULL, - Hlp_COURSE_Program,Box_NOT_CLOSABLE); - free (Title); + if (Editing[ListingType]) + { + if (asprintf (&Title,Txt_Resources_of_X,Item->Title) < 0) + Err_NotEnoughMemoryExit (); + Box_BoxBegin ("100%",Title, + EditingResourcesOfThisItem ? PrgRsc_PutIconsViewResources : + PrgRsc_PutIconsEditResources, + &Item->Hierarchy.ItmCod, + Hlp_COURSE_Program,Box_NOT_CLOSABLE); + free (Title); + } + else + Box_BoxBegin ("100%",NULL, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); - /***** Table *****/ - HTM_TABLE_BeginWideMarginPadding (2); - HTM_TBODY_Begin (NULL); + /***** Table *****/ + HTM_TABLE_BeginWidePadding (2); + HTM_TBODY_Begin (NULL); - /***** Write all item resources *****/ - for (NumRsc = 0, The_ResetRowColor1 (1); - NumRsc < NumResources; - NumRsc++, The_ChangeRowColor1 (1)) - { - /* Get data of this item resource */ - PrgRsc_GetDataOfResource (Item,&mysql_res); + /***** Write all item resources *****/ + for (NumRsc = 0, The_ResetRowColor1 (1); + NumRsc < NumResources; + NumRsc++, The_ChangeRowColor1 (1)) + { + /* Get data of this item resource */ + PrgRsc_GetDataOfResource (Item,&mysql_res); - /* Show item */ - if (EditingResourcesOfThisItem) - PrgRsc_WriteRowEditResource (NumRsc,NumResources,Item, - (ListingType == Prg_EDIT_RESOURCE_LINK && - Item->Resource.Hierarchy.RscCod == SelectedRscCod)); // Edit this link? - else - PrgRsc_WriteRowViewResource (NumRsc,Item); - } + /* Show item */ + if (EditingResourcesOfThisItem) + PrgRsc_WriteRowEditResource (NumRsc,NumResources,Item, + (ListingType == Prg_EDIT_RESOURCE_LINK && + Item->Resource.Hierarchy.RscCod == SelectedRscCod)); // Edit this link? + else + PrgRsc_WriteRowViewResource (NumRsc,Item); + } - /***** Form to create a new resource *****/ - if (EditingResourcesOfThisItem) - { - Prg_ResetResource (Item); - PrgRsc_WriteRowNewResource (NumResources,Item, - (ListingType == Prg_EDIT_RESOURCE_LINK && - Item->Resource.Hierarchy.RscCod == SelectedRscCod)); // Edit this link? - } + /***** Form to create a new resource *****/ + if (EditingResourcesOfThisItem) + { + Prg_ResetResource (Item); + PrgRsc_WriteRowNewResource (NumResources,Item, + (ListingType == Prg_EDIT_RESOURCE_LINK && + Item->Resource.Hierarchy.RscCod == SelectedRscCod)); // Edit this link? + } - /***** End table *****/ - HTM_TBODY_End (); - HTM_TABLE_End (); + /***** End table *****/ + HTM_TBODY_End (); + HTM_TABLE_End (); /***** End box *****/ Box_BoxEnd ();