swad-core/swad_match.h

129 lines
4.6 KiB
C
Raw Normal View History

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.
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
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 ***********************************/
/*****************************************************************************/
#include "swad_scope.h"
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
#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
2019-09-28 02:31:42 +02:00
#define Mch_NUM_SHOWING 4
typedef enum
{
Mch_NOTHING, // Don't show anything
Mch_STEM, // Showing only the question stem
Mch_ANSWERS, // Showing the question stem and the answers
Mch_RESULTS, // Showing the results
} Mch_Showing_t;
#define Mch_SHOWING_DEFAULT Mch_NOTHING
struct Match
{
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
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 *****************************/
/*****************************************************************************/
void Mch_ListMatches (struct Game *Game,bool PutFormNewMatch);
2019-09-28 02:31:42 +02:00
void Mch_GetDataOfMatchByCod (struct Match *Match);
2019-09-14 12:59:34 +02:00
2019-09-25 21:58:12 +02:00
void Mch_ToggleVisibilResultsMchUsr (void);
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);
void Mch_RemoveMatchInCourseFromAllTables (long CrsCod);
2019-09-29 23:13:20 +02:00
void Mch_RemoveUsrFromMatchTablesInCrs (long UsrCod,long CrsCod);
2019-09-27 21:45:53 +02:00
2019-09-30 01:10:57 +02:00
void Mch_PutParamsEdit (void);
2019-09-29 22:38:32 +02:00
void Mch_GetAndCheckParameters (struct Game *Game,struct Match *Match);
2019-09-28 02:31:42 +02:00
long Mch_GetParamMchCod (void);
2019-09-14 12:59:34 +02:00
void Mch_CreateNewMatchTch (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,
unsigned Indexes[Tst_MAX_OPTIONS_PER_QUESTION]);
2019-09-27 20:22:32 +02:00
void Mch_RemoveGroup (long GrpCod);
void Mch_RemoveGroupsOfType (long GrpTypCod);
2019-10-18 00:05:21 +02:00
void Mch_PlayPauseMatch (void);
2019-09-25 21:58:12 +02:00
void Mch_ToggleVisibilResultsMchQst (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
2019-09-28 02:31:42 +02:00
unsigned Mch_GetNumMchsInGame (long GamCod);
2019-09-26 01:15:21 +02:00
2019-09-29 19:36:32 +02:00
bool Mch_CheckIfICanPlayThisMatchBasedOnGrps (long MchCod);
2019-09-14 12:59:34 +02:00
void Mch_GetMatchBeingPlayed (void);
2019-09-29 21:33:27 +02:00
void Mch_JoinMatchAsStd (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);
2019-09-14 12:59:34 +02:00
2019-09-16 00:15:40 +02:00
void Mch_GetAndDrawBarNumUsrsWhoHaveChosenAns (long MchCod,unsigned QstInd,unsigned AnsInd,
unsigned NumAnswerersQst,bool Correct);
unsigned Mch_GetNumUsrsWhoHaveAnswerQst (long MchCod,unsigned QstInd);
2019-09-14 12:59:34 +02:00
2019-09-30 01:10:57 +02:00
void Mch_SetParamCurrentMchCod (long MchCod);
2019-09-14 12:59:34 +02:00
#endif