mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-05 16:25:29 +02:00
Version19.12.1
This commit is contained in:
parent
b4bc3aa6ef
commit
f77322a716
|
@ -470,11 +470,11 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
||||||
En OpenSWAD:
|
En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.12 (2019-09-24)"
|
#define Log_PLATFORM_VERSION "SWAD 19.12.1 (2019-09-24)"
|
||||||
#define CSS_FILE "swad19.3.css"
|
#define CSS_FILE "swad19.3.css"
|
||||||
#define JS_FILE "swad18.130.2.js"
|
#define JS_FILE "swad18.130.2.js"
|
||||||
/*
|
/*
|
||||||
*
|
Version 19.12.1: Sep 24, 2019 View matches results. Not finished. (245987 lines)
|
||||||
Version 19.12: Sep 24, 2019 View matches results. Not finished. (245973 lines)
|
Version 19.12: Sep 24, 2019 View matches results. Not finished. (245973 lines)
|
||||||
1 change necessary in database:
|
1 change necessary in database:
|
||||||
ALTER TABLE mch_answers ADD COLUMN NumOpt TINYINT NOT NULL AFTER QstInd;
|
ALTER TABLE mch_answers ADD COLUMN NumOpt TINYINT NOT NULL AFTER QstInd;
|
||||||
|
|
61
swad_match.c
61
swad_match.c
|
@ -202,8 +202,9 @@ static void Mch_GetNumPlayers (struct Match *Match);
|
||||||
|
|
||||||
static void Mch_GetQstAnsFromDB (long MchCod,long UsrCod,unsigned QstInd,
|
static void Mch_GetQstAnsFromDB (long MchCod,long UsrCod,unsigned QstInd,
|
||||||
struct Mch_UsrAnswer *UsrAnswer);
|
struct Mch_UsrAnswer *UsrAnswer);
|
||||||
static void Mch_ComputeScore (struct Match *Match,unsigned NumQsts,long UsrCod,
|
static void Mch_ComputeScore (long MchCod,long UsrCod,
|
||||||
unsigned *NumQstsNotBlank,double *TotalScore);
|
unsigned *NumQsts,unsigned *NumQstsNotBlank,
|
||||||
|
double *TotalScore);
|
||||||
|
|
||||||
static unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd);
|
static unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd);
|
||||||
static unsigned Mch_GetNumUsrsWhoHaveAnswerMch (long MchCod);
|
static unsigned Mch_GetNumUsrsWhoHaveAnswerMch (long MchCod);
|
||||||
|
@ -2504,9 +2505,21 @@ void Mch_ReceiveQstAnsFromStd (void)
|
||||||
UsrAnswer.AnsInd);
|
UsrAnswer.AnsInd);
|
||||||
|
|
||||||
/***** Update student's match result *****/
|
/***** Update student's match result *****/
|
||||||
NumQsts = Gam_GetNumQstsGame (Match.GamCod);
|
Mch_ComputeScore (Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
Mch_ComputeScore (&Match,NumQsts,Gbl.Usrs.Me.UsrDat.UsrCod,
|
&NumQsts,&NumQstsNotBlank,&TotalScore);
|
||||||
&NumQstsNotBlank,&TotalScore);
|
|
||||||
|
DB_QueryINSERT ("can not debug", // TODO: Remove
|
||||||
|
"INSERT INTO debug"
|
||||||
|
" (DebugTime,Txt)"
|
||||||
|
" VALUES"
|
||||||
|
" (NOW(),'NumQsts = %u')",
|
||||||
|
NumQsts);
|
||||||
|
DB_QueryINSERT ("can not debug", // TODO: Remove
|
||||||
|
"INSERT INTO debug"
|
||||||
|
" (DebugTime,Txt)"
|
||||||
|
" VALUES"
|
||||||
|
" (NOW(),'NumQstsNotBlank = %u')",
|
||||||
|
NumQstsNotBlank);
|
||||||
|
|
||||||
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
Str_SetDecimalPointToUS (); // To print the floating point as a dot
|
||||||
if (DB_QueryCOUNT ("can not get if match result exists",
|
if (DB_QueryCOUNT ("can not get if match result exists",
|
||||||
|
@ -2551,8 +2564,9 @@ void Mch_ReceiveQstAnsFromStd (void)
|
||||||
/******************** Compute match score for a student **********************/
|
/******************** Compute match score for a student **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_ComputeScore (struct Match *Match,unsigned NumQsts,long UsrCod,
|
static void Mch_ComputeScore (long MchCod,long UsrCod,
|
||||||
unsigned *NumQstsNotBlank,double *TotalScore)
|
unsigned *NumQsts,unsigned *NumQstsNotBlank,
|
||||||
|
double *TotalScore)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -2566,22 +2580,23 @@ static void Mch_ComputeScore (struct Match *Match,unsigned NumQsts,long UsrCod,
|
||||||
bool AnswersUsr[Tst_MAX_OPTIONS_PER_QUESTION];
|
bool AnswersUsr[Tst_MAX_OPTIONS_PER_QUESTION];
|
||||||
|
|
||||||
/***** Get questions and answers of a match result *****/
|
/***** Get questions and answers of a match result *****/
|
||||||
NumQsts = (unsigned)
|
*NumQsts = (unsigned)
|
||||||
DB_QuerySELECT (&mysql_res,"can not get questions and answers"
|
DB_QuerySELECT (&mysql_res,"can not get questions and answers"
|
||||||
" of a match result",
|
" of a match result",
|
||||||
"SELECT gam_questions.QstCod," // row[0]
|
"SELECT gam_questions.QstCod," // row[0]
|
||||||
"gam_questions.QstInd," // row[1]
|
"gam_questions.QstInd," // row[1]
|
||||||
"mch_indexes.Indexes" // row[2]
|
"mch_indexes.Indexes" // row[2]
|
||||||
" FROM mch_matches,gam_questions,mch_indexes"
|
" FROM mch_matches,gam_questions,mch_indexes"
|
||||||
" WHERE mch_matches.MchCod=%ld"
|
" WHERE mch_matches.MchCod=%ld"
|
||||||
" AND mch_matches.GamCod=gam_questions.GamCod"
|
" AND mch_matches.GamCod=gam_questions.GamCod"
|
||||||
" AND mch_matches.MchCod=mch_indexes.MchCod"
|
" AND mch_matches.MchCod=mch_indexes.MchCod"
|
||||||
" AND gam_questions.QstInd=mch_indexes.QstInd"
|
" AND gam_questions.QstInd=mch_indexes.QstInd"
|
||||||
" ORDER BY gam_questions.QstInd");
|
" ORDER BY gam_questions.QstInd",
|
||||||
|
MchCod);
|
||||||
|
|
||||||
/***** For each question in match... *****/
|
/***** For each question in match... *****/
|
||||||
for (NumQst = 0, *NumQstsNotBlank = 0, *TotalScore = 0.0;
|
for (NumQst = 0, *NumQstsNotBlank = 0, *TotalScore = 0.0;
|
||||||
NumQst < NumQsts;
|
NumQst < *NumQsts;
|
||||||
NumQst++)
|
NumQst++)
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
@ -2591,16 +2606,16 @@ static void Mch_ComputeScore (struct Match *Match,unsigned NumQsts,long UsrCod,
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
|
|
||||||
/* Get question index (row[1]) */
|
/* Get question index (row[1]) */
|
||||||
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||||
QstInd = (unsigned) LongNum;
|
QstInd = (unsigned) LongNum;
|
||||||
|
|
||||||
/* Get indexes for this question (row[2]) */
|
/* Get indexes for this question (row[2]) */
|
||||||
Str_Copy (Gbl.Test.StrIndexesOneQst[NumQst],row[1],
|
Str_Copy (Gbl.Test.StrIndexesOneQst[NumQst],row[2],
|
||||||
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
||||||
|
|
||||||
/***** Get answers selected by user for this question *****/
|
/***** Get answers selected by user for this question *****/
|
||||||
Mch_GetQstAnsFromDB (Match->MchCod,UsrCod,QstInd,&UsrAnswer);
|
Mch_GetQstAnsFromDB (MchCod,UsrCod,QstInd,&UsrAnswer);
|
||||||
if (UsrAnswer.AnsInd >= 0) // AnsInd >= 0 ==> answer selected
|
if (UsrAnswer.AnsInd >= 0) // AnsInd >= 0 ==> answer selected
|
||||||
{
|
{
|
||||||
snprintf (Gbl.Test.StrAnswersOneQst[NumQst],Tst_MAX_BYTES_ANSWERS_ONE_QST + 1,
|
snprintf (Gbl.Test.StrAnswersOneQst[NumQst],Tst_MAX_BYTES_ANSWERS_ONE_QST + 1,
|
||||||
|
|
18
swad_test.c
18
swad_test.c
|
@ -4017,23 +4017,25 @@ void Tst_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES_ON
|
||||||
const char *Ptr;
|
const char *Ptr;
|
||||||
char StrOneIndex[10 + 1];
|
char StrOneIndex[10 + 1];
|
||||||
|
|
||||||
/***** Initialize to 0 *****/
|
|
||||||
for (NumOpt = 0, Ptr = StrIndexesOneQst;
|
|
||||||
NumOpt < Tst_MAX_OPTIONS_PER_QUESTION && *Ptr;
|
|
||||||
NumOpt++)
|
|
||||||
Indexes[NumOpt] = 0;
|
|
||||||
|
|
||||||
/***** Get indexes from string *****/
|
/***** Get indexes from string *****/
|
||||||
for (NumOpt = 0, Ptr = StrIndexesOneQst;
|
for (NumOpt = 0, Ptr = StrIndexesOneQst;
|
||||||
NumOpt < Tst_MAX_OPTIONS_PER_QUESTION && *Ptr;
|
NumOpt < Tst_MAX_OPTIONS_PER_QUESTION && *Ptr;
|
||||||
NumOpt++)
|
NumOpt++)
|
||||||
{
|
{
|
||||||
Par_GetNextStrUntilSeparParamMult (&Ptr,StrOneIndex,10);
|
Par_GetNextStrUntilSeparParamMult (&Ptr,StrOneIndex,10);
|
||||||
|
|
||||||
if (sscanf (StrOneIndex,"%u",&(Indexes[NumOpt])) != 1)
|
if (sscanf (StrOneIndex,"%u",&(Indexes[NumOpt])) != 1)
|
||||||
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
||||||
|
|
||||||
if (Indexes[NumOpt] >= Tst_MAX_OPTIONS_PER_QUESTION)
|
if (Indexes[NumOpt] >= Tst_MAX_OPTIONS_PER_QUESTION)
|
||||||
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***** Initialize remaining to 0 *****/
|
||||||
|
for (;
|
||||||
|
NumOpt < Tst_MAX_OPTIONS_PER_QUESTION;
|
||||||
|
NumOpt++)
|
||||||
|
Indexes[NumOpt] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user