Version 22.8: Sep 18, 2022 Links to games in program.

This commit is contained in:
acanas 2022-09-18 23:15:43 +02:00
parent e878405ecd
commit 004c451068
14 changed files with 223 additions and 76 deletions

View File

@ -822,6 +822,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActRemGamQst ] = {1665,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_RemoveQstFromGame ,NULL},
[ActUp_GamQst ] = {1668,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_MoveUpQst ,NULL},
[ActDwnGamQst ] = {1669,-1,TabUnk,ActSeeAllGam ,0x238,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_MoveDownQst ,NULL},
[ActReqLnkGam ] = {1935,-1,TabUnk,ActSeeAllGam ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Gam_GetLinkToGame ,NULL},
[ActSeeSvy ] = { 982,-1,TabUnk,ActSeeAllSvy ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_SeeOneSurvey ,NULL},
[ActAnsSvy ] = { 983,-1,TabUnk,ActSeeAllSvy ,0x3F8,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_ReceiveSurveyAnswers ,NULL},
@ -3779,6 +3780,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
ActSeeCliPrgRsc, // #1932
ActChgLnkPrgRsc, // #1933
ActReqLnkCfe, // #1934
ActReqLnkGam, // #1935
};
/*****************************************************************************/

View File

@ -65,7 +65,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 1934
#define Act_MAX_ACTION_COD 1935
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
@ -776,23 +776,24 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
#define ActRemGamQst (ActChgCrsTT1stDay + 222)
#define ActUp_GamQst (ActChgCrsTT1stDay + 223)
#define ActDwnGamQst (ActChgCrsTT1stDay + 224)
#define ActReqLnkGam (ActChgCrsTT1stDay + 225)
#define ActSeeSvy (ActChgCrsTT1stDay + 225)
#define ActAnsSvy (ActChgCrsTT1stDay + 226)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 227)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 228)
#define ActNewSvy (ActChgCrsTT1stDay + 229)
#define ActChgSvy (ActChgCrsTT1stDay + 230)
#define ActReqRemSvy (ActChgCrsTT1stDay + 231)
#define ActRemSvy (ActChgCrsTT1stDay + 232)
#define ActReqRstSvy (ActChgCrsTT1stDay + 233)
#define ActRstSvy (ActChgCrsTT1stDay + 234)
#define ActHidSvy (ActChgCrsTT1stDay + 235)
#define ActUnhSvy (ActChgCrsTT1stDay + 236)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 237)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 238)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 239)
#define ActRemSvyQst (ActChgCrsTT1stDay + 240)
#define ActSeeSvy (ActChgCrsTT1stDay + 226)
#define ActAnsSvy (ActChgCrsTT1stDay + 227)
#define ActFrmNewSvy (ActChgCrsTT1stDay + 228)
#define ActEdiOneSvy (ActChgCrsTT1stDay + 229)
#define ActNewSvy (ActChgCrsTT1stDay + 230)
#define ActChgSvy (ActChgCrsTT1stDay + 231)
#define ActReqRemSvy (ActChgCrsTT1stDay + 232)
#define ActRemSvy (ActChgCrsTT1stDay + 233)
#define ActReqRstSvy (ActChgCrsTT1stDay + 234)
#define ActRstSvy (ActChgCrsTT1stDay + 235)
#define ActHidSvy (ActChgCrsTT1stDay + 236)
#define ActUnhSvy (ActChgCrsTT1stDay + 237)
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 238)
#define ActRcvSvyQst (ActChgCrsTT1stDay + 239)
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 240)
#define ActRemSvyQst (ActChgCrsTT1stDay + 241)
/*****************************************************************************/
/******************************** Files tab **********************************/

View File

@ -1688,7 +1688,49 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
}
/*****************************************************************************/
/******************** Write file name in course program **********************/
/************************ Get link to call for exam **************************/
/*****************************************************************************/
void Cfe_GetLinkToCallForExam (void)
{
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
struct Cfe_CallsForExams *CallsForExams = Cfe_GetGlobalCallsForExams ();
long ExaCod;
char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE];
/***** Reset calls for exams context *****/
Cfe_ResetCallsForExams (CallsForExams);
/***** Get the code of the call for exam *****/
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
Err_WrongCallForExamExit ();
/***** Get data of call for exam *****/
Cfe_AllocMemCallForExam (CallsForExams);
Cfe_GetDataCallForExamFromDB (CallsForExams,ExaCod);
/***** Session and date of the exam *****/
Cfe_BuildSessionAndDate (CallsForExams,SessionAndDate);
/***** Copy link to call for exam into resource clipboard *****/
Prg_DB_CopyToClipboard (PrgRsc_CALL_FOR_EXAM,ExaCod);
/***** Write sucess message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
SessionAndDate);
/***** Free memory of the call for exam *****/
Cfe_FreeMemCallForExam (CallsForExams);
/***** Set exam to be highlighted *****/
CallsForExams->HighlightExaCod = ExaCod;
/***** Show again the list of calls for exams *****/
Cfe_ListCallsForExamsEdit ();
}
/*****************************************************************************/
/******************* Write call for exam in course program *******************/
/*****************************************************************************/
void Cfe_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo)
@ -1735,48 +1777,6 @@ void Cfe_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo)
}
}
/*****************************************************************************/
/************************ Get link to call for exam **************************/
/*****************************************************************************/
void Cfe_GetLinkToCallForExam (void)
{
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
struct Cfe_CallsForExams *CallsForExams = Cfe_GetGlobalCallsForExams ();
long ExaCod;
char SessionAndDate[Cfe_MAX_BYTES_SESSION_AND_DATE];
/***** Reset calls for exams context *****/
Cfe_ResetCallsForExams (CallsForExams);
/***** Get the code of the call for exam *****/
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
Err_WrongCallForExamExit ();
/***** Get data of call for exam *****/
Cfe_AllocMemCallForExam (CallsForExams);
Cfe_GetDataCallForExamFromDB (CallsForExams,ExaCod);
/***** Session and date of the exam *****/
Cfe_BuildSessionAndDate (CallsForExams,SessionAndDate);
/***** Copy link to call for exam into resource clipboard *****/
Prg_DB_CopyToClipboard (PrgRsc_CALL_FOR_EXAM,ExaCod);
/***** Write sucess message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
SessionAndDate);
/***** Free memory of the call for exam *****/
Cfe_FreeMemCallForExam (CallsForExams);
/***** Set exam to be highlighted *****/
CallsForExams->HighlightExaCod = ExaCod;
/***** Show again the list of calls for exams *****/
Cfe_ListCallsForExamsEdit ();
}
/*****************************************************************************/
/************** Get call for exam text from call for exam code ***************/
/*****************************************************************************/

View File

@ -126,9 +126,9 @@ void Cfe_GetSummaryAndContentCallForExam (char SummaryStr[Ntf_MAX_BYTES_SUMMARY
char **ContentStr,
long ExaCod,bool GetContent);
void Cfe_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo);
//--------------------------- Program resources -------------------------------
void Cfe_GetLinkToCallForExam (void);
void Cfe_WriteCallForExamInCrsProgram (long ExaCod,bool PutFormToGo);
void Cfe_GetTitleFromExaCod (long ExaCod,char *Title,size_t TitleSize);
#endif

View File

@ -606,14 +606,15 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
TODO: Attach pdf files in multimedia.
*/
#define Log_PLATFORM_VERSION "SWAD 22.7 (2022-09-17)"
#define Log_PLATFORM_VERSION "SWAD 22.8 (2022-09-18)"
#define CSS_FILE "swad22.7.css"
#define JS_FILE "swad21.100.js"
/*
Version 22.7: Sep 18, 2022 Link to calls for exams in program.
Version 22.8: Sep 18, 2022 Links to games in program. (330355 lines)
Version 22.7: Sep 18, 2022 Links to calls for exams in program.
Notification of a call for exam now links to the call. (330230 lines)
Version 22.6: Sep 17, 2022 Changes in edition of program items. (330065 lines)
Version 22.5: Sep 16, 2022 Link to download document in program. (330018 lines)
Version 22.5: Sep 16, 2022 Links to download documents in program. (330018 lines)
Version 22.4.2: Sep 16, 2022 Changes in edition of program items. (329982 lines)
Version 22.4.1: Sep 15, 2022 Changes in edition of program items. (329955 lines)
Copy the following icon to icon public directory:

View File

@ -1484,7 +1484,7 @@ unsigned Exa_DB_GetDataOfSessionByCod (MYSQL_RES **mysql_res,long SesCod)
" AND ExaCod IN" // Extra check
" (SELECT ExaCod"
" FROM exa_exams"
" WHERE CrsCod='%ld')",
" WHERE CrsCod=%ld)",
SesCod,
Gbl.Hierarchy.Crs.CrsCod);
}

View File

@ -47,6 +47,7 @@
#include "swad_match_database.h"
#include "swad_match_result.h"
#include "swad_pagination.h"
#include "swad_program_database.h"
#include "swad_role.h"
#include "swad_test.h"
#include "swad_test_visibility.h"
@ -116,7 +117,7 @@ static void Gam_PutParamsToCreateNewGame (void *Games);
static void Gam_ShowOneGame (struct Gam_Games *Games,
struct Gam_Game *Game,bool ShowOnlyThisGame);
static void Gam_PutIconToShowResultsOfGame (void *Games);
static void Gam_PutIconsOneGame (void *Games);
static void Gam_WriteAuthor (struct Gam_Game *Game);
static void Gam_PutHiddenParamGameOrder (Gam_Order_t SelectedOrder);
@ -487,7 +488,7 @@ void Gam_ShowOnlyOneGameBegin (struct Gam_Games *Games,
/***** Begin box *****/
Games->GamCod = Game->GamCod;
Box_BoxBegin (NULL,Txt_Game,
Gam_PutIconToShowResultsOfGame,Games,
Gam_PutIconsOneGame,Games,
Hlp_ASSESSMENT_Games,Box_NOT_CLOSABLE);
/***** Show game *****/
@ -691,7 +692,7 @@ static void Gam_ShowOneGame (struct Gam_Games *Games,
/************* Put icon to show results of matches in a game *****************/
/*****************************************************************************/
static void Gam_PutIconToShowResultsOfGame (void *Games)
static void Gam_PutIconsOneGame (void *Games)
{
static const Act_Action_t NextAction[Rol_NUM_ROLES] =
{
@ -702,10 +703,17 @@ static void Gam_PutIconToShowResultsOfGame (void *Games)
};
if (Games)
{
/***** Put icon to view matches results *****/
if (NextAction[Gbl.Usrs.Me.Role.Logged])
Ico_PutContextualIconToShowResults (NextAction[Gbl.Usrs.Me.Role.Logged],MchRes_RESULTS_BOX_ID,
Gam_PutParams,Games);
/***** Link to get resource link *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // Only if I am superuser // TODO: Include teachers
Ico_PutContextualIconToGetLink (ActReqLnkGam,NULL,
Gam_PutParams,Games);
}
}
/*****************************************************************************/
@ -2342,3 +2350,85 @@ void Gam_GetAndShowGamesStats (void)
/***** End table and box *****/
Box_BoxTableEnd ();
}
/*****************************************************************************/
/***************************** Get link to game ******************************/
/*****************************************************************************/
void Gam_GetLinkToGame (void)
{
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
struct Gam_Games Games;
struct Gam_Game Game;
/***** Reset games context *****/
Gam_ResetGames (&Games);
/***** Reset game *****/
Gam_ResetGame (&Game);
/***** Get parameters *****/
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
Err_WrongGameExit ();
/***** Get data of the game from database *****/
Gam_GetDataOfGameByCod (&Game);
/***** Copy link to call for exam into resource clipboard *****/
Prg_DB_CopyToClipboard (PrgRsc_GAME,Game.GamCod);
/***** Write sucess message *****/
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
Game.Title);
/***** Show games again *****/
Gam_ListAllGames (&Games);
}
/*****************************************************************************/
/*********************** Write game in course program ************************/
/*****************************************************************************/
void Gam_WriteGameInCrsProgram (long GamCod,bool PutFormToGo)
{
extern const char *Txt_Actions[Act_NUM_ACTIONS];
char Title[Gam_MAX_BYTES_TITLE + 1];
/***** Get game title *****/
Gam_DB_GetGameTitle (GamCod,Title);
/***** Begin form to download file *****/
if (PutFormToGo)
{
Frm_BeginForm (ActSeeGam);
Gam_PutParamGameCod (GamCod);
HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeOneCfe],
"class=\"LM BT_LINK PRG_RSC_%s\"",
The_GetSuffix ());
}
/***** Write Name of the course and date of exam *****/
HTM_Txt (Title);
/***** End form to download file *****/
if (PutFormToGo)
{
/* End form */
HTM_BUTTON_End ();
Frm_EndForm ();
}
}
/*****************************************************************************/
/************** Get game title from call for exam code ***************/
/*****************************************************************************/
void Gam_GetTitleFromGamCod (long GamCod,char *Title,size_t TitleSize)
{
char TitleFromDB[Gam_MAX_BYTES_TITLE + 1];
/***** Get game title *****/
Gam_DB_GetGameTitle (GamCod,TitleFromDB);
Str_Copy (Title,TitleFromDB,TitleSize);
}

View File

@ -167,4 +167,9 @@ void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore);
//-------------------------------- Figures ------------------------------------
void Gam_GetAndShowGamesStats (void);
//--------------------------- Program resources -------------------------------
void Gam_GetLinkToGame (void);
void Gam_WriteGameInCrsProgram (long GamCod,bool PutFormToGo);
void Gam_GetTitleFromGamCod (long GamCod,char *Title,size_t TitleSize);
#endif

View File

@ -217,18 +217,32 @@ unsigned Gam_DB_GetDataOfGameByCod (MYSQL_RES **mysql_res,long GamCod)
" LEFT JOIN mch_matches"
" ON gam_games.GamCod=mch_matches.GamCod"
" WHERE gam_games.GamCod=%ld"
" AND gam_games.CrsCod='%ld'", // Extra check
" AND gam_games.CrsCod=%ld", // Extra check
GamCod,
Gbl.Hierarchy.Crs.CrsCod);
}
/*****************************************************************************/
/*********************** Get game title from database ************************/
/*****************************************************************************/
void Gam_DB_GetGameTitle (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
{
DB_QuerySELECTString (Title,Gam_MAX_BYTES_TITLE,"can not get game title",
"SELECT Title" // row[0]
" FROM gam_games"
" WHERE GamCod=%ld"
" AND gam_games.CrsCod=%ld", // Extra check
GamCod,
Gbl.Hierarchy.Crs.CrsCod);
}
/*****************************************************************************/
/********************** Get game text from database ************************/
/*****************************************************************************/
void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{
/***** Get text of game from database *****/
DB_QuerySELECTString (Txt,Cns_MAX_BYTES_TEXT,"can not get game text",
"SELECT Txt" // row[0]
" FROM gam_games"

View File

@ -42,6 +42,7 @@ void Gam_DB_HideOrUnhideGame (long GamCod,bool Hide);
unsigned Gam_DB_GetListGames (MYSQL_RES **mysql_res,Gam_Order_t SelectedOrder);
unsigned Gam_DB_GetListAvailableGames (MYSQL_RES **mysql_res);
unsigned Gam_DB_GetDataOfGameByCod (MYSQL_RES **mysql_res,long GamCod);
void Gam_DB_GetGameTitle (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1]);
void Gam_DB_GetGameTxt (long GamCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
bool Gam_DB_CheckIfSimilarGameExists (const struct Gam_Game *Game);
unsigned Gam_DB_GetNumCoursesWithGames (HieLvl_Level_t Scope);

View File

@ -192,7 +192,7 @@ unsigned Mch_DB_GetDataOfMatchByCod (MYSQL_RES **mysql_res,long MchCod)
" AND GamCod IN" // Extra check
" (SELECT GamCod"
" FROM gam_games"
" WHERE CrsCod='%ld')",
" WHERE CrsCod=%ld)",
MchCod,
Gbl.Hierarchy.Crs.CrsCod);
}

View File

@ -31,6 +31,7 @@
#include "swad_call_for_exam.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_game.h"
#include "swad_global.h"
#include "swad_program.h"
#include "swad_program_database.h"
@ -1020,7 +1021,11 @@ static void PrgRsc_WriteLinkName (const struct Prg_Link *Link,bool PutForm)
Cfe_WriteCallForExamInCrsProgram (Link->Cod,PutForm);
break;
case PrgRsc_EXAM:
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
break;
case PrgRsc_GAME:
Gam_WriteGameInCrsProgram (Link->Cod,PutForm);
break;
case PrgRsc_SURVEY:
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
break;
@ -1064,7 +1069,13 @@ static void PrgRsc_GetResourceTitleFromLink (struct Prg_Item *Item)
sizeof (Item->Resource.Title) - 1);
break;
case PrgRsc_EXAM:
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
break;
case PrgRsc_GAME:
Gam_GetTitleFromGamCod (Item->Resource.Link.Cod,
Item->Resource.Title,
sizeof (Item->Resource.Title) - 1);
break;
case PrgRsc_SURVEY:
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
break;

View File

@ -286,11 +286,11 @@ unsigned Qst_DB_GetQsts (MYSQL_RES **mysql_res,
"tst_tags",
Qst_MAX_BYTES_QUERY_QUESTIONS);
Str_Concat (Query," WHERE tst_questions.CrsCod='",
Str_Concat (Query," WHERE tst_questions.CrsCod=",
Qst_MAX_BYTES_QUERY_QUESTIONS);
snprintf (CrsCodStr,sizeof (CrsCodStr),"%ld",Gbl.Hierarchy.Crs.CrsCod);
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
Str_Concat (Query," AND tst_questions.EditTime>=FROM_UNIXTIME('",
Qst_MAX_BYTES_QUERY_QUESTIONS);
snprintf (LongStr,sizeof (LongStr),"%ld",
(long) Gbl.DateRange.TimeUTC[Dat_STR_TIME]);
@ -307,10 +307,9 @@ unsigned Qst_DB_GetQsts (MYSQL_RES **mysql_res,
{
Str_Concat (Query," AND tst_questions.QstCod=tst_question_tags.QstCod"
" AND tst_question_tags.TagCod=tst_tags.TagCod"
" AND tst_tags.CrsCod='",
" AND tst_tags.CrsCod=",
Qst_MAX_BYTES_QUERY_QUESTIONS);
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
LengthQuery = strlen (Query);
NumItemInList = 0;
Ptr = Questions->Tags.List;

View File

@ -13607,6 +13607,29 @@ const char *Txt_Actions[Act_NUM_ACTIONS] =
"Move down game question" // Precisa de tradução
#elif L==10 // tr
"Move down game question" // Çeviri lazim!
#endif
,
[ActReqLnkGam] =
#if L==1 // ca
"Copy link to game" // Necessita traducció
#elif L==2 // de
"Copy link to game" // Need Übersetzung
#elif L==3 // en
"Copy link to game"
#elif L==4 // es
"Copiar enlace a juego"
#elif L==5 // fr
"Copy link to game" // Besoin de traduction
#elif L==6 // gn
"Copiar enlace a juego" // Okoteve traducción
#elif L==7 // it
"Copy link to game" // Bisogno di traduzione
#elif L==8 // pl
"Copy link to game" // Potrzebujesz tlumaczenie
#elif L==9 // pt
"Copy link to game" // Precisa de tradução
#elif L==10 // tr
"Copy link to game" // Çeviri lazim!
#endif
,
[ActSeeSvy] =