From 0af579adbdcb172b373f2119c487d6aab0052c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 8 Oct 2019 00:50:28 +0200 Subject: [PATCH] Version19.31.22 --- swad_changelog.h | 3 +- swad_course.c | 239 +++++++++++++++++++++-------------------------- swad_table.c | 2 +- 3 files changed, 110 insertions(+), 134 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 02cbdd330..ab3b01d6c 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -487,7 +487,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.31.21 (2019-10-08)" +#define Log_PLATFORM_VERSION "SWAD 19.31.22 (2019-10-08)" #define CSS_FILE "swad19.29.css" #define JS_FILE "swad19.30.js" /* @@ -495,6 +495,7 @@ ps2pdf source.ps destination.pdf // TODO: Un TFG preasignado sin estudiante tiene que salir un triángulo amarillo // TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.) + Version 19.31.22: Oct 08, 2019 Code refactoring in HTML tables. (247099 lines) Version 19.31.21: Oct 08, 2019 Code refactoring in HTML tables. (247124 lines) Version 19.31.20: Oct 07, 2019 Code refactoring in HTML tables. (247192 lines) Version 19.31.19: Oct 07, 2019 Code refactoring in HTML tables. (247211 lines) diff --git a/swad_course.c b/swad_course.c index 8ad00f8be..b51637d8f 100644 --- a/swad_course.c +++ b/swad_course.c @@ -240,13 +240,13 @@ static void Crs_Configuration (bool PrintView) /***** Degree *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "", + Tbl_StartCellAttr ("class=\"RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"", The_ClassFormInBox[Gbl.Prefs.Theme], Txt_Degree); Tbl_EndCell (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (!PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM) @@ -285,13 +285,13 @@ static void Crs_Configuration (bool PrintView) /***** Course full name *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "", + Tbl_StartCellAttr ("class=\"RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"", The_ClassFormInBox[Gbl.Prefs.Theme], Txt_Course); Tbl_EndCell (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT_N LEFT_MIDDLE\""); if (!PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins and system admins can edit course full name @@ -317,15 +317,15 @@ static void Crs_Configuration (bool PrintView) /***** Course short name *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "", + Tbl_StartCellAttr ("class=\"RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"", The_ClassFormInBox[Gbl.Prefs.Theme], Txt_Short_name); Tbl_EndCell (); Tbl_EndRow (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT_N LEFT_MIDDLE\""); if (!PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM) // Only degree admins, centre admins, institution admins and system admins can edit course short name @@ -351,13 +351,13 @@ static void Crs_Configuration (bool PrintView) IsForm = (!PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_TCH); Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "", + Tbl_StartCellAttr ("class=\"RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"", The_ClassFormInBox[Gbl.Prefs.Theme], Txt_Year_OF_A_DEGREE); Tbl_EndRow (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (IsForm) { Frm_StartForm (ActChgCrsYeaCfg); @@ -387,13 +387,13 @@ static void Crs_Configuration (bool PrintView) /***** Institutional code of the course *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "", + Tbl_StartCellAttr ("class=\"RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"", The_ClassFormInBox[Gbl.Prefs.Theme], Txt_Institutional_code); Tbl_EndRow (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (IsForm) { Frm_StartForm (ActChgInsCrsCodCfg); @@ -415,15 +415,12 @@ static void Crs_Configuration (bool PrintView) /***** Internal code of the course *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "%s:", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_Internal_code); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,"%s:",Txt_Internal_code); Tbl_EndRow (); - fprintf (Gbl.F.Out,"" - "%ld", - Gbl.Hierarchy.Crs.CrsCod); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); + fprintf (Gbl.F.Out,"%ld",Gbl.Hierarchy.Crs.CrsCod); Tbl_EndRow (); Tbl_EndRow (); @@ -432,14 +429,12 @@ static void Crs_Configuration (bool PrintView) /***** Link to the course *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "%s:", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_Shortcut); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,"%s:",Txt_Shortcut); Tbl_EndRow (); - fprintf (Gbl.F.Out,"" - "" + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); + fprintf (Gbl.F.Out,"" "%s/%s?crs=%ld", Cfg_URL_SWAD_CGI, Lan_STR_LANG_ID[Gbl.Prefs.Language], @@ -456,13 +451,11 @@ static void Crs_Configuration (bool PrintView) /***** QR code with link to the course *****/ Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "%s:", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_QR_code); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,"%s:",Txt_QR_code); Tbl_EndRow (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); QR_LinkTo (250,"crs",Gbl.Hierarchy.Crs.CrsCod); Tbl_EndCell (); @@ -481,13 +474,11 @@ static void Crs_Configuration (bool PrintView) NumIndicatorsFromDB,&Indicators); Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "%s:", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_Indicators); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,"%s:",Txt_Indicators); Tbl_EndRow (); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"LEFT_MIDDLE\""); Frm_StartForm (ActReqStaCrs); snprintf (Gbl.Title,sizeof (Gbl.Title), "%u %s %u", @@ -534,15 +525,12 @@ static void Crs_ShowNumUsrsInCrs (Rol_Role_t Role) Tbl_StartRow (); - fprintf (Gbl.F.Out,"" - "%s:", - The_ClassFormInBox[Gbl.Prefs.Theme], - Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE\"",The_ClassFormInBox[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,"%s:",Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); Tbl_EndRow (); - fprintf (Gbl.F.Out,"" - "%u", - Gbl.Hierarchy.Crs.NumUsrs[Role]); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); + fprintf (Gbl.F.Out,"%u",Gbl.Hierarchy.Crs.NumUsrs[Role]); Tbl_EndRow (); Tbl_EndRow (); @@ -1303,32 +1291,29 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year) Tbl_StartRow (); /* Put green tip if course has users */ - fprintf (Gbl.F.Out,"" - "%s", - TxtClassNormal,BgColor, - Crs->NumUsrs[Rol_UNK] ? Txt_COURSE_With_users : - Txt_COURSE_Without_users, - Crs->NumUsrs[Rol_UNK] ? "✓" : - " "); + Tbl_StartCellAttr ("class=\"%s CENTER_MIDDLE %s\" title=\"%s\"", + TxtClassNormal,BgColor, + Crs->NumUsrs[Rol_UNK] ? Txt_COURSE_With_users : + Txt_COURSE_Without_users); + fprintf (Gbl.F.Out,"%s",Crs->NumUsrs[Rol_UNK] ? "✓" : + " "); Tbl_EndRow (); /* Institutional code of the course */ - fprintf (Gbl.F.Out,"" - "%s", - TxtClassNormal,BgColor, - Crs->InstitutionalCrsCod); + Tbl_StartCellAttr ("class=\"%s CENTER_MIDDLE %s\"", + TxtClassNormal,BgColor); + fprintf (Gbl.F.Out,"%s",Crs->InstitutionalCrsCod); Tbl_EndRow (); /* Course year */ - fprintf (Gbl.F.Out,"" - "%s", - TxtClassNormal,BgColor, - Txt_YEAR_OF_DEGREE[Crs->Year]); + Tbl_StartCellAttr ("class=\"%s CENTER_MIDDLE %s\">", + TxtClassNormal,BgColor); + fprintf (Gbl.F.Out,"%s",Txt_YEAR_OF_DEGREE[Crs->Year]); Tbl_EndRow (); /* Course full name */ - fprintf (Gbl.F.Out,"", - TxtClassStrong,BgColor); + Tbl_StartCellAttr ("class=\"%s LEFT_MIDDLE %s\">", + TxtClassStrong,BgColor); Frm_StartFormGoTo (ActSeeCrsInf); Crs_PutParamCrsCod (Crs->CrsCod); snprintf (Gbl.Title,sizeof (Gbl.Title), @@ -1341,24 +1326,22 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year) Tbl_EndCell (); /* Current number of teachers in this course */ - fprintf (Gbl.F.Out,"" - "%u", - TxtClassNormal,BgColor, - Crs->NumUsrs[Rol_TCH] + - Crs->NumUsrs[Rol_NET]); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE %s\"", + TxtClassNormal,BgColor); + fprintf (Gbl.F.Out,"%u",Crs->NumUsrs[Rol_TCH] + + Crs->NumUsrs[Rol_NET]); Tbl_EndRow (); /* Current number of students in this course */ - fprintf (Gbl.F.Out,"" - "%u", - TxtClassNormal,BgColor, - Crs->NumUsrs[Rol_STD]); + Tbl_StartCellAttr ("class=\"%s RIGHT_MIDDLE %s\"", + TxtClassNormal,BgColor); + fprintf (Gbl.F.Out,"%u",Crs->NumUsrs[Rol_STD]); Tbl_EndRow (); /* Course status */ StatusTxt = Crs_GetStatusTxtFromStatusBits (Crs->Status); - fprintf (Gbl.F.Out,"", - TxtClassNormal,BgColor); + Tbl_StartCellAttr ("class=\"%s LEFT_MIDDLE %s\"", + TxtClassNormal,BgColor); if (StatusTxt != Crs_STATUS_ACTIVE) // If active ==> do not show anything fprintf (Gbl.F.Out,"%s",Txt_COURSE_STATUS[StatusTxt]); Tbl_EndCell (); @@ -1501,9 +1484,10 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) { ICanEdit = Crs_CheckIfICanEdit (Crs); - /* Put icon to remove course */ Tbl_StartRow (); - fprintf (Gbl.F.Out,""); + + /* Put icon to remove course */ + Tbl_StartCellAttr ("class=\"BM\""); if (Crs->NumUsrs[Rol_UNK] || // Course has users ==> deletion forbidden !ICanEdit) Ico_PutIconRemovalNotAllowed (); @@ -1517,13 +1501,12 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) Tbl_EndCell (); /* Course code */ - fprintf (Gbl.F.Out,"" - "%ld", - Crs->CrsCod); + Tbl_StartCellAttr ("class=\"DAT CODE\""); + fprintf (Gbl.F.Out,"%ld",Crs->CrsCod); Tbl_EndRow (); /* Institutional code of the course */ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT CENTER_MIDDLE\""); if (ICanEdit) { Frm_StartForm (ActChgInsCrsCod); @@ -1542,7 +1525,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) Tbl_EndCell (); /* Course year */ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT CENTER_MIDDLE\""); if (ICanEdit) { Frm_StartForm (ActChgCrsYea); @@ -1567,7 +1550,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) Tbl_EndCell (); /* Course short name */ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (ICanEdit) { Frm_StartForm (ActRenCrsSho); @@ -1585,7 +1568,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) Tbl_EndCell (); /* Course full name */ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (ICanEdit) { Frm_StartForm (ActRenCrsFul); @@ -1603,28 +1586,26 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) Tbl_EndCell (); /* Current number of teachers in this course */ - fprintf (Gbl.F.Out,"" - "%u", - Crs->NumUsrs[Rol_TCH] + - Crs->NumUsrs[Rol_NET]); - Tbl_EndRow (); + Tbl_StartCellAttr ("class=\"DAT RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"%u",Crs->NumUsrs[Rol_TCH] + + Crs->NumUsrs[Rol_NET]); + Tbl_EndCell (); /* Current number of students in this course */ - fprintf (Gbl.F.Out,"" - "%u", - Crs->NumUsrs[Rol_STD]); - Tbl_EndRow (); + Tbl_StartCellAttr ("class=\"DAT RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"%u",Crs->NumUsrs[Rol_STD]); + Tbl_EndCell (); /* Course requester */ UsrDat.UsrCod = Crs->RequesterUsrCod; Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT INPUT_REQUESTER LEFT_TOP\""); Msg_WriteMsgAuthor (&UsrDat,true,NULL); Tbl_EndCell (); /* Course status */ StatusTxt = Crs_GetStatusTxtFromStatusBits (Crs->Status); - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM && StatusTxt == Crs_STATUS_PENDING) { @@ -1735,16 +1716,16 @@ static void Crs_PutFormToCreateCourse (void) Tbl_StartRow (); /***** Column to remove course, disabled here *****/ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"BM\""); Tbl_EndRow (); /***** Course code *****/ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"CODE\""); Tbl_EndRow (); /***** Institutional code of the course *****/ - fprintf (Gbl.F.Out,"" - "", Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD, @@ -1752,8 +1733,8 @@ static void Crs_PutFormToCreateCourse (void) Tbl_EndRow (); /***** Year *****/ - fprintf (Gbl.F.Out,"" - ""); for (Year = 0; Year <= Deg_MAX_YEARS_PER_DEGREE; Year++) @@ -1766,8 +1747,8 @@ static void Crs_PutFormToCreateCourse (void) Tbl_EndRow (); /***** Course short name *****/ - fprintf (Gbl.F.Out,"" - "", @@ -1775,8 +1756,8 @@ static void Crs_PutFormToCreateCourse (void) Tbl_EndRow (); /***** Course full name *****/ - fprintf (Gbl.F.Out,"" - "", @@ -1784,22 +1765,22 @@ static void Crs_PutFormToCreateCourse (void) Tbl_EndRow (); /***** Current number of teachers in this course *****/ - fprintf (Gbl.F.Out,"" - "0"); + Tbl_StartCellAttr ("class=\"DAT RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"0"); Tbl_EndRow (); /***** Current number of students in this course *****/ - fprintf (Gbl.F.Out,"" - "0"); + Tbl_StartCellAttr ("class=\"DAT RIGHT_MIDDLE\""); + fprintf (Gbl.F.Out,"0"); Tbl_EndRow (); /***** Course requester *****/ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT INPUT_REQUESTER LEFT_TOP\""); Msg_WriteMsgAuthor (&Gbl.Usrs.Me.UsrDat,true,NULL); Tbl_EndCell (); /***** Course status *****/ - fprintf (Gbl.F.Out,""); + Tbl_StartCellAttr ("class=\"DAT LEFT_MIDDLE\""); Tbl_EndRow (); Tbl_EndRow (); @@ -3315,26 +3296,24 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA if (WriteColumnAccepted) { Accepted = (row[7][0] == 'Y'); - fprintf (Gbl.F.Out,"" - "%s", - BgColor, - Accepted ? Txt_Enrolment_confirmed : - Txt_Enrolment_not_confirmed, + Tbl_StartCellAttr ("class=\"BT %s\" title=\"%s\"", + BgColor, + Accepted ? Txt_Enrolment_confirmed : + Txt_Enrolment_not_confirmed); + fprintf (Gbl.F.Out,"%s", Accepted ? "✓" : "✗"); Tbl_EndRow (); } /***** Write number of course in this search *****/ - fprintf (Gbl.F.Out,"" - "%u", - StyleNoBR,BgColor,NumCrs); + Tbl_StartCellAttr ("class=\"%s RIGHT_TOP %s\"",StyleNoBR,BgColor); + fprintf (Gbl.F.Out,"%u",NumCrs); Tbl_EndRow (); /***** Write degree logo, degree short name (row[2]) and centre short name (row[6]) *****/ - fprintf (Gbl.F.Out,"", - StyleNoBR,BgColor); + Tbl_StartCellAttr ("class=\"%s LEFT_TOP %s\"",StyleNoBR,BgColor); Frm_StartFormGoTo (ActSeeDegInf); Deg_PutParamDegCod (Deg.DegCod); snprintf (Gbl.Title,sizeof (Gbl.Title), @@ -3349,14 +3328,12 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA Tbl_EndCell (); /***** Write year (row[4]) *****/ - fprintf (Gbl.F.Out,"" - "%s", - Style,BgColor,Txt_YEAR_OF_DEGREE[Deg_ConvStrToYear (row[4])]); + Tbl_StartCellAttr ("class=\"%s CENTER_TOP %s\"",Style,BgColor); + fprintf (Gbl.F.Out,"%s",Txt_YEAR_OF_DEGREE[Deg_ConvStrToYear (row[4])]); Tbl_EndRow (); /***** Write course full name (row[5]) *****/ - fprintf (Gbl.F.Out,"", - Style,BgColor); + Tbl_StartCellAttr ("class=\"%s LEFT_TOP %s\"",Style,BgColor); Frm_StartFormGoTo (ActSeeCrsInf); Crs_PutParamCrsCod (CrsCod); snprintf (Gbl.Title,sizeof (Gbl.Title), @@ -3368,16 +3345,14 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA Tbl_EndCell (); /***** Write number of teachers in course *****/ - fprintf (Gbl.F.Out,"" - "%u", - Style,BgColor,NumTchs); - Tbl_EndRow (); + Tbl_StartCellAttr ("class=\"%s RIGHT_TOP %s\"",Style,BgColor); + fprintf (Gbl.F.Out,"%u",NumTchs); + Tbl_EndCell (); /***** Write number of students in course *****/ - fprintf (Gbl.F.Out,"" - "%u", - Style,BgColor,NumStds); - Tbl_EndRow (); + Tbl_StartCellAttr ("class=\"%s RIGHT_TOP %s\"",Style,BgColor); + fprintf (Gbl.F.Out,"%u",NumStds); + Tbl_EndCell (); Tbl_EndRow (); diff --git a/swad_table.c b/swad_table.c index f2a16d728..c228bb91f 100644 --- a/swad_table.c +++ b/swad_table.c @@ -234,7 +234,7 @@ void Tbl_StartCellAttr (const char *fmt,...) /***** Print HTML *****/ fprintf (Gbl.F.Out, - "",Attr); + "",Attr); free ((void *) Attr); }