From 1aeaeb5bf3692e9d0abba7da0e08691b83436c70 Mon Sep 17 00:00:00 2001 From: acanas Date: Fri, 23 Sep 2022 22:11:49 +0200 Subject: [PATCH] Version 22.24: Sep 23, 2022 New module swad_exam_resource. --- Makefile | 3 +- swad_action.c | 3 +- swad_changelog.h | 3 +- swad_exam.c | 92 +----------------------------- swad_exam.h | 7 +-- swad_exam_resource.c | 122 ++++++++++++++++++++++++++++++++++++++++ swad_exam_resource.h | 41 ++++++++++++++ swad_program_resource.c | 2 +- 8 files changed, 172 insertions(+), 101 deletions(-) create mode 100644 swad_exam_resource.c create mode 100644 swad_exam_resource.h diff --git a/Makefile b/Makefile index 791f1d5fb..82a2715ab 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,8 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \ swad_department_database.o swad_duplicate.o swad_duplicate_database.o \ swad_enrolment.o swad_enrolment_database.o swad_error.o swad_exam.o \ swad_exam_database.o swad_exam_log.o swad_exam_print.o \ - swad_exam_result.o swad_exam_session.o swad_exam_set.o \ + swad_exam_resource.o swad_exam_result.o swad_exam_session.o \ + swad_exam_set.o \ swad_figure.o swad_figure_cache.o swad_figure_database.o swad_file.o \ swad_file_database.o swad_file_extension.o swad_file_MIME.o \ swad_firewall.o swad_firewall_database.o swad_follow.o \ diff --git a/swad_action.c b/swad_action.c index 7ee062205..68a784f4e 100644 --- a/swad_action.c +++ b/swad_action.c @@ -52,6 +52,7 @@ #include "swad_duplicate.h" #include "swad_exam.h" #include "swad_exam_print.h" +#include "swad_exam_resource.h" #include "swad_exam_result.h" #include "swad_exam_session.h" #include "swad_exam_set.h" @@ -733,7 +734,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActRemExa ] = {1882,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_RemoveExam ,NULL}, [ActHidExa ] = {1883,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_HideExam ,NULL}, [ActUnhExa ] = {1884,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_UnhideExam ,NULL}, - [ActReqLnkExa ] = {1936,-1,TabUnk,ActSeeAllExa ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Exa_GetLinkToExam ,NULL}, + [ActReqLnkExa ] = {1936,-1,TabUnk,ActSeeAllExa ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaRsc_GetLinkToExam ,NULL}, [ActFrmNewExaSet ] = {1892,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Dat_SetIniEndDates ,ExaSet_RequestCreatOrEditSet ,NULL}, [ActNewExaSet ] = {1898,-1,TabUnk,ActSeeAllExa ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,ExaSet_ReceiveFormSet ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index e38db2324..112c1a65e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -606,10 +606,11 @@ 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.23 (2022-09-23)" +#define Log_PLATFORM_VERSION "SWAD 22.24 (2022-09-23)" #define CSS_FILE "swad22.22.1.css" #define JS_FILE "swad21.100.js" /* + Version 22.24: Sep 23, 2022 New module swad_exam_resource. (331980 lines) 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) diff --git a/swad_exam.c b/swad_exam.c index 814310301..843ff935e 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -107,7 +107,6 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Exa_ListAllExams (struct Exa_Exams *Exams); static void Exa_PutIconsListExams (void *Exams); static void Exa_PutIconToCreateNewExam (struct Exa_Exams *Exams); static void Exa_PutButtonToCreateNewExam (struct Exa_Exams *Exams); @@ -208,7 +207,7 @@ void Exa_SeeAllExams (void) /******************************* Show all exams ******************************/ /*****************************************************************************/ -static void Exa_ListAllExams (struct Exa_Exams *Exams) +void Exa_ListAllExams (struct Exa_Exams *Exams) { extern const char *Hlp_ASSESSMENT_Exams; extern const char *Txt_Exams; @@ -1639,92 +1638,3 @@ void Exa_GetAndShowExamsStats (void) /***** End table and box *****/ Box_BoxTableEnd (); } - -/*****************************************************************************/ -/***************************** Get link to exam ******************************/ -/*****************************************************************************/ - -void Exa_GetLinkToExam (void) - { - extern const char *Txt_Link_to_resource_X_copied_into_clipboard; - struct Exa_Exams Exams; - long ExaCod; - char Title[Gam_MAX_BYTES_TITLE + 1]; - - /***** Reset exams context *****/ - Exa_ResetExams (&Exams); - - /***** Get parameters *****/ - Exa_GetParams (&Exams); - if (Exams.ExaCod <= 0) - Err_WrongExamExit (); - ExaCod = Exams.ExaCod; - - /***** Get exam title *****/ - Exa_DB_GetExamTitle (ExaCod,Title); - - /***** Copy link to exam into resource clipboard *****/ - Prg_DB_CopyToClipboard (PrgRsc_EXAM,ExaCod); - - /***** Write sucess message *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, - Title); - - /***** Show exams again *****/ - Exa_ListAllExams (&Exams); - } - -/*****************************************************************************/ -/*********************** Write exam in course program ************************/ -/*****************************************************************************/ - -void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo, - const char *Icon,const char *IconTitle) - { - extern const char *Txt_Actions[Act_NUM_ACTIONS]; - char Title[Gam_MAX_BYTES_TITLE + 1]; - - /***** Get exam title *****/ - Exa_DB_GetExamTitle (ExaCod,Title); - - /***** Begin form to go to exam *****/ - if (PutFormToGo) - { - Frm_BeginForm (ActSeeExa); - Exa_PutParamExamCod (ExaCod); - HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeExa], - "class=\"LM BT_LINK PRG_LNK_%s\"", - The_GetSuffix ()); - } - - /***** Icon depending on type ******/ - if (PutFormToGo) - Ico_PutIconLink (Icon,Ico_BLACK,ActSeeExa); - else - Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); - - /***** Write Name of the course and date of exam *****/ - HTM_Txt (Title); - - /***** End form to download file *****/ - if (PutFormToGo) - { - /* End form */ - HTM_BUTTON_End (); - - Frm_EndForm (); - } - } - -/*****************************************************************************/ -/*********************** Get exam title from exam code ***********************/ -/*****************************************************************************/ - -void ExaRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize) - { - char TitleFromDB[Exa_MAX_BYTES_TITLE + 1]; - - /***** Get exam title *****/ - Exa_DB_GetExamTitle (ExaCod,TitleFromDB); - Str_Copy (Title,TitleFromDB,TitleSize); - } diff --git a/swad_exam.h b/swad_exam.h index f03d9d6e6..06afb2a8c 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -37,6 +37,7 @@ void Exa_ResetExams (struct Exa_Exams *Exams); void Exa_ResetExam (struct Exa_Exam *Exam); void Exa_SeeAllExams (void); +void Exa_ListAllExams (struct Exa_Exams *Exams); bool Exa_CheckIfICanEditExams (void); @@ -87,10 +88,4 @@ bool Exa_CheckIfEditable (const struct Exa_Exam *Exam); //-------------------------------- Figures ------------------------------------ void Exa_GetAndShowExamsStats (void); -//--------------------------- Program resources ------------------------------- -void Exa_GetLinkToExam (void); -void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo, - const char *Icon,const char *IconTitle); -void ExaRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize); - #endif diff --git a/swad_exam_resource.c b/swad_exam_resource.c new file mode 100644 index 000000000..8a70ba42d --- /dev/null +++ b/swad_exam_resource.c @@ -0,0 +1,122 @@ +// swad_exam_resource.c: links to 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_error.h" +#include "swad_exam.h" +#include "swad_exam_database.h" +#include "swad_form.h" +#include "swad_program_database.h" + +/*****************************************************************************/ +/***************************** Get link to exam ******************************/ +/*****************************************************************************/ + +void ExaRsc_GetLinkToExam (void) + { + extern const char *Txt_Link_to_resource_X_copied_into_clipboard; + struct Exa_Exams Exams; + long ExaCod; + char Title[Exa_MAX_BYTES_TITLE + 1]; + + /***** Reset exams context *****/ + Exa_ResetExams (&Exams); + + /***** Get parameters *****/ + Exa_GetParams (&Exams); + if (Exams.ExaCod <= 0) + Err_WrongExamExit (); + ExaCod = Exams.ExaCod; + + /***** Get exam title *****/ + Exa_DB_GetExamTitle (ExaCod,Title); + + /***** Copy link to exam into resource clipboard *****/ + Prg_DB_CopyToClipboard (PrgRsc_EXAM,ExaCod); + + /***** Write sucess message *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard, + Title); + + /***** Show exams again *****/ + Exa_ListAllExams (&Exams); + } + +/*****************************************************************************/ +/*********************** Write exam in course program ************************/ +/*****************************************************************************/ + +void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo, + const char *Icon,const char *IconTitle) + { + extern const char *Txt_Actions[Act_NUM_ACTIONS]; + char Title[Exa_MAX_BYTES_TITLE + 1]; + + /***** Get exam title *****/ + Exa_DB_GetExamTitle (ExaCod,Title); + + /***** Begin form to go to exam *****/ + if (PutFormToGo) + { + Frm_BeginForm (ActSeeExa); + Exa_PutParamExamCod (ExaCod); + HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeExa], + "class=\"LM BT_LINK PRG_LNK_%s\"", + The_GetSuffix ()); + } + + /***** Icon depending on type ******/ + if (PutFormToGo) + Ico_PutIconLink (Icon,Ico_BLACK,ActSeeExa); + else + Ico_PutIconOn (Icon,Ico_BLACK,IconTitle); + + /***** Write Name of the course and date of exam *****/ + HTM_Txt (Title); + + /***** End form to download file *****/ + if (PutFormToGo) + { + /* End form */ + HTM_BUTTON_End (); + + Frm_EndForm (); + } + } + +/*****************************************************************************/ +/*********************** Get exam title from exam code ***********************/ +/*****************************************************************************/ + +void ExaRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize) + { + char TitleFromDB[Exa_MAX_BYTES_TITLE + 1]; + + /***** Get exam title *****/ + Exa_DB_GetExamTitle (ExaCod,TitleFromDB); + Str_Copy (Title,TitleFromDB,TitleSize); + } diff --git a/swad_exam_resource.h b/swad_exam_resource.h new file mode 100644 index 000000000..38680d6a5 --- /dev/null +++ b/swad_exam_resource.h @@ -0,0 +1,41 @@ +// swad_exam_resource.h: links to exams as program resources + +#ifndef _SWAD_EXA_RSC +#define _SWAD_EXA_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 ExaRsc_GetLinkToExam (void); +void ExaRsc_WriteExamInCrsProgram (long ExaCod,bool PutFormToGo, + const char *Icon,const char *IconTitle); +void ExaRsc_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize); + +#endif diff --git a/swad_program_resource.c b/swad_program_resource.c index a70cdc719..184e88c44 100644 --- a/swad_program_resource.c +++ b/swad_program_resource.c @@ -35,7 +35,7 @@ #include "swad_browser.h" #include "swad_call_for_exam_resource.h" #include "swad_error.h" -#include "swad_exam.h" +#include "swad_exam_resource.h" #include "swad_form.h" #include "swad_game.h" #include "swad_global.h"