2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_test.h: self-assessment tests
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_TST
|
|
|
|
|
#define _SWAD_TST
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2020-01-01 14:53:57 +01:00
|
|
|
|
Copyright (C) 1999-2020 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
|
|
|
|
|
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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-09-07 18:38:18 +02:00
|
|
|
|
#include "swad_game.h"
|
2020-03-17 13:10:44 +01:00
|
|
|
|
#include "swad_media.h"
|
2020-03-21 15:41:25 +01:00
|
|
|
|
#include "swad_test_config.h"
|
2020-04-02 03:28:08 +02:00
|
|
|
|
// #include "swad_test_exam.h"
|
2017-09-06 23:17:52 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public constants ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 03:48:23 +01:00
|
|
|
|
#define Tst_MAX_TAGS_PER_QUESTION 5
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Tst_MAX_CHARS_TAG (128 - 1) // 127
|
|
|
|
|
#define Tst_MAX_BYTES_TAG ((Tst_MAX_CHARS_TAG + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2017-03-08 03:48:23 +01:00
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Tst_MAX_CHARS_ANSWER_OR_FEEDBACK (1024 - 1) // 1023
|
|
|
|
|
#define Tst_MAX_BYTES_ANSWER_OR_FEEDBACK ((Tst_MAX_CHARS_ANSWER_OR_FEEDBACK + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383
|
2017-03-08 03:48:23 +01:00
|
|
|
|
|
|
|
|
|
#define Tst_MAX_BYTES_ANSWER_TYPE 32
|
2017-01-15 18:02:52 +01:00
|
|
|
|
|
2020-04-02 03:28:08 +02:00
|
|
|
|
#define Tst_MAX_OPTIONS_PER_QUESTION 10
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Public types ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-03-21 15:41:25 +01:00
|
|
|
|
struct Tst_Tags
|
|
|
|
|
{
|
|
|
|
|
unsigned Num;
|
|
|
|
|
bool All;
|
|
|
|
|
char *List;
|
|
|
|
|
char Txt[Tst_MAX_TAGS_PER_QUESTION][Tst_MAX_BYTES_TAG + 1];
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-19 13:02:58 +01:00
|
|
|
|
#define Tst_NUM_ANS_TYPES 6
|
|
|
|
|
#define Tst_MAX_BYTES_LIST_ANSWER_TYPES (Tst_NUM_ANS_TYPES * (Cns_MAX_DECIMAL_DIGITS_UINT + 1))
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Tst_ANS_INT = 0,
|
|
|
|
|
Tst_ANS_FLOAT = 1,
|
|
|
|
|
Tst_ANS_TRUE_FALSE = 2,
|
|
|
|
|
Tst_ANS_UNIQUE_CHOICE = 3,
|
|
|
|
|
Tst_ANS_MULTIPLE_CHOICE = 4,
|
|
|
|
|
Tst_ANS_TEXT = 5,
|
|
|
|
|
Tst_ANS_ALL = 6, // All/any type of answer
|
|
|
|
|
} Tst_AnswerType_t;
|
|
|
|
|
|
2020-03-21 22:18:24 +01:00
|
|
|
|
struct Tst_AnswerTypes
|
|
|
|
|
{
|
|
|
|
|
bool All;
|
|
|
|
|
char List[Tst_MAX_BYTES_LIST_ANSWER_TYPES + 1];
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-21 15:41:25 +01:00
|
|
|
|
#define Tst_NUM_TYPES_ORDER_QST 5
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Tst_ORDER_STEM = 0,
|
|
|
|
|
Tst_ORDER_NUM_HITS = 1,
|
|
|
|
|
Tst_ORDER_AVERAGE_SCORE = 2,
|
|
|
|
|
Tst_ORDER_NUM_HITS_NOT_BLANK = 3,
|
|
|
|
|
Tst_ORDER_AVERAGE_SCORE_NOT_BLANK = 4,
|
|
|
|
|
} Tst_QuestionsOrder_t;
|
2020-03-22 19:34:53 +01:00
|
|
|
|
#define Tst_DEFAULT_ORDER Tst_ORDER_STEM
|
2020-03-21 15:41:25 +01:00
|
|
|
|
|
2020-03-17 13:10:44 +01:00
|
|
|
|
struct Tst_Question
|
|
|
|
|
{
|
2020-03-25 01:36:22 +01:00
|
|
|
|
long QstCod;
|
|
|
|
|
struct Tst_Tags Tags;
|
2020-04-03 19:13:00 +02:00
|
|
|
|
time_t EditTime;
|
2020-04-04 19:20:50 +02:00
|
|
|
|
char *Stem;
|
|
|
|
|
char *Feedback;
|
2020-03-17 13:10:44 +01:00
|
|
|
|
struct Media Media;
|
2020-03-18 01:57:08 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
2020-03-19 20:57:54 +01:00
|
|
|
|
Tst_AnswerType_t Type;
|
|
|
|
|
unsigned NumOptions;
|
2020-04-03 19:13:00 +02:00
|
|
|
|
bool Shuffle;
|
2020-03-19 20:57:54 +01:00
|
|
|
|
char TF;
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
bool Correct;
|
|
|
|
|
char *Text;
|
|
|
|
|
char *Feedback;
|
|
|
|
|
struct Media Media;
|
|
|
|
|
} Options[Tst_MAX_OPTIONS_PER_QUESTION];
|
|
|
|
|
long Integer;
|
|
|
|
|
double FloatingPoint[2];
|
|
|
|
|
} Answer;
|
2020-04-04 02:07:54 +02:00
|
|
|
|
unsigned long NumHits;
|
|
|
|
|
unsigned long NumHitsNotBlank;
|
|
|
|
|
double Score;
|
2020-03-18 01:57:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2020-03-26 21:39:44 +01:00
|
|
|
|
struct Tst_Test
|
|
|
|
|
{
|
|
|
|
|
struct Tst_Tags Tags; // Selected tags
|
|
|
|
|
struct Tst_AnswerTypes AnswerTypes; // Selected answer types
|
|
|
|
|
Tst_QuestionsOrder_t SelectedOrder; // Order for listing questions
|
|
|
|
|
unsigned NumQsts; // Number of questions
|
|
|
|
|
struct Tst_Question Question; // Selected / editing question
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-01 14:36:25 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2017-09-04 17:03:49 +02:00
|
|
|
|
Tst_SHOW_TEST_TO_ANSWER, // Showing a test to a student
|
2019-09-17 15:42:41 +02:00
|
|
|
|
Tst_SHOW_TEST_RESULT, // Showing the assessment of a test
|
2017-09-04 17:03:49 +02:00
|
|
|
|
Tst_EDIT_TEST, // Editing test questions
|
2017-09-01 14:36:25 +02:00
|
|
|
|
Tst_SELECT_QUESTIONS_FOR_GAME, // Selecting test questions for a game
|
|
|
|
|
} Tst_ActionToDoWithQuestions_t;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Tst_Stats
|
|
|
|
|
{
|
|
|
|
|
unsigned NumCoursesWithQuestions;
|
|
|
|
|
unsigned NumCoursesWithPluggableQuestions;
|
|
|
|
|
unsigned NumQsts;
|
2019-11-11 00:15:44 +01:00
|
|
|
|
double AvgQstsPerCourse;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long NumHits;
|
2019-11-11 00:15:44 +01:00
|
|
|
|
double AvgHitsPerCourse;
|
|
|
|
|
double AvgHitsPerQuestion;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
double TotalScore;
|
|
|
|
|
double AvgScorePerQuestion;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-03-21 15:41:25 +01:00
|
|
|
|
void Tst_RequestTest (void);
|
2016-11-21 13:15:08 +01:00
|
|
|
|
void Tst_ShowNewTest (void);
|
2020-03-30 00:30:08 +02:00
|
|
|
|
void Tst_RequestAssessTest (void);
|
2016-11-21 13:15:08 +01:00
|
|
|
|
void Tst_AssessTest (void);
|
2019-11-28 09:12:34 +01:00
|
|
|
|
|
2019-09-24 22:48:25 +02:00
|
|
|
|
void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res);
|
|
|
|
|
|
2020-03-23 17:14:41 +01:00
|
|
|
|
void Tst_WriteNumQst (unsigned NumQst);
|
|
|
|
|
void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType);
|
2020-02-17 15:30:55 +01:00
|
|
|
|
void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback);
|
2015-10-26 13:06:26 +01:00
|
|
|
|
|
2020-03-21 15:41:25 +01:00
|
|
|
|
void Tst_RequestEditTests (void);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
void Tst_RequestSelectTestsForGame (struct Gam_Games *Games);
|
2020-03-21 15:41:25 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ListQuestionsToEdit (void);
|
2020-04-08 03:06:45 +02:00
|
|
|
|
void Tst_ListQuestionsToSelect (struct Gam_Games *Games);
|
2020-03-26 21:39:44 +01:00
|
|
|
|
void Tst_WriteParamEditQst (const struct Tst_Test *Test);
|
2020-03-21 15:41:25 +01:00
|
|
|
|
|
2019-05-22 09:36:18 +02:00
|
|
|
|
unsigned Tst_GetNumAnswersQst (long QstCod);
|
2020-03-25 01:36:22 +01:00
|
|
|
|
void Tst_GetAnswersQst (struct Tst_Question *Question,MYSQL_RES **mysql_res,
|
|
|
|
|
bool Shuffle);
|
2020-04-04 02:07:54 +02:00
|
|
|
|
void Tst_WriteAnswersListing (const struct Tst_Question *Question);
|
2019-05-22 09:36:18 +02:00
|
|
|
|
bool Tst_CheckIfQuestionIsValidForGame (long QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_WriteAnsTF (char AnsTF);
|
2020-04-02 03:28:08 +02:00
|
|
|
|
void Tst_GetChoiceAns (struct Tst_Question *Question,MYSQL_RES *mysql_res);
|
2020-03-19 20:57:54 +01:00
|
|
|
|
void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question);
|
2017-09-06 15:03:43 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long Tst_GetTagsQst (long QstCod,MYSQL_RES **mysql_res);
|
2017-09-06 15:03:43 +02:00
|
|
|
|
void Tst_GetAndWriteTagsQst (long QstCod);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ShowFormConfig (void);
|
|
|
|
|
void Tst_EnableTag (void);
|
|
|
|
|
void Tst_DisableTag (void);
|
|
|
|
|
void Tst_RenameTag (void);
|
2017-07-16 13:54:11 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown (void);
|
2020-03-21 15:41:25 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ShowFormEditOneQst (void);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2020-03-19 20:57:54 +01:00
|
|
|
|
void Tst_QstConstructor (struct Tst_Question *Question);
|
|
|
|
|
void Tst_QstDestructor (struct Tst_Question *Question);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2020-03-25 01:36:22 +01:00
|
|
|
|
bool Tst_AllocateTextChoiceAnswer (struct Tst_Question *Question,unsigned NumOpt);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2020-04-02 03:28:08 +02:00
|
|
|
|
Tst_AnswerType_t Tst_GetQstAnswerType (long QstCod);
|
2020-04-04 19:20:50 +02:00
|
|
|
|
bool Tst_GetQstDataFromDB (struct Tst_Question *Question);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD);
|
|
|
|
|
void Tst_ReceiveQst (void);
|
2020-03-25 01:36:22 +01:00
|
|
|
|
bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (struct Tst_Question *Question);
|
2019-12-15 20:02:34 +01:00
|
|
|
|
|
2020-03-25 01:36:22 +01:00
|
|
|
|
bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question);
|
2019-12-15 20:02:34 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long Tst_GetIntAnsFromStr (char *Str);
|
2020-03-17 00:35:11 +01:00
|
|
|
|
|
|
|
|
|
void Tst_RequestRemoveSelectedQsts (void);
|
|
|
|
|
void Tst_RemoveSelectedQsts (void);
|
|
|
|
|
void Tst_RequestRemoveOneQst (void);
|
|
|
|
|
void Tst_RemoveOneQst (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ChangeShuffleQst (void);
|
2017-09-08 01:18:20 +02:00
|
|
|
|
|
2020-03-26 15:22:51 +01:00
|
|
|
|
void Tst_PutParamQstCod (void *QstCodPtr);
|
2017-09-08 01:18:20 +02:00
|
|
|
|
|
2020-03-25 01:36:22 +01:00
|
|
|
|
void Tst_InsertOrUpdateQstTagsAnsIntoDB (struct Tst_Question *Question);
|
2016-04-01 21:56:00 +02:00
|
|
|
|
|
2020-02-16 13:02:30 +01:00
|
|
|
|
void Tst_RemoveCrsTests (long CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats);
|
|
|
|
|
|
|
|
|
|
#endif
|