swad-core/swad_test.h

191 lines
6.8 KiB
C
Raw Normal View History

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.
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
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 ***********************************/
/*****************************************************************************/
2020-04-22 03:15:04 +02:00
#include "swad_exam.h"
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-05-07 18:33:26 +02:00
#include "swad_test_print.h"
#include "swad_test_type.h"
2017-09-06 23:17:52 +02:00
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Public constants ******************************/
/*****************************************************************************/
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
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/******************************* Public types ********************************/
/*****************************************************************************/
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-26 21:39:44 +01:00
struct Tst_Test
{
2020-05-17 17:11:04 +02:00
struct Tag_Tags Tags; // Selected tags
2020-03-26 21:39:44 +01:00
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
2020-04-27 14:20:21 +02:00
Tst_SELECT_QUESTIONS_FOR_EXAM, // Selecting test questions for a set of questions in an exam
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-04-16 21:03:22 +02:00
void Tst_ReceiveTestDraft (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-06-17 02:31:42 +02:00
void Tst_ListQuestionForEdition (struct Tst_Question *Question,
2020-04-27 16:00:53 +02:00
unsigned QstInd,bool QuestionExists,
const char *Anchor);
2020-06-17 20:20:16 +02:00
void Tst_WriteNumQst (unsigned NumQst,const char *Class);
void Tst_WriteAnswerType (Tst_AnswerType_t AnswerType,const char *Class);
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-27 14:20:21 +02:00
void Tst_RequestSelectTestsForSet (struct Exa_Exams *Exams);
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-27 14:20:21 +02:00
void Tst_ListQuestionsToSelectForSet (struct Exa_Exams *Exams);
2020-04-22 03:15:04 +02:00
void Tst_ListQuestionsToSelectForGame (struct Gam_Games *Games);
2020-05-07 18:33:26 +02:00
2020-05-13 00:28:32 +02:00
void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
bool Shuffle);
2020-05-07 18:33:26 +02:00
2020-10-14 00:59:24 +02:00
void Tst_PutParamsEditQst (void *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-06-17 02:31:42 +02:00
void Tst_ChangeFormatAnswersText (struct Tst_Question *Question);
void Tst_ChangeFormatAnswersFeedback (struct Tst_Question *Question);
2020-06-17 20:20:16 +02:00
void Tst_WriteAnswersBank (struct Tst_Question *Question,
const char *ClassTxt,
const char *ClassFeedback);
2014-12-01 23:55:08 +01:00
void Tst_WriteAnsTF (char AnsTF);
2020-05-09 23:12:53 +02:00
void Tst_WriteParamQstCod (unsigned NumQst,long QstCod);
2020-03-19 20:57:54 +01:00
void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question);
2017-09-06 15:03:43 +02:00
unsigned 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);
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
2020-04-27 14:20:21 +02:00
unsigned Tst_CountNumQuestionsInList (const char *ListQuestions);
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-05-13 00:28:32 +02:00
Tst_AnswerType_t Tst_GetQstAnswerTypeFromDB (long QstCod);
2020-04-04 19:20:50 +02:00
bool Tst_GetQstDataFromDB (struct Tst_Question *Question);
Tst_AnswerType_t Tst_ConvertFromStrAnsTypDBToAnsTyp (const char *StrAnsTypeDB);
2014-12-01 23:55:08 +01:00
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-04-27 19:37:49 +02:00
long Tst_GetParamQstCod (void);
2020-04-24 02:49:51 +02:00
void Tst_PutParamQstCod (void *QstCod);
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-05-09 01:37:00 +02:00
void Tst_UpdateQstScoreInDB (struct TstPrn_PrintedQuestion *PrintedQuestion);
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