Version 23.42: Oct 29, 2023 Code refactoring in view/edit/print.

This commit is contained in:
acanas 2023-10-29 22:20:07 +01:00
parent c9f70dcafb
commit 7fcf9f48ed
17 changed files with 288 additions and 193 deletions

View File

@ -3952,7 +3952,7 @@ int swad__getTrivialQuestion (struct soap *soap,
{ {
/***** Get answer from database *****/ /***** Get answer from database *****/
NumAnss = Qst_DB_GetAnswersData (&mysql_res,QstCod, NumAnss = Qst_DB_GetAnswersData (&mysql_res,QstCod,
false); // Don't shuffle false); // Don't shuffle
getTrivialQuestionOut->answersArray.__size = (int) NumAnss; getTrivialQuestionOut->answersArray.__size = (int) NumAnss;

View File

@ -41,6 +41,22 @@
#include "swad_parameter_code.h" #include "swad_parameter_code.h"
#include "swad_role.h" #include "swad_role.h"
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
typedef enum
{
Ann_DONT_SHOW_ALL = 0,
Ann_SHOW_ALL = 1,
} Ann_ShowAll_t;
typedef enum
{
Ann_I_CAN_NOT_EDIT = 0,
Ann_I_CAN_EDIT = 1,
} Ann_ICanEdit_t;
/*****************************************************************************/ /*****************************************************************************/
/************** External global variables from others modules ****************/ /************** External global variables from others modules ****************/
/*****************************************************************************/ /*****************************************************************************/
@ -57,8 +73,8 @@ static void Ann_GetAnnouncementDataFromRow (MYSQL_RES *mysql_res,
struct Ann_Announcement *Announcement); struct Ann_Announcement *Announcement);
static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement, static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
bool ShowAllAnnouncements, Ann_ShowAll_t ShowAll,
bool ICanEdit); Ann_ICanEdit_t ICanEdit);
static void Ann_PutParAnnCod (void *AnnCod); static void Ann_PutParAnnCod (void *AnnCod);
static void Ann_PutSubjectMessage (const char *Field,const char *Label, static void Ann_PutSubjectMessage (const char *Field,const char *Label,
unsigned Rows); unsigned Rows);
@ -76,7 +92,8 @@ void Ann_ShowAllAnnouncements (void)
struct Ann_Announcement Announcement; struct Ann_Announcement Announcement;
unsigned NumAnnouncements; unsigned NumAnnouncements;
unsigned NumAnn; unsigned NumAnn;
bool ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); Ann_ICanEdit_t ICanEdit = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM) ? Ann_I_CAN_EDIT :
Ann_I_CAN_NOT_EDIT;
/***** Get announcements from database *****/ /***** Get announcements from database *****/
if (ICanEdit) if (ICanEdit)
@ -108,7 +125,7 @@ void Ann_ShowAllAnnouncements (void)
/* Show the announcement */ /* Show the announcement */
Ann_DrawAnAnnouncement (&Announcement, Ann_DrawAnAnnouncement (&Announcement,
true, // Show all announcements Ann_SHOW_ALL, // Show all announcements
ICanEdit); ICanEdit);
} }
@ -157,8 +174,8 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
/* Show the announcement */ /* Show the announcement */
Ann_DrawAnAnnouncement (&Announcement, Ann_DrawAnAnnouncement (&Announcement,
false, // Don't show all announcements Ann_DONT_SHOW_ALL, // Don't show all announcements
false); // I can not edit Ann_I_CAN_NOT_EDIT); // I can not edit
} }
HTM_DIV_End (); HTM_DIV_End ();
@ -206,8 +223,8 @@ static void Ann_GetAnnouncementDataFromRow (MYSQL_RES *mysql_res,
/*****************************************************************************/ /*****************************************************************************/
static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement, static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
bool ShowAllAnnouncements, Ann_ShowAll_t ShowAll,
bool ICanEdit) Ann_ICanEdit_t ICanEdit)
{ {
extern const char *Txt_Users; extern const char *Txt_Users;
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
@ -228,7 +245,7 @@ static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
/***** Begin yellow note *****/ /***** Begin yellow note *****/
HTM_DIV_Begin ("class=\"%s\"",ContainerClass[Announcement->Status]); HTM_DIV_Begin ("class=\"%s\"",ContainerClass[Announcement->Status]);
if (ICanEdit) if (ICanEdit == Ann_I_CAN_EDIT)
{ {
/***** Icon to remove announcement *****/ /***** Icon to remove announcement *****/
Ico_PutContextualIconToRemove (ActRemAnn,NULL, Ico_PutContextualIconToRemove (ActRemAnn,NULL,
@ -257,27 +274,30 @@ static void Ann_DrawAnAnnouncement (struct Ann_Announcement *Announcement,
/* Begin container for foot */ /* Begin container for foot */
HTM_DIV_Begin ("class=\"NOTICE_USERS\""); HTM_DIV_Begin ("class=\"NOTICE_USERS\"");
if (ShowAllAnnouncements) switch (ShowAll)
{ {
/* Users' roles who can view this announcement */ case Ann_DONT_SHOW_ALL:
HTM_TxtColon (Txt_Users); /***** Put form to mark announcement as seen *****/
for (Role = Rol_UNK, SomeRolesAreSelected = false; Lay_PutContextualLinkIconText (ActAnnSee,NULL,
Role <= Rol_TCH; Ann_PutParAnnCod,&Announcement->AnnCod,
Role++) "times.svg",Ico_BLACK,
if (Announcement->Roles & (1 << Role)) Txt_Do_not_show_again,NULL);
{ break;
if (SomeRolesAreSelected) case Ann_SHOW_ALL:
HTM_Comma (); /* Users' roles who can view this announcement */
SomeRolesAreSelected = true; HTM_TxtColon (Txt_Users);
HTM_TxtF ("&nbsp;%s",Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN]); for (Role = Rol_UNK, SomeRolesAreSelected = false;
} Role <= Rol_TCH;
Role++)
if (Announcement->Roles & (1 << Role))
{
if (SomeRolesAreSelected)
HTM_Comma ();
SomeRolesAreSelected = true;
HTM_TxtF ("&nbsp;%s",Txt_ROLES_PLURAL_abc[Role][Usr_SEX_UNKNOWN]);
}
break;
} }
else
/***** Put form to mark announcement as seen *****/
Lay_PutContextualLinkIconText (ActAnnSee,NULL,
Ann_PutParAnnCod,&Announcement->AnnCod,
"times.svg",Ico_BLACK,
Txt_Do_not_show_again,NULL);
/* End container for foot */ /* End container for foot */
HTM_DIV_End (); HTM_DIV_End ();
@ -335,7 +355,8 @@ void Ann_ShowFormAnnouncement (void)
1 << Rol_STD | 1 << Rol_STD |
1 << Rol_NET | 1 << Rol_NET |
1 << Rol_TCH, 1 << Rol_TCH,
false,false); false,
HTM_DONT_SUBMIT_ON_CHANGE);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();

View File

@ -1432,7 +1432,7 @@ static void Att_ShowEvent (struct Att_Events *Events)
Att_PutIconsOneEvent,Events, Att_PutIconsOneEvent,Events,
Hlp_USERS_Attendance,Box_NOT_CLOSABLE,2); Hlp_USERS_Attendance,Box_NOT_CLOSABLE,2);
Att_ShowOneEventRow (Events, Att_ShowOneEventRow (Events,
true); // Show only this event true); // Show only this event
Box_BoxTableEnd (); Box_BoxTableEnd ();
switch (Gbl.Usrs.Me.Role.Logged) switch (Gbl.Usrs.Me.Role.Logged)

View File

@ -4548,25 +4548,25 @@ static void Brw_PutIconFolder (unsigned Level,
{ {
/***** Visible icon with folder closed *****/ /***** Visible icon with folder closed *****/
Brw_PutIconFolderWithPlus (FileBrowserId,RowId, Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
false, // Closed false, // Closed
false); // Visible HidVis_VISIBLE); // Visible
/***** Hidden icon with folder open *****/ /***** Hidden icon with folder open *****/
Brw_PutIconFolderWithPlus (FileBrowserId,RowId, Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
true, // Open true, // Open
true); // Hidden HidVis_HIDDEN); // Hidden
} }
else else
{ {
/***** Hidden icon with folder closed *****/ /***** Hidden icon with folder closed *****/
Brw_PutIconFolderWithPlus (FileBrowserId,RowId, Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
false, // Closed false, // Closed
true); // Hidden HidVis_HIDDEN); // Hidden
/***** Visible icon with folder open *****/ /***** Visible icon with folder open *****/
Brw_PutIconFolderWithPlus (FileBrowserId,RowId, Brw_PutIconFolderWithPlus (FileBrowserId,RowId,
true, // Open true, // Open
false); // Visible HidVis_VISIBLE); // Visible
} }
} }
else // I can't create a new file or folder else // I can't create a new file or folder

View File

@ -154,7 +154,7 @@ void Cfe_PutFrmEditACallForExam (void)
/***** Show call for exam *****/ /***** Show call for exam *****/
Cfe_ShowCallForExam (&CallsForExams,ExaCod,Cfe_FORM_VIEW, Cfe_ShowCallForExam (&CallsForExams,ExaCod,Cfe_FORM_VIEW,
false); // Don't highlight false); // Don't highlight
/***** Free memory of the call for exam *****/ /***** Free memory of the call for exam *****/
Cfe_FreeMemCallForExam (&CallsForExams); Cfe_FreeMemCallForExam (&CallsForExams);

View File

@ -633,10 +633,11 @@ Me sale este error, no s
"can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod') "can npt create received message (duplicated entry '243218-2160773' for key 'UsrCod_MsgCod')
*/ */
#define Log_PLATFORM_VERSION "SWAD 23.41.2 (2023-10-29)" #define Log_PLATFORM_VERSION "SWAD 23.42 (2023-10-29)"
#define CSS_FILE "swad23.35.1.css" #define CSS_FILE "swad23.35.1.css"
#define JS_FILE "swad22.49.js" #define JS_FILE "swad22.49.js"
/* /*
Version 23.42: Oct 29, 2023 Code refactoring in view/edit/print. (335453 lines)
Version 23.41.2: Oct 29, 2023 Code refactoring in class photo. (335361 lines) Version 23.41.2: Oct 29, 2023 Code refactoring in class photo. (335361 lines)
Version 23.41.1: Oct 29, 2023 Code refactoring in view/edit/print. (335361 lines) Version 23.41.1: Oct 29, 2023 Code refactoring in view/edit/print. (335361 lines)
Version 23.41: Oct 29, 2023 Code refactoring in view/edit/print. (335359 lines) Version 23.41: Oct 29, 2023 Code refactoring in view/edit/print. (335359 lines)

View File

@ -2170,7 +2170,8 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
1 << Rol_NET | 1 << Rol_NET |
1 << Rol_TCH, 1 << Rol_TCH,
RolesSelected, RolesSelected,
false,true); false,
HTM_SUBMIT_ON_CHANGE);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();

View File

@ -29,7 +29,7 @@
#include "swad_action.h" #include "swad_action.h"
#include "swad_icon.h" #include "swad_icon.h"
#include "swad_view_edit.h" #include "swad_view.h"
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/

View File

@ -106,7 +106,8 @@ void Pwd_GetParUsrPwdLogin (void)
bool Pwd_CheckCurrentPassword (void) bool Pwd_CheckCurrentPassword (void)
{ {
return (Gbl.Usrs.Me.UsrDat.Password[0] ? return (Gbl.Usrs.Me.UsrDat.Password[0] ?
!strcmp (Gbl.Usrs.Me.LoginEncryptedPassword,Gbl.Usrs.Me.UsrDat.Password) : true); !strcmp (Gbl.Usrs.Me.LoginEncryptedPassword,Gbl.Usrs.Me.UsrDat.Password) :
true);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -974,7 +974,7 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateFirstClickTimeUsr (UsrCod,UsrFigures.FirstClickTimeUTC); Prf_DB_UpdateFirstClickTimeUsr (UsrCod,UsrFigures.FirstClickTimeUTC);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }
@ -998,7 +998,7 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateNumClicksUsr (UsrCod,UsrFigures.NumClicks); Prf_DB_UpdateNumClicksUsr (UsrCod,UsrFigures.NumClicks);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }
@ -1022,7 +1022,7 @@ static void Prf_GetNumTimelinePubsAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateNumTimelinePubsUsr (UsrCod,UsrFigures.NumTimelinePubs); Prf_DB_UpdateNumTimelinePubsUsr (UsrCod,UsrFigures.NumTimelinePubs);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }
@ -1046,7 +1046,7 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateNumFileViewsUsr (UsrCod,UsrFigures.NumFileViews); Prf_DB_UpdateNumFileViewsUsr (UsrCod,UsrFigures.NumFileViews);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }
@ -1070,7 +1070,7 @@ static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateNumForumPostsUsr (UsrCod,UsrFigures.NumForumPosts); Prf_DB_UpdateNumForumPostsUsr (UsrCod,UsrFigures.NumForumPosts);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }
@ -1094,7 +1094,7 @@ static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod)
if (Prf_DB_CheckIfUsrFiguresExists (UsrCod)) if (Prf_DB_CheckIfUsrFiguresExists (UsrCod))
Prf_DB_UpdateNumMessagesSentUsr (UsrCod,UsrFigures.NumMessagesSent); Prf_DB_UpdateNumMessagesSentUsr (UsrCod,UsrFigures.NumMessagesSent);
else // User entry does not exist else // User entry does not exist
Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,false); Prf_DB_CreateUsrFigures (UsrCod,&UsrFigures,Usr_OTHER);
} }
} }

View File

@ -43,7 +43,7 @@
#include "swad_program.h" #include "swad_program.h"
#include "swad_program_database.h" #include "swad_program_database.h"
#include "swad_resource_database.h" #include "swad_resource_database.h"
#include "swad_view_edit.h" #include "swad_view.h"
/*****************************************************************************/ /*****************************************************************************/
/************** External global variables from others modules ****************/ /************** External global variables from others modules ****************/

View File

@ -574,7 +574,8 @@ void Qst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
Str_Copy (StemRigorousHTML,Stem,StemLength); Str_Copy (StemRigorousHTML,Stem,StemLength);
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
StemRigorousHTML,StemLength,false); StemRigorousHTML,StemLength,
Str_DONT_REMOVE_SPACES);
/* Write stem text */ /* Write stem text */
HTM_Txt (StemRigorousHTML); HTM_Txt (StemRigorousHTML);
@ -2496,7 +2497,7 @@ bool Qst_GetQstDataByCod (struct Qst_Question *Question)
/***** Get the answers from the database *****/ /***** Get the answers from the database *****/
Question->Answer.NumOptions = Qst_DB_GetAnswersData (&mysql_res,Question->QstCod, Question->Answer.NumOptions = Qst_DB_GetAnswersData (&mysql_res,Question->QstCod,
false); // Don't shuffle false); // Don't shuffle
/* /*
row[0] AnsInd row[0] AnsInd
row[1] Answer row[1] Answer

View File

@ -147,14 +147,16 @@ static void Rec_ShowEmail (struct Usr_Data *UsrDat);
static void Rec_ShowUsrIDs (struct Usr_Data *UsrDat,const char *Anchor); static void Rec_ShowUsrIDs (struct Usr_Data *UsrDat,const char *Anchor);
static void Rec_ShowRole (struct Usr_Data *UsrDat, static void Rec_ShowRole (struct Usr_Data *UsrDat,
Rec_SharedRecordViewType_t TypeOfView); Rec_SharedRecordViewType_t TypeOfView);
static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,bool PutForm); static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType);
static void Rec_ShowSurname2 (struct Usr_Data *UsrDat,bool PutForm); static void Rec_ShowSurname2 (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType);
static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm); static void Rec_ShowFirstName (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType);
static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm); static void Rec_ShowCountry (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType);
static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutForm); static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,
static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,bool PutForm, Vie_ViewType_t ViewType);
unsigned NumPhone); static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,
static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,bool PutForm); Vie_ViewType_t ViewType,unsigned NumPhone);
static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,
Vie_ViewType_t ViewType);
static void Rec_ShowTeacherRows (struct Usr_Data *UsrDat,struct Hie_Node *Ins, static void Rec_ShowTeacherRows (struct Usr_Data *UsrDat,struct Hie_Node *Ins,
bool ShowData); bool ShowData);
static void Rec_ShowInstitution (struct Hie_Node *Ins,bool ShowData); static void Rec_ShowInstitution (struct Hie_Node *Ins,bool ShowData);
@ -2028,7 +2030,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
Usr_MeOrOther_t MeOrOther; Usr_MeOrOther_t MeOrOther;
bool IAmLoggedAsTeacherOrSysAdm; bool IAmLoggedAsTeacherOrSysAdm;
bool CountryForm; bool CountryForm;
bool ICanEdit; Vie_ViewType_t ViewType;
bool PutFormLinks; // Put links (forms) inside record card bool PutFormLinks; // Put links (forms) inside record card
bool ShowData; bool ShowData;
bool ShowIDRows; bool ShowIDRows;
@ -2069,13 +2071,14 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
{ {
case Rec_SHA_MY_RECORD_FORM: case Rec_SHA_MY_RECORD_FORM:
case Rec_SHA_OTHER_NEW_USR_FORM: case Rec_SHA_OTHER_NEW_USR_FORM:
ICanEdit = true; ViewType = Vie_EDIT;
break; break;
case Rec_SHA_OTHER_EXISTING_USR_FORM: case Rec_SHA_OTHER_EXISTING_USR_FORM:
ICanEdit = Usr_ICanChangeOtherUsrData (UsrDat); ViewType = Usr_ICanChangeOtherUsrData (UsrDat) ? Vie_EDIT :
Vie_VIEW;
break; break;
default: // In other options, I can not edit user's data default: // In other options, I can not edit user's data
ICanEdit = false; ViewType = Vie_VIEW;
break; break;
} }
@ -2200,27 +2203,27 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
Rec_ShowRole (UsrDat,TypeOfView); Rec_ShowRole (UsrDat,TypeOfView);
/***** Name *****/ /***** Name *****/
Rec_ShowSurname1 (UsrDat,ICanEdit); Rec_ShowSurname1 (UsrDat,ViewType);
Rec_ShowSurname2 (UsrDat,ICanEdit); Rec_ShowSurname2 (UsrDat,ViewType);
Rec_ShowFirstName (UsrDat,ICanEdit); Rec_ShowFirstName (UsrDat,ViewType);
/***** Country *****/ /***** Country *****/
if (CountryForm) if (CountryForm)
Rec_ShowCountry (UsrDat,ICanEdit); Rec_ShowCountry (UsrDat,ViewType);
} }
/***** Address rows *****/ /***** Address rows *****/
if (ShowAddressRows) if (ShowAddressRows)
{ {
/***** Date of birth *****/ /***** Date of birth *****/
Rec_ShowDateOfBirth (UsrDat,ShowData,ICanEdit); Rec_ShowDateOfBirth (UsrDat,ShowData,ViewType);
/***** Phones *****/ /***** Phones *****/
Rec_ShowPhone (UsrDat,ShowData,ICanEdit,0); Rec_ShowPhone (UsrDat,ShowData,ViewType,0);
Rec_ShowPhone (UsrDat,ShowData,ICanEdit,1); Rec_ShowPhone (UsrDat,ShowData,ViewType,1);
/***** User's comments *****/ /***** User's comments *****/
Rec_ShowComments (UsrDat,ShowData,ICanEdit); Rec_ShowComments (UsrDat,ShowData,ViewType);
} }
/***** Teacher's rows *****/ /***** Teacher's rows *****/
@ -3028,7 +3031,7 @@ static void Rec_ShowRole (struct Usr_Data *UsrDat,
/*************************** Show user's surname 1 ***************************/ /*************************** Show user's surname 1 ***************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType)
{ {
extern const char *Txt_Surname_1; extern const char *Txt_Surname_1;
char *Label; char *Label;
@ -3036,31 +3039,46 @@ static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,bool PutForm)
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
if (PutForm) switch (ViewType)
{ {
if (asprintf (&Label,"%s*",Txt_Surname_1) < 0) case Vie_VIEW:
Err_NotEnoughMemoryExit (); Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_Surname_1);
Frm_LabelColumn ("REC_C1_BOT RM","Surname1",Label); break;
free (Label); case Vie_EDIT:
} if (asprintf (&Label,"%s*",Txt_Surname_1) < 0)
else Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_Surname_1); Frm_LabelColumn ("REC_C1_BOT RM","Surname1",Label);
free (Label);
break;
default:
Err_WrongTypeExit ();
break;
}
/* Data */ /* Data */
HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"", HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"",
The_GetSuffix ()); The_GetSuffix ());
if (PutForm) switch (ViewType)
HTM_INPUT_TEXT ("Surname1",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,UsrDat->Surname1,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Surname1\" class=\"REC_C2_BOT_INPUT INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());
else if (UsrDat->Surname1[0])
{ {
HTM_STRONG_Begin (); case Vie_VIEW:
HTM_Txt (UsrDat->Surname1); if (UsrDat->Surname1[0])
HTM_STRONG_End (); {
} HTM_STRONG_Begin ();
HTM_Txt (UsrDat->Surname1);
HTM_STRONG_End ();
}
break;
case Vie_EDIT:
HTM_INPUT_TEXT ("Surname1",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,UsrDat->Surname1,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Surname1\" class=\"REC_C2_BOT_INPUT INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());
break;
default:
Err_WrongTypeExit ();
break;
}
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
@ -3070,33 +3088,42 @@ static void Rec_ShowSurname1 (struct Usr_Data *UsrDat,bool PutForm)
/*************************** Show user's surname 2 ***************************/ /*************************** Show user's surname 2 ***************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowSurname2 (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowSurname2 (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType)
{ {
extern const char *Txt_Surname_2; extern const char *Txt_Surname_2;
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? "Surname2" : Frm_LabelColumn ("REC_C1_BOT RM",ViewType == Vie_EDIT ? "Surname2" :
NULL, NULL,
Txt_Surname_2); Txt_Surname_2);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"", HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"",
The_GetSuffix ()); The_GetSuffix ());
if (PutForm) switch (ViewType)
HTM_INPUT_TEXT ("Surname2",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
UsrDat->Surname2,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Surname2\""
" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
The_GetSuffix ());
else if (UsrDat->Surname2[0])
{ {
HTM_STRONG_Begin (); case Vie_VIEW:
HTM_Txt (UsrDat->Surname2); if (UsrDat->Surname2[0])
HTM_STRONG_End (); {
} HTM_STRONG_Begin ();
HTM_Txt (UsrDat->Surname2);
HTM_STRONG_End ();
}
break;
case Vie_EDIT:
HTM_INPUT_TEXT ("Surname2",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
UsrDat->Surname2,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"Surname2\""
" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
The_GetSuffix ());
break;
default:
Err_WrongTypeExit ();
break;
}
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
@ -3106,7 +3133,7 @@ static void Rec_ShowSurname2 (struct Usr_Data *UsrDat,bool PutForm)
/************************** Show user's first name ***************************/ /************************** Show user's first name ***************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowFirstName (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType)
{ {
extern const char *Txt_First_name; extern const char *Txt_First_name;
char *Label; char *Label;
@ -3114,32 +3141,47 @@ static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm)
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
if (PutForm) switch (ViewType)
{ {
if (asprintf (&Label,"%s*",Txt_First_name) < 0) case Vie_VIEW:
Err_NotEnoughMemoryExit (); Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_First_name);
Frm_LabelColumn ("REC_C1_BOT RM","FirstName",Label); break;
free (Label); case Vie_EDIT:
if (asprintf (&Label,"%s*",Txt_First_name) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM","FirstName",Label);
free (Label);
break;
default:
Err_WrongTypeExit ();
break;
} }
else
Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_First_name);
/* Data */ /* Data */
HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT LM DAT_STRONG_%s\"", HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT LM DAT_STRONG_%s\"",
The_GetSuffix ()); The_GetSuffix ());
if (PutForm) switch (ViewType)
HTM_INPUT_TEXT ("FirstName",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
UsrDat->FrstName,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"FirstName\""
" class=\"REC_C2_BOT_INPUT INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());
else if (UsrDat->FrstName[0])
{ {
HTM_STRONG_Begin (); case Vie_VIEW:
HTM_Txt (UsrDat->FrstName); if (UsrDat->FrstName[0])
HTM_STRONG_End (); {
HTM_STRONG_Begin ();
HTM_Txt (UsrDat->FrstName);
HTM_STRONG_End ();
}
break;
case Vie_EDIT:
HTM_INPUT_TEXT ("FirstName",Usr_MAX_CHARS_FIRSTNAME_OR_SURNAME,
UsrDat->FrstName,
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"FirstName\""
" class=\"REC_C2_BOT_INPUT INPUT_%s\""
" required=\"required\"",
The_GetSuffix ());
break;
default:
Err_WrongTypeExit ();
break;
} }
HTM_TD_End (); HTM_TD_End ();
@ -3150,7 +3192,7 @@ static void Rec_ShowFirstName (struct Usr_Data *UsrDat,bool PutForm)
/**************************** Show user's country ****************************/ /**************************** Show user's country ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm) static void Rec_ShowCountry (struct Usr_Data *UsrDat,Vie_ViewType_t ViewType)
{ {
extern const char *Par_CodeStr[]; extern const char *Par_CodeStr[];
extern const char *Txt_Country; extern const char *Txt_Country;
@ -3166,15 +3208,21 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm)
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
if (PutForm) switch (ViewType)
{ {
if (asprintf (&Label,"%s*",Txt_Country) < 0) case Vie_VIEW:
Err_NotEnoughMemoryExit (); Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_Country);
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[ParCod_OthCty],Label); break;
free (Label); case Vie_EDIT:
if (asprintf (&Label,"%s*",Txt_Country) < 0)
Err_NotEnoughMemoryExit ();
Frm_LabelColumn ("REC_C1_BOT RM",Par_CodeStr[ParCod_OthCty],Label);
free (Label);
break;
default:
Err_WrongTypeExit ();
break;
} }
else
Frm_LabelColumn ("REC_C1_BOT RM",NULL,Txt_Country);
/* Data */ /* Data */
HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT LM\""); HTM_TD_Begin ("colspan=\"2\" class=\"REC_C2_BOT LM\"");
@ -3215,7 +3263,8 @@ static void Rec_ShowCountry (struct Usr_Data *UsrDat,bool PutForm)
/************************ Show user's date of birth **************************/ /************************ Show user's date of birth **************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutForm) static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,
Vie_ViewType_t ViewType)
{ {
extern const char *Txt_Date_of_birth; extern const char *Txt_Date_of_birth;
unsigned CurrentYear = Dat_GetCurrentYear (); unsigned CurrentYear = Dat_GetCurrentYear ();
@ -3224,25 +3273,31 @@ static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutF
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? "" : Frm_LabelColumn ("REC_C1_BOT RM",ViewType == Vie_EDIT ? "" :
NULL, NULL,
Txt_Date_of_birth); Txt_Date_of_birth);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"", HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"",The_GetSuffix ());
The_GetSuffix ());
if (ShowData) if (ShowData)
{ switch (ViewType)
if (PutForm) {
Dat_WriteFormDate (CurrentYear - Rec_USR_MAX_AGE, case Vie_VIEW:
CurrentYear - Rec_USR_MIN_AGE, if (UsrDat->StrBirthday[0])
"Birth", HTM_Txt (UsrDat->StrBirthday);
&(UsrDat->Birthday), break;
HTM_DONT_SUBMIT_ON_CHANGE, case Vie_EDIT:
false); Dat_WriteFormDate (CurrentYear - Rec_USR_MAX_AGE,
else if (UsrDat->StrBirthday[0]) CurrentYear - Rec_USR_MIN_AGE,
HTM_Txt (UsrDat->StrBirthday); "Birth",
} &(UsrDat->Birthday),
HTM_DONT_SUBMIT_ON_CHANGE,
false);
break;
default:
Err_WrongTypeExit ();
break;
}
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
@ -3253,8 +3308,8 @@ static void Rec_ShowDateOfBirth (struct Usr_Data *UsrDat,bool ShowData,bool PutF
/*****************************************************************************/ /*****************************************************************************/
// NumPhone can be 0 or 1 // NumPhone can be 0 or 1
static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,bool PutForm, static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,
unsigned NumPhone) Vie_ViewType_t ViewType,unsigned NumPhone)
{ {
extern const char *Txt_Phone; extern const char *Txt_Phone;
char *Name; char *Name;
@ -3272,29 +3327,36 @@ static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,bool PutForm,
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("REC_C1_BOT RM",PutForm ? Name : Frm_LabelColumn ("REC_C1_BOT RM",ViewType == Vie_EDIT ? Name :
NULL, NULL,
Label); Label);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"", HTM_TD_Begin ("class=\"REC_C2_BOT LM DAT_STRONG_%s\"",
The_GetSuffix ()); The_GetSuffix ());
if (ShowData) if (ShowData)
{ switch (ViewType)
if (PutForm)
HTM_INPUT_TEL (Name,UsrDat->Phone[NumPhone],
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"%s\" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
Name,
The_GetSuffix ());
else if (UsrDat->Phone[NumPhone][0])
{ {
HTM_A_Begin ("href=\"tel:%s\" class=\"DAT_STRONG_%s\"", case Vie_VIEW:
UsrDat->Phone[NumPhone],The_GetSuffix ()); if (UsrDat->Phone[NumPhone][0])
HTM_Txt (UsrDat->Phone[NumPhone]); {
HTM_A_End (); HTM_A_Begin ("href=\"tel:%s\" class=\"DAT_STRONG_%s\"",
UsrDat->Phone[NumPhone],The_GetSuffix ());
HTM_Txt (UsrDat->Phone[NumPhone]);
HTM_A_End ();
}
break;
case Vie_EDIT:
HTM_INPUT_TEL (Name,UsrDat->Phone[NumPhone],
HTM_DONT_SUBMIT_ON_CHANGE,
"id=\"%s\" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
Name,
The_GetSuffix ());
break;
default:
Err_WrongTypeExit ();
break;
} }
}
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();
@ -3310,7 +3372,8 @@ static void Rec_ShowPhone (struct Usr_Data *UsrDat,bool ShowData,bool PutForm,
/************************** Show user's comments *****************************/ /************************** Show user's comments *****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,bool PutForm) static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,
Vie_ViewType_t ViewType)
{ {
extern const char *Txt_USER_comments; extern const char *Txt_USER_comments;
@ -3318,32 +3381,37 @@ static void Rec_ShowComments (struct Usr_Data *UsrDat,bool ShowData,bool PutForm
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Label */ /* Label */
Frm_LabelColumn ("REC_C1_BOT RT",PutForm ? "Comments" : Frm_LabelColumn ("REC_C1_BOT RT",ViewType == Vie_EDIT ? "Comments" :
NULL, NULL,
Txt_USER_comments); Txt_USER_comments);
/* Data */ /* Data */
HTM_TD_Begin ("class=\"REC_C2_BOT LT DAT_STRONG_%s\"", HTM_TD_Begin ("class=\"REC_C2_BOT LT DAT_STRONG_%s\"",
The_GetSuffix ()); The_GetSuffix ());
if (ShowData) if (ShowData)
{ switch (ViewType)
if (PutForm)
{ {
HTM_TEXTAREA_Begin ("id=\"Comments\" name=\"Comments\"" case Vie_VIEW:
" rows=\"4\"" if (UsrDat->Comments[0])
" class=\"REC_C2_BOT_INPUT INPUT_%s\"", {
The_GetSuffix ()); Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
HTM_Txt (UsrDat->Comments); UsrDat->Comments,Cns_MAX_BYTES_TEXT,
HTM_TEXTAREA_End (); Str_DONT_REMOVE_SPACES);
HTM_Txt (UsrDat->Comments);
}
break;
case Vie_EDIT:
HTM_TEXTAREA_Begin ("id=\"Comments\" name=\"Comments\""
" rows=\"4\""
" class=\"REC_C2_BOT_INPUT INPUT_%s\"",
The_GetSuffix ());
HTM_Txt (UsrDat->Comments);
HTM_TEXTAREA_End ();
break;
default:
Err_WrongTypeExit ();
break;
} }
else if (UsrDat->Comments[0])
{
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
UsrDat->Comments,Cns_MAX_BYTES_TEXT,
Str_DONT_REMOVE_SPACES);
HTM_Txt (UsrDat->Comments);
}
}
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();

