mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-02 06:45:30 +02:00
Version18.132.2
This commit is contained in:
parent
ad554839d6
commit
bcef02f59f
|
@ -2674,6 +2674,10 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
line-height:normal;
|
line-height:normal;
|
||||||
white-space:nowrap;
|
white-space:nowrap;
|
||||||
}
|
}
|
||||||
|
.GAM_PLAY_STD_ANSWER_SELECTED
|
||||||
|
{
|
||||||
|
box-shadow: 0px 0px 24px 12px rgba(0,180,0,1);
|
||||||
|
}
|
||||||
.GAM_PLAY_TCH_BUTTON:hover, .GAM_PLAY_STD_BUTTON:hover
|
.GAM_PLAY_TCH_BUTTON:hover, .GAM_PLAY_STD_BUTTON:hover
|
||||||
{
|
{
|
||||||
background-image:-webkit-linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.2)); /* Safari */
|
background-image:-webkit-linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.2)); /* Safari */
|
|
@ -458,10 +458,11 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 18.132.1 (2019-07-15)"
|
#define Log_PLATFORM_VERSION "SWAD 18.132.2 (2019-07-15)"
|
||||||
#define CSS_FILE "swad18.131.css"
|
#define CSS_FILE "swad18.132.2.css"
|
||||||
#define JS_FILE "swad18.130.2.js"
|
#define JS_FILE "swad18.130.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 18.132.2: Jul 15, 2019 Reception of student answer to a match question. Not finished. (243456 lines)
|
||||||
Version 18.132.1: Jul 15, 2019 Reception of student answer to a match question. Not finished. (243405 lines)
|
Version 18.132.1: Jul 15, 2019 Reception of student answer to a match question. Not finished. (243405 lines)
|
||||||
2 changes necessary in database:
|
2 changes necessary in database:
|
||||||
DROP TABLE IF EXISTS gam_answers;
|
DROP TABLE IF EXISTS gam_answers;
|
||||||
|
|
79
swad_game.c
79
swad_game.c
|
@ -191,6 +191,7 @@ static void Gam_PlayGameShowQuestionAndAnswers (struct Match *Match);
|
||||||
static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon);
|
static void Gam_PutBigButton (long MchCod,const char *Txt,const char *Icon);
|
||||||
|
|
||||||
static void Gam_ShowMatchStatusForStd (struct Match *Match);
|
static void Gam_ShowMatchStatusForStd (struct Match *Match);
|
||||||
|
static int Gam_GetQstAnsFromDB (long MchCod,unsigned QstInd);
|
||||||
|
|
||||||
static unsigned Gam_GetNumUsrsWhoHaveAnsweredGame (long GamCod);
|
static unsigned Gam_GetNumUsrsWhoHaveAnsweredGame (long GamCod);
|
||||||
|
|
||||||
|
@ -3636,6 +3637,7 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
bool Shuffle = false; // TODO: Read shuffle from question
|
bool Shuffle = false; // TODO: Read shuffle from question
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
int StdAnsInd;
|
||||||
unsigned NumOptions;
|
unsigned NumOptions;
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
unsigned Index;
|
unsigned Index;
|
||||||
|
@ -3674,13 +3676,15 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
{
|
{
|
||||||
if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod))
|
if (Tst_CheckIfQuestionIsValidForGame (Match->Status.QstCod))
|
||||||
{
|
{
|
||||||
/***** Start table *****/
|
/***** Get student's answer to this question
|
||||||
Tbl_StartTableWide (8);
|
(<0 ==> no answer) *****/
|
||||||
|
StdAnsInd = Gam_GetQstAnsFromDB (Match->MchCod,
|
||||||
|
Match->Status.QstInd);
|
||||||
|
|
||||||
/***** Write answers *****/
|
/***** Get number of options in this question *****/
|
||||||
NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod);
|
NumOptions = Tst_GetNumAnswersQst (Match->Status.QstCod);
|
||||||
|
|
||||||
/***** Get answers of a question from database *****/
|
/***** Get answers of question from database *****/
|
||||||
Shuffle = false;
|
Shuffle = false;
|
||||||
NumOptions = Tst_GetAnswersQst (Match->Status.QstCod,&mysql_res,Shuffle);
|
NumOptions = Tst_GetAnswersQst (Match->Status.QstCod,&mysql_res,Shuffle);
|
||||||
/*
|
/*
|
||||||
|
@ -3691,6 +3695,9 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
row[4] Correct
|
row[4] Correct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/***** Start table *****/
|
||||||
|
Tbl_StartTableWide (8);
|
||||||
|
|
||||||
for (NumOpt = 0;
|
for (NumOpt = 0;
|
||||||
NumOpt < NumOptions;
|
NumOpt < NumOptions;
|
||||||
NumOpt++)
|
NumOpt++)
|
||||||
|
@ -3725,7 +3732,10 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
|
Gam_PutParamQstInd (Match->Status.QstInd); // Current question index shown
|
||||||
Gam_PutParamAnswer (Index); // Index for this option
|
Gam_PutParamAnswer (Index); // Index for this option
|
||||||
fprintf (Gbl.F.Out,"<button type=\"submit\""
|
fprintf (Gbl.F.Out,"<button type=\"submit\""
|
||||||
" class=\"GAM_PLAY_STD_BUTTON BT_%c\">"
|
" class=\"");
|
||||||
|
if (StdAnsInd == (int) NumOpt) // Student's answer
|
||||||
|
fprintf (Gbl.F.Out,"GAM_PLAY_STD_ANSWER_SELECTED ");
|
||||||
|
fprintf (Gbl.F.Out,"GAM_PLAY_STD_BUTTON BT_%c\">"
|
||||||
"%c"
|
"%c"
|
||||||
"</button>",
|
"</button>",
|
||||||
'A' + (char) NumOpt,
|
'A' + (char) NumOpt,
|
||||||
|
@ -3752,6 +3762,38 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**** Receive previous question answer in a match question from database *****/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static int Gam_GetQstAnsFromDB (long MchCod,unsigned QstInd)
|
||||||
|
{
|
||||||
|
MYSQL_RES *mysql_res;
|
||||||
|
MYSQL_ROW row;
|
||||||
|
unsigned NumRows;
|
||||||
|
int StdAnsInd = -1; // <0 ==> no answer selected
|
||||||
|
|
||||||
|
/***** Get student's answer *****/
|
||||||
|
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get student's answer to a match question",
|
||||||
|
"SELECT AnsInd FROM gam_answers"
|
||||||
|
" WHERE MchCod=%ld AND UsrCod=%ld AND QstInd=%u",
|
||||||
|
MchCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
QstInd);
|
||||||
|
if (NumRows) // Answer found...
|
||||||
|
{
|
||||||
|
/***** Get answer index *****/
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
if (sscanf (row[0],"%d",&StdAnsInd) != 1)
|
||||||
|
Lay_ShowErrorAndExit ("Error when getting student's answer to a match question.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Free structure that stores the query result *****/
|
||||||
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
|
|
||||||
|
return StdAnsInd;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********* Receive question answer from student when playing a match *********/
|
/********* Receive question answer from student when playing a match *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3760,7 +3802,8 @@ void Gam_ReceiveQstAnsFromStd (void)
|
||||||
{
|
{
|
||||||
struct Match Match;
|
struct Match Match;
|
||||||
unsigned QstInd;
|
unsigned QstInd;
|
||||||
unsigned AnsInd;
|
unsigned StdAnsInd;
|
||||||
|
int PreviousStdAnsInd;
|
||||||
|
|
||||||
/***** Get match code *****/
|
/***** Get match code *****/
|
||||||
if ((Match.MchCod = Gam_GetParamMatchCod ()) == -1L)
|
if ((Match.MchCod = Gam_GetParamMatchCod ()) == -1L)
|
||||||
|
@ -3786,15 +3829,25 @@ void Gam_ReceiveQstAnsFromStd (void)
|
||||||
| d | 3 |
|
| d | 3 |
|
||||||
| ... | ... |
|
| ... | ... |
|
||||||
+--------+-------------*/
|
+--------+-------------*/
|
||||||
AnsInd = Gam_GetParamAnswer ();
|
StdAnsInd = Gam_GetParamAnswer ();
|
||||||
|
|
||||||
|
/***** Get previous student's answer to this question
|
||||||
|
(<0 ==> no answer) *****/
|
||||||
|
PreviousStdAnsInd = Gam_GetQstAnsFromDB (Match.MchCod,QstInd);
|
||||||
|
|
||||||
/***** Store student's answer *****/
|
/***** Store student's answer *****/
|
||||||
DB_QueryUPDATE ("can not register your answer to the game",
|
if (PreviousStdAnsInd == (int) StdAnsInd)
|
||||||
"REPLACE gam_answers"
|
DB_QueryDELETE ("can not register your answer to the match question",
|
||||||
" (MchCod,UsrCod,QstInd,AnsInd)"
|
"DELETE FROM gam_answers"
|
||||||
" VALUES"
|
" WHERE MchCod=%ld AND UsrCod=%ld AND QstInd=%u",
|
||||||
" (%ld,%ld,%u,%u)",
|
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,QstInd);
|
||||||
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,QstInd,AnsInd);
|
else
|
||||||
|
DB_QueryREPLACE ("can not register your answer to the match question",
|
||||||
|
"REPLACE gam_answers"
|
||||||
|
" (MchCod,UsrCod,QstInd,AnsInd)"
|
||||||
|
" VALUES"
|
||||||
|
" (%ld,%ld,%u,%u)",
|
||||||
|
Match.MchCod,Gbl.Usrs.Me.UsrDat.UsrCod,QstInd,StdAnsInd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user