Version 16.192.1

This commit is contained in:
Antonio Cañas Vargas 2017-04-25 21:42:29 +02:00
parent 675b1236a9
commit e2f30749f8
4 changed files with 50 additions and 54 deletions

View File

@ -219,14 +219,15 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.192 (2017-04-25)" #define Log_PLATFORM_VERSION "SWAD 16.192.1 (2017-04-25)"
#define CSS_FILE "swad16.192.css" #define CSS_FILE "swad16.192.css"
#define JS_FILE "swad16.181.js" #define JS_FILE "swad16.181.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/* /*
Version 16.192: Apr 25, 2017 Changes in layout and code refactoring in timetable. (? lines) Version 16.192.1: Apr 25, 2017 Code refactoring in timetable. (218258 lines)
Version 16.192: Apr 25, 2017 Changes in layout and code refactoring in timetable. (218262 lines)
Version 16.191: Apr 25, 2017 Changes in layout of timetable. (218183 lines) Version 16.191: Apr 25, 2017 Changes in layout of timetable. (218183 lines)
Version 16.190: Apr 25, 2017 Code refactoring in timetable. (218106 lines) Version 16.190: Apr 25, 2017 Code refactoring in timetable. (218106 lines)
Version 16.189: Apr 25, 2017 Changes in timetable. (218027 lines) Version 16.189: Apr 25, 2017 Changes in timetable. (218027 lines)

View File

@ -632,7 +632,8 @@ struct Globals
unsigned IntervalsBeforeStartHour; unsigned IntervalsBeforeStartHour;
} Config; } Config;
TT_TimeTableType_t Type; TT_TimeTableType_t Type;
bool Editing; TT_TimeTableView_t View;
// bool Editing;
unsigned Weekday; unsigned Weekday;
unsigned Interval; unsigned Interval;
unsigned Column; unsigned Column;

View File

@ -504,22 +504,28 @@ void TT_ShowTimeTable (long UsrCod)
{ {
extern const char *Txt_The_timetable_is_empty; extern const char *Txt_The_timetable_is_empty;
/***** Editing or viewing? *****/ /***** Set type of view depending on current action *****/
Gbl.TimeTable.View = TT_CRS_VIEW;
switch (Gbl.Action.Act) switch (Gbl.Action.Act)
{ {
case ActSeeCrsTT: case ActPrnCrsTT: case ActChgCrsTT1stDay: case ActSeeCrsTT: case ActPrnCrsTT: case ActChgCrsTT1stDay:
case ActSeeMyTT: case ActPrnMyTT: case ActChgMyTT1stDay: case ActSeeMyTT: case ActPrnMyTT: case ActChgMyTT1stDay:
Gbl.TimeTable.View = TT_CRS_VIEW;
break;
case ActSeeRecOneTch: case ActSeeRecSevTch: case ActSeeRecOneTch: case ActSeeRecSevTch:
Gbl.TimeTable.Editing = false; Gbl.TimeTable.View = TT_TUT_VIEW;
break; break;
case ActEdiCrsTT: case ActChgCrsTT: case ActEdiCrsTT: case ActChgCrsTT:
Gbl.TimeTable.View = TT_CRS_EDIT;
break;
case ActEdiTut: case ActChgTut: case ActEdiTut: case ActChgTut:
Gbl.TimeTable.Editing = true; Gbl.TimeTable.View = TT_TUT_EDIT;
break; break;
} }
/***** If editing ==> configure and allocate timetable *****/ /***** If editing ==> configure and allocate timetable *****/
if (Gbl.TimeTable.Editing) if (Gbl.TimeTable.View == TT_CRS_EDIT ||
Gbl.TimeTable.View == TT_TUT_EDIT)
{ {
Gbl.TimeTable.Config.Range.Hours.Start = TT_START_HOUR; // Day starts at this hour Gbl.TimeTable.Config.Range.Hours.Start = TT_START_HOUR; // Day starts at this hour
Gbl.TimeTable.Config.Range.Hours.End = TT_END_HOUR; // Day ends at this hour Gbl.TimeTable.Config.Range.Hours.End = TT_END_HOUR; // Day ends at this hour
@ -842,7 +848,8 @@ static void TT_FillTimeTableFromDB (long UsrCod)
/***** If viewing (not editing) ==> /***** If viewing (not editing) ==>
calculate range of hours and resolution *****/ calculate range of hours and resolution *****/
if (!Gbl.TimeTable.Editing) if (Gbl.TimeTable.View == TT_CRS_VIEW ||
Gbl.TimeTable.View == TT_TUT_VIEW)
{ {
/* Initialize hours and resolution for timetable */ /* Initialize hours and resolution for timetable */
Gbl.TimeTable.Config.Range.Hours.Start = TT_END_HOUR; // Initialized to maximum hour Gbl.TimeTable.Config.Range.Hours.Start = TT_END_HOUR; // Initialized to maximum hour
@ -1225,12 +1232,16 @@ static void TT_DrawTimeTable (void)
we must check the maximum of columns */ we must check the maximum of columns */
ColumnsToDraw = TT_CalculateColsToDrawInCell (true, // Top call, non recursive ColumnsToDraw = TT_CalculateColsToDrawInCell (true, // Top call, non recursive
Weekday,Interval); Weekday,Interval);
if (!Gbl.TimeTable.Editing && ColumnsToDraw == 0) if (ColumnsToDraw == 0 &&
(Gbl.TimeTable.View == TT_CRS_VIEW ||
Gbl.TimeTable.View == TT_TUT_VIEW))
ColumnsToDraw = 1; ColumnsToDraw = 1;
// If editing and there's place for more columns, // If editing and there's place for more columns,
// a potential new column is added at the end of each day // a potential new column is added at the end of each day
ColumnsToDrawIncludingExtraColumn = ColumnsToDraw; ColumnsToDrawIncludingExtraColumn = ColumnsToDraw;
if (Gbl.TimeTable.Editing && ColumnsToDraw < TT_MAX_COLUMNS_PER_CELL) if (ColumnsToDraw < TT_MAX_COLUMNS_PER_CELL &&
(Gbl.TimeTable.View == TT_CRS_EDIT ||
Gbl.TimeTable.View == TT_TUT_EDIT))
ColumnsToDrawIncludingExtraColumn++; ColumnsToDrawIncludingExtraColumn++;
/* Draw cells */ /* Draw cells */
@ -1466,18 +1477,11 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
extern const char *Txt_Place; extern const char *Txt_Place;
static const char *TimeTableClasses[TT_NUM_CLASS_TYPES] = static const char *TimeTableClasses[TT_NUM_CLASS_TYPES] =
{ {
"TT_FREE", // Free hour "TT_FREE", // TT_FREE (free hour)
"TT_LECT", // Theoretical class "TT_LECT", // TT_LECTURE (lecture class)
"TT_PRAC", // Practical class "TT_PRAC", // TT_PRACTICAL (practical class)
"TT_TUTO" // Tutorials "TT_TUTO", // TT_TUTORING (tutoring/office hour)
}; };
enum
{
TT_CRS_SHOW,
TT_CRS_EDIT,
TT_TUT_SHOW,
TT_TUT_EDIT,
} TimeTableView = TT_CRS_SHOW;
struct GroupData GrpDat; struct GroupData GrpDat;
unsigned NumGrpTyp; unsigned NumGrpTyp;
unsigned NumGrp; unsigned NumGrp;
@ -1505,28 +1509,10 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
if (RowSpan == 0) if (RowSpan == 0)
return; return;
/***** Set type of view depending on current action *****/
switch (Gbl.Action.Act)
{
case ActSeeCrsTT: case ActPrnCrsTT: case ActChgCrsTT1stDay:
case ActSeeMyTT: case ActPrnMyTT: case ActChgMyTT1stDay:
TimeTableView = TT_CRS_SHOW;
break;
case ActEdiCrsTT: case ActChgCrsTT:
TimeTableView = TT_CRS_EDIT;
break;
case ActSeeRecOneTch: case ActSeeRecSevTch:
TimeTableView = TT_TUT_SHOW;
break;
case ActEdiTut: case ActChgTut:
TimeTableView = TT_TUT_EDIT;
break;
}
/***** If group code > 0, a group is selected ==> get group type and name *****/ /***** If group code > 0, a group is selected ==> get group type and name *****/
if (IntervalType == TT_FIRST_INTERVAL && if (IntervalType == TT_FIRST_INTERVAL &&
(TimeTableView == TT_CRS_SHOW || (Gbl.TimeTable.View == TT_CRS_VIEW ||
TimeTableView == TT_CRS_EDIT) && Gbl.TimeTable.View == TT_CRS_EDIT) &&
GrpCod > 0) GrpCod > 0)
{ {
/* Get group type and name */ /* Get group type and name */
@ -1548,16 +1534,16 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
fprintf (Gbl.F.Out,"\">"); fprintf (Gbl.F.Out,"\">");
/***** Form to modify this cell *****/ /***** Form to modify this cell *****/
if (TimeTableView == TT_CRS_EDIT) if (Gbl.TimeTable.View == TT_CRS_EDIT)
Act_FormStart (ActChgCrsTT); Act_FormStart (ActChgCrsTT);
else if (TimeTableView == TT_TUT_EDIT) else if (Gbl.TimeTable.View == TT_TUT_EDIT)
Act_FormStart (ActChgTut); Act_FormStart (ActChgTut);
/***** Draw cell depending on type of view *****/ /***** Draw cell depending on type of view *****/
switch (TimeTableView) switch (Gbl.TimeTable.View)
{ {
case TT_CRS_SHOW: // View course timetable case TT_CRS_VIEW: // View course timetable
case TT_TUT_SHOW: // View tutoring timetable case TT_TUT_VIEW: // View tutoring timetable
if (IntervalType != TT_FREE_INTERVAL) // If cell is not empty... if (IntervalType != TT_FREE_INTERVAL) // If cell is not empty...
{ {
/***** Start cell *****/ /***** Start cell *****/
@ -1583,7 +1569,7 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
Gbl.TimeTable.Config.Range.MinutesPerInterval); // Minutes Gbl.TimeTable.Config.Range.MinutesPerInterval); // Minutes
/***** Group *****/ /***** Group *****/
if (TimeTableView == TT_CRS_SHOW) if (Gbl.TimeTable.View == TT_CRS_VIEW)
{ {
if (GrpCod <= 0) if (GrpCod <= 0)
{ {
@ -1617,8 +1603,8 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
CT < (TT_ClassType_t) TT_NUM_CLASS_TYPES; CT < (TT_ClassType_t) TT_NUM_CLASS_TYPES;
CT++) CT++)
if ((CT == TT_FREE) || if ((CT == TT_FREE) ||
((TimeTableView == TT_CRS_EDIT) && (CT == TT_LECTURE || CT == TT_PRACTICAL)) || ((Gbl.TimeTable.View == TT_CRS_EDIT) && (CT == TT_LECTURE || CT == TT_PRACTICAL)) ||
((TimeTableView == TT_TUT_EDIT) && (CT == TT_TUTORING))) ((Gbl.TimeTable.View == TT_TUT_EDIT) && (CT == TT_TUTORING)))
{ {
fprintf (Gbl.F.Out,"<option"); fprintf (Gbl.F.Out,"<option");
if (CT == ClassType) if (CT == ClassType)
@ -1673,7 +1659,7 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
} }
fprintf (Gbl.F.Out,"</select>"); fprintf (Gbl.F.Out,"</select>");
if (TimeTableView == TT_CRS_EDIT) if (Gbl.TimeTable.View == TT_CRS_EDIT)
{ {
/***** Group *****/ /***** Group *****/
fprintf (Gbl.F.Out,"<br />" fprintf (Gbl.F.Out,"<br />"
@ -1732,8 +1718,8 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co
} }
/***** End of form *****/ /***** End of form *****/
if (TimeTableView == TT_CRS_EDIT || if (Gbl.TimeTable.View == TT_CRS_EDIT ||
TimeTableView == TT_TUT_EDIT) Gbl.TimeTable.View == TT_TUT_EDIT)
Act_FormEnd (); Act_FormEnd ();
/***** End of cell *****/ /***** End of cell *****/

View File

@ -36,6 +36,14 @@
#define TT_MAX_CHARS_PLACE (32 - 1) // 31 #define TT_MAX_CHARS_PLACE (32 - 1) // 31
#define TT_MAX_BYTES_PLACE ((TT_MAX_CHARS_PLACE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511 #define TT_MAX_BYTES_PLACE ((TT_MAX_CHARS_PLACE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 511
typedef enum
{
TT_CRS_VIEW,
TT_TUT_VIEW,
TT_CRS_EDIT,
TT_TUT_EDIT,
} TT_TimeTableView_t;
#define TT_NUM_TIMETABLE_TYPES 3 #define TT_NUM_TIMETABLE_TYPES 3
typedef enum typedef enum
{ {