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.
|
2019-01-07 21:52:19 +01:00
|
|
|
|
Copyright (C) 1999-2019 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"
|
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_SCORE_MAX 10 // Maximum score of a test (10 in Spain). Must be unsigned! // TODO: Make this configurable by teachers
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-08 03:48:23 +01:00
|
|
|
|
#define Tst_MAX_QUESTIONS_PER_TEST 100 // Absolute maximum number of questions in a test
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
#define Tst_MAX_OPTIONS_PER_QUESTION 10
|
2017-03-13 19:02:15 +01:00
|
|
|
|
#define Tst_MAX_BYTES_INDEXES_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1))
|
|
|
|
|
#define Tst_MAX_BYTES_ANSWERS_ONE_QST (Tst_MAX_OPTIONS_PER_QUESTION * (10 + 1))
|
2014-12-01 23:55:08 +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_CONFIG_DEFAULT_MIN_QUESTIONS 1
|
|
|
|
|
#define Tst_CONFIG_DEFAULT_DEF_QUESTIONS 20 // Number of questions to be generated by default in a self-assessment test
|
|
|
|
|
#define Tst_CONFIG_DEFAULT_MAX_QUESTIONS 30 // Maximum number of questions to be generated in a self-assessment test
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-08 03:48:23 +01:00
|
|
|
|
#define Tst_MAX_BYTES_FEEDBACK_TYPE 32
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-08 03:48:23 +01:00
|
|
|
|
#define Tst_MAX_BYTES_ANSWER_TYPE 32
|
2017-01-15 18:02:52 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Public types ********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define Tst_NUM_OPTIONS_PLUGGABLE 3
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Tst_PLUGGABLE_UNKNOWN = 0,
|
|
|
|
|
Tst_PLUGGABLE_NO = 1,
|
|
|
|
|
Tst_PLUGGABLE_YES = 2,
|
|
|
|
|
} Tst_Pluggable_t;
|
|
|
|
|
|
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
|
|
|
|
#define Tst_NUM_TYPES_FEEDBACK 5
|
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Tst_FEEDBACK_NOTHING = 0,
|
|
|
|
|
Tst_FEEDBACK_TOTAL_RESULT = 1,
|
|
|
|
|
Tst_FEEDBACK_EACH_RESULT = 2,
|
|
|
|
|
Tst_FEEDBACK_EACH_GOOD_BAD = 3,
|
|
|
|
|
Tst_FEEDBACK_FULL_FEEDBACK = 4,
|
|
|
|
|
} Tst_Feedback_t;
|
|
|
|
|
#define Tst_FEEDBACK_DEFAULT Tst_FEEDBACK_FULL_FEEDBACK
|
|
|
|
|
|
|
|
|
|
struct Tst_Config
|
|
|
|
|
{
|
|
|
|
|
Tst_Pluggable_t Pluggable;
|
2016-11-19 16:46:43 +01:00
|
|
|
|
unsigned Min; // Minimum number of questions
|
|
|
|
|
unsigned Def; // Default number of questions
|
|
|
|
|
unsigned Max; // Maximum number of questions
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned long MinTimeNxtTstPerQst;
|
2018-04-24 13:21:53 +02:00
|
|
|
|
Tst_Feedback_t Feedback;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define Tst_NUM_ANS_TYPES 6
|
2019-11-08 01:10:32 +01:00
|
|
|
|
#define Tst_MAX_BYTES_LIST_ANSWER_TYPES (Tst_NUM_ANS_TYPES * (Cns_MAX_DECIMAL_DIGITS_UINT + 1))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
#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;
|
|
|
|
|
|
|
|
|
|
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 *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Tst_ShowFormAskTst (void);
|
2016-11-21 13:15:08 +01:00
|
|
|
|
void Tst_ShowNewTest (void);
|
|
|
|
|
void Tst_AssessTest (void);
|
2019-09-23 20:47:42 +02:00
|
|
|
|
void Tst_ShowTstTotalMark (unsigned NumQsts,double TotalScore);
|
2017-09-01 14:36:25 +02:00
|
|
|
|
|
2019-09-24 22:48:25 +02:00
|
|
|
|
void Tst_ShowTagList (unsigned NumTags,MYSQL_RES *mysql_res);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_WriteQstStem (const char *Stem,const char *ClassStem);
|
|
|
|
|
void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback);
|
2015-10-26 13:06:26 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ShowFormAskEditTsts (void);
|
2019-09-29 17:33:39 +02:00
|
|
|
|
void Tst_ShowFormAskSelectTstsForGame (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_ListQuestionsToEdit (void);
|
2019-09-29 17:33:39 +02:00
|
|
|
|
void Tst_ListQuestionsToSelect (void);
|
2017-09-01 14:36:25 +02:00
|
|
|
|
bool Tst_GetOneQuestionByCod (long QstCod,MYSQL_RES **mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_WriteParamEditQst (void);
|
2019-05-22 09:36:18 +02:00
|
|
|
|
unsigned Tst_GetNumAnswersQst (long QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned Tst_GetAnswersQst (long QstCod,MYSQL_RES **mysql_res,bool Shuffle);
|
2019-09-23 19:17:12 +02:00
|
|
|
|
void Tst_GetCorrectAnswersFromDB (long QstCod);
|
2019-09-24 19:09:06 +02:00
|
|
|
|
void Tst_WriteAnswersEdit (long QstCod);
|
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);
|
2019-09-23 01:48:28 +02:00
|
|
|
|
void Tst_GetChoiceAns (MYSQL_RES *mysql_res);
|
2019-09-23 19:17:12 +02:00
|
|
|
|
void Tst_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ONE_QST + 1], // 0 1 2 3, 3 0 2 1, etc.
|
|
|
|
|
unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]);
|
|
|
|
|
void Tst_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1],
|
|
|
|
|
bool AnswersUsr[Tst_MAX_OPTIONS_PER_QUESTION]);
|
2019-09-23 01:48:28 +02:00
|
|
|
|
void Tst_ComputeScoreQst (unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION],
|
|
|
|
|
bool AnswersUsr[Tst_MAX_OPTIONS_PER_QUESTION],
|
|
|
|
|
double *ScoreThisQst,bool *AnswerIsNotBlank);
|
2019-10-23 01:30:11 +02:00
|
|
|
|
void Tst_WriteChoiceAnsViewMatch (long MchCod,unsigned QstInd,long QstCod,
|
|
|
|
|
unsigned NumCols,const char *Class,bool ShowResult);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_CheckIfNumberOfAnswersIsOne (void);
|
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
|
|
|
|
|
2019-09-22 13:54:11 +02:00
|
|
|
|
void Tst_GetConfigTstFromDB (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_GetConfigFromRow (MYSQL_ROW row);
|
|
|
|
|
bool Tst_CheckIfCourseHaveTestsAndPluggableIsUnknown (void);
|
|
|
|
|
void Tst_ReceiveConfigTst (void);
|
|
|
|
|
void Tst_ShowFormEditOneQst (void);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
|
|
|
|
void Tst_QstConstructor (void);
|
|
|
|
|
void Tst_QstDestructor (void);
|
|
|
|
|
|
|
|
|
|
int Tst_AllocateTextChoiceAnswer (unsigned NumOpt);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeBD);
|
|
|
|
|
void Tst_ReceiveQst (void);
|
|
|
|
|
bool Tst_CheckIfQstFormatIsCorrectAndCountNumOptions (void);
|
|
|
|
|
long Tst_GetIntAnsFromStr (char *Str);
|
|
|
|
|
double Tst_GetFloatAnsFromStr (char *Str);
|
2016-04-05 02:59:34 +02:00
|
|
|
|
void Tst_RequestRemoveQst (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_RemoveQst (void);
|
|
|
|
|
void Tst_ChangeShuffleQst (void);
|
2017-09-08 01:18:20 +02:00
|
|
|
|
|
|
|
|
|
void Tst_PutParamQstCod (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_InsertOrUpdateQstTagsAnsIntoDB (void);
|
2016-04-01 21:56:00 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Tst_FreeTagsList (void);
|
|
|
|
|
|
|
|
|
|
void Tst_GetTestStats (Tst_AnswerType_t AnsType,struct Tst_Stats *Stats);
|
|
|
|
|
|
2019-09-18 23:49:07 +02:00
|
|
|
|
void Tst_SelUsrsToViewUsrsTstResults (void);
|
2019-09-22 13:54:11 +02:00
|
|
|
|
void Tst_SelDatesToSeeMyTstResults (void);
|
|
|
|
|
void Tst_ShowMyTstResults (void);
|
2019-11-14 14:34:34 +01:00
|
|
|
|
void Tst_GetUsrsAndShowTstResults (void);
|
2019-09-22 13:54:11 +02:00
|
|
|
|
void Tst_ShowOneTstResult (void);
|
2019-09-24 19:09:06 +02:00
|
|
|
|
void Tst_ShowTestResult (struct UsrData *UsrDat,
|
|
|
|
|
unsigned NumQsts,time_t TstTimeUTC);
|
2016-11-21 13:15:08 +01:00
|
|
|
|
void Tst_RemoveTestResultsMadeByUsrInAllCrss (long UsrCod);
|
|
|
|
|
void Tst_RemoveTestResultsMadeByUsrInCrs (long UsrCod,long CrsCod);
|
|
|
|
|
void Tst_RemoveCrsTestResults (long CrsCod);
|
2016-04-03 14:13:20 +02:00
|
|
|
|
|
|
|
|
|
void Tst_RemoveCrsTests (long CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#endif
|