View File

@ -608,7 +608,8 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
1 << Rol_NET | 1 << Rol_NET |
1 << Rol_TCH, 1 << Rol_TCH,
Surveys->Svy.Roles, Surveys->Svy.Roles,
true,false); true,
HTM_DONT_SUBMIT_ON_CHANGE);
HTM_DIV_End (); HTM_DIV_End ();
/* Groups whose users can answer this survey */ /* Groups whose users can answer this survey */
@ -1704,7 +1705,8 @@ void Svy_ReqCreatOrEditSvy (void)
1 << Rol_NET | 1 << Rol_NET |
1 << Rol_TCH, 1 << Rol_TCH,
Surveys.Svy.Roles, Surveys.Svy.Roles,
false,false); false,
HTM_DONT_SUBMIT_ON_CHANGE);
HTM_TD_End (); HTM_TD_End ();
HTM_TR_End (); HTM_TR_End ();

View File

@ -27,7 +27,7 @@
/********************************* Headers ***********************************/ /********************************* Headers ***********************************/
/*****************************************************************************/ /*****************************************************************************/
#include "swad_view_edit.h" #include "swad_view.h"
/*****************************************************************************/ /*****************************************************************************/
/************************ Public constants and types *************************/ /************************ Public constants and types *************************/

View File

@ -1426,7 +1426,7 @@ static void TstPrn_WriteChoAnsPrint (struct Usr_Data *UsrDat,
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Draw icon depending on user's answer */ /* Draw icon depending on user's answer */
if (UsrAnswers[Indexes[NumOpt]] == true) // This answer has been selected by the user if (UsrAnswers[Indexes[NumOpt]]) // This answer has been selected by the user
{ {
if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER]) if (ICanView[TstVis_VISIBLE_CORRECT_ANSWER])
{ {