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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-30 11:50:29 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <stdio.h> // For asprintf
|
2022-04-25 18:27:24 +02:00
|
|
|
|
#include <stdlib.h> // For free
|
2021-12-30 11:50:29 +01:00
|
|
|
|
|
2015-10-16 02:24:29 +02:00
|
|
|
|
#include "swad_action.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.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"
|
2021-12-30 11:50:29 +01:00
|
|
|
|
#include "swad_error.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"
|
2023-09-22 14:47:56 +02:00
|
|
|
|
#include "swad_hierarchy_type.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"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** 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;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_If_you_can_not_find_your_institution_your_center_your_degree_or_your_courses_you_can_create_them;
|
2015-10-16 02:24:29 +02:00
|
|
|
|
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;
|
2023-11-06 15:20:34 +01:00
|
|
|
|
extern const char *Txt_HIERARCHY_PLURAL_Abc[Hie_NUM_LEVELS];
|
2023-11-06 16:54:49 +01:00
|
|
|
|
extern const char *Txt_Select_or_create_one_course_in_X;
|
2016-03-20 12:20:38 +01:00
|
|
|
|
extern const char *Txt_Select_or_create_one_degree_in_X;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
extern const char *Txt_Select_or_create_one_center_in_X;
|
2016-03-20 12:20:38 +01:00
|
|
|
|
extern const char *Txt_Select_or_create_one_institution_in_X;
|
2023-12-06 20:59:19 +01:00
|
|
|
|
extern const char *Txt_Select_one_country_in_X;
|
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;
|
2023-05-10 11:56:47 +02:00
|
|
|
|
extern const char *Txt_Actions[ActLst_NUM_ACTIONS];
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t ActionsRemoveMe[Rol_NUM_ROLES] =
|
2017-05-29 14:14:31 +02:00
|
|
|
|
{
|
2019-11-21 01:27:17 +01:00
|
|
|
|
[Rol_UNK ] = ActUnk,
|
|
|
|
|
[Rol_GST ] = ActUnk,
|
|
|
|
|
[Rol_USR ] = ActUnk,
|
|
|
|
|
[Rol_STD ] = ActRemMe_Std,
|
|
|
|
|
[Rol_NET ] = ActRemMe_NET,
|
|
|
|
|
[Rol_TCH ] = ActRemMe_Tch,
|
|
|
|
|
[Rol_DEG_ADM] = ActUnk,
|
|
|
|
|
[Rol_CTR_ADM] = ActUnk,
|
|
|
|
|
[Rol_INS_ADM] = ActUnk,
|
|
|
|
|
[Rol_SYS_ADM] = ActUnk,
|
2017-05-29 14:14:31 +02:00
|
|
|
|
};
|
2023-12-06 20:59:19 +01:00
|
|
|
|
static struct
|
2023-11-06 16:54:49 +01:00
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Act_Action_t Action;
|
|
|
|
|
const char **Description;
|
|
|
|
|
} SelectOrCreate[Hie_NUM_LEVELS]=
|
2023-11-06 16:54:49 +01:00
|
|
|
|
{
|
2023-12-06 20:59:19 +01:00
|
|
|
|
[Hie_SYS] = {ActSeeCty,&Txt_Select_one_country_in_X },
|
|
|
|
|
[Hie_CTY] = {ActSeeIns,&Txt_Select_or_create_one_institution_in_X },
|
|
|
|
|
[Hie_INS] = {ActSeeCtr,&Txt_Select_or_create_one_center_in_X },
|
|
|
|
|
[Hie_CTR] = {ActSeeDeg,&Txt_Select_or_create_one_degree_in_X },
|
|
|
|
|
[Hie_DEG] = {ActSeeCrs,&Txt_Select_or_create_one_course_in_X },
|
2023-11-06 16:54:49 +01:00
|
|
|
|
};
|
2021-12-30 11:50:29 +01:00
|
|
|
|
char *Description;
|
2015-10-16 02:24:29 +02:00
|
|
|
|
|
|
|
|
|
/***** Alert message *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Logged &&
|
2023-10-03 14:32:22 +02:00
|
|
|
|
!Gbl.Usrs.Me.Hierarchy[Hie_CRS].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,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Txt_If_you_can_not_find_your_institution_your_center_your_degree_or_your_courses_you_can_create_them);
|
2015-10-16 02:24:29 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box and table *****/
|
2024-01-24 13:36:17 +01:00
|
|
|
|
HTM_DIV_Begin (NULL);
|
2024-01-29 08:47:21 +01:00
|
|
|
|
Box_BoxTableBegin (Txt_What_would_you_like_to_do,NULL,NULL,
|
2024-01-24 13:36:17 +01:00
|
|
|
|
NULL,Box_CLOSABLE,2);
|
2015-10-16 02:24:29 +02:00
|
|
|
|
|
2024-01-24 13:36:17 +01:00
|
|
|
|
if (Gbl.Usrs.Me.Logged) // I am logged
|
2016-03-24 20:13:42 +01:00
|
|
|
|
{
|
2024-01-24 13:36:17 +01:00
|
|
|
|
if (Gbl.Hierarchy.Level == Hie_CRS) // Course selected
|
2021-07-08 15:00:17 +02:00
|
|
|
|
{
|
2024-04-19 12:00:30 +02:00
|
|
|
|
switch (Gbl.Usrs.Me.IBelongToCurrent[Hie_CRS])
|
|
|
|
|
{
|
|
|
|
|
case Usr_BELONG: // I belong to this course
|
|
|
|
|
if (Gbl.Action.Act != ActLogIn &&
|
|
|
|
|
Gbl.Action.Act != ActLogInNew &&
|
|
|
|
|
Gbl.Action.Act != ActLogInLan) // I am not just logged
|
|
|
|
|
if (ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs] != ActUnk)
|
|
|
|
|
{
|
|
|
|
|
/***** Request my removing from this course *****/
|
|
|
|
|
if (asprintf (&Description,Txt_Remove_me_from_THE_COURSE_X,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].ShrtName) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Description,
|
|
|
|
|
ActionsRemoveMe[Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs],
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_me);
|
|
|
|
|
free (Description);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case Usr_DONT_BELONG: // I do not belong to this course
|
|
|
|
|
default:
|
|
|
|
|
/***** Request my registration in this course *****/
|
|
|
|
|
if (asprintf (&Description,Txt_Register_me_in_X,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].ShrtName) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Description,
|
|
|
|
|
ActReqSignUp,
|
|
|
|
|
Btn_CREATE_BUTTON,Txt_Sign_up);
|
|
|
|
|
free (Description);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2024-01-24 13:36:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Gbl.Usrs.Me.Hierarchy[Hie_CRS].Num) // I am enroled in some courses
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Hierarchy.Level == Hie_CRS && // Course selected
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs == Rol_TCH) // I am a teacher in current course
|
|
|
|
|
if (!Enr_GetCachedNumUsrsInCrss (Hie_CRS,Gbl.Hierarchy.Node[Hie_CRS].HieCod,
|
|
|
|
|
1 << Rol_STD)) // Current course probably has no students
|
2021-07-08 15:00:17 +02:00
|
|
|
|
{
|
2024-01-24 13:36:17 +01:00
|
|
|
|
/***** Request students enrolment *****/
|
|
|
|
|
if (asprintf (&Description,Txt_Register_students_in_COURSE_X,
|
|
|
|
|
Gbl.Hierarchy.Node[Hie_CRS].ShrtName) < 0)
|
2021-12-30 11:50:29 +01:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Description,
|
2024-01-24 13:36:17 +01:00
|
|
|
|
ActReqEnrSevStd,
|
|
|
|
|
Btn_CREATE_BUTTON,Txt_Register_students);
|
2021-12-30 11:50:29 +01:00
|
|
|
|
free (Description);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
}
|
2024-01-24 13:36:17 +01:00
|
|
|
|
|
|
|
|
|
if (Gbl.Action.Act != ActMyCrs) // I am not seeing the action to list my courses
|
|
|
|
|
/***** Request list my courses *****/
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Go_to_one_of_my_courses,
|
|
|
|
|
ActMyCrs,
|
|
|
|
|
Btn_CONFIRM_BUTTON,Txt_My_courses);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
}
|
2024-01-24 13:36:17 +01:00
|
|
|
|
|
|
|
|
|
/***** Go to list of hierarchy subnodes
|
|
|
|
|
to select or create a new one *****/
|
|
|
|
|
if (Gbl.Hierarchy.Level >= Hie_SYS &&
|
|
|
|
|
Gbl.Hierarchy.Level <= Hie_DEG)
|
2021-07-08 15:00:17 +02:00
|
|
|
|
{
|
2024-01-24 13:36:17 +01:00
|
|
|
|
if (asprintf (&Description,*(SelectOrCreate[Gbl.Hierarchy.Level].Description),
|
|
|
|
|
Gbl.Hierarchy.Node[Gbl.Hierarchy.Level].ShrtName) < 0)
|
2021-12-30 11:50:29 +01:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Description,
|
2024-01-24 13:36:17 +01:00
|
|
|
|
SelectOrCreate[Gbl.Hierarchy.Level].Action,
|
|
|
|
|
Btn_CONFIRM_BUTTON,
|
|
|
|
|
Txt_HIERARCHY_PLURAL_Abc[Gbl.Hierarchy.Level + 1]);
|
2021-12-30 11:50:29 +01:00
|
|
|
|
free (Description);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-24 13:36:17 +01:00
|
|
|
|
if (!Gbl.Usrs.Me.MyPhotoExists) // I have no photo
|
|
|
|
|
/***** Upload my photo *****/
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Upload_my_picture,
|
|
|
|
|
ActReqMyPho,
|
|
|
|
|
Btn_CREATE_BUTTON,Txt_Upload_photo);
|
2016-03-24 20:13:42 +01:00
|
|
|
|
}
|
2024-01-24 13:36:17 +01:00
|
|
|
|
else // I am not logged
|
2023-12-06 20:59:19 +01:00
|
|
|
|
{
|
2024-01-24 13:36:17 +01:00
|
|
|
|
/***** Log in *****/
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Txt_Log_in,
|
|
|
|
|
ActFrmLogIn,
|
|
|
|
|
Btn_CONFIRM_BUTTON,Txt_Log_in);
|
|
|
|
|
|
|
|
|
|
/***** Sign up *****/
|
|
|
|
|
if (asprintf (&Description,Txt_New_on_PLATFORM_Sign_up,
|
|
|
|
|
Cfg_PLATFORM_SHORT_NAME) < 0)
|
2023-12-06 20:59:19 +01:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
Hlp_ShowRowHelpWhatWouldYouLikeToDo (Description,
|
2024-01-24 13:36:17 +01:00
|
|
|
|
ActFrmMyAcc,
|
|
|
|
|
Btn_CREATE_BUTTON,Txt_Actions[ActCreUsrAcc]);
|
2023-12-06 20:59:19 +01:00
|
|
|
|
free (Description);
|
|
|
|
|
}
|
2015-10-16 02:24:29 +02:00
|
|
|
|
|
2024-01-24 13:36:17 +01:00
|
|
|
|
/***** End table and box *****/
|
|
|
|
|
Box_BoxTableEnd ();
|
|
|
|
|
HTM_DIV_End ();
|
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
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Description *****/
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TxtColon (Description);
|
|
|
|
|
HTM_TD_End ();
|
2015-10-16 02:24:29 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Button *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LM\"");
|
|
|
|
|
Frm_BeginForm (Action);
|
|
|
|
|
Btn_PutButtonInline (Button,TxtButton);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
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
|
|
|
|
}
|