From 0cd2ceb4c5a11ad1ac532b053a1b415178933278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 25 Apr 2017 02:07:32 +0200 Subject: [PATCH] Version 16.189 --- css/{swad16.185.3.css => swad16.189.css} | 10 +-- sql/swad.sql | 14 ++-- swad_changelog.h | 15 +++- swad_database.c | 66 +++++---------- swad_timetable.c | 102 +++++++++++++---------- 5 files changed, 104 insertions(+), 103 deletions(-) rename css/{swad16.185.3.css => swad16.189.css} (99%) diff --git a/css/swad16.185.3.css b/css/swad16.189.css similarity index 99% rename from css/swad16.185.3.css rename to css/swad16.189.css index 14279da0..9d2bc3b8 100644 --- a/css/swad16.185.3.css +++ b/css/swad16.189.css @@ -2364,7 +2364,7 @@ a:hover img.CENTRE_PHOTO_SHOW font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#345C6C; font-size:10pt; - line-height:110%; + line-height:100%; letter-spacing:0; } .TT_DAY @@ -2385,17 +2385,17 @@ a:hover img.CENTRE_PHOTO_SHOW { font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#404040; - font-size:14pt; + font-size:13pt; font-weight:bold; - line-height:110%; + line-height:100%; letter-spacing:0; } .TT_HOUR_SMALL { font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#A0A0A0; - font-size:10pt; - line-height:110%; + font-size:8pt; + line-height:100%; letter-spacing:0; } .TT_HOUR {height:16px;} diff --git a/sql/swad.sql b/sql/swad.sql index 69f8f860..6eb44c62 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -1061,10 +1061,10 @@ CREATE TABLE IF NOT EXISTS svy_users ( CREATE TABLE IF NOT EXISTS timetable_crs ( CrsCod INT NOT NULL DEFAULT -1, GrpCod INT NOT NULL DEFAULT -1, - Day ENUM('L','M','X','J','V','S','D') NOT NULL, - Hour TINYINT NOT NULL, - Duration TINYINT NOT NULL, - ClassType ENUM('libre','teoria','practicas') NOT NULL, + Weekday TINYINT NOT NULL, + StartTime TIME NOT NULL, + Duration TIME NOT NULL, + ClassType ENUM('free','lecture','practical') NOT NULL, Place VARCHAR(511) NOT NULL, GroupName VARCHAR(2047) NOT NULL, INDEX(CrsCod,GrpCod)); @@ -1073,9 +1073,9 @@ CREATE TABLE IF NOT EXISTS timetable_crs ( -- CREATE TABLE IF NOT EXISTS timetable_tut ( UsrCod INT NOT NULL, - Day ENUM('L','M','X','J','V','S','D') NOT NULL, - Hour TINYINT NOT NULL, - Duration TINYINT NOT NULL, + Weekday TINYINT NOT NULL, + StartTime TIME NOT NULL, + Duration TIME NOT NULL, Place VARCHAR(511) NOT NULL, INDEX(UsrCod)); -- diff --git a/swad_changelog.h b/swad_changelog.h index 34fafcbf..d9860f28 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -219,13 +219,24 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.188 (2017-04-24)" -#define CSS_FILE "swad16.185.3.css" +#define Log_PLATFORM_VERSION "SWAD 16.189 (2017-04-25)" +#define CSS_FILE "swad16.189.css" #define JS_FILE "swad16.181.js" // 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 /* + Version 16.189: Apr 25, 2017 Changes in timetable. (218027 lines) + 7 changes necessary in database. +ALTER TABLE timetable_crs DROP COLUMN DayOld; +ALTER TABLE timetable_crs DROP COLUMN HourOld; +ALTER TABLE timetable_crs DROP COLUMN DurationOld; +ALTER TABLE timetable_crs DROP COLUMN ClassTypeOld; + +ALTER TABLE timetable_tut DROP COLUMN DayOld; +ALTER TABLE timetable_tut DROP COLUMN HourOld; +ALTER TABLE timetable_tut DROP COLUMN DurationOld; + Version 16.188: Apr 24, 2017 Changes in timetable. Not finished. (218029 lines) Version 16.187.3: Apr 24, 2017 Changes in timetable. Not finished. (218040 lines) Version 16.187.2: Apr 24, 2017 Changes in timetable. Not finished. (217963 lines) diff --git a/swad_database.c b/swad_database.c index 2aa3da31..f009e9f8 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2245,38 +2245,27 @@ mysql> DESCRIBE svy_users; /***** Table timetable_crs *****/ /* mysql> DESCRIBE timetable_crs; -+--------------+------------------------------------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+--------------+------------------------------------+------+-----+---------+-------+ -| CrsCod | int(11) | NO | MUL | -1 | | -| GrpCod | int(11) | NO | | -1 | | -| Weekday | tinyint(4) | NO | | NULL | | -| StartTime | time | NO | | NULL | | -| Duration | time | NO | | NULL | | -| ClassType | enum('free','lecture','practical') | NO | | NULL | | -| DayOld | enum('L','M','X','J','V','S','D') | NO | | NULL | | -| HourOld | tinyint(4) | NO | | NULL | | -| DurationOld | tinyint(4) | NO | | NULL | | -| ClassTypeOld | enum('libre','teoria','practicas') | NO | | NULL | | -| Place | varchar(511) | NO | | NULL | | -| GroupName | varchar(2047) | NO | | NULL | | -+--------------+------------------------------------+------+-----+---------+-------+ -12 rows in set (0,00 sec) ++-----------+------------------------------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-----------+------------------------------------+------+-----+---------+-------+ +| CrsCod | int(11) | NO | MUL | -1 | | +| GrpCod | int(11) | NO | | -1 | | +| Weekday | tinyint(4) | NO | | NULL | | +| StartTime | time | NO | | NULL | | +| Duration | time | NO | | NULL | | +| ClassType | enum('free','lecture','practical') | NO | | NULL | | +| Place | varchar(511) | NO | | NULL | | +| GroupName | varchar(2047) | NO | | NULL | | ++-----------+------------------------------------+------+-----+---------+-------+ +8 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS timetable_crs (" "CrsCod INT NOT NULL DEFAULT -1," "GrpCod INT NOT NULL DEFAULT -1," - "Weekday TINYINT NOT NULL," // 0=Monday...6=Sunday "StartTime TIME NOT NULL," "Duration TIME NOT NULL," "ClassType ENUM('free','lecture','practical') NOT NULL," - - "DayOld ENUM('L','M','X','J','V','S','D') NOT NULL," - "HourOld TINYINT NOT NULL," - "DurationOld TINYINT NOT NULL," - "ClassTypeOld ENUM('libre','teoria','practicas') NOT NULL," - "Place VARCHAR(511) NOT NULL," // TT_MAX_BYTES_PLACE "GroupName VARCHAR(2047) NOT NULL," // Grp_MAX_BYTES_GROUP_NAME "INDEX(CrsCod,GrpCod))"); @@ -2284,31 +2273,22 @@ mysql> DESCRIBE timetable_crs; /***** Table timetable_tut *****/ /* mysql> DESCRIBE timetable_tut; -+-------------+-----------------------------------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+-------------+-----------------------------------+------+-----+---------+-------+ -| UsrCod | int(11) | NO | MUL | NULL | | -| Weekday | tinyint(4) | NO | | NULL | | -| StartTime | time | NO | | NULL | | -| Duration | time | NO | | NULL | | -| DayOld | enum('L','M','X','J','V','S','D') | NO | | NULL | | -| HourOld | tinyint(4) | NO | | NULL | | -| DurationOld | tinyint(4) | NO | | NULL | | -| Place | varchar(511) | NO | | NULL | | -+-------------+-----------------------------------+------+-----+---------+-------+ -8 rows in set (0,01 sec) ++-----------+--------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++-----------+--------------+------+-----+---------+-------+ +| UsrCod | int(11) | NO | MUL | NULL | | +| Weekday | tinyint(4) | NO | | NULL | | +| StartTime | time | NO | | NULL | | +| Duration | time | NO | | NULL | | +| Place | varchar(511) | NO | | NULL | | ++-----------+--------------+------+-----+---------+-------+ +5 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS timetable_tut (" "UsrCod INT NOT NULL," - "Weekday TINYINT NOT NULL," // 0=Monday...6=Sunday "StartTime TIME NOT NULL," "Duration TIME NOT NULL," - - "DayOld ENUM('L','M','X','J','V','S','D') NOT NULL," - "HourOld TINYINT NOT NULL," - "DurationOld TINYINT NOT NULL," - "Place VARCHAR(511) NOT NULL," // TT_MAX_BYTES_PLACE "INDEX(UsrCod))"); diff --git a/swad_timetable.c b/swad_timetable.c index 116194c1..f184d3d5 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -184,7 +184,7 @@ static void TT_GetParamsTimeTable (void) Gbl.TimeTable.Interval = (unsigned) Par_GetParToUnsignedLong ("ModTTHour", 0, - TT_HOURS_PER_DAY * 2 - 1, + TT_INTERVALS_PER_DAY - 1, 0); /***** Get number of column *****/ @@ -615,7 +615,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) case Grp_ONLY_MY_GROUPS: sprintf (Query,"SELECT " "timetable_crs.Weekday," - "TIME_TO_SEC(timetable_crs.StartTime)," + "TIME_TO_SEC(timetable_crs.StartTime) AS S," "TIME_TO_SEC(timetable_crs.Duration) AS D," "timetable_crs.Place," "timetable_crs.ClassType," @@ -629,7 +629,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) " UNION DISTINCT " "SELECT " "timetable_crs.Weekday," - "TIME_TO_SEC(timetable_crs.StartTime)," + "TIME_TO_SEC(timetable_crs.StartTime) AS S," "TIME_TO_SEC(timetable_crs.Duration) AS D," "timetable_crs.Place," "timetable_crs.ClassType," @@ -642,7 +642,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) " UNION " "SELECT " "Weekday," - "TIME_TO_SEC(StartTime)," + "TIME_TO_SEC(StartTime) AS S," "TIME_TO_SEC(Duration) AS D," "Place," "'tutoring' AS ClassType," @@ -651,14 +651,14 @@ static void TT_CreatTimeTableFromDB (long UsrCod) "-1 AS CrsCod" " FROM timetable_tut" " WHERE UsrCod=%ld" - " ORDER BY Weekday,StartTime,ClassType," + " ORDER BY Weekday,S,ClassType," "GroupName,GrpCod,Place,D DESC,CrsCod", UsrCod,UsrCod,UsrCod); break; case Grp_ALL_GROUPS: sprintf (Query,"SELECT " "timetable_crs.Weekday," - "TIME_TO_SEC(timetable_crs.StartTime)," + "TIME_TO_SEC(timetable_crs.StartTime) AS S," "TIME_TO_SEC(timetable_crs.Duration) AS D," "timetable_crs.Place," "timetable_crs.ClassType," @@ -671,7 +671,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) " UNION " "SELECT " "Weekday," - "TIME_TO_SEC(StartTime)," + "TIME_TO_SEC(StartTime) AS S," "TIME_TO_SEC(Duration) AS D," "Place," "'tutoring' AS ClassType," @@ -680,7 +680,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) "-1 AS CrsCod" " FROM timetable_tut" " WHERE UsrCod=%ld" - " ORDER BY Weekday,StartTime,ClassType," + " ORDER BY Weekday,S,ClassType," "GroupName,GrpCod,Place,D DESC,CrsCod", UsrCod,UsrCod); break; @@ -692,7 +692,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) Gbl.Action.Act == ActChgCrsTT) // If we are editing, all groups are shown sprintf (Query,"SELECT " "Weekday," - "TIME_TO_SEC(StartTime)," + "TIME_TO_SEC(StartTime) AS S," "TIME_TO_SEC(Duration) AS D," "Place," "ClassType," @@ -700,13 +700,13 @@ static void TT_CreatTimeTableFromDB (long UsrCod) "GrpCod" " FROM timetable_crs" " WHERE CrsCod=%ld" - " ORDER BY Weekday,StartTime,ClassType," + " ORDER BY Weekday,S,ClassType," "GroupName,GrpCod,Place,D DESC", Gbl.CurrentCrs.Crs.CrsCod); else sprintf (Query,"SELECT " "timetable_crs.Weekday," - "TIME_TO_SEC(timetable_crs.StartTime)," + "TIME_TO_SEC(timetable_crs.StartTime) AS S," "TIME_TO_SEC(timetable_crs.Duration) AS D," "timetable_crs.Place," "timetable_crs.ClassType," @@ -718,7 +718,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) " AND timetable_crs.CrsCod=crs_usr.CrsCod" " UNION DISTINCT " "SELECT timetable_crs.Weekday," - "TIME_TO_SEC(timetable_crs.StartTime)," + "TIME_TO_SEC(timetable_crs.StartTime) AS S," "TIME_TO_SEC(timetable_crs.Duration) AS D," "timetable_crs.Place," "timetable_crs.ClassType," @@ -728,7 +728,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) " WHERE timetable_crs.CrsCod=%ld" " AND crs_grp_usr.UsrCod=%ld" " AND timetable_crs.GrpCod=crs_grp_usr.GrpCod" - " ORDER BY Weekday,StartTime,ClassType," + " ORDER BY Weekday,S,ClassType," "GroupName,GrpCod,Place,D DESC", Gbl.CurrentCrs.Crs.CrsCod,UsrCod, Gbl.CurrentCrs.Crs.CrsCod,UsrCod); @@ -736,12 +736,12 @@ static void TT_CreatTimeTableFromDB (long UsrCod) case TT_TUTORING_TIMETABLE: sprintf (Query,"SELECT " "Weekday," - "TIME_TO_SEC(StartTime)," + "TIME_TO_SEC(StartTime) AS S," "TIME_TO_SEC(Duration) AS D," "Place" " FROM timetable_tut" " WHERE UsrCod=%ld" - " ORDER BY Weekday,StartTime,Place,D DESC", + " ORDER BY Weekday,S,Place,D DESC", UsrCod); break; } @@ -761,17 +761,18 @@ static void TT_CreatTimeTableFromDB (long UsrCod) GrpCod = -1; /* Day of week (row[0]) */ - if (sscanf (row[0],"%u",&Weekday) == 1) - if (Weekday >= TT_DAYS_PER_WEEK) - Lay_ShowErrorAndExit ("Wrong day of week in timetable."); + if (sscanf (row[0],"%u",&Weekday) != 1) + Lay_ShowErrorAndExit ("Wrong day of week in timetable."); + if (Weekday >= TT_DAYS_PER_WEEK) + Lay_ShowErrorAndExit ("Wrong day of week in timetable."); /* StartTime formatted as seconds (row[1]) --> StartTime in number of intervals */ if (sscanf (row[1],"%u",&Seconds) != 1) - Lay_ShowErrorAndExit ("Wrong hour in timetable."); - Interval = Seconds / TT_SECONDS_PER_MINUTE; + Lay_ShowErrorAndExit ("Wrong start time in timetable."); + Interval = Seconds / TT_SECONDS_PER_INTERVAL; if (Interval < TT_INTERVALS_BEFORE_START_HOUR) - Lay_ShowErrorAndExit ("Wrong hour in timetable."); + Lay_ShowErrorAndExit ("Wrong start time in timetable."); Interval -= TT_INTERVALS_BEFORE_START_HOUR; /* Duration formatted as seconds (row[2]) @@ -815,6 +816,7 @@ static void TT_CreatTimeTableFromDB (long UsrCod) FirstFreeColumn = Column; break; } + if (FirstFreeColumn < TT_MAX_COLUMNS_PER_CELL) // If there's place for another column in this cell { @@ -834,10 +836,10 @@ static void TT_CreatTimeTableFromDB (long UsrCod) { TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].ClassType = ClassType; TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].DurationNumIntervals = DurationNumIntervals; - TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].IntervalType = TT_FIRST_INTERVAL; + TT_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].IntervalType = TT_FIRST_INTERVAL; for (I = Interval + 1; I < Interval + DurationNumIntervals && - I < TT_HOURS_PER_DAY * 2; + I < TT_INTERVALS_PER_DAY; I++) { TT_TimeTable[Weekday][I].Columns[FirstFreeColumn].IntervalType = TT_NEXT_INTERVAL; @@ -1006,7 +1008,8 @@ static void TT_DrawTimeTable (void) Weekday = (DayColumn + Gbl.Prefs.FirstDayOfWeek) % 7; /* Check how many colums are needed. - For each item (class) in this hour from left to right, we must check the maximum of columns */ + For each item (class) in this hour from left to right, + we must check the maximum of columns */ for (I = 0; I < TT_INTERVALS_PER_DAY; I++) @@ -1332,11 +1335,14 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co /***** Draw cell depending on type of view *****/ switch (TimeTableView) { - case TT_CRS_SHOW: - case TT_TUT_SHOW: + case TT_CRS_SHOW: // View course timetable + case TT_TUT_SHOW: // View tutoring timetable if (IntervalType != TT_FREE_INTERVAL) // If cell is not empty... { + /***** Start cell *****/ fprintf (Gbl.F.Out,"
"); + + /***** Course name *****/ if (Gbl.TimeTable.Type == TT_MY_TIMETABLE) { Crs.CrsCod = CrsCod; @@ -1347,14 +1353,17 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co Crs.ShrtName[0] ? Crs.ShrtName : Txt_unknown_removed_course); } - fprintf (Gbl.F.Out,"%s (%dh%s)", + + /***** Type of class and duration *****/ + fprintf (Gbl.F.Out,"%s (%u:%02u h)", Txt_TIMETABLE_CLASS_TYPES[ClassType], - DurationNumIntervals / 2, - DurationNumIntervals % 2 ? "30'" : - ""); + (DurationNumIntervals / TT_INTERVALS_PER_HOUR), // Hours + (DurationNumIntervals % TT_INTERVALS_PER_HOUR) * TT_MINUTES_PER_INTERVAL); // Minutes + + /***** Group *****/ if (TimeTableView == TT_CRS_SHOW) { - if (GrpCod == -1) + if (GrpCod <= 0) { if (Group[0]) fprintf (Gbl.F.Out,"
%s",Group); @@ -1362,12 +1371,13 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co else fprintf (Gbl.F.Out,"
%s %s", GrpDat.GrpTypName,GrpDat.GrpName); - if (Place[0]) - fprintf (Gbl.F.Out,"
%s",Place); } - else // TimeTableView == TT_TUT_SHOW - if (Place[0]) - fprintf (Gbl.F.Out,"
%s",Place); + + /***** Place *****/ + if (Place[0]) + fprintf (Gbl.F.Out,"
%s",Place); + + /***** End cell *****/ fprintf (Gbl.F.Out,"
"); } break; @@ -1396,20 +1406,21 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co Txt_TIMETABLE_CLASS_TYPES[CT]); } fprintf (Gbl.F.Out,""); + if (IntervalType == TT_FREE_INTERVAL) { fprintf (Gbl.F.Out," 1) - fprintf (Gbl.F.Out,"1:00"); - else - fprintf (Gbl.F.Out,"0:30"); - fprintf (Gbl.F.Out," h\" />"); + Dur = (MaxDuration >= TT_INTERVALS_PER_HOUR) ? TT_INTERVALS_PER_HOUR : // MaxDuration >= 1h ==> Dur = 1h + MaxDuration; // MaxDuration < 1h ==> Dur = MaxDuration + fprintf (Gbl.F.Out,"%u:%02u h\" />", + (Dur / TT_INTERVALS_PER_HOUR), // Hours + (Dur % TT_INTERVALS_PER_HOUR) * TT_MINUTES_PER_INTERVAL); // Minutes } else { @@ -1418,7 +1429,7 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co " onchange=\"document.getElementById('%s').submit();\">", Gbl.Form.Id); for (I = Interval + TT_TimeTable[Weekday][Interval].Columns[Column].DurationNumIntervals; - I < TT_HOURS_PER_DAY * 2; + I < TT_INTERVALS_PER_DAY; I++) if (TT_TimeTable[Weekday][I].NumColumns == TT_MAX_COLUMNS_PER_CELL) break; @@ -1433,9 +1444,8 @@ static void TT_TimeTableDrawCell (unsigned Weekday,unsigned Interval,unsigned Co if (Dur == DurationNumIntervals) fprintf (Gbl.F.Out," selected=\"selected\""); fprintf (Gbl.F.Out,">%u:%02u h", - Dur / 2, - Dur % 2 ? 30 : - 0); + (Dur / TT_INTERVALS_PER_HOUR), // Hours + (Dur % TT_INTERVALS_PER_HOUR) * TT_MINUTES_PER_INTERVAL); // Minutes } fprintf (Gbl.F.Out,"");