Version20.7

This commit is contained in:
acanas 2020-11-25 01:50:13 +01:00
parent e85c2105c7
commit 1bb6dab8aa
18 changed files with 323 additions and 2260 deletions

File diff suppressed because it is too large Load Diff

View File

@ -750,8 +750,9 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActReqRemMch ] = {1783,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_RequestRemoveMatch ,NULL},
[ActRemMch ] = {1784,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_RemoveMatch ,NULL},
[ActEdiMch ] = {1913,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_EditMatch ,NULL},
[ActChgMch ] = {1914,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Mch_ChangeMatch ,NULL},
[ActReqNewMch ] = {1670,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RequestNewMatch ,NULL},
[ActNewMch ] = {1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Mch_CreateNewMatchTch ,Mch_ResumeMatch ,NULL},
[ActNewMch ] = {1671,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Mch_CreateNewMatch ,Mch_ResumeMatch ,NULL},
[ActResMch ] = {1785,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,Mch_GetMatchBeingPlayed ,Mch_ResumeMatch ,NULL},
[ActBckMch ] = {1790,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_BackMatch ,NULL},
[ActPlyPauMch ] = {1789,-1,TabUnk,ActSeeAllGam ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_2ND_TAB,Mch_GetMatchBeingPlayed ,Mch_PlayPauseMatch ,NULL},
@ -3730,6 +3731,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActChgRooMAC, // #1911
ActLstOneGam, // #1912
ActEdiMch, // #1913
ActChgMch, // #1914
};
/*****************************************************************************/

View File

@ -64,7 +64,7 @@ typedef enum
typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action
#define Act_MAX_ACTION_COD 1913
#define Act_MAX_ACTION_COD 1914
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
@ -651,10 +651,10 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActRcvCfgTst (ActChgCrsTT1stDay + 126)
#define ActReqSeeMyTstRes (ActChgCrsTT1stDay + 127)
#define ActSeeMyTstResCrs (ActChgCrsTT1stDay + 128)
#define ActSeeMyTstResCrs (ActChgCrsTT1stDay + 128)
#define ActSeeOneTstResMe (ActChgCrsTT1stDay + 129)
#define ActReqSeeUsrTstRes (ActChgCrsTT1stDay + 130)
#define ActSeeUsrTstResCrs (ActChgCrsTT1stDay + 131)
#define ActSeeUsrTstResCrs (ActChgCrsTT1stDay + 131)
#define ActSeeOneTstResOth (ActChgCrsTT1stDay + 132)
#define ActSeeExa (ActChgCrsTT1stDay + 133)
@ -712,70 +712,71 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActReqRemMch (ActChgCrsTT1stDay + 179)
#define ActRemMch (ActChgCrsTT1stDay + 180)
#define ActEdiMch (ActChgCrsTT1stDay + 181)
#define ActReqNewMch (ActChgCrsTT1stDay + 182)
#define ActNewMch (ActChgCrsTT1stDay + 183)
#define ActResMch (ActChgCrsTT1stDay + 184)
#define ActBckMch (ActChgCrsTT1stDay + 185)
#define ActPlyPauMch (ActChgCrsTT1stDay + 186)
#define ActFwdMch (ActChgCrsTT1stDay + 187)
#define ActChgNumColMch (ActChgCrsTT1stDay + 188)
#define ActChgVisResMchQst (ActChgCrsTT1stDay + 189)
#define ActMchCntDwn (ActChgCrsTT1stDay + 190)
#define ActRefMchTch (ActChgCrsTT1stDay + 191)
#define ActChgMch (ActChgCrsTT1stDay + 182)
#define ActReqNewMch (ActChgCrsTT1stDay + 183)
#define ActNewMch (ActChgCrsTT1stDay + 184)
#define ActResMch (ActChgCrsTT1stDay + 185)
#define ActBckMch (ActChgCrsTT1stDay + 186)
#define ActPlyPauMch (ActChgCrsTT1stDay + 187)
#define ActFwdMch (ActChgCrsTT1stDay + 188)
#define ActChgNumColMch (ActChgCrsTT1stDay + 189)
#define ActChgVisResMchQst (ActChgCrsTT1stDay + 190)
#define ActMchCntDwn (ActChgCrsTT1stDay + 191)
#define ActRefMchTch (ActChgCrsTT1stDay + 192)
#define ActJoiMch (ActChgCrsTT1stDay + 192)
#define ActSeeMchAnsQstStd (ActChgCrsTT1stDay + 193)
#define ActRemMchAnsQstStd (ActChgCrsTT1stDay + 194)
#define ActAnsMchQstStd (ActChgCrsTT1stDay + 195)
#define ActRefMchStd (ActChgCrsTT1stDay + 196)
#define ActJoiMch (ActChgCrsTT1stDay + 193)
#define ActSeeMchAnsQstStd (ActChgCrsTT1stDay + 194)
#define ActRemMchAnsQstStd (ActChgCrsTT1stDay + 195)
#define ActAnsMchQstStd (ActChgCrsTT1stDay + 196)
#define ActRefMchStd (ActChgCrsTT1stDay + 197)
#define ActSeeMyMchResCrs (ActChgCrsTT1stDay + 197)
#define ActSeeMyMchResGam (ActChgCrsTT1stDay + 198)
#define ActSeeMyMchResMch (ActChgCrsTT1stDay + 199)
#define ActSeeOneMchResMe (ActChgCrsTT1stDay + 200)
#define ActSeeMyMchResCrs (ActChgCrsTT1stDay + 198)
#define ActSeeMyMchResGam (ActChgCrsTT1stDay + 199)
#define ActSeeMyMchResMch (ActChgCrsTT1stDay + 200)
#define ActSeeOneMchResMe (ActChgCrsTT1stDay + 201)
#define ActReqSeeUsrMchRes (ActChgCrsTT1stDay + 201)
#define ActSeeUsrMchResCrs (ActChgCrsTT1stDay + 202)
#define ActSeeUsrMchResGam (ActChgCrsTT1stDay + 203)
#define ActSeeUsrMchResMch (ActChgCrsTT1stDay + 204)
#define ActSeeOneMchResOth (ActChgCrsTT1stDay + 205)
#define ActReqSeeUsrMchRes (ActChgCrsTT1stDay + 202)
#define ActSeeUsrMchResCrs (ActChgCrsTT1stDay + 203)
#define ActSeeUsrMchResGam (ActChgCrsTT1stDay + 204)
#define ActSeeUsrMchResMch (ActChgCrsTT1stDay + 205)
#define ActSeeOneMchResOth (ActChgCrsTT1stDay + 206)
#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 206)
#define ActChgVisResMchUsr (ActChgCrsTT1stDay + 207)
#define ActLstOneGam (ActChgCrsTT1stDay + 207)
#define ActLstOneGam (ActChgCrsTT1stDay + 208)
#define ActFrmNewGam (ActChgCrsTT1stDay + 208)
#define ActEdiOneGam (ActChgCrsTT1stDay + 209)
#define ActNewGam (ActChgCrsTT1stDay + 210)
#define ActChgGam (ActChgCrsTT1stDay + 211)
#define ActReqRemGam (ActChgCrsTT1stDay + 212)
#define ActRemGam (ActChgCrsTT1stDay + 213)
#define ActHidGam (ActChgCrsTT1stDay + 214)
#define ActShoGam (ActChgCrsTT1stDay + 215)
#define ActAddOneGamQst (ActChgCrsTT1stDay + 216)
#define ActGamLstTstQst (ActChgCrsTT1stDay + 217)
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 218)
#define ActReqRemGamQst (ActChgCrsTT1stDay + 219)
#define ActRemGamQst (ActChgCrsTT1stDay + 220)
#define ActUp_GamQst (ActChgCrsTT1stDay + 221)
#define ActDwnGamQst (ActChgCrsTT1stDay + 222)
#define ActFrmNewGam (ActChgCrsTT1stDay + 209)
#define ActEdiOneGam (ActChgCrsTT1stDay + 210)
#define ActNewGam (ActChgCrsTT1stDay + 211)
#define ActChgGam (ActChgCrsTT1stDay + 212)
#define ActReqRemGam (ActChgCrsTT1stDay + 213)
#define ActRemGam (ActChgCrsTT1stDay + 214)
#define ActHidGam (ActChgCrsTT1stDay + 215)
#define ActShoGam (ActChgCrsTT1stDay + 216)
#define ActAddOneGamQst (ActChgCrsTT1stDay + 217)
#define ActGamLstTstQst (ActChgCrsTT1stDay + 218)
#define ActAddTstQstToGam (ActChgCrsTT1stDay + 219)
#define ActReqRemGamQst (ActChgCrsTT1stDay + 220)
#define ActRemGamQst (ActChgCrsTT1stDay + 221)
#define ActUp_GamQst (ActChgCrsTT1stDay + 222)
#define ActDwnGamQst (ActChgCrsTT1stDay + 223)
#define ActSeeSvy (ActChgCrsTT1stDay + 223)
#define ActAnsSvy (ActChgCrsTT1stDay + 224)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 225)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 226)
#define ActNewSvy (ActChgCrsTT1stDay + 227)
#define ActChgSvy (ActChgCrsTT1stDay + 228)
#define ActReqRemSvy (ActChgCrsTT1stDay + 229)
#define ActRemSvy (ActChgCrsTT1stDay + 230)
#define ActReqRstSvy (ActChgCrsTT1stDay + 231)
#define ActRstSvy (ActChgCrsTT1stDay + 232)
#define ActHidSvy (ActChgCrsTT1stDay + 233)
#define ActShoSvy (ActChgCrsTT1stDay + 234)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 235)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 236)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 237)
#define ActRemSvyQst (ActChgCrsTT1stDay + 238)
#define ActSeeSvy (ActChgCrsTT1stDay + 224)
#define ActAnsSvy (ActChgCrsTT1stDay + 225)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 226)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 227)
#define ActNewSvy (ActChgCrsTT1stDay + 228)
#define ActChgSvy (ActChgCrsTT1stDay + 229)
#define ActReqRemSvy (ActChgCrsTT1stDay + 230)
#define ActRemSvy (ActChgCrsTT1stDay + 231)
#define ActReqRstSvy (ActChgCrsTT1stDay + 232)
#define ActRstSvy (ActChgCrsTT1stDay + 233)
#define ActHidSvy (ActChgCrsTT1stDay + 234)
#define ActShoSvy (ActChgCrsTT1stDay + 235)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 236)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 237)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 238)
#define ActRemSvyQst (ActChgCrsTT1stDay + 239)
/*****************************************************************************/
/******************************** Files tab **********************************/

View File

@ -1381,7 +1381,7 @@ static void Asg_ShowLstGrpsToEditAssignment (long AsgCod)
NumGrpTyp++)
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
AsgCod,Grp_ASSIGNMENT);
Grp_ASSIGNMENT,AsgCod);
/***** End table and box *****/
Box_BoxTableEnd ();

View File

@ -1283,7 +1283,7 @@ static void Att_ShowLstGrpsToEditAttEvent (long AttCod)
NumGrpTyp++)
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
AttCod,Grp_ATT_EVENT);
Grp_ATT_EVENT,AttCod);
/***** End table and box *****/
Box_BoxTableEnd ();

View File

@ -555,9 +555,9 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 20.6 (2020-11-11)"
#define Log_PLATFORM_VERSION "SWAD 20.7 (2020-11-25)"
#define CSS_FILE "swad20.1.1.css"
#define JS_FILE "swad19.254.js"
#define JS_FILE "swad20.6.2.js"
/*
TODO: Juan Miguel Boyero Corral: Este verano ha habido varias personas que han solicitado incluir la funcionalidad del apartado de Actividades en SWADroid. Si lo ves viable podríamos estudiarlo.
@ -599,9 +599,12 @@ Muchas gracias,.
Juan Miguel.
TODO: Fix bug: un profesor editor no puede ver las carpetas de TFG (proyectos) de otros. Debería poder.
TODO: DNI de un estudiante sale erróneamente como ******* en lugar de mostrarse al ver los accesos de un estudiante a la asignatura.
TODO: Poder editar las partidas, al menos el título, y si es posible, también los grupos.
Version 20.7: Nov 25, 2020 Editing match title and groups. (304680 lines)
Version 20.6.2: Nov 24, 2020 Fixed JavaScript bug contracting folders. Reported by Christian Agustín Morillas Gutiérrez. (? lines)
Version 20.6.1: Nov 23, 2020 Fix bug while removing messages. Reported by Christian Agustín Morillas Gutiérrez. (304522 lines)
Version 20.6: Nov 11, 2020 Fixed bug and code refactoring in forums. (304516 lines)
Version 20.5.1: Nov 10, 2020 Fixed bug in file browser, reportedby Luis Javier Herrera Maldonado. (? lines)
Version 20.5: Oct 14, 2020 Code refactoring in remove icon. (304491 lines)

View File

@ -1761,7 +1761,7 @@ mysql> DESCRIBE mch_matches;
"UsrCod INT NOT NULL,"
"StartTime DATETIME NOT NULL,"
"EndTime DATETIME NOT NULL,"
"Title VARCHAR(2047) NOT NULL," // Gam_MAX_BYTES_TITLE
"Title VARCHAR(2047) NOT NULL," // Mch_MAX_BYTES_TITLE
"QstInd INT NOT NULL DEFAULT 0,"
"QstCod INT NOT NULL DEFAULT -1,"
"Showing ENUM('start','stem','answers','results','end') NOT NULL DEFAULT 'start',"

View File

@ -1377,8 +1377,7 @@ static void ExaSes_ShowLstGrpsToCreateSession (long SesCod)
NumGrpTyp++)
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
SesCod,
Grp_EXA_EVENT);
Grp_EXA_EVENT,SesCod);
/***** End table and box *****/
Box_BoxTableEnd ();

View File

@ -185,8 +185,9 @@ void Gam_ResetGames (struct Gam_Games *Games)
Games->CurrentPage = 0;
Games->ListQuestions = NULL;
Games->GamCodsSelected = NULL; // String with selected game codes separated by separator multiple
Games->GamCod = -1L; // Selected/current game code
Games->MchCod = -1L; // Selected/current match code
Games->GamCod = -1L; // Current/selected game code
Games->MchCod.Current =
Games->MchCod.Selected = -1L; // Current/selected match code
Games->QstInd = 0; // Current question index
}

View File

@ -72,7 +72,11 @@ struct Gam_Games
char *ListQuestions;
char *GamCodsSelected; // String with selected game codes separated by separator multiple
long GamCod; // Selected/current game code
long MchCod; // Selected/current match code
struct
{
long Selected; // Current match code
long Current;
} MchCod;
unsigned QstInd; // Current question index
};

View File

@ -1682,8 +1682,9 @@ static void Grp_WriteHeadingGroups (void)
/****** assignments, attendance events, surveys, exam events or matches ******/
/*****************************************************************************/
void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,long Cod,
Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp)
void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,
Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp,
long Cod) // Assignment, attendance event, survey, exam event or match
{
static const struct
{
@ -1736,9 +1737,11 @@ void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,long Cod,
"id=\"Grp%ld\" value=\"%ld\"%s%s"
" onclick=\"uncheckParent(this,'WholeCrs')\"",
Grp->GrpCod,Grp->GrpCod,
AssociatedToGrp ? " checked=\"checked\"" : "",
AssociatedToGrp ? " checked=\"checked\"" :
"",
(IBelongToThisGroup ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? "" : " disabled=\"disabled\"");
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? "" :
" disabled=\"disabled\"");
HTM_TD_End ();
Grp_WriteRowGrp (Grp,IBelongToThisGroup);
@ -1768,11 +1771,16 @@ static bool Grp_CheckIfAssociatedToGrp (const char *Table,const char *Field,
/*****************************************************************************/
/*************** Check if a survey is associated to any group ****************/
/*** Check if an assignment, attendance event, survey, exam event or match ***/
/*** is associated to any group ***/
/*****************************************************************************/
bool Grp_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod)
{
/***** Trivial check *****/
if (Cod <= 0) // Assignment, attendance event, survey, exam event or match code
return false;
/***** Get if an assignment, attendance event, survey, exam event or match
is associated to any group from database *****/
return (DB_QueryCOUNT ("can not check if associated to groups",

View File

@ -180,8 +180,9 @@ void Grp_RegisterUsrIntoGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGr
unsigned Grp_RemoveUsrFromGroups (struct UsrData *UsrDat,struct ListCodGrps *LstGrps);
void Grp_RemUsrFromAllGrpsInCrs (long UsrCod,long CrsCod);
void Grp_RemUsrFromAllGrps (long UsrCod);
void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,long Cod,
Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp);
void Grp_ListGrpsToEditAsgAttSvyEvtMch (struct GroupType *GrpTyp,
Grp_WhichIsAssociatedToGrp_t WhichIsAssociatedToGrp,
long Cod);
bool Grp_CheckIfAssociatedToGrps (const char *Table,const char *Field,long Cod);
void Grp_ReqRegisterInGrps (void);

View File

@ -115,10 +115,12 @@ static bool Mch_CheckIfICanEditMatches (void);
static bool Mch_CheckIfICanEditThisMatch (const struct Mch_Match *Match);
static bool Mch_CheckIfVisibilityOfResultsCanBeChanged (const struct Mch_Match *Match);
static void Mch_ListOneOrMoreMatchesIcons (struct Gam_Games *Games,
const struct Mch_Match *Match);
const struct Mch_Match *Match,
const char *Anchor);
static void Mch_ListOneOrMoreMatchesAuthor (const struct Mch_Match *Match);
static void Mch_ListOneOrMoreMatchesTimes (const struct Mch_Match *Match,unsigned UniqueId);
static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match);
static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match,
const char *Anchor);
static void Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (const struct Mch_Match *Match);
static void Mch_ListOneOrMoreMatchesNumPlayers (const struct Mch_Match *Match);
static void Mch_ListOneOrMoreMatchesStatus (struct Mch_Match *Match,unsigned NumQsts);
@ -143,10 +145,14 @@ static void Mch_RemoveMatchesMadeByUsrInCrsFromTable (long UsrCod,long CrsCod,co
static void Mch_PutParamsPlay (void *MchCod);
static void Mch_PutParamMchCod (long MchCod);
static void Mch_PutFormExistingMatch (struct Gam_Games *Games,
const struct Mch_Match *Match,
const char *Anchor);
static void Mch_PutFormNewMatch (const struct Gam_Game *Game);
static void Mch_ShowLstGrpsToCreateMatch (void);
static void Mch_ShowLstGrpsToEditMatch (long MchCod);
static void Mch_UpdateMatchTitleAndGrps (const struct Mch_Match *Match);
static long Mch_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]);
static long Mch_CreateMatch (long GamCod,char Title[Mch_MAX_BYTES_TITLE + 1]);
static void Mch_CreateIndexes (long GamCod,long MchCod);
static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
const struct Tst_Question *Question);
@ -377,7 +383,7 @@ void Mch_ListMatches (struct Gam_Games *Games,
case Rol_TCH:
case Rol_SYS_ADM:
if (PutFormNewMatch)
Mch_PutFormNewMatch (Game); // Form to fill in data and start playing a new match
Mch_PutFormNewMatch (Game); // Form to fill in data and start playing a new match
else
Gam_PutButtonNewMatch (Games,Game->GamCod); // Button to create a new match
break;
@ -475,6 +481,7 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
unsigned NumMatch;
unsigned UniqueId;
struct Mch_Match Match;
char *Anchor;
bool ICanEditMatches = Mch_CheckIfICanEditMatches ();
/***** Trivial check *****/
@ -500,12 +507,17 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
if (Mch_CheckIfICanPlayThisMatchBasedOnGrps (&Match))
{
/***** Begin row for this match ****/
/***** Build anchor string *****/
if (asprintf (&Anchor,"mch_%ld",Match.MchCod) < 0)
Lay_NotEnoughMemoryExit ();
/***** First row for this match with match data ****/
/* Begin first row */
HTM_TR_Begin (NULL);
/* Icons */
if (ICanEditMatches)
Mch_ListOneOrMoreMatchesIcons (Games,&Match);
Mch_ListOneOrMoreMatchesIcons (Games,&Match,Anchor);
/* Match player */
Mch_ListOneOrMoreMatchesAuthor (&Match);
@ -514,7 +526,7 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
Mch_ListOneOrMoreMatchesTimes (&Match,UniqueId);
/* Title and groups */
Mch_ListOneOrMoreMatchesTitleGrps (&Match);
Mch_ListOneOrMoreMatchesTitleGrps (&Match,Anchor);
/* Number of players who have played the match */
Mch_ListOneOrMoreMatchesNumPlayers (&Match);
@ -525,8 +537,28 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
/* Match result visible? */
Mch_ListOneOrMoreMatchesResult (Games,&Match);
/***** Begin row for this match ****/
HTM_TR_Begin (NULL);
/* End first row */
HTM_TR_End ();
/***** Second row for this match used for edition ****/
if (Match.MchCod == Games->MchCod.Selected)
/***** Check if I can edit this match *****/
if (Mch_CheckIfICanEditThisMatch (&Match))
{
/* Begin second row */
HTM_TR_Begin (NULL);
/* Form to edit match */
HTM_TD_Begin ("colspan=\"8\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
Mch_PutFormExistingMatch (Games,&Match,Anchor); // Form to fill in data and edit this match
HTM_TD_End ();
/* End second row */
HTM_TR_End ();
}
/***** Free anchor string *****/
free (Anchor);
}
}
@ -621,21 +653,22 @@ static bool Mch_CheckIfVisibilityOfResultsCanBeChanged (const struct Mch_Match *
/*****************************************************************************/
static void Mch_ListOneOrMoreMatchesIcons (struct Gam_Games *Games,
const struct Mch_Match *Match)
const struct Mch_Match *Match,
const char *Anchor)
{
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
if (Mch_CheckIfICanEditThisMatch (Match))
{
Games->GamCod = Match->GamCod;
Games->MchCod = Match->MchCod;
Games->GamCod = Match->GamCod;
Games->MchCod.Current = Match->MchCod;
/***** Put icon to remove the match *****/
Ico_PutContextualIconToRemove (ActReqRemMch,NULL,
Mch_PutParamsEdit,Games);
/***** Put icon to edit the match *****/
Ico_PutContextualIconToEdit (ActEdiMch,NULL,
Ico_PutContextualIconToEdit (ActEdiMch,Anchor,
Mch_PutParamsEdit,Games);
}
else
@ -688,12 +721,14 @@ static void Mch_ListOneOrMoreMatchesTimes (const struct Mch_Match *Match,unsigne
/***************** Put a column for match title and grous ********************/
/*****************************************************************************/
static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match)
static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match,
const char *Anchor)
{
extern const char *Txt_Play;
extern const char *Txt_Resume;
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
HTM_ARTICLE_Begin (Anchor);
/***** Match title *****/
Frm_StartForm (Gbl.Usrs.Me.Role.Logged == Rol_STD ? ActJoiMch :
@ -710,6 +745,7 @@ static void Mch_ListOneOrMoreMatchesTitleGrps (const struct Mch_Match *Match)
if (Gbl.Crs.Grps.NumGrps)
Mch_GetAndWriteNamesOfGrpsAssociatedToMatch (Match);
HTM_ARTICLE_End ();
HTM_TD_End ();
}
@ -857,7 +893,7 @@ static void Mch_ListOneOrMoreMatchesResultStd (struct Gam_Games *Games,
{
/* Result is visible by me */
Games->GamCod = Match->GamCod;
Games->MchCod = Match->MchCod;
Games->MchCod.Current = Match->MchCod;
Lay_PutContextualLinkOnlyIcon (ActSeeMyMchResMch,MchRes_RESULTS_BOX_ID,
Mch_PutParamsEdit,Games,
"trophy.svg",
@ -876,7 +912,7 @@ static void Mch_ListOneOrMoreMatchesResultTch (struct Gam_Games *Games,
extern const char *Txt_Results;
Games->GamCod = Match->GamCod;
Games->MchCod = Match->MchCod;
Games->MchCod.Current = Match->MchCod;
/***** Show match results *****/
if (Mch_CheckIfICanEditThisMatch (Match))
@ -983,10 +1019,10 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
StartEndTime++)
Match->TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[3 + StartEndTime]);
/* Get the title of the game (row[5]) */
/* Get the title of the match (row[5]) */
if (row[5])
Str_Copy (Match->Title,row[5],
Gam_MAX_BYTES_TITLE);
Mch_MAX_BYTES_TITLE);
else
Match->Title[0] = '\0';
@ -1071,8 +1107,6 @@ void Mch_RequestRemoveMatch (void)
Mch_GetAndCheckParameters (&Games,&Game,&Match);
/***** Show question and button to remove question *****/
Games.GamCod = Match.GamCod;
Games.MchCod = Match.MchCod;
Ale_ShowAlertAndButton (ActRemMch,NULL,NULL,
Mch_PutParamsEdit,&Games,
Btn_REMOVE_BUTTON,Txt_Remove_match,
@ -1305,10 +1339,6 @@ void Mch_EditMatch (void)
if (!Mch_CheckIfICanEditThisMatch (&Match))
Lay_NoPermissionExit ();
/***** Write message *****/
Ale_ShowAlert (Ale_SUCCESS,"Editando partida %s",
Match.Title);
/***** Show current game *****/
Gam_ShowOnlyOneGame (&Games,&Game,
false, // Do not list game questions
@ -1324,7 +1354,7 @@ void Mch_PutParamsEdit (void *Games)
if (Games)
{
Gam_PutParams (Games);
Mch_PutParamMchCod (((struct Gam_Games *) Games)->MchCod);
Mch_PutParamMchCod (((struct Gam_Games *) Games)->MchCod.Current);
}
}
@ -1375,6 +1405,11 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games,
Lay_ShowErrorAndExit ("Wrong game code.");
if (Game->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
Lay_ShowErrorAndExit ("Match does not belong to this course.");
/***** Initialize context *****/
Games->GamCod = Game->GamCod;
Games->MchCod.Current =
Games->MchCod.Selected = Match->MchCod;
}
/*****************************************************************************/
@ -1388,7 +1423,59 @@ long Mch_GetParamMchCod (void)
}
/*****************************************************************************/
/****** Put a big button to play match (start a new match) as a teacher ******/
/******************* Put a form to change and existing match *****************/
/*****************************************************************************/
static void Mch_PutFormExistingMatch (struct Gam_Games *Games,
const struct Mch_Match *Match,
const char *Anchor)
{
extern const char *Hlp_ASSESSMENT_Games_matches;
extern const char *Txt_Title;
extern const char *Txt_Save_changes;
/***** Begin form *****/
Frm_StartFormAnchor (ActChgMch,Anchor);
Mch_PutParamsEdit (Games);
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Match->Title,
NULL,NULL,
Hlp_ASSESSMENT_Games_matches,Box_CLOSABLE,2);
/***** Match title *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("RT","Title",Txt_Title);
/* Data */
HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_TEXT ("Title",Mch_MAX_CHARS_TITLE,Match->Title,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Title\" size=\"45\" required=\"required\"");
HTM_TD_End ();
HTM_TR_End ();
/***** Groups *****/
Mch_ShowLstGrpsToEditMatch (Match->MchCod);
/***** End table *****/
HTM_TABLE_End ();
/***** Put button to submit the form *****/
Btn_PutConfirmButton (Txt_Save_changes);
/***** End box *****/
Box_BoxEnd ();
/***** End form *****/
Frm_EndForm ();
}
/*****************************************************************************/
/********************** Put a form to create a new match *********************/
/*****************************************************************************/
static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
@ -1419,7 +1506,7 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
/* Data */
HTM_TD_Begin ("class=\"LT\"");
HTM_INPUT_TEXT ("Title",Gam_MAX_CHARS_TITLE,Game->Title,
HTM_INPUT_TEXT ("Title",Mch_MAX_CHARS_TITLE,Game->Title,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Title\" size=\"45\" required=\"required\"");
HTM_TD_End ();
@ -1427,7 +1514,7 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
HTM_TR_End ();
/***** Groups *****/
Mch_ShowLstGrpsToCreateMatch ();
Mch_ShowLstGrpsToEditMatch (-1L);
/***** End table *****/
HTM_TABLE_End ();
@ -1450,7 +1537,7 @@ static void Mch_PutFormNewMatch (const struct Gam_Game *Game)
/***************** Show list of groups to create a new match *****************/
/*****************************************************************************/
static void Mch_ShowLstGrpsToCreateMatch (void)
static void Mch_ShowLstGrpsToEditMatch (long MchCod)
{
extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_Groups;
@ -1480,8 +1567,10 @@ static void Mch_ShowLstGrpsToCreateMatch (void)
HTM_TD_Begin ("colspan=\"7\" class=\"DAT LM\"");
HTM_LABEL_Begin (NULL);
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"WholeCrs\" value=\"Y\" checked=\"checked\""
" onclick=\"uncheckChildren(this,'GrpCods')\"");
"id=\"WholeCrs\" value=\"Y\"%s"
" onclick=\"uncheckChildren(this,'GrpCods')\"",
Grp_CheckIfAssociatedToGrps ("mch_groups","MchCod",MchCod) ? "" :
" checked=\"checked\"");
HTM_TxtF ("%s&nbsp;%s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
HTM_LABEL_End ();
HTM_TD_End ();
@ -1494,8 +1583,7 @@ static void Mch_ShowLstGrpsToCreateMatch (void)
NumGrpTyp++)
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
-1L, // -1 means "New match"
Grp_MATCH);
Grp_MATCH,MchCod);
/***** End table and box *****/
Box_BoxTableEnd ();
@ -1511,10 +1599,10 @@ static void Mch_ShowLstGrpsToCreateMatch (void)
/********************* Create a new match (by a teacher) *********************/
/*****************************************************************************/
void Mch_CreateNewMatchTch (void)
void Mch_CreateNewMatch (void)
{
long GamCod;
char Title[Gam_MAX_BYTES_TITLE + 1];
char Title[Mch_MAX_BYTES_TITLE + 1];
/***** Get form parameters *****/
/* Get match code */
@ -1522,9 +1610,9 @@ void Mch_CreateNewMatchTch (void)
Lay_ShowErrorAndExit ("Code of game is missing.");
/* Get match title */
Par_GetParToText ("Title",Title,Gam_MAX_BYTES_TITLE);
Par_GetParToText ("Title",Title,Mch_MAX_BYTES_TITLE);
/* Get groups for this games */
/* Get groups for this match */
Grp_GetParCodsSeveralGrps ();
/***** Create a new match *****/
@ -1534,6 +1622,68 @@ void Mch_CreateNewMatchTch (void)
Grp_FreeListCodSelectedGrps ();
}
/*****************************************************************************/
/************************ Change a match (by a teacher) **********************/
/*****************************************************************************/
void Mch_ChangeMatch (void)
{
struct Gam_Games Games;
struct Gam_Game Game;
struct Mch_Match Match;
/***** Reset games context *****/
Gam_ResetGames (&Games);
/***** Reset game and match *****/
Gam_ResetGame (&Game);
Mch_ResetMatch (&Match);
/***** Get and check parameters *****/
Mch_GetAndCheckParameters (&Games,&Game,&Match);
/***** Check if I can update this match *****/
if (!Mch_CheckIfICanEditThisMatch (&Match))
Lay_NoPermissionExit ();
/***** Get match title and groups *****/
/* Get match title */
Par_GetParToText ("Title",Match.Title,Mch_MAX_BYTES_TITLE);
/* Get groups for this match */
Grp_GetParCodsSeveralGrps ();
/***** Update match *****/
Mch_UpdateMatchTitleAndGrps (&Match);
/***** Free memory for list of selected groups *****/
Grp_FreeListCodSelectedGrps ();
/***** Show current game *****/
Gam_ShowOnlyOneGame (&Games,&Game,
false, // Do not list game questions
false); // Do not put form to start new match
}
/*****************************************************************************/
/*************** Update title and groups of an existing match ****************/
/*****************************************************************************/
static void Mch_UpdateMatchTitleAndGrps (const struct Mch_Match *Match)
{
/***** Update match title into database *****/
DB_QueryUPDATE ("can not update match",
"UPDATE mch_matches SET Title='%s'"
" WHERE MchCod=%ld",
Match->Title,
Match->MchCod);
/***** Update groups associated to the match *****/
Mch_RemoveMatchFromTable (Match->MchCod,"mch_groups"); // Remove all groups associated to this match
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
Mch_CreateGrps (Match->MchCod); // Associate selected groups
}
/*****************************************************************************/
/******* Show button to actually start / resume a match (by a teacher) *******/
/*****************************************************************************/
@ -1571,7 +1721,7 @@ void Mch_ResumeMatch (void)
/********************** Create a new match in a game *************************/
/*****************************************************************************/
static long Mch_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
static long Mch_CreateMatch (long GamCod,char Title[Mch_MAX_BYTES_TITLE + 1])
{
long MchCod;

View File

@ -27,6 +27,7 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
#include "swad_game.h"
#include "swad_match_print.h"
#include "swad_scope.h"
#include "swad_test.h"
@ -35,6 +36,9 @@
/************************** Public types and constants ***********************/
/*****************************************************************************/
#define Mch_MAX_CHARS_TITLE Gam_MAX_CHARS_TITLE // 127
#define Mch_MAX_BYTES_TITLE ((Mch_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define Mch_NEW_MATCH_SECTION_ID "new_match"
#define Mch_AFTER_LAST_QUESTION ((unsigned)((1UL << 31) - 1)) // 2^31 - 1, don't change this number because it is used in database to indicate that a match is finished
@ -111,7 +115,8 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games,
struct Mch_Match *Match);
long Mch_GetParamMchCod (void);
void Mch_CreateNewMatchTch (void);
void Mch_CreateNewMatch (void);
void Mch_ChangeMatch (void);
void Mch_ResumeMatch (void);
void Mch_GetIndexes (long MchCod,unsigned QstInd,
unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]);

View File

@ -1007,8 +1007,8 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
HTM_TD_Begin ("class=\"RT LINE_LEFT COLOR%u\"",Gbl.RowEvenOdd);
if (ICanView.Result)
{
Games->GamCod = Match.GamCod;
Games->MchCod = Match.MchCod;
Games->GamCod = Match.GamCod;
Games->MchCod.Current = Match.MchCod;
switch (MeOrOther)
{
case Usr_ME:

View File

@ -148,7 +148,7 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
struct Media *Media);
static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Messages,
Msg_TypeOfMessages_t TypeOfMessages,long UsrCod,
long UsrCod,
const char *FilterFromToSubquery);
static void Msg_InsertReceivedMsgIntoDB (long MsgCod,long UsrCod,bool NotifyByEmail);
static void Msg_SetReceivedMsgAsReplied (long MsgCod);
@ -1063,8 +1063,8 @@ void Msg_DelAllRecMsgs (void)
Msg_MakeFilterFromToSubquery (&Messages,FilterFromToSubquery);
/***** Delete messages *****/
Messages.TypeOfMessages = Msg_RECEIVED;
NumMsgs = Msg_DelSomeRecOrSntMsgsUsr (&Messages,
Msg_RECEIVED,
Gbl.Usrs.Me.UsrDat.UsrCod,
FilterFromToSubquery);
Msg_ShowNumMsgsDeleted (NumMsgs);
@ -1091,8 +1091,8 @@ void Msg_DelAllSntMsgs (void)
Msg_MakeFilterFromToSubquery (&Messages,FilterFromToSubquery);
/***** Delete messages *****/
Messages.TypeOfMessages = Msg_SENT;
NumMsgs = Msg_DelSomeRecOrSntMsgsUsr (&Messages,
Msg_SENT,
Gbl.Usrs.Me.UsrDat.UsrCod,
FilterFromToSubquery);
Msg_ShowNumMsgsDeleted (NumMsgs);
@ -1446,7 +1446,7 @@ static long Msg_InsertNewMsg (const char *Subject,const char *Content,
/*****************************************************************************/
static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Messages,
Msg_TypeOfMessages_t TypeOfMessages,long UsrCod,
long UsrCod,
const char *FilterFromToSubquery)
{
MYSQL_RES *mysql_res;
@ -1469,7 +1469,7 @@ static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Mess
row = mysql_fetch_row (mysql_res);
if (sscanf (row[0],"%ld",&MsgCod) != 1)
Lay_ShowErrorAndExit ("Wrong code of message.");
switch (TypeOfMessages)
switch (Messages->TypeOfMessages)
{
case Msg_RECEIVED:
Msg_MoveReceivedMsgToDeleted (MsgCod,UsrCod);

View File

@ -2168,7 +2168,7 @@ static void Svy_ShowLstGrpsToEditSurvey (long SvyCod)
NumGrpTyp++)
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
SvyCod,Grp_SURVEY);
Grp_SURVEY,SvyCod);
/***** End table and box *****/
Box_BoxTableEnd ();

View File

@ -11261,7 +11261,7 @@ const char *Txt_Actions[Act_NUM_ACTIONS] =
#elif L==2 // de
"" // Need Übersetzung
#elif L==3 // en
"Create a new match show it in a new tab"
"Create a new match and show it in a new tab"
#elif L==4 // es
"Crear una nueva partida y mostrarla en una nueva pesta&ntilde;a"
#elif L==5 // fr
@ -11274,6 +11274,27 @@ const char *Txt_Actions[Act_NUM_ACTIONS] =
"" // Potrzebujesz tlumaczenie
#elif L==9 // pt
"" // Precisa de tradução
#endif
,
[ActChgMch] =
#if L==1 // ca
"" // Necessita traducció
#elif L==2 // de
"" // Need Übersetzung
#elif L==3 // en
"Change a match"
#elif L==4 // es
"Cambiar una partida"
#elif L==5 // fr
"" // Besoin de traduction
#elif L==6 // gn
"" // Okoteve traducción
#elif L==7 // it
"" // Bisogno di traduzione
#elif L==8 // pl
"" // Potrzebujesz tlumaczenie
#elif L==9 // pt
"" // Precisa de tradução
#endif
,
[ActResMch] =