From 5b4fad705c4c64c2073f81ca7f9e70dfb77e54f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 3 Mar 2020 17:36:24 +0100 Subject: [PATCH] Version19.141.3 --- swad_changelog.h | 3 ++- swad_program.c | 70 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 59 insertions(+), 14 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 7c24ad471..675fd8f1a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -497,7 +497,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.141.2 (2020-03-03)" +#define Log_PLATFORM_VERSION "SWAD 19.141.3 (2020-03-03)" #define CSS_FILE "swad19.136.css" #define JS_FILE "swad19.91.1.js" /* @@ -524,6 +524,7 @@ Param // TODO: Miguel Damas: al principio de los exámenes tendría que poner cuánto resta cada pregunta // TODO: Si el alumno ha marcado "Permitir que los profesores...", entonces pedir confirmación al pulsar el botón azul, para evitar que se envíe por error antes de tiempo + Version 19.141.3: Mar 03, 2020 Form to create new item inside course program. (282199 lines) Version 19.141.2: Mar 03, 2020 Form to create new item inside course program. (282156 lines) Version 19.141.1: Mar 03, 2020 Form to create new item inside course program. (282123 lines) Version 19.141: Mar 03, 2020 Remove groups in course program. (282052 lines) diff --git a/swad_program.c b/swad_program.c index 9a4906fbd..15c902e02 100644 --- a/swad_program.c +++ b/swad_program.c @@ -96,6 +96,7 @@ static void Prg_FreeNumbers (void); static void Prg_IncreaseNumItem (unsigned Level); static unsigned Prg_GetNumItem (unsigned Level); static void Prg_WriteNumItem (unsigned Level); +static void Prg_WriteNumNewItem (unsigned Level); static void Prg_PutFormsToRemEditOnePrgItem (unsigned NumItem, const struct ProgramItem *Item, @@ -283,6 +284,7 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,boo static unsigned UniqueId = 0; char *Id; unsigned ColSpan; + unsigned NumCol; Dat_StartEndTime_t StartEndTime; char Txt[Cns_MAX_BYTES_TEXT + 1]; @@ -304,10 +306,11 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,boo } /***** Indent depending on the level *****/ - if (Item->Hierarchy.Level > 1) + for (NumCol = 1; + NumCol < Item->Hierarchy.Level; + NumCol++) { - HTM_TD_Begin ("colspan=\"%u\" class=\"COLOR%u\"", - Item->Hierarchy.Level - 1,Gbl.RowEvenOdd); + HTM_TD_Begin ("class=\"COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_End (); } @@ -322,7 +325,7 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,boo /***** Title and text *****/ /* Begin title and text */ - ColSpan = Prg_MaxLevel - Item->Hierarchy.Level + 1; + ColSpan = (Prg_MaxLevel + 2) - Item->Hierarchy.Level; if (PrintView) HTM_TD_Begin ("colspan=\"%u\" class=\"LT\"", ColSpan); @@ -343,7 +346,6 @@ static void Prg_ShowOneItem (unsigned NumItem,const struct ProgramItem *Item,boo Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, Txt,Cns_MAX_BYTES_TEXT,false); // Convert from HTML to recpectful HTML Str_InsertLinks (Txt,Cns_MAX_BYTES_TEXT,60); // Insert links - HTM_DIV_Begin ("class=\"PAR %s\"",Item->Hierarchy.Hidden ? "DAT_LIGHT" : "DAT"); HTM_Txt (Txt); @@ -400,6 +402,7 @@ static void Prg_ShowItemForm (const struct ProgramItem *Item, unsigned FormLevel) { unsigned ColSpan; + unsigned NumCol; /***** Trivial check *****/ if (CreateOrChangeItem == Prg_DONT_PUT_FORM_ITEM) @@ -417,15 +420,26 @@ static void Prg_ShowItemForm (const struct ProgramItem *Item, HTM_TD_End (); /***** Indent depending on the level *****/ - if (FormLevel > 1) + for (NumCol = 1; + NumCol < FormLevel; + NumCol++) { - HTM_TD_Begin ("colspan=\"%u\" class=\"COLOR%u\"", - FormLevel - 1,Gbl.RowEvenOdd); + HTM_TD_Begin ("class=\"COLOR%u\"",Gbl.RowEvenOdd); HTM_TD_End (); } + /***** Item number *****/ + HTM_TD_Begin ("class=\"ASG_TITLE RT COLOR%u\" style=\"width:%dpx;\"", + Gbl.RowEvenOdd, + FormLevel * Prg_WIDTH_NUM_ITEM); + if (CreateOrChangeItem == Prg_PUT_FORM_CREATE_ITEM) + Prg_WriteNumNewItem (FormLevel); + else + Prg_WriteNumItem (FormLevel); + HTM_TD_End (); + /***** Show form to create new item as child *****/ - ColSpan = Prg_MaxLevel - FormLevel + 4; + ColSpan = (Prg_MaxLevel + 4) - FormLevel; HTM_TD_Begin ("colspan=\"%u\" class=\"LT COLOR%u\"", ColSpan,Gbl.RowEvenOdd); HTM_ARTICLE_Begin ("item_form"); @@ -449,7 +463,19 @@ static void Prg_CreateNumbers (unsigned MaxLevel) if (MaxLevel) { /***** Allocate memory for item numbers and initialize to 0 *****/ - if ((Prg_NumItem = (unsigned *) calloc (1 + MaxLevel,sizeof (unsigned))) == NULL) + /* + Example: 2.5.2.1 + MaxLevel = 4 + Level Number + ----- ------ + 0 <--- Not used + 1 2 + 2 5 + 3 2 + 4 1 + 5 0 <--- Used to create a new item + */ + if ((Prg_NumItem = (unsigned *) calloc (1 + MaxLevel + 1,sizeof (unsigned))) == NULL) Lay_NotEnoughMemoryExit (); } else @@ -504,16 +530,34 @@ static void Prg_WriteNumItem (unsigned Level) unsigned i; /***** Write number in legal style *****/ - HTM_Unsigned (Prg_GetNumItem (1)); - for (i = 2; + for (i = 1; i <= Level; i++) { - HTM_Txt ("."); + if (i > 1) + HTM_Txt ("."); HTM_Unsigned (Prg_GetNumItem (i)); } } +static void Prg_WriteNumNewItem (unsigned Level) + { + unsigned i; + + /***** Write number in legal style *****/ + for (i = 1; + i <= Level; + i++) + { + if (i > 1) + HTM_Txt ("."); + if (i < Level) + HTM_Unsigned (Prg_GetNumItem (i)); + else + HTM_Unsigned (Prg_GetNumItem (i) + 1); + } + } + /*****************************************************************************/ /**************** Put a link (form) to edit one program item *****************/ /*****************************************************************************/