2020-04-20 01:26:46 +02:00
|
|
|
|
// swad_exam.c: exams
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
2020-04-20 01:26:46 +02:00
|
|
|
|
it under the terms of the GNU Affero General 3 License as
|
2014-12-01 23:55:08 +01:00
|
|
|
|
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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-17 14:12:09 +02:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2020-04-20 01:26:46 +02:00
|
|
|
|
#include <float.h> // For DBL_MAX
|
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2020-04-20 01:26:46 +02:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2021-04-23 22:57:57 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2021-11-28 00:49:23 +01:00
|
|
|
|
#include "swad_autolink.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_exam.h"
|
2021-07-20 13:14:12 +02:00
|
|
|
|
#include "swad_exam_database.h"
|
2020-05-18 22:59:07 +02:00
|
|
|
|
#include "swad_exam_print.h"
|
2020-04-22 03:15:04 +02:00
|
|
|
|
#include "swad_exam_result.h"
|
2020-05-17 02:28:30 +02:00
|
|
|
|
#include "swad_exam_session.h"
|
2020-05-07 02:22:57 +02:00
|
|
|
|
#include "swad_exam_set.h"
|
2020-05-05 21:49:00 +02:00
|
|
|
|
#include "swad_exam_type.h"
|
2020-04-20 01:26:46 +02:00
|
|
|
|
#include "swad_figure.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-05-27 23:30:16 +02:00
|
|
|
|
#include "swad_hierarchy_level.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2020-04-20 01:26:46 +02:00
|
|
|
|
#include "swad_match.h"
|
|
|
|
|
#include "swad_match_result.h"
|
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_role.h"
|
|
|
|
|
#include "swad_test.h"
|
|
|
|
|
#include "swad_test_visibility.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
#define Exa_MAX_CHARS_ANSWER (1024 - 1) // 1023
|
|
|
|
|
#define Exa_MAX_BYTES_ANSWER ((Exa_MAX_CHARS_ANSWER + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383
|
|
|
|
|
|
|
|
|
|
#define Exa_MAX_ANSWERS_PER_QUESTION 10
|
|
|
|
|
|
|
|
|
|
/* Score range [0...max.score]
|
|
|
|
|
will be converted to
|
|
|
|
|
grade range [0...max.grade]
|
|
|
|
|
Example: Exam with 5 questions, unique-choice, 4 options per question
|
|
|
|
|
max.score = 5 * 1 = 5
|
|
|
|
|
min.score = 5 * (-0.33) = -1,67
|
|
|
|
|
max.grade given by teacher = 0.2 ==> min.grade = -0,067
|
|
|
|
|
|
|
|
|
|
grade
|
|
|
|
|
^
|
|
|
|
|
| /
|
|
|
|
|
max.grade--> +---------+
|
|
|
|
|
| /|
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
| / |
|
|
|
|
|
|/ |
|
|
|
|
|
------+---0-+---------+---------> score
|
|
|
|
|
^ /0 ^
|
|
|
|
|
min.score/ | max.score
|
|
|
|
|
| / | (num.questions)
|
|
|
|
|
| / |
|
|
|
|
|
|/ |
|
|
|
|
|
+-----+ <--min.grade
|
|
|
|
|
/ |
|
|
|
|
|
*/
|
|
|
|
|
#define Exa_MAX_GRADE_DEFAULT 1.0
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
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);
|
|
|
|
|
static void Exa_PutParamsToCreateNewExam (void *Exams);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_ShowOneExam (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,bool ShowOnlyThisExam);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutIconToShowResultsOfExam (void *Exams);
|
|
|
|
|
static void Exa_WriteAuthor (struct Exa_Exam *Exam);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutHiddenParamExamOrder (Exa_Order_t SelectedOrder);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-05-05 20:09:28 +02:00
|
|
|
|
static void Exa_PutIconsToRemEditOneExam (struct Exa_Exams *Exams,
|
2020-04-20 01:26:46 +02:00
|
|
|
|
const struct Exa_Exam *Exam,
|
|
|
|
|
const char *Anchor);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutHiddenParamOrder (Exa_Order_t SelectedOrder);
|
|
|
|
|
static Exa_Order_t Exa_GetParamOrder (void);
|
2016-06-01 13:43:22 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_RemoveExamFromAllTables (long ExaCod);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2021-07-30 12:14:57 +02:00
|
|
|
|
static void Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (long ExaCod);
|
|
|
|
|
static void Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (long CrsCod);
|
|
|
|
|
static void Exa_RemoveAllMedFilesFromAnsOfAllQstsFromExam (long ExaCod);
|
|
|
|
|
static void Exa_RemoveAllMedFilesFromAnsOfAllQstsFromCrs (long CrsCod);
|
2020-05-18 22:59:07 +02:00
|
|
|
|
|
2021-09-09 18:11:46 +02:00
|
|
|
|
static void Exa_HideUnhideExam (bool Hide);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam,
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
|
|
|
|
static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam);
|
|
|
|
|
|
|
|
|
|
static void Exa_CreateExam (struct Exa_Exam *Exam,const char *Txt);
|
|
|
|
|
static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt);
|
|
|
|
|
|
2020-04-12 20:08:37 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/******************************* Reset exams *********************************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_ResetExams (struct Exa_Exams *Exams)
|
2020-04-12 20:08:37 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exams->LstIsRead = false; // List not read from database...
|
|
|
|
|
Exams->Num = 0; // Total number of exams
|
|
|
|
|
Exams->NumSelected = 0; // Number of exams selected
|
|
|
|
|
Exams->Lst = NULL; // List of exams
|
|
|
|
|
Exams->SelectedOrder = Exa_ORDER_DEFAULT;
|
|
|
|
|
Exams->CurrentPage = 0;
|
|
|
|
|
Exams->ListQuestions = NULL;
|
|
|
|
|
Exams->ExaCodsSelected = NULL; // String with selected exam codes separated by separator multiple
|
|
|
|
|
Exams->ExaCod = -1L; // Selected/current exam code
|
2020-05-17 02:28:30 +02:00
|
|
|
|
Exams->SesCod = -1L; // Selected/current session code
|
2020-04-24 02:49:51 +02:00
|
|
|
|
Exams->SetInd = 0; // Current set index
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams->QstCod = -1L; // Current question code
|
2020-04-12 20:08:37 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Initialize exam to empty ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Exa_ResetExam (struct Exa_Exam *Exam)
|
|
|
|
|
{
|
|
|
|
|
/***** Initialize to empty exam *****/
|
|
|
|
|
Exam->ExaCod = -1L;
|
|
|
|
|
Exam->CrsCod = -1L;
|
|
|
|
|
Exam->UsrCod = -1L;
|
|
|
|
|
Exam->MaxGrade = Exa_MAX_GRADE_DEFAULT;
|
|
|
|
|
Exam->Visibility = TstVis_VISIBILITY_DEFAULT;
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Exam->TimeUTC[Dat_STR_TIME] = (time_t) 0;
|
|
|
|
|
Exam->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exam->Title[0] = '\0';
|
2020-05-05 20:09:28 +02:00
|
|
|
|
Exam->Hidden = false;
|
2020-04-26 03:07:55 +02:00
|
|
|
|
Exam->NumSets = 0;
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exam->NumQsts = 0;
|
2020-05-17 02:28:30 +02:00
|
|
|
|
Exam->NumSess = 0;
|
|
|
|
|
Exam->NumOpenSess = 0;
|
2020-04-23 23:09:28 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***************************** List all exams ********************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_SeeAllExams (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
struct Exa_Exams Exams;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Show all exams *****/
|
|
|
|
|
Exa_ListAllExams (&Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/******************************* Show all exams ******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_ListAllExams (struct Exa_Exams *Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Exams;
|
|
|
|
|
extern const char *Txt_Exams;
|
|
|
|
|
extern const char *Txt_EXAMS_ORDER_HELP[Exa_NUM_ORDERS];
|
|
|
|
|
extern const char *Txt_EXAMS_ORDER[Exa_NUM_ORDERS];
|
2020-05-17 02:28:30 +02:00
|
|
|
|
extern const char *Txt_Sessions;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
extern const char *Txt_No_exams;
|
|
|
|
|
Exa_Order_t Order;
|
|
|
|
|
struct Pagination Pagination;
|
|
|
|
|
unsigned NumExam;
|
|
|
|
|
struct Exa_Exam Exam;
|
|
|
|
|
|
|
|
|
|
/***** Get number of groups in current course *****/
|
|
|
|
|
if (!Gbl.Crs.Grps.NumGrps)
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_ALL_GROUPS;
|
|
|
|
|
|
|
|
|
|
/***** Get list of exams *****/
|
|
|
|
|
Exa_GetListExams (Exams,Exams->SelectedOrder);
|
|
|
|
|
|
|
|
|
|
/***** Compute variables related to pagination *****/
|
|
|
|
|
Pagination.NumItems = Exams->Num;
|
|
|
|
|
Pagination.CurrentPage = (int) Exams->CurrentPage;
|
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
|
|
|
|
Exams->CurrentPage = (unsigned) Pagination.CurrentPage;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
Box_BoxBegin ("100%",Txt_Exams,
|
|
|
|
|
Exa_PutIconsListExams,Exams,
|
|
|
|
|
Hlp_ASSESSMENT_Exams,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination,
|
|
|
|
|
Exams,-1L);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (Exams->Num)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Table head *****/
|
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (5);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
if (Exa_CheckIfICanEditExams ())
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Span (NULL,HTM_HEAD_CENTER,1,1,"CONTEXT_COL"); // Column for contextual icons
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
for (Order = (Exa_Order_t) 0;
|
|
|
|
|
Order <= (Exa_Order_t) (Exa_NUM_ORDERS - 1);
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Begin (HTM_HEAD_LEFT);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
/* Form to change order */
|
|
|
|
|
Frm_BeginForm (ActSeeAllExa);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_EXAMS,Exams->CurrentPage);
|
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) Order);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_EXAMS_ORDER_HELP[Order],
|
|
|
|
|
"class=\"BT_LINK\"");
|
2021-06-17 13:26:25 +02:00
|
|
|
|
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 ();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH (Txt_Sessions,HTM_HEAD_RIGHT);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2021-06-17 13:26:25 +02:00
|
|
|
|
else // No exams created
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_EXAMS,&Pagination,
|
|
|
|
|
Exams,-1L);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Button to create a new exam *****/
|
|
|
|
|
if (Exa_CheckIfICanEditExams ())
|
|
|
|
|
Exa_PutButtonToCreateNewExam (Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Free list of exams *****/
|
|
|
|
|
Exa_FreeListExams (Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/************************ Check if I can edit exams **************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-07 02:22:57 +02:00
|
|
|
|
bool Exa_CheckIfICanEditExams (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-10 21:04:34 +01:00
|
|
|
|
static const bool ICanEditExams[Rol_NUM_ROLES] =
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
2021-11-10 21:04:34 +01:00
|
|
|
|
[Rol_TCH ] = true,
|
|
|
|
|
[Rol_SYS_ADM] = true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ICanEditExams[Gbl.Usrs.Me.Role.Logged];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***************** Put contextual icons in list of exams *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutIconsListExams (void *Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-10 21:04:34 +01:00
|
|
|
|
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
|
|
|
|
{
|
|
|
|
|
[Rol_STD ] = ActSeeMyExaResCrs,
|
|
|
|
|
[Rol_NET ] = ActReqSeeUsrExaRes,
|
|
|
|
|
[Rol_TCH ] = ActReqSeeUsrExaRes,
|
|
|
|
|
[Rol_SYS_ADM] = ActReqSeeUsrExaRes,
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Put icon to create a new exam *****/
|
|
|
|
|
if (Exa_CheckIfICanEditExams ())
|
|
|
|
|
Exa_PutIconToCreateNewExam ((struct Exa_Exams *) Exams);
|
|
|
|
|
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/***** Put icon to view sessions results *****/
|
2021-11-10 21:04:34 +01:00
|
|
|
|
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
|
|
|
|
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],NULL,
|
|
|
|
|
NULL,NULL);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_EXAMS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/********************** Put icon to create a new exam **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutIconToCreateNewExam (struct Exa_Exams *Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Ico_PutContextualIconToAdd (ActFrmNewExa,NULL,
|
2022-06-29 18:04:45 +02:00
|
|
|
|
Exa_PutParamsToCreateNewExam,Exams);
|
2016-12-12 02:21:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put button to create a new exam *********************/
|
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutButtonToCreateNewExam (struct Exa_Exams *Exams)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_exam;
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActFrmNewExa);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Exa_PutParamsToCreateNewExam (Exams);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_exam);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/******************* Put parameters to create a new exam *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutParamsToCreateNewExam (void *Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (Exams)
|
|
|
|
|
{
|
|
|
|
|
Exa_PutHiddenParamExamOrder (((struct Exa_Exams *) Exams)->SelectedOrder);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_EXAMS,((struct Exa_Exams *) Exams)->CurrentPage);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/****************************** Show one exam ******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_SeeOneExam (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
2020-05-17 02:28:30 +02:00
|
|
|
|
struct ExaSes_Session Session;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
2020-05-17 02:28:30 +02:00
|
|
|
|
ExaSes_ResetSession (&Session);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
|
|
|
|
if (Exams.ExaCod <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongExamExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exam.ExaCod = Exams.ExaCod;
|
|
|
|
|
|
2020-04-26 01:54:27 +02:00
|
|
|
|
/***** Get exam data *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Show exam *****/
|
2020-05-17 02:28:30 +02:00
|
|
|
|
Exa_ShowOnlyOneExam (&Exams,&Exam,&Session,
|
|
|
|
|
false); // Do not put form for session
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/******************************* Show one exam *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_ShowOnlyOneExam (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,
|
2020-05-17 02:28:30 +02:00
|
|
|
|
struct ExaSes_Session *Session,
|
|
|
|
|
bool PutFormSession)
|
2016-12-11 21:02:22 +01:00
|
|
|
|
{
|
2020-05-17 02:28:30 +02:00
|
|
|
|
Exa_ShowOnlyOneExamBegin (Exams,Exam,Session,PutFormSession);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ShowOnlyOneExamEnd ();
|
|
|
|
|
}
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_ShowOnlyOneExamBegin (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,
|
2020-05-17 02:28:30 +02:00
|
|
|
|
struct ExaSes_Session *Session,
|
|
|
|
|
bool PutFormSession)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Exams;
|
|
|
|
|
extern const char *Txt_Exam;
|
2016-12-11 21:02:22 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
Exams->ExaCod = Exam->ExaCod;
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Exam,
|
|
|
|
|
Exa_PutIconToShowResultsOfExam,Exams,
|
|
|
|
|
Hlp_ASSESSMENT_Exams,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Show exam *****/
|
|
|
|
|
Exa_ShowOneExam (Exams,
|
|
|
|
|
Exam,
|
|
|
|
|
true); // Show only this exam
|
|
|
|
|
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/***** List sessions *****/
|
|
|
|
|
ExaSes_ListSessions (Exams,Exam,Session,PutFormSession);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2016-12-11 21:02:22 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_ShowOnlyOneExamEnd (void)
|
|
|
|
|
{
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
|
|
|
|
}
|
2016-12-11 21:02:22 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_ShowOneExam (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,bool ShowOnlyThisExam)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_View_exam;
|
2020-05-07 01:14:50 +02:00
|
|
|
|
extern const char *Txt_Sets_of_questions;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
extern const char *Txt_Maximum_grade;
|
|
|
|
|
extern const char *Txt_Result_visibility;
|
2020-05-17 02:28:30 +02:00
|
|
|
|
extern const char *Txt_Sessions;
|
2020-04-27 19:37:49 +02:00
|
|
|
|
char *Anchor;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
|
|
|
|
char *Id;
|
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
|
|
|
|
const char *Color;
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2019-03-25 19:05:10 +01:00
|
|
|
|
|
2020-04-27 19:37:49 +02:00
|
|
|
|
/***** Build anchor string *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Frm_SetAnchorStr (Exam->ExaCod,&Anchor);
|
2016-12-11 21:02:22 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Begin box and table *****/
|
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2016-12-11 21:02:22 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin first row of this exam *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Icons related to this exam *****/
|
|
|
|
|
if (Exa_CheckIfICanEditExams ())
|
|
|
|
|
{
|
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\"");
|
|
|
|
|
else
|
2021-12-20 22:43:32 +01:00
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL %s\"",
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Icons to remove/edit this exam */
|
|
|
|
|
Exa_PutIconsToRemEditOneExam (Exams,Exam,Anchor);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** 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)
|
2022-04-07 13:04:45 +02:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s\"",
|
|
|
|
|
Id,Color,The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
else
|
2022-04-07 13:04:45 +02:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"LT %s_%s %s\"",
|
|
|
|
|
Id,Color,The_GetSuffix (),The_GetColorRows ());
|
2021-09-18 18:22:26 +02:00
|
|
|
|
if (Exam->TimeUTC[Dat_STR_TIME])
|
2021-06-17 13:26:25 +02:00
|
|
|
|
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 *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (ShowOnlyThisExam)
|
2022-04-22 13:33:30 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2020-04-20 01:26:46 +02:00
|
|
|
|
else
|
2022-04-22 13:33:30 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT %s\"",The_GetColorRows ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
/* Exam title */
|
|
|
|
|
Exams->ExaCod = Exam->ExaCod;
|
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
|
|
|
|
Frm_BeginForm (ActSeeExa);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Exa_PutParams (Exams);
|
2022-04-23 00:56:15 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_View_exam,"class=\"LT BT_LINK %s_%s\"",
|
2022-04-22 13:33:30 +02:00
|
|
|
|
Exam->Hidden ? "ASG_TITLE_LIGHT":
|
|
|
|
|
"ASG_TITLE",
|
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_Txt (Exam->Title);
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_ARTICLE_End ();
|
|
|
|
|
|
|
|
|
|
/* Number of questions, maximum grade, visibility of results */
|
2022-04-22 22:22:14 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s_%s\"",
|
|
|
|
|
Exam->Hidden ? "ASG_GRP_LIGHT" :
|
|
|
|
|
"ASG_GRP",
|
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
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)
|
2022-04-22 13:33:30 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT\"");
|
2021-06-17 13:26:25 +02:00
|
|
|
|
else
|
2022-04-22 13:33:30 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT %s\"",The_GetColorRows ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
Exams->ExaCod = Exam->ExaCod;
|
|
|
|
|
Frm_BeginForm (ActSeeExa);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Exa_PutParams (Exams);
|
2022-04-23 00:56:15 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_Sessions,"class=\"LT BT_LINK %s_%s\"",
|
2022-04-22 13:33:30 +02:00
|
|
|
|
Exam->Hidden ? "ASG_TITLE_LIGHT":
|
|
|
|
|
"ASG_TITLE",
|
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Sessions);
|
|
|
|
|
HTM_Unsigned (Exam->NumSess);
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** End 1st row of this exam *****/
|
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin 2nd row of this exam *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Author of the exam *****/
|
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
|
|
|
|
else
|
2021-12-20 22:43:32 +01:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Exa_WriteAuthor (Exam);
|
|
|
|
|
HTM_TD_End ();
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Text of the exam *****/
|
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
|
|
|
|
else
|
2021-12-20 22:43:32 +01:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT %s\"",
|
2022-03-19 02:05:53 +01:00
|
|
|
|
The_GetColorRows ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
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
|
2021-11-28 00:49:23 +01:00
|
|
|
|
ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
|
2022-03-25 11:09:51 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"PAR %s_%s\"",
|
|
|
|
|
Exam->Hidden ? "DAT_LIGHT" :
|
|
|
|
|
"DAT",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_Txt (Txt);
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
HTM_TD_End ();
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** End 2nd row of this exam *****/
|
|
|
|
|
HTM_TR_End ();
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
if (ShowOnlyThisExam)
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
else
|
2022-03-24 01:18:19 +01:00
|
|
|
|
The_ChangeRowColor ();
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Free anchor string *****/
|
|
|
|
|
Frm_FreeAnchorStr (Anchor);
|
2016-12-12 02:21:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/************ Put icon to show results of sessions in an exam ****************/
|
2016-12-12 02:21:41 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutIconToShowResultsOfExam (void *Exams)
|
2016-12-12 02:21:41 +01:00
|
|
|
|
{
|
2021-11-10 21:04:34 +01:00
|
|
|
|
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
2021-11-10 21:04:34 +01:00
|
|
|
|
[Rol_STD ] = ActSeeMyExaResExa,
|
|
|
|
|
[Rol_NET ] = ActSeeUsrExaResExa,
|
|
|
|
|
[Rol_TCH ] = ActSeeUsrExaResExa,
|
|
|
|
|
[Rol_SYS_ADM] = ActSeeUsrExaResExa,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (Exams)
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/***** Put icon to view sessions results *****/
|
2021-11-10 21:04:34 +01:00
|
|
|
|
if (NextAction[Gbl.Usrs.Me.Role.Logged])
|
|
|
|
|
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],ExaRes_RESULTS_BOX_ID,
|
|
|
|
|
Exa_PutParams,Exams);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Write the author of an exam ************************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_WriteAuthor (struct Exa_Exam *Exam)
|
|
|
|
|
{
|
|
|
|
|
Usr_WriteAuthor1Line (Exam->UsrCod,Exam->Hidden);
|
|
|
|
|
}
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****** Put a hidden parameter with the type of order in list of exams *******/
|
|
|
|
|
/*****************************************************************************/
|
2016-12-12 02:21:41 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutHiddenParamExamOrder (Exa_Order_t SelectedOrder)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/******************** Put a link (form) to edit one exam *********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 20:09:28 +02:00
|
|
|
|
static void Exa_PutIconsToRemEditOneExam (struct Exa_Exams *Exams,
|
2020-04-20 01:26:46 +02:00
|
|
|
|
const struct Exa_Exam *Exam,
|
|
|
|
|
const char *Anchor)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2022-07-21 19:30:03 +02:00
|
|
|
|
static Act_Action_t ActionHideUnhide[2] =
|
|
|
|
|
{
|
|
|
|
|
[false] = ActHidExa, // Visible ==> action to hide
|
|
|
|
|
[true ] = ActUnhExa, // Hidden ==> action to unhide
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exams->ExaCod = Exam->ExaCod;
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
/***** Icon to remove exam *****/
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemExa,NULL,
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_PutParams,Exams);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2022-07-21 19:30:03 +02:00
|
|
|
|
/***** Icon to hide/unhide exam *****/
|
|
|
|
|
Ico_PutContextualIconToHideUnhide (ActionHideUnhide,Anchor,
|
|
|
|
|
Exa_PutParams,Exams,
|
|
|
|
|
Exam->Hidden);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
/***** Icon to edit exam *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneExa,NULL,
|
|
|
|
|
Exa_PutParams,Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-12 20:08:37 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*********************** Params used to edit an exam **************************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_PutParams (void *Exams)
|
2020-04-12 20:08:37 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (Exams)
|
|
|
|
|
{
|
|
|
|
|
if (((struct Exa_Exams *) Exams)->ExaCod > 0)
|
|
|
|
|
Exa_PutParamExamCod (((struct Exa_Exams *) Exams)->ExaCod);
|
|
|
|
|
Exa_PutHiddenParamOrder (((struct Exa_Exams *) Exams)->SelectedOrder);
|
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_EXAMS,((struct Exa_Exams *) Exams)->CurrentPage);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of exam **********************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_PutParamExamCod (long ExaCod)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamLong (NULL,"ExaCod",ExaCod);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/********************* Get parameter with code of exam ***********************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
long Exa_GetParamExamCod (void)
|
2020-04-12 20:08:37 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get code of exam *****/
|
|
|
|
|
return Par_GetParToLong ("ExaCod");
|
|
|
|
|
}
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get parameters used to edit an exam **********************/
|
|
|
|
|
/*****************************************************************************/
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
void Exa_GetParams (struct Exa_Exams *Exams)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Get other parameters *****/
|
|
|
|
|
Exams->SelectedOrder = Exa_GetParamOrder ();
|
|
|
|
|
Exams->CurrentPage = Pag_GetParamPagNum (Pag_EXAMS);
|
2020-04-12 20:08:37 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get exam code *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exams->ExaCod = Exa_GetParamExamCod ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-01 19:34:44 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/****** Put a hidden parameter with the type of order in list of exams *******/
|
2016-06-01 19:34:44 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_PutHiddenParamOrder (Exa_Order_t SelectedOrder)
|
2016-06-03 10:37:00 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (SelectedOrder != Exa_ORDER_DEFAULT)
|
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"Order",(unsigned) SelectedOrder);
|
2016-06-03 10:37:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/********** Get parameter with the type or order in list of exams ************/
|
2016-06-03 10:37:00 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static Exa_Order_t Exa_GetParamOrder (void)
|
2016-06-01 19:34:44 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
return (Exa_Order_t) Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Exa_NUM_ORDERS - 1,
|
|
|
|
|
(unsigned long) Exa_ORDER_DEFAULT);
|
2016-06-01 19:34:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/************************** Get list of all exams ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
unsigned NumExam;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Free list of exams *****/
|
|
|
|
|
if (Exams->LstIsRead)
|
|
|
|
|
Exa_FreeListExams (Exams);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get list of exams from database *****/
|
2021-07-27 21:33:09 +02:00
|
|
|
|
if ((Exams->Num = Exa_DB_GetListExams (&mysql_res,SelectedOrder))) // Exams found...
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Create list of exams *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if ((Exams->Lst = malloc ((size_t) Exams->Num *
|
|
|
|
|
sizeof (*Exams->Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get the exams codes *****/
|
|
|
|
|
for (NumExam = 0;
|
|
|
|
|
NumExam < Exams->Num;
|
|
|
|
|
NumExam++)
|
2019-03-25 19:05:10 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get next exam code (row[0]) */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if ((Exams->Lst[NumExam].ExaCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongExamExit ();
|
2019-03-25 19:05:10 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2016-06-01 13:43:22 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exams->LstIsRead = true;
|
2016-06-01 13:43:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/******************** Get list of exam sessions selected *********************/
|
2016-06-01 13:43:22 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
|
2016-06-01 13:43:22 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
unsigned MaxSizeListExaCodsSelected;
|
|
|
|
|
unsigned NumExam;
|
|
|
|
|
const char *Ptr;
|
|
|
|
|
long ExaCod;
|
|
|
|
|
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
|
|
|
|
|
|
|
|
|
/***** Allocate memory for list of exams selected *****/
|
|
|
|
|
MaxSizeListExaCodsSelected = Exams->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Exams->ExaCodsSelected = malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Get parameter multiple with list of exams selected *****/
|
|
|
|
|
Par_GetParMultiToText ("ExaCod",Exams->ExaCodsSelected,MaxSizeListExaCodsSelected);
|
2016-06-01 13:43:22 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Set which exams will be shown as selected (checkboxes on) *****/
|
|
|
|
|
if (Exams->ExaCodsSelected[0]) // Some exams selected
|
|
|
|
|
{
|
|
|
|
|
/* Reset selection */
|
|
|
|
|
for (NumExam = 0;
|
|
|
|
|
NumExam < Exams->Num;
|
|
|
|
|
NumExam++)
|
|
|
|
|
Exams->Lst[NumExam].Selected = false;
|
|
|
|
|
Exams->NumSelected = 0;
|
|
|
|
|
|
|
|
|
|
/* Set some exams as selected */
|
|
|
|
|
for (Ptr = Exams->ExaCodsSelected;
|
|
|
|
|
*Ptr;
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
/* Get next exam selected */
|
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
|
|
|
|
ExaCod = Str_ConvertStrCodToLongCod (LongStr);
|
|
|
|
|
|
|
|
|
|
/* Set each exam in *StrExaCodsSelected as selected */
|
|
|
|
|
for (NumExam = 0;
|
|
|
|
|
NumExam < Exams->Num;
|
|
|
|
|
NumExam++)
|
|
|
|
|
if (Exams->Lst[NumExam].ExaCod == ExaCod)
|
|
|
|
|
{
|
|
|
|
|
Exams->Lst[NumExam].Selected = true;
|
|
|
|
|
Exams->NumSelected++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // No exams selected
|
|
|
|
|
{
|
|
|
|
|
/***** Set all exams as selected *****/
|
|
|
|
|
for (NumExam = 0;
|
|
|
|
|
NumExam < Exams->Num;
|
|
|
|
|
NumExam++)
|
|
|
|
|
Exams->Lst[NumExam].Selected = true;
|
|
|
|
|
Exams->NumSelected = Exams->Num;
|
|
|
|
|
}
|
2016-06-01 13:43:22 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/********************** Get exam data using its code *************************/
|
2016-06-01 13:43:22 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_GetDataOfExamByCod (struct Exa_Exam *Exam)
|
2016-06-01 13:43:22 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
2020-05-06 12:47:36 +02:00
|
|
|
|
/***** Trivial check *****/
|
|
|
|
|
if (Exam->ExaCod <= 0)
|
|
|
|
|
{
|
|
|
|
|
/* Initialize to empty exam */
|
|
|
|
|
Exa_ResetExam (Exam);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-26 01:54:27 +02:00
|
|
|
|
/***** Get exam data from database *****/
|
2021-07-27 21:33:09 +02:00
|
|
|
|
if (Exa_DB_GetDataOfExamByCod (&mysql_res,Exam->ExaCod)) // Exam found...
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2016-06-01 13:43:22 +02:00
|
|
|
|
|
2021-07-27 21:33:09 +02:00
|
|
|
|
/* Get code of the exam (row[0])
|
|
|
|
|
and code of the course (row[1]) */
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exam->ExaCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Exam->CrsCod = Str_ConvertStrCodToLongCod (row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get whether the exam is hidden (row[2]) */
|
|
|
|
|
Exam->Hidden = (row[2][0] == 'Y');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get author of the exam (row[3]) */
|
|
|
|
|
Exam->UsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get maximum grade (row[4]) */
|
|
|
|
|
Exam->MaxGrade = Str_GetDoubleFromStr (row[4]);
|
|
|
|
|
if (Exam->MaxGrade < 0.0) // Only positive values allowed
|
|
|
|
|
Exam->MaxGrade = 0.0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get visibility (row[5]) */
|
|
|
|
|
Exam->Visibility = TstVis_GetVisibilityFromStr (row[5]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get the title of the exam (row[6]) */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Exam->Title,row[6],sizeof (Exam->Title) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-27 21:33:09 +02:00
|
|
|
|
/* Get number of sets,
|
|
|
|
|
number of questions,
|
|
|
|
|
number of sessions
|
|
|
|
|
and number of open sessions */
|
|
|
|
|
Exam->NumSets = Exa_DB_GetNumSetsExam (Exam->ExaCod);
|
|
|
|
|
Exam->NumQsts = Exa_DB_GetNumQstsExam (Exam->ExaCod);
|
|
|
|
|
Exam->NumSess = Exa_DB_GetNumSessionsInExam (Exam->ExaCod);
|
2021-07-20 13:14:12 +02:00
|
|
|
|
Exam->NumOpenSess = Exa_DB_GetNumOpenSessionsInExam (Exam->ExaCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
/* Initialize to empty exam */
|
|
|
|
|
Exa_ResetExam (Exam);
|
2019-03-25 19:05:10 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (Exam->ExaCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get start and end times from database *****/
|
2021-07-27 21:33:09 +02:00
|
|
|
|
if (Exa_DB_GetExamStartEnd (&mysql_res,Exam->ExaCod))
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2021-07-27 21:33:09 +02:00
|
|
|
|
/* Get start date (row[0] holds the start UTC time)
|
|
|
|
|
and end date (row[1] holds the end UTC time) */
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Exam->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[0]);
|
|
|
|
|
Exam->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Free structure that stores the query result */
|
2014-12-01 23:55:08 +01:00
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
2020-04-20 01:26:46 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Exam->TimeUTC[Dat_STR_TIME] =
|
|
|
|
|
Exam->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***************************** Free list of exams ****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_FreeListExams (struct Exa_Exams *Exams)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
if (Exams->LstIsRead && Exams->Lst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Free memory used by the list of exams *****/
|
|
|
|
|
free (Exams->Lst);
|
|
|
|
|
Exams->Lst = NULL;
|
|
|
|
|
Exams->Num = 0;
|
|
|
|
|
Exams->LstIsRead = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/*************** Ask for confirmation of removing of an exam *****************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-11-21 00:40:35 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_AskRemExam (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_exam_X;
|
|
|
|
|
extern const char *Txt_Remove_exam;
|
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Check if I can edit exams *****/
|
|
|
|
|
if (!Exa_CheckIfICanEditExams ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
|
|
|
|
if (Exams.ExaCod <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongExamExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exam.ExaCod = Exams.ExaCod;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Get data of the exam from database *****/
|
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Show question and button to remove exam *****/
|
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
|
|
|
|
Ale_ShowAlertAndButton (ActRemExa,NULL,NULL,
|
|
|
|
|
Exa_PutParams,&Exams,
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_exam,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_exam_X,
|
|
|
|
|
Exam.Title);
|
|
|
|
|
|
|
|
|
|
/***** Show exams again *****/
|
|
|
|
|
Exa_ListAllExams (&Exams);
|
|
|
|
|
}
|
2019-11-21 00:40:35 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/******************************* Remove an exam ******************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_RemoveExam (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Exam_X_removed;
|
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Check if I can edit exams *****/
|
|
|
|
|
if (!Exa_CheckIfICanEditExams ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get exam code *****/
|
2021-04-24 17:02:25 +02:00
|
|
|
|
if ((Exam.ExaCod = Exa_GetParamExamCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongExamExit ();
|
2019-03-25 19:05:10 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get data of the exam from database *****/
|
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
2019-03-25 19:05:10 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Remove exam from all tables *****/
|
|
|
|
|
Exa_RemoveExamFromAllTables (Exam.ExaCod);
|
2015-04-01 12:54:25 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Write message to show the change made *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Exam_X_removed,
|
|
|
|
|
Exam.Title);
|
2015-04-01 12:54:25 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Show exams again *****/
|
|
|
|
|
Exa_ListAllExams (&Exams);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Remove exam from all tables *************************/
|
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_RemoveExamFromAllTables (long ExaCod)
|
|
|
|
|
{
|
2021-09-08 11:05:08 +02:00
|
|
|
|
/***** Remove questions of exams prints, and exam prints, in this exam *****/
|
|
|
|
|
// TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
|
|
|
|
|
Exa_DB_RemovePrintQstsFromExa (ExaCod);
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllPrintsFromExa (ExaCod);
|
2021-07-30 12:14:57 +02:00
|
|
|
|
|
2021-09-08 11:05:08 +02:00
|
|
|
|
/***** Remove groups associated to sessions, and sessions, in this exam *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllGrpsFromExa (ExaCod);
|
|
|
|
|
Exa_DB_RemoveAllSessionsFromExam (ExaCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
2021-07-30 12:14:57 +02:00
|
|
|
|
/***** Remove media associated to exam questions in the exam *****/
|
|
|
|
|
Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (ExaCod);
|
|
|
|
|
Exa_RemoveAllMedFilesFromAnsOfAllQstsFromExam (ExaCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove the answers and the questions in sets of questions *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllSetAnswersFromExam (ExaCod);
|
|
|
|
|
Exa_DB_RemoveAllSetQuestionsFromExam (ExaCod);
|
2020-05-13 00:28:32 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove exam sets *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllSetsFromExam (ExaCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove exam *****/
|
2021-07-30 12:14:57 +02:00
|
|
|
|
Exa_DB_RemoveExam (ExaCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/*********************** Remove all exams of a course ************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2019-10-04 20:43:43 +02:00
|
|
|
|
|
2020-05-18 22:59:07 +02:00
|
|
|
|
void Exa_RemoveCrsExams (long CrsCod)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
2021-07-30 12:14:57 +02:00
|
|
|
|
/***** Remove questions of exams prints, and exam prints,
|
|
|
|
|
made in the given course *****/
|
2021-09-08 11:05:08 +02:00
|
|
|
|
// TODO: DO NOT REMOVE EXAMS PRINTS. Instead move them to tables of deleted prints
|
|
|
|
|
Exa_DB_RemovePrintQstsFromCrs (CrsCod);
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllPrintsFromCrs (CrsCod);
|
2020-05-18 22:59:07 +02:00
|
|
|
|
|
2021-09-08 11:05:08 +02:00
|
|
|
|
/***** Remove groups associated to sessions, and sessions, in this course *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllGrpsFromCrs (CrsCod);
|
|
|
|
|
Exa_DB_RemoveAllSessionsFromCrs (CrsCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/***** Remove media associated to test questions in the course *****/
|
2021-07-30 12:14:57 +02:00
|
|
|
|
Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (CrsCod);
|
|
|
|
|
Exa_RemoveAllMedFilesFromAnsOfAllQstsFromCrs (CrsCod);
|
|
|
|
|
|
|
|
|
|
/***** Remove the answers and the questions in sets of questions *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllSetAnswersFromCrs (CrsCod);
|
|
|
|
|
Exa_DB_RemoveAllSetQuestionsFromCrs (CrsCod);
|
2020-05-13 00:28:32 +02:00
|
|
|
|
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/***** Remove the sets of questions in exams *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllSetsFromCrs (CrsCod);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Remove the exams *****/
|
2021-09-09 11:11:08 +02:00
|
|
|
|
Exa_DB_RemoveAllExamsFromCrs (CrsCod);
|
2021-07-30 12:14:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Remove all media associated to stems of an exam questions *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Exa_RemoveAllMedFilesFromStemOfAllQstsFromExam (long ExaCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumMedia;
|
|
|
|
|
|
2021-09-09 18:11:46 +02:00
|
|
|
|
/***** Get media codes associated to stems of an exam questions *****/
|
|
|
|
|
NumMedia = Exa_DB_GetAllMediaFomStemOfAllQstsFromExam (&mysql_res,ExaCod);
|
2021-07-30 12:14:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Go over result removing media files *****/
|
|
|
|
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/** Remove all media associated to stems of all exam questions in a course ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-07-30 12:14:57 +02:00
|
|
|
|
static void Exa_RemoveAllMedFilesFromStemOfAllQstsFromCrs (long CrsCod)
|
2020-05-18 22:59:07 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumMedia;
|
|
|
|
|
|
|
|
|
|
/***** Get media codes associated to stems of exam questions from database *****/
|
2021-09-09 18:11:46 +02:00
|
|
|
|
NumMedia = Exa_DB_GetAllMediaFomStemOfAllQstsFromCrs (&mysql_res,CrsCod);
|
2020-05-18 22:59:07 +02:00
|
|
|
|
|
|
|
|
|
/***** Go over result removing media files *****/
|
|
|
|
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 12:14:57 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/** Remove media associated to all answers of all exam questions in an exam **/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Exa_RemoveAllMedFilesFromAnsOfAllQstsFromExam (long ExaCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumMedia;
|
|
|
|
|
|
|
|
|
|
/***** Get names of media files associated to answers of exam questions from database *****/
|
2021-09-09 18:11:46 +02:00
|
|
|
|
NumMedia = Exa_DB_GetAllMediaFromAnsOfAllQstsFromExam (&mysql_res,ExaCod);
|
2021-07-30 12:14:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Go over result removing media files *****/
|
|
|
|
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 22:59:07 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/* Remove media associated to all answers of all exam questions in a course **/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-07-30 12:14:57 +02:00
|
|
|
|
static void Exa_RemoveAllMedFilesFromAnsOfAllQstsFromCrs (long CrsCod)
|
2020-05-18 22:59:07 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumMedia;
|
|
|
|
|
|
|
|
|
|
/***** Get names of media files associated to answers of exam questions from database *****/
|
2021-09-09 18:11:46 +02:00
|
|
|
|
NumMedia = Exa_DB_GetAllMediaFromAnsOfAllQstsFromCrs (&mysql_res,CrsCod);
|
2020-05-18 22:59:07 +02:00
|
|
|
|
|
|
|
|
|
/***** Go over result removing media files *****/
|
|
|
|
|
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Hide an exam ******************************/
|
|
|
|
|
/*****************************************************************************/
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
void Exa_HideExam (void)
|
|
|
|
|
{
|
2021-09-09 18:11:46 +02:00
|
|
|
|
Exa_HideUnhideExam (true);
|
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-09-09 18:11:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Unhide an exam ******************************/
|
|
|
|
|
/*****************************************************************************/
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-09-09 18:11:46 +02:00
|
|
|
|
void Exa_UnhideExam (void)
|
|
|
|
|
{
|
|
|
|
|
Exa_HideUnhideExam (false);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-05-05 20:09:28 +02:00
|
|
|
|
/******************************* Unhide an exam ******************************/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-09 18:11:46 +02:00
|
|
|
|
static void Exa_HideUnhideExam (bool Hide)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Check if I can edit exams *****/
|
|
|
|
|
if (!Exa_CheckIfICanEditExams ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
|
|
|
|
if (Exams.ExaCod <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongExamExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exam.ExaCod = Exams.ExaCod;
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get data of the exam from database *****/
|
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-05-05 20:09:28 +02:00
|
|
|
|
/***** Unhide exam *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Exa_DB_HideOrUnhideExam (Exam.ExaCod,Hide);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Show exams again *****/
|
|
|
|
|
Exa_ListAllExams (&Exams);
|
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Request the creation or edition of an exam ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Exa_RequestCreatOrEditExam (void)
|
|
|
|
|
{
|
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
2020-04-25 23:15:47 +02:00
|
|
|
|
struct ExaSet_Set Set;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
bool ItsANewExam;
|
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Check if I can edit exams *****/
|
|
|
|
|
if (!Exa_CheckIfICanEditExams ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
2020-04-25 23:15:47 +02:00
|
|
|
|
ExaSet_ResetSet (&Set);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
|
|
|
|
Exam.ExaCod = Exams.ExaCod;
|
|
|
|
|
ItsANewExam = (Exam.ExaCod <= 0);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Get exam data *****/
|
|
|
|
|
if (ItsANewExam)
|
|
|
|
|
/* Initialize to empty exam */
|
|
|
|
|
Exa_ResetExam (&Exam);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-27 19:37:49 +02:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* Get exam data from database */
|
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
2020-04-27 19:37:49 +02:00
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-25 23:15:47 +02:00
|
|
|
|
/***** Put form to create/edit an exam and show sets *****/
|
|
|
|
|
Exa_PutFormsOneExam (&Exams,&Exam,&Set,ItsANewExam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put forms to create/edit an exam ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-07 02:22:57 +02:00
|
|
|
|
void Exa_PutFormsOneExam (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,
|
|
|
|
|
struct ExaSet_Set *Set,
|
|
|
|
|
bool ItsANewExam)
|
2020-04-25 23:15:47 +02:00
|
|
|
|
{
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
|
|
|
|
|
|
|
|
|
/***** Initialize text / get text from database *****/
|
|
|
|
|
if (ItsANewExam)
|
|
|
|
|
Txt[0] = '\0';
|
2020-04-20 01:26:46 +02:00
|
|
|
|
else
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Exa_DB_GetExamTxt (Exam->ExaCod,Txt);
|
2020-04-25 23:15:47 +02:00
|
|
|
|
|
|
|
|
|
/***** Put form to create/edit an exam *****/
|
|
|
|
|
Exa_PutFormEditionExam (Exams,Exam,Txt,ItsANewExam);
|
|
|
|
|
|
2020-04-25 23:53:15 +02:00
|
|
|
|
/***** Show other lists *****/
|
|
|
|
|
if (ItsANewExam)
|
|
|
|
|
/* Show exams again */
|
|
|
|
|
Exa_ListAllExams (Exams);
|
|
|
|
|
else
|
|
|
|
|
/* Show list of sets */
|
2020-04-25 23:15:47 +02:00
|
|
|
|
ExaSet_ListExamSets (Exams,Exam,Set);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create/edit an exam **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-07 02:22:57 +02:00
|
|
|
|
void Exa_PutFormEditionExam (struct Exa_Exams *Exams,
|
|
|
|
|
struct Exa_Exam *Exam,
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1],
|
|
|
|
|
bool ItsANewExam)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Exams_new_exam;
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Exams_edit_exam;
|
|
|
|
|
extern const char *Txt_New_exam;
|
|
|
|
|
extern const char *Txt_Edit_exam;
|
|
|
|
|
extern const char *Txt_Title;
|
|
|
|
|
extern const char *Txt_Maximum_grade;
|
|
|
|
|
extern const char *Txt_Result_visibility;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Create_exam;
|
|
|
|
|
extern const char *Txt_Save_changes;
|
|
|
|
|
|
|
|
|
|
/***** Begin form *****/
|
|
|
|
|
Exams->ExaCod = Exam->ExaCod;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ItsANewExam ? ActNewExa :
|
2020-04-20 01:26:46 +02:00
|
|
|
|
ActChgExa);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Exa_PutParams (Exams);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** 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);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Exam title *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Title",Txt_Title);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Title",Exa_MAX_CHARS_TITLE,Exam->Title,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2021-12-18 00:57:27 +01:00
|
|
|
|
"id=\"Title\""
|
2022-03-30 00:46:18 +02:00
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH INPUT_%s\""
|
2021-12-18 00:57:27 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Maximum grade *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM FORM_IN_%s\"",The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TxtColon (Txt_Maximum_grade);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
HTM_INPUT_FLOAT ("MaxGrade",0.0,DBL_MAX,0.01,Exam->MaxGrade,false,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
" class=\"INPUT_%s\" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Visibility of results *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT %s\"",The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TxtColon (Txt_Result_visibility);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LB\"");
|
|
|
|
|
TstVis_PutVisibilityCheckboxes (Exam->Visibility);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Exam text *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Txt",Txt_Description);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\" rows=\"5\""
|
2022-03-30 00:46:18 +02:00
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH INPUT_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_Txt (Txt);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** 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);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Receive form to create a new exam ********************/
|
|
|
|
|
/*****************************************************************************/
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Exa_ReceiveFormExam (void)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
struct Exa_Exams Exams;
|
|
|
|
|
struct Exa_Exam Exam;
|
2020-04-25 23:53:15 +02:00
|
|
|
|
struct ExaSet_Set Set;
|
2020-04-20 01:26:46 +02:00
|
|
|
|
bool ItsANewExam;
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Check if I can edit exams *****/
|
|
|
|
|
if (!Exa_CheckIfICanEditExams ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
/***** Reset exams context *****/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
Exa_ResetExams (&Exams);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
Exa_ResetExam (&Exam);
|
2020-04-25 23:53:15 +02:00
|
|
|
|
ExaSet_ResetSet (&Set);
|
2020-04-23 23:09:28 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_GetParams (&Exams);
|
|
|
|
|
Exam.ExaCod = Exams.ExaCod;
|
|
|
|
|
ItsANewExam = (Exam.ExaCod <= 0);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
2020-05-06 12:47:36 +02:00
|
|
|
|
/***** Get all current exam data from database *****/
|
2020-05-06 21:27:06 +02:00
|
|
|
|
// Some data, not received from form,
|
|
|
|
|
// are necessary to show exam and sets of questions again
|
2020-05-06 12:47:36 +02:00
|
|
|
|
if (!ItsANewExam)
|
|
|
|
|
{
|
|
|
|
|
Exa_GetDataOfExamByCod (&Exam);
|
|
|
|
|
Exams.ExaCod = Exam.ExaCod;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-06 21:27:06 +02:00
|
|
|
|
/***** If I can edit exams ==>
|
|
|
|
|
overwrite some exam data with the data received from form *****/
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_ReceiveExamFieldsFromForm (&Exam,Txt);
|
|
|
|
|
if (Exa_CheckExamFieldsReceivedFromForm (&Exam))
|
2019-10-31 17:42:05 +01:00
|
|
|
|
{
|
2020-04-25 01:36:53 +02:00
|
|
|
|
/***** Create a new exam or update an existing one *****/
|
|
|
|
|
if (ItsANewExam)
|
2020-04-25 23:53:15 +02:00
|
|
|
|
{
|
2020-04-25 01:36:53 +02:00
|
|
|
|
Exa_CreateExam (&Exam,Txt); // Add new exam to database
|
2020-04-25 23:53:15 +02:00
|
|
|
|
ItsANewExam = false;
|
|
|
|
|
}
|
2020-04-25 01:36:53 +02:00
|
|
|
|
else
|
|
|
|
|
Exa_UpdateExam (&Exam,Txt); // Update exam data in database
|
2019-10-31 17:42:05 +01:00
|
|
|
|
}
|
2020-04-25 01:36:53 +02:00
|
|
|
|
|
2020-04-26 01:54:27 +02:00
|
|
|
|
/***** Show current exam and its sets *****/
|
2020-04-25 23:53:15 +02:00
|
|
|
|
Exa_PutFormsOneExam (&Exams,&Exam,&Set,
|
|
|
|
|
ItsANewExam); // It's not a new exam
|
2020-04-20 01:26:46 +02:00
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_ReceiveExamFieldsFromForm (struct Exa_Exam *Exam,
|
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1])
|
|
|
|
|
{
|
|
|
|
|
char MaxGradeStr[64];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get exam title *****/
|
|
|
|
|
Par_GetParToText ("Title",Exam->Title,Exa_MAX_BYTES_TITLE);
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get maximum grade *****/
|
|
|
|
|
Par_GetParToText ("MaxGrade",MaxGradeStr,sizeof (MaxGradeStr) - 1);
|
|
|
|
|
Exam->MaxGrade = Str_GetDoubleFromStr (MaxGradeStr);
|
|
|
|
|
if (Exam->MaxGrade < 0.0) // Only positive values allowed
|
|
|
|
|
Exam->MaxGrade = 0.0;
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/***** Get visibility *****/
|
|
|
|
|
Exam->Visibility = TstVis_GetVisibilityFromForm ();
|
|
|
|
|
|
|
|
|
|
/***** Get exam text *****/
|
|
|
|
|
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool Exa_CheckExamFieldsReceivedFromForm (const struct Exa_Exam *Exam)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Already_existed_an_exam_with_the_title_X;
|
|
|
|
|
bool NewExamIsCorrect;
|
|
|
|
|
|
|
|
|
|
/***** Check if title is correct *****/
|
|
|
|
|
NewExamIsCorrect = true;
|
|
|
|
|
if (Exam->Title[0]) // If there's an exam title
|
2019-10-31 17:42:05 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/* If title of exam was in database... */
|
2021-09-09 18:11:46 +02:00
|
|
|
|
if (Exa_DB_CheckIfSimilarExamExists (Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
Exam->ExaCod,Exam->Title))
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
NewExamIsCorrect = false;
|
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_an_exam_with_the_title_X,
|
|
|
|
|
Exam->Title);
|
|
|
|
|
}
|
2019-10-31 17:42:05 +01:00
|
|
|
|
}
|
2020-04-20 01:26:46 +02:00
|
|
|
|
else // If there is not an exam title
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-20 01:26:46 +02:00
|
|
|
|
NewExamIsCorrect = false;
|
2022-06-18 19:50:40 +02:00
|
|
|
|
Ale_ShowAlertYouMustSpecifyTheTitle ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
return NewExamIsCorrect;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Create a new exam ******************************/
|
|
|
|
|
/*****************************************************************************/
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
static void Exa_CreateExam (struct Exa_Exam *Exam,const char *Txt)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Created_new_exam_X;
|
|
|
|
|
|
|
|
|
|
/***** Create a new exam *****/
|
2021-09-09 18:11:46 +02:00
|
|
|
|
Exam->ExaCod = Exa_DB_CreateExam (Exam,Txt);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_exam_X,
|
|
|
|
|
Exam->Title);
|
|
|
|
|
}
|
2019-10-07 08:55:06 +02:00
|
|
|
|
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Update an existing exam *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_exam_has_been_modified;
|
|
|
|
|
|
|
|
|
|
/***** Update the data of the exam *****/
|
2021-09-09 18:11:46 +02:00
|
|
|
|
Exa_DB_UpdateExam (Exam,Txt);
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_exam_has_been_modified);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/********** Get number of sessions and check is edition is possible **********/
|
2020-04-20 01:26:46 +02:00
|
|
|
|
/*****************************************************************************/
|
2020-05-17 02:28:30 +02:00
|
|
|
|
// Before calling this function, number of sessions must be calculated
|
2020-04-20 01:26:46 +02:00
|
|
|
|
|
2020-05-07 02:22:57 +02:00
|
|
|
|
bool Exa_CheckIfEditable (const struct Exa_Exam *Exam)
|
2020-04-20 01:26:46 +02:00
|
|
|
|
{
|
|
|
|
|
if (Exa_CheckIfICanEditExams ())
|
2020-05-17 02:28:30 +02:00
|
|
|
|
/***** Questions are editable only if exam has no sessions *****/
|
2021-11-12 01:12:15 +01:00
|
|
|
|
return Exam->NumSess == 0; // Exams with sessions should not be edited
|
2020-04-20 01:26:46 +02:00
|
|
|
|
else
|
|
|
|
|
return false; // Questions are not editable
|
|
|
|
|
}
|
2022-01-03 02:47:16 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Show stats about exams **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Exa_GetAndShowExamsStats (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ANALYTICS_Figures_exams;
|
|
|
|
|
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
|
|
|
|
|
extern const char *Txt_Number_of_BR_exams;
|
|
|
|
|
extern const char *Txt_Number_of_BR_courses_with_BR_exams;
|
|
|
|
|
extern const char *Txt_Average_number_BR_of_exams_BR_per_course;
|
|
|
|
|
unsigned NumExams;
|
|
|
|
|
unsigned NumCoursesWithExams = 0;
|
|
|
|
|
double NumExamsPerCourse = 0.0;
|
|
|
|
|
|
|
|
|
|
/***** Get the number of exams from this location *****/
|
|
|
|
|
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 *****/
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_FIGURE_TYPES[Fig_EXAMS],
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_ANALYTICS_Figures_exams,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Write table heading *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_exams ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Number_of_BR_courses_with_BR_exams ,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TH (Txt_Average_number_BR_of_exams_BR_per_course,HTM_HEAD_RIGHT);
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write number of exams *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
2022-01-03 02:47:16 +01:00
|
|
|
|
HTM_Unsigned (NumExams);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
2022-01-03 02:47:16 +01:00
|
|
|
|
HTM_Unsigned (NumCoursesWithExams);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
2022-01-03 02:47:16 +01:00
|
|
|
|
HTM_Double2Decimals (NumExamsPerCourse);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_BoxTableEnd ();
|
|
|
|
|
}
|