swad-core/swad_help.c

289 lines
12 KiB
C
Raw Normal View History

2015-10-16 02:24:29 +02:00
// swad_help.c: contextual help to enhance usability
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
2015-10-16 02:24:29 +02:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 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 <stdlib.h> // For exit, system, malloc, free, rand, etc.
#include "swad_action.h"
2017-06-10 21:38:10 +02:00
#include "swad_box.h"
2015-10-16 02:24:29 +02:00
#include "swad_config.h"
2018-11-09 20:47:39 +01:00
#include "swad_form.h"
2015-10-16 02:24:29 +02:00
#include "swad_global.h"
#include "swad_help.h"
2019-10-23 19:05:05 +02:00
#include "swad_HTML.h"
2015-10-16 02:24:29 +02:00
#include "swad_user.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Internal types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Internal global variables *************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Hlp_ShowRowHelpWhatWouldYouLikeToDo (const char *Description,
Act_Action_t Action,
2017-06-11 19:02:40 +02:00
Btn_Button_t Button,
2015-10-16 02:24:29 +02:00
const char *TxtButton);
/*****************************************************************************/
/*************************** Show contextual help ****************************/
/*****************************************************************************/
void Hlp_ShowHelpWhatWouldYouLikeToDo (void)
{
2017-03-30 11:20:06 +02:00
extern const char *Txt_You_are_not_enroled_in_any_course[Usr_NUM_SEXS];
extern const char *Txt_You_can_search_for_courses_select_them_and_request_your_enrolment_in_them;
2015-10-16 02:24:29 +02:00
extern const char *Txt_If_you_can_not_find_your_institution_your_centre_your_degree_or_your_courses_you_can_create_them;
extern const char *Txt_What_would_you_like_to_do;
2018-10-10 14:03:06 +02:00
extern const char *Txt_Register_students_in_COURSE_X;
2015-11-20 16:39:08 +01:00
extern const char *Txt_Register_students;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Go_to_one_of_my_courses;
extern const char *Txt_My_courses;
extern const char *Txt_Sign_up;
2018-10-07 18:07:01 +02:00
extern const char *Txt_Remove_me_from_THE_COURSE_X;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Remove_me;
2016-03-24 20:13:42 +01:00
extern const char *Txt_Register_me_in_X;
2018-10-07 18:07:01 +02:00
extern const char *Txt_Select_create_course_in_X;
2016-03-20 12:20:38 +01:00
extern const char *Txt_Select_or_create_one_course_in_X;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Courses;
2016-03-20 12:20:38 +01:00
extern const char *Txt_Select_or_create_another_degree_in_X;
extern const char *Txt_Select_or_create_one_degree_in_X;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Degrees;
2016-03-20 12:20:38 +01:00
extern const char *Txt_Select_or_create_another_centre_in_X;
extern const char *Txt_Select_or_create_one_centre_in_X;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Centres;
2016-03-20 12:20:38 +01:00
extern const char *Txt_Select_or_create_another_institution_in_X;
extern const char *Txt_Select_or_create_one_institution_in_X;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Institutions;
extern const char *Txt_Select_another_country;
extern const char *Txt_Select_one_country;
extern const char *Txt_Countries;
2015-11-20 16:39:08 +01:00
extern const char *Txt_Upload_my_picture;
extern const char *Txt_Upload_photo;
2015-10-16 02:24:29 +02:00
extern const char *Txt_Log_in;
extern const char *Txt_New_on_PLATFORM_Sign_up;
extern const char *Txt_Create_account;
2017-05-29 14:14:31 +02:00
static const Act_Action_t ActionsRemoveMe[Rol_NUM_ROLES] =
{
ActUnk, // Rol_UNK
ActUnk, // Rol_GST
ActUnk, // Rol_USR
ActRemMe_Std, // Rol_STD
ActRemMe_NET, // Rol_NET
ActRemMe_Tch, // Rol_TCH
ActUnk, // Rol_DEG_ADM
ActUnk, // Rol_CTR_ADM
ActUnk, // Rol_INS_ADM
ActUnk, // Rol_SYS_ADM
};
2015-10-16 02:24:29 +02:00
/***** Alert message *****/
if (Gbl.Usrs.Me.Logged &&
2016-10-28 10:03:37 +02:00
!Gbl.Usrs.Me.MyCrss.Num)
2019-02-16 16:18:54 +01:00
Ale_ShowAlert (Ale_INFO,"%s<br />%s<br />%s",
Txt_You_are_not_enroled_in_any_course[Gbl.Usrs.Me.UsrDat.Sex],
Txt_You_can_search_for_courses_select_them_and_request_your_enrolment_in_them,
Txt_If_you_can_not_find_your_institution_your_centre_your_degree_or_your_courses_you_can_create_them);
2015-10-16 02:24:29 +02:00
2017-06-12 14:16:33 +02:00
/***** Start box and table *****/
2017-06-10 21:38:10 +02:00
Box_StartBoxTable (NULL,Txt_What_would_you_like_to_do,NULL,
2017-06-12 15:03:29 +02:00
NULL,Box_CLOSABLE,2);
2015-10-16 02:24:29 +02:00
if (Gbl.Usrs.Me.Logged) // I am logged
{
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
2016-03-24 20:13:42 +01:00
{
if (Gbl.Usrs.Me.IBelongToCurrentCrs) // I belong to this course
{
2016-12-05 13:26:12 +01:00
if (Gbl.Action.Act != ActLogIn &&
Gbl.Action.Act != ActLogInNew &&
Gbl.Action.Act != ActLogInLan) // I am not just logged
2017-06-08 15:32:33 +02:00
if (ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role] != ActUnk)
2017-05-29 14:14:31 +02:00
{
/* Request my removing from this course */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Remove_me_from_THE_COURSE_X,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.ShrtName);
2017-05-29 14:14:31 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
2017-06-08 15:32:33 +02:00
ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role],
2017-06-11 19:02:40 +02:00
Btn_REMOVE_BUTTON,Txt_Remove_me);
2017-05-29 14:14:31 +02:00
}
2016-03-24 20:13:42 +01:00
}
else // I do not belong to this course
{
/* Request my registration in this course */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Register_me_in_X,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.ShrtName);
2016-03-24 20:13:42 +01:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActReqSignUp,
2017-06-11 19:02:40 +02:00
Btn_CREATE_BUTTON,Txt_Sign_up);
2016-03-24 20:13:42 +01:00
}
}
2017-03-30 11:20:06 +02:00
if (Gbl.Usrs.Me.MyCrss.Num) // I am enroled in some courses
2015-10-16 02:24:29 +02:00
{
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected
2019-04-04 10:45:15 +02:00
!Gbl.Hierarchy.Crs.NumUsrs[Rol_STD] && // Current course has no students
2017-06-08 15:32:33 +02:00
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role == Rol_TCH) // I am a teacher in current course
2015-11-20 16:39:08 +01:00
{
2017-03-30 11:20:06 +02:00
/* Request students enrolment */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_Register_students_in_COURSE_X,
2019-04-04 10:45:15 +02:00
Gbl.Hierarchy.Crs.ShrtName);
2015-11-20 16:39:08 +01:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActReqEnrSevStd,
2017-06-11 19:02:40 +02:00
Btn_CREATE_BUTTON,Txt_Register_students);
2015-11-20 16:39:08 +01:00
}
2016-01-17 15:10:54 +01:00
if (Gbl.Action.Act != ActMyCrs) // I am not seeing the action to list my courses
2015-10-16 02:24:29 +02:00
/* Request list my courses */
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Go_to_one_of_my_courses,
2015-11-20 16:39:08 +01:00
ActMyCrs,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_My_courses);
2015-10-16 02:24:29 +02:00
}
2019-04-03 20:57:04 +02:00
if (Gbl.Hierarchy.Deg.DegCod > 0) // Degree selected
2015-10-16 02:24:29 +02:00
{
/* Select a course */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Level == Hie_CRS ? Txt_Select_create_course_in_X :
Txt_Select_or_create_one_course_in_X,
Gbl.Hierarchy.Deg.ShrtName);
2015-10-16 02:24:29 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeCrs,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Courses);
2015-10-16 02:24:29 +02:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ctr.CtrCod > 0) // Centre selected
2015-10-16 02:24:29 +02:00
{
/* Select a degree */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Deg.DegCod > 0 ? Txt_Select_or_create_another_degree_in_X :
2018-10-18 02:02:32 +02:00
Txt_Select_or_create_one_degree_in_X,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.ShrtName);
2015-10-16 02:24:29 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeDeg,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Degrees);
2015-10-16 02:24:29 +02:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Ins.InsCod > 0) // Institution selected
2015-10-16 02:24:29 +02:00
{
/* Select a centre */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ctr.CtrCod > 0 ? Txt_Select_or_create_another_centre_in_X :
2018-10-18 02:02:32 +02:00
Txt_Select_or_create_one_centre_in_X,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.ShrtName);
2015-10-16 02:24:29 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeCtr,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Centres);
2015-10-16 02:24:29 +02:00
}
2019-04-03 20:57:04 +02:00
else if (Gbl.Hierarchy.Cty.CtyCod > 0) // Country selected
2015-10-16 02:24:29 +02:00
{
/* Select an institution */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Ins.InsCod > 0 ? Txt_Select_or_create_another_institution_in_X :
2018-10-18 02:02:32 +02:00
Txt_Select_or_create_one_institution_in_X,
2019-04-03 20:57:04 +02:00
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
2015-10-16 02:24:29 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
ActSeeIns,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Institutions);
2015-10-16 02:24:29 +02:00
}
else
/* Select a country */
2019-04-03 20:57:04 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Hierarchy.Cty.CtyCod > 0 ? Txt_Select_another_country :
2015-10-16 02:24:29 +02:00
Txt_Select_one_country,
ActSeeCty,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Countries);
2015-10-16 02:24:29 +02:00
if (!Gbl.Usrs.Me.MyPhotoExists) // I have no photo
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Upload_my_picture,
ActReqMyPho,
2017-06-11 19:02:40 +02:00
Btn_CREATE_BUTTON,Txt_Upload_photo);
2015-10-16 02:24:29 +02:00
}
else // I am not logged
{
/* Log in */
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Log_in,
ActFrmLogIn,
2017-06-11 19:02:40 +02:00
Btn_CONFIRM_BUTTON,Txt_Log_in);
2015-10-16 02:24:29 +02:00
/* Sign up */
2018-10-18 02:02:32 +02:00
snprintf (Gbl.Title,sizeof (Gbl.Title),
Txt_New_on_PLATFORM_Sign_up,
Cfg_PLATFORM_SHORT_NAME);
2015-10-16 02:24:29 +02:00
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Gbl.Title,
2016-10-12 14:02:56 +02:00
ActFrmMyAcc,
2017-06-11 19:02:40 +02:00
Btn_CREATE_BUTTON,Txt_Create_account);
2015-10-16 02:24:29 +02:00
}
2017-06-12 14:16:33 +02:00
/***** End table and box *****/
2017-06-10 21:38:10 +02:00
Box_EndBoxTable ();
2015-10-16 02:24:29 +02:00
}
/*****************************************************************************/
/*************************** Show contextual help ****************************/
/*****************************************************************************/
static void Hlp_ShowRowHelpWhatWouldYouLikeToDo (const char *Description,
Act_Action_t Action,
2017-06-11 19:02:40 +02:00
Btn_Button_t Button,
2015-10-16 02:24:29 +02:00
const char *TxtButton)
{
2019-10-23 19:05:05 +02:00
HTM_TR_Begin (NULL);
2019-10-04 20:43:43 +02:00
/***** Description *****/
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"DAT RM\"");
2019-10-08 23:28:51 +02:00
fprintf (Gbl.F.Out,"%s:",Description);
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2015-10-16 02:24:29 +02:00
/***** Button *****/
2019-10-23 19:05:05 +02:00
HTM_TD_Begin ("class=\"LM\"");
2018-11-09 20:47:39 +01:00
Frm_StartForm (Action);
2017-06-11 19:02:40 +02:00
Btn_PutButtonInline (Button,TxtButton);
2018-11-09 20:47:39 +01:00
Frm_EndForm ();
2019-10-23 19:05:05 +02:00
HTM_TD_End ();
2019-10-04 20:43:43 +02:00
2019-10-23 19:05:05 +02:00
HTM_TR_End ();
2015-10-16 02:24:29 +02:00
}