Version 21.83.4: Mar 11, 2022 Code refactoring in timetable.

This commit is contained in:
acanas 2022-03-11 00:46:06 +01:00
parent fd3bcb2d94
commit 2073965f8b
3 changed files with 106 additions and 89 deletions

View File

@ -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.3 (2022-03-10)" #define Log_PLATFORM_VERSION "SWAD 21.83.4 (2022-03-11)"
#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.4: Mar 11, 2022 Code refactoring in timetable. (323543 lines)
Version 21.83.3: Mar 10, 2022 Code refactoring in timetable. (323527 lines) 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:

View File

@ -135,7 +135,7 @@ static unsigned Tmt_CalculateColsToDrawInCell (const struct Tmt_Timetable *Timet
unsigned Weekday,unsigned Interval); unsigned Weekday,unsigned Interval);
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, const struct Tmt_WhichCell *WhichCell,unsigned ColSpan,
long CrsCod,long GrpCod, long CrsCod,long GrpCod,
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType, Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
unsigned DurationNumIntervals,const char *Info); unsigned DurationNumIntervals,const char *Info);
@ -145,7 +145,7 @@ static void Tmt_TimeTableDrawCellView (const struct Tmt_Timetable *Timetable,
unsigned DurationNumIntervals, unsigned DurationNumIntervals,
const char *Info); const char *Info);
static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable, static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
unsigned Weekday,unsigned Interval,unsigned Column, const struct Tmt_WhichCell *WhichCell,
long GrpCod, long GrpCod,
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType, Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
unsigned DurationNumIntervals,const char *Info); unsigned DurationNumIntervals,const char *Info);
@ -178,7 +178,7 @@ static void Tmt_TimeTableConfigureIntervalsAndAllocateTimeTable (struct Tmt_Time
Weekday < Tmt_DAYS_PER_WEEK; Weekday < Tmt_DAYS_PER_WEEK;
Weekday++) Weekday++)
if ((Tmt_TimeTable[Weekday] = malloc (Timetable->Config.IntervalsPerDay * if ((Tmt_TimeTable[Weekday] = malloc (Timetable->Config.IntervalsPerDay *
sizeof (*Tmt_TimeTable[Weekday]))) == NULL) sizeof (*Tmt_TimeTable[Weekday]))) == NULL)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
} }
else else
@ -256,25 +256,25 @@ static void Tmt_GetParamsTimeTable (struct Tmt_Timetable *Timetable)
unsigned Minutes; unsigned Minutes;
/***** Get day (0: monday, 1: tuesday,..., 6: sunday *****/ /***** Get day (0: monday, 1: tuesday,..., 6: sunday *****/
Timetable->Weekday = (unsigned) Timetable->WhichCell.Weekday = (unsigned)
Par_GetParToUnsignedLong ("TTDay", Par_GetParToUnsignedLong ("TTDay",
0, 0,
Tmt_DAYS_PER_WEEK - 1, Tmt_DAYS_PER_WEEK - 1,
0); 0);
/***** Get hour *****/ /***** Get hour *****/
Timetable->Interval = (unsigned) Timetable->WhichCell.Interval = (unsigned)
Par_GetParToUnsignedLong ("TTInt", Par_GetParToUnsignedLong ("TTInt",
0, 0,
Timetable->Config.IntervalsPerDay - 1, Timetable->Config.IntervalsPerDay - 1,
0); 0);
/***** Get number of column *****/ /***** Get number of column *****/
Timetable->Column = (unsigned) Timetable->WhichCell.Column = (unsigned)
Par_GetParToUnsignedLong ("TTCol", Par_GetParToUnsignedLong ("TTCol",
0, 0,
Tmt_MAX_COLUMNS_PER_CELL - 1, Tmt_MAX_COLUMNS_PER_CELL - 1,
0); 0);
/***** Get class type *****/ /***** Get class type *****/
Par_GetParToText ("TTTyp",StrClassType,Tmt_MAX_BYTES_STR_CLASS_TYPE); Par_GetParToText ("TTTyp",StrClassType,Tmt_MAX_BYTES_STR_CLASS_TYPE);
@ -960,30 +960,30 @@ static unsigned Tmt_CalculateMinutesPerInterval (unsigned Seconds)
static void Tmt_ModifTimeTable (struct Tmt_Timetable *Timetable) static void Tmt_ModifTimeTable (struct Tmt_Timetable *Timetable)
{ {
if (Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].IntervalType == Tmt_FIRST_INTERVAL) if (Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].IntervalType == Tmt_FIRST_INTERVAL)
{ {
/***** Free this cell *****/ /***** Free this cell *****/
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].GrpCod = -1L; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].GrpCod = -1L;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].IntervalType = Tmt_FREE_INTERVAL; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].IntervalType = Tmt_FREE_INTERVAL;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].ClassType = Tmt_FREE; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].ClassType = Tmt_FREE;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].DurationIntervals = 0; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].DurationIntervals = 0;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].Info[0] = '\0'; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].Info[0] = '\0';
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].NumColumns--; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].NumColumns--;
} }
if (Timetable->ClassType != Tmt_FREE && if (Timetable->ClassType != Tmt_FREE &&
Timetable->DurationIntervals > 0 && Timetable->DurationIntervals > 0 &&
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].NumColumns < Tmt_MAX_COLUMNS_PER_CELL) Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].NumColumns < Tmt_MAX_COLUMNS_PER_CELL)
{ {
/***** Change this cell *****/ /***** Change this cell *****/
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].NumColumns++; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].NumColumns++;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].GrpCod = Timetable->GrpCod; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].GrpCod = Timetable->GrpCod;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].IntervalType = Tmt_FIRST_INTERVAL; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].IntervalType = Tmt_FIRST_INTERVAL;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].ClassType = Timetable->ClassType; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].ClassType = Timetable->ClassType;
Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].DurationIntervals = Timetable->DurationIntervals; Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].DurationIntervals = Timetable->DurationIntervals;
Str_Copy (Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].Info, Str_Copy (Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].Info,
Timetable->Info, Timetable->Info,
sizeof (Tmt_TimeTable[Timetable->Weekday][Timetable->Interval].Columns[Timetable->Column].Info) - 1); sizeof (Tmt_TimeTable[Timetable->WhichCell.Weekday][Timetable->WhichCell.Interval].Columns[Timetable->WhichCell.Column].Info) - 1);
} }
} }
@ -994,10 +994,8 @@ static void Tmt_ModifTimeTable (struct Tmt_Timetable *Timetable)
static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable) static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
{ {
unsigned DayColumn; // Column from left (0) to right (6) unsigned DayColumn; // Column from left (0) to right (6)
unsigned Weekday; // Day of week struct Tmt_WhichCell WhichCell;
unsigned Interval;
unsigned Min; unsigned Min;
unsigned Column;
unsigned ColumnsToDraw; unsigned ColumnsToDraw;
unsigned ColumnsToDrawIncludingExtraColumn; unsigned ColumnsToDrawIncludingExtraColumn;
unsigned ContinuousFreeMinicolumns; unsigned ContinuousFreeMinicolumns;
@ -1033,20 +1031,20 @@ static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS); Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_ONLY_GROUP_TYPES_WITH_GROUPS);
/***** Write the table row by row *****/ /***** Write the table row by row *****/
for (Interval = 0, Min = Timetable->Config.Range.MinutesPerInterval; for (WhichCell.Interval = 0, Min = Timetable->Config.Range.MinutesPerInterval;
Interval < Timetable->Config.IntervalsPerDay; WhichCell.Interval < Timetable->Config.IntervalsPerDay;
Interval++, WhichCell.Interval++,
Min = (Min + Timetable->Config.Range.MinutesPerInterval) % Min = (Min + Timetable->Config.Range.MinutesPerInterval) %
Tmt_SECONDS_PER_MINUTE) Tmt_SECONDS_PER_MINUTE)
{ {
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
/* Left hour:minutes cell */ /* Left hour:minutes cell */
if (Interval % 2) if (WhichCell.Interval % 2)
Tmt_TimeTableDrawHourCell (Timetable->Config.Range.Hours.Start + Tmt_TimeTableDrawHourCell (Timetable->Config.Range.Hours.Start +
(Interval + 2) / Timetable->Config.IntervalsPerHour, (WhichCell.Interval + 2) / Timetable->Config.IntervalsPerHour,
Min, Min,
"RM"); "RM");
/* Empty column used to adjust height */ /* Empty column used to adjust height */
Tmt_DrawCellAlignTimeTable (); Tmt_DrawCellAlignTimeTable ();
@ -1059,14 +1057,14 @@ static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
/* Weekday == 0 ==> monday, /* Weekday == 0 ==> monday,
... ...
Weekday == 6 ==> sunday */ Weekday == 6 ==> sunday */
Weekday = (DayColumn + Gbl.Prefs.FirstDayOfWeek) % 7; WhichCell.Weekday = (DayColumn + Gbl.Prefs.FirstDayOfWeek) % 7;
/* Check how many colums are needed. /* Check how many colums are needed.
For each item (class) in this hour from left to right, For each item (class) in this hour from left to right,
we must check the maximum of columns */ we must check the maximum of columns */
ColumnsToDraw = Tmt_CalculateColsToDrawInCell (Timetable, ColumnsToDraw = Tmt_CalculateColsToDrawInCell (Timetable,
true, // Top call, non recursive true, // Top call, non recursive
Weekday,Interval); WhichCell.Weekday,WhichCell.Interval);
if (ColumnsToDraw == 0 && if (ColumnsToDraw == 0 &&
(Timetable->View == Tmt_CRS_VIEW || (Timetable->View == Tmt_CRS_VIEW ||
Timetable->View == Tmt_TUT_VIEW)) Timetable->View == Tmt_TUT_VIEW))
@ -1080,45 +1078,51 @@ static void Tmt_DrawTimeTable (const struct Tmt_Timetable *Timetable)
ColumnsToDrawIncludingExtraColumn++; ColumnsToDrawIncludingExtraColumn++;
/* Draw cells */ /* Draw cells */
for (Column = 0, ContinuousFreeMinicolumns = 0; for (WhichCell.Column = 0, ContinuousFreeMinicolumns = 0;
Column < ColumnsToDrawIncludingExtraColumn; WhichCell.Column < ColumnsToDrawIncludingExtraColumn;
Column++) WhichCell.Column++)
if (Tmt_TimeTable[Weekday][Interval].Columns[Column].IntervalType == Tmt_FREE_INTERVAL) if (Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].IntervalType == Tmt_FREE_INTERVAL)
ContinuousFreeMinicolumns += Tmt_NUM_MINICOLUMNS_PER_DAY / ContinuousFreeMinicolumns += Tmt_NUM_MINICOLUMNS_PER_DAY /
ColumnsToDrawIncludingExtraColumn; ColumnsToDrawIncludingExtraColumn;
else else
{ {
if (ContinuousFreeMinicolumns) if (ContinuousFreeMinicolumns)
{ {
WhichCell.Column--;
Tmt_TimeTableDrawCell (Timetable, Tmt_TimeTableDrawCell (Timetable,
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns, &WhichCell,ContinuousFreeMinicolumns,
-1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL); -1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL);
WhichCell.Column++;
ContinuousFreeMinicolumns = 0; ContinuousFreeMinicolumns = 0;
} }
Tmt_TimeTableDrawCell (Timetable, Tmt_TimeTableDrawCell (Timetable,
Weekday,Interval,Column, &WhichCell,
Tmt_NUM_MINICOLUMNS_PER_DAY / Tmt_NUM_MINICOLUMNS_PER_DAY /
ColumnsToDrawIncludingExtraColumn, ColumnsToDrawIncludingExtraColumn,
Tmt_TimeTable[Weekday][Interval].Columns[Column].CrsCod, Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].CrsCod,
Tmt_TimeTable[Weekday][Interval].Columns[Column].GrpCod, Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].GrpCod,
Tmt_TimeTable[Weekday][Interval].Columns[Column].IntervalType, Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].IntervalType,
Tmt_TimeTable[Weekday][Interval].Columns[Column].ClassType, Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].ClassType,
Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals, Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].DurationIntervals,
Tmt_TimeTable[Weekday][Interval].Columns[Column].Info); Tmt_TimeTable[WhichCell.Weekday][WhichCell.Interval].Columns[WhichCell.Column].Info);
} }
if (ContinuousFreeMinicolumns) if (ContinuousFreeMinicolumns)
{
WhichCell.Column--;
Tmt_TimeTableDrawCell (Timetable, Tmt_TimeTableDrawCell (Timetable,
Weekday,Interval,Column - 1,ContinuousFreeMinicolumns, &WhichCell,ContinuousFreeMinicolumns,
-1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL); -1L,-1L,Tmt_FREE_INTERVAL,Tmt_FREE,0,NULL);
WhichCell.Column++;
}
} }
/* Empty column used to adjust height */ /* Empty column used to adjust height */
Tmt_DrawCellAlignTimeTable (); Tmt_DrawCellAlignTimeTable ();
/* Right hour:minutes cell */ /* Right hour:minutes cell */
if (Interval % 2) if (WhichCell.Interval % 2)
Tmt_TimeTableDrawHourCell (Timetable->Config.Range.Hours.Start + Tmt_TimeTableDrawHourCell (Timetable->Config.Range.Hours.Start +
(Interval + 2) / Timetable->Config.IntervalsPerHour, (WhichCell.Interval + 2) / Timetable->Config.IntervalsPerHour,
Min, Min,
"LM"); "LM");
@ -1310,7 +1314,7 @@ 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, const struct Tmt_WhichCell *WhichCell,unsigned ColSpan,
long CrsCod,long GrpCod, long CrsCod,long GrpCod,
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType, Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
unsigned DurationNumIntervals,const char *Info) unsigned DurationNumIntervals,const char *Info)
@ -1384,7 +1388,7 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
{ {
if (asprintf (&ClassStr,"%s%u", if (asprintf (&ClassStr,"%s%u",
TimeTableClasses[ClassType], TimeTableClasses[ClassType],
Interval % 4) < 0) WhichCell->Interval % 4) < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
} }
else else
@ -1417,8 +1421,7 @@ static void Tmt_TimeTableDrawCell (const struct Tmt_Timetable *Timetable,
break; break;
case Tmt_CRS_EDIT: // Edit course timetable case Tmt_CRS_EDIT: // Edit course timetable
case Tmt_TUT_EDIT: // Edit tutoring timetable case Tmt_TUT_EDIT: // Edit tutoring timetable
Tmt_TimeTableDrawCellEdit (Timetable, Tmt_TimeTableDrawCellEdit (Timetable,WhichCell,
Weekday,Interval,Column,
GrpCod, GrpCod,
IntervalType,ClassType, IntervalType,ClassType,
DurationNumIntervals, DurationNumIntervals,
@ -1493,7 +1496,7 @@ static void Tmt_TimeTableDrawCellView (const struct Tmt_Timetable *Timetable,
} }
static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable, static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
unsigned Weekday,unsigned Interval,unsigned Column, const struct Tmt_WhichCell *WhichCell,
long GrpCod, long GrpCod,
Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType, Tmt_IntervalType_t IntervalType,Tmt_ClassType_t ClassType,
unsigned DurationNumIntervals,const char *Info) unsigned DurationNumIntervals,const char *Info)
@ -1505,6 +1508,13 @@ static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
extern const char *Txt_Group; extern const char *Txt_Group;
extern const char *Txt_All_groups; extern const char *Txt_All_groups;
extern const char *Txt_Info; extern const char *Txt_Info;
static Act_Action_t NextAction[Tmt_NUM_VIEW_EDIT] =
{
[Tmt_CRS_VIEW] = ActUnk, // course view
[Tmt_TUT_VIEW] = ActUnk, // tutorials view
[Tmt_CRS_EDIT] = ActChgCrsTT, // course edit
[Tmt_TUT_EDIT] = ActChgTut, // tutorials edit
};
char *CellStr; // Unique string for this cell used in labels char *CellStr; // Unique string for this cell used in labels
Tmt_ClassType_t CT; Tmt_ClassType_t CT;
unsigned i; unsigned i;
@ -1518,18 +1528,17 @@ static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
char *Room; char *Room;
/***** Form to modify this cell *****/ /***** Form to modify this cell *****/
Frm_BeginForm (Timetable->View == Tmt_CRS_EDIT ? ActChgCrsTT : Frm_BeginForm (NextAction[Timetable->View]);
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) WhichCell->Weekday,WhichCell->Interval,WhichCell->Column) < 0)
Err_NotEnoughMemoryExit (); Err_NotEnoughMemoryExit ();
/***** Put hidden parameters *****/ /***** Put hidden parameters *****/
Par_PutHiddenParamUnsigned (NULL,"TTDay",Weekday); Par_PutHiddenParamUnsigned (NULL,"TTDay",WhichCell->Weekday );
Par_PutHiddenParamUnsigned (NULL,"TTInt",Interval); Par_PutHiddenParamUnsigned (NULL,"TTInt",WhichCell->Interval);
Par_PutHiddenParamUnsigned (NULL,"TTCol",Column); Par_PutHiddenParamUnsigned (NULL,"TTCol",WhichCell->Column );
/***** Class type *****/ /***** Class type *****/
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
@ -1547,12 +1556,12 @@ static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
if (IntervalType == Tmt_FREE_INTERVAL) if (IntervalType == Tmt_FREE_INTERVAL)
{ {
for (i = Interval + 1; for (i = WhichCell->Interval + 1;
i < Timetable->Config.IntervalsPerDay; i < Timetable->Config.IntervalsPerDay;
i++) i++)
if (Tmt_TimeTable[Weekday][i].NumColumns == Tmt_MAX_COLUMNS_PER_CELL) if (Tmt_TimeTable[WhichCell->Weekday][i].NumColumns == Tmt_MAX_COLUMNS_PER_CELL)
break; break;
MaxDuration = i - Interval; MaxDuration = i - WhichCell->Interval;
Dur = (MaxDuration >= Timetable->Config.IntervalsPerHour) ? Timetable->Config.IntervalsPerHour : // MaxDuration >= 1h ==> Dur = 1h Dur = (MaxDuration >= Timetable->Config.IntervalsPerHour) ? Timetable->Config.IntervalsPerHour : // MaxDuration >= 1h ==> Dur = 1h
MaxDuration; // MaxDuration < 1h ==> Dur = MaxDuration MaxDuration; // MaxDuration < 1h ==> Dur = MaxDuration
if (asprintf (&TTDur,"%u:%02u", if (asprintf (&TTDur,"%u:%02u",
@ -1568,15 +1577,16 @@ static void Tmt_TimeTableDrawCellEdit (const struct Tmt_Timetable *Timetable,
/***** Class duration *****/ /***** Class duration *****/
HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE, HTM_SELECT_Begin (HTM_SUBMIT_ON_CHANGE,
"name=\"TTDur\" class=\"Tmt_DUR\""); "name=\"TTDur\" class=\"Tmt_DUR\"");
for (i = Interval + Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals; for (i = WhichCell->Interval +
Tmt_TimeTable[WhichCell->Weekday][WhichCell->Interval].Columns[WhichCell->Column].DurationIntervals;
i < Timetable->Config.IntervalsPerDay; i < Timetable->Config.IntervalsPerDay;
i++) i++)
if (Tmt_TimeTable[Weekday][i].NumColumns == Tmt_MAX_COLUMNS_PER_CELL) if (Tmt_TimeTable[WhichCell->Weekday][i].NumColumns == Tmt_MAX_COLUMNS_PER_CELL)
break; break;
MaxDuration = i - Interval; MaxDuration = i - WhichCell->Interval;
if (Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals > MaxDuration) if (Tmt_TimeTable[WhichCell->Weekday][WhichCell->Interval].Columns[WhichCell->Column].DurationIntervals > MaxDuration)
MaxDuration = Tmt_TimeTable[Weekday][Interval].Columns[Column].DurationIntervals; MaxDuration = Tmt_TimeTable[WhichCell->Weekday][WhichCell->Interval].Columns[WhichCell->Column].DurationIntervals;
for (Dur = 0; for (Dur = 0;
Dur <= MaxDuration; Dur <= MaxDuration;
Dur++) Dur++)
{ {

View File

@ -36,12 +36,13 @@
#define Tmt_MAX_CHARS_INFO (128 - 1) // 127 #define Tmt_MAX_CHARS_INFO (128 - 1) // 127
#define Tmt_MAX_BYTES_INFO ((Tmt_MAX_CHARS_INFO + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047 #define Tmt_MAX_BYTES_INFO ((Tmt_MAX_CHARS_INFO + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 2047
#define Tmt_NUM_VIEW_EDIT 4
typedef enum typedef enum
{ {
Tmt_CRS_VIEW, Tmt_CRS_VIEW = 0, // course view
Tmt_TUT_VIEW, Tmt_TUT_VIEW = 1, // tutorials view
Tmt_CRS_EDIT, Tmt_CRS_EDIT = 2, // course edit
Tmt_TUT_EDIT, Tmt_TUT_EDIT = 3, // tutorials edit
} Tmt_TimeTableView_t; } Tmt_TimeTableView_t;
#define Tmt_NUM_TIMETABLE_TYPES 3 #define Tmt_NUM_TIMETABLE_TYPES 3
@ -78,6 +79,13 @@ struct Tmt_Range
unsigned MinutesPerInterval; // 5, 15 or 30 minutes unsigned MinutesPerInterval; // 5, 15 or 30 minutes
}; };
struct Tmt_WhichCell
{
unsigned Weekday;
unsigned Interval;
unsigned Column;
};
struct Tmt_Timetable struct Tmt_Timetable
{ {
struct struct
@ -91,9 +99,7 @@ struct Tmt_Timetable
} Config; } Config;
Tmt_TimeTableType_t Type; Tmt_TimeTableType_t Type;
Tmt_TimeTableView_t View; Tmt_TimeTableView_t View;
unsigned Weekday; struct Tmt_WhichCell WhichCell;
unsigned Interval;
unsigned Column;
Tmt_ClassType_t ClassType; Tmt_ClassType_t ClassType;
unsigned DurationIntervals; unsigned DurationIntervals;
char Info[Tmt_MAX_BYTES_INFO + 1]; char Info[Tmt_MAX_BYTES_INFO + 1];