Version 22.24: Sep 23, 2022 New module swad_exam_resource.

This commit is contained in:
acanas 2022-09-23 22:11:49 +02:00
parent f5efd11ecd
commit 1aeaeb5bf3
8 changed files with 172 additions and 101 deletions

View File

@ -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 \

View File

@ -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},

View File

@ -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)

View File

@ -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);
}

View File

@ -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

122
swad_exam_resource.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* 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);
}

41
swad_exam_resource.h Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include <stddef.h> // 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

View File

@ -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"