mirror of https://github.com/acanas/swad-core.git
Version 21.83.3: Mar 10, 2022 Code refactoring in timetable.
This commit is contained in:
parent
dd1ce2569c
commit
fd3bcb2d94
|
@ -606,10 +606,11 @@ TODO: Fix bug: error al enviar un mensaje a dos recipientes, error on duplicate
|
||||||
|
|
||||||
TODO: Attach pdf files in multimedia.
|
TODO: Attach pdf files in multimedia.
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 21.83.2 (2022-03-10)"
|
#define Log_PLATFORM_VERSION "SWAD 21.83.3 (2022-03-10)"
|
||||||
#define CSS_FILE "swad21.83.2.css"
|
#define CSS_FILE "swad21.83.2.css"
|
||||||
#define JS_FILE "swad21.78.2.js"
|
#define JS_FILE "swad21.78.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 21.83.3: Mar 10, 2022 Code refactoring in timetable. (323527 lines)
|
||||||
Version 21.83.2: Mar 10, 2022 Working on design of dark theme. (323488 lines)
|
Version 21.83.2: Mar 10, 2022 Working on design of dark theme. (323488 lines)
|
||||||
Copy the following icon to icon public directory:
|
Copy the following icon to icon public directory:
|
||||||
sudo cp icon/theme/dark/theme_32x20.gif /var/www/html/swad/icon/theme/dark/
|
sudo cp icon/theme/dark/theme_32x20.gif /var/www/html/swad/icon/theme/dark/
|
||||||
|
|
131
swad_timetable.c
131
swad_timetable.c
|
@ -136,8 +136,19 @@ static unsigned Tmt_CalculateColsToDrawInCell (const struct Tmt_Timetable *Timet
|
||||||
static void Tmt_DrawCellAlignTimeTable (void);
|
static void Tmt_DrawCellAlignTimeTable (void);
|
||||||
static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
unsigned Weekday,unsigned Interval,unsigned Column,unsigned ColSpan,
|
unsigned Weekday,unsigned Interval,unsigned Column,unsigned ColSpan,
|
||||||
long CrsCod,Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
long CrsCod,long GrpCod,
|
||||||
unsigned DurationNumIntervals,long GrpCod,const char *Info);
|
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,const char *Info);
|
||||||
|
static void Tmt_TimeTableDrawCellView (const struct Tmt_Timetable *Timetable,
|
||||||
|
long CrsCod,long GrpCod,
|
||||||
|
Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,
|
||||||
|
const char *Info);
|
||||||
|
static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
|
||||||
|
unsigned Weekday,unsigned Interval,unsigned Column,
|
||||||
|
long GrpCod,
|
||||||
|
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,const char *Info);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************** Create internal timetable in memory ********************/
|
/******************** Create internal timetable in memory ********************/
|
||||||
|
@ -1081,7 +1092,7 @@ static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
|
||||||
{
|
{
|
||||||
Tmt_TimeTableDrawCell (Timetable,
|
Tmt_TimeTableDrawCell (Timetable,
|
||||||
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns,
|
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns,
|
||||||
-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,-1L,NULL);
|
-1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL);
|
||||||
ContinuousFreeMinicolumns = 0;
|
ContinuousFreeMinicolumns = 0;
|
||||||
}
|
}
|
||||||
Tmt_TimeTableDrawCell (Timetable,
|
Tmt_TimeTableDrawCell (Timetable,
|
||||||
|
@ -1089,16 +1100,16 @@ static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
|
||||||
Tmt_NUM_MINICOLUMNS_PER_DAY /
|
Tmt_NUM_MINICOLUMNS_PER_DAY /
|
||||||
ColumnsToDrawIncludingExtraColumn,
|
ColumnsToDrawIncludingExtraColumn,
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].CrsCod,
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].CrsCod,
|
||||||
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].IntervalType,
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].IntervalType,
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].ClassType,
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].ClassType,
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals,
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals,
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].GrpCod,
|
|
||||||
Tmt_TimeTable[Weekday][Interval].Columns[Column].Info);
|
Tmt_TimeTable[Weekday][Interval].Columns[Column].Info);
|
||||||
}
|
}
|
||||||
if (ContinuousFreeMinicolumns)
|
if (ContinuousFreeMinicolumns)
|
||||||
Tmt_TimeTableDrawCell (Timetable,
|
Tmt_TimeTableDrawCell (Timetable,
|
||||||
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns,
|
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns,
|
||||||
-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,-1L,NULL);
|
-1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Empty column used to adjust height */
|
/* Empty column used to adjust height */
|
||||||
|
@ -1300,16 +1311,12 @@ static void Tmt_DrawCellAlignTimeTable (void)
|
||||||
|
|
||||||
static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
unsigned Weekday,unsigned Interval,unsigned Column,unsigned ColSpan,
|
unsigned Weekday,unsigned Interval,unsigned Column,unsigned ColSpan,
|
||||||
long CrsCod,Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
long CrsCod,long GrpCod,
|
||||||
unsigned DurationNumIntervals,long GrpCod,const char *Info)
|
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,const char *Info)
|
||||||
{
|
{
|
||||||
extern const char *The_ClassDatSmall[The_NUM_THEMES];
|
extern const char *The_ClassDatSmall[The_NUM_THEMES];
|
||||||
extern const char *Tmt_DB_ClassType[Tmt_NUM_CLASS_TYPES];
|
|
||||||
extern const char *Txt_unknown_removed_course;
|
|
||||||
extern const char *Txt_TIMETABLE_CLASS_TYPES[Tmt_NUM_CLASS_TYPES];
|
|
||||||
extern const char *Txt_Group;
|
|
||||||
extern const char *Txt_All_groups;
|
extern const char *Txt_All_groups;
|
||||||
extern const char *Txt_Info;
|
|
||||||
static const char *TimeTableClasses[Tmt_NUM_CLASS_TYPES] =
|
static const char *TimeTableClasses[Tmt_NUM_CLASS_TYPES] =
|
||||||
{
|
{
|
||||||
[Tmt_FREE ] = "Tmt_FREE", // free hour
|
[Tmt_FREE ] = "Tmt_FREE", // free hour
|
||||||
|
@ -1317,23 +1324,11 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
[Tmt_PRACTICAL] = "Tmt_PRAC", // practical class
|
[Tmt_PRACTICAL] = "Tmt_PRAC", // practical class
|
||||||
[Tmt_TUTORING ] = "Tmt_TUTO", // tutoring/office hour
|
[Tmt_TUTORING ] = "Tmt_TUTO", // tutoring/office hour
|
||||||
};
|
};
|
||||||
char *CellStr; // Unique string for this cell used in labels
|
|
||||||
struct GroupData GrpDat;
|
struct GroupData GrpDat;
|
||||||
unsigned NumGrpTyp;
|
|
||||||
unsigned NumGrp;
|
|
||||||
unsigned i;
|
|
||||||
unsigned Dur;
|
|
||||||
unsigned MaxDuration;
|
|
||||||
char *TTDur;
|
|
||||||
unsigned RowSpan = 0;
|
unsigned RowSpan = 0;
|
||||||
char *RowSpanStr;
|
char *RowSpanStr;
|
||||||
char *ColSpanStr;
|
char *ColSpanStr;
|
||||||
char *ClassStr;
|
char *ClassStr;
|
||||||
Tmt_ClassType_t CT;
|
|
||||||
struct Crs_Course Crs;
|
|
||||||
struct GroupType *GrpTyp;
|
|
||||||
struct Group *Grp;
|
|
||||||
char *Room;
|
|
||||||
|
|
||||||
/***** Compute row span and background color depending on hour type *****/
|
/***** Compute row span and background color depending on hour type *****/
|
||||||
switch (IntervalType)
|
switch (IntervalType)
|
||||||
|
@ -1408,19 +1403,44 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
free (ColSpanStr);
|
free (ColSpanStr);
|
||||||
free (ClassStr);
|
free (ClassStr);
|
||||||
|
|
||||||
/***** Form to modify this cell *****/
|
|
||||||
if (Timetable->View == Tmt_CRS_EDIT)
|
|
||||||
Frm_BeginForm (ActChgCrsTT);
|
|
||||||
else if (Timetable->View == Tmt_TUT_EDIT)
|
|
||||||
Frm_BeginForm (ActChgTut);
|
|
||||||
|
|
||||||
/***** Draw cell depending on type of view *****/
|
/***** Draw cell depending on type of view *****/
|
||||||
switch (Timetable->View)
|
switch (Timetable->View)
|
||||||
{
|
{
|
||||||
case Tmt_CRS_VIEW: // View course timetable
|
case Tmt_CRS_VIEW: // View course timetable
|
||||||
case Tmt_TUT_VIEW: // View tutoring timetable
|
case Tmt_TUT_VIEW: // View tutoring timetable
|
||||||
if (IntervalType != Tmt_FREE_INTERVAL) // If cell is not empty...
|
if (IntervalType != Tmt_FREE_INTERVAL) // If cell is not empty...
|
||||||
|
Tmt_TimeTableDrawCellView (Timetable,
|
||||||
|
CrsCod,GrpCod,
|
||||||
|
ClassType,
|
||||||
|
DurationNumIntervals,
|
||||||
|
Info);
|
||||||
|
break;
|
||||||
|
case Tmt_CRS_EDIT: // Edit course timetable
|
||||||
|
case Tmt_TUT_EDIT: // Edit tutoring timetable
|
||||||
|
Tmt_TimeTableDrawCellEdit (Timetable,
|
||||||
|
Weekday,Interval,Column,
|
||||||
|
GrpCod,
|
||||||
|
IntervalType,ClassType,
|
||||||
|
DurationNumIntervals,
|
||||||
|
Info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** End cell *****/
|
||||||
|
HTM_TD_End ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Tmt_TimeTableDrawCellView (const struct Tmt_Timetable *Timetable,
|
||||||
|
long CrsCod,long GrpCod,
|
||||||
|
Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,
|
||||||
|
const char *Info)
|
||||||
{
|
{
|
||||||
|
extern const char *Txt_unknown_removed_course;
|
||||||
|
extern const char *Txt_TIMETABLE_CLASS_TYPES[Tmt_NUM_CLASS_TYPES];
|
||||||
|
struct Crs_Course Crs;
|
||||||
|
struct GroupData GrpDat;
|
||||||
|
|
||||||
/***** Begin cell *****/
|
/***** Begin cell *****/
|
||||||
HTM_DIV_Begin ("class=\"Tmt_CELL Tmt_TXT\"");
|
HTM_DIV_Begin ("class=\"Tmt_CELL Tmt_TXT\"");
|
||||||
|
|
||||||
|
@ -1471,9 +1491,36 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
/***** End cell *****/
|
/***** End cell *****/
|
||||||
HTM_DIV_End ();
|
HTM_DIV_End ();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case Tmt_CRS_EDIT:
|
static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
|
||||||
case Tmt_TUT_EDIT:
|
unsigned Weekday,unsigned Interval,unsigned Column,
|
||||||
|
long GrpCod,
|
||||||
|
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
|
||||||
|
unsigned DurationNumIntervals,const char *Info)
|
||||||
|
{
|
||||||
|
extern const char *The_ClassDatSmall[The_NUM_THEMES];
|
||||||
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
||||||
|
extern const char *Tmt_DB_ClassType[Tmt_NUM_CLASS_TYPES];
|
||||||
|
extern const char *Txt_TIMETABLE_CLASS_TYPES[Tmt_NUM_CLASS_TYPES];
|
||||||
|
extern const char *Txt_Group;
|
||||||
|
extern const char *Txt_All_groups;
|
||||||
|
extern const char *Txt_Info;
|
||||||
|
char *CellStr; // Unique string for this cell used in labels
|
||||||
|
Tmt_ClassType_t CT;
|
||||||
|
unsigned i;
|
||||||
|
unsigned Dur;
|
||||||
|
unsigned MaxDuration;
|
||||||
|
char *TTDur;
|
||||||
|
unsigned NumGrpTyp;
|
||||||
|
unsigned NumGrp;
|
||||||
|
struct GroupType *GrpTyp;
|
||||||
|
struct Group *Grp;
|
||||||
|
char *Room;
|
||||||
|
|
||||||
|
/***** Form to modify this cell *****/
|
||||||
|
Frm_BeginForm (Timetable->View == Tmt_CRS_EDIT ? ActChgCrsTT :
|
||||||
|
ActChgTut);
|
||||||
|
|
||||||
/***** Create unique string for this cell used in labels *****/
|
/***** Create unique string for this cell used in labels *****/
|
||||||
if (asprintf (&CellStr,"%02u%02u%02u",
|
if (asprintf (&CellStr,"%02u%02u%02u",
|
||||||
Weekday,Interval,Column) < 0)
|
Weekday,Interval,Column) < 0)
|
||||||
|
@ -1596,8 +1643,9 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
HTM_INPUT_TEXT ("TTInf",Tmt_MAX_CHARS_INFO,Info ? Info :
|
HTM_INPUT_TEXT ("TTInf",Tmt_MAX_CHARS_INFO,Info ? Info :
|
||||||
"",
|
"",
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"id=\"TTInf%s\" size=\"1\" class=\"Tmt_INF\"",
|
"id=\"TTInf%s\" size=\"1\""
|
||||||
CellStr);
|
" class=\"Tmt_INF %s\"",
|
||||||
|
CellStr,The_ClassInput[Gbl.Prefs.Theme]);
|
||||||
}
|
}
|
||||||
else // TimeTableView == Tmt_TUT_EDIT
|
else // TimeTableView == Tmt_TUT_EDIT
|
||||||
{
|
{
|
||||||
|
@ -1610,22 +1658,15 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
|
||||||
HTM_LABEL_End ();
|
HTM_LABEL_End ();
|
||||||
HTM_INPUT_TEXT ("TTInf",Tmt_MAX_CHARS_INFO,Info,
|
HTM_INPUT_TEXT ("TTInf",Tmt_MAX_CHARS_INFO,Info,
|
||||||
HTM_SUBMIT_ON_CHANGE,
|
HTM_SUBMIT_ON_CHANGE,
|
||||||
"id=\"TTInf%s\" size=\"12\" class=\"Tmt_INF\"",
|
"id=\"TTInf%s\" size=\"12\""
|
||||||
CellStr);
|
" class=\"Tmt_INF %s\"",
|
||||||
|
CellStr,The_ClassInput[Gbl.Prefs.Theme]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free allocated unique string for this cell used in labels *****/
|
/***** Free allocated unique string for this cell used in labels *****/
|
||||||
free (CellStr);
|
free (CellStr);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** End form *****/
|
/***** End form *****/
|
||||||
if (Timetable->View == Tmt_CRS_EDIT ||
|
|
||||||
Timetable->View == Tmt_TUT_EDIT)
|
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
|
|
||||||
/***** End cell *****/
|
|
||||||
HTM_TD_End ();
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue