mirror of https://github.com/acanas/swad-core.git
Version19.91.1
This commit is contained in:
parent
38b5bbe163
commit
35afdec6a2
|
@ -604,19 +604,24 @@ function refreshMatchTch () {
|
||||||
function readMatchTchData () {
|
function readMatchTchData () {
|
||||||
if (objXMLHttpReqMchTch.readyState == 4) { // Check if data have been received
|
if (objXMLHttpReqMchTch.readyState == 4) { // Check if data have been received
|
||||||
if (objXMLHttpReqMchTch.status == 200) {
|
if (objXMLHttpReqMchTch.status == 200) {
|
||||||
var endOfId = objXMLHttpReqMchTch.responseText.indexOf('|',0); // Get separator position
|
var endOfId = objXMLHttpReqMchTch.responseText.indexOf('|',0 ); // Get separator position
|
||||||
var Id = objXMLHttpReqMchTch.responseText.substring(0,endOfId); // Get Id
|
var endOfEv = objXMLHttpReqMchTch.responseText.indexOf('|',endOfId + 1); // Get separator position
|
||||||
var htmlMatch = objXMLHttpReqMchTch.responseText.substring(endOfId + 1); // Get HTML code
|
|
||||||
|
|
||||||
var div = document.getElementById(Id); // Access to refreshable DIV
|
var id = objXMLHttpReqMchTch.responseText.substring(0 ,endOfId); // Get id
|
||||||
|
var ev = objXMLHttpReqMchTch.responseText.substring(endOfId + 1,endOfEv); // Get ev ('0' / '1')
|
||||||
|
var html = objXMLHttpReqMchTch.responseText.substring(endOfEv + 1); // Get HTML code
|
||||||
|
|
||||||
|
var div = document.getElementById(id); // Access to refreshable DIV
|
||||||
if (div) {
|
if (div) {
|
||||||
div.innerHTML = htmlMatch; // Update DIV content
|
div.innerHTML = html; // Update DIV content
|
||||||
|
|
||||||
// Scripts in div got via AJAX are not executed ==> execute them
|
if (parseInt(ev)) { // 0 / 1
|
||||||
evalScriptsInElem (div);
|
// Scripts in div got via AJAX are not executed ==> execute them
|
||||||
|
evalScriptsInElem (div);
|
||||||
|
|
||||||
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
// Process mathematics; see http://docs.mathjax.org/en/latest/advanced/typeset.html
|
||||||
MathJax.Hub.Queue(["Typeset",MathJax.Hub,div]);
|
MathJax.Hub.Queue(["Typeset",MathJax.Hub,div]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global delay variable is set initially in swad-core
|
// Global delay variable is set initially in swad-core
|
10
swad_HTML.c
10
swad_HTML.c
|
@ -1068,7 +1068,7 @@ void HTM_INPUT_URL (const char *Name,const char *Value,bool SubmitOnChange,
|
||||||
int NumBytesPrinted;
|
int NumBytesPrinted;
|
||||||
char *Attr;
|
char *Attr;
|
||||||
|
|
||||||
HTM_TxtF ("<input type=\"url\" name=\"%s\ maxlength=\"%u\" value=\"%s\"",
|
HTM_TxtF ("<input type=\"url\" name=\"%s\" maxlength=\"%u\" value=\"%s\"",
|
||||||
Name,Cns_MAX_CHARS_WWW,Value);
|
Name,Cns_MAX_CHARS_WWW,Value);
|
||||||
|
|
||||||
if (fmt)
|
if (fmt)
|
||||||
|
@ -1322,7 +1322,7 @@ void HTM_INPUT_CHECKBOX (const char *Name,bool SubmitOnChange,
|
||||||
/********************************** Buttons **********************************/
|
/********************************** Buttons **********************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
void HTM_BUTTON_OnMouseDown_Begin (const char *Title,const char *Class,const char *OnMouseDown)
|
void HTM_BUTTON_OnMouseDown_Begin (const char *Title,const char *Class)
|
||||||
{
|
{
|
||||||
HTM_Txt ("<button type=\"submit\"");
|
HTM_Txt ("<button type=\"submit\"");
|
||||||
if (Title)
|
if (Title)
|
||||||
|
@ -1331,11 +1331,7 @@ void HTM_BUTTON_OnMouseDown_Begin (const char *Title,const char *Class,const cha
|
||||||
if (Class)
|
if (Class)
|
||||||
if (Class[0])
|
if (Class[0])
|
||||||
HTM_TxtF (" class=\"%s\"",Class);
|
HTM_TxtF (" class=\"%s\"",Class);
|
||||||
HTM_TxtF (" onmousedown=\"");
|
HTM_TxtF (" onmousedown=\"document.getElementById('%s').submit();return false;\">",
|
||||||
if (OnMouseDown) // JavaScript function to be called before submitting the form
|
|
||||||
if (OnMouseDown[0])
|
|
||||||
HTM_TxtF ("%s;",OnMouseDown);
|
|
||||||
HTM_TxtF ("document.getElementById('%s').submit();return false;\">",
|
|
||||||
Gbl.Form.Id);
|
Gbl.Form.Id);
|
||||||
HTM_BUTTON_NestingLevel++;
|
HTM_BUTTON_NestingLevel++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ void HTM_INPUT_RADIO (const char *Name,bool SubmitOnClick,
|
||||||
void HTM_INPUT_CHECKBOX (const char *Name,bool SubmitOnChange,
|
void HTM_INPUT_CHECKBOX (const char *Name,bool SubmitOnChange,
|
||||||
const char *fmt,...);
|
const char *fmt,...);
|
||||||
|
|
||||||
void HTM_BUTTON_OnMouseDown_Begin (const char *Title,const char *Class,const char *OnMouseDown);
|
void HTM_BUTTON_OnMouseDown_Begin (const char *Title,const char *Class);
|
||||||
void HTM_BUTTON_SUBMIT_Begin (const char *Title,const char *Class,const char *OnSubmit);
|
void HTM_BUTTON_SUBMIT_Begin (const char *Title,const char *Class,const char *OnSubmit);
|
||||||
void HTM_BUTTON_BUTTON_Begin (const char *Title,const char *Class,const char *OnClick);
|
void HTM_BUTTON_BUTTON_Begin (const char *Title,const char *Class,const char *OnClick);
|
||||||
void HTM_BUTTON_Animated_Begin (const char *Title,const char *Class,const char *OnClick);
|
void HTM_BUTTON_Animated_Begin (const char *Title,const char *Class,const char *OnClick);
|
||||||
|
|
|
@ -490,13 +490,14 @@ 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.91 (2019-12-13)"
|
#define Log_PLATFORM_VERSION "SWAD 19.91.1 (2019-12-14)"
|
||||||
#define CSS_FILE "swad19.90.1.css"
|
#define CSS_FILE "swad19.90.1.css"
|
||||||
#define JS_FILE "swad19.91.js"
|
#define JS_FILE "swad19.91.1.js"
|
||||||
/*
|
/*
|
||||||
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.)
|
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.)
|
||||||
// TODO: Impedir la creación y edición de proyectos si no son editables.
|
// TODO: Impedir la creación y edición de proyectos si no son editables.
|
||||||
|
|
||||||
|
Version 19.91.1: Dec 14, 2019 Changes in match layout. (248533 lines)
|
||||||
Version 19.91: Dec 13, 2019 Changes in match countdown.
|
Version 19.91: Dec 13, 2019 Changes in match countdown.
|
||||||
Code refactoring in HTML. (248513 lines)
|
Code refactoring in HTML. (248513 lines)
|
||||||
Version 19.90.5: Dec 13, 2019 Fixed issues in layout of links (buttons). (248432 lines)
|
Version 19.90.5: Dec 13, 2019 Fixed issues in layout of links (buttons). (248432 lines)
|
||||||
|
|
411
swad_match.c
411
swad_match.c
|
@ -167,10 +167,10 @@ static void Mch_ShowLeftColumnTch (struct Match *Match);
|
||||||
static void Mch_ShowRefreshablePartTch (struct Match *Match);
|
static void Mch_ShowRefreshablePartTch (struct Match *Match);
|
||||||
static void Mch_WriteElapsedTimeInMch (struct Match *Match);
|
static void Mch_WriteElapsedTimeInMch (struct Match *Match);
|
||||||
static void Mch_WriteElapsedTimeInQst (struct Match *Match);
|
static void Mch_WriteElapsedTimeInQst (struct Match *Match);
|
||||||
static void Mch_WriteHourglass (struct Match *Match);
|
|
||||||
static void Mch_PutFormCountdown (struct Match *Match,long Countdown,const char *Color);
|
|
||||||
static void Mch_PutCountdownAndHourglassIcon (struct Match *Match);
|
|
||||||
static void Mch_WriteNumRespondersQst (struct Match *Match);
|
static void Mch_WriteNumRespondersQst (struct Match *Match);
|
||||||
|
static void Mch_PutFormCountdown (struct Match *Match,long Seconds,const char *Color);
|
||||||
|
static void Mch_PutCountdownAndHourglassIcon (struct Match *Match);
|
||||||
|
static void Mch_PutFormsCountdown (struct Match *Match);
|
||||||
|
|
||||||
static void Mch_ShowRightColumnTch (const struct Match *Match);
|
static void Mch_ShowRightColumnTch (const struct Match *Match);
|
||||||
static void Mch_ShowLeftColumnStd (const struct Match *Match,
|
static void Mch_ShowLeftColumnStd (const struct Match *Match,
|
||||||
|
@ -196,7 +196,7 @@ static bool Mch_ShowQuestionAndAnswersStd (const struct Match *Match,
|
||||||
Mch_Update_t Update);
|
Mch_Update_t Update);
|
||||||
|
|
||||||
static void Mch_ShowMatchScore (const struct Match *Match);
|
static void Mch_ShowMatchScore (const struct Match *Match);
|
||||||
static void Mch_DrawEmptyRowScore (unsigned NumRow,double MinScore,double MaxScore);
|
static void Mch_DrawEmptyScoreRow (unsigned NumRow,double MinScore,double MaxScore);
|
||||||
static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
|
static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
|
||||||
unsigned NumRow,unsigned NumUsrs,unsigned MaxUsrs);
|
unsigned NumRow,unsigned NumUsrs,unsigned MaxUsrs);
|
||||||
static const char *Mch_GetClassBorder (unsigned NumRow);
|
static const char *Mch_GetClassBorder (unsigned NumRow);
|
||||||
|
@ -1976,6 +1976,10 @@ static void Mch_SetMatchStatusToPrev (struct Match *Match)
|
||||||
Match->Status.Countdown = -1L; // No countdown
|
Match->Status.Countdown = -1L; // No countdown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Set match status to previous question ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_SetMatchStatusToPrevQst (struct Match *Match)
|
static void Mch_SetMatchStatusToPrevQst (struct Match *Match)
|
||||||
{
|
{
|
||||||
/***** Get index of the previous question *****/
|
/***** Get index of the previous question *****/
|
||||||
|
@ -1992,6 +1996,10 @@ static void Mch_SetMatchStatusToPrevQst (struct Match *Match)
|
||||||
Mch_SetMatchStatusToStart (Match);
|
Mch_SetMatchStatusToStart (Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************ Set match status to start **************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_SetMatchStatusToStart (struct Match *Match)
|
static void Mch_SetMatchStatusToStart (struct Match *Match)
|
||||||
{
|
{
|
||||||
Match->Status.QstInd = 0; // Before first question
|
Match->Status.QstInd = 0; // Before first question
|
||||||
|
@ -2031,6 +2039,10 @@ static void Mch_SetMatchStatusToNext (struct Match *Match)
|
||||||
Match->Status.Countdown = -1L; // No countdown
|
Match->Status.Countdown = -1L; // No countdown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Set match status to next question ************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_SetMatchStatusToNextQst (struct Match *Match)
|
static void Mch_SetMatchStatusToNextQst (struct Match *Match)
|
||||||
{
|
{
|
||||||
/***** Get index of the next question *****/
|
/***** Get index of the next question *****/
|
||||||
|
@ -2048,6 +2060,10 @@ static void Mch_SetMatchStatusToNextQst (struct Match *Match)
|
||||||
Mch_SetMatchStatusToEnd (Match);
|
Mch_SetMatchStatusToEnd (Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************* Set match status to end ***************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_SetMatchStatusToEnd (struct Match *Match)
|
static void Mch_SetMatchStatusToEnd (struct Match *Match)
|
||||||
{
|
{
|
||||||
Match->Status.QstInd = Mch_AFTER_LAST_QUESTION; // After last question
|
Match->Status.QstInd = Mch_AFTER_LAST_QUESTION; // After last question
|
||||||
|
@ -2183,6 +2199,9 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
|
||||||
Mch_ShowRefreshablePartTch (Match);
|
Mch_ShowRefreshablePartTch (Match);
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
/***** Put forms to start countdown *****/
|
||||||
|
Mch_PutFormsCountdown (Match);
|
||||||
|
|
||||||
/***** Buttons *****/
|
/***** Buttons *****/
|
||||||
Mch_PutMatchControlButtons (Match);
|
Mch_PutMatchControlButtons (Match);
|
||||||
|
|
||||||
|
@ -2198,6 +2217,10 @@ static void Mch_ShowLeftColumnTch (struct Match *Match)
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Show left refreshable part for teachers *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_ShowRefreshablePartTch (struct Match *Match)
|
static void Mch_ShowRefreshablePartTch (struct Match *Match)
|
||||||
{
|
{
|
||||||
/***** Write elapsed time in match *****/
|
/***** Write elapsed time in match *****/
|
||||||
|
@ -2209,13 +2232,17 @@ static void Mch_ShowRefreshablePartTch (struct Match *Match)
|
||||||
/***** Write elapsed time in question *****/
|
/***** Write elapsed time in question *****/
|
||||||
Mch_WriteElapsedTimeInQst (Match);
|
Mch_WriteElapsedTimeInQst (Match);
|
||||||
|
|
||||||
/***** Write hourglass *****/
|
|
||||||
Mch_WriteHourglass (Match);
|
|
||||||
|
|
||||||
/***** Number of users who have responded this question *****/
|
/***** Number of users who have responded this question *****/
|
||||||
Mch_WriteNumRespondersQst (Match);
|
Mch_WriteNumRespondersQst (Match);
|
||||||
|
|
||||||
|
/***** Write hourglass *****/
|
||||||
|
Mch_PutCountdownAndHourglassIcon (Match);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Write elapsed time in current match ********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_WriteElapsedTimeInMch (struct Match *Match)
|
static void Mch_WriteElapsedTimeInMch (struct Match *Match)
|
||||||
{
|
{
|
||||||
struct Time Time;
|
struct Time Time;
|
||||||
|
@ -2231,6 +2258,10 @@ static void Mch_WriteElapsedTimeInMch (struct Match *Match)
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****************** Write elapsed time in current question *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_WriteElapsedTimeInQst (struct Match *Match)
|
static void Mch_WriteElapsedTimeInQst (struct Match *Match)
|
||||||
{
|
{
|
||||||
struct Time Time;
|
struct Time Time;
|
||||||
|
@ -2252,184 +2283,6 @@ static void Mch_WriteElapsedTimeInQst (struct Match *Match)
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mch_WriteHourglass (struct Match *Match)
|
|
||||||
{
|
|
||||||
/***** Start container *****/
|
|
||||||
HTM_DIV_Begin ("class=\"MCH_SHOW_HOURGLASS\"");
|
|
||||||
|
|
||||||
/***** Put icon hourglass and write countdown *****/
|
|
||||||
Mch_PutCountdownAndHourglassIcon (Match);
|
|
||||||
HTM_BR ();
|
|
||||||
|
|
||||||
/***** Put forms to start countdown *****/
|
|
||||||
Mch_PutFormCountdown (Match,-1 ,"MCH_GREEN" );
|
|
||||||
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_LARGE ,"MCH_LIMEGREEN");
|
|
||||||
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_MEDIUM,"MCH_YELLOW" );
|
|
||||||
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_SMALL ,"MCH_RED" );
|
|
||||||
|
|
||||||
/***** End container *****/
|
|
||||||
HTM_DIV_End ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Mch_PutFormCountdown (struct Match *Match,long Countdown,const char *Color)
|
|
||||||
{
|
|
||||||
extern const char *Txt_Countdown;
|
|
||||||
char *OnSubmit;
|
|
||||||
char *Class;
|
|
||||||
bool PutForm = Match->Status.Showing != Mch_END;
|
|
||||||
|
|
||||||
if (PutForm)
|
|
||||||
{
|
|
||||||
/***** Start form *****/
|
|
||||||
if (asprintf (&OnSubmit,"updateMatchTch('match_left',"
|
|
||||||
"'act=%ld&ses=%s&MchCod=%ld&Countdown=%ld');"
|
|
||||||
" return false;", // return false is necessary to not submit form
|
|
||||||
Act_GetActCod (ActMchCntDwn),Gbl.Session.Id,
|
|
||||||
Match->MchCod,Countdown) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
// Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit);
|
|
||||||
|
|
||||||
/***** Set class *****/
|
|
||||||
if (asprintf (&Class,"BT_LINK MCH_BUTTON_ON %s",Color) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/***** Set class *****/
|
|
||||||
if (asprintf (&Class,"BT_LINK_OFF MCH_BUTTON_HIDDEN %s",Color) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Put icon *****/
|
|
||||||
HTM_DIV_Begin ("class=\"MCH_SMALLBUTTON_CONT\"");
|
|
||||||
|
|
||||||
if (PutForm)
|
|
||||||
{
|
|
||||||
HTM_BUTTON_OnMouseDown_Begin (Txt_Countdown,Class,OnSubmit);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
HTM_BUTTON_BUTTON_Begin (NULL,Class,NULL);
|
|
||||||
|
|
||||||
if (Countdown >= 0)
|
|
||||||
HTM_TxtF (" %ld″",Countdown);
|
|
||||||
else
|
|
||||||
HTM_Txt (" ∞ ");
|
|
||||||
|
|
||||||
HTM_BUTTON_End ();
|
|
||||||
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** Free class *****/
|
|
||||||
free (Class);
|
|
||||||
|
|
||||||
/***** End form *****/
|
|
||||||
if (PutForm)
|
|
||||||
{
|
|
||||||
Frm_EndForm ();
|
|
||||||
free (OnSubmit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Mch_PutFormCountdown_old (struct Match *Match,long Countdown,const char *Color)
|
|
||||||
{
|
|
||||||
extern const char *Txt_Countdown;
|
|
||||||
char *Class;
|
|
||||||
bool PutForm = Match->Status.Showing != Mch_END;
|
|
||||||
|
|
||||||
if (PutForm)
|
|
||||||
{
|
|
||||||
/***** Start form *****/
|
|
||||||
Frm_StartForm (ActMchCntDwn);
|
|
||||||
Mch_PutParamMchCod (Match->MchCod); // Current match being played
|
|
||||||
Par_PutHiddenParamLong (NULL,"Countdown",Countdown);
|
|
||||||
|
|
||||||
/***** Set class *****/
|
|
||||||
if (asprintf (&Class,"BT_LINK MCH_BUTTON_ON %s",Color) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/***** Set class *****/
|
|
||||||
if (asprintf (&Class,"BT_LINK_OFF MCH_BUTTON_HIDDEN %s",Color) < 0)
|
|
||||||
Lay_NotEnoughMemoryExit ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Put icon *****/
|
|
||||||
HTM_DIV_Begin ("class=\"MCH_SMALLBUTTON_CONT\"");
|
|
||||||
|
|
||||||
if (PutForm)
|
|
||||||
HTM_BUTTON_OnMouseDown_Begin (Txt_Countdown,Class,NULL);
|
|
||||||
else
|
|
||||||
HTM_BUTTON_BUTTON_Begin (NULL,Class,NULL);
|
|
||||||
|
|
||||||
if (Countdown >= 0)
|
|
||||||
HTM_TxtF (" %ld″",Countdown);
|
|
||||||
else
|
|
||||||
HTM_Txt (" ∞ ");
|
|
||||||
|
|
||||||
HTM_BUTTON_End ();
|
|
||||||
|
|
||||||
HTM_DIV_End ();
|
|
||||||
|
|
||||||
/***** Free class *****/
|
|
||||||
free (Class);
|
|
||||||
|
|
||||||
/***** End form *****/
|
|
||||||
if (PutForm)
|
|
||||||
Frm_EndForm ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Mch_PutCountdownAndHourglassIcon (struct Match *Match)
|
|
||||||
{
|
|
||||||
extern const char *Txt_Countdown;
|
|
||||||
const char *Class;
|
|
||||||
const char *Icon;
|
|
||||||
|
|
||||||
/***** Set hourglass icon depending on countdown *****/
|
|
||||||
if (Match->Status.Showing == Mch_END) // Match over
|
|
||||||
{
|
|
||||||
Class = "BT_LINK_OFF MCH_BUTTON_HIDDEN MCH_GREEN";
|
|
||||||
Icon = "fa-hourglass-start";
|
|
||||||
}
|
|
||||||
else if (Match->Status.Countdown < 0) // No countdown
|
|
||||||
{
|
|
||||||
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_GREEN";
|
|
||||||
Icon = "fa-hourglass-start";
|
|
||||||
}
|
|
||||||
else if (Match->Status.Countdown > Mch_COUNTDOWN_SECONDS_MEDIUM) // Countdown in progress
|
|
||||||
{
|
|
||||||
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_LIMEGREEN";
|
|
||||||
Icon = "fa-hourglass-start";
|
|
||||||
}
|
|
||||||
else if (Match->Status.Countdown > Mch_COUNTDOWN_SECONDS_SMALL) // Countdown in progress
|
|
||||||
{
|
|
||||||
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_YELLOW";
|
|
||||||
Icon = "fa-hourglass-half";
|
|
||||||
}
|
|
||||||
else // Countdown about to end
|
|
||||||
{
|
|
||||||
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_RED";
|
|
||||||
Icon = "fa-hourglass-end";
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Write countdown and put hourglass icon *****/
|
|
||||||
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
|
|
||||||
HTM_BUTTON_BUTTON_Begin (Txt_Countdown,Class,NULL);
|
|
||||||
|
|
||||||
/* Countdown */
|
|
||||||
if (Match->Status.Countdown > 0)
|
|
||||||
HTM_TxtF (" %02ld″",Match->Status.Countdown);
|
|
||||||
else
|
|
||||||
HTM_NBSP ();
|
|
||||||
HTM_BR ();
|
|
||||||
|
|
||||||
/* Icon */
|
|
||||||
HTM_TxtF ("<i class=\"fas %s\"></i>",Icon);
|
|
||||||
|
|
||||||
HTM_BUTTON_End ();
|
|
||||||
HTM_DIV_End ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************** Write number of responders to a match question **************/
|
/*************** Write number of responders to a match question **************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2472,6 +2325,147 @@ static void Mch_WriteNumRespondersQst (struct Match *Match)
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*************** Write current countdown and hourglass icon ******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_PutCountdownAndHourglassIcon (struct Match *Match)
|
||||||
|
{
|
||||||
|
extern const char *Txt_Countdown;
|
||||||
|
const char *Class;
|
||||||
|
const char *Icon;
|
||||||
|
|
||||||
|
/***** Set hourglass icon depending on countdown *****/
|
||||||
|
if (Match->Status.Showing == Mch_END) // Match over
|
||||||
|
{
|
||||||
|
Class = "BT_LINK_OFF MCH_BUTTON_HIDDEN MCH_GREEN";
|
||||||
|
Icon = "fa-hourglass-start";
|
||||||
|
}
|
||||||
|
else if (Match->Status.Countdown < 0) // No countdown
|
||||||
|
{
|
||||||
|
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_GREEN";
|
||||||
|
Icon = "fa-hourglass-start";
|
||||||
|
}
|
||||||
|
else if (Match->Status.Countdown > Mch_COUNTDOWN_SECONDS_MEDIUM) // Countdown in progress
|
||||||
|
{
|
||||||
|
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_LIMEGREEN";
|
||||||
|
Icon = "fa-hourglass-start";
|
||||||
|
}
|
||||||
|
else if (Match->Status.Countdown > Mch_COUNTDOWN_SECONDS_SMALL) // Countdown in progress
|
||||||
|
{
|
||||||
|
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_YELLOW";
|
||||||
|
Icon = "fa-hourglass-half";
|
||||||
|
}
|
||||||
|
else // Countdown about to end
|
||||||
|
{
|
||||||
|
Class = "BT_LINK_OFF MCH_BUTTON_OFF MCH_RED";
|
||||||
|
Icon = "fa-hourglass-end";
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Write countdown and put hourglass icon *****/
|
||||||
|
HTM_DIV_Begin ("class=\"MCH_SHOW_HOURGLASS\"");
|
||||||
|
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
|
||||||
|
HTM_BUTTON_BUTTON_Begin (Txt_Countdown,Class,NULL);
|
||||||
|
|
||||||
|
/* Countdown */
|
||||||
|
if (Match->Status.Countdown > 0)
|
||||||
|
HTM_TxtF (" %02ld″",Match->Status.Countdown);
|
||||||
|
else
|
||||||
|
HTM_NBSP ();
|
||||||
|
HTM_BR ();
|
||||||
|
|
||||||
|
/* Icon */
|
||||||
|
HTM_TxtF ("<i class=\"fas %s\"></i>",Icon);
|
||||||
|
|
||||||
|
HTM_BUTTON_End ();
|
||||||
|
HTM_DIV_End ();
|
||||||
|
HTM_DIV_End ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************** Put all forms to start countdowns **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_PutFormsCountdown (struct Match *Match)
|
||||||
|
{
|
||||||
|
/***** Start container *****/
|
||||||
|
HTM_DIV_Begin ("class=\"MCH_SHOW_HOURGLASS\"");
|
||||||
|
|
||||||
|
/***** Put forms to start countdown *****/
|
||||||
|
Mch_PutFormCountdown (Match,-1 ,"MCH_GREEN" );
|
||||||
|
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_LARGE ,"MCH_LIMEGREEN");
|
||||||
|
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_MEDIUM,"MCH_YELLOW" );
|
||||||
|
Mch_PutFormCountdown (Match,Mch_COUNTDOWN_SECONDS_SMALL ,"MCH_RED" );
|
||||||
|
|
||||||
|
/***** End container *****/
|
||||||
|
HTM_DIV_End ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/****** Put a form to start a countdown with a given number of seconds *******/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_PutFormCountdown (struct Match *Match,long Seconds,const char *Color)
|
||||||
|
{
|
||||||
|
extern const char *Txt_Countdown;
|
||||||
|
char *OnSubmit;
|
||||||
|
char *Class;
|
||||||
|
bool PutForm = Match->Status.Showing != Mch_END;
|
||||||
|
|
||||||
|
if (PutForm)
|
||||||
|
{
|
||||||
|
/***** Start form *****/
|
||||||
|
if (asprintf (&OnSubmit,"updateMatchTch('match_left',"
|
||||||
|
"'act=%ld&ses=%s&MchCod=%ld&Countdown=%ld');"
|
||||||
|
" return false;", // return false is necessary to not submit form
|
||||||
|
Act_GetActCod (ActMchCntDwn),Gbl.Session.Id,
|
||||||
|
Match->MchCod,Seconds) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
Frm_StartFormOnSubmit (ActUnk,OnSubmit);
|
||||||
|
|
||||||
|
/***** Set class *****/
|
||||||
|
if (asprintf (&Class,"BT_LINK MCH_BUTTON_ON %s",Color) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Set class *****/
|
||||||
|
if (asprintf (&Class,"BT_LINK_OFF MCH_BUTTON_HIDDEN %s",Color) < 0)
|
||||||
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Put icon *****/
|
||||||
|
HTM_DIV_Begin ("class=\"MCH_SMALLBUTTON_CONT\"");
|
||||||
|
|
||||||
|
if (PutForm)
|
||||||
|
HTM_BUTTON_SUBMIT_Begin (Txt_Countdown,Class,NULL);
|
||||||
|
else
|
||||||
|
HTM_BUTTON_BUTTON_Begin (NULL,Class,NULL);
|
||||||
|
|
||||||
|
HTM_NBSP ();
|
||||||
|
if (Seconds >= 0)
|
||||||
|
HTM_TxtF ("%ld″",Seconds);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HTM_Txt ("∞");
|
||||||
|
HTM_NBSP ();
|
||||||
|
}
|
||||||
|
|
||||||
|
HTM_BUTTON_End ();
|
||||||
|
|
||||||
|
HTM_DIV_End ();
|
||||||
|
|
||||||
|
/***** Free class *****/
|
||||||
|
free (Class);
|
||||||
|
|
||||||
|
/***** End form *****/
|
||||||
|
if (PutForm)
|
||||||
|
{
|
||||||
|
Frm_EndForm ();
|
||||||
|
free (OnSubmit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/********** Show right column when playing a match (as a teacher) ************/
|
/********** Show right column when playing a match (as a teacher) ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2790,7 +2784,7 @@ static void Mch_PutIfAnswered (const struct Match *Match,bool Answered)
|
||||||
Frm_StartForm (ActSeeMchAnsQstStd);
|
Frm_StartForm (ActSeeMchAnsQstStd);
|
||||||
Mch_PutParamMchCod (Match->MchCod); // Current match being played
|
Mch_PutParamMchCod (Match->MchCod); // Current match being played
|
||||||
|
|
||||||
HTM_BUTTON_OnMouseDown_Begin (Txt_View_my_answer,"BT_LINK DAT_SMALL_GREEN",NULL);
|
HTM_BUTTON_OnMouseDown_Begin (Txt_View_my_answer,"BT_LINK DAT_SMALL_GREEN");
|
||||||
HTM_TxtF ("<i class=\"%s\"></i>","fas fa-check-circle");
|
HTM_TxtF ("<i class=\"%s\"></i>","fas fa-check-circle");
|
||||||
HTM_TxtF (" %s",Txt_MATCH_QUESTION_Answered);
|
HTM_TxtF (" %s",Txt_MATCH_QUESTION_Answered);
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
|
@ -2834,7 +2828,7 @@ static void Mch_PutIconToRemoveMyAnswer (const struct Match *Match)
|
||||||
|
|
||||||
/***** Put icon with link *****/
|
/***** Put icon with link *****/
|
||||||
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
|
HTM_DIV_Begin ("class=\"MCH_BIGBUTTON_CONT\"");
|
||||||
HTM_BUTTON_OnMouseDown_Begin (Txt_Delete_my_answer,"BT_LINK MCH_BUTTON_ON ICO_DARKRED",NULL);
|
HTM_BUTTON_OnMouseDown_Begin (Txt_Delete_my_answer,"BT_LINK MCH_BUTTON_ON ICO_DARKRED");
|
||||||
HTM_Txt ("<i class=\"fas fa-trash\"></i>");
|
HTM_Txt ("<i class=\"fas fa-trash\"></i>");
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
|
@ -3002,7 +2996,7 @@ static bool Mch_ShowQuestionAndAnswersStd (const struct Match *Match,
|
||||||
"",
|
"",
|
||||||
'A' + (char) NumOpt) < 0)
|
'A' + (char) NumOpt) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
HTM_BUTTON_OnMouseDown_Begin (NULL,Class,NULL);
|
HTM_BUTTON_OnMouseDown_Begin (NULL,Class);
|
||||||
HTM_TxtF ("%c",'a' + (char) NumOpt);
|
HTM_TxtF ("%c",'a' + (char) NumOpt);
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
free (Class);
|
free (Class);
|
||||||
|
@ -3113,7 +3107,7 @@ static void Mch_ShowMatchScore (const struct Match *Match)
|
||||||
for (;
|
for (;
|
||||||
NumRow < NumRowForThisScore;
|
NumRow < NumRowForThisScore;
|
||||||
NumRow++)
|
NumRow++)
|
||||||
Mch_DrawEmptyRowScore (NumRow,MinScore,MaxScore);
|
Mch_DrawEmptyScoreRow (NumRow,MinScore,MaxScore);
|
||||||
|
|
||||||
/***** Draw row for this score *****/
|
/***** Draw row for this score *****/
|
||||||
Mch_DrawScoreRow (Score,MinScore,MaxScore,NumRow,NumUsrs,MaxUsrs);
|
Mch_DrawScoreRow (Score,MinScore,MaxScore,NumRow,NumUsrs,MaxUsrs);
|
||||||
|
@ -3124,7 +3118,7 @@ static void Mch_ShowMatchScore (const struct Match *Match)
|
||||||
for (;
|
for (;
|
||||||
NumRow < Mch_NUM_ROWS_SCORE;
|
NumRow < Mch_NUM_ROWS_SCORE;
|
||||||
NumRow++)
|
NumRow++)
|
||||||
Mch_DrawEmptyRowScore (NumRow,MinScore,MaxScore);
|
Mch_DrawEmptyScoreRow (NumRow,MinScore,MaxScore);
|
||||||
|
|
||||||
/***** End table *****/
|
/***** End table *****/
|
||||||
HTM_TABLE_End ();
|
HTM_TABLE_End ();
|
||||||
|
@ -3133,7 +3127,11 @@ static void Mch_ShowMatchScore (const struct Match *Match)
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Mch_DrawEmptyRowScore (unsigned NumRow,double MinScore,double MaxScore)
|
/*****************************************************************************/
|
||||||
|
/*************************** Draw empty score row ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Mch_DrawEmptyScoreRow (unsigned NumRow,double MinScore,double MaxScore)
|
||||||
{
|
{
|
||||||
/***** Draw row *****/
|
/***** Draw row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -3159,6 +3157,10 @@ static void Mch_DrawEmptyRowScore (unsigned NumRow,double MinScore,double MaxSco
|
||||||
HTM_TR_End ();
|
HTM_TR_End ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************************* Draw score row ******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
|
static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
|
||||||
unsigned NumRow,unsigned NumUsrs,unsigned MaxUsrs)
|
unsigned NumRow,unsigned NumUsrs,unsigned MaxUsrs)
|
||||||
{
|
{
|
||||||
|
@ -3292,6 +3294,10 @@ static void Mch_PutBigButton (Act_Action_t NextAction,const char *Id,
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************** Put a big button hidden **************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_PutBigButtonHidden (const char *Icon)
|
static void Mch_PutBigButtonHidden (const char *Icon)
|
||||||
{
|
{
|
||||||
/***** Put inactive icon *****/
|
/***** Put inactive icon *****/
|
||||||
|
@ -3301,6 +3307,9 @@ static void Mch_PutBigButtonHidden (const char *Icon)
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Put a big button to close window *********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_PutBigButtonClose (void)
|
static void Mch_PutBigButtonClose (void)
|
||||||
{
|
{
|
||||||
|
@ -3344,6 +3353,10 @@ static void Mch_RemoveOldPlayers (void)
|
||||||
Cfg_SECONDS_TO_REFRESH_MATCH_STD*3);
|
Cfg_SECONDS_TO_REFRESH_MATCH_STD*3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************** Update match as being played *************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_UpdateMatchAsBeingPlayed (long MchCod)
|
static void Mch_UpdateMatchAsBeingPlayed (long MchCod)
|
||||||
{
|
{
|
||||||
/***** Insert match as being played *****/
|
/***** Insert match as being played *****/
|
||||||
|
@ -3352,6 +3365,10 @@ static void Mch_UpdateMatchAsBeingPlayed (long MchCod)
|
||||||
MchCod);
|
MchCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**************** Update match as paused, not being played *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_SetMatchAsNotBeingPlayed (long MchCod)
|
static void Mch_SetMatchAsNotBeingPlayed (long MchCod)
|
||||||
{
|
{
|
||||||
/***** Delete all match players ******/
|
/***** Delete all match players ******/
|
||||||
|
@ -3367,6 +3384,10 @@ static void Mch_SetMatchAsNotBeingPlayed (long MchCod)
|
||||||
MchCod);
|
MchCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********************** Get if match is being played ************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static bool Mch_GetIfMatchIsBeingPlayed (long MchCod)
|
static bool Mch_GetIfMatchIsBeingPlayed (long MchCod)
|
||||||
{
|
{
|
||||||
/***** Get if a match is being played or not *****/
|
/***** Get if a match is being played or not *****/
|
||||||
|
@ -3377,6 +3398,10 @@ static bool Mch_GetIfMatchIsBeingPlayed (long MchCod)
|
||||||
MchCod) != 0);
|
MchCod) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*************************** Get number of players ***************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
static void Mch_GetNumPlayers (struct Match *Match)
|
static void Mch_GetNumPlayers (struct Match *Match)
|
||||||
{
|
{
|
||||||
/***** Get number of players who are playing a match *****/
|
/***** Get number of players who are playing a match *****/
|
||||||
|
@ -3555,11 +3580,11 @@ void Mch_RefreshMatchTch (void)
|
||||||
switch (WhatToRefresh)
|
switch (WhatToRefresh)
|
||||||
{
|
{
|
||||||
case REFRESH_LEFT: // Refresh only left part
|
case REFRESH_LEFT: // Refresh only left part
|
||||||
HTM_Txt ("match_left|");
|
HTM_Txt ("match_left|0|"); // 0 ==> do not evaluate MatJax scripts after updating HTML
|
||||||
Mch_ShowRefreshablePartTch (&Match);
|
Mch_ShowRefreshablePartTch (&Match);
|
||||||
break;
|
break;
|
||||||
case REFRESH_ALL: // Refresh the whole page
|
case REFRESH_ALL: // Refresh the whole page
|
||||||
HTM_Txt ("match|");
|
HTM_Txt ("match|1|"); // 1 ==> evaluate MatJax scripts after updating HTML
|
||||||
Mch_ShowMatchStatusForTch (&Match);
|
Mch_ShowMatchStatusForTch (&Match);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue