mirror of https://github.com/acanas/swad-core.git
Version 22.10: Sep 19, 2022 Links to surveys in program.
This commit is contained in:
parent
dae5efb1d6
commit
5bef9711e3
|
@ -837,6 +837,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
[ActRstSvy ] = { 985,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_ResetSurvey ,NULL},
|
||||
[ActHidSvy ] = { 977,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_HideSurvey ,NULL},
|
||||
[ActUnhSvy ] = { 978,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_UnhideSurvey ,NULL},
|
||||
[ActReqLnkSvy ] = {1937,-1,TabUnk,ActSeeAllSvy ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_GetLinkToSurvey ,NULL},
|
||||
[ActEdiOneSvyQst ] = { 979,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_RequestEditQuestion ,NULL},
|
||||
[ActRcvSvyQst ] = { 980,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_ReceiveQst ,NULL},
|
||||
[ActReqRemSvyQst ] = {1524,-1,TabUnk,ActSeeAllSvy ,0x3E0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,0x3C0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Svy_RequestRemoveQst ,NULL},
|
||||
|
@ -3783,6 +3784,7 @@ Act_Action_t Act_FromActCodToAction[1 + Act_MAX_ACTION_COD] = // Do not reuse un
|
|||
ActReqLnkCfe, // #1934
|
||||
ActReqLnkGam, // #1935
|
||||
ActReqLnkExa, // #1936
|
||||
ActReqLnkSvy, // #1937
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -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 1936
|
||||
#define Act_MAX_ACTION_COD 1937
|
||||
|
||||
#define Act_MAX_OPTIONS_IN_MENU_PER_TAB 13
|
||||
|
||||
|
@ -792,10 +792,12 @@ typedef signed int Act_Action_t; // Must be a signed type, because -1 is used to
|
|||
#define ActRstSvy (ActChgCrsTT1stDay + 236)
|
||||
#define ActHidSvy (ActChgCrsTT1stDay + 237)
|
||||
#define ActUnhSvy (ActChgCrsTT1stDay + 238)
|
||||
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 239)
|
||||
#define ActRcvSvyQst (ActChgCrsTT1stDay + 240)
|
||||
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 241)
|
||||
#define ActRemSvyQst (ActChgCrsTT1stDay + 242)
|
||||
#define ActReqLnkSvy (ActChgCrsTT1stDay + 239)
|
||||
|
||||
#define ActEdiOneSvyQst (ActChgCrsTT1stDay + 240)
|
||||
#define ActRcvSvyQst (ActChgCrsTT1stDay + 241)
|
||||
#define ActReqRemSvyQst (ActChgCrsTT1stDay + 242)
|
||||
#define ActRemSvyQst (ActChgCrsTT1stDay + 243)
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************** Files tab **********************************/
|
||||
|
|
|
@ -606,10 +606,11 @@ 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.9.1 (2022-09-19)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 22.10 (2022-09-19)"
|
||||
#define CSS_FILE "swad22.7.css"
|
||||
#define JS_FILE "swad21.100.js"
|
||||
/*
|
||||
Version 22.10: Sep 19, 2022 Links to surveys in program. (330822 lines)
|
||||
Version 22.9.1: Sep 19, 2022 Text for icons in program. (330725 lines)
|
||||
Version 22.9: Sep 19, 2022 Links to exams in program. (330491 lines)
|
||||
Version 22.8: Sep 18, 2022 Links to games in program. (330355 lines)
|
||||
|
|
|
@ -1028,7 +1028,7 @@ static void PrgRsc_WriteLinkName (const struct Prg_Link *Link,bool PutForm)
|
|||
Gam_WriteGameInCrsProgram (Link->Cod,PutForm);
|
||||
break;
|
||||
case PrgRsc_SURVEY:
|
||||
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
|
||||
Svy_WriteSurveyInCrsProgram (Link->Cod,PutForm);
|
||||
break;
|
||||
case PrgRsc_DOCUMENT:
|
||||
Brw_WriteFileNameInCrsProgram (Link->Cod,PutForm);
|
||||
|
@ -1080,7 +1080,9 @@ static void PrgRsc_GetResourceTitleFromLink (struct Prg_Item *Item)
|
|||
sizeof (Item->Resource.Title) - 1);
|
||||
break;
|
||||
case PrgRsc_SURVEY:
|
||||
Ale_ShowAlert (Ale_ERROR,"Not implemented!");
|
||||
Svy_GetTitleFromSvyCod (Item->Resource.Link.Cod,
|
||||
Item->Resource.Title,
|
||||
sizeof (Item->Resource.Title) - 1);
|
||||
break;
|
||||
case PrgRsc_DOCUMENT:
|
||||
Brw_GetFileNameFromFilCod (Item->Resource.Link.Cod,
|
||||
|
|
110
swad_survey.c
110
swad_survey.c
|
@ -47,6 +47,8 @@
|
|||
#include "swad_notification_database.h"
|
||||
#include "swad_pagination.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_program.h"
|
||||
#include "swad_program_database.h"
|
||||
#include "swad_role.h"
|
||||
#include "swad_setting.h"
|
||||
#include "swad_survey.h"
|
||||
|
@ -97,6 +99,7 @@ static void Svy_PutParamsToCreateNewSvy (void *Surveys);
|
|||
static void Svy_ParamsWhichGroupsToShow (void *Surveys);
|
||||
static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
||||
long SvyCod,bool ShowOnlyThisSvyComplete);
|
||||
static void Svy_PutIconsOneSvy (void *Surveys);
|
||||
static void Svy_WriteAuthor (struct Svy_Survey *Svy);
|
||||
static void Svy_WriteStatus (struct Svy_Survey *Svy);
|
||||
static Dat_StartEndTime_t Svy_GetParamSvyOrder (void);
|
||||
|
@ -441,15 +444,16 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
struct Svy_Survey Svy;
|
||||
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
||||
|
||||
/***** Begin box *****/
|
||||
if (ShowOnlyThisSvyComplete)
|
||||
Box_BoxBegin (NULL,Txt_Survey,
|
||||
NULL,NULL,
|
||||
Hlp_ASSESSMENT_Surveys,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Get data of this survey *****/
|
||||
Svy.SvyCod = SvyCod;
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
Surveys->SvyCod = Svy.SvyCod; // Used as parameters in contextual links
|
||||
|
||||
/***** Begin box *****/
|
||||
if (ShowOnlyThisSvyComplete)
|
||||
Box_BoxBegin (NULL,Txt_Survey,
|
||||
Svy_PutIconsOneSvy,Surveys,
|
||||
Hlp_ASSESSMENT_Surveys,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Set anchor string *****/
|
||||
Frm_SetAnchorStr (Svy.SvyCod,&Anchor);
|
||||
|
@ -720,6 +724,18 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
Frm_FreeAnchorStr (Anchor);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Put contextual icons in a survey ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Svy_PutIconsOneSvy (void *Surveys)
|
||||
{
|
||||
/***** Put icon to get resource link *****/
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) // Only if I am superuser // TODO: Include teachers
|
||||
Ico_PutContextualIconToGetLink (ActReqLnkSvy,NULL,
|
||||
Svy_PutParams,Surveys);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Write the author of a survey ************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -878,8 +894,6 @@ static void Svy_PutFormsToRemEditOneSvy (struct Svy_Surveys *Surveys,
|
|||
[true ] = ActUnhSvy, // Hidden ==> action to unhide
|
||||
};
|
||||
|
||||
Surveys->SvyCod = Svy->SvyCod; // Used as parameters in contextual links
|
||||
|
||||
/***** Icon to remove survey *****/
|
||||
Ico_PutContextualIconToRemove (ActReqRemSvy,NULL,
|
||||
Svy_PutParams,Surveys);
|
||||
|
@ -3438,3 +3452,83 @@ void Svy_GetAndShowSurveysStats (void)
|
|||
/***** End table and box *****/
|
||||
Box_BoxTableEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************************** Get link to survey *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Svy_GetLinkToSurvey (void)
|
||||
{
|
||||
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
|
||||
struct Svy_Surveys Surveys;
|
||||
long SvyCod;
|
||||
char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1];
|
||||
|
||||
/***** Reset surveys context *****/
|
||||
Svy_ResetSurveys (&Surveys);
|
||||
|
||||
/***** Get survey code *****/
|
||||
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get survey title *****/
|
||||
Svy_DB_GetSurveyTitle (SvyCod,Title);
|
||||
|
||||
/***** Copy link to survey into resource clipboard *****/
|
||||
Prg_DB_CopyToClipboard (PrgRsc_SURVEY,SvyCod);
|
||||
|
||||
/***** Write sucess message *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
|
||||
Title);
|
||||
|
||||
/***** Show surveys again *****/
|
||||
Svy_ListAllSurveys (&Surveys);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Write survey in course program ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Svy_WriteSurveyInCrsProgram (long SvyCod,bool PutFormToGo)
|
||||
{
|
||||
extern const char *Txt_Actions[Act_NUM_ACTIONS];
|
||||
char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1];
|
||||
|
||||
/***** Get survey title *****/
|
||||
Svy_DB_GetSurveyTitle (SvyCod,Title);
|
||||
|
||||
/***** Begin form to go to survey *****/
|
||||
if (PutFormToGo)
|
||||
{
|
||||
Frm_BeginForm (ActSeeSvy);
|
||||
Svy_PutParamSvyCod (SvyCod);
|
||||
HTM_BUTTON_Submit_Begin (Txt_Actions[ActSeeSvy],
|
||||
"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 survey title from survey code *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Svy_GetTitleFromSvyCod (long SvyCod,char *Title,size_t TitleSize)
|
||||
{
|
||||
char TitleFromDB[Svy_MAX_BYTES_SURVEY_TITLE + 1];
|
||||
|
||||
/***** Get survey title *****/
|
||||
Svy_DB_GetSurveyTitle (SvyCod,TitleFromDB);
|
||||
Str_Copy (Title,TitleFromDB,TitleSize);
|
||||
}
|
||||
|
|
|
@ -117,4 +117,8 @@ unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif);
|
|||
//-------------------------------- Figures ------------------------------------
|
||||
void Svy_GetAndShowSurveysStats (void);
|
||||
|
||||
//--------------------------- Program resources -------------------------------
|
||||
void Svy_GetLinkToSurvey (void);
|
||||
void Svy_WriteSurveyInCrsProgram (long SvyCod,bool PutFormToGo);
|
||||
void Svy_GetTitleFromSvyCod (long SvyCod,char *Title,size_t TitleSize);
|
||||
#endif
|
||||
|
|
|
@ -287,7 +287,20 @@ unsigned Svy_DB_GetDataOfSurveyByCod (MYSQL_RES **mysql_res,long SvyCod)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Get survey data using its code ************************/
|
||||
/******************** Get survey title using its code ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Svy_DB_GetSurveyTitle (long SvyCod,char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1])
|
||||
{
|
||||
DB_QuerySELECTString (Title,Svy_MAX_BYTES_SURVEY_TITLE,"can not get survey title",
|
||||
"SELECT Title" // row[0]
|
||||
" FROM svy_surveys"
|
||||
" WHERE SvyCod=%ld", // Extra check
|
||||
SvyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get survey title and text using its code ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Svy_DB_GetSurveyTitleAndText (MYSQL_RES **mysql_res,long SvyCod)
|
||||
|
|
|
@ -48,6 +48,7 @@ unsigned Svy_DB_GetListSurveys (MYSQL_RES **mysql_res,
|
|||
unsigned HiddenAllowed,
|
||||
Dat_StartEndTime_t SelectedOrder);
|
||||
unsigned Svy_DB_GetDataOfSurveyByCod (MYSQL_RES **mysql_res,long SvyCod);
|
||||
void Svy_DB_GetSurveyTitle (long SvyCod,char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1]);
|
||||
unsigned Svy_DB_GetSurveyTitleAndText (MYSQL_RES **mysql_res,long SvyCod);
|
||||
void Svy_DB_GetSurveyTxt (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
|
||||
bool Svy_DB_CheckIfSimilarSurveyExists (const struct Svy_Survey *Svy);
|
||||
|
|
Loading…
Reference in New Issue