swad-core/swad_figure.c

269 lines
9.8 KiB
C
Raw Permalink Normal View History

2019-02-12 14:46:14 +01:00
// swad_figure.c: figures (global stats)
/*
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-2024 Antonio Ca<EFBFBD>as Vargas
2019-02-12 14:46:14 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include "swad_action.h"
#include "swad_action_list.h"
#include "swad_agenda.h"
2019-02-12 14:46:14 +01:00
#include "swad_box.h"
#include "swad_calendar.h"
#include "swad_cookie.h"
#include "swad_degree_type.h"
#include "swad_exam.h"
2019-02-12 14:46:14 +01:00
#include "swad_figure.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_forum.h"
2019-02-12 14:46:14 +01:00
#include "swad_global.h"
#include "swad_hierarchy.h"
2019-10-23 19:05:05 +02:00
#include "swad_HTML.h"
2020-04-14 17:15:17 +02:00
#include "swad_message.h"
2019-02-12 14:46:14 +01:00
#include "swad_network.h"
#include "swad_notice.h"
#include "swad_parameter.h"
2019-03-23 13:10:31 +01:00
#include "swad_privacy.h"
2020-02-24 22:47:34 +01:00
#include "swad_program.h"
2020-04-14 17:15:17 +02:00
#include "swad_project.h"
#include "swad_rubric.h"
2020-04-14 17:15:17 +02:00
#include "swad_survey.h"
#include "swad_test.h"
#include "swad_theme.h"
2020-04-14 17:15:17 +02:00
#include "swad_timeline.h"
2019-02-12 14:46:14 +01:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
2019-11-21 16:47:07 +01:00
/****************************** Private prototypes ***************************/
2019-02-12 14:46:14 +01:00
/*****************************************************************************/
2020-04-06 23:18:02 +02:00
static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType);
static void Fig_PutParFigureType (Fig_FigureType_t FigureType);
static void Fig_PutParFigScope (Hie_Level_t Level);
2019-02-12 14:46:14 +01:00
/*****************************************************************************/
/************************** Show use of the platform *************************/
/*****************************************************************************/
void Fig_ReqShowFigures (void)
2020-04-06 23:18:02 +02:00
{
Fig_ReqShowFigure (Fig_FIGURE_TYPE_DEF);
}
static void Fig_ReqShowFigure (Fig_FigureType_t SelectedFigureType)
2019-02-12 14:46:14 +01:00
{
extern const char *Hlp_ANALYTICS_Figures;
extern const char *Txt_Figures;
extern const char *Txt_Scope;
extern const char *Txt_Statistic;
extern const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES];
extern const char *Txt_Show_statistic;
2020-04-06 23:18:02 +02:00
Fig_FigureType_t FigType;
2019-11-06 19:45:20 +01:00
unsigned FigureTypeUnsigned;
2019-02-12 14:46:14 +01:00
/***** Get scope *****/
Gbl.Scope.Allowed = 1 << Hie_SYS |
1 << Hie_CTY |
1 << Hie_INS |
1 << Hie_CTR |
1 << Hie_DEG |
1 << Hie_CRS;
Sco_GetScope ("FigScope",Hie_SYS);
2019-02-12 14:46:14 +01:00
/***** Form to show statistic *****/
Frm_BeginForm (ActSeeUseGbl);
2019-02-12 14:46:14 +01:00
/***** Begin box *****/
Box_BoxBegin (Txt_Figures,NULL,NULL,
Hlp_ANALYTICS_Figures,Box_NOT_CLOSABLE);
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (2);
/***** Compute stats for anywhere, degree or course? *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("Frm_C1 RM","FigScope",Txt_Scope);
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM DAT_%s\"",The_GetSuffix ());
Sco_PutSelectorScope ("FigScope",HTM_DONT_SUBMIT_ON_CHANGE);
HTM_TD_End ();
HTM_TR_End ();
/***** Type of statistic *****/
HTM_TR_Begin (NULL);
/* Label */
Frm_LabelColumn ("Frm_C1 RM","FigureType",Txt_Statistic);
/* Data */
HTM_TD_Begin ("class=\"Frm_C2 LM DAT_%s\"",The_GetSuffix ());
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,NULL,
"name=\"FigureType\""
" class=\"Frm_C2_INPUT INPUT_%s\"",
The_GetSuffix ());
for (FigType = (Fig_FigureType_t) 0;
FigType <= (Fig_FigureType_t) (Fig_NUM_FIGURES - 1);
FigType++)
{
FigureTypeUnsigned = (unsigned) FigType;
HTM_OPTION (HTM_Type_UNSIGNED,&FigureTypeUnsigned,
FigType == SelectedFigureType ? HTM_OPTION_SELECTED :
HTM_OPTION_UNSELECTED,
HTM_OPTION_ENABLED,
"%s",Txt_FIGURE_TYPES[FigType]);
}
HTM_SELECT_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** End table *****/
HTM_TABLE_End ();
2019-02-12 14:46:14 +01:00
/***** Send button and end box *****/
Box_BoxWithButtonEnd (Btn_CONFIRM_BUTTON,Txt_Show_statistic);
2019-02-12 14:46:14 +01:00
/***** End form *****/
Frm_EndForm ();
}
/*****************************************************************************/
/************************* Put icon to show a figure *************************/
/*****************************************************************************/
2020-04-06 23:18:02 +02:00
void Fig_PutIconToShowFigure (Fig_FigureType_t FigureType)
2019-02-12 14:46:14 +01:00
{
2020-04-06 23:18:02 +02:00
struct Fig_Figures Figures;
2019-02-12 14:46:14 +01:00
2020-04-06 23:18:02 +02:00
/***** Set default scope (used only if Gbl.Scope.Current is unknown) *****/
Sco_AdjustScope (Hie_CRS);
2020-04-06 23:18:02 +02:00
/***** Put icon to show figure *****/
Figures.Level = Gbl.Scope.Current;
2020-04-06 23:18:02 +02:00
Figures.FigureType = FigureType;
2020-03-26 02:54:30 +01:00
Lay_PutContextualLinkOnlyIcon (ActSeeUseGbl,NULL,
Fig_PutParsFigures,&Figures,
"chart-pie.svg",Ico_BLACK);
2019-02-12 14:46:14 +01:00
}
/*****************************************************************************/
/************* Put hidden parameters for figures (statistics) ****************/
/*****************************************************************************/
void Fig_PutParsFigures (void *Figures)
2019-02-12 14:46:14 +01:00
{
2020-04-06 23:18:02 +02:00
if (Figures)
2020-03-26 02:54:30 +01:00
{
Fig_PutParFigScope (((struct Fig_Figures *) Figures)->Level);
Fig_PutParFigureType (((struct Fig_Figures *) Figures)->FigureType);
2020-03-26 02:54:30 +01:00
}
2019-02-12 14:46:14 +01:00
}
/*****************************************************************************/
/********* Put hidden parameter for the type of figure (statistic) ***********/
/*****************************************************************************/
static void Fig_PutParFigureType (Fig_FigureType_t FigureType)
2019-02-12 14:46:14 +01:00
{
Par_PutParUnsigned (NULL,"FigureType",(unsigned) FigureType);
2019-02-12 14:46:14 +01:00
}
/*****************************************************************************/
/********* Put hidden parameter for the type of figure (statistic) ***********/
/*****************************************************************************/
static void Fig_PutParFigScope (Hie_Level_t Level)
2019-02-12 14:46:14 +01:00
{
Sco_PutParScope ("FigScope",Level);
2019-02-12 14:46:14 +01:00
}
/*****************************************************************************/
/************************** Show use of the platform *************************/
/*****************************************************************************/
void Fig_ShowFigures (void)
{
static void (*Fig_Function[Fig_NUM_FIGURES])(void) = // Array of pointers to functions
{
[Fig_USERS ] = Usr_GetAndShowUsersStats,
[Fig_USERS_RANKING ] = Usr_GetAndShowUsersRanking,
[Fig_HIERARCHY ] = Hie_GetAndShowHierarchyStats,
[Fig_INSTITS ] = Ins_GetAndShowInstitutionsStats,
[Fig_DEGREE_TYPES ] = DegTyp_GetAndShowDegTypesStats,
[Fig_FOLDERS_AND_FILES] = Brw_GetAndShowFileBrowsersStats,
[Fig_OER ] = Brw_GetAndShowOERsStats,
[Fig_COURSE_PROGRAMS ] = Prg_GetAndShowCourseProgramStats,
[Fig_ASSIGNMENTS ] = Asg_GetAndShowAssignmentsStats,
[Fig_PROJECTS ] = Prj_GetAndShowProjectsStats,
[Fig_TESTS ] = Tst_GetAndShowTestsStats,
[Fig_EXAMS ] = Exa_GetAndShowExamsStats,
[Fig_GAMES ] = Gam_GetAndShowGamesStats,
[Fig_RUBRICS ] = Rub_GetAndShowRubricsStats,
[Fig_TIMELINE ] = Tml_GetAndShowTimelineActivityStats,
[Fig_FOLLOW ] = Fol_GetAndShowFollowStats,
[Fig_FORUMS ] = For_GetAndShowForumStats,
[Fig_NOTIFY_EVENTS ] = Ntf_GetAndShowNumUsrsPerNotifyEvent,
[Fig_NOTICES ] = Not_GetAndShowNoticesStats,
[Fig_MESSAGES ] = Msg_GetAndShowMsgsStats,
[Fig_SURVEYS ] = Svy_GetAndShowSurveysStats,
[Fig_AGENDAS ] = Agd_GetAndShowAgendasStats,
2019-12-15 01:10:36 +01:00
[Fig_SOCIAL_NETWORKS ] = Net_ShowWebAndSocialNetworksStats,
[Fig_LANGUAGES ] = Lan_GetAndShowNumUsrsPerLanguage,
[Fig_FIRST_DAY_OF_WEEK] = Cal_GetAndShowNumUsrsPerFirstDayOfWeek,
[Fig_DATE_FORMAT ] = Dat_GetAndShowNumUsrsPerDateFormat,
[Fig_ICON_SETS ] = Ico_GetAndShowNumUsrsPerIconSet,
[Fig_MENUS ] = Mnu_GetAndShowNumUsrsPerMenu,
[Fig_THEMES ] = The_GetAndShowNumUsrsPerTheme,
[Fig_SIDE_COLUMNS ] = Lay_GetAndShowNumUsrsPerSideColumns,
[Fig_PHOTO_SHAPES ] = PhoSha_GetAndShowNumUsrsPerPhotoShape,
[Fig_PRIVACY ] = Pri_GetAndShowNumUsrsPerPrivacy,
[Fig_COOKIES ] = Coo_GetAndShowNumUsrsPerCookies,
2019-02-12 14:46:14 +01:00
};
2020-04-06 23:18:02 +02:00
Fig_FigureType_t SelectedFigureType;
2019-02-12 14:46:14 +01:00
/***** Get the type of figure ******/
2020-04-06 23:18:02 +02:00
SelectedFigureType = (Fig_FigureType_t)
Par_GetParUnsignedLong ("FigureType",
0,
Fig_NUM_FIGURES - 1,
(unsigned long) Fig_FIGURE_TYPE_DEF);
2019-02-12 14:46:14 +01:00
/***** Show again the form to see use of the platform *****/
2020-04-06 23:18:02 +02:00
Fig_ReqShowFigure (SelectedFigureType);
2019-02-12 14:46:14 +01:00
/***** Show the stat of use selected by user *****/
HTM_BR ();
2020-04-06 23:18:02 +02:00
Fig_Function[SelectedFigureType] ();
2019-02-12 14:46:14 +01:00
}