mirror of https://github.com/acanas/swad-core.git
Version 21.38: Oct 20, 2021 New module swad_survey_database for database queries related to surveys.
This commit is contained in:
parent
776174d0f1
commit
0bcffd3ee1
4
Makefile
4
Makefile
|
@ -80,8 +80,8 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
|
||||||
swad_room_database.o swad_RSS.o \
|
swad_room_database.o swad_RSS.o \
|
||||||
swad_scope.o swad_search.o swad_session.o swad_session_database.o \
|
swad_scope.o swad_search.o swad_session.o swad_session_database.o \
|
||||||
swad_setting.o swad_setting_database.o swad_statistic.o \
|
swad_setting.o swad_setting_database.o swad_statistic.o \
|
||||||
swad_statistic_database.o swad_string.o swad_survey.o swad_syllabus.o \
|
swad_statistic_database.o swad_string.o swad_survey.o \
|
||||||
swad_system_config.o \
|
swad_survey_database.o swad_syllabus.o swad_system_config.o \
|
||||||
swad_tab.o swad_tag.o swad_test.o swad_test_config.o \
|
swad_tab.o swad_tag.o swad_test.o swad_test_config.o \
|
||||||
swad_test_import.o swad_test_print.o swad_test_visibility.o \
|
swad_test_import.o swad_test_print.o swad_test_visibility.o \
|
||||||
swad_theme.o \
|
swad_theme.o \
|
||||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
||||||
|
|
||||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.37.1 (2021-10-20)"
|
#define Log_PLATFORM_VERSION "SWAD 21.38 (2021-10-20)"
|
||||||
#define CSS_FILE "swad20.45.css"
|
#define CSS_FILE "swad20.45.css"
|
||||||
#define JS_FILE "swad20.69.1.js"
|
#define JS_FILE "swad20.69.1.js"
|
||||||
/*
|
/*
|
||||||
TODO: Rename CENTRE to CENTER in help wiki.
|
TODO: Rename CENTRE to CENTER in help wiki.
|
||||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||||
|
|
||||||
|
Version 21.38: Oct 20, 2021 New module swad_survey_database for database queries related to surveys. (320457 lines)
|
||||||
Version 21.37.1: Oct 20, 2021 Code refactoring in attendance. (320361 lines)
|
Version 21.37.1: Oct 20, 2021 Code refactoring in attendance. (320361 lines)
|
||||||
Version 21.37: Oct 19, 2021 New module swad_statistic_database for database queries related to statistics of accesses to platform. (320363 lines)
|
Version 21.37: Oct 19, 2021 New module swad_statistic_database for database queries related to statistics of accesses to platform. (320363 lines)
|
||||||
Version 21.36: Oct 18, 2021 New module swad_setting_database for database queries related to user's settings / preferences. (320253 lines)
|
Version 21.36: Oct 18, 2021 New module swad_setting_database for database queries related to user's settings / preferences. (320253 lines)
|
||||||
|
|
|
@ -3223,10 +3223,10 @@ static void Fig_GetAndShowSurveysStats (void)
|
||||||
/***** Get the number of surveys and the average number of questions per survey from this location *****/
|
/***** Get the number of surveys and the average number of questions per survey from this location *****/
|
||||||
if ((NumSurveys = Svy_GetNumCrsSurveys (Gbl.Scope.Current,&NumNotif)))
|
if ((NumSurveys = Svy_GetNumCrsSurveys (Gbl.Scope.Current,&NumNotif)))
|
||||||
{
|
{
|
||||||
if ((NumCoursesWithSurveys = Svy_GetNumCoursesWithCrsSurveys (Gbl.Scope.Current)) != 0)
|
if ((NumCoursesWithSurveys = Svy_DB_GetNumCrssWithCrsSvys (Gbl.Scope.Current)) != 0)
|
||||||
NumSurveysPerCourse = (double) NumSurveys /
|
NumSurveysPerCourse = (double) NumSurveys /
|
||||||
(double) NumCoursesWithSurveys;
|
(double) NumCoursesWithSurveys;
|
||||||
NumQstsPerSurvey = Svy_GetNumQstsPerCrsSurvey (Gbl.Scope.Current);
|
NumQstsPerSurvey = Svy_DB_GetNumQstsPerCrsSurvey (Gbl.Scope.Current);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Begin box and table *****/
|
/***** Begin box and table *****/
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
#include "swad_setting.h"
|
#include "swad_setting.h"
|
||||||
#include "swad_setting_database.h"
|
#include "swad_setting_database.h"
|
||||||
#include "swad_survey.h"
|
#include "swad_survey.h"
|
||||||
|
#include "swad_survey_database.h"
|
||||||
#include "swad_timeline.h"
|
#include "swad_timeline.h"
|
||||||
#include "swad_timeline_database.h"
|
#include "swad_timeline_database.h"
|
||||||
#include "swad_timeline_notification.h"
|
#include "swad_timeline_notification.h"
|
||||||
|
|
741
swad_survey.c
741
swad_survey.c
File diff suppressed because it is too large
Load Diff
|
@ -120,10 +120,8 @@ void Svy_RemoveQst (void);
|
||||||
|
|
||||||
void Svy_ReceiveSurveyAnswers (void);
|
void Svy_ReceiveSurveyAnswers (void);
|
||||||
|
|
||||||
unsigned Svy_GetNumCoursesWithCrsSurveys (HieLvl_Level_t Scope);
|
unsigned Svy_DB_GetNumCrssWithCrsSvys (HieLvl_Level_t Scope);
|
||||||
unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif);
|
unsigned Svy_GetNumCrsSurveys (HieLvl_Level_t Scope,unsigned *NumNotif);
|
||||||
double Svy_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope);
|
double Svy_DB_GetNumQstsPerCrsSurvey (HieLvl_Level_t Scope);
|
||||||
|
|
||||||
unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
// swad_survey_database.c: surveys, operations with database
|
||||||
|
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************* Headers ***********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
// #define _GNU_SOURCE // For asprintf
|
||||||
|
// #include <linux/limits.h> // For PATH_MAX
|
||||||
|
// #include <stddef.h> // For NULL
|
||||||
|
// #include <stdio.h> // For asprintf
|
||||||
|
// #include <stdlib.h> // For calloc
|
||||||
|
// #include <string.h> // For string functions
|
||||||
|
|
||||||
|
// #include "swad_attendance.h"
|
||||||
|
// #include "swad_box.h"
|
||||||
|
#include "swad_database.h"
|
||||||
|
// #include "swad_error.h"
|
||||||
|
// #include "swad_figure.h"
|
||||||
|
// #include "swad_form.h"
|
||||||
|
#include "swad_global.h"
|
||||||
|
// #include "swad_group.h"
|
||||||
|
// #include "swad_group_database.h"
|
||||||
|
// #include "swad_HTML.h"
|
||||||
|
// #include "swad_notification.h"
|
||||||
|
// #include "swad_notification_database.h"
|
||||||
|
// #include "swad_pagination.h"
|
||||||
|
// #include "swad_parameter.h"
|
||||||
|
// #include "swad_role.h"
|
||||||
|
// #include "swad_setting.h"
|
||||||
|
// #include "swad_survey.h"
|
||||||
|
#include "swad_survey_database.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************** External global variables from others modules ****************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
extern struct Globals Gbl;
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private constants *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************************* Private types *******************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private variables *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Private prototypes ****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************ Get all user codes belonging to a survey, except me ************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod)
|
||||||
|
{
|
||||||
|
// 1. If the survey is available for the whole course ==> get users enroled in the course whose role is available in survey, except me
|
||||||
|
// 2. If the survey is available only for some groups ==> get users who belong to any of the groups and whose role is available in survey, except me
|
||||||
|
// Cases 1 and 2 are mutually exclusive, so the union returns the case 1 or 2
|
||||||
|
return (unsigned)
|
||||||
|
DB_QuerySELECT (mysql_res,"can not get users to be notified",
|
||||||
|
"(SELECT crs_users.UsrCod"
|
||||||
|
" FROM svy_surveys,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE svy_surveys.SvyCod=%ld"
|
||||||
|
" AND svy_surveys.SvyCod NOT IN"
|
||||||
|
" (SELECT SvyCod"
|
||||||
|
" FROM svy_groups"
|
||||||
|
" WHERE SvyCod=%ld)"
|
||||||
|
" AND svy_surveys.Scope='%s'"
|
||||||
|
" AND svy_surveys.Cod=crs_users.CrsCod"
|
||||||
|
" AND crs_users.UsrCod<>%ld"
|
||||||
|
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)"
|
||||||
|
" UNION "
|
||||||
|
"(SELECT DISTINCT grp_users.UsrCod"
|
||||||
|
" FROM svy_groups,"
|
||||||
|
"grp_users,"
|
||||||
|
"svy_surveys,"
|
||||||
|
"crs_users"
|
||||||
|
" WHERE svy_groups.SvyCod=%ld"
|
||||||
|
" AND svy_groups.GrpCod=grp_users.GrpCod"
|
||||||
|
" AND grp_users.UsrCod=crs_users.UsrCod"
|
||||||
|
" AND grp_users.UsrCod<>%ld"
|
||||||
|
" AND svy_groups.SvyCod=svy_surveys.SvyCod"
|
||||||
|
" AND svy_surveys.Scope='%s'"
|
||||||
|
" AND svy_surveys.Cod=crs_users.CrsCod"
|
||||||
|
" AND (svy_surveys.Roles&(1<<crs_users.Role))<>0)",
|
||||||
|
SvyCod,
|
||||||
|
SvyCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_CRS),
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
SvyCod,
|
||||||
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||||
|
Sco_GetDBStrFromScope (HieLvl_CRS));
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
// swad_survey_database.h: surveys, operations with database
|
||||||
|
|
||||||
|
#ifndef _SWAD_SVY_DB
|
||||||
|
#define _SWAD_SVY_DB
|
||||||
|
/*
|
||||||
|
SWAD (Shared Workspace At a Distance in Spanish),
|
||||||
|
is a web platform developed at the University of Granada (Spain),
|
||||||
|
and used to support university teaching.
|
||||||
|
|
||||||
|
This file is part of SWAD core.
|
||||||
|
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************************* Headers ***********************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <mysql/mysql.h> // To access MySQL databases
|
||||||
|
|
||||||
|
// #include "swad_date.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/************************** Public types and constants ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************************** Public prototypes *****************************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Svy_DB_GetUsrsFromSurveyExceptMe (MYSQL_RES **mysql_res,long SvyCod);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue