2016-10-27 15:06:11 +02:00
|
|
|
|
// swad_survey.c: surveys
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-01-03 15:25:18 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <linux/limits.h> // For PATH_MAX
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2019-01-03 15:25:18 +01:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_attendance.h"
|
2021-11-28 00:49:23 +01:00
|
|
|
|
#include "swad_autolink.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
|
|
|
|
#include "swad_group.h"
|
2021-06-17 13:55:45 +02:00
|
|
|
|
#include "swad_group_database.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notification.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_pagination.h"
|
|
|
|
|
#include "swad_parameter.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role.h"
|
2019-03-26 11:53:21 +01:00
|
|
|
|
#include "swad_setting.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_survey.h"
|
2021-10-20 17:57:27 +02:00
|
|
|
|
#include "swad_survey_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#define Svy_MAX_CHARS_ANSWER (1024 - 1) // 1023
|
|
|
|
|
#define Svy_MAX_BYTES_ANSWER ((Svy_MAX_CHARS_ANSWER + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383
|
2017-03-08 03:48:23 +01:00
|
|
|
|
|
2019-11-08 01:10:32 +01:00
|
|
|
|
#define Svy_MAX_BYTES_LIST_ANSWER_TYPES (Svy_NUM_ANS_TYPES * (Cns_MAX_DECIMAL_DIGITS_UINT + 1))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
#define Svy_MAX_ANSWERS_PER_QUESTION 10
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Question // Must be initialized to 0 before using it
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long QstCod;
|
|
|
|
|
unsigned QstInd;
|
|
|
|
|
Svy_AnswerType_t AnswerType;
|
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
char *Text;
|
|
|
|
|
} AnsChoice[Svy_MAX_ANSWERS_PER_QUESTION];
|
|
|
|
|
bool AllAnsTypes;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char ListAnsTypes[Svy_MAX_BYTES_LIST_ANSWER_TYPES + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ResetSurveys (struct Svy_Surveys *Surveys);
|
|
|
|
|
|
|
|
|
|
static void Svy_ListAllSurveys (struct Svy_Surveys *Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Svy_CheckIfICanCreateSvy (void);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconsListSurveys (void *Surveys);
|
|
|
|
|
static void Svy_PutIconToCreateNewSvy (struct Svy_Surveys *Surveys);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToCreateNewSvy (struct Svy_Surveys *Surveys);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParamsToCreateNewSvy (void *Surveys);
|
|
|
|
|
static void Svy_ParamsWhichGroupsToShow (void *Surveys);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|
|
|
|
long SvyCod,bool ShowOnlyThisSvyComplete);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_WriteAuthor (struct Svy_Survey *Svy);
|
|
|
|
|
static void Svy_WriteStatus (struct Svy_Survey *Svy);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static Dat_StartEndTime_t Svy_GetParamSvyOrder (void);
|
2015-04-02 18:39:49 +02:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutFormsToRemEditOneSvy (struct Svy_Surveys *Surveys,
|
|
|
|
|
const struct Svy_Survey *Svy,
|
2019-04-20 22:50:57 +02:00
|
|
|
|
const char *Anchor);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParams (void *Surveys);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_GetListSurveys (struct Svy_Surveys *Surveys);
|
2019-09-29 17:33:39 +02:00
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed,
|
|
|
|
|
unsigned *HiddenAllowed);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_PutParamSvyCod (long SvyCod);
|
|
|
|
|
static long Svy_GetParamSvyCod (void);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToResetSurvey (struct Svy_Surveys *Surveys);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_ShowLstGrpsToEditSurvey (long SvyCod);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_CreateSurvey (struct Svy_Survey *Svy,const char *Txt);
|
|
|
|
|
static void Svy_UpdateSurvey (struct Svy_Survey *Svy,const char *Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_CreateGrps (long SvyCod);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Svy_Survey *Svy);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|
|
|
|
long SvyCod,struct Svy_Question *SvyQst,
|
2021-10-24 16:55:47 +02:00
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1]);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_InitQst (struct Svy_Question *SvyQst);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_PutParamQstCod (long QstCod);
|
|
|
|
|
static long Svy_GetParamQstCod (void);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns);
|
|
|
|
|
static void Svy_FreeTextChoiceAnswers (struct Svy_Question *SvyQst,unsigned NumAnswers);
|
|
|
|
|
static void Svy_FreeTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
static unsigned Svy_GetNextQuestionIndexInSvy (long SvyCod);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys,
|
|
|
|
|
struct Svy_Survey *Svy);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
static void Svy_GetDataOfQstFromRow (struct Svy_Question *SvyQst,
|
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1],
|
|
|
|
|
MYSQL_ROW row);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParamsToEditQuestion (void *Surveys);
|
|
|
|
|
static void Svy_PutIconToAddNewQuestion (void *Surveys);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToCreateNewQuestion (struct Svy_Surveys *Surveys);
|
2015-09-06 11:36:34 +02:00
|
|
|
|
static void Svy_WriteQstStem (const char *Stem);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Question *SvyQst,
|
2017-11-30 12:07:19 +01:00
|
|
|
|
bool PutFormAnswerSurvey);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs);
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconToRemoveOneQst (void *Surveys);
|
|
|
|
|
static void Svy_PutParamsRemoveOneQst (void *Surveys);
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod);
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Reset surveys context ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_ResetSurveys (struct Svy_Surveys *Surveys)
|
|
|
|
|
{
|
|
|
|
|
Surveys->LstIsRead = false; // Is the list already read from database, or it needs to be read?
|
|
|
|
|
Surveys->Num = 0; // Number of surveys
|
|
|
|
|
Surveys->LstSvyCods = NULL; // List of survey codes
|
|
|
|
|
Surveys->SelectedOrder = Svy_ORDER_DEFAULT;
|
|
|
|
|
Surveys->CurrentPage = 0;
|
|
|
|
|
Surveys->SvyCod = -1L;
|
|
|
|
|
Surveys->QstCod = -1L;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2019-09-26 23:57:10 +02:00
|
|
|
|
/***************************** List all surveys ******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_SeeAllSurveys (void)
|
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
|
|
|
|
|
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-09-26 23:57:10 +02:00
|
|
|
|
/***** Show all surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***************************** Show all surveys ******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ListAllSurveys (struct Svy_Surveys *Surveys)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-02 16:57:49 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
extern const char *Txt_Surveys;
|
2016-12-15 00:39:52 +01:00
|
|
|
|
extern const char *Txt_START_END_TIME_HELP[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_START_END_TIME[Dat_NUM_START_END_TIME];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Survey;
|
|
|
|
|
extern const char *Txt_Status;
|
2016-03-19 20:03:39 +01:00
|
|
|
|
extern const char *Txt_No_surveys;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_StartEndTime_t Order;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Pagination Pagination;
|
|
|
|
|
unsigned NumSvy;
|
|
|
|
|
|
2016-10-29 00:22:34 +02:00
|
|
|
|
/***** Get number of groups in current course *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (!Gbl.Crs.Grps.NumGrps)
|
|
|
|
|
Gbl.Crs.Grps.WhichGrps = Grp_ALL_GROUPS;
|
2016-10-29 00:22:34 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_GetListSurveys (Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-01-02 12:57:26 +01:00
|
|
|
|
/***** Compute variables related to pagination *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Pagination.NumItems = Surveys->Num;
|
|
|
|
|
Pagination.CurrentPage = (int) Surveys->CurrentPage;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
Pag_CalculatePagination (&Pagination);
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys->CurrentPage = (unsigned) Pagination.CurrentPage;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin ("100%",Txt_Surveys,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutIconsListSurveys,Surveys,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_ASSESSMENT_Surveys,Box_NOT_CLOSABLE);
|
2015-01-02 12:57:26 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Select whether show only my groups or all groups *****/
|
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
|
|
|
|
{
|
|
|
|
|
Set_BeginSettingsHead ();
|
|
|
|
|
Grp_ShowFormToSelWhichGrps (ActSeeAllSvy,
|
|
|
|
|
Svy_ParamsWhichGroupsToShow,Surveys);
|
|
|
|
|
Set_EndSettingsHead ();
|
|
|
|
|
}
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_SURVEYS,&Pagination,
|
|
|
|
|
Surveys,-1L);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
if (Surveys->Num)
|
2016-03-19 20:03:39 +01:00
|
|
|
|
{
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Table head *****/
|
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (5);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
for (Order = Dat_STR_TIME;
|
|
|
|
|
Order <= Dat_END_TIME;
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
|
|
|
|
HTM_TH_Begin (1,1,"LM");
|
|
|
|
|
|
|
|
|
|
/* Form to change order */
|
|
|
|
|
Frm_BeginForm (ActSeeAllSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,Surveys->CurrentPage);
|
|
|
|
|
Dat_PutHiddenParamOrder (Order);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_START_END_TIME_HELP[Order],
|
|
|
|
|
"BT_LINK TIT_TBL",NULL);
|
|
|
|
|
if (Order == Surveys->SelectedOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
HTM_Txt (Txt_START_END_TIME[Order]);
|
|
|
|
|
if (Order == Surveys->SelectedOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
}
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TH (1,1,"LM",Txt_Survey);
|
|
|
|
|
HTM_TH (1,1,"CM",Txt_Status);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TR_End ();
|
2016-03-19 20:03:39 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Write all surveys *****/
|
|
|
|
|
for (NumSvy = Pagination.FirstItemVisible;
|
|
|
|
|
NumSvy <= Pagination.LastItemVisible;
|
|
|
|
|
NumSvy++)
|
|
|
|
|
Svy_ShowOneSurvey (Surveys,Surveys->LstSvyCods[NumSvy - 1],false);
|
2016-03-19 20:03:39 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
}
|
|
|
|
|
else // No surveys created
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_surveys);
|
2016-03-19 20:03:39 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_SURVEYS,&Pagination,
|
|
|
|
|
Surveys,-1L);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/***** Button to create a new survey *****/
|
|
|
|
|
if (Svy_CheckIfICanCreateSvy ())
|
|
|
|
|
Svy_PutButtonToCreateNewSvy (Surveys);
|
2016-03-19 20:03:39 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free list of surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_FreeListSurveys (Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-11-07 00:12:30 +01:00
|
|
|
|
/******************* Check if I can create a new survey **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Svy_CheckIfICanCreateSvy (void)
|
|
|
|
|
{
|
2021-11-10 23:05:08 +01:00
|
|
|
|
static const bool ICanCreateSvy[Rol_NUM_ROLES] =
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-10 23:05:08 +01:00
|
|
|
|
[Rol_TCH ] = true,
|
|
|
|
|
[Rol_DEG_ADM] = true,
|
|
|
|
|
[Rol_CTR_ADM] = true,
|
|
|
|
|
[Rol_INS_ADM] = true,
|
|
|
|
|
[Rol_SYS_ADM] = true,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ICanCreateSvy[Gbl.Usrs.Me.Role.Logged];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 00:12:30 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put contextual icons in list of surveys *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconsListSurveys (void *Surveys)
|
2016-11-07 00:12:30 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
/***** Put icon to create a new survey *****/
|
|
|
|
|
if (Svy_CheckIfICanCreateSvy ())
|
|
|
|
|
Svy_PutIconToCreateNewSvy ((struct Svy_Surveys *) Surveys);
|
2016-11-07 00:12:30 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_SURVEYS);
|
2016-11-07 00:12:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-19 20:03:39 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Put icon to create a new survey **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconToCreateNewSvy (struct Svy_Surveys *Surveys)
|
2016-03-19 20:03:39 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_survey;
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToAdd (ActFrmNewSvy,NULL,
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutParamsToCreateNewSvy,Surveys,
|
2019-01-10 15:26:33 +01:00
|
|
|
|
Txt_New_survey);
|
2016-03-19 20:03:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put button to create a new survey *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToCreateNewSvy (struct Svy_Surveys *Surveys)
|
2016-03-19 20:03:39 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_survey;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActFrmNewSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamsToCreateNewSvy (Surveys);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_survey);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-03-19 20:03:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Put parameters to create a new survey *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParamsToCreateNewSvy (void *Surveys)
|
2016-03-19 20:03:39 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Surveys)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutHiddenParamSvyOrder (((struct Svy_Surveys *) Surveys)->SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,((struct Svy_Surveys *) Surveys)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2016-03-19 20:03:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2019-02-25 15:14:28 +01:00
|
|
|
|
/**************** Put params to select which groups to show ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_ParamsWhichGroupsToShow (void *Surveys)
|
2016-12-04 23:09:28 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Surveys)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutHiddenParamSvyOrder (((struct Svy_Surveys *) Surveys)->SelectedOrder);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,((struct Svy_Surveys *) Surveys)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Show one survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_SeeOneSurvey (void)
|
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-07-02 19:46:53 +02:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,Svy.SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Show one survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|
|
|
|
long SvyCod,bool ShowOnlyThisSvyComplete)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-02 16:57:49 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys;
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2021-12-15 14:02:49 +01:00
|
|
|
|
extern const char *The_ClassDatLight[The_NUM_THEMES];
|
2015-04-12 18:01:06 +02:00
|
|
|
|
extern const char *Txt_Survey;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_View_survey;
|
2020-05-07 14:15:39 +02:00
|
|
|
|
extern const char *Txt_Number_of_questions;
|
|
|
|
|
extern const char *Txt_Number_of_users;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Scope;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
extern const char *Txt_Country;
|
|
|
|
|
extern const char *Txt_Institution;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Center;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Degree;
|
|
|
|
|
extern const char *Txt_Course;
|
|
|
|
|
extern const char *Txt_Users;
|
|
|
|
|
extern const char *Txt_Answer_survey;
|
2020-05-18 22:59:07 +02:00
|
|
|
|
extern const char *Txt_View_results;
|
2019-04-20 22:50:57 +02:00
|
|
|
|
char *Anchor = NULL;
|
2015-10-23 13:51:33 +02:00
|
|
|
|
static unsigned UniqueId = 0;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2015-04-12 18:01:06 +02:00
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Survey,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_ASSESSMENT_Surveys,Box_NOT_CLOSABLE);
|
2015-04-12 18:01:06 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get data of this survey *****/
|
|
|
|
|
Svy.SvyCod = SvyCod;
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
|
2019-04-20 22:50:57 +02:00
|
|
|
|
/***** Set anchor string *****/
|
|
|
|
|
Frm_SetAnchorStr (Svy.SvyCod,&Anchor);
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2016-11-13 00:50:24 +01:00
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2016-11-13 00:50:24 +01:00
|
|
|
|
|
2017-05-02 11:39:17 +02:00
|
|
|
|
/***** Write first row of data of this assignment *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-09 23:49:29 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* Forms to remove/edit this assignment */
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"CONTEXT_COL COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
if (Svy.Status.ICanEdit)
|
|
|
|
|
Svy_PutFormsToRemEditOneSvy (Surveys,&Svy,Anchor);
|
|
|
|
|
HTM_TD_End ();
|
2016-03-24 22:03:24 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* Start date/time */
|
|
|
|
|
UniqueId++;
|
|
|
|
|
if (asprintf (&Id,"svy_date_start_%u",UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
|
|
|
|
Id,
|
|
|
|
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED") :
|
|
|
|
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT"));
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
|
|
|
|
Id,
|
|
|
|
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED") :
|
|
|
|
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT"),
|
|
|
|
|
Gbl.RowEvenOdd);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Svy.TimeUTC[Dat_STR_TIME],
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
|
|
|
|
true,true,true,0x7);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
free (Id);
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* End date/time */
|
|
|
|
|
if (asprintf (&Id,"svy_date_end_%u",UniqueId) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
|
|
|
|
Id,
|
|
|
|
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED") :
|
|
|
|
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT"));
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
|
|
|
|
Id,
|
|
|
|
|
Svy.Status.Visible ? (Svy.Status.Open ? "DATE_GREEN" :
|
|
|
|
|
"DATE_RED") :
|
|
|
|
|
(Svy.Status.Open ? "DATE_GREEN_LIGHT" :
|
|
|
|
|
"DATE_RED_LIGHT"),
|
|
|
|
|
Gbl.RowEvenOdd);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,Svy.TimeUTC[Dat_END_TIME],
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
|
|
|
|
true,false,true,0x7);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
free (Id);
|
|
|
|
|
|
|
|
|
|
/* Survey title */
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_ARTICLE_Begin (Anchor);
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamSvyCod (SvyCod);
|
|
|
|
|
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
|
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,Surveys->CurrentPage);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_View_survey,
|
|
|
|
|
Svy.Status.Visible ? "BT_LINK LT ASG_TITLE" :
|
|
|
|
|
"BT_LINK LT ASG_TITLE_LIGHT",
|
|
|
|
|
NULL);
|
|
|
|
|
HTM_Txt (Svy.Title);
|
|
|
|
|
HTM_BUTTON_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_ARTICLE_End ();
|
|
|
|
|
|
|
|
|
|
/* Number of questions and number of distinct users who have already answered this survey */
|
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",
|
|
|
|
|
Svy.Status.Visible ? "ASG_GRP" :
|
|
|
|
|
"ASG_GRP_LIGHT");
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Number_of_questions);
|
|
|
|
|
HTM_Unsigned (Svy.NumQsts);
|
|
|
|
|
HTM_Txt ("; ");
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Number_of_users);
|
|
|
|
|
HTM_Unsigned (Svy.NumUsrs);
|
|
|
|
|
HTM_DIV_End ();
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TD_End ();
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* Status of the survey */
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"LT\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("rowspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
Svy_WriteStatus (&Svy);
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
if (!ShowOnlyThisSvyComplete)
|
|
|
|
|
{
|
|
|
|
|
/* Possible button to answer this survey */
|
|
|
|
|
if (Svy.Status.ICanAnswer)
|
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\"");
|
|
|
|
|
|
|
|
|
|
Frm_BeginForm (ActSeeSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamSvyCod (Svy.SvyCod);
|
|
|
|
|
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
|
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,Surveys->CurrentPage);
|
|
|
|
|
Btn_PutCreateButtonInline (Txt_Answer_survey);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
|
|
|
|
/* Possible button to see the result of the survey */
|
|
|
|
|
else if (Svy.Status.ICanViewResults)
|
|
|
|
|
{
|
|
|
|
|
HTM_DIV_Begin ("class=\"BUTTONS_AFTER_ALERT\"");
|
|
|
|
|
|
|
|
|
|
Frm_BeginForm (ActSeeSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamSvyCod (Svy.SvyCod);
|
|
|
|
|
Svy_PutHiddenParamSvyOrder (Surveys->SelectedOrder);
|
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,Surveys->CurrentPage);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Btn_PutConfirmButtonInline (Txt_View_results);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
}
|
2016-03-24 22:03:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write second row of data of this survey *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* 1st column: Author of the survey */
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
Svy_WriteAuthor (&Svy);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* 2nd column: Scope, Users, Groups and Text */
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
else
|
|
|
|
|
HTM_TD_Begin ("class=\"LT COLOR%u\"",Gbl.RowEvenOdd);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* Scope of the survey */
|
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",Svy.Status.Visible ? "ASG_GRP" :
|
|
|
|
|
"ASG_GRP_LIGHT");
|
|
|
|
|
HTM_TxtColonNBSP (Txt_Scope);
|
|
|
|
|
switch (Svy.Scope)
|
|
|
|
|
{
|
|
|
|
|
case HieLvl_UNK: // Unknown
|
|
|
|
|
Err_WrongScopeExit ();
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_SYS: // System
|
|
|
|
|
HTM_Txt (Cfg_PLATFORM_SHORT_NAME);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CTY: // Country
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_Country,Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_INS: // Institution
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_Institution,Gbl.Hierarchy.Ins.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CTR: // Center
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_Center,Gbl.Hierarchy.Ctr.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_DEG: // Degree
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_Degree,Gbl.Hierarchy.Deg.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
case HieLvl_CRS: // Course
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_Course,Gbl.Hierarchy.Crs.ShrtName);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/* Users' roles who can answer the survey */
|
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",Svy.Status.Visible ? "ASG_GRP" :
|
|
|
|
|
"ASG_GRP_LIGHT");
|
|
|
|
|
HTM_TxtColon (Txt_Users);
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
Rol_WriteSelectorRoles (1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH,
|
|
|
|
|
Svy.Roles,
|
|
|
|
|
true,false);
|
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
|
|
|
|
|
/* Groups whose users can answer this survey */
|
|
|
|
|
if (Svy.Scope == HieLvl_CRS)
|
|
|
|
|
if (Gbl.Crs.Grps.NumGrps)
|
|
|
|
|
Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (&Svy);
|
|
|
|
|
|
|
|
|
|
/* Text of the survey */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_DB_GetSurveyTxt (Svy.SvyCod,Txt);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
|
|
|
|
Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to rigorous HTML
|
2021-11-28 00:49:23 +01:00
|
|
|
|
ALn_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_DIV_Begin ("class=\"PAR %s\"",Svy.Status.Visible ? The_ClassDat[Gbl.Prefs.Theme] :
|
2021-12-15 14:02:49 +01:00
|
|
|
|
The_ClassDatLight[Gbl.Prefs.Theme]);
|
2021-11-09 10:26:27 +01:00
|
|
|
|
HTM_Txt (Txt);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_DIV_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write questions of this survey *****/
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
|
|
|
|
{
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2021-10-20 16:46:34 +02:00
|
|
|
|
HTM_TD_Begin ("colspan=\"5\"");
|
|
|
|
|
Svy_ListSvyQuestions (Surveys,&Svy);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
|
|
|
|
|
|
|
|
|
/***** Mark possible notification as seen *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy.Scope == HieLvl_CRS) // Only course surveys are notified
|
2021-11-09 12:36:32 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_SURVEY,Svy.Cod);
|
2015-04-12 18:01:06 +02:00
|
|
|
|
|
|
|
|
|
if (ShowOnlyThisSvyComplete)
|
2016-11-13 00:50:24 +01:00
|
|
|
|
{
|
2021-11-09 10:26:27 +01:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
2016-11-13 00:50:24 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-11-13 00:50:24 +01:00
|
|
|
|
}
|
2019-04-20 22:50:57 +02:00
|
|
|
|
|
|
|
|
|
/***** Free anchor string *****/
|
|
|
|
|
Frm_FreeAnchorStr (Anchor);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Write the author of a survey ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_WriteAuthor (struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-03-04 01:59:27 +01:00
|
|
|
|
Usr_WriteAuthor1Line (Svy->UsrCod,!Svy->Status.Visible);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write status of a survey ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_WriteStatus (struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Hidden_survey;
|
|
|
|
|
extern const char *Txt_Visible_survey;
|
|
|
|
|
extern const char *Txt_Closed_survey;
|
|
|
|
|
extern const char *Txt_Open_survey;
|
|
|
|
|
extern const char *Txt_SURVEY_Type_of_user_not_allowed;
|
|
|
|
|
extern const char *Txt_SURVEY_Type_of_user_allowed;
|
2016-10-28 10:36:14 +02:00
|
|
|
|
extern const char *Txt_SURVEY_You_belong_to_the_scope_of_the_survey;
|
|
|
|
|
extern const char *Txt_SURVEY_You_dont_belong_to_the_scope_of_the_survey;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_SURVEY_You_have_already_answered;
|
|
|
|
|
extern const char *Txt_SURVEY_You_have_not_answered;
|
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin list with items of status *****/
|
2019-10-26 12:25:27 +02:00
|
|
|
|
HTM_UL_Begin (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Write whether survey is visible or hidden */
|
|
|
|
|
if (Svy->Status.Visible)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"STATUS_GREEN\"");
|
|
|
|
|
HTM_Txt (Txt_Visible_survey);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"STATUS_RED_LIGHT\"");
|
|
|
|
|
HTM_Txt (Txt_Hidden_survey);
|
|
|
|
|
}
|
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Write whether survey is open or closed */
|
|
|
|
|
if (Svy->Status.Open)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_GREEN" :
|
|
|
|
|
"STATUS_GREEN_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_Open_survey);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_RED" :
|
|
|
|
|
"STATUS_RED_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_Closed_survey);
|
|
|
|
|
}
|
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Write whether survey can be answered by me or not depending on user type */
|
|
|
|
|
if (Svy->Status.IAmLoggedWithAValidRoleToAnswer)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_GREEN" :
|
|
|
|
|
"STATUS_GREEN_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_Type_of_user_allowed);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_RED" :
|
|
|
|
|
"STATUS_RED_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_Type_of_user_not_allowed);
|
|
|
|
|
}
|
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Write whether survey can be answered by me or not depending on groups */
|
|
|
|
|
if (Svy->Status.IBelongToScope)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_GREEN" :
|
|
|
|
|
"STATUS_GREEN_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_You_belong_to_the_scope_of_the_survey);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_RED" :
|
|
|
|
|
"STATUS_RED_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_You_dont_belong_to_the_scope_of_the_survey);
|
|
|
|
|
}
|
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/* Write whether survey has been already answered by me or not */
|
|
|
|
|
if (Svy->Status.IHaveAnswered)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_GREEN" :
|
|
|
|
|
"STATUS_GREEN_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_You_have_already_answered);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",
|
|
|
|
|
Svy->Status.Visible ? "STATUS_RED" :
|
|
|
|
|
"STATUS_RED_LIGHT");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_You_have_not_answered);
|
|
|
|
|
}
|
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** End list with items of status *****/
|
2019-10-26 02:19:42 +02:00
|
|
|
|
HTM_UL_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********* Get parameter with the type or order in list of surveys ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static Dat_StartEndTime_t Svy_GetParamSvyOrder (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
return (Dat_StartEndTime_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Dat_NUM_START_END_TIME - 1,
|
|
|
|
|
(unsigned long) Svy_ORDER_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Put a hidden parameter with the type of order in list of surveys ******/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
void Svy_PutHiddenParamSvyOrder (Dat_StartEndTime_t SelectedOrder)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (SelectedOrder);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Put a link (form) to edit one survey ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutFormsToRemEditOneSvy (struct Svy_Surveys *Surveys,
|
|
|
|
|
const struct Svy_Survey *Svy,
|
2019-04-20 22:50:57 +02:00
|
|
|
|
const char *Anchor)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Reset;
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys->SvyCod = Svy->SvyCod; // Used as parameters in contextual links
|
2015-12-13 19:37:08 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Put form to remove survey *****/
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemSvy,NULL,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to reset survey *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActReqRstSvy,NULL,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,Surveys,
|
2019-01-12 03:00:59 +01:00
|
|
|
|
"recycle.svg",
|
|
|
|
|
Txt_Reset);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to hide/show survey *****/
|
2019-04-20 22:50:57 +02:00
|
|
|
|
if (Svy->Status.Visible)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToHide (ActHidSvy,Anchor,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToUnhide (ActShoSvy,Anchor,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Put form to edit survey *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneSvy,NULL,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2015-12-13 19:37:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Params used to edit a survey *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParams (void *Surveys)
|
2015-12-13 19:37:08 +01:00
|
|
|
|
{
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_WhichGroups_t WhichGroups;
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Surveys)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
if (((struct Svy_Surveys *) Surveys)->SvyCod > 0)
|
|
|
|
|
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->SvyCod);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (((struct Svy_Surveys *) Surveys)->SelectedOrder);
|
2020-03-27 14:56:54 +01:00
|
|
|
|
WhichGroups = Grp_GetParamWhichGroups ();
|
|
|
|
|
Grp_PutParamWhichGroups (&WhichGroups);
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_SURVEYS,((struct Svy_Surveys *) Surveys)->CurrentPage);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2015-12-13 19:37:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/************************** Get list of all surveys **************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumSvy;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
unsigned ScopesAllowed = 0;
|
|
|
|
|
unsigned HiddenAllowed = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
/***** Free list of surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
if (Surveys->LstIsRead)
|
|
|
|
|
Svy_FreeListSurveys (Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
/***** Set allowed and hidden scopes to get list depending on my user's role *****/
|
|
|
|
|
Svy_SetAllowedAndHiddenScopes (&ScopesAllowed,&HiddenAllowed);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of surveys from database *****/
|
2021-10-20 23:34:45 +02:00
|
|
|
|
if ((Surveys->Num = Svy_DB_GetListSurveys (&mysql_res,
|
|
|
|
|
ScopesAllowed,
|
|
|
|
|
HiddenAllowed,
|
|
|
|
|
Surveys->SelectedOrder))) // Surveys found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list of surveys *****/
|
2021-10-20 23:34:45 +02:00
|
|
|
|
if ((Surveys->LstSvyCods = calloc ((size_t) Surveys->Num,
|
2021-02-15 16:25:55 +01:00
|
|
|
|
sizeof (*Surveys->LstSvyCods))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the surveys codes *****/
|
|
|
|
|
for (NumSvy = 0;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
NumSvy < Surveys->Num;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumSvy++)
|
|
|
|
|
/* Get next survey code */
|
2021-04-05 23:45:24 +02:00
|
|
|
|
if ((Surveys->LstSvyCods[NumSvy] = DB_GetNextCode (mysql_res)) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys->LstIsRead = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*** Set allowed and hidden scopes to get list depending on my user's role ***/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed,
|
|
|
|
|
unsigned *HiddenAllowed)
|
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_UNK: // User not logged in *********************************
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*ScopesAllowed = 0;
|
|
|
|
|
*HiddenAllowed = 0;
|
|
|
|
|
break;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_GST: // User not belonging to any course *******************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
|
|
|
|
break;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_USR: // Student or teacher in other courses...
|
2016-10-27 01:30:14 +02:00
|
|
|
|
// ...but not belonging to the current course *********
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Cty_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ins_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ctr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Deg_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod))
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_DEG;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_STD: // Student in current course **************************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Cty_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ins_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ctr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Deg_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_DEG;
|
2017-05-23 00:40:03 +02:00
|
|
|
|
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CRS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2017-05-21 21:23:13 +02:00
|
|
|
|
case Rol_NET: // Non-editing teacher in current course **************
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH: // Teacher in current course **************************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Cty_CheckIfIBelongToCty (Gbl.Hierarchy.Cty.CtyCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ins_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Ctr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
2021-11-03 11:35:21 +01:00
|
|
|
|
if (Deg_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod))
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_DEG;
|
2017-05-23 00:40:03 +02:00
|
|
|
|
if (Gbl.Usrs.Me.IBelongToCurrentCrs)
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CRS;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_CRS; // A non-editing teacher or teacher can view hidden course surveys
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_DEG_ADM: // Degree administrator *******************************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Center selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_DEG;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_DEG; // A degree admin can view hidden degree surveys
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case Rol_CTR_ADM: // Center administrator *******************************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Center selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_CTR; // A center admin can view hidden center surveys
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_INS_ADM: // Institution administrator **************************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
*HiddenAllowed = 0;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_INS; // An institution admin can view hidden institution surveys
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_SYS_ADM: // System administrator (superuser) *******************
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed = 1 << HieLvl_SYS;
|
|
|
|
|
*HiddenAllowed = 1 << HieLvl_SYS; // A system admin can view hidden system surveys
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTY;
|
2021-10-20 16:46:34 +02:00
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_CTY; // A system admin can view hidden country surveys
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_INS;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_INS; // A system admin can view hidden institution surveys
|
2021-03-07 21:21:04 +01:00
|
|
|
|
if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Center selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CTR;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_CTR; // A system admin can view hidden center surveys
|
2019-04-03 20:57:04 +02:00
|
|
|
|
if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_DEG;
|
2021-10-20 16:46:34 +02:00
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_DEG; // A system admin can view hidden degree surveys
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
*ScopesAllowed |= 1 << HieLvl_CRS;
|
|
|
|
|
*HiddenAllowed |= 1 << HieLvl_CRS; // A system admin can view hidden course surveys
|
2016-10-27 01:30:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get survey data using its code ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get data of survey from database *****/
|
2021-10-21 22:28:09 +02:00
|
|
|
|
if (Svy_DB_GetDataOfSurveyByCod (&mysql_res,Svy->SvyCod)) // Survey found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get code of the survey (row[0]) */
|
|
|
|
|
Svy->SvyCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
/* Get survey scope (row[1]) */
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == HieLvl_UNK)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2016-10-27 01:30:14 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/* Get code of the country, institution, center, degree or course (row[2]) */
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Cod = Str_ConvertStrCodToLongCod (row[2]);
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Get whether the survey is hidden (row[3]) */
|
2016-09-07 18:48:10 +02:00
|
|
|
|
Svy->Status.Visible = (row[3][0] == 'N');
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get roles (row[4]) */
|
|
|
|
|
if (sscanf (row[4],"%u",&Svy->Roles) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when reading roles of survey.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get author of the survey (row[5]) */
|
|
|
|
|
Svy->UsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
|
|
|
|
|
2021-10-20 16:46:34 +02:00
|
|
|
|
/* Get start date (row[6] holds the start UTC time)
|
|
|
|
|
and end date (row[7] holds the end UTC time) */
|
|
|
|
|
Svy->TimeUTC[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[6]);
|
|
|
|
|
Svy->TimeUTC[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[7]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get whether the survey is open or closed (row(8)) */
|
|
|
|
|
Svy->Status.Open = (row[8][0] == '1');
|
|
|
|
|
|
|
|
|
|
/* Get the title of the survey (row[9]) */
|
2021-04-25 21:18:22 +02:00
|
|
|
|
Str_Copy (Svy->Title,row[9],sizeof (Svy->Title) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get number of questions and number of users who have already answer this survey */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy->NumQsts = Svy_DB_GetNumQstsSvy (Svy->SvyCod);
|
|
|
|
|
Svy->NumUsrs = Svy_DB_GetNumUsrsWhoHaveAnsweredSvy (Svy->SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Am I logged with a valid role to answer this survey? */
|
2017-06-04 18:18:54 +02:00
|
|
|
|
Svy->Status.IAmLoggedWithAValidRoleToAnswer = (Svy->Roles & (1 << Gbl.Usrs.Me.Role.Logged));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Do I belong to valid groups to answer this survey? */
|
2016-10-27 01:30:14 +02:00
|
|
|
|
switch (Svy->Scope)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_UNK: // Unknown
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_SYS: // System
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope = Gbl.Usrs.Me.Logged;
|
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTY: // Country
|
2021-11-03 11:35:21 +01:00
|
|
|
|
Svy->Status.IBelongToScope = Cty_CheckIfIBelongToCty (Svy->Cod);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_INS: // Institution
|
2021-11-03 11:35:21 +01:00
|
|
|
|
Svy->Status.IBelongToScope = Ins_CheckIfIBelongToIns (Svy->Cod);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTR: // Center
|
2021-11-03 11:35:21 +01:00
|
|
|
|
Svy->Status.IBelongToScope = Ctr_CheckIfIBelongToCtr (Svy->Cod);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_DEG: // Degree
|
2021-11-03 11:35:21 +01:00
|
|
|
|
Svy->Status.IBelongToScope = Deg_CheckIfIBelongToDeg (Svy->Cod);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CRS: // Course
|
2021-11-03 21:31:16 +01:00
|
|
|
|
Svy->Status.IBelongToScope = Enr_CheckIfIBelongToCrs (Svy->Cod) &&
|
2021-10-21 22:28:09 +02:00
|
|
|
|
Svy_DB_CheckIfICanDoThisSurveyBasedOnGrps (Svy->SvyCod);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Have I answered this survey? */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy->Status.IHaveAnswered = Svy_DB_CheckIfIHaveAnsweredSvy (Svy->SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Can I answer survey? */
|
|
|
|
|
Svy->Status.ICanAnswer = (Svy->NumQsts != 0) &&
|
|
|
|
|
Svy->Status.Visible &&
|
|
|
|
|
Svy->Status.Open &&
|
|
|
|
|
Svy->Status.IAmLoggedWithAValidRoleToAnswer &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope &&
|
2014-12-01 23:55:08 +01:00
|
|
|
|
!Svy->Status.IHaveAnswered;
|
|
|
|
|
|
|
|
|
|
/* Can I view results of the survey?
|
|
|
|
|
Can I edit survey? */
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_STD:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_CRS ||
|
|
|
|
|
Svy->Scope == HieLvl_DEG ||
|
|
|
|
|
Svy->Scope == HieLvl_CTR ||
|
|
|
|
|
Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
(Svy->NumQsts != 0) &&
|
|
|
|
|
Svy->Status.Visible &&
|
|
|
|
|
Svy->Status.Open &&
|
|
|
|
|
Svy->Status.IAmLoggedWithAValidRoleToAnswer &&
|
|
|
|
|
Svy->Status.IBelongToScope &&
|
|
|
|
|
Svy->Status.IHaveAnswered;
|
|
|
|
|
Svy->Status.ICanEdit = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-05-22 21:03:14 +02:00
|
|
|
|
case Rol_NET:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_CRS ||
|
|
|
|
|
Svy->Scope == HieLvl_DEG ||
|
|
|
|
|
Svy->Scope == HieLvl_CTR ||
|
|
|
|
|
Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2017-05-22 21:03:14 +02:00
|
|
|
|
Svy->NumQsts != 0 &&
|
|
|
|
|
!Svy->Status.ICanAnswer;
|
|
|
|
|
Svy->Status.ICanEdit = false;
|
|
|
|
|
break;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_CRS ||
|
|
|
|
|
Svy->Scope == HieLvl_DEG ||
|
|
|
|
|
Svy->Scope == HieLvl_CTR ||
|
|
|
|
|
Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->NumQsts != 0 &&
|
2014-12-01 23:55:08 +01:00
|
|
|
|
!Svy->Status.ICanAnswer;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanEdit = Svy->Scope == HieLvl_CRS &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_DEG_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_DEG ||
|
|
|
|
|
Svy->Scope == HieLvl_CTR ||
|
|
|
|
|
Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
(Svy->NumQsts != 0) &&
|
|
|
|
|
!Svy->Status.ICanAnswer;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanEdit = Svy->Scope == HieLvl_DEG &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope;
|
|
|
|
|
break;
|
|
|
|
|
case Rol_CTR_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_CTR ||
|
|
|
|
|
Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
(Svy->NumQsts != 0) &&
|
|
|
|
|
!Svy->Status.ICanAnswer;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanEdit = Svy->Scope == HieLvl_CTR &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope;
|
|
|
|
|
break;
|
|
|
|
|
case Rol_INS_ADM:
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->Scope == HieLvl_INS ||
|
|
|
|
|
Svy->Scope == HieLvl_CTY ||
|
|
|
|
|
Svy->Scope == HieLvl_SYS) &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
(Svy->NumQsts != 0) &&
|
|
|
|
|
!Svy->Status.ICanAnswer;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy->Status.ICanEdit = Svy->Scope == HieLvl_INS &&
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2015-04-07 21:44:24 +02:00
|
|
|
|
case Rol_SYS_ADM:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy->Status.ICanViewResults = (Svy->NumQsts != 0);
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.ICanEdit = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
Svy->Status.ICanViewResults = false;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.ICanEdit = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Initialize to empty survey */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy->SvyCod = -1L;
|
|
|
|
|
Svy->Scope = HieLvl_UNK;
|
|
|
|
|
Svy->Roles = 0;
|
|
|
|
|
Svy->UsrCod = -1L;
|
|
|
|
|
Svy->TimeUTC[Dat_STR_TIME] =
|
|
|
|
|
Svy->TimeUTC[Dat_END_TIME] = (time_t) 0;
|
|
|
|
|
Svy->Title[0] = '\0';
|
|
|
|
|
Svy->NumQsts = 0;
|
|
|
|
|
Svy->NumUsrs = 0;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.Visible = true;
|
|
|
|
|
Svy->Status.Open = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy->Status.IAmLoggedWithAValidRoleToAnswer = false;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy->Status.IBelongToScope = false;
|
|
|
|
|
Svy->Status.IHaveAnswered = false;
|
|
|
|
|
Svy->Status.ICanAnswer = false;
|
|
|
|
|
Svy->Status.ICanViewResults = false;
|
|
|
|
|
Svy->Status.ICanEdit = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Free list of surveys ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
void Svy_FreeListSurveys (struct Svy_Surveys *Surveys)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
if (Surveys->LstIsRead && Surveys->LstSvyCods)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
free (Surveys->LstSvyCods);
|
|
|
|
|
Surveys->LstSvyCods = NULL;
|
|
|
|
|
Surveys->Num = 0;
|
|
|
|
|
Surveys->LstIsRead = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get summary and content of a survey *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
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,
|
|
|
|
|
long SvyCod,bool GetContent)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
SummaryStr[0] = '\0'; // Return nothing on error
|
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Get title and text *****/
|
|
|
|
|
if (Svy_DB_GetSurveyTitleAndText (&mysql_res,SvyCod))
|
2020-02-24 12:43:18 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get row *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get summary *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Get content *****/
|
|
|
|
|
if (GetContent)
|
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[1]);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (*ContentStr,row[1],Length);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Write parameter with code of survey *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_PutParamSvyCod (long SvyCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"SvyCod",SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Get parameter with code of survey **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-03-20 02:48:16 +01:00
|
|
|
|
static long Svy_GetParamSvyCod (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of survey *****/
|
|
|
|
|
return Par_GetParToLong ("SvyCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Ask for confirmation of removing of a survey ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_AskRemSurvey (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_survey_X;
|
|
|
|
|
extern const char *Txt_Remove_survey;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-28 14:05:30 +02:00
|
|
|
|
/***** Show question and button to remove survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SvyCod = Svy.SvyCod;
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ale_ShowAlertAndButton (ActRemSvy,NULL,NULL,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParams,&Surveys,
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_survey,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_survey_X,
|
|
|
|
|
Svy.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Remove a survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_RemoveSurvey (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Survey_X_removed;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2019-12-06 22:18:05 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Remove all users in this survey *****/
|
|
|
|
|
Svy_DB_RemoveUsrsWhoHaveAnsweredSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Remove all answers in this survey *****/
|
|
|
|
|
Svy_DB_RemoveAnswersSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Remove all questions in this survey *****/
|
|
|
|
|
Svy_DB_RemoveQstsSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Remove all groups of this survey *****/
|
|
|
|
|
Svy_DB_RemoveGrpsAssociatedToSurvey (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove survey *****/
|
2021-10-21 22:28:09 +02:00
|
|
|
|
Svy_DB_RemoveSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications as removed *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Survey_X_removed,
|
|
|
|
|
Svy.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Ask for confirmation of reset of a survey *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_AskResetSurvey (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_reset_the_survey_X;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Ask for confirmation of reset *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Do_you_really_want_to_reset_the_survey_X,
|
|
|
|
|
Svy.Title);
|
2015-12-13 21:12:34 +01:00
|
|
|
|
|
|
|
|
|
/***** Button of confirmation of reset *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SvyCod = Svy.SvyCod;
|
|
|
|
|
Svy_PutButtonToResetSurvey (&Surveys);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Put button to reset survey ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToResetSurvey (struct Svy_Surveys *Surveys)
|
2016-03-20 02:48:16 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Reset_survey;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActRstSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParams (Surveys);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Btn_PutRemoveButton (Txt_Reset_survey);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Reset a survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_ResetSurvey (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Survey_X_reset;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2019-12-06 22:18:05 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Remove all users in this survey *****/
|
|
|
|
|
Svy_DB_RemoveUsrsWhoHaveAnsweredSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-21 22:28:09 +02:00
|
|
|
|
/***** Reset all answers in this survey *****/
|
|
|
|
|
Svy_DB_ResetAnswersSvy (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Survey_X_reset,
|
|
|
|
|
Svy.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Hide a survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_HideSurvey (void)
|
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2019-09-29 17:33:39 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2019-09-29 17:33:39 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Hide survey *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_HideOrUnhideSurvey (Svy.SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************** Show a survey ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_UnhideSurvey (void)
|
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2019-09-29 17:33:39 +02:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2019-09-29 17:33:39 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show survey *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_HideOrUnhideSurvey (Svy.SvyCod,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new survey *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_RequestCreatOrEditSvy (void)
|
|
|
|
|
{
|
2017-05-02 16:57:49 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys_new_survey;
|
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys_edit_survey;
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2021-12-17 00:17:35 +01:00
|
|
|
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_New_survey;
|
|
|
|
|
extern const char *Txt_Scope;
|
|
|
|
|
extern const char *Txt_Edit_survey;
|
|
|
|
|
extern const char *Txt_Title;
|
|
|
|
|
extern const char *Txt_Description;
|
|
|
|
|
extern const char *Txt_Users;
|
|
|
|
|
extern const char *Txt_Create_survey;
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewSurvey;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2020-02-26 19:35:33 +01:00
|
|
|
|
static const Dat_SetHMS SetHMS[Dat_NUM_START_END_TIME] =
|
|
|
|
|
{
|
2021-09-18 18:22:26 +02:00
|
|
|
|
[Dat_STR_TIME] = Dat_HMS_TO_000000,
|
|
|
|
|
[Dat_END_TIME] = Dat_HMS_TO_235959
|
2020-02-26 19:35:33 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the survey *****/
|
2021-04-25 20:36:48 +02:00
|
|
|
|
ItsANewSurvey = ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get from the database the data of the survey *****/
|
|
|
|
|
if (ItsANewSurvey)
|
|
|
|
|
{
|
|
|
|
|
/***** Put link (form) to create new survey *****/
|
|
|
|
|
if (!Svy_CheckIfICanCreateSvy ())
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Initialize to empty survey */
|
|
|
|
|
Svy.SvyCod = -1L;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Svy.Scope = HieLvl_UNK;
|
2017-05-18 19:13:41 +02:00
|
|
|
|
Svy.Roles = (1 << Rol_STD);
|
2016-10-26 01:23:02 +02:00
|
|
|
|
Svy.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
Svy.TimeUTC[Dat_END_TIME] = Gbl.StartExecutionTimeUTC + (24 * 60 * 60); // +24 hours
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy.Title[0] = '\0';
|
|
|
|
|
Svy.NumQsts = 0;
|
|
|
|
|
Svy.NumUsrs = 0;
|
|
|
|
|
Svy.Status.Visible = true;
|
|
|
|
|
Svy.Status.Open = true;
|
|
|
|
|
Svy.Status.IAmLoggedWithAValidRoleToAnswer = false;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy.Status.IBelongToScope = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy.Status.IHaveAnswered = false;
|
|
|
|
|
Svy.Status.ICanAnswer = false;
|
|
|
|
|
Svy.Status.ICanViewResults = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Get data of the survey from database */
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
if (!Svy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get text of the survey from database */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_DB_GetSurveyTxt (Svy.SvyCod,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SvyCod = Svy.SvyCod;
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ItsANewSurvey ? ActNewSvy :
|
2015-12-13 21:12:34 +01:00
|
|
|
|
ActChgSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParams (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Begin box and table *****/
|
|
|
|
|
if (ItsANewSurvey)
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_survey,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Surveys_new_survey,Box_NOT_CLOSABLE,2);
|
|
|
|
|
else
|
|
|
|
|
Box_BoxTableBegin (NULL,
|
|
|
|
|
Svy.Title[0] ? Svy.Title :
|
|
|
|
|
Txt_Edit_survey,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Surveys_edit_survey,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Scope of the survey *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","ScopeSvy",Txt_Scope);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
Svy_SetDefaultAndAllowedScope (&Svy);
|
|
|
|
|
Sco_GetScope ("ScopeSvy");
|
|
|
|
|
Sco_PutSelectorScope ("ScopeSvy",HTM_DONT_SUBMIT_ON_CHANGE);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Survey title *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Title",Txt_Title);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Title",Svy_MAX_CHARS_SURVEY_TITLE,Svy.Title,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"Title\" required=\"required\""
|
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH\"");
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Survey start and end dates *****/
|
|
|
|
|
Dat_PutFormStartEndClientLocalDateTimes (Svy.TimeUTC,
|
|
|
|
|
Dat_FORM_SECONDS_ON,
|
|
|
|
|
SetHMS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Survey text *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Txt",Txt_Description);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\" rows=\"5\""
|
2021-12-17 00:17:35 +01:00
|
|
|
|
" class=\"TITLE_DESCRIPTION_WIDTH %s\"",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (!ItsANewSurvey)
|
|
|
|
|
HTM_Txt (Txt);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Users' roles who can answer the survey *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RT %s\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TxtColon (Txt_Users);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LM\"",The_ClassDat[Gbl.Prefs.Theme]);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Rol_WriteSelectorRoles (1 << Rol_STD |
|
|
|
|
|
1 << Rol_NET |
|
|
|
|
|
1 << Rol_TCH,
|
|
|
|
|
Svy.Roles,
|
|
|
|
|
false,false);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Groups *****/
|
|
|
|
|
Svy_ShowLstGrpsToEditSurvey (Svy.SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
if (ItsANewSurvey)
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_survey);
|
|
|
|
|
else
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Save_changes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-04-11 17:33:14 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show questions of the survey ready to be edited *****/
|
|
|
|
|
if (!ItsANewSurvey)
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListSvyQuestions (&Surveys,&Svy);
|
2019-09-26 23:57:10 +02:00
|
|
|
|
|
|
|
|
|
/***** Show all surveys *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-10-27 01:30:14 +02:00
|
|
|
|
/****** Set default and allowed scopes depending on logged user's role *******/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-26 01:23:02 +02:00
|
|
|
|
bool ICanEdit = false;
|
|
|
|
|
|
|
|
|
|
/***** Set default scope *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Default = HieLvl_UNK;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Scope.Allowed = 0;
|
|
|
|
|
|
2017-06-04 18:18:54 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.Role.Logged)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-18 19:13:41 +02:00
|
|
|
|
case Rol_TCH: // Teachers only can edit course surveys
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected
|
2016-10-26 01:23:02 +02:00
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy->Scope == HieLvl_UNK) // Scope not defined
|
|
|
|
|
Svy->Scope = HieLvl_CRS;
|
|
|
|
|
if (Svy->Scope == HieLvl_CRS)
|
2016-10-26 01:23:02 +02:00
|
|
|
|
{
|
|
|
|
|
Gbl.Scope.Default = Svy->Scope;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_CRS;
|
2016-10-26 01:23:02 +02:00
|
|
|
|
ICanEdit = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
case Rol_DEG_ADM: // Degree admins only can edit degree surveys
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy->Scope == HieLvl_UNK) // Scope not defined
|
|
|
|
|
Svy->Scope = HieLvl_DEG;
|
|
|
|
|
if (Svy->Scope == HieLvl_DEG)
|
2016-10-26 01:23:02 +02:00
|
|
|
|
{
|
|
|
|
|
Gbl.Scope.Default = Svy->Scope;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_DEG;
|
2016-10-26 01:23:02 +02:00
|
|
|
|
ICanEdit = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case Rol_CTR_ADM: // Center admins only can edit center surveys
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy->Scope == HieLvl_UNK) // Scope not defined
|
|
|
|
|
Svy->Scope = HieLvl_CTR;
|
|
|
|
|
if (Svy->Scope == HieLvl_CTR)
|
2016-10-27 01:30:14 +02:00
|
|
|
|
{
|
|
|
|
|
Gbl.Scope.Default = Svy->Scope;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_CTR;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
ICanEdit = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_INS_ADM: // Institution admins only can edit institution surveys
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy->Scope == HieLvl_UNK) // Scope not defined
|
|
|
|
|
Svy->Scope = HieLvl_INS;
|
|
|
|
|
if (Svy->Scope == HieLvl_INS)
|
2016-10-26 01:23:02 +02:00
|
|
|
|
{
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Gbl.Scope.Default = Svy->Scope;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_INS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
ICanEdit = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Rol_SYS_ADM:// System admins can edit any survey
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (Svy->Scope == HieLvl_UNK) // Scope not defined
|
|
|
|
|
Svy->Scope = (Gbl.Hierarchy.Level < HieLvl_NUM_LEVELS &&
|
|
|
|
|
Gbl.Hierarchy.Level != HieLvl_UNK) ? Gbl.Hierarchy.Level :
|
|
|
|
|
HieLvl_SYS;
|
2016-10-26 01:23:02 +02:00
|
|
|
|
Gbl.Scope.Default = Svy->Scope;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
Gbl.Scope.Allowed = 1 << HieLvl_SYS |
|
|
|
|
|
1 << HieLvl_CTY |
|
|
|
|
|
1 << HieLvl_INS |
|
|
|
|
|
1 << HieLvl_CTR |
|
|
|
|
|
1 << HieLvl_DEG |
|
|
|
|
|
1 << HieLvl_CRS;
|
2016-10-26 01:23:02 +02:00
|
|
|
|
ICanEdit = true;
|
|
|
|
|
break;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
default:
|
2016-10-26 01:23:02 +02:00
|
|
|
|
break;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2016-10-26 01:23:02 +02:00
|
|
|
|
|
|
|
|
|
if (!ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Show list of groups to edit a survey *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_ShowLstGrpsToEditSurvey (long SvyCod)
|
|
|
|
|
{
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
extern const char *Txt_The_whole_course;
|
|
|
|
|
unsigned NumGrpTyp;
|
|
|
|
|
|
|
|
|
|
/***** Get list of groups types and groups in this course *****/
|
|
|
|
|
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
|
|
|
|
|
|
2021-06-28 12:54:09 +02:00
|
|
|
|
if (Gbl.Crs.Grps.GrpTypes.NumGrpTypes)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TxtColon (Txt_Groups);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
Box_BoxTableBegin ("95%",NULL,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
NULL,Box_NOT_CLOSABLE,0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** First row: checkbox to select the whole course *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("colspan=\"7\" class=\"%s LM\"",
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme]);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_LABEL_Begin (NULL);
|
|
|
|
|
HTM_INPUT_CHECKBOX ("WholeCrs",HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"WholeCrs\" value=\"Y\"%s onclick=\"uncheckChildren(this,'GrpCods')\"",
|
|
|
|
|
Grp_DB_CheckIfAssociatedToGrps ("svy_groups","SvyCod",SvyCod) ? "" :
|
|
|
|
|
" checked=\"checked\"");
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** List the groups for each group type *****/
|
|
|
|
|
for (NumGrpTyp = 0;
|
|
|
|
|
NumGrpTyp < Gbl.Crs.Grps.GrpTypes.NumGrpTypes;
|
|
|
|
|
NumGrpTyp++)
|
|
|
|
|
if (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps)
|
|
|
|
|
Grp_ListGrpsToEditAsgAttSvyEvtMch (&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp],
|
|
|
|
|
Grp_SURVEY,SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_BoxTableEnd ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free list of groups types and groups in this course *****/
|
|
|
|
|
Grp_FreeListGrpTypesAndGrps ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Receive form to create a new survey *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Svy_ReceiveFormSurvey (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Already_existed_a_survey_with_the_title_X;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_title_of_the_survey;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey OldSvy;
|
|
|
|
|
struct Svy_Survey NewSvy;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ItsANewSurvey;
|
|
|
|
|
bool NewSurveyIsCorrect = true;
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Txt[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2019-12-06 22:18:05 +01:00
|
|
|
|
/***** Get parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get the code of the survey *****/
|
2021-04-25 20:36:48 +02:00
|
|
|
|
ItsANewSurvey = ((NewSvy.SvyCod = Svy_GetParamSvyCod ()) <= 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-27 01:30:14 +02:00
|
|
|
|
if (ItsANewSurvey)
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_UNK;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
else
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/* Get data of the old (current) survey from database */
|
|
|
|
|
OldSvy.SvyCod = NewSvy.SvyCod;
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&OldSvy);
|
|
|
|
|
if (!OldSvy.Status.ICanEdit)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2016-10-27 01:30:14 +02:00
|
|
|
|
NewSvy.Scope = OldSvy.Scope;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get scope *****/
|
2016-10-27 01:30:14 +02:00
|
|
|
|
Svy_SetDefaultAndAllowedScope (&NewSvy);
|
2016-06-24 20:34:58 +02:00
|
|
|
|
Sco_GetScope ("ScopeSvy");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
switch (Gbl.Scope.Current)
|
|
|
|
|
{
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_SYS:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_SYS;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
NewSvy.Cod = -1L;
|
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTY:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_CTY;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
NewSvy.Cod = Gbl.Hierarchy.Cty.CtyCod;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_INS:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged != Rol_INS_ADM)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_INS;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
NewSvy.Cod = Gbl.Hierarchy.Ins.InsCod;
|
2016-10-27 01:30:14 +02:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CTR:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged != Rol_CTR_ADM)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_CTR;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
NewSvy.Cod = Gbl.Hierarchy.Ctr.CtrCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_DEG:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged != Rol_DEG_ADM)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_DEG;
|
2019-04-03 20:57:04 +02:00
|
|
|
|
NewSvy.Cod = Gbl.Hierarchy.Deg.DegCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-05-27 23:30:16 +02:00
|
|
|
|
case HieLvl_CRS:
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged != Rol_TCH)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2021-05-27 23:30:16 +02:00
|
|
|
|
NewSvy.Scope = HieLvl_CRS;
|
2019-04-04 10:45:15 +02:00
|
|
|
|
NewSvy.Cod = Gbl.Hierarchy.Crs.CrsCod;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongScopeExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-23 13:51:33 +02:00
|
|
|
|
/***** Get start/end date-times *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
NewSvy.TimeUTC[Dat_STR_TIME] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
|
|
|
|
|
NewSvy.TimeUTC[Dat_END_TIME] = Dat_GetTimeUTCFromForm ("EndTimeUTC" );
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey title *****/
|
2017-03-08 03:48:23 +01:00
|
|
|
|
Par_GetParToText ("Title",NewSvy.Title,Svy_MAX_BYTES_SURVEY_TITLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey text and insert links *****/
|
|
|
|
|
Par_GetParToHTML ("Txt",Txt,Cns_MAX_BYTES_TEXT); // Store in HTML format (not rigorous)
|
|
|
|
|
|
|
|
|
|
/***** Adjust dates *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (NewSvy.TimeUTC[Dat_STR_TIME] == 0)
|
|
|
|
|
NewSvy.TimeUTC[Dat_STR_TIME] = Gbl.StartExecutionTimeUTC;
|
|
|
|
|
if (NewSvy.TimeUTC[Dat_END_TIME] == 0)
|
|
|
|
|
NewSvy.TimeUTC[Dat_END_TIME] = NewSvy.TimeUTC[Dat_STR_TIME] + 24 * 60 * 60; // +24 hours
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get users who can answer this survey *****/
|
2016-03-24 16:49:36 +01:00
|
|
|
|
NewSvy.Roles = Rol_GetSelectedRoles ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if title is correct *****/
|
|
|
|
|
if (NewSvy.Title[0]) // If there's a survey title
|
|
|
|
|
{
|
|
|
|
|
/* If title of survey was in database... */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (Svy_DB_CheckIfSimilarSurveyExists (&NewSvy))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
NewSurveyIsCorrect = false;
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_Already_existed_a_survey_with_the_title_X,
|
|
|
|
|
NewSvy.Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // If there is not a survey title
|
|
|
|
|
{
|
|
|
|
|
NewSurveyIsCorrect = false;
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_title_of_the_survey);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Create a new survey or update an existing one *****/
|
|
|
|
|
if (NewSurveyIsCorrect)
|
|
|
|
|
{
|
|
|
|
|
/* Get groups for this surveys */
|
2017-01-19 20:55:31 +01:00
|
|
|
|
Grp_GetParCodsSeveralGrps ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (ItsANewSurvey)
|
|
|
|
|
Svy_CreateSurvey (&NewSvy,Txt); // Add new survey to database
|
|
|
|
|
else
|
|
|
|
|
Svy_UpdateSurvey (&NewSvy,Txt);
|
|
|
|
|
|
|
|
|
|
/* Free memory for list of selected groups */
|
|
|
|
|
Grp_FreeListCodSelectedGrps ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Svy_RequestCreatOrEditSvy ();
|
|
|
|
|
|
2016-11-16 23:19:52 +01:00
|
|
|
|
/***** Notify by email about the new survey *****/
|
2021-05-27 23:30:16 +02:00
|
|
|
|
if (NewSvy.Scope == HieLvl_CRS) // Notify only the surveys for a course, not for a degree or global
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_SURVEY,NewSvy.SvyCod)))
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_DB_UpdateNumUsrsNotifiedByEMailAboutSurvey (NewSvy.SvyCod,NumUsrsToBeNotifiedByEMail);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show surveys again *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ListAllSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Create a new survey *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_CreateSurvey (struct Svy_Survey *Svy,const char *Txt)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Created_new_survey_X;
|
|
|
|
|
|
|
|
|
|
/***** Create a new survey *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy->SvyCod = Svy_DB_CreateSurvey (Svy,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create groups *****/
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy_CreateGrps (Svy->SvyCod);
|
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_survey_X,
|
|
|
|
|
Svy->Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Update an existing survey *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_UpdateSurvey (struct Svy_Survey *Svy,const char *Txt)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_survey_has_been_modified;
|
|
|
|
|
|
|
|
|
|
/***** Update the data of the survey *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_UpdateSurvey (Svy,Txt);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update groups *****/
|
|
|
|
|
/* Remove old groups */
|
2021-10-21 22:28:09 +02:00
|
|
|
|
Svy_DB_RemoveGrpsAssociatedToSurvey (Svy->SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Create new groups */
|
2019-04-04 10:45:15 +02:00
|
|
|
|
if (Gbl.Crs.Grps.LstGrpsSel.NumGrps)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy_CreateGrps (Svy->SvyCod);
|
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_survey_has_been_modified);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-07-20 13:14:12 +02:00
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/************************ Create groups of a survey **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_CreateGrps (long SvyCod)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumGrpSel;
|
|
|
|
|
|
|
|
|
|
/***** Create groups of the survey *****/
|
|
|
|
|
for (NumGrpSel = 0;
|
2019-04-04 10:45:15 +02:00
|
|
|
|
NumGrpSel < Gbl.Crs.Grps.LstGrpsSel.NumGrps;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumGrpSel++)
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_CreateGrp (SvyCod,Gbl.Crs.Grps.LstGrpsSel.GrpCods[NumGrpSel]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Get and write the names of the groups of a survey **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_GetAndWriteNamesOfGrpsAssociatedToSvy (struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Group;
|
|
|
|
|
extern const char *Txt_Groups;
|
|
|
|
|
extern const char *Txt_and;
|
|
|
|
|
extern const char *Txt_The_whole_course;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-10-24 16:55:47 +02:00
|
|
|
|
unsigned NumGrps;
|
|
|
|
|
unsigned NumGrp;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get groups associated to a survey from database *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
NumGrps = Svy_DB_GetGrpNamesAssociatedToSvy (&mysql_res,Svy->SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
2019-10-24 00:04:40 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"%s\"",Svy->Status.Visible ? "ASG_GRP" :
|
|
|
|
|
"ASG_GRP_LIGHT");
|
2021-10-24 16:55:47 +02:00
|
|
|
|
HTM_TxtColonNBSP (NumGrps == 1 ? Txt_Group :
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Txt_Groups);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Write groups *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (NumGrps) // Groups found...
|
2021-10-20 17:57:27 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get and write the group types and names */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
for (NumGrp = 0;
|
|
|
|
|
NumGrp < NumGrps;
|
|
|
|
|
NumGrp++)
|
2021-10-20 17:57:27 +02:00
|
|
|
|
{
|
|
|
|
|
/* Get next group */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write group type name and group name */
|
|
|
|
|
HTM_TxtF ("%s %s",row[0],row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (NumGrps >= 2)
|
2021-10-20 17:57:27 +02:00
|
|
|
|
{
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (NumGrp == NumGrps - 2)
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TxtF (" %s ",Txt_and);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (NumGrps >= 3)
|
|
|
|
|
if (NumGrp < NumGrps - 2)
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_Txt (", ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_TxtF ("%s %s",Txt_The_whole_course,Gbl.Hierarchy.Crs.ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/************* Remove all surveys in a place on the hierarchy **************/
|
|
|
|
|
/************* (country, institution, center, degree or course) **************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
void Svy_RemoveSurveys (HieLvl_Level_t Scope,long Cod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/***** Remove all users in surveys *****/
|
|
|
|
|
Svy_DB_RemoveUsrsWhoHaveAnsweredSvysIn (Scope,Cod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all answers in surveys *****/
|
|
|
|
|
Svy_DB_RemoveAnswersSvysIn (Scope,Cod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all questions in surveys *****/
|
|
|
|
|
Svy_DB_RemoveQstsSvysIn (Scope,Cod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all groups *****/
|
|
|
|
|
Svy_DB_RemoveGrpsSvysIn (Scope,Cod);
|
|
|
|
|
|
|
|
|
|
/***** Remove all surveys *****/
|
|
|
|
|
Svy_DB_RemoveSvysIn (Scope,Cod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Put a form to edit/create a question in survey *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_RequestEditQuestion (void)
|
|
|
|
|
{
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
|
|
|
|
struct Svy_Question SvyQst;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long SvyCod;
|
2021-10-24 16:55:47 +02:00
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Initialize question to zero *****/
|
|
|
|
|
Svy_InitQst (&SvyQst);
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize text to empty string *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Stem[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the question code */
|
|
|
|
|
SvyQst.QstCod = Svy_GetParamQstCod ();
|
|
|
|
|
|
|
|
|
|
/***** Get other parameters *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SelectedOrder = Svy_GetParamSvyOrder ();
|
2020-03-27 14:56:54 +01:00
|
|
|
|
Grp_GetParamWhichGroups ();
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.CurrentPage = Pag_GetParamPagNum (Pag_SURVEYS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show form to create a new question in this survey *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_ShowFormEditOneQst (&Surveys,SvyCod,&SvyQst,Stem);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show current survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Show form to edit one survey question *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|
|
|
|
long SvyCod,struct Svy_Question *SvyQst,
|
2021-10-24 16:55:47 +02:00
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-02 16:57:49 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys_questions;
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2021-12-17 00:17:35 +01:00
|
|
|
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Question;
|
|
|
|
|
extern const char *Txt_New_question;
|
2019-09-12 23:53:00 +02:00
|
|
|
|
extern const char *Txt_Wording;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Type;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Svy_NUM_ANS_TYPES];
|
2019-02-18 18:27:45 +01:00
|
|
|
|
extern const char *Txt_Save_changes;
|
2015-04-11 20:18:30 +02:00
|
|
|
|
extern const char *Txt_Create_question;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2016-12-25 22:01:43 +01:00
|
|
|
|
unsigned NumAns;
|
|
|
|
|
unsigned NumAnswers = 0;
|
2019-12-30 22:32:06 +01:00
|
|
|
|
char *Title;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy_AnswerType_t AnsType;
|
|
|
|
|
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.Act == ActEdiOneSvyQst) // If no receiving the question, but editing a new or existing question
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if ((SvyQst->QstCod > 0)) // If parameter QstCod received ==> question already exists in the database
|
|
|
|
|
{
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/***** Get question data from database *****/
|
|
|
|
|
if (Svy_DB_GetQstDataByCod (&mysql_res,SvyQst->QstCod,SvyCod))
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Svy_GetDataOfQstFromRow (SvyQst,Stem,row);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Err_WrongQuestionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get the answers from the database *****/
|
2021-10-20 17:57:27 +02:00
|
|
|
|
NumAnswers = Svy_DB_GetAnswersQst (&mysql_res,SvyQst->QstCod); // Result: AnsInd,NumUsrs,Answer
|
2014-12-01 23:55:08 +01:00
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < NumAnswers;
|
|
|
|
|
NumAns++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongAnswerExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
|
2019-03-09 20:12:44 +01:00
|
|
|
|
/* Abort on error */
|
|
|
|
|
Ale_ShowAlertsAndExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (SvyQst->QstCod > 0) // If the question already has assigned a code
|
|
|
|
|
{
|
2016-04-05 13:07:33 +02:00
|
|
|
|
/* Parameters for contextual icon */
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys->SvyCod = SvyCod;
|
|
|
|
|
Surveys->QstCod = SvyQst->QstCod;
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2019-12-30 22:32:06 +01:00
|
|
|
|
if (asprintf (&Title,"%s %u",Txt_Question,SvyQst->QstInd + 1) < 0) // Question index may be 0, 1, 2, 3,...
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Title,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutIconToRemoveOneQst,Surveys,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2019-12-30 22:32:06 +01:00
|
|
|
|
free (Title);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_New_question,
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_ASSESSMENT_Surveys_questions,Box_NOT_CLOSABLE);
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActRcvSvyQst);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamSvyCod (SvyCod);
|
|
|
|
|
if (SvyQst->QstCod > 0) // If the question already has assigned a code
|
|
|
|
|
Svy_PutParamQstCod (SvyQst->QstCod);
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Begin table *****/
|
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Stem *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Txt",Txt_Wording);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2021-12-17 00:17:35 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"Txt\" name=\"Txt\""
|
|
|
|
|
" cols=\"60\" rows=\"4\""
|
|
|
|
|
" class=\"%s\"",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_Txt (Stem);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TR_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Type of answer *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s RT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TxtColon (Txt_Type);
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT\"",The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
for (AnsType = (Svy_AnswerType_t) 0;
|
|
|
|
|
AnsType <= (Svy_AnswerType_t) (Svy_NUM_ANS_TYPES - 1);
|
|
|
|
|
AnsType++)
|
|
|
|
|
{
|
|
|
|
|
HTM_LABEL_Begin (NULL);
|
|
|
|
|
HTM_INPUT_RADIO ("AnswerType",false,
|
|
|
|
|
"value=\"%u\"%s",
|
|
|
|
|
(unsigned) AnsType,
|
|
|
|
|
AnsType == SvyQst->AnswerType ? " checked=\"checked\"" : "");
|
|
|
|
|
HTM_Txt (Txt_SURVEY_STR_ANSWER_TYPES[AnsType]);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TD_End ();
|
2019-10-05 13:27:58 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TR_End ();
|
2019-10-05 13:27:58 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Answers *****/
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TD_Empty (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Unique or multiple choice answers */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_TABLE_BeginPadding (2);
|
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
|
|
|
|
|
NumAns++)
|
|
|
|
|
{
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Label with the number of the answer */
|
|
|
|
|
HTM_TD_Begin ("class=\"RT\"");
|
|
|
|
|
HTM_LABEL_Begin ("for=\"AnsStr%u\" class=\"%s\"",
|
|
|
|
|
NumAns,The_ClassFormInBox[Gbl.Prefs.Theme]);
|
|
|
|
|
HTM_TxtF ("%u)",NumAns + 1);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Answer text */
|
|
|
|
|
HTM_TD_Begin ("class=\"RT\"");
|
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"AnsStr%u\" name=\"AnsStr%u\" cols=\"50\" rows=\"1\"",
|
|
|
|
|
NumAns,NumAns);
|
|
|
|
|
if (SvyQst->AnsChoice[NumAns].Text)
|
|
|
|
|
HTM_Txt (SvyQst->AnsChoice[NumAns].Text);
|
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TR_End ();
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Send button *****/
|
|
|
|
|
if (SvyQst->QstCod > 0) // If the question already has assigned a code
|
|
|
|
|
Btn_PutConfirmButton (Txt_Save_changes);
|
|
|
|
|
else
|
|
|
|
|
Btn_PutCreateButton (Txt_Create_question);
|
2015-03-24 17:47:26 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-04-05 13:07:33 +02:00
|
|
|
|
|
|
|
|
|
/***** Free memory for answers *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy_FreeTextChoiceAnswers (SvyQst,NumAnswers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Initialize a new question to zero *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_InitQst (struct Svy_Question *SvyQst)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned NumAns;
|
|
|
|
|
|
|
|
|
|
SvyQst->QstCod = -1L;
|
|
|
|
|
SvyQst->QstInd = 0;
|
|
|
|
|
SvyQst->AnswerType = Svy_ANS_UNIQUE_CHOICE;
|
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
|
|
|
|
|
NumAns++)
|
|
|
|
|
SvyQst->AnsChoice[NumAns].Text = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Write parameter with code of question ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_PutParamQstCod (long QstCod)
|
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"QstCod",QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get parameter with code of question *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static long Svy_GetParamQstCod (void)
|
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of question *****/
|
|
|
|
|
return Par_GetParToLong ("QstCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Allocate memory for a choice answer *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static bool Svy_AllocateTextChoiceAnswer (struct Svy_Question *SvyQst,
|
2017-11-30 12:07:19 +01:00
|
|
|
|
unsigned NumAns)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((SvyQst->AnsChoice[NumAns].Text = malloc (Svy_MAX_BYTES_ANSWER + 1)) == NULL)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-09 20:12:44 +01:00
|
|
|
|
Ale_CreateAlert (Ale_ERROR,NULL,
|
|
|
|
|
"Not enough memory to store answer.");
|
2017-07-02 19:46:53 +02:00
|
|
|
|
return false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
SvyQst->AnsChoice[NumAns].Text[0] = '\0';
|
2017-07-02 19:46:53 +02:00
|
|
|
|
return true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Free memory of all choice answers **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_FreeTextChoiceAnswers (struct Svy_Question *SvyQst,unsigned NumAnswers)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
unsigned NumAns;
|
|
|
|
|
|
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < NumAnswers;
|
|
|
|
|
NumAns++)
|
|
|
|
|
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Free memory of a choice answer ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_FreeTextChoiceAnswer (struct Svy_Question *SvyQst,unsigned NumAns)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (SvyQst->AnsChoice[NumAns].Text)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (SvyQst->AnsChoice[NumAns].Text);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
SvyQst->AnsChoice[NumAns].Text = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Receive a question of a survey **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_ReceiveQst (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_must_type_the_stem_of_the_question;
|
|
|
|
|
extern const char *Txt_You_can_not_leave_empty_intermediate_answers;
|
|
|
|
|
extern const char *Txt_You_must_type_at_least_the_first_two_answers;
|
|
|
|
|
extern const char *Txt_The_survey_has_been_modified;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
|
|
|
|
struct Svy_Question SvyQst;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long SvyCod;
|
2021-10-24 16:55:47 +02:00
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumAns;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char AnsStr[8 + 10 + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumLastAns;
|
|
|
|
|
bool ThereIsEndOfAnswers;
|
|
|
|
|
bool Error = false;
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2017-11-30 12:07:19 +01:00
|
|
|
|
/***** Initialize question to zero *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Svy_InitQst (&SvyQst);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get survey code */
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get question code */
|
|
|
|
|
SvyQst.QstCod = Svy_GetParamQstCod ();
|
|
|
|
|
|
|
|
|
|
/* Get answer type */
|
2017-01-29 21:41:08 +01:00
|
|
|
|
SvyQst.AnswerType = (Svy_AnswerType_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("AnswerType",
|
|
|
|
|
0,
|
|
|
|
|
Svy_NUM_ANS_TYPES - 1,
|
|
|
|
|
(unsigned long) Svy_ANSWER_TYPE_DEFAULT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get question text */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Par_GetParToHTML ("Txt",Stem,Cns_MAX_BYTES_TEXT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the texts of the answers */
|
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
|
|
|
|
|
NumAns++)
|
|
|
|
|
{
|
2017-07-02 19:46:53 +02:00
|
|
|
|
if (!Svy_AllocateTextChoiceAnswer (&SvyQst,NumAns))
|
2019-03-09 20:12:44 +01:00
|
|
|
|
/* Abort on error */
|
|
|
|
|
Ale_ShowAlertsAndExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (AnsStr,sizeof (AnsStr),"AnsStr%u",NumAns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Par_GetParToHTML (AnsStr,SvyQst.AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Make sure that stem and answer are not empty *****/
|
2021-10-24 16:55:47 +02:00
|
|
|
|
if (Stem[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (SvyQst.AnsChoice[0].Text[0]) // If the first answer has been filled
|
|
|
|
|
{
|
|
|
|
|
for (NumAns = 0, NumLastAns = 0, ThereIsEndOfAnswers = false;
|
|
|
|
|
!Error && NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
|
|
|
|
|
NumAns++)
|
|
|
|
|
if (SvyQst.AnsChoice[NumAns].Text[0])
|
|
|
|
|
{
|
|
|
|
|
if (ThereIsEndOfAnswers)
|
|
|
|
|
{
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_empty_intermediate_answers);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
NumLastAns = NumAns;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ThereIsEndOfAnswers = true;
|
|
|
|
|
if (!Error)
|
|
|
|
|
{
|
|
|
|
|
if (NumLastAns < 1)
|
|
|
|
|
{
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_type_at_least_the_first_two_answers);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // If first answer is empty
|
|
|
|
|
{
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_type_at_least_the_first_two_answers);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_type_the_stem_of_the_question);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Error = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Error)
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_ShowFormEditOneQst (&Surveys,SvyCod,&SvyQst,Stem);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Form is received OK ==> insert question and answer in the database *****/
|
|
|
|
|
if (SvyQst.QstCod < 0) // It's a new question
|
|
|
|
|
{
|
|
|
|
|
SvyQst.QstInd = Svy_GetNextQuestionIndexInSvy (SvyCod);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
SvyQst.QstCod = Svy_DB_CreateQuestion (SvyCod,SvyQst.QstInd,
|
|
|
|
|
SvyQst.AnswerType,Stem);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // It's an existing question
|
|
|
|
|
/* Update question */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_UpdateQuestion (SvyCod,SvyQst.QstCod,SvyQst.AnswerType,Stem);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Insert, update or delete answers in the answers table */
|
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < Svy_MAX_ANSWERS_PER_QUESTION;
|
|
|
|
|
NumAns++)
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (Svy_DB_CheckIfAnswerExists (SvyQst.QstCod,NumAns)) // If this answer exists...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
if (SvyQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
|
|
|
|
/* Update answer text */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_UpdateAnswerText (SvyQst.QstCod,NumAns,
|
|
|
|
|
SvyQst.AnsChoice[NumAns].Text);
|
|
|
|
|
else // Answer is empty
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Delete answer from database */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_RemoveAnswerQst (SvyQst.QstCod,NumAns);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If this answer does not exist...
|
|
|
|
|
{
|
|
|
|
|
if (SvyQst.AnsChoice[NumAns].Text[0]) // Answer is not empty
|
|
|
|
|
/* Create answer into database */
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_DB_CreateAnswer (SvyQst.QstCod,NumAns,
|
|
|
|
|
SvyQst.AnsChoice[NumAns].Text);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** List the questions of this survey, including the new one just inserted into the database *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_survey_has_been_modified);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free answers *****/
|
|
|
|
|
Svy_FreeTextChoiceAnswers (&SvyQst,Svy_MAX_ANSWERS_PER_QUESTION);
|
|
|
|
|
|
|
|
|
|
/***** Show current survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Get next question index in a survey *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned Svy_GetNextQuestionIndexInSvy (long SvyCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned QstInd = 0;
|
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/***** Get last question index *****/
|
|
|
|
|
if (Svy_DB_GetLastQstInd (&mysql_res,SvyCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-10-24 16:55:47 +02:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (row[0]) // There are questions
|
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[0],"%u",&QstInd) != 1)
|
|
|
|
|
Err_WrongQuestionIndexExit ();
|
|
|
|
|
QstInd++;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return QstInd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ List the questions of a survey *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys,
|
|
|
|
|
struct Svy_Survey *Svy)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-05-02 16:57:49 +02:00
|
|
|
|
extern const char *Hlp_ASSESSMENT_Surveys_questions;
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2015-04-12 18:01:06 +02:00
|
|
|
|
extern const char *Txt_Questions;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_No_INDEX;
|
|
|
|
|
extern const char *Txt_Type;
|
|
|
|
|
extern const char *Txt_Question;
|
2015-01-02 12:57:26 +01:00
|
|
|
|
extern const char *Txt_SURVEY_STR_ANSWER_TYPES[Svy_NUM_ANS_TYPES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_This_survey_has_no_questions;
|
2016-03-24 22:03:24 +01:00
|
|
|
|
extern const char *Txt_Done;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumQsts;
|
|
|
|
|
unsigned NumQst;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Question SvyQst;
|
2021-10-24 16:55:47 +02:00
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1];
|
2016-04-05 10:47:36 +02:00
|
|
|
|
bool Editing = (Gbl.Action.Act == ActEdiOneSvy ||
|
2016-01-17 15:10:54 +01:00
|
|
|
|
Gbl.Action.Act == ActEdiOneSvyQst ||
|
|
|
|
|
Gbl.Action.Act == ActRcvSvyQst);
|
2015-12-13 21:12:34 +01:00
|
|
|
|
bool PutFormAnswerSurvey = Svy->Status.ICanAnswer && !Editing;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys->SvyCod = Svy->SvyCod;
|
2020-03-26 02:54:30 +01:00
|
|
|
|
if (Svy->Status.ICanEdit)
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Questions,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutIconToAddNewQuestion,Surveys,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Hlp_ASSESSMENT_Surveys_questions,Box_NOT_CLOSABLE);
|
|
|
|
|
else
|
|
|
|
|
Box_BoxBegin (NULL,Txt_Questions,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_ASSESSMENT_Surveys_questions,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 23:34:45 +02:00
|
|
|
|
/***** Get data of questions from database *****/
|
|
|
|
|
if ((NumQsts = Svy_DB_GetSurveyQsts (&mysql_res,Svy->SvyCod)))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-03-20 02:48:16 +01:00
|
|
|
|
if (PutFormAnswerSurvey)
|
|
|
|
|
{
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form to send answers to survey *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActAnsSvy);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParamSvyCod (Svy->SvyCod);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Write the heading *****/
|
2020-05-17 22:16:39 +02:00
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (5);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (Svy->Status.ICanEdit)
|
|
|
|
|
HTM_TH_Empty (1);
|
|
|
|
|
HTM_TH (1,1,"CT",Txt_No_INDEX);
|
|
|
|
|
HTM_TH (1,1,"CT",Txt_Type);
|
|
|
|
|
HTM_TH (1,1,"LT",Txt_Question);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Write questions one by one *****/
|
|
|
|
|
for (NumQst = 0;
|
|
|
|
|
NumQst < NumQsts;
|
|
|
|
|
NumQst++)
|
|
|
|
|
{
|
|
|
|
|
Gbl.RowEvenOdd = (int) (NumQst % 2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Initialize question to zero */
|
|
|
|
|
Svy_InitQst (&SvyQst);
|
2019-12-06 22:18:05 +01:00
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/* Get question data from row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
Svy_GetDataOfQstFromRow (&SvyQst,Stem,row);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (Svy->Status.ICanEdit)
|
|
|
|
|
{
|
|
|
|
|
HTM_TD_Begin ("class=\"BT%u\"",Gbl.RowEvenOdd);
|
2017-09-08 01:18:20 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Initialize context */
|
|
|
|
|
Surveys->SvyCod = Svy->SvyCod;
|
|
|
|
|
Surveys->QstCod = SvyQst.QstCod;
|
2020-10-14 00:59:24 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write icon to remove the question */
|
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemSvyQst,NULL,
|
|
|
|
|
Svy_PutParamsToEditQuestion,Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write icon to edit the question */
|
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiOneSvyQst,NULL,
|
|
|
|
|
Svy_PutParamsToEditQuestion,Surveys);
|
2017-09-08 01:18:20 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/* Write index of question inside survey */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_Unsigned (SvyQst.QstInd + 1);
|
|
|
|
|
HTM_TD_End ();
|
2021-04-25 13:24:39 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write the question type (row[2]) */
|
|
|
|
|
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
|
|
|
|
|
HTM_Txt (Txt_SURVEY_STR_ANSWER_TYPES[SvyQst.AnswerType]);
|
|
|
|
|
HTM_TD_End ();
|
2021-04-25 13:24:39 +02:00
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/* Write the stem and the answers of this question */
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT COLOR%u\"",
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme],Gbl.RowEvenOdd);
|
2021-10-24 16:55:47 +02:00
|
|
|
|
Svy_WriteQstStem (Stem);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_WriteAnswersOfAQst (Svy,&SvyQst,PutFormAnswerSurvey);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-13 18:19:26 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
|
|
|
|
if (PutFormAnswerSurvey)
|
|
|
|
|
{
|
|
|
|
|
/***** Button to create/modify survey *****/
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_Done);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-03-20 02:48:16 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // This survey has no questions
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_This_survey_has_no_questions);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-25 13:24:51 +02:00
|
|
|
|
if (Svy->Status.ICanEdit && // I can edit
|
|
|
|
|
(!NumQsts || // This survey has no questions
|
|
|
|
|
Editing)) // I am editing
|
2016-03-20 02:48:16 +01:00
|
|
|
|
/***** Put button to add a new question in this survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutButtonToCreateNewQuestion (Surveys);
|
2015-04-11 20:18:30 +02:00
|
|
|
|
|
2016-10-25 13:24:51 +02:00
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2016-03-20 02:48:16 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 16:55:47 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Get question data from row ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_GetDataOfQstFromRow (struct Svy_Question *SvyQst,
|
|
|
|
|
char Stem[Cns_MAX_BYTES_TEXT + 1],
|
|
|
|
|
MYSQL_ROW row)
|
|
|
|
|
{
|
|
|
|
|
/***** Get the code of the question (row[0]) *****/
|
|
|
|
|
if (sscanf (row[0],"%ld",&(SvyQst->QstCod)) != 1)
|
|
|
|
|
Err_WrongQuestionExit ();
|
|
|
|
|
|
|
|
|
|
/***** Get the index of the question inside the survey (row[1]) *****/
|
|
|
|
|
SvyQst->QstInd = Str_ConvertStrToUnsigned (row[1]);
|
|
|
|
|
|
|
|
|
|
/***** Get the answer type (row[2]) *****/
|
|
|
|
|
SvyQst->AnswerType = Svy_DB_ConvertFromStrAnsTypDBToAnsTyp (row[2]);
|
|
|
|
|
|
|
|
|
|
/***** Get the stem of the question from the database (row[2]) *****/
|
|
|
|
|
Str_Copy (Stem,row[2],Cns_MAX_BYTES_TEXT);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 01:18:20 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put parameters to edit a question **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParamsToEditQuestion (void *Surveys)
|
2017-09-08 01:18:20 +02:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Surveys)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->SvyCod);
|
|
|
|
|
Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2017-09-08 01:18:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-20 02:48:16 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put icon to add a new question to survey ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconToAddNewQuestion (void *Surveys)
|
2016-03-20 02:48:16 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_question;
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
/***** Put form to create a new question *****/
|
|
|
|
|
Ico_PutContextualIconToAdd (ActEdiOneSvyQst,NULL,
|
|
|
|
|
Svy_PutParams,Surveys,
|
|
|
|
|
Txt_New_question);
|
2016-03-20 02:48:16 +01:00
|
|
|
|
}
|
2015-04-11 20:18:30 +02:00
|
|
|
|
|
2016-03-20 02:48:16 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Put button to add a new question to survey *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
static void Svy_PutButtonToCreateNewQuestion (struct Svy_Surveys *Surveys)
|
2016-03-20 02:48:16 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_New_question;
|
|
|
|
|
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActEdiOneSvyQst);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Svy_PutParams (Surveys);
|
2021-10-20 23:34:45 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_question);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Write the heading of a survey question *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-09-06 11:36:34 +02:00
|
|
|
|
static void Svy_WriteQstStem (const char *Stem)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
char *HeadingRigorousHTML;
|
2017-01-15 22:58:26 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Convert the stem, that is in HTML, to rigorous HTML */
|
2017-03-08 03:48:23 +01:00
|
|
|
|
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (HeadingRigorousHTML,Stem,Length);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
2017-01-15 22:58:26 +01:00
|
|
|
|
HeadingRigorousHTML,Length,false);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Write the stem */
|
2019-11-10 12:36:37 +01:00
|
|
|
|
HTM_Txt (HeadingRigorousHTML);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Free memory allocated for the stem */
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (HeadingRigorousHTML);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get and write the answers of a survey question ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Question *SvyQst,
|
2017-11-30 12:07:19 +01:00
|
|
|
|
bool PutFormAnswerSurvey)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2016-12-20 02:18:50 +01:00
|
|
|
|
unsigned NumAnswers;
|
|
|
|
|
unsigned NumAns;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumUsrsThisAnswer;
|
2019-11-04 20:41:35 +01:00
|
|
|
|
char StrAns[32];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-07-02 19:46:53 +02:00
|
|
|
|
/***** Get answers of this question *****/
|
2021-10-20 17:57:27 +02:00
|
|
|
|
NumAnswers = Svy_DB_GetAnswersQst (&mysql_res,SvyQst->QstCod); // Result: AnsInd,NumUsrs,Answer
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write the answers *****/
|
2016-04-06 19:26:09 +02:00
|
|
|
|
if (NumAnswers)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-07-02 19:46:53 +02:00
|
|
|
|
/* Check number of answers */
|
|
|
|
|
if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION)
|
2021-09-25 22:49:05 +02:00
|
|
|
|
Err_WrongAnswerExit ();
|
2017-07-02 19:46:53 +02:00
|
|
|
|
|
|
|
|
|
/* Write one row for each answer */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginPadding (5);
|
2019-10-13 18:19:26 +02:00
|
|
|
|
|
2016-04-06 19:26:09 +02:00
|
|
|
|
for (NumAns = 0;
|
|
|
|
|
NumAns < NumAnswers;
|
|
|
|
|
NumAns++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get number of users who have marked this answer (row[1]) */
|
|
|
|
|
if (sscanf (row[1],"%u",&NumUsrsThisAnswer) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of users who have marked an answer.");
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
|
|
|
|
/* Convert the answer (row[2]), that is in HTML, to rigorous HTML */
|
2017-07-02 19:46:53 +02:00
|
|
|
|
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
|
2019-03-09 20:12:44 +01:00
|
|
|
|
/* Abort on error */
|
|
|
|
|
Ale_ShowAlertsAndExit ();
|
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SvyQst->AnsChoice[NumAns].Text,row[2],Svy_MAX_BYTES_ANSWER);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
2017-07-02 19:46:53 +02:00
|
|
|
|
SvyQst->AnsChoice[NumAns].Text,Svy_MAX_BYTES_ANSWER,false);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
|
|
|
|
/* Selectors and label with the letter of the answer */
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
if (PutFormAnswerSurvey)
|
|
|
|
|
{
|
|
|
|
|
/* Write selector to choice this answer */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
snprintf (StrAns,sizeof (StrAns),"Ans%010u",
|
|
|
|
|
(unsigned) SvyQst->QstCod);
|
|
|
|
|
if (SvyQst->AnswerType == Svy_ANS_UNIQUE_CHOICE)
|
|
|
|
|
HTM_INPUT_RADIO (StrAns,false,
|
|
|
|
|
"id=\"Ans%010u_%010u\" value=\"%u\""
|
|
|
|
|
" onclick=\"selectUnselectRadio(this,this.form.Ans%010u,%u)\"",
|
|
|
|
|
(unsigned) SvyQst->QstCod,NumAns,NumAns,
|
|
|
|
|
NumAns,
|
|
|
|
|
(unsigned) SvyQst->QstCod,NumAnswers);
|
|
|
|
|
else // SvyQst->AnswerType == Svy_ANS_MULTIPLE_CHOICE
|
|
|
|
|
HTM_INPUT_CHECKBOX (StrAns,HTM_DONT_SUBMIT_ON_CHANGE,
|
|
|
|
|
"id=\"Ans%010u_%010u\" value=\"%u\"",
|
|
|
|
|
(unsigned) SvyQst->QstCod,NumAns,NumAns,
|
|
|
|
|
NumAns);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
}
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write the number of option */
|
|
|
|
|
HTM_TD_Begin ("class=\"SVY_OPT LT\"");
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_LABEL_Begin ("for=\"Ans%010u_%010u\" class=\"%s\"",
|
|
|
|
|
(unsigned) SvyQst->QstCod,NumAns,
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme]);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_TxtF ("%u)",NumAns + 1);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Write the text of the answer */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_LABEL_Begin ("for=\"Ans%010u_%010u\" class=\"%s\"",
|
|
|
|
|
(unsigned) SvyQst->QstCod,NumAns,
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme]);
|
2021-10-20 17:57:27 +02:00
|
|
|
|
HTM_Txt (SvyQst->AnsChoice[NumAns].Text);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_TD_End ();
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/* Show stats of this answer */
|
|
|
|
|
if (Svy->Status.ICanViewResults)
|
|
|
|
|
Svy_DrawBarNumUsrs (NumUsrsThisAnswer,Svy->NumUsrs);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2016-04-06 19:26:09 +02:00
|
|
|
|
|
|
|
|
|
/* Free memory allocated for the answer */
|
2017-07-02 19:46:53 +02:00
|
|
|
|
Svy_FreeTextChoiceAnswer (SvyQst,NumAns);
|
2016-04-06 19:26:09 +02:00
|
|
|
|
}
|
2019-10-13 18:19:26 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Draw a bar with the percentage of answers *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-09-28 18:28:29 +02:00
|
|
|
|
#define Svy_MAX_BAR_WIDTH 125
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
|
|
|
|
|
{
|
2021-12-15 00:47:29 +01:00
|
|
|
|
extern const char *The_ClassDat[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_of_PART_OF_A_TOTAL;
|
|
|
|
|
unsigned BarWidth = 0;
|
2019-12-30 22:32:06 +01:00
|
|
|
|
char *Title;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-12-30 22:32:06 +01:00
|
|
|
|
/***** Build string with the number of users *****/
|
2015-07-22 18:59:44 +02:00
|
|
|
|
if (MaxUsrs)
|
2019-12-30 22:32:06 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&Title,"%u (%u%% %s %u)",
|
|
|
|
|
NumUsrs,
|
|
|
|
|
(unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5),
|
|
|
|
|
Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-12-30 22:32:06 +01:00
|
|
|
|
}
|
2015-07-22 18:59:44 +02:00
|
|
|
|
else
|
2019-12-30 22:32:06 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&Title,"0 (0%% %s %u)",
|
|
|
|
|
Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-12-30 22:32:06 +01:00
|
|
|
|
}
|
2015-07-22 18:59:44 +02:00
|
|
|
|
|
2021-12-15 00:47:29 +01:00
|
|
|
|
HTM_TD_Begin ("class=\"%s LT\" style=\"width:%upx;\"",
|
|
|
|
|
The_ClassDat[Gbl.Prefs.Theme],Svy_MAX_BAR_WIDTH + 125);
|
2019-10-13 18:19:26 +02:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Draw bar with a with proportional to the number of clicks *****/
|
|
|
|
|
if (NumUsrs && MaxUsrs)
|
|
|
|
|
BarWidth = (unsigned) ((((double) NumUsrs * (double) Svy_MAX_BAR_WIDTH) /
|
|
|
|
|
(double) MaxUsrs) + 0.5);
|
|
|
|
|
if (BarWidth < 2)
|
|
|
|
|
BarWidth = 2;
|
|
|
|
|
HTM_IMG (Cfg_URL_ICON_PUBLIC,"o1x1.png",Title,
|
|
|
|
|
"class=\"LT\" style=\"width:%upx; height:20px;\"",BarWidth);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Write the number of users *****/
|
|
|
|
|
HTM_TxtF (" %s",Title);
|
2019-12-30 22:32:06 +01:00
|
|
|
|
|
2021-10-20 17:57:27 +02:00
|
|
|
|
/***** Free string with the number of users *****/
|
|
|
|
|
free (Title);
|
2019-10-07 21:15:14 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-05 13:07:33 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put icon to remove one question ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutIconToRemoveOneQst (void *Surveys)
|
2016-04-05 13:07:33 +02:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
Ico_PutContextualIconToRemove (ActReqRemSvyQst,NULL,
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutParamsRemoveOneQst,Surveys);
|
2016-04-05 13:07:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Put parameter to remove one question *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void Svy_PutParamsRemoveOneQst (void *Surveys)
|
2016-04-05 13:07:33 +02:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
if (Surveys)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
{
|
2020-04-09 21:36:21 +02:00
|
|
|
|
Svy_PutParamSvyCod (((struct Svy_Surveys *) Surveys)->SvyCod);
|
|
|
|
|
Svy_PutParamQstCod (((struct Svy_Surveys *) Surveys)->QstCod);
|
2020-03-26 02:54:30 +01:00
|
|
|
|
}
|
2016-04-05 13:07:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-05 10:47:36 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Request the removal of a question ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_RequestRemoveQst (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_question_X;
|
|
|
|
|
extern const char *Txt_Remove_question;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
|
|
|
|
struct Svy_Question SvyQst;
|
2016-04-05 10:47:36 +02:00
|
|
|
|
long SvyCod;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
2017-11-30 12:07:19 +01:00
|
|
|
|
/***** Initialize question to zero *****/
|
|
|
|
|
Svy_InitQst (&SvyQst);
|
|
|
|
|
|
2016-04-05 10:47:36 +02:00
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get survey code */
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
|
|
|
|
/* Get question code */
|
|
|
|
|
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongQuestionExit ();
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
|
|
|
|
/* Get question index */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod);
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
2017-04-28 13:38:23 +02:00
|
|
|
|
/***** Show question and button to remove question *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Surveys.SvyCod = SvyCod;
|
|
|
|
|
Surveys.QstCod = SvyQst.QstCod;
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ale_ShowAlertAndButton (ActRemSvyQst,NULL,NULL,
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_PutParamsRemoveOneQst,&Surveys,
|
2019-02-17 01:14:55 +01:00
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_question,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_question_X,
|
2019-05-30 12:57:31 +02:00
|
|
|
|
(long) SvyQst.QstInd + 1);
|
2016-04-05 10:47:36 +02:00
|
|
|
|
|
|
|
|
|
/***** Show current survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,SvyCod,true);
|
2016-04-05 10:47:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Remove a question ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_RemoveQst (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Question_removed;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
|
|
|
|
struct Svy_Question SvyQst;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long SvyCod;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-11-30 12:07:19 +01:00
|
|
|
|
/***** Initialize question to zero *****/
|
|
|
|
|
Svy_InitQst (&SvyQst);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get survey code */
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get question code */
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongQuestionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get question index */
|
2021-10-20 17:57:27 +02:00
|
|
|
|
SvyQst.QstInd = Svy_DB_GetQstIndFromQstCod (SvyQst.QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Remove the question from all tables *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Remove answers from this test question */
|
2021-10-21 22:28:09 +02:00
|
|
|
|
Svy_DB_RemoveAnswersQst (SvyQst.QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Remove the question itself */
|
2021-10-20 23:34:45 +02:00
|
|
|
|
Svy_DB_RemoveQst (SvyQst.QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Change index of questions greater than this */
|
2021-10-20 23:34:45 +02:00
|
|
|
|
Svy_DB_ChangeIndexesQsts (SvyCod,SvyQst.QstInd);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message *****/
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show current survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Receive answers of a survey ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Svy_ReceiveSurveyAnswers (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_You_already_answered_this_survey_before;
|
|
|
|
|
extern const char *Txt_Thanks_for_answering_the_survey;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
struct Svy_Surveys Surveys;
|
2020-04-09 21:36:21 +02:00
|
|
|
|
struct Svy_Survey Svy;
|
2017-11-30 12:07:19 +01:00
|
|
|
|
|
2020-04-10 21:57:50 +02:00
|
|
|
|
/***** Reset surveys *****/
|
|
|
|
|
Svy_ResetSurveys (&Surveys);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get survey code *****/
|
2021-04-25 13:24:39 +02:00
|
|
|
|
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongSurveyExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the survey from database *****/
|
|
|
|
|
Svy_GetDataOfSurveyByCod (&Svy);
|
|
|
|
|
|
|
|
|
|
/***** Check if I have no answered this survey formerly *****/
|
|
|
|
|
if (Svy.Status.IHaveAnswered)
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_already_answered_this_survey_before);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/***** Receive and store user's answers *****/
|
|
|
|
|
Svy_ReceiveAndStoreUserAnswersToASurvey (Svy.SvyCod);
|
2019-02-16 19:29:27 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Thanks_for_answering_the_survey);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show current survey *****/
|
2020-04-10 21:57:50 +02:00
|
|
|
|
Svy_ShowOneSurvey (&Surveys,Svy.SvyCod,true);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Get and store user's answers to a survey *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumQst;
|
|
|
|
|
unsigned NumQsts;
|
|
|
|
|
long QstCod;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char ParamName[3 + 10 + 6 + 1];
|
2019-11-08 01:10:32 +01:00
|
|
|
|
char StrAnswersIndexes[Svy_MAX_ANSWERS_PER_QUESTION * (Cns_MAX_DECIMAL_DIGITS_UINT + 1)];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const char *Ptr;
|
2019-11-08 01:10:32 +01:00
|
|
|
|
char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned AnsInd;
|
|
|
|
|
|
|
|
|
|
/***** Get questions of this survey from database *****/
|
2021-10-20 23:34:45 +02:00
|
|
|
|
if ((NumQsts = Svy_DB_GetSurveyQstsCodes (&mysql_res,SvyCod)))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-11-30 12:07:19 +01:00
|
|
|
|
// This survey has questions
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get questions *****/
|
|
|
|
|
for (NumQst = 0;
|
|
|
|
|
NumQst < NumQsts;
|
|
|
|
|
NumQst++)
|
|
|
|
|
{
|
2021-04-05 23:45:24 +02:00
|
|
|
|
/* Get next question */
|
|
|
|
|
if ((QstCod = DB_GetNextCode (mysql_res)) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongQuestionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get possible parameter with the user's answer */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ParamName,sizeof (ParamName),"Ans%010u",(unsigned) QstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
// Lay_ShowAlert (Lay_INFO,ParamName);
|
2017-01-28 15:58:46 +01:00
|
|
|
|
Par_GetParMultiToText (ParamName,StrAnswersIndexes,
|
2019-11-08 01:10:32 +01:00
|
|
|
|
Svy_MAX_ANSWERS_PER_QUESTION * (Cns_MAX_DECIMAL_DIGITS_UINT + 1));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Ptr = StrAnswersIndexes;
|
|
|
|
|
while (*Ptr)
|
|
|
|
|
{
|
2019-11-08 01:10:32 +01:00
|
|
|
|
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (sscanf (UnsignedStr,"%u",&AnsInd) == 1)
|
2017-11-30 12:07:19 +01:00
|
|
|
|
// Parameter exists ==> user has checked this answer
|
|
|
|
|
// ==> store it in database
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_DB_IncreaseAnswer (QstCod,AnsInd);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-30 12:07:19 +01:00
|
|
|
|
else // This survey has no questions
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error: this survey has no questions.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Register that you have answered this survey *****/
|
2021-10-20 17:57:27 +02:00
|
|
|
|
Svy_DB_RegisterIHaveAnsweredSvy (SvyCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-10-27 15:06:11 +02:00
|
|
|
|
/******************** Get number of surveys for courses **********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns the number of surveys for courses
|
|
|
|
|
// in this location (all the platform, current degree or current course)
|
|
|
|
|
|
2021-05-27 23:30:16 +02:00
|
|
|
|
unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumSurveys;
|
|
|
|
|
|
|
|
|
|
/***** Get number of surveys from database *****/
|
2021-10-20 23:34:45 +02:00
|
|
|
|
if (Svy_DB_GetNumCrsSurveys (&mysql_res,Scope))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-10-20 23:34:45 +02:00
|
|
|
|
/***** Get number of surveys *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
if (sscanf (row[0],"%u",&NumSurveys) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of surveys.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-20 23:34:45 +02:00
|
|
|
|
/***** Get number of notifications by email *****/
|
|
|
|
|
if (row[1])
|
|
|
|
|
{
|
|
|
|
|
if (sscanf (row[1],"%u",NumNotif) != 1)
|
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of notifications of surveys.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
*NumNotif = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-10-20 23:34:45 +02:00
|
|
|
|
NumSurveys = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumSurveys;
|
|
|
|
|
}
|