2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_survey.h: surveys
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_SVY
|
|
|
|
|
#define _SWAD_SVY
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01: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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "swad_date.h"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.h"
|
2022-09-24 18:30:26 +02:00
|
|
|
|
#include "swad_notification.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Public types and constants ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Svy_MAX_CHARS_SURVEY_TITLE (128 - 1) // 127
|
|
|
|
|
#define Svy_MAX_BYTES_SURVEY_TITLE ((Svy_MAX_CHARS_SURVEY_TITLE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-18 18:22:26 +02:00
|
|
|
|
#define Svy_ORDER_DEFAULT Dat_STR_TIME
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long SvyCod;
|
2023-09-22 14:47:56 +02:00
|
|
|
|
Hie_Level_t Level;
|
2023-07-11 19:12:24 +02:00
|
|
|
|
long HieCod; // Country, institution, center, degree or course code
|
2017-05-22 21:03:14 +02:00
|
|
|
|
unsigned Roles; // Example: if survey can be made by students, Roles == (1 << Rol_STD)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long UsrCod;
|
2017-03-08 03:48:23 +01:00
|
|
|
|
char Title[Svy_MAX_BYTES_SURVEY_TITLE + 1];
|
2021-10-24 16:55:47 +02:00
|
|
|
|
time_t TimeUTC[Dat_NUM_START_END_TIME];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumQsts; // Number of questions in the survey
|
|
|
|
|
unsigned NumUsrs; // Number of distinct users who have already answered the survey
|
|
|
|
|
struct
|
|
|
|
|
{
|
2023-06-06 22:18:31 +02:00
|
|
|
|
HidVis_HiddenOrVisible_t HiddenOrVisible; // Survey is hidden or visible?
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Open; // Start date <= now <= end date
|
|
|
|
|
bool IAmLoggedWithAValidRoleToAnswer; // I am logged with a valid role to answer this survey
|
2016-10-27 01:30:14 +02:00
|
|
|
|
bool IBelongToScope; // I belong to the scope of this survey
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool IHaveAnswered; // I have already answered this survey
|
|
|
|
|
bool ICanAnswer;
|
|
|
|
|
bool ICanViewResults;
|
2023-05-22 14:34:35 +02:00
|
|
|
|
bool ICanViewComments;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanEdit;
|
|
|
|
|
} Status;
|
|
|
|
|
};
|
|
|
|
|
|
2022-10-02 00:54:48 +02:00
|
|
|
|
struct Svy_Surveys
|
|
|
|
|
{
|
|
|
|
|
bool LstIsRead; // Is the list already read from database, or it needs to be read?
|
|
|
|
|
unsigned Num; // Number of surveys
|
|
|
|
|
long *LstSvyCods; // List of survey codes
|
|
|
|
|
Dat_StartEndTime_t SelectedOrder;
|
|
|
|
|
unsigned CurrentPage;
|
|
|
|
|
struct Svy_Survey Svy; // Selected/current survey
|
|
|
|
|
long QstCod;
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#define Svy_NUM_ANS_TYPES 2
|
2017-01-29 21:41:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
Svy_ANS_UNIQUE_CHOICE = 0,
|
|
|
|
|
Svy_ANS_MULTIPLE_CHOICE = 1,
|
|
|
|
|
} Svy_AnswerType_t;
|
|
|
|
|
#define Svy_ANSWER_TYPE_DEFAULT Svy_ANS_UNIQUE_CHOICE
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-05-22 14:34:35 +02:00
|
|
|
|
#define Svy_MAX_ANSWERS_PER_QUESTION 10
|
|
|
|
|
struct Svy_Question // Must be initialized to 0 before using it
|
|
|
|
|
{
|
|
|
|
|
long QstCod;
|
|
|
|
|
unsigned QstInd;
|
|
|
|
|
Svy_AnswerType_t AnswerType;
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
char *Text;
|
|
|
|
|
} AnsChoice[Svy_MAX_ANSWERS_PER_QUESTION];
|
|
|
|
|
bool CommentsAllowed;
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Svy_ResetSurveys (struct Svy_Surveys *Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Svy_SeeAllSurveys (void);
|
2022-09-24 18:30:26 +02:00
|
|
|
|
void Svy_ListAllSurveys (struct Svy_Surveys *Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Svy_SeeOneSurvey (void);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void Svy_PutParSvyOrder (Dat_StartEndTime_t SelectedOrder);
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void Svy_ReqCreatOrEditSvy (void);
|
2023-03-23 09:35:20 +01:00
|
|
|
|
void Svy_GetSurveyDataByCod (struct Svy_Survey *Svy);
|
|
|
|
|
void Svy_GetSurveyDataByFolder (struct Svy_Survey *Svy);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
void Svy_FreeListSurveys (struct Svy_Surveys *Surveys);
|
2017-03-08 14:12:33 +01:00
|
|
|
|
void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
2017-03-06 13:01:16 +01:00
|
|
|
|
char **ContentStr,
|
2023-11-05 19:44:03 +01:00
|
|
|
|
long SvyCod,Ntf_GetContent_t GetContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Svy_AskRemSurvey (void);
|
|
|
|
|
void Svy_RemoveSurvey (void);
|
|
|
|
|
void Svy_AskResetSurvey (void);
|
|
|
|
|
void Svy_ResetSurvey (void);
|
|
|
|
|
void Svy_HideSurvey (void);
|
|
|
|
|
void Svy_UnhideSurvey (void);
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Svy_ReceiveFormSurvey (void);
|
2023-09-22 14:47:56 +02:00
|
|
|
|
void Svy_RemoveSurveys (Hie_Level_t Level,long Cod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void Svy_ReqEditQuestion (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Svy_ReceiveQst (void);
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void Svy_ReqRemQst (void);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
void Svy_RemoveQst (void);
|
|
|
|
|
|
|
|
|
|
void Svy_ReceiveSurveyAnswers (void);
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
unsigned Svy_GetNumCrsSurveys (Hie_Level_t Level,unsigned *NumNotif);
|
2021-10-04 14:36:35 +02:00
|
|
|
|
|
2022-01-03 02:47:16 +01:00
|
|
|
|
//-------------------------------- Figures ------------------------------------
|
|
|
|
|
void Svy_GetAndShowSurveysStats (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#endif
|