Version19.136.2

This commit is contained in:
Antonio Cañas Vargas 2020-02-29 12:11:07 +01:00
parent 30966b4471
commit 874b30a90e
2 changed files with 48 additions and 15 deletions

View File

@ -523,8 +523,9 @@ Param
// TODO: Miguel Damas: por defecto, marcar "Permitir que los profesores..." en los test (que ya esté marcado en lugar de desmarcado)
// 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.136.2: Feb 27, 2020 Move to left items in course program. (282330 lines)
Version 19.136.1: Feb 29, 2020 Fixed bugs in course program. (282301 lines)
Version 19.136: Feb 27, 2020 Indent items in course program. (282292 lines)
Version 19.136: Feb 27, 2020 Move to right (indent) items in course program. (282292 lines)
3 changes necessary in database:
DROP INDEX CrsCod ON prg_items;
ALTER TABLE prg_items CHANGE COLUMN CrsCod CrsCod INT NOT NULL DEFAULT -1 AFTER ItmCod;

View File

@ -61,6 +61,13 @@ extern struct Globals Gbl;
/******************************* Private types *******************************/
/*****************************************************************************/
#define Prg_NUM_LEFT_RIGHT 2
typedef enum
{
Prg_TO_LEFT = 0,
Prg_TO_RIGHT = 1
} Prg_LeftRight;
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
@ -107,7 +114,8 @@ static unsigned Prg_GetNextItemIndex (unsigned Index);
static unsigned Prg_GetItemLevelFromIndex (unsigned Index);
static unsigned Prg_GetNextIndexNotChild (const struct ProgramItem *Item);
static void Prg_ExchangeItems (unsigned TopIndex,unsigned BottomIndex);
static void Prg_MoveItemAndChildrenToRight (unsigned Index,unsigned NextIndex);
static void Prg_MoveItemAndChildrenLeftRight (Prg_LeftRight LeftRight,
unsigned Index,unsigned NextIndex);
static bool Prg_CheckIfSimilarPrgItemExists (const char *Field,const char *Value,long ItmCod);
static void Prg_ShowLstGrpsToEditPrgItem (long ItmCod);
@ -437,7 +445,7 @@ static void Prg_PutFormsToRemEditOnePrgItem (const struct ProgramItem *Item,
extern const char *Txt_Increase_level_of_X;
extern const char *Txt_Decrease_level_of_X;
extern const char *Txt_Movement_not_allowed;
static unsigned LastLevel = 0;
static unsigned PrevLevel = 0;
char StrItemIndex[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
Prg_SetCurrentItmCod (Item->ItmCod); // Used as parameter in contextual links
@ -492,7 +500,7 @@ static void Prg_PutFormsToRemEditOnePrgItem (const struct ProgramItem *Item,
HTM_BR ();
/***** Icon to increase the level of an item *****/
/***** Icon to move left item (increase level) *****/
if (Item->Level > 1)
{
Lay_PutContextualLinkOnlyIcon (ActLftPrgItm,NULL,Prg_PutParams,
@ -504,8 +512,8 @@ static void Prg_PutFormsToRemEditOnePrgItem (const struct ProgramItem *Item,
else
Ico_PutIconOff ("arrow-left.svg",Txt_Movement_not_allowed);
/***** Icon to decrease level item *****/
if (Item->Level < LastLevel + 1)
/***** Icon to move right item (indent, decrease level) *****/
if (Item->Level <= PrevLevel)
{
Lay_PutContextualLinkOnlyIcon (ActRgtPrgItm,NULL,Prg_PutParams,
"arrow-right.svg",
@ -516,7 +524,7 @@ static void Prg_PutFormsToRemEditOnePrgItem (const struct ProgramItem *Item,
else
Ico_PutIconOff ("arrow-right.svg",Txt_Movement_not_allowed);
LastLevel = Item->Level;
PrevLevel = Item->Level;
break;
case Rol_STD:
case Rol_NET:
@ -1104,7 +1112,7 @@ void Prg_MoveRightPrgItem (void)
NextIndex = Prg_GetNextIndexNotChild (&Item);
/* Move item and its children to right */
Prg_MoveItemAndChildrenToRight (Item.Index,NextIndex);
Prg_MoveItemAndChildrenLeftRight (Prg_TO_RIGHT,Item.Index,NextIndex);
/* Success alert */
Ale_ShowAlert (Ale_SUCCESS,Txt_The_item_has_been_moved_to_the_right);
@ -1125,7 +1133,10 @@ void Prg_MoveRightPrgItem (void)
void Prg_MoveLeftPrgItem (void)
{
extern const char *Txt_The_item_has_been_moved_to_the_left;
extern const char *Txt_Movement_not_allowed;
struct ProgramItem Item;
unsigned NextIndex;
/***** Get program item code *****/
if ((Item.ItmCod = Prg_GetParamItmCod ()) == -1L)
@ -1135,7 +1146,19 @@ void Prg_MoveLeftPrgItem (void)
Prg_GetDataOfItemByCod (&Item);
/***** Move left item (decrease level) *****/
// TODO: Implement
if (Item.Level >= 1)
{
/* Get index of next item not children */
NextIndex = Prg_GetNextIndexNotChild (&Item);
/* Move item and its children to left */
Prg_MoveItemAndChildrenLeftRight (Prg_TO_LEFT,Item.Index,NextIndex);
/* Success alert */
Ale_ShowAlert (Ale_SUCCESS,Txt_The_item_has_been_moved_to_the_left);
}
else
Ale_ShowAlert (Ale_WARNING,Txt_Movement_not_allowed);
/***** Show program items again *****/
Prg_SeeCourseProgram ();
@ -1340,23 +1363,32 @@ static unsigned Prg_GetNextIndexNotChild (const struct ProgramItem *Item)
}
/*****************************************************************************/
/******************** Move item and its children to right ********************/
/**************** Move item and its children to left or right ****************/
/*****************************************************************************/
static void Prg_MoveItemAndChildrenToRight (unsigned Index,unsigned NextIndex)
static void Prg_MoveItemAndChildrenLeftRight (Prg_LeftRight LeftRight,
unsigned Index,unsigned NextIndex)
{
static const char *Update[Prg_NUM_LEFT_RIGHT] =
{
[Prg_TO_LEFT ] = "-1",
[Prg_TO_RIGHT] = "+1"
};
if (NextIndex == 0) // At the end, no more not-children items
DB_QueryUPDATE ("can not move to right (ident)",
"UPDATE prg_items SET Level=Level+1"
DB_QueryUPDATE ("can not move items",
"UPDATE prg_items SET Level=Level%s"
" WHERE CrsCod=%ld"
" AND ItmInd>=%u",
Update[LeftRight],
Gbl.Hierarchy.Crs.CrsCod,
Index);
else
DB_QueryUPDATE ("can not move to right (ident)",
"UPDATE prg_items SET Level=Level+1"
DB_QueryUPDATE ("can not move items",
"UPDATE prg_items SET Level=Level%s"
" WHERE CrsCod=%ld"
" AND ItmInd>=%u AND ItmInd<%u",
Update[LeftRight],
Gbl.Hierarchy.Crs.CrsCod,
Index,NextIndex);
}