2021-10-26 09:23:06 +02:00
|
|
|
|
// swad_test_print.h: test prints made by users
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2020-05-07 18:33:26 +02:00
|
|
|
|
#ifndef _SWAD_TST_PRN
|
|
|
|
|
#define _SWAD_TST_PRN
|
2020-04-02 03:28:08 +02:00
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2022-09-21 10:46:14 +02:00
|
|
|
|
Copyright (C) 1999-2022 Antonio Ca<EFBFBD>as Vargas
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-10-25 10:24:43 +02:00
|
|
|
|
#include "swad_question.h"
|
2021-10-25 09:48:54 +02:00
|
|
|
|
#include "swad_question_type.h"
|
2021-10-25 13:52:17 +02:00
|
|
|
|
#include "swad_test.h"
|
2020-05-07 18:33:26 +02:00
|
|
|
|
#include "swad_test_config.h"
|
2020-05-22 20:10:45 +02:00
|
|
|
|
#include "swad_test_visibility.h"
|
2020-04-02 03:28:08 +02:00
|
|
|
|
#include "swad_user.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Public types ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-06-24 02:15:50 +02:00
|
|
|
|
struct TstPrn_NumQuestions
|
|
|
|
|
{
|
|
|
|
|
unsigned All; // Total number of questions
|
|
|
|
|
unsigned NotBlank; // Answered questions
|
|
|
|
|
};
|
|
|
|
|
|
2020-06-22 19:27:23 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
TstPrn_ANSWER_IS_CORRECT,
|
|
|
|
|
TstPrn_ANSWER_IS_WRONG_NEGATIVE,
|
|
|
|
|
TstPrn_ANSWER_IS_WRONG_ZERO,
|
|
|
|
|
TstPrn_ANSWER_IS_WRONG_POSITIVE,
|
|
|
|
|
TstPrn_ANSWER_IS_BLANK,
|
|
|
|
|
} TstPrn_Correct_t;
|
|
|
|
|
|
2020-05-07 18:33:26 +02:00
|
|
|
|
struct TstPrn_PrintedQuestion
|
2020-04-02 03:28:08 +02:00
|
|
|
|
{
|
2020-05-07 18:33:26 +02:00
|
|
|
|
long QstCod; // Question code
|
2020-05-09 21:07:50 +02:00
|
|
|
|
long SetCod; // Only for exams
|
2021-10-24 21:35:42 +02:00
|
|
|
|
char StrIndexes[Qst_MAX_BYTES_INDEXES_ONE_QST + 1]; // 0 1 2 3, 3 0 2 1, etc.
|
|
|
|
|
char StrAnswers[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1]; // Answers selected by user
|
2020-06-22 19:27:23 +02:00
|
|
|
|
TstPrn_Correct_t AnswerIsCorrect; // Is question wrong, medium or correct?
|
|
|
|
|
double Score; // Question score
|
2020-05-07 18:33:26 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TstPrn_Print
|
|
|
|
|
{
|
|
|
|
|
long PrnCod; // Test print code
|
2020-04-02 03:28:08 +02:00
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
2020-06-24 02:15:50 +02:00
|
|
|
|
struct TstPrn_NumQuestions NumQsts; // Number of questions
|
2020-05-07 18:33:26 +02:00
|
|
|
|
bool Sent; // This test print has been sent or not?
|
2020-04-16 21:03:22 +02:00
|
|
|
|
// "Sent" means that user has clicked "Send" button after finishing
|
2020-04-22 03:15:04 +02:00
|
|
|
|
bool AllowTeachers; // Are teachers allowed to see this test result?
|
2020-05-07 18:33:26 +02:00
|
|
|
|
double Score; // Total score of the test print
|
|
|
|
|
struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST];
|
2020-04-02 03:28:08 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-06-17 02:31:42 +02:00
|
|
|
|
#define Tst_NUM_REQUEST_OR_CONFIRM 2
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
TstPrn_REQUEST,
|
|
|
|
|
TstPrn_CONFIRM,
|
|
|
|
|
} TstPrn_RequestOrConfirm_t;
|
|
|
|
|
|
2020-04-02 03:28:08 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-11 02:28:38 +02:00
|
|
|
|
void TstPrn_ResetPrint (struct TstPrn_Print *Print);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2020-06-17 02:31:42 +02:00
|
|
|
|
void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
2021-10-26 09:23:06 +02:00
|
|
|
|
unsigned NumPrintsGeneratedByMe,
|
2020-06-17 02:31:42 +02:00
|
|
|
|
TstPrn_RequestOrConfirm_t RequestOrConfirm);
|
|
|
|
|
|
2020-05-18 14:34:31 +02:00
|
|
|
|
void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2021-10-26 17:33:20 +02:00
|
|
|
|
void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print);
|
|
|
|
|
|
2020-05-09 01:37:00 +02:00
|
|
|
|
void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print,
|
2020-05-18 14:34:31 +02:00
|
|
|
|
bool UpdateQstScore);
|
2020-05-09 01:37:00 +02:00
|
|
|
|
void TstPrn_ComputeAnswerScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
struct Qst_Question *Question);
|
2020-05-13 12:53:27 +02:00
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2020-05-13 13:13:03 +02:00
|
|
|
|
|
2020-05-13 12:53:27 +02:00
|
|
|
|
void TstPrn_ComputeIntAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
const struct Qst_Question *Question);
|
2020-05-13 12:53:27 +02:00
|
|
|
|
void TstPrn_ComputeFltAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
const struct Qst_Question *Question);
|
2020-05-13 12:53:27 +02:00
|
|
|
|
void TstPrn_ComputeTF_AnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
const struct Qst_Question *Question);
|
2020-05-13 12:53:27 +02:00
|
|
|
|
void TstPrn_ComputeChoAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
const struct Qst_Question *Question);
|
2020-05-13 12:53:27 +02:00
|
|
|
|
void TstPrn_ComputeTxtAnsScore (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
const struct Qst_Question *Question);
|
2021-10-25 09:30:46 +02:00
|
|
|
|
|
2020-05-13 12:53:27 +02:00
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
2021-10-24 21:35:42 +02:00
|
|
|
|
void Qst_ChangeFormatAnswersText (struct Qst_Question *Question);
|
|
|
|
|
void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question);
|
2020-06-17 02:31:42 +02:00
|
|
|
|
|
2021-10-24 21:35:42 +02:00
|
|
|
|
void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Qst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc.
|
|
|
|
|
unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]);
|
|
|
|
|
void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Qst_MAX_BYTES_ANSWERS_ONE_QST + 1],
|
|
|
|
|
bool UsrAnswers[Qst_MAX_OPTIONS_PER_QUESTION]);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2020-05-07 18:33:26 +02:00
|
|
|
|
void TstPrn_ComputeAndShowGrade (unsigned NumQsts,double Score,double MaxGrade);
|
|
|
|
|
double TstPrn_ComputeGrade (unsigned NumQsts,double Score,double MaxGrade);
|
|
|
|
|
void TstPrn_ShowGrade (double Grade,double MaxGrade);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void TstPrn_WriteAnswersExam (struct Usr_Data *UsrDat,
|
2020-05-16 02:04:36 +02:00
|
|
|
|
const struct TstPrn_PrintedQuestion *PrintedQuestion,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
struct Qst_Question *Question,
|
2020-06-17 20:20:16 +02:00
|
|
|
|
bool ICanView[TstVis_NUM_ITEMS_VISIBILITY],
|
|
|
|
|
const char *ClassTxt,
|
|
|
|
|
const char *ClassFeedback);
|
2020-05-16 02:04:36 +02:00
|
|
|
|
|
2020-05-18 14:34:31 +02:00
|
|
|
|
void TstPrn_SelUsrsToViewUsrsPrints (void);
|
|
|
|
|
void TstPrn_SelDatesToSeeMyPrints (void);
|
|
|
|
|
void TstPrn_ShowMyPrints (void);
|
|
|
|
|
void TstPrn_GetUsrsAndShowPrints (void);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2020-05-09 21:07:50 +02:00
|
|
|
|
void TstPrn_PutParamPrnCod (long ExaCod);
|
|
|
|
|
long TstPrn_GetParamPrnCod (void);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2020-05-18 14:34:31 +02:00
|
|
|
|
void TstPrn_ShowOnePrint (void);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void TstPrn_ShowPrintAnswers (struct Usr_Data *UsrDat,
|
2020-06-24 20:10:57 +02:00
|
|
|
|
unsigned NumQsts,
|
|
|
|
|
struct TstPrn_PrintedQuestion PrintedQuestions[TstCfg_MAX_QUESTIONS_PER_TEST],
|
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
2020-05-18 14:34:31 +02:00
|
|
|
|
unsigned Visibility);
|
2020-05-10 01:42:30 +02:00
|
|
|
|
void TstPrn_GetPrintDataByPrnCod (struct TstPrn_Print *Print);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2021-11-26 01:53:31 +01:00
|
|
|
|
bool TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print);
|
2020-05-18 14:34:31 +02:00
|
|
|
|
void TstPrn_RemovePrintsMadeByUsrInAllCrss (long UsrCod);
|
|
|
|
|
void TstPrn_RemovePrintsMadeByUsrInCrs (long UsrCod,long CrsCod);
|
|
|
|
|
void TstPrn_RemoveCrsPrints (long CrsCod);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
|
2021-10-26 09:23:06 +02:00
|
|
|
|
unsigned TstPrn_GetNumPrintsGeneratedByMe (void);
|
|
|
|
|
|
2020-04-02 03:28:08 +02:00
|
|
|
|
#endif
|