2019-09-14 12:59:34 +02:00
|
|
|
|
// swad_match.h: matches in games using remote control
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_MCH
|
|
|
|
|
#define _SWAD_MCH
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance in Spanish),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 Antonio Ca<EFBFBD>as Vargas
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-11-25 01:50:13 +01:00
|
|
|
|
#include "swad_game.h"
|
2020-06-24 20:10:57 +02:00
|
|
|
|
#include "swad_match_print.h"
|
2019-09-14 12:59:34 +02:00
|
|
|
|
#include "swad_scope.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_test.h"
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Public types and constants ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-11-25 01:50:13 +01:00
|
|
|
|
#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
|
|
|
|
|
|
2019-09-14 12:59:34 +02:00
|
|
|
|
#define Mch_NEW_MATCH_SECTION_ID "new_match"
|
|
|
|
|
|
2019-12-10 21:52:22 +01:00
|
|
|
|
#define Mch_NUM_SHOWING 5
|
2019-09-28 02:31:42 +02:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2019-12-10 21:52:22 +01:00
|
|
|
|
Mch_START, // Start: don't show anything
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Mch_STEM, // Showing only the question stem
|
|
|
|
|
Mch_ANSWERS, // Showing the question stem and the answers
|
|
|
|
|
Mch_RESULTS, // Showing the results
|
2019-12-10 21:52:22 +01:00
|
|
|
|
Mch_END, // End: don't show anything
|
2019-09-28 02:31:42 +02:00
|
|
|
|
} Mch_Showing_t;
|
2019-12-10 21:52:22 +01:00
|
|
|
|
#define Mch_SHOWING_DEFAULT Mch_START
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
2021-09-24 21:49:06 +02:00
|
|
|
|
/* Columns */
|
|
|
|
|
#define Mch_MAX_COLS 4
|
|
|
|
|
#define Mch_NUM_COLS_DEFAULT 1
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
struct Mch_Match
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
long MchCod;
|
|
|
|
|
long GamCod;
|
|
|
|
|
long UsrCod;
|
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
|
|
|
|
char Title[Gam_MAX_BYTES_TITLE + 1];
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
unsigned QstInd; // 0 means that the game has not started. First question has index 1.
|
|
|
|
|
long QstCod;
|
|
|
|
|
time_t QstStartTimeUTC;
|
|
|
|
|
Mch_Showing_t Showing; // What is shown on teacher's screen
|
2019-12-12 18:24:23 +01:00
|
|
|
|
long Countdown; // > 0 ==> countdown in progress
|
|
|
|
|
// = 0 ==> countdown over ==> go to next step
|
|
|
|
|
// < 0 ==> no countdown at this time
|
2019-10-22 22:39:37 +02:00
|
|
|
|
unsigned NumCols; // Number of columns for answers on teacher's screen
|
2019-09-28 02:31:42 +02:00
|
|
|
|
bool ShowQstResults; // Show global results of current question while playing
|
|
|
|
|
bool ShowUsrResults; // Show exam with results of all questions for the student
|
|
|
|
|
bool Playing; // Is being played now?
|
|
|
|
|
unsigned NumPlayers;
|
|
|
|
|
} Status; // Status related to match playing
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Mch_UsrAnswer
|
|
|
|
|
{
|
|
|
|
|
int NumOpt; // < 0 ==> no answer selected
|
|
|
|
|
int AnsInd; // < 0 ==> no answer selected
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-14 12:59:34 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
long Mch_GetMchCodBeingPlayed (void);
|
|
|
|
|
|
2020-04-23 23:09:28 +02:00
|
|
|
|
void Mch_ResetMatch (struct Mch_Match *Match);
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
void Mch_ListMatches (struct Gam_Games *Games,
|
|
|
|
|
struct Gam_Game *Game,
|
|
|
|
|
bool PutFormNewMatch);
|
|
|
|
|
void Mch_GetDataOfMatchByCod (struct Mch_Match *Match);
|
2021-11-26 01:53:31 +01:00
|
|
|
|
void Mch_ListOneOrMoreMatchesAuthor (const struct Mch_Match *Match);
|
|
|
|
|
void Mch_ListOneOrMoreMatchesTimes (const struct Mch_Match *Match,unsigned UniqueId);
|
|
|
|
|
void Mch_ListOneOrMoreMatchesNumPlayers (const struct Mch_Match *Match);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
2020-05-16 02:04:36 +02:00
|
|
|
|
void Mch_ToggleVisResultsMchUsr (void);
|
2019-09-25 21:58:12 +02:00
|
|
|
|
|
2019-09-29 21:33:27 +02:00
|
|
|
|
void Mch_RequestRemoveMatch (void);
|
|
|
|
|
void Mch_RemoveMatch (void);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
2019-09-28 01:12:53 +02:00
|
|
|
|
void Mch_RemoveMatchesInGameFromAllTables (long GamCod);
|
2020-05-18 22:59:07 +02:00
|
|
|
|
void Mch_RemoveMatchesInCourseFromAllTables (long CrsCod);
|
|
|
|
|
void Mch_RemoveMatchesMadeByUsrInAllCrss (long UsrCod);
|
|
|
|
|
void Mch_RemoveMatchesMadeByUsrInCrs (long UsrCod,long CrsCod);
|
2019-09-27 21:45:53 +02:00
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
void Mch_EditMatch (void);
|
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
void Mch_PutParamsEdit (void *Games);
|
|
|
|
|
void Mch_GetAndCheckParameters (struct Gam_Games *Games,
|
|
|
|
|
struct Gam_Game *Game,
|
|
|
|
|
struct Mch_Match *Match);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
long Mch_GetParamMchCod (void);
|
|
|
|
|
|
2020-11-25 01:50:13 +01:00
|
|
|
|
void Mch_CreateNewMatch (void);
|
|
|
|
|
void Mch_ChangeMatch (void);
|
2019-09-29 21:33:27 +02:00
|
|
|
|
void Mch_ResumeMatch (void);
|
2019-09-24 01:41:51 +02:00
|
|
|
|
void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
2021-10-24 21:35:42 +02:00
|
|
|
|
unsigned Indexes[Qst_MAX_OPTIONS_PER_QUESTION]);
|
2019-09-27 20:22:32 +02:00
|
|
|
|
|
2019-10-18 00:05:21 +02:00
|
|
|
|
void Mch_PlayPauseMatch (void);
|
2019-10-23 00:49:03 +02:00
|
|
|
|
void Mch_ChangeNumColsMch (void);
|
2020-05-16 02:04:36 +02:00
|
|
|
|
void Mch_ToggleVisResultsMchQst (void);
|
2019-09-29 21:33:27 +02:00
|
|
|
|
void Mch_BackMatch (void);
|
|
|
|
|
void Mch_ForwardMatch (void);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
bool Mch_CheckIfICanPlayThisMatchBasedOnGrps (const struct Mch_Match *Match);
|
2020-03-27 22:02:01 +01:00
|
|
|
|
|
2020-04-08 03:06:45 +02:00
|
|
|
|
bool Mch_RegisterMeAsPlayerInMatch (struct Mch_Match *Match);
|
2019-09-29 19:36:32 +02:00
|
|
|
|
|
2019-09-14 12:59:34 +02:00
|
|
|
|
void Mch_GetMatchBeingPlayed (void);
|
2019-09-29 21:33:27 +02:00
|
|
|
|
void Mch_JoinMatchAsStd (void);
|
2020-08-26 12:06:25 +02:00
|
|
|
|
void Mch_RemMyQstAnsAndShowMchStatus (void);
|
|
|
|
|
void Mch_RemoveMyQuestionAnswer (const struct Mch_Match *Match,unsigned QstInd);
|
2019-12-13 23:38:29 +01:00
|
|
|
|
|
|
|
|
|
void Mch_StartCountdown (void);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
void Mch_RefreshMatchTch (void);
|
|
|
|
|
void Mch_RefreshMatchStd (void);
|
|
|
|
|
|
2019-09-28 02:31:42 +02:00
|
|
|
|
void Mch_GetQstAnsFromDB (long MchCod,long UsrCod,unsigned QstInd,
|
|
|
|
|
struct Mch_UsrAnswer *UsrAnswer);
|
2019-09-29 21:33:27 +02:00
|
|
|
|
void Mch_ReceiveQuestionAnswer (void);
|
2020-08-26 12:06:25 +02:00
|
|
|
|
void Mch_StoreQuestionAnswer (const struct Mch_Match *Match,unsigned QstInd,
|
2020-08-22 13:05:15 +02:00
|
|
|
|
struct Mch_UsrAnswer *UsrAnswer);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
2020-06-24 20:10:57 +02:00
|
|
|
|
void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print);
|
2020-05-18 14:34:31 +02:00
|
|
|
|
|
2020-03-12 13:53:37 +01:00
|
|
|
|
void Mch_DrawBarNumUsrs (unsigned NumRespondersAns,unsigned NumRespondersQst,bool Correct);
|
2019-09-14 12:59:34 +02:00
|
|
|
|
|
|
|
|
|
#endif
|