mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-28 11:25:43 +02:00
Version19.3
This commit is contained in:
parent
49c49e9d4b
commit
9164c0c8a4
|
@ -2705,7 +2705,13 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
opacity:0.1;
|
opacity:0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.MATCH_TCH_QST
|
.MATCH_TCH_STEM
|
||||||
|
{
|
||||||
|
color:#202020;
|
||||||
|
font-size:24pt;
|
||||||
|
padding-bottom:12pt;
|
||||||
|
}
|
||||||
|
.MATCH_TCH_ANS
|
||||||
{
|
{
|
||||||
color:#202020;
|
color:#202020;
|
||||||
font-size:24pt;
|
font-size:24pt;
|
||||||
|
@ -2728,6 +2734,13 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
font-size:24pt;
|
font-size:24pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MATCH_TCH_BUTTON_TD
|
||||||
|
{
|
||||||
|
box-sizing:border-box;
|
||||||
|
width:84px;
|
||||||
|
text-align:center;
|
||||||
|
vertical-align:middle;
|
||||||
|
}
|
||||||
.MATCH_TCH_BUTTON
|
.MATCH_TCH_BUTTON
|
||||||
{
|
{
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
|
@ -2770,6 +2783,34 @@ a:hover img.CENTRE_PHOTO_SHOW
|
||||||
box-shadow: 0px 0px 18px 12px rgba(0,128,0,1);
|
box-shadow: 0px 0px 18px 12px rgba(0,128,0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.MATCH_RESULT
|
||||||
|
{
|
||||||
|
padding:10px 0;
|
||||||
|
color:#606060;
|
||||||
|
font-size:16pt;
|
||||||
|
text-align:left;
|
||||||
|
vertical-align:top;
|
||||||
|
}
|
||||||
|
.MATCH_RES_TR
|
||||||
|
{
|
||||||
|
height:24px;
|
||||||
|
}
|
||||||
|
.MATCH_RES_CORRECT
|
||||||
|
{
|
||||||
|
width:1%;
|
||||||
|
background:green;
|
||||||
|
}
|
||||||
|
.MATCH_RES_WRONG
|
||||||
|
{
|
||||||
|
width:1%;
|
||||||
|
background:red;
|
||||||
|
}
|
||||||
|
.MATCH_RES_VOID
|
||||||
|
{
|
||||||
|
width:1%;
|
||||||
|
background:white;
|
||||||
|
}
|
||||||
|
|
||||||
.BT_A {background-color:#e21c3d; border-color:#a9152d;} /* red */
|
.BT_A {background-color:#e21c3d; border-color:#a9152d;} /* red */
|
||||||
.BT_B {background-color:#1369ce; border-color:#0e519c;} /* blue */
|
.BT_B {background-color:#1369ce; border-color:#0e519c;} /* blue */
|
||||||
.BT_C {background-color:#d89e00; border-color:#a27600;} /* yellow */
|
.BT_C {background-color:#d89e00; border-color:#a27600;} /* yellow */
|
|
@ -640,7 +640,7 @@ CREATE TABLE IF NOT EXISTS gam_matches (
|
||||||
QstCod INT NOT NULL DEFAULT -1,
|
QstCod INT NOT NULL DEFAULT -1,
|
||||||
QstStartTime DATETIME NOT NULL,
|
QstStartTime DATETIME NOT NULL,
|
||||||
ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',
|
ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',
|
||||||
Showing ENUM('wording','answers','results') NOT NULL DEFAULT 'wording',
|
Showing ENUM('stem','answers','results') NOT NULL DEFAULT 'stem',
|
||||||
UNIQUE INDEX(MchCod),
|
UNIQUE INDEX(MchCod),
|
||||||
INDEX(GamCod));
|
INDEX(GamCod));
|
||||||
--
|
--
|
||||||
|
|
|
@ -460,10 +460,15 @@ En OpenSWAD:
|
||||||
ps2pdf source.ps destination.pdf
|
ps2pdf source.ps destination.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 19.2.1 (2019-09-14)"
|
#define Log_PLATFORM_VERSION "SWAD 19.3 (2019-09-15)"
|
||||||
#define CSS_FILE "swad18.138.css"
|
#define CSS_FILE "swad19.3.css"
|
||||||
#define JS_FILE "swad18.130.2.js"
|
#define JS_FILE "swad18.130.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 19.3: Sep 15, 2019 Changes in match results. (244680 lines)
|
||||||
|
2 changes necessary in database:
|
||||||
|
ALTER TABLE gam_matches DROP COLUMN Showing;
|
||||||
|
ALTER TABLE gam_matches ADD COLUMN Showing ENUM('stem','answers','results') NOT NULL DEFAULT 'stem' AFTER ShowResults;
|
||||||
|
|
||||||
Version 19.2.1: Sep 14, 2019 Show results in match is the default. (244630 lines)
|
Version 19.2.1: Sep 14, 2019 Show results in match is the default. (244630 lines)
|
||||||
1 change necessary in database:
|
1 change necessary in database:
|
||||||
ALTER TABLE gam_matches CHANGE COLUMN ShowResults ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y';
|
ALTER TABLE gam_matches CHANGE COLUMN ShowResults ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y';
|
||||||
|
|
|
@ -1369,9 +1369,9 @@ mysql> DESCRIBE gam_grp;
|
||||||
/***** Table gam_matches *****/
|
/***** Table gam_matches *****/
|
||||||
/*
|
/*
|
||||||
mysql> DESCRIBE gam_matches;
|
mysql> DESCRIBE gam_matches;
|
||||||
+--------------+-------------------------------------+------+-----+---------+----------------+
|
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||||
| Field | Type | Null | Key | Default | Extra |
|
| Field | Type | Null | Key | Default | Extra |
|
||||||
+--------------+-------------------------------------+------+-----+---------+----------------+
|
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||||
| MchCod | int(11) | NO | PRI | NULL | auto_increment |
|
| MchCod | int(11) | NO | PRI | NULL | auto_increment |
|
||||||
| GamCod | int(11) | NO | MUL | NULL | |
|
| GamCod | int(11) | NO | MUL | NULL | |
|
||||||
| UsrCod | int(11) | NO | | NULL | |
|
| UsrCod | int(11) | NO | | NULL | |
|
||||||
|
@ -1382,8 +1382,8 @@ mysql> DESCRIBE gam_matches;
|
||||||
| QstCod | int(11) | NO | | -1 | |
|
| QstCod | int(11) | NO | | -1 | |
|
||||||
| QstStartTime | datetime | NO | | NULL | |
|
| QstStartTime | datetime | NO | | NULL | |
|
||||||
| ShowResults | enum('N','Y') | NO | | Y | |
|
| ShowResults | enum('N','Y') | NO | | Y | |
|
||||||
| Showing | enum('wording','answers','results') | NO | | wording | |
|
| Showing | enum('stem','answers','results') | NO | | stem | |
|
||||||
+--------------+-------------------------------------+------+-----+---------+----------------+
|
+--------------+----------------------------------+------+-----+---------+----------------+
|
||||||
11 rows in set (0.00 sec)
|
11 rows in set (0.00 sec)
|
||||||
*/
|
*/
|
||||||
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches ("
|
DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches ("
|
||||||
|
@ -1397,7 +1397,7 @@ mysql> DESCRIBE gam_matches;
|
||||||
"QstCod INT NOT NULL DEFAULT -1,"
|
"QstCod INT NOT NULL DEFAULT -1,"
|
||||||
"QstStartTime DATETIME NOT NULL,"
|
"QstStartTime DATETIME NOT NULL,"
|
||||||
"ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',"
|
"ShowResults ENUM('N','Y') NOT NULL DEFAULT 'Y',"
|
||||||
"Showing ENUM('wording','answers','request','results') NOT NULL DEFAULT 'wording',"
|
"Showing ENUM('stem','answers','request','results') NOT NULL DEFAULT 'stem',"
|
||||||
"UNIQUE INDEX(MchCod),"
|
"UNIQUE INDEX(MchCod),"
|
||||||
"INDEX(GamCod)");
|
"INDEX(GamCod)");
|
||||||
|
|
||||||
|
|
157
swad_match.c
157
swad_match.c
|
@ -71,11 +71,11 @@ extern struct Globals Gbl;
|
||||||
#define Mch_NUM_SHOWING 3
|
#define Mch_NUM_SHOWING 3
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Mch_WORDING, // Showing only the question wording
|
Mch_STEM, // Showing only the question stem
|
||||||
Mch_ANSWERS, // Showing the question wording and the answers
|
Mch_ANSWERS, // Showing the question stem and the answers
|
||||||
Mch_RESULTS, // Showing the results
|
Mch_RESULTS, // Showing the results
|
||||||
} Mch_Showing_t;
|
} Mch_Showing_t;
|
||||||
#define Mch_SHOWING_DEFAULT Mch_WORDING
|
#define Mch_SHOWING_DEFAULT Mch_STEM
|
||||||
|
|
||||||
struct Match
|
struct Match
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,7 @@ struct Match
|
||||||
|
|
||||||
const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
|
||||||
{
|
{
|
||||||
"wording",
|
"stem",
|
||||||
"answers",
|
"answers",
|
||||||
"results",
|
"results",
|
||||||
};
|
};
|
||||||
|
@ -183,9 +183,8 @@ static void Mch_GetNumPlayers (struct Match *Match);
|
||||||
|
|
||||||
static int Mch_GetQstAnsFromDB (long MchCod,unsigned QstInd);
|
static int Mch_GetQstAnsFromDB (long MchCod,unsigned QstInd);
|
||||||
|
|
||||||
static unsigned Mch_GetNumAnswerers (struct Match *Match);
|
static unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd);
|
||||||
static unsigned Mch_GetNumUsrsWhoAnswered (long MchCod,unsigned QstInd,unsigned AnsInd);
|
static void Mch_DrawBarNumUsrs (unsigned NumAnswerersAns,unsigned NumAnswerersQst,bool Correct);
|
||||||
static void Mch_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs);
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************* List the matches of a game ************************/
|
/************************* List the matches of a game ************************/
|
||||||
|
@ -318,7 +317,7 @@ static void Mch_GetDataOfMatchByCod (struct Match *Match)
|
||||||
Match->Status.QstCod = -1L;
|
Match->Status.QstCod = -1L;
|
||||||
Match->Status.QstStartTimeUTC = (time_t) 0;
|
Match->Status.QstStartTimeUTC = (time_t) 0;
|
||||||
Match->Status.ShowResults = true;
|
Match->Status.ShowResults = true;
|
||||||
Match->Status.Showing = Mch_WORDING;
|
Match->Status.Showing = Mch_STEM;
|
||||||
Match->Status.BeingPlayed = false;
|
Match->Status.BeingPlayed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1335,7 +1334,7 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
|
||||||
/***** What to show *****/
|
/***** What to show *****/
|
||||||
switch (Match->Status.Showing)
|
switch (Match->Status.Showing)
|
||||||
{
|
{
|
||||||
case Mch_WORDING:
|
case Mch_STEM:
|
||||||
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
||||||
Mch_ANSWERS;
|
Mch_ANSWERS;
|
||||||
|
|
||||||
|
@ -1352,7 +1351,7 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
|
||||||
Match->Status.QstInd);
|
Match->Status.QstInd);
|
||||||
break;
|
break;
|
||||||
case Mch_ANSWERS:
|
case Mch_ANSWERS:
|
||||||
Match->Status.Showing = Mch_WORDING;
|
Match->Status.Showing = Mch_STEM;
|
||||||
break;
|
break;
|
||||||
case Mch_RESULTS:
|
case Mch_RESULTS:
|
||||||
Match->Status.Showing = Mch_ANSWERS;
|
Match->Status.Showing = Mch_ANSWERS;
|
||||||
|
@ -1369,20 +1368,20 @@ static void Mch_SetMatchStatusToNext (struct Match *Match)
|
||||||
/***** What to show *****/
|
/***** What to show *****/
|
||||||
switch (Match->Status.Showing)
|
switch (Match->Status.Showing)
|
||||||
{
|
{
|
||||||
case Mch_WORDING:
|
case Mch_STEM:
|
||||||
Match->Status.Showing = Mch_ANSWERS;
|
Match->Status.Showing = Mch_ANSWERS;
|
||||||
break;
|
break;
|
||||||
case Mch_ANSWERS:
|
case Mch_ANSWERS:
|
||||||
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
Match->Status.Showing = Match->Status.ShowResults ? Mch_RESULTS :
|
||||||
Mch_WORDING;
|
Mch_STEM;
|
||||||
break;
|
break;
|
||||||
case Mch_RESULTS:
|
case Mch_RESULTS:
|
||||||
Match->Status.Showing = Mch_WORDING;
|
Match->Status.Showing = Mch_STEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Go to next question? *****/
|
/***** Go to next question? *****/
|
||||||
if (Match->Status.Showing == Mch_WORDING)
|
if (Match->Status.Showing == Mch_STEM)
|
||||||
{
|
{
|
||||||
/***** Get index of the next question *****/
|
/***** Get index of the next question *****/
|
||||||
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
|
||||||
|
@ -1498,7 +1497,7 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
|
||||||
{
|
{
|
||||||
extern const char *Txt_MATCH_respond;
|
extern const char *Txt_MATCH_respond;
|
||||||
struct Time Time;
|
struct Time Time;
|
||||||
unsigned NumAnswerers;
|
unsigned NumAnswerersQst;
|
||||||
|
|
||||||
/***** Start left container *****/
|
/***** Start left container *****/
|
||||||
fprintf (Gbl.F.Out,"<div class=\"MATCH_LEFT\">");
|
fprintf (Gbl.F.Out,"<div class=\"MATCH_LEFT\">");
|
||||||
|
@ -1536,16 +1535,17 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
|
||||||
/***** Number of players *****/
|
/***** Number of players *****/
|
||||||
Mch_ShowNumPlayers (Match);
|
Mch_ShowNumPlayers (Match);
|
||||||
|
|
||||||
/***** Number of users who have answered *****/
|
/***** Number of users who have answered this question *****/
|
||||||
if (Match->Status.BeingPlayed)
|
if (Match->Status.BeingPlayed)
|
||||||
{
|
{
|
||||||
NumAnswerers = Mch_GetNumAnswerers (Match);
|
NumAnswerersQst = Mch_GetNumUsrsWhoHaveAnswerQst (Match->MchCod,
|
||||||
|
Match->Status.QstInd);
|
||||||
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_ANSWERERS\">"
|
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_ANSWERERS\">"
|
||||||
"%s<br />"
|
"%s<br />"
|
||||||
"<strong>%u/%u</strong>"
|
"<strong>%u/%u</strong>"
|
||||||
"</div>",
|
"</div>",
|
||||||
Txt_MATCH_respond,
|
Txt_MATCH_respond,
|
||||||
NumAnswerers,Match->Status.NumPlayers);
|
NumAnswerersQst,Match->Status.NumPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** End left container *****/
|
/***** End left container *****/
|
||||||
|
@ -1751,10 +1751,10 @@ static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
|
||||||
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
|
Gbl.Test.AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[0]);
|
||||||
// TODO: Check that answer type is correct (unique choice)
|
// TODO: Check that answer type is correct (unique choice)
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM\">");
|
fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM\">"); // Bottom
|
||||||
|
|
||||||
/* Write stem (row[1]) */
|
/* Write stem (row[1]) */
|
||||||
Tst_WriteQstStem (row[1],"MATCH_TCH_QST");
|
Tst_WriteQstStem (row[1],"MATCH_TCH_STEM");
|
||||||
|
|
||||||
/* Get media (row[2]) */
|
/* Get media (row[2]) */
|
||||||
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]);
|
Gbl.Test.Media.MedCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||||
|
@ -1768,16 +1768,17 @@ static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
|
||||||
/* Write answers? */
|
/* Write answers? */
|
||||||
switch (Match->Status.Showing)
|
switch (Match->Status.Showing)
|
||||||
{
|
{
|
||||||
case Mch_WORDING:
|
case Mch_STEM:
|
||||||
/* Don't write anything */
|
/* Don't write anything */
|
||||||
break;
|
break;
|
||||||
case Mch_ANSWERS:
|
case Mch_ANSWERS:
|
||||||
if (Match->Status.BeingPlayed)
|
if (Match->Status.BeingPlayed) // Being played
|
||||||
/* Write answers */
|
/* Write answers */
|
||||||
Tst_WriteAnswersMatchResult (Match->MchCod,
|
Tst_WriteAnswersMatchResult (Match->MchCod,
|
||||||
Match->Status.QstInd,
|
Match->Status.QstInd,
|
||||||
Match->Status.QstCod,
|
Match->Status.QstCod,
|
||||||
"MATCH_TCH_QST",false); // Don't show result
|
"MATCH_TCH_ANS",
|
||||||
|
false); // Don't show result
|
||||||
else // Not being played
|
else // Not being played
|
||||||
Mch_ShowWaitImage (Txt_MATCH_Paused);
|
Mch_ShowWaitImage (Txt_MATCH_Paused);
|
||||||
break;
|
break;
|
||||||
|
@ -1786,11 +1787,12 @@ static void Mch_ShowQuestionAndAnswersTch (struct Match *Match)
|
||||||
Tst_WriteAnswersMatchResult (Match->MchCod,
|
Tst_WriteAnswersMatchResult (Match->MchCod,
|
||||||
Match->Status.QstInd,
|
Match->Status.QstInd,
|
||||||
Match->Status.QstCod,
|
Match->Status.QstCod,
|
||||||
"MATCH_TCH_QST",true); // Show result
|
"MATCH_TCH_ANS",
|
||||||
|
true); // Show result
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>"); // Bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2259,50 +2261,49 @@ void Mch_ReceiveQstAnsFromStd (void)
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/***** Get number of users who have answered current question in a match *****/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static unsigned Mch_GetNumAnswerers (struct Match *Match)
|
|
||||||
{
|
|
||||||
/***** Get number of users who have answered the current question in a match from database *****/
|
|
||||||
return
|
|
||||||
(unsigned) DB_QueryCOUNT ("can not get number of questions of a game",
|
|
||||||
"SELECT COUNT(*) FROM gam_answers"
|
|
||||||
" WHERE MchCod=%ld AND QstInd=%u",
|
|
||||||
Match->MchCod,
|
|
||||||
Match->Status.QstInd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*** Get number of users who selected this answer and draw proportional bar **/
|
/*** Get number of users who selected this answer and draw proportional bar **/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void Mch_GetAndDrawBarNumUsrsWhoAnswered (long MchCod,unsigned QstInd,unsigned AnsInd,unsigned NumUsrs)
|
void Mch_GetAndDrawBarNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd,
|
||||||
|
unsigned NumAnswerersQst,bool Correct)
|
||||||
{
|
{
|
||||||
unsigned NumUsrsThisAnswer;
|
unsigned NumAnswerersAns;
|
||||||
|
|
||||||
/***** Get number of users who selected this answer *****/
|
/***** Get number of users who selected this answer *****/
|
||||||
NumUsrsThisAnswer = Mch_GetNumUsrsWhoAnswered (MchCod,QstInd,AnsInd);
|
NumAnswerersAns = Mch_GetNumUsrsWhoHaveChosenAns (MchCod,QstInd,AnsInd);
|
||||||
|
|
||||||
/***** Show stats of this answer *****/
|
/***** Show stats of this answer *****/
|
||||||
Mch_DrawBarNumUsrs (NumUsrsThisAnswer,NumUsrs);
|
Mch_DrawBarNumUsrs (NumAnswerersAns,NumAnswerersQst,Correct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**** Get number of users who selected a given answer of a game question *****/
|
/******* Get number of users who have answered a question in a match *********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static unsigned Mch_GetNumUsrsWhoAnswered (long MchCod,unsigned QstInd,unsigned AnsInd)
|
unsigned Mch_GetNumUsrsWhoHaveAnswerQst (long MchCod,unsigned QstInd)
|
||||||
|
{
|
||||||
|
/***** Get number of users who have answered
|
||||||
|
a question in a match from database *****/
|
||||||
|
return
|
||||||
|
(unsigned) DB_QueryCOUNT ("can not get number of users who hasve answered a question",
|
||||||
|
"SELECT COUNT(*) FROM gam_answers"
|
||||||
|
" WHERE MchCod=%ld AND QstInd=%u",
|
||||||
|
MchCod,QstInd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*** Get number of users who have chosen a given answer of a game question ***/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static unsigned Mch_GetNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd)
|
||||||
{
|
{
|
||||||
/***** Get number of users who have chosen
|
/***** Get number of users who have chosen
|
||||||
an answer of a question from database *****/
|
an answer of a question from database *****/
|
||||||
return (unsigned) DB_QueryCOUNT ("can not get number of users who answered",
|
return
|
||||||
"SELECT COUNT(*)"
|
(unsigned) DB_QueryCOUNT ("can not get number of users who have chosen an answer",
|
||||||
" FROM gam_answers"
|
"SELECT COUNT(*) FROM gam_answers"
|
||||||
" WHERE MchCod=%ld"
|
" WHERE MchCod=%ld AND QstInd=%u AND AnsInd=%u",
|
||||||
" AND QstInd=%u"
|
|
||||||
" AND AnsInd=%u",
|
|
||||||
MchCod,QstInd,AnsInd);
|
MchCod,QstInd,AnsInd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2310,41 +2311,51 @@ static unsigned Mch_GetNumUsrsWhoAnswered (long MchCod,unsigned QstInd,unsigned
|
||||||
/***************** Draw a bar with the percentage of answers *****************/
|
/***************** Draw a bar with the percentage of answers *****************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Gam_MAX_BAR_WIDTH 125
|
// #define Mch_MAX_BAR_WIDTH 400
|
||||||
|
#define Mch_MAX_BAR_WIDTH 100
|
||||||
|
|
||||||
static void Mch_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
|
static void Mch_DrawBarNumUsrs (unsigned NumAnswerersAns,unsigned NumAnswerersQst,bool Correct)
|
||||||
{
|
{
|
||||||
extern const char *Txt_of_PART_OF_A_TOTAL;
|
extern const char *Txt_of_PART_OF_A_TOTAL;
|
||||||
|
unsigned i;
|
||||||
unsigned BarWidth = 0;
|
unsigned BarWidth = 0;
|
||||||
|
|
||||||
/***** String with the number of users *****/
|
/***** String with the number of users *****/
|
||||||
if (MaxUsrs)
|
if (NumAnswerersQst)
|
||||||
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
||||||
"%u (%u%% %s %u)",
|
"%u (%u%% %s %u)",
|
||||||
NumUsrs,
|
NumAnswerersAns,
|
||||||
(unsigned) ((((float) NumUsrs * 100.0) / (float) MaxUsrs) + 0.5),
|
(unsigned) ((((float) NumAnswerersAns * 100.0) / (float) NumAnswerersQst) + 0.5),
|
||||||
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
|
Txt_of_PART_OF_A_TOTAL,NumAnswerersQst);
|
||||||
else
|
else
|
||||||
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
||||||
"0 (0%% %s %u)",
|
"0 (0%% %s %u)",
|
||||||
Txt_of_PART_OF_A_TOTAL,MaxUsrs);
|
Txt_of_PART_OF_A_TOTAL,NumAnswerersQst);
|
||||||
|
|
||||||
|
/***** Start container *****/
|
||||||
|
fprintf (Gbl.F.Out,"<div class=\"MATCH_RESULT\">");
|
||||||
|
|
||||||
/***** Draw bar with a with proportional to the number of clicks *****/
|
/***** Draw bar with a with proportional to the number of clicks *****/
|
||||||
if (NumUsrs && MaxUsrs)
|
if (NumAnswerersAns && NumAnswerersQst)
|
||||||
BarWidth = (unsigned) ((((float) NumUsrs * (float) Gam_MAX_BAR_WIDTH) /
|
BarWidth = (unsigned) ((((float) NumAnswerersAns * (float) Mch_MAX_BAR_WIDTH) /
|
||||||
(float) MaxUsrs) + 0.5);
|
(float) NumAnswerersQst) + 0.5);
|
||||||
if (BarWidth < 2)
|
|
||||||
BarWidth = 2;
|
/***** Bar proportional to number of users *****/
|
||||||
fprintf (Gbl.F.Out,"<img src=\"%s/c1x16.gif\""
|
Tbl_StartTableWide (0);
|
||||||
" alt=\"%s\" title=\"%s\""
|
fprintf (Gbl.F.Out,"<tr class=\"MATCH_RES_TR\">");
|
||||||
" class=\"LEFT_TOP\""
|
for (i = 0;
|
||||||
" style=\"width:%upx; height:20px;\" />"
|
i < 100;
|
||||||
" ",
|
i++)
|
||||||
Cfg_URL_ICON_PUBLIC,
|
fprintf (Gbl.F.Out,"<td class=\"%s\"></td>",
|
||||||
Gbl.Title,
|
(i < BarWidth) ? (Correct ? "MATCH_RES_CORRECT" :
|
||||||
Gbl.Title,
|
"MATCH_RES_WRONG") :
|
||||||
BarWidth);
|
"MATCH_RES_VOID");
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
|
Tbl_EndTable ();
|
||||||
|
|
||||||
/***** Write the number of users *****/
|
/***** Write the number of users *****/
|
||||||
fprintf (Gbl.F.Out,"%s",Gbl.Title);
|
fprintf (Gbl.F.Out,"%s",Gbl.Title);
|
||||||
|
|
||||||
|
/***** End container *****/
|
||||||
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ void Mch_RefreshMatchStd (void);
|
||||||
|
|
||||||
void Mch_ReceiveQstAnsFromStd (void);
|
void Mch_ReceiveQstAnsFromStd (void);
|
||||||
|
|
||||||
void Mch_GetAndDrawBarNumUsrsWhoAnswered (long MchCod,unsigned QstInd,unsigned AnsInd,unsigned NumUsrs);
|
void Mch_GetAndDrawBarNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd,
|
||||||
|
unsigned NumAnswerersQst,bool Correct);
|
||||||
|
unsigned Mch_GetNumUsrsWhoHaveAnswerQst (long MchCod,unsigned QstInd);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
59
swad_test.c
59
swad_test.c
|
@ -210,7 +210,7 @@ static void Tst_WriteChoiceAnsViewTest (unsigned NumQst,long QstCod,bool Shuffle
|
||||||
static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
||||||
unsigned NumQst,MYSQL_RES *mysql_res,
|
unsigned NumQst,MYSQL_RES *mysql_res,
|
||||||
double *ScoreThisQst,bool *AnswerIsNotBlank);
|
double *ScoreThisQst,bool *AnswerIsNotBlank);
|
||||||
static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
static void Tst_WriteChoiceAnsViewMatch (long MchCod,unsigned QstInd,long QstCod,
|
||||||
const char *Class,
|
const char *Class,
|
||||||
bool ShowResult);
|
bool ShowResult);
|
||||||
|
|
||||||
|
@ -3531,7 +3531,7 @@ void Tst_WriteAnswersMatchResult (long MchCod,unsigned QstInd,long QstCod,
|
||||||
{
|
{
|
||||||
/***** Write answer depending on type *****/
|
/***** Write answer depending on type *****/
|
||||||
if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE)
|
if (Gbl.Test.AnswerType == Tst_ANS_UNIQUE_CHOICE)
|
||||||
Tst_WriteChoiceAnsViewGame (MchCod,QstInd,QstCod,
|
Tst_WriteChoiceAnsViewMatch (MchCod,QstInd,QstCod,
|
||||||
Class,ShowResult);
|
Class,ShowResult);
|
||||||
else
|
else
|
||||||
Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
|
Ale_ShowAlert (Ale_ERROR,"Type of answer not valid in a game.");
|
||||||
|
@ -4042,10 +4042,10 @@ static void Tst_WriteChoiceAnsAssessTest (struct UsrData *UsrDat,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******** Write single or multiple choice answer when viewing a test *********/
|
/******** Write single or multiple choice answer when viewing a match ********/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
static void Tst_WriteChoiceAnsViewMatch (long MchCod,unsigned QstInd,long QstCod,
|
||||||
const char *Class,
|
const char *Class,
|
||||||
bool ShowResult)
|
bool ShowResult)
|
||||||
{
|
{
|
||||||
|
@ -4053,8 +4053,13 @@ static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned AnsInd;
|
unsigned AnsInd;
|
||||||
|
unsigned NumAnswerersQst;
|
||||||
|
bool Correct;
|
||||||
bool ErrorInIndex = false;
|
bool ErrorInIndex = false;
|
||||||
|
|
||||||
|
/***** Get number of users who hasve answered this question from database *****/
|
||||||
|
NumAnswerersQst = Mch_GetNumUsrsWhoHaveAnswerQst (MchCod,QstInd);
|
||||||
|
|
||||||
/***** Get answers of a question from database *****/
|
/***** Get answers of a question from database *****/
|
||||||
Gbl.Test.Answer.NumOptions = Tst_GetAnswersQst (QstCod,&mysql_res,false);
|
Gbl.Test.Answer.NumOptions = Tst_GetAnswersQst (QstCod,&mysql_res,false);
|
||||||
/*
|
/*
|
||||||
|
@ -4066,7 +4071,7 @@ static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/***** Start table *****/
|
/***** Start table *****/
|
||||||
Tbl_StartTable (2);
|
Tbl_StartTableWide (2);
|
||||||
|
|
||||||
for (NumOpt = 0;
|
for (NumOpt = 0;
|
||||||
NumOpt < Gbl.Test.Answer.NumOptions;
|
NumOpt < Gbl.Test.Answer.NumOptions;
|
||||||
|
@ -4104,24 +4109,19 @@ static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
||||||
Gbl.Test.Answer.Options[NumOpt].Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
|
Gbl.Test.Answer.Options[NumOpt].Media.MedCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
Med_GetMediaDataByCod (&Gbl.Test.Answer.Options[NumOpt].Media);
|
Med_GetMediaDataByCod (&Gbl.Test.Answer.Options[NumOpt].Media);
|
||||||
|
|
||||||
|
/***** Start row for this option *****/
|
||||||
|
fprintf (Gbl.F.Out,"<tr>");
|
||||||
|
|
||||||
/***** Write letter for this option *****/
|
/***** Write letter for this option *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<td class=\"MATCH_TCH_BUTTON_TD\">"
|
||||||
"<td class=\"CENTER_MIDDLE\">"
|
"<div class=\"MATCH_TCH_BUTTON BT_%c\">"
|
||||||
"<div class=\"");
|
"%c"
|
||||||
if (ShowResult)
|
"</div>"
|
||||||
fprintf (Gbl.F.Out,"%s\">"
|
"</td>",
|
||||||
"%c) ",
|
|
||||||
Class,
|
|
||||||
'a' + (char) NumOpt);
|
|
||||||
else
|
|
||||||
fprintf (Gbl.F.Out,"MATCH_TCH_BUTTON BT_%c\">"
|
|
||||||
"%c",
|
|
||||||
'A' + (char) NumOpt,
|
'A' + (char) NumOpt,
|
||||||
'a' + (char) NumOpt);
|
'a' + (char) NumOpt);
|
||||||
fprintf (Gbl.F.Out,"</div>"
|
|
||||||
"</td>");
|
|
||||||
|
|
||||||
/***** Write the option text *****/
|
/***** Write the option text and the result *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||||
"<label for=\"Ans%06u_%u\" class=\"%s\">"
|
"<label for=\"Ans%06u_%u\" class=\"%s\">"
|
||||||
"%s"
|
"%s"
|
||||||
|
@ -4132,22 +4132,23 @@ static void Tst_WriteChoiceAnsViewGame (long MchCod,unsigned QstInd,long QstCod,
|
||||||
Med_ShowMedia (&Gbl.Test.Answer.Options[NumOpt].Media,
|
Med_ShowMedia (&Gbl.Test.Answer.Options[NumOpt].Media,
|
||||||
"TEST_MED_SHOW_CONTAINER",
|
"TEST_MED_SHOW_CONTAINER",
|
||||||
"TEST_MED_SHOW");
|
"TEST_MED_SHOW");
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"</tr>");
|
|
||||||
|
|
||||||
/***** Show result (number of users who answered? *****/
|
/* Show result (number of users who answered? */
|
||||||
if (ShowResult)
|
if (ShowResult)
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
/* Get if correct (row[4]) */
|
||||||
"<td></td>"
|
Correct = (row[4][0] == 'Y');
|
||||||
"<td class=\"DAT LEFT_TOP\">");
|
|
||||||
/* Get number of users who selected this answer
|
/* Get number of users who selected this answer
|
||||||
and draw proportional bar */
|
and draw proportional bar */
|
||||||
Mch_GetAndDrawBarNumUsrsWhoAnswered (MchCod,QstInd,AnsInd,
|
Mch_GetAndDrawBarNumUsrsWhoHaveChosenAns (MchCod,QstInd,AnsInd,
|
||||||
0); // TODO: NumUsrs
|
NumAnswerersQst,Correct);
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"</tr>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
|
/***** End row for this option *****/
|
||||||
|
fprintf (Gbl.F.Out,"</tr>");
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** End table *****/
|
/***** End table *****/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user