mirror of https://github.com/acanas/swad-core.git
Version 21.46.3: Oct 27, 2021 Queries moved to module swad_test_database.
This commit is contained in:
parent
5ad59021f1
commit
352b95589c
49
swad_API.c
49
swad_API.c
|
@ -259,7 +259,6 @@ static int API_GetMyLanguage (struct soap *soap);
|
||||||
|
|
||||||
static int API_SendMessageToUsr (long OriginalMsgCod,long SenderUsrCod,long ReplyUsrCod,long RecipientUsrCod,bool NotifyByEmail,const char *Subject,const char *Content);
|
static int API_SendMessageToUsr (long OriginalMsgCod,long SenderUsrCod,long ReplyUsrCod,long RecipientUsrCod,bool NotifyByEmail,const char *Subject,const char *Content);
|
||||||
|
|
||||||
static int API_GetTstConfig (long CrsCod);
|
|
||||||
static unsigned API_GetNumTestQuestionsInCrs (long CrsCod);
|
static unsigned API_GetNumTestQuestionsInCrs (long CrsCod);
|
||||||
static int API_GetTstTags (struct soap *soap,
|
static int API_GetTstTags (struct soap *soap,
|
||||||
long CrsCod,struct swad__getTestsOutput *getTestsOut);
|
long CrsCod,struct swad__getTestsOutput *getTestsOut);
|
||||||
|
@ -3979,8 +3978,7 @@ int swad__getTestConfig (struct soap *soap,
|
||||||
getTestConfigOut->feedback[0] = '\0';
|
getTestConfigOut->feedback[0] = '\0';
|
||||||
|
|
||||||
/***** Get test configuration *****/
|
/***** Get test configuration *****/
|
||||||
if ((ReturnCode = API_GetTstConfig ((long) courseCode)) != SOAP_OK)
|
TstCfg_GetConfig ();
|
||||||
return ReturnCode;
|
|
||||||
getTestConfigOut->pluggable = (TstCfg_GetConfigPluggable () == TstCfg_PLUGGABLE_YES) ? 1 :
|
getTestConfigOut->pluggable = (TstCfg_GetConfigPluggable () == TstCfg_PLUGGABLE_YES) ? 1 :
|
||||||
0;
|
0;
|
||||||
getTestConfigOut->minQuestions = (int) TstCfg_GetConfigMin ();
|
getTestConfigOut->minQuestions = (int) TstCfg_GetConfigMin ();
|
||||||
|
@ -4014,46 +4012,6 @@ int swad__getTestConfig (struct soap *soap,
|
||||||
return SOAP_OK;
|
return SOAP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****** Get configuration of tests from database giving a course code ********/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static int API_GetTstConfig (long CrsCod)
|
|
||||||
{
|
|
||||||
MYSQL_RES *mysql_res;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
/***** Query database *****/
|
|
||||||
if (DB_QuerySELECT (&mysql_res,"can not get test configuration",
|
|
||||||
"SELECT Pluggable," // row[0]
|
|
||||||
"Min," // row[1]
|
|
||||||
"Def," // row[2]
|
|
||||||
"Max," // row[3]
|
|
||||||
"MinTimeNxtTstPerQst," // row[4]
|
|
||||||
"Visibility" // row[5]
|
|
||||||
" FROM tst_config"
|
|
||||||
" WHERE CrsCod=%ld",
|
|
||||||
CrsCod))
|
|
||||||
{
|
|
||||||
/***** Get minimun, default and maximum *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
TstCfg_GetConfigFromRow (row);
|
|
||||||
}
|
|
||||||
else // NumRows == 0
|
|
||||||
{
|
|
||||||
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
|
||||||
TstCfg_SetConfigMin (0);
|
|
||||||
TstCfg_SetConfigDef (0);
|
|
||||||
TstCfg_SetConfigMax (0);
|
|
||||||
TstCfg_SetConfigVisibility (TstVis_VISIBILITY_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
|
||||||
|
|
||||||
return SOAP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/** Get number of visible test questions from database giving a course code **/
|
/** Get number of visible test questions from database giving a course code **/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -4145,10 +4103,7 @@ int swad__getTests (struct soap *soap,
|
||||||
getTestsOut->questionTagsArray.__ptr = NULL;
|
getTestsOut->questionTagsArray.__ptr = NULL;
|
||||||
|
|
||||||
/***** Get test configuration *****/
|
/***** Get test configuration *****/
|
||||||
if ((ReturnCode = API_GetTstConfig ((long) courseCode)) != SOAP_OK)
|
if (TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests ())
|
||||||
return ReturnCode;
|
|
||||||
|
|
||||||
if (TstCfg_GetConfigPluggable () == TstCfg_PLUGGABLE_YES)
|
|
||||||
{
|
{
|
||||||
/***** Get tags *****/
|
/***** Get tags *****/
|
||||||
if ((ReturnCode = API_GetTstTags (soap,
|
if ((ReturnCode = API_GetTstTags (soap,
|
||||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.46.2 (2021-10-26)"
|
#define Log_PLATFORM_VERSION "SWAD 21.46.3 (2021-10-27)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.46.3: Oct 27, 2021 Queries moved to module swad_test_database. (321054 lines)
|
||||||
Version 21.46.2: Oct 26, 2021 Queries moved to module swad_test_database. (321062 lines)
|
Version 21.46.2: Oct 26, 2021 Queries moved to module swad_test_database. (321062 lines)
|
||||||
Version 21.46.1: Oct 26, 2021 Queries moved to module swad_test_database. (321058 lines)
|
Version 21.46.1: Oct 26, 2021 Queries moved to module swad_test_database. (321058 lines)
|
||||||
Version 21.46: Oct 26, 2021 New module swad_test_database for database queries related to self-assessment tests. (321036 lines)
|
Version 21.46: Oct 26, 2021 New module swad_test_database for database queries related to self-assessment tests. (321036 lines)
|
||||||
|
|
|
@ -4353,7 +4353,7 @@ unsigned Qst_GetNumCoursesWithQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t A
|
||||||
unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType)
|
unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType)
|
||||||
{
|
{
|
||||||
extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES];
|
extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES];
|
||||||
extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
extern const char *Tst_DB_Pluggable[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
||||||
|
|
||||||
/***** Get number of courses with test questions from database *****/
|
/***** Get number of courses with test questions from database *****/
|
||||||
switch (Scope)
|
switch (Scope)
|
||||||
|
@ -4367,7 +4367,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
"tst_config"
|
"tst_config"
|
||||||
" WHERE tst_questions.CrsCod=tst_config.CrsCod"
|
" WHERE tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4378,7 +4378,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
case HieLvl_CTY:
|
case HieLvl_CTY:
|
||||||
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -4398,7 +4398,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Cty.CtyCod,
|
Gbl.Hierarchy.Cty.CtyCod,
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4419,7 +4419,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Cty.CtyCod,
|
Gbl.Hierarchy.Cty.CtyCod,
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
case HieLvl_INS:
|
case HieLvl_INS:
|
||||||
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -4437,7 +4437,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Ins.InsCod,
|
Gbl.Hierarchy.Ins.InsCod,
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4456,7 +4456,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Ins.InsCod,
|
Gbl.Hierarchy.Ins.InsCod,
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
case HieLvl_CTR:
|
case HieLvl_CTR:
|
||||||
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -4472,7 +4472,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Ctr.CtrCod,
|
Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4489,7 +4489,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Ctr.CtrCod,
|
Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
case HieLvl_DEG:
|
case HieLvl_DEG:
|
||||||
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -4503,7 +4503,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Deg.DegCod,
|
Gbl.Hierarchy.Deg.DegCod,
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4518,7 +4518,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Deg.DegCod,
|
Gbl.Hierarchy.Deg.DegCod,
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
case HieLvl_CRS:
|
case HieLvl_CRS:
|
||||||
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
if (AnsType == Qst_ANS_UNKNOWN) // Any type
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
|
@ -4530,7 +4530,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
" AND tst_questions.CrsCod=tst_config.CrsCod"
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
|
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
DB_QueryCOUNT ("can not get number of courses with pluggable test questions",
|
||||||
|
@ -4543,7 +4543,7 @@ unsigned Qst_GetNumCoursesWithPluggableQuestions (HieLvl_Level_t Scope,Qst_Answe
|
||||||
" AND tst_config.pluggable='%s'",
|
" AND tst_config.pluggable='%s'",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
Qst_DB_StrAnswerTypes[AnsType],
|
Qst_DB_StrAnswerTypes[AnsType],
|
||||||
TstCfg_PluggableDB[TstCfg_PLUGGABLE_YES]);
|
Tst_DB_Pluggable[TstCfg_PLUGGABLE_YES]);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,25 +27,22 @@
|
||||||
|
|
||||||
#include <string.h> // For string functions
|
#include <string.h> // For string functions
|
||||||
|
|
||||||
|
#include "swad_alert.h"
|
||||||
|
#include "swad_box.h"
|
||||||
#include "swad_database.h"
|
#include "swad_database.h"
|
||||||
#include "swad_form.h"
|
#include "swad_form.h"
|
||||||
#include "swad_global.h"
|
#include "swad_global.h"
|
||||||
|
#include "swad_parameter.h"
|
||||||
|
#include "swad_question.h"
|
||||||
#include "swad_tag_database.h"
|
#include "swad_tag_database.h"
|
||||||
#include "swad_test.h"
|
#include "swad_test.h"
|
||||||
#include "swad_test_config.h"
|
#include "swad_test_config.h"
|
||||||
#include "swad_test_visibility.h"
|
#include "swad_test_database.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public constants ******************************/
|
/***************************** Public constants ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE] =
|
|
||||||
{
|
|
||||||
[TstCfg_PLUGGABLE_UNKNOWN] = "unknown",
|
|
||||||
[TstCfg_PLUGGABLE_NO ] = "N",
|
|
||||||
[TstCfg_PLUGGABLE_YES ] = "Y",
|
|
||||||
};
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************************** Private constants ******************************/
|
/**************************** Private constants ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -84,6 +81,8 @@ static void TstCfg_ShowFormConfig (void);
|
||||||
static void TstCfg_PutInputFieldNumQsts (const char *Field,const char *Label,
|
static void TstCfg_PutInputFieldNumQsts (const char *Field,const char *Label,
|
||||||
unsigned Value);
|
unsigned Value);
|
||||||
|
|
||||||
|
static void TstCfg_GetConfigFromRow (MYSQL_ROW row);
|
||||||
|
|
||||||
static TstCfg_Pluggable_t TstCfg_GetPluggableFromForm (void);
|
static TstCfg_Pluggable_t TstCfg_GetPluggableFromForm (void);
|
||||||
static void TstCfg_CheckAndCorrectMinDefMax (void);
|
static void TstCfg_CheckAndCorrectMinDefMax (void);
|
||||||
|
|
||||||
|
@ -111,19 +110,14 @@ void TstCfg_CheckAndShowFormConfig (void)
|
||||||
|
|
||||||
bool TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests (void)
|
bool TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests (void)
|
||||||
{
|
{
|
||||||
extern const char *TstCfg_PluggableDB[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
extern const char *Tst_DB_Pluggable[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned NumRows;
|
unsigned NumRows;
|
||||||
TstCfg_Pluggable_t Pluggable;
|
TstCfg_Pluggable_t Pluggable;
|
||||||
|
|
||||||
/***** Get pluggability of tests for current course from database *****/
|
/***** Get pluggability of tests for current course from database *****/
|
||||||
NumRows = (unsigned)
|
NumRows = Tst_DB_GetPluggableFromConfig (&mysql_res);
|
||||||
DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
|
||||||
"SELECT Pluggable" // row[0]
|
|
||||||
" FROM tst_config"
|
|
||||||
" WHERE CrsCod=%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
|
|
||||||
if (NumRows == 0)
|
if (NumRows == 0)
|
||||||
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
||||||
|
@ -136,7 +130,7 @@ bool TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests (void)
|
||||||
for (Pluggable = TstCfg_PLUGGABLE_NO;
|
for (Pluggable = TstCfg_PLUGGABLE_NO;
|
||||||
Pluggable <= TstCfg_PLUGGABLE_YES;
|
Pluggable <= TstCfg_PLUGGABLE_YES;
|
||||||
Pluggable++)
|
Pluggable++)
|
||||||
if (!strcmp (row[0],TstCfg_PluggableDB[Pluggable]))
|
if (!strcmp (row[0],Tst_DB_Pluggable[Pluggable]))
|
||||||
{
|
{
|
||||||
TstCfg_SetConfigPluggable (Pluggable);
|
TstCfg_SetConfigPluggable (Pluggable);
|
||||||
break;
|
break;
|
||||||
|
@ -317,34 +311,21 @@ void TstCfg_GetConfig (void)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned long NumRows;
|
|
||||||
|
|
||||||
/***** Get configuration of test for current course from database *****/
|
/***** Get configuration of test for current course from database *****/
|
||||||
NumRows = DB_QuerySELECT (&mysql_res,"can not get configuration of test",
|
if (Tst_DB_GetConfig (&mysql_res,Gbl.Hierarchy.Crs.CrsCod))
|
||||||
"SELECT Pluggable," // row[0]
|
{
|
||||||
"Min," // row[1]
|
row = mysql_fetch_row (mysql_res);
|
||||||
"Def," // row[2]
|
TstCfg_GetConfigFromRow (row);
|
||||||
"Max," // row[3]
|
}
|
||||||
"MinTimeNxtTstPerQst," // row[4]
|
else
|
||||||
"Visibility" // row[5]
|
|
||||||
" FROM tst_config"
|
|
||||||
" WHERE CrsCod=%ld",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod);
|
|
||||||
|
|
||||||
TstCfg_SetConfigMinTimeNxtTstPerQst (0UL);
|
|
||||||
TstCfg_SetConfigVisibility (TstVis_VISIBILITY_DEFAULT);
|
|
||||||
if (NumRows == 0)
|
|
||||||
{
|
{
|
||||||
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
TstCfg_SetConfigPluggable (TstCfg_PLUGGABLE_UNKNOWN);
|
||||||
TstCfg_SetConfigMin (TstCfg_DEFAULT_MIN_QUESTIONS);
|
TstCfg_SetConfigMin (TstCfg_DEFAULT_MIN_QUESTIONS);
|
||||||
TstCfg_SetConfigDef (TstCfg_DEFAULT_DEF_QUESTIONS);
|
TstCfg_SetConfigDef (TstCfg_DEFAULT_DEF_QUESTIONS);
|
||||||
TstCfg_SetConfigMax (TstCfg_DEFAULT_MAX_QUESTIONS);
|
TstCfg_SetConfigMax (TstCfg_DEFAULT_MAX_QUESTIONS);
|
||||||
}
|
TstCfg_SetConfigMinTimeNxtTstPerQst (0UL);
|
||||||
else // NumRows == 1
|
TstCfg_SetConfigVisibility (TstVis_VISIBILITY_DEFAULT);
|
||||||
{
|
|
||||||
/***** Get minimun, default and maximum *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
TstCfg_GetConfigFromRow (row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -355,8 +336,9 @@ void TstCfg_GetConfig (void)
|
||||||
/************ Get configuration values from a database table row *************/
|
/************ Get configuration values from a database table row *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void TstCfg_GetConfigFromRow (MYSQL_ROW row)
|
static void TstCfg_GetConfigFromRow (MYSQL_ROW row)
|
||||||
{
|
{
|
||||||
|
extern const char *Tst_DB_Pluggable[TstCfg_NUM_OPTIONS_PLUGGABLE];
|
||||||
int IntNum;
|
int IntNum;
|
||||||
long LongNum;
|
long LongNum;
|
||||||
TstCfg_Pluggable_t Pluggable;
|
TstCfg_Pluggable_t Pluggable;
|
||||||
|
@ -366,7 +348,7 @@ void TstCfg_GetConfigFromRow (MYSQL_ROW row)
|
||||||
for (Pluggable = TstCfg_PLUGGABLE_NO;
|
for (Pluggable = TstCfg_PLUGGABLE_NO;
|
||||||
Pluggable <= TstCfg_PLUGGABLE_YES;
|
Pluggable <= TstCfg_PLUGGABLE_YES;
|
||||||
Pluggable++)
|
Pluggable++)
|
||||||
if (!strcmp (row[0],TstCfg_PluggableDB[Pluggable]))
|
if (!strcmp (row[0],Tst_DB_Pluggable[Pluggable]))
|
||||||
{
|
{
|
||||||
TstCfg_SetConfigPluggable (Pluggable);
|
TstCfg_SetConfigPluggable (Pluggable);
|
||||||
break;
|
break;
|
||||||
|
@ -375,19 +357,19 @@ void TstCfg_GetConfigFromRow (MYSQL_ROW row)
|
||||||
/***** Get number of questions *****/
|
/***** Get number of questions *****/
|
||||||
if (sscanf (row[1],"%d",&IntNum) == 1)
|
if (sscanf (row[1],"%d",&IntNum) == 1)
|
||||||
TstCfg_SetConfigMin ((IntNum < 1) ? 1 :
|
TstCfg_SetConfigMin ((IntNum < 1) ? 1 :
|
||||||
(unsigned) IntNum);
|
(unsigned) IntNum);
|
||||||
else
|
else
|
||||||
TstCfg_SetConfigMin (TstCfg_DEFAULT_MIN_QUESTIONS);
|
TstCfg_SetConfigMin (TstCfg_DEFAULT_MIN_QUESTIONS);
|
||||||
|
|
||||||
if (sscanf (row[2],"%d",&IntNum) == 1)
|
if (sscanf (row[2],"%d",&IntNum) == 1)
|
||||||
TstCfg_SetConfigDef ((IntNum < 1) ? 1 :
|
TstCfg_SetConfigDef ((IntNum < 1) ? 1 :
|
||||||
(unsigned) IntNum);
|
(unsigned) IntNum);
|
||||||
else
|
else
|
||||||
TstCfg_SetConfigDef (TstCfg_DEFAULT_DEF_QUESTIONS);
|
TstCfg_SetConfigDef (TstCfg_DEFAULT_DEF_QUESTIONS);
|
||||||
|
|
||||||
if (sscanf (row[3],"%d",&IntNum) == 1)
|
if (sscanf (row[3],"%d",&IntNum) == 1)
|
||||||
TstCfg_SetConfigMax ((IntNum < 1) ? 1 :
|
TstCfg_SetConfigMax ((IntNum < 1) ? 1 :
|
||||||
(unsigned) IntNum);
|
(unsigned) IntNum);
|
||||||
else
|
else
|
||||||
TstCfg_SetConfigMax (TstCfg_DEFAULT_MAX_QUESTIONS);
|
TstCfg_SetConfigMax (TstCfg_DEFAULT_MAX_QUESTIONS);
|
||||||
|
|
||||||
|
@ -397,7 +379,7 @@ void TstCfg_GetConfigFromRow (MYSQL_ROW row)
|
||||||
/***** Get minimum time between consecutive tests, per question (row[4]) *****/
|
/***** Get minimum time between consecutive tests, per question (row[4]) *****/
|
||||||
if (sscanf (row[4],"%ld",&LongNum) == 1)
|
if (sscanf (row[4],"%ld",&LongNum) == 1)
|
||||||
TstCfg_SetConfigMinTimeNxtTstPerQst ((LongNum < 1L) ? 0UL :
|
TstCfg_SetConfigMinTimeNxtTstPerQst ((LongNum < 1L) ? 0UL :
|
||||||
(unsigned long) LongNum);
|
(unsigned long) LongNum);
|
||||||
else
|
else
|
||||||
TstCfg_SetConfigMinTimeNxtTstPerQst (0UL);
|
TstCfg_SetConfigMinTimeNxtTstPerQst (0UL);
|
||||||
|
|
||||||
|
@ -451,20 +433,7 @@ void TstCfg_ReceiveConfigTst (void)
|
||||||
TstCfg_SetConfigVisibility (TstVis_GetVisibilityFromForm ());
|
TstCfg_SetConfigVisibility (TstVis_GetVisibilityFromForm ());
|
||||||
|
|
||||||
/***** Update database *****/
|
/***** Update database *****/
|
||||||
DB_QueryREPLACE ("can not save configuration of tests",
|
Tst_DB_SaveConfig ();
|
||||||
"REPLACE INTO tst_config"
|
|
||||||
" (CrsCod,Pluggable,Min,Def,Max,"
|
|
||||||
"MinTimeNxtTstPerQst,Visibility)"
|
|
||||||
" VALUES"
|
|
||||||
" (%ld,'%s',%u,%u,%u,"
|
|
||||||
"'%lu',%u)",
|
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
|
||||||
TstCfg_PluggableDB[TstCfg_GetConfigPluggable ()],
|
|
||||||
TstCfg_GetConfigMin (),
|
|
||||||
TstCfg_GetConfigDef (),
|
|
||||||
TstCfg_GetConfigMax (),
|
|
||||||
TstCfg_GetConfigMinTimeNxtTstPerQst (),
|
|
||||||
TstCfg_GetConfigVisibility ());
|
|
||||||
|
|
||||||
/***** Show confirmation message *****/
|
/***** Show confirmation message *****/
|
||||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_test_configuration_has_been_updated);
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_test_configuration_has_been_updated);
|
||||||
|
|
|
@ -61,7 +61,6 @@ bool TstCfg_CheckIfPluggableIsUnknownAndCrsHasTests (void);
|
||||||
|
|
||||||
void TstCfg_GetConfig (void);
|
void TstCfg_GetConfig (void);
|
||||||
|
|
||||||
void TstCfg_GetConfigFromRow (MYSQL_ROW row);
|
|
||||||
void TstCfg_ReceiveConfigTst (void);
|
void TstCfg_ReceiveConfigTst (void);
|
||||||
|
|
||||||
void TstCfg_SetConfigPluggable (TstCfg_Pluggable_t Pluggable);
|
void TstCfg_SetConfigPluggable (TstCfg_Pluggable_t Pluggable);
|
||||||
|
|
|
@ -67,6 +67,13 @@
|
||||||
/***************************** Public constants ******************************/
|
/***************************** Public constants ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
const char *Tst_DB_Pluggable[TstCfg_NUM_OPTIONS_PLUGGABLE] =
|
||||||
|
{
|
||||||
|
[TstCfg_PLUGGABLE_UNKNOWN] = "unknown",
|
||||||
|
[TstCfg_PLUGGABLE_NO ] = "N",
|
||||||
|
[TstCfg_PLUGGABLE_YES ] = "Y",
|
||||||
|
};
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************************** Private constants ******************************/
|
/**************************** Private constants ******************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -271,6 +278,61 @@ unsigned Tst_DB_GetQuestionsForNewTest (MYSQL_RES **mysql_res,
|
||||||
Query);
|
Query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** Save configuration of test for current course ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void Tst_DB_SaveConfig (void)
|
||||||
|
{
|
||||||
|
DB_QueryREPLACE ("can not save configuration of tests",
|
||||||
|
"REPLACE INTO tst_config"
|
||||||
|
" (CrsCod,Pluggable,Min,Def,Max,"
|
||||||
|
"MinTimeNxtTstPerQst,Visibility)"
|
||||||
|
" VALUES"
|
||||||
|
" (%ld,'%s',%u,%u,%u,"
|
||||||
|
"'%lu',%u)",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
|
Tst_DB_Pluggable[TstCfg_GetConfigPluggable ()],
|
||||||
|
TstCfg_GetConfigMin (),
|
||||||
|
TstCfg_GetConfigDef (),
|
||||||
|
TstCfg_GetConfigMax (),
|
||||||
|
TstCfg_GetConfigMinTimeNxtTstPerQst (),
|
||||||
|
TstCfg_GetConfigVisibility ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Get configuration of test in a course *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Tst_DB_GetConfig (MYSQL_RES **mysql_res,long CrsCod)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get configuration of test",
|
||||||
|
"SELECT Pluggable," // row[0]
|
||||||
|
"Min," // row[1]
|
||||||
|
"Def," // row[2]
|
||||||
|
"Max," // row[3]
|
||||||
|
"MinTimeNxtTstPerQst," // row[4]
|
||||||
|
"Visibility" // row[5]
|
||||||
|
" FROM tst_config"
|
||||||
|
" WHERE CrsCod=%ld",
|
||||||
|
CrsCod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********* Get pluggability of tests for current course from database ********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Tst_DB_GetPluggableFromConfig (MYSQL_RES **mysql_res)
|
||||||
|
{
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get configuration of test",
|
||||||
|
"SELECT Pluggable" // row[0]
|
||||||
|
" FROM tst_config"
|
||||||
|
" WHERE CrsCod=%ld",
|
||||||
|
Gbl.Hierarchy.Crs.CrsCod);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Remove test configuration in a course ********************/
|
/****************** Remove test configuration in a course ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -49,14 +49,22 @@
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
//----------------------- User's settings in course ---------------------------
|
||||||
void Tst_DB_IncreaseNumMyPrints (void);
|
void Tst_DB_IncreaseNumMyPrints (void);
|
||||||
void Tst_DB_UpdateLastAccTst (unsigned NumQsts);
|
void Tst_DB_UpdateLastAccTst (unsigned NumQsts);
|
||||||
|
|
||||||
unsigned Tst_DB_GetDateNextTstAllowed (MYSQL_RES **mysql_res);
|
unsigned Tst_DB_GetDateNextTstAllowed (MYSQL_RES **mysql_res);
|
||||||
unsigned Tst_DB_GetNumPrintsGeneratedByMe (MYSQL_RES **mysql_res);
|
unsigned Tst_DB_GetNumPrintsGeneratedByMe (MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
|
//---------------------------- Test questions ---------------------------------
|
||||||
unsigned Tst_DB_GetQuestionsForNewTest (MYSQL_RES **mysql_res,
|
unsigned Tst_DB_GetQuestionsForNewTest (MYSQL_RES **mysql_res,
|
||||||
const struct Qst_Questions *Questions);
|
const struct Qst_Questions *Questions);
|
||||||
|
|
||||||
|
//--------------------------- Test configuration ------------------------------
|
||||||
|
void Tst_DB_SaveConfig (void);
|
||||||
|
unsigned Tst_DB_GetConfig (MYSQL_RES **mysql_res,long CrsCod);
|
||||||
|
unsigned Tst_DB_GetPluggableFromConfig (MYSQL_RES **mysql_res);
|
||||||
|
|
||||||
void Tst_DB_RemoveTstConfig (long CrsCod);
|
void Tst_DB_RemoveTstConfig (long CrsCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue