2019-09-28 02:31:42 +02:00
|
|
|
|
// swad_match_result.c: matches results in games using remote control
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
|
|
|
|
#include <linux/stddef.h> // For NULL
|
|
|
|
|
#include <stdio.h> // For asprintf
|
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2019-09-30 01:23:24 +02:00
|
|
|
|
#include "swad_action.h"
|
2019-09-28 02:31:42 +02:00
|
|
|
|
#include "swad_database.h"
|
2019-09-30 01:23:24 +02:00
|
|
|
|
#include "swad_date.h"
|
2019-09-28 02:31:42 +02:00
|
|
|
|
#include "swad_form.h"
|
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2019-09-28 02:31:42 +02:00
|
|
|
|
#include "swad_ID.h"
|
|
|
|
|
#include "swad_match.h"
|
|
|
|
|
#include "swad_match_result.h"
|
|
|
|
|
#include "swad_user.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 22:31:07 +02:00
|
|
|
|
static void McR_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther);
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther);
|
|
|
|
|
static void McR_ShowMchResultsSummaryRow (bool ShowSummaryResults,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
unsigned NumResults,
|
|
|
|
|
unsigned NumTotalQsts,
|
|
|
|
|
unsigned NumTotalQstsNotBlank,
|
|
|
|
|
double TotalScoreOfAllResults);
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static void McR_GetMatchResultDataByMchCod (long MchCod,long UsrCod,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
|
|
|
|
unsigned *NumQsts,
|
|
|
|
|
unsigned *NumQstsNotBlank,
|
|
|
|
|
double *Score);
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static bool McR_CheckIfICanSeeMatchResult (long MchCod,long UsrCod);
|
|
|
|
|
static bool McR_GetVisibilityMchResultFromDB (long MchCod);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Write a form to go to result of matches ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_PutFormToViewMchResults (Act_Action_t Action)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Results;
|
|
|
|
|
|
2019-10-24 09:46:20 +02:00
|
|
|
|
/***** Contextual menu *****/
|
|
|
|
|
Mnu_ContextMenuBegin ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Lay_PutContextualLinkIconText (Action,NULL,NULL,
|
|
|
|
|
"tasks.svg",
|
2019-10-24 09:46:20 +02:00
|
|
|
|
Txt_Results); // View match results
|
|
|
|
|
Mnu_ContextMenuEnd ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Select dates to show my matches results ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_SelDatesToSeeMyMchResults (void)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Games_results;
|
|
|
|
|
extern const char *Txt_Results;
|
|
|
|
|
extern const char *Txt_View_matches_results;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Frm_StartForm (ActSeeMyMchRes);
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Results,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE,2);
|
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (false);
|
|
|
|
|
|
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
Box_EndBoxTableWithButton (Btn_CONFIRM_BUTTON,Txt_View_matches_results);
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Show my matches results *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_ShowMyMchResults (void)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Games_results;
|
|
|
|
|
extern const char *Txt_Results;
|
|
|
|
|
|
|
|
|
|
/***** Get starting and ending dates *****/
|
|
|
|
|
Dat_GetIniEndDatesFromForm ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Results,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Header of the table with the list of users *****/
|
2019-09-30 22:31:07 +02:00
|
|
|
|
McR_ShowHeaderMchResults (Usr_ME);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** List my matches results *****/
|
|
|
|
|
Tst_GetConfigTstFromDB (); // To get feedback type
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_ShowMchResults (Usr_ME);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_EndBoxTable ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Select users and dates to show their matches results ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_SelUsrsToViewUsrsMchResults (void)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Games_results;
|
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
|
|
|
|
extern const char *Txt_Results;
|
|
|
|
|
extern const char *Txt_Users;
|
|
|
|
|
extern const char *Txt_View_matches_results;
|
|
|
|
|
unsigned NumTotalUsrs;
|
|
|
|
|
|
|
|
|
|
/***** Get and update type of list,
|
|
|
|
|
number of columns in class photo
|
|
|
|
|
and preference about viewing photos *****/
|
|
|
|
|
Usr_GetAndUpdatePrefsAboutUsrList ();
|
|
|
|
|
|
|
|
|
|
/***** Get groups to show ******/
|
|
|
|
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
|
|
|
|
|
|
|
|
|
/***** Get and order lists of users from this course *****/
|
|
|
|
|
Usr_GetListUsrs (Hie_CRS,Rol_STD);
|
|
|
|
|
Usr_GetListUsrs (Hie_CRS,Rol_NET);
|
|
|
|
|
Usr_GetListUsrs (Hie_CRS,Rol_TCH);
|
|
|
|
|
NumTotalUsrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs +
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs +
|
|
|
|
|
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs;
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Results,NULL,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Show form to select the groups *****/
|
|
|
|
|
Grp_ShowFormToSelectSeveralGroups (NULL,
|
2019-09-29 17:33:39 +02:00
|
|
|
|
Grp_MY_GROUPS);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Start section with user list *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (Usr_USER_LIST_SECTION_ID);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
if (NumTotalUsrs)
|
|
|
|
|
{
|
|
|
|
|
if (Usr_GetIfShowBigList (NumTotalUsrs,NULL,NULL))
|
|
|
|
|
{
|
|
|
|
|
/***** Form to select type of list used for select several users *****/
|
|
|
|
|
Usr_ShowFormsToSelectUsrListType (NULL);
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Frm_StartForm (ActSeeUsrMchRes);
|
|
|
|
|
Grp_PutParamsCodGrps ();
|
|
|
|
|
|
|
|
|
|
/***** Put list of users to select some of them *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Users);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"%s LT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TABLE_BeginPadding (2);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Usr_ListUsersToSelect (Rol_TCH);
|
|
|
|
|
Usr_ListUsersToSelect (Rol_NET);
|
|
|
|
|
Usr_ListUsersToSelect (Rol_STD);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Starting and ending dates in the search *****/
|
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (false);
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Send button *****/
|
|
|
|
|
Btn_PutConfirmButton (Txt_View_matches_results);
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // NumTotalUsrs == 0
|
|
|
|
|
/***** Show warning indicating no students found *****/
|
|
|
|
|
Usr_ShowWarningNoUsersFound (Rol_UNK);
|
|
|
|
|
|
|
|
|
|
/***** End section with user list *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory for users' list *****/
|
|
|
|
|
Usr_FreeUsrsList (Rol_TCH);
|
|
|
|
|
Usr_FreeUsrsList (Rol_NET);
|
|
|
|
|
Usr_FreeUsrsList (Rol_STD);
|
|
|
|
|
|
|
|
|
|
/***** Free memory used by list of selected users' codes *****/
|
|
|
|
|
Usr_FreeListsSelectedUsrsCods ();
|
|
|
|
|
|
|
|
|
|
/***** Free memory for list of selected groups *****/
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Show matches results for several users *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_ShowUsrsMchResults (void)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Games_results;
|
|
|
|
|
extern const char *Txt_Results;
|
|
|
|
|
extern const char *Txt_You_must_select_one_ore_more_users;
|
|
|
|
|
const char *Ptr;
|
|
|
|
|
|
|
|
|
|
/***** Get list of the selected users's IDs *****/
|
|
|
|
|
Usr_GetListsSelectedUsrsCods ();
|
|
|
|
|
|
|
|
|
|
/***** Get starting and ending dates *****/
|
|
|
|
|
Dat_GetIniEndDatesFromForm ();
|
|
|
|
|
|
|
|
|
|
/***** Check the number of users whose matches results will be shown *****/
|
|
|
|
|
if (Usr_CountNumUsrsInListOfSelectedUsrs ()) // If some users are selected...
|
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_Results,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE,2);
|
|
|
|
|
|
|
|
|
|
/***** Header of the table with the list of users *****/
|
2019-09-30 22:31:07 +02:00
|
|
|
|
McR_ShowHeaderMchResults (Usr_OTHER);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** List the matches results of the selected users *****/
|
|
|
|
|
Ptr = Gbl.Usrs.Selected.List[Rol_UNK];
|
|
|
|
|
while (*Ptr)
|
|
|
|
|
{
|
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,
|
|
|
|
|
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
|
|
|
|
|
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
|
|
|
|
|
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS)) // Get of the database the data of the user
|
|
|
|
|
if (Usr_CheckIfICanViewMch (&Gbl.Usrs.Other.UsrDat))
|
|
|
|
|
/***** Show matches results *****/
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_ShowMchResults (Usr_OTHER);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_EndBoxTable ();
|
|
|
|
|
}
|
|
|
|
|
else // If no users are selected...
|
|
|
|
|
{
|
|
|
|
|
// ...write warning alert
|
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_select_one_ore_more_users);
|
|
|
|
|
// ...and show again the form
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_SelUsrsToViewUsrsMchResults ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used by list of selected users' codes *****/
|
|
|
|
|
Usr_FreeListsSelectedUsrsCods ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Show header of my matches results *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 22:31:07 +02:00
|
|
|
|
static void McR_ShowHeaderMchResults (Usr_MeOrOther_t MeOrOther)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_User[Usr_NUM_SEXS];
|
2019-09-30 20:13:08 +02:00
|
|
|
|
extern const char *Txt_Match;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_Questions;
|
|
|
|
|
extern const char *Txt_Non_blank_BR_questions;
|
|
|
|
|
extern const char *Txt_Total_BR_score;
|
|
|
|
|
extern const char *Txt_Average_BR_score_BR_per_question_BR_from_0_to_1;
|
|
|
|
|
extern const char *Txt_Score;
|
|
|
|
|
extern const char *Txt_out_of_PART_OF_A_SCORE;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,2,"CT",Txt_User[MeOrOther == Usr_ME ? Gbl.Usrs.Me.UsrDat.Sex :
|
2019-10-13 16:21:05 +02:00
|
|
|
|
Usr_SEX_UNKNOWN]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH (1,1,"LT",Txt_START_END_TIME[Dat_START_TIME]);
|
|
|
|
|
HTM_TH (1,1,"LT",Txt_START_END_TIME[Dat_END_TIME]);
|
|
|
|
|
HTM_TH (1,1,"LT",Txt_Match);
|
|
|
|
|
HTM_TH (1,1,"RT",Txt_Questions);
|
|
|
|
|
HTM_TH (1,1,"RT",Txt_Non_blank_BR_questions);
|
|
|
|
|
HTM_TH (1,1,"RT",Txt_Total_BR_score);
|
|
|
|
|
HTM_TH (1,1,"RT",Txt_Average_BR_score_BR_per_question_BR_from_0_to_1);
|
|
|
|
|
HTM_TH_Begin (1,1,"RT");
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Txt_Score);
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Txt (Txt_out_of_PART_OF_A_SCORE);
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (Tst_SCORE_MAX);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
HTM_TH_Empty (1);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Show the matches results of a user in the current course **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static void McR_ShowMchResults (Usr_MeOrOther_t MeOrOther)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Match_result;
|
|
|
|
|
extern const char *Txt_Hidden_result;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
struct UsrData *UsrDat;
|
|
|
|
|
bool ShowResultThisMatch;
|
|
|
|
|
bool ShowSummaryResults = true;
|
|
|
|
|
unsigned NumResults;
|
|
|
|
|
unsigned NumResult;
|
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2019-09-30 01:10:57 +02:00
|
|
|
|
struct Match Match;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
|
|
|
|
unsigned NumQstsInThisResult;
|
|
|
|
|
unsigned NumQstsNotBlankInThisResult;
|
|
|
|
|
unsigned NumTotalQsts = 0;
|
|
|
|
|
unsigned NumTotalQstsNotBlank = 0;
|
|
|
|
|
double ScoreInThisResult;
|
|
|
|
|
double TotalScoreOfAllResults = 0.0;
|
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
|
|
|
|
|
|
|
|
|
/***** Set user *****/
|
|
|
|
|
UsrDat = (MeOrOther == Usr_ME) ? &Gbl.Usrs.Me.UsrDat :
|
|
|
|
|
&Gbl.Usrs.Other.UsrDat;
|
|
|
|
|
|
|
|
|
|
/***** Make database query *****/
|
|
|
|
|
NumResults =
|
|
|
|
|
(unsigned) DB_QuerySELECT (&mysql_res,"can not get matches results of a user",
|
|
|
|
|
"SELECT mch_results.MchCod," // row[0]
|
|
|
|
|
"UNIX_TIMESTAMP(mch_results.StartTime)," // row[1]
|
|
|
|
|
"UNIX_TIMESTAMP(mch_results.EndTime)," // row[2]
|
|
|
|
|
"mch_results.NumQsts," // row[3]
|
|
|
|
|
"mch_results.NumQstsNotBlank," // row[4]
|
|
|
|
|
"mch_results.Score" // row[5]
|
|
|
|
|
" FROM mch_results,mch_matches,gam_games"
|
|
|
|
|
" WHERE mch_results.UsrCod=%ld"
|
|
|
|
|
" AND mch_results.MchCod=mch_matches.MchCod"
|
|
|
|
|
" AND mch_matches.GamCod=gam_games.GamCod"
|
|
|
|
|
" AND gam_games.CrsCod=%ld" // Extra check
|
|
|
|
|
" AND mch_matches.EndTime>=FROM_UNIXTIME(%ld)"
|
|
|
|
|
" AND mch_matches.StartTime<=FROM_UNIXTIME(%ld)"
|
|
|
|
|
" ORDER BY MchCod",
|
|
|
|
|
UsrDat->UsrCod,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
(long) Gbl.DateRange.TimeUTC[Dat_START_TIME],
|
|
|
|
|
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
|
|
|
|
|
|
|
|
|
|
/***** Show user's data *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Usr_ShowTableCellWithUsrData (UsrDat,NumResults);
|
|
|
|
|
|
|
|
|
|
/***** Get and print matches results *****/
|
|
|
|
|
if (NumResults)
|
|
|
|
|
{
|
|
|
|
|
for (NumResult = 0;
|
|
|
|
|
NumResult < NumResults;
|
|
|
|
|
NumResult++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get match code (row[0]) */
|
2019-09-30 01:10:57 +02:00
|
|
|
|
if ((Match.MchCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of match.");
|
2019-09-30 01:10:57 +02:00
|
|
|
|
Mch_GetDataOfMatchByCod (&Match);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Show match result? */
|
2019-09-30 01:26:19 +02:00
|
|
|
|
ShowResultThisMatch = McR_CheckIfICanSeeMatchResult (Match.MchCod,UsrDat->UsrCod);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
ShowSummaryResults = ShowSummaryResults && ShowResultThisMatch;
|
|
|
|
|
|
|
|
|
|
if (NumResult)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Write start/end times (row[1], row[2] hold UTC start/end times) */
|
|
|
|
|
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
|
|
|
|
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
|
|
|
|
StartEndTime++)
|
|
|
|
|
{
|
|
|
|
|
TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[1 + StartEndTime]);
|
|
|
|
|
UniqueId++;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"mch_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"",
|
|
|
|
|
Id,Gbl.RowEvenOdd);
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,TimeUTC[StartEndTime],
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,false,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-30 22:31:07 +02:00
|
|
|
|
/* Write match title */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (Match.Title);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-30 22:31:07 +02:00
|
|
|
|
|
2019-09-28 02:31:42 +02:00
|
|
|
|
/* Get number of questions (row[3]) */
|
|
|
|
|
if (sscanf (row[3],"%u",&NumQstsInThisResult) != 1)
|
|
|
|
|
NumQstsInThisResult = 0;
|
|
|
|
|
NumTotalQsts += NumQstsInThisResult;
|
|
|
|
|
|
|
|
|
|
/* Get number of questions not blank (row[4]) */
|
|
|
|
|
if (sscanf (row[4],"%u",&NumQstsNotBlankInThisResult) != 1)
|
|
|
|
|
NumQstsNotBlankInThisResult = 0;
|
|
|
|
|
NumTotalQstsNotBlank += NumQstsNotBlankInThisResult;
|
|
|
|
|
|
|
|
|
|
if (ShowResultThisMatch)
|
|
|
|
|
{
|
|
|
|
|
/* Get score (row[5]) */
|
|
|
|
|
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
|
|
|
|
if (sscanf (row[5],"%lf",&ScoreInThisResult) != 1)
|
|
|
|
|
ScoreInThisResult = 0.0;
|
|
|
|
|
Str_SetDecimalPointToLocal (); // Return to local system
|
|
|
|
|
TotalScoreOfAllResults += ScoreInThisResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write number of questions */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumQstsInThisResult);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Write number of questions not blank */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumQstsNotBlankInThisResult);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Write score */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowResultThisMatch)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (ScoreInThisResult);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Write average score per question */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowResultThisMatch)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (NumQstsInThisResult ? ScoreInThisResult /
|
|
|
|
|
(double) NumQstsInThisResult :
|
|
|
|
|
0.0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Write score over Tst_SCORE_MAX */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowResultThisMatch)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (NumQstsInThisResult ? ScoreInThisResult * Tst_SCORE_MAX /
|
|
|
|
|
(double) NumQstsInThisResult :
|
|
|
|
|
0.0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Link to show this result */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowResultThisMatch)
|
|
|
|
|
{
|
2019-09-30 01:10:57 +02:00
|
|
|
|
Gam_SetParamCurrentGamCod (Match.GamCod); // Used to pass parameter
|
|
|
|
|
Mch_SetParamCurrentMchCod (Match.MchCod); // Used to pass parameter
|
2019-09-28 02:31:42 +02:00
|
|
|
|
switch (MeOrOther)
|
|
|
|
|
{
|
|
|
|
|
case Usr_ME:
|
|
|
|
|
Frm_StartForm (ActSeeOneMchResMe);
|
2019-09-30 01:10:57 +02:00
|
|
|
|
Mch_PutParamsEdit ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case Usr_OTHER:
|
|
|
|
|
Frm_StartForm (ActSeeOneMchResOth);
|
2019-09-30 01:10:57 +02:00
|
|
|
|
Mch_PutParamsEdit ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Usr_PutParamOtherUsrCodEncrypted ();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Ico_PutIconLink ("tasks.svg",Txt_Match_result);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Ico_PutIconOff ("eye-slash.svg",Txt_Hidden_result);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Write totals for this user *****/
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_ShowMchResultsSummaryRow (ShowSummaryResults,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
NumResults,
|
|
|
|
|
NumTotalQsts,NumTotalQstsNotBlank,
|
|
|
|
|
TotalScoreOfAllResults);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_ColouredEmpty (8);
|
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Show row with summary of user's matches results **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static void McR_ShowMchResultsSummaryRow (bool ShowSummaryResults,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
unsigned NumResults,
|
|
|
|
|
unsigned NumTotalQsts,
|
|
|
|
|
unsigned NumTotalQstsNotBlank,
|
|
|
|
|
double TotalScoreOfAllResults)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Matches;
|
|
|
|
|
|
|
|
|
|
/***** Start row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Row title *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"3\" class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s: ",Txt_Matches);
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Unsigned (NumResults);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write total number of questions *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (NumResults)
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumTotalQsts);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write total number of questions not blank *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (NumResults)
|
2019-11-10 13:31:47 +01:00
|
|
|
|
HTM_Unsigned (NumTotalQstsNotBlank);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write total score *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowSummaryResults)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (TotalScoreOfAllResults);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write average score per question *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowSummaryResults)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (NumTotalQsts ? TotalScoreOfAllResults / (double) NumTotalQsts :
|
|
|
|
|
0.0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write score over Tst_SCORE_MAX *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP RM COLOR%u\"",Gbl.RowEvenOdd);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ShowSummaryResults)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Double (NumTotalQsts ? TotalScoreOfAllResults * Tst_SCORE_MAX /
|
|
|
|
|
(double) NumTotalQsts :
|
|
|
|
|
0.0);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Last cell *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N_LINE_TOP COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_TD_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** End row *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Show one match result of another user *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_ShowOneMchResult (void)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Games_results;
|
|
|
|
|
extern const char *Txt_Match_result;
|
2019-09-30 01:10:57 +02:00
|
|
|
|
extern const char *Txt_The_user_does_not_exist;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_Questions;
|
|
|
|
|
extern const char *Txt_non_blank_QUESTIONS;
|
|
|
|
|
extern const char *Txt_Score;
|
|
|
|
|
extern const char *Txt_out_of_PART_OF_A_SCORE;
|
|
|
|
|
extern const char *Txt_Tags;
|
2019-09-29 22:38:32 +02:00
|
|
|
|
struct Game Game;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
struct Match Match;
|
|
|
|
|
Usr_MeOrOther_t MeOrOther;
|
|
|
|
|
struct UsrData *UsrDat;
|
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME]; // Match result UTC date-time
|
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
unsigned NumQsts;
|
|
|
|
|
unsigned NumQstsNotBlank;
|
|
|
|
|
double TotalScore;
|
|
|
|
|
bool ShowPhoto;
|
|
|
|
|
char PhotoURL[PATH_MAX + 1];
|
|
|
|
|
bool ItsMe;
|
2019-09-29 19:36:32 +02:00
|
|
|
|
bool ICanPlayThisMatchBasedOnGrps;
|
2019-09-28 02:31:42 +02:00
|
|
|
|
bool ICanViewResult;
|
|
|
|
|
bool ICanViewScore;
|
|
|
|
|
|
2019-09-29 22:38:32 +02:00
|
|
|
|
/***** Get and check parameters *****/
|
|
|
|
|
Mch_GetAndCheckParameters (&Game,&Match);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Pointer to user's data *****/
|
|
|
|
|
MeOrOther = (Gbl.Action.Act == ActSeeOneMchResMe) ? Usr_ME :
|
|
|
|
|
Usr_OTHER;
|
|
|
|
|
switch (MeOrOther)
|
|
|
|
|
{
|
|
|
|
|
case Usr_ME:
|
|
|
|
|
UsrDat = &Gbl.Usrs.Me.UsrDat;
|
|
|
|
|
break;
|
|
|
|
|
case Usr_OTHER:
|
|
|
|
|
default:
|
|
|
|
|
UsrDat = &Gbl.Usrs.Other.UsrDat;
|
|
|
|
|
Usr_GetParamOtherUsrCodEncrypted (UsrDat);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get match result data *****/
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_GetMatchResultDataByMchCod (Match.MchCod,UsrDat->UsrCod,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
TimeUTC,
|
|
|
|
|
&NumQsts,
|
|
|
|
|
&NumQstsNotBlank,
|
|
|
|
|
&TotalScore);
|
|
|
|
|
Gbl.Test.Config.Feedback = Tst_FEEDBACK_FULL_FEEDBACK; // Initialize feedback to maximum
|
|
|
|
|
|
|
|
|
|
/***** Check if I can view this match result *****/
|
|
|
|
|
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
switch (MeOrOther)
|
|
|
|
|
{
|
|
|
|
|
case Usr_ME:
|
2019-09-29 19:36:32 +02:00
|
|
|
|
ICanPlayThisMatchBasedOnGrps = Mch_CheckIfICanPlayThisMatchBasedOnGrps (Match.MchCod);
|
|
|
|
|
ICanViewResult = ItsMe && ICanPlayThisMatchBasedOnGrps &&
|
|
|
|
|
Match.Status.ShowUsrResults;
|
|
|
|
|
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ICanViewResult)
|
|
|
|
|
{
|
|
|
|
|
Tst_GetConfigTstFromDB (); // To get feedback type
|
|
|
|
|
ICanViewScore = Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ICanViewScore = false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_DEG_ADM:
|
|
|
|
|
case Rol_CTR_ADM:
|
|
|
|
|
case Rol_INS_ADM:
|
|
|
|
|
switch (MeOrOther)
|
|
|
|
|
{
|
|
|
|
|
case Usr_ME:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = ItsMe;
|
|
|
|
|
break;
|
|
|
|
|
case Usr_OTHER:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ICanViewResult =
|
|
|
|
|
ICanViewScore = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ICanViewResult) // I am allowed to view this match result
|
|
|
|
|
{
|
|
|
|
|
/***** Get questions and user's answers of the match result from database *****/
|
2019-09-30 01:26:19 +02:00
|
|
|
|
McR_GetMatchResultQuestionsFromDB (Match.MchCod,UsrDat->UsrCod,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
&NumQsts,&NumQstsNotBlank);
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Match_result,NULL,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Hlp_ASSESSMENT_Games_results,Box_NOT_CLOSABLE);
|
|
|
|
|
Lay_WriteHeaderClassPhoto (false,false,
|
|
|
|
|
Gbl.Hierarchy.Ins.InsCod,
|
|
|
|
|
Gbl.Hierarchy.Deg.DegCod,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (10);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Header row *****/
|
|
|
|
|
/* Get data of the user who answer the match */
|
|
|
|
|
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat,Usr_DONT_GET_PREFS))
|
2019-09-30 01:10:57 +02:00
|
|
|
|
Lay_ShowErrorAndExit (Txt_The_user_does_not_exist);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (!Usr_CheckIfICanViewTst (UsrDat))
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* User */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RT\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_ROLES_SINGUL_Abc[UsrDat->Roles.InCurrentCrs.Role][UsrDat->Sex]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
2019-09-28 02:31:42 +02:00
|
|
|
|
ID_WriteUsrIDs (UsrDat,NULL);
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",UsrDat->Surname1);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (UsrDat->Surname2[0])
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF (" %s",UsrDat->Surname2);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (UsrDat->FirstName[0])
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF (", %s",UsrDat->FirstName);
|
2019-11-09 21:08:20 +01:00
|
|
|
|
HTM_BR ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (UsrDat,PhotoURL);
|
|
|
|
|
Pho_ShowUsrPhoto (UsrDat,ShowPhoto ? PhotoURL :
|
|
|
|
|
NULL,
|
|
|
|
|
"PHOTO45x60",Pho_ZOOM,false);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Start/end time (for user in this match) */
|
|
|
|
|
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
|
|
|
|
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
|
|
|
|
StartEndTime++)
|
2019-10-04 14:42:59 +02:00
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RT\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_START_END_TIME[StartEndTime]);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-11-01 22:53:39 +01:00
|
|
|
|
if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0)
|
|
|
|
|
Lay_NotEnoughMemoryExit ();
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"DAT LT\"",Id);
|
2019-11-01 23:35:55 +01:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,TimeUTC[StartEndTime],
|
2019-11-02 12:10:58 +01:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
2019-11-02 11:45:41 +01:00
|
|
|
|
true,true,true,0x7);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Id);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-10-04 14:42:59 +02:00
|
|
|
|
}
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Number of questions */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RT\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Questions);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_TxtF ("%u (%u %s)",NumQsts,NumQstsNotBlank,Txt_non_blank_QUESTIONS);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Score */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RT\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Score);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
2019-09-28 02:31:42 +02:00
|
|
|
|
if (ICanViewScore)
|
2019-11-11 00:15:44 +01:00
|
|
|
|
{
|
|
|
|
|
HTM_Double (TotalScore);
|
|
|
|
|
HTM_Txt (" (");
|
|
|
|
|
HTM_Double (NumQsts ? TotalScore * Tst_SCORE_MAX / (double) NumQsts :
|
|
|
|
|
0.0);
|
|
|
|
|
}
|
2019-09-28 02:31:42 +02:00
|
|
|
|
else
|
2019-11-11 00:15:44 +01:00
|
|
|
|
HTM_Txt ("? (?"); // No feedback
|
|
|
|
|
HTM_TxtF (" %s %u)",Txt_out_of_PART_OF_A_SCORE,Tst_SCORE_MAX);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/* Tags present in this result */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_N RT\"");
|
2019-11-11 10:59:24 +01:00
|
|
|
|
HTM_TxtF ("%s:",Txt_Tags);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT LT\"");
|
2019-09-28 02:31:42 +02:00
|
|
|
|
Gam_ShowTstTagsPresentInAGame (Match.GamCod);
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write answers and solutions *****/
|
|
|
|
|
Tst_ShowTestResult (UsrDat,NumQsts,TimeUTC[Dat_START_TIME]);
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
|
|
|
|
|
/***** Write total mark of match result *****/
|
|
|
|
|
if (ICanViewScore)
|
|
|
|
|
Tst_ShowTstTotalMark (NumQsts,TotalScore);
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
else // I am not allowed to view this match result
|
2019-10-26 01:56:36 +02:00
|
|
|
|
Lay_NoPermissionExit ();
|
2019-09-28 02:31:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get the questions of a match result from database **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
void McR_GetMatchResultQuestionsFromDB (long MchCod,long UsrCod,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
unsigned *NumQsts,unsigned *NumQstsNotBlank)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumQst;
|
|
|
|
|
long LongNum;
|
|
|
|
|
unsigned QstInd;
|
|
|
|
|
struct Mch_UsrAnswer UsrAnswer;
|
|
|
|
|
|
|
|
|
|
/***** Get questions and answers of a match result *****/
|
|
|
|
|
*NumQsts = (unsigned)
|
|
|
|
|
DB_QuerySELECT (&mysql_res,"can not get questions and answers"
|
|
|
|
|
" of a match result",
|
|
|
|
|
"SELECT gam_questions.QstCod," // row[0]
|
|
|
|
|
"gam_questions.QstInd," // row[1]
|
|
|
|
|
"mch_indexes.Indexes" // row[2]
|
|
|
|
|
" FROM mch_matches,gam_questions,mch_indexes"
|
|
|
|
|
" WHERE mch_matches.MchCod=%ld"
|
|
|
|
|
" AND mch_matches.GamCod=gam_questions.GamCod"
|
|
|
|
|
" AND mch_matches.MchCod=mch_indexes.MchCod"
|
|
|
|
|
" AND gam_questions.QstInd=mch_indexes.QstInd"
|
|
|
|
|
" ORDER BY gam_questions.QstInd",
|
|
|
|
|
MchCod);
|
|
|
|
|
for (NumQst = 0, *NumQstsNotBlank = 0;
|
|
|
|
|
NumQst < *NumQsts;
|
|
|
|
|
NumQst++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get question code (row[0]) */
|
|
|
|
|
if ((Gbl.Test.QstCodes[NumQst] = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
|
|
|
|
|
|
|
|
|
/* Get question index (row[1]) */
|
|
|
|
|
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of question.");
|
|
|
|
|
QstInd = (unsigned) LongNum;
|
|
|
|
|
|
|
|
|
|
/* Get indexes for this question (row[2]) */
|
|
|
|
|
Str_Copy (Gbl.Test.StrIndexesOneQst[NumQst],row[2],
|
|
|
|
|
Tst_MAX_BYTES_INDEXES_ONE_QST);
|
|
|
|
|
|
|
|
|
|
/* Get answers selected by user for this question */
|
|
|
|
|
Mch_GetQstAnsFromDB (MchCod,UsrCod,QstInd,&UsrAnswer);
|
|
|
|
|
if (UsrAnswer.AnsInd >= 0) // UsrAnswer.AnsInd >= 0 ==> answer selected
|
|
|
|
|
{
|
|
|
|
|
snprintf (Gbl.Test.StrAnswersOneQst[NumQst],Tst_MAX_BYTES_ANSWERS_ONE_QST + 1,
|
|
|
|
|
"%d",UsrAnswer.AnsInd);
|
|
|
|
|
(*NumQstsNotBlank)++;
|
|
|
|
|
}
|
|
|
|
|
else // UsrAnswer.AnsInd < 0 ==> no answer selected
|
|
|
|
|
Gbl.Test.StrAnswersOneQst[NumQst][0] = '\0'; // Empty answer
|
|
|
|
|
|
|
|
|
|
/* Replace each comma by a separator of multiple parameters */
|
|
|
|
|
/* In database commas are used as separators instead of special chars */
|
|
|
|
|
Par_ReplaceCommaBySeparatorMultiple (Gbl.Test.StrIndexesOneQst[NumQst]);
|
|
|
|
|
Par_ReplaceCommaBySeparatorMultiple (Gbl.Test.StrAnswersOneQst[NumQst]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Get data of a match result using its match code ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static void McR_GetMatchResultDataByMchCod (long MchCod,long UsrCod,
|
2019-09-28 02:31:42 +02:00
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME],
|
|
|
|
|
unsigned *NumQsts,
|
|
|
|
|
unsigned *NumQstsNotBlank,
|
|
|
|
|
double *Score)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
Dat_StartEndTime_t StartEndTime;
|
|
|
|
|
|
|
|
|
|
/***** Make database query *****/
|
|
|
|
|
if (DB_QuerySELECT (&mysql_res,"can not get data"
|
|
|
|
|
" of a match result of a user",
|
|
|
|
|
"SELECT UNIX_TIMESTAMP(mch_results.StartTime)," // row[1]
|
|
|
|
|
"UNIX_TIMESTAMP(mch_results.EndTime)," // row[2]
|
|
|
|
|
"mch_results.NumQsts," // row[3]
|
|
|
|
|
"mch_results.NumQstsNotBlank," // row[4]
|
|
|
|
|
"mch_results.Score" // row[5]
|
|
|
|
|
" FROM mch_results,mch_matches,gam_games"
|
|
|
|
|
" WHERE mch_results.MchCod=%ld"
|
|
|
|
|
" AND mch_results.UsrCod=%ld"
|
|
|
|
|
" AND mch_results.MchCod=mch_matches.MchCod"
|
|
|
|
|
" AND mch_matches.GamCod=gam_games.GamCod"
|
|
|
|
|
" AND gam_games.CrsCod=%ld", // Extra check
|
|
|
|
|
MchCod,UsrCod,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod) == 1)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get start time (row[0] and row[1] hold UTC date-times) */
|
|
|
|
|
for (StartEndTime = (Dat_StartEndTime_t) 0;
|
|
|
|
|
StartEndTime <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
|
|
|
|
StartEndTime++)
|
|
|
|
|
TimeUTC[StartEndTime] = Dat_GetUNIXTimeFromStr (row[StartEndTime]);
|
|
|
|
|
|
|
|
|
|
/* Get number of questions (row[2]) */
|
|
|
|
|
if (sscanf (row[2],"%u",NumQsts) != 1)
|
|
|
|
|
*NumQsts = 0;
|
|
|
|
|
|
|
|
|
|
/* Get number of questions not blank (row[3]) */
|
|
|
|
|
if (sscanf (row[3],"%u",NumQstsNotBlank) != 1)
|
|
|
|
|
*NumQstsNotBlank = 0;
|
|
|
|
|
|
|
|
|
|
/* Get score (row[4]) */
|
|
|
|
|
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
|
|
|
|
if (sscanf (row[4],"%lf",Score) != 1)
|
|
|
|
|
*Score = 0.0;
|
|
|
|
|
Str_SetDecimalPointToLocal (); // Return to local system
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get if I can see match result ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static bool McR_CheckIfICanSeeMatchResult (long MchCod,long UsrCod)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
bool ItsMe;
|
|
|
|
|
bool ShowResultThisMatch;
|
|
|
|
|
|
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
|
|
|
|
{
|
|
|
|
|
case Rol_STD:
|
|
|
|
|
ItsMe = Usr_ItsMe (UsrCod);
|
|
|
|
|
if (ItsMe && Gbl.Test.Config.Feedback != Tst_FEEDBACK_NOTHING)
|
2019-09-30 01:26:19 +02:00
|
|
|
|
ShowResultThisMatch = McR_GetVisibilityMchResultFromDB (MchCod);
|
2019-09-28 02:31:42 +02:00
|
|
|
|
else
|
|
|
|
|
ShowResultThisMatch = false;
|
|
|
|
|
break;
|
|
|
|
|
case Rol_NET:
|
|
|
|
|
case Rol_TCH:
|
|
|
|
|
case Rol_DEG_ADM:
|
|
|
|
|
case Rol_CTR_ADM:
|
|
|
|
|
case Rol_INS_ADM:
|
|
|
|
|
case Rol_SYS_ADM:
|
|
|
|
|
ShowResultThisMatch = true;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ShowResultThisMatch = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ShowResultThisMatch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get visibility of match result ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-09-30 01:26:19 +02:00
|
|
|
|
static bool McR_GetVisibilityMchResultFromDB (long MchCod)
|
2019-09-28 02:31:42 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
bool ShowUsrResults;
|
|
|
|
|
|
|
|
|
|
/***** Get visibility of match result from database *****/
|
|
|
|
|
NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get if show result",
|
|
|
|
|
"SELECT ShowUsrResults" // row[0]
|
|
|
|
|
" FROM mch_matches"
|
|
|
|
|
" WHERE MchCod=%ld"
|
|
|
|
|
" AND GamCod IN" // Extra check
|
|
|
|
|
" (SELECT GamCod FROM gam_games"
|
|
|
|
|
" WHERE CrsCod='%ld')",
|
|
|
|
|
MchCod,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod);
|
|
|
|
|
if (NumRows) // Match found...
|
|
|
|
|
{
|
|
|
|
|
/* Get whether to show user results or not (row(0)) */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
ShowUsrResults = (row[0][0] == 'Y');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ShowUsrResults = false;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return ShowUsrResults;
|
|
|
|
|
}
|