swad-core/swad_game.h

168 lines
5.6 KiB
C
Raw Permalink Normal View History

2017-09-07 18:38:18 +02:00
// swad_game.h: games using remote control
2017-07-09 20:31:40 +02:00
2017-09-07 18:38:18 +02:00
#ifndef _SWAD_GAM
#define _SWAD_GAM
2017-07-09 20:31:40 +02:00
/*
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-2024 Antonio Ca<EFBFBD>as Vargas
2017-07-09 20:31:40 +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 ***********************************/
/*****************************************************************************/
2019-09-22 19:50:24 +02:00
#include "swad_date.h"
2017-09-07 18:38:18 +02:00
#include "swad_scope.h"
2017-07-09 20:31:40 +02:00
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
2019-05-28 15:06:53 +02:00
#define Gam_MAX_CHARS_TITLE (128 - 1) // 127
#define Gam_MAX_BYTES_TITLE ((Gam_MAX_CHARS_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
2017-07-09 20:31:40 +02:00
#define Gam_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
2020-04-08 03:06:45 +02:00
#define Gam_NUM_ORDERS 3
typedef enum
{
Gam_ORDER_BY_START_DATE = 0,
Gam_ORDER_BY_END_DATE = 1,
Gam_ORDER_BY_TITLE = 2,
} Gam_Order_t;
#define Gam_ORDER_DEFAULT Gam_ORDER_BY_START_DATE
#define Gam_NUM_ANS_TYPES 2
typedef enum
{
Gam_ANS_UNIQUE_CHOICE = 0,
Gam_ANS_MULTIPLE_CHOICE = 1,
} Gam_AnswerType_t;
#define Gam_ANSWER_TYPE_DEFAULT Gam_ANS_UNIQUE_CHOICE
#define Gam_NUM_EXISTING_NEW_GAME 2
typedef enum
{
Gam_EXISTING_GAME,
Gam_NEW_GAME,
} Gam_ExistingNewGame_t;
2020-04-08 03:06:45 +02:00
struct Gam_GameSelected
2019-11-25 23:18:08 +01:00
{
long GamCod; // Game code
2020-03-30 18:54:17 +02:00
bool Selected; // Is this game selected when seeing match results?
2019-11-25 23:18:08 +01:00
};
struct Gam_Game
{
long GamCod; // Game code
long CrsCod; // Course code
long UsrCod; // Author code
double MaxGrade; // Score range [0...max.score]
// will be converted to
// grade range [0...max.grade]
unsigned Visibility; // Visibility of results
char Title[Gam_MAX_BYTES_TITLE + 1];
time_t TimeUTC[Dat_NUM_START_END_TIME];
HidVis_HiddenOrVisible_t HiddenOrVisible; // Game is hidden or visible?
unsigned NumQsts; // Number of questions in the game
unsigned NumMchs; // Number of matches in the game
unsigned NumUnfinishedMchs; // Number of unfinished matches in the game
};
2020-04-08 03:06:45 +02:00
struct Gam_Games
{
bool LstIsRead; // Is the list already read from database...
// ...or it needs to be read?
unsigned Num; // Total number of games
unsigned NumSelected; // Number of games selected
struct Gam_GameSelected *Lst;// List of games
Gam_Order_t SelectedOrder;
unsigned CurrentPage;
char *ListQuestions;
char *GamCodsSelected; // String with selected game codes separated by separator multiple
struct Gam_Game Game; // Selected/current game
long MchCod; // Selected/current match
2020-04-08 03:06:45 +02:00
unsigned QstInd; // Current question index
};
2017-07-09 20:31:40 +02:00
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
2020-04-08 03:06:45 +02:00
void Gam_ResetGames (struct Gam_Games *Games);
2020-04-23 23:09:28 +02:00
void Gam_ResetGame (struct Gam_Game *Game);
2020-04-08 03:06:45 +02:00
2017-09-07 18:38:18 +02:00
void Gam_SeeAllGames (void);
void Gam_ListAllGames (struct Gam_Games *Games);
2017-09-07 18:38:18 +02:00
void Gam_SeeOneGame (void);
2020-04-08 03:06:45 +02:00
void Gam_ShowOnlyOneGame (struct Gam_Games *Games,
2019-12-08 16:46:25 +01:00
bool ListGameQuestions,
Frm_PutForm_t PutFormNewMatch);
2020-04-08 03:06:45 +02:00
void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games,
2019-12-08 17:08:15 +01:00
bool ListGameQuestions,
Frm_PutForm_t PutFormNewMatch);
2019-12-08 17:08:15 +01:00
void Gam_ShowOnlyOneGameEnd (void);
2019-09-29 17:33:39 +02:00
2020-02-26 00:26:07 +01:00
void Gam_SetCurrentGamCod (long GamCod);
void Gam_PutPars (void *Games);
long Gam_GetPars (struct Gam_Games *Games);
2019-09-29 17:33:39 +02:00
2020-04-08 03:06:45 +02:00
void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder);
void Gam_GetListSelectedGamCods (struct Gam_Games *Games);
void Gam_GetGameDataByCod (struct Gam_Game *Game);
2020-04-08 03:06:45 +02:00
void Gam_FreeListGames (struct Gam_Games *Games);
2017-09-13 16:24:29 +02:00
2017-09-07 18:38:18 +02:00
void Gam_AskRemGame (void);
void Gam_RemoveGame (void);
2020-05-18 22:59:07 +02:00
void Gam_RemoveCrsGames (long CrsCod);
2019-09-28 01:12:53 +02:00
2017-09-07 18:38:18 +02:00
void Gam_HideGame (void);
void Gam_UnhideGame (void);
2020-04-08 03:06:45 +02:00
2020-09-30 20:23:52 +02:00
void Gam_ListGame (void);
void Gam_ReqCreatOrEditGame (void);
void Gam_PutFormsOneGame (struct Gam_Games *Games,
Gam_ExistingNewGame_t ExistingNewGame);
void Gam_ReceiveGame (void);
2017-09-07 18:38:18 +02:00
2020-04-27 14:20:21 +02:00
void Gam_ReqSelectQstsToAddToGame (void);
void Gam_ListQstsToAddToGame (void);
2019-09-26 21:27:36 +02:00
void Gam_PutParQstInd (unsigned QstInd);
unsigned Gam_GetParQstInd (void);
2017-09-07 18:38:18 +02:00
2020-04-27 14:20:21 +02:00
void Gam_AddQstsToGame (void);
2017-09-07 18:38:18 +02:00
void Gam_ReqRemQstFromGame (void);
2020-04-27 19:37:49 +02:00
void Gam_RemoveQstFromGame (void);
2017-09-07 18:38:18 +02:00
2017-09-11 19:06:46 +02:00
void Gam_MoveUpQst (void);
void Gam_MoveDownQst (void);
2019-09-25 21:58:12 +02:00
void Gam_ShowTstTagsPresentInAGame (long GamCod);
2019-10-21 13:36:28 +02:00
void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore);
//-------------------------------- Figures ------------------------------------
void Gam_GetAndShowGamesStats (void);
2017-07-09 20:31:40 +02:00
#endif