Version19.41

This commit is contained in:
Antonio Cañas Vargas 2019-10-22 23:42:22 +02:00
parent 223907b7f4
commit 8822f87c6b
5 changed files with 75 additions and 20 deletions

View File

@ -640,6 +640,7 @@ CREATE TABLE IF NOT EXISTS mch_matches (
QstInd INT NOT NULL DEFAULT 0, QstInd INT NOT NULL DEFAULT 0,
QstCod INT NOT NULL DEFAULT -1, QstCod INT NOT NULL DEFAULT -1,
Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing', Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing',
NumCols INT NOT NULL DEFAULT 1,
ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N', ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N',
ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N', ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N',
UNIQUE INDEX(MchCod), UNIQUE INDEX(MchCod),

View File

@ -487,7 +487,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.40.5 (2019-10-22)" #define Log_PLATFORM_VERSION "SWAD 19.41 (2019-10-22)"
#define CSS_FILE "swad19.40.3.css" #define CSS_FILE "swad19.40.3.css"
#define JS_FILE "swad19.39.js" #define JS_FILE "swad19.39.js"
/* /*
@ -495,7 +495,11 @@ ps2pdf source.ps destination.pdf
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.) // TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.)
// TODO: Change icon to upload file in timeline to photo-video.svg // TODO: Change icon to upload file in timeline to photo-video.svg
Version 19.40.5: Oct 22, 2019 New icons to view match in two columns. (245882 lines) Version 19.41: Oct 22, 2019 Number of columns in match is stored in database. (245930 lines)
1 change necessary in database:
ALTER TABLE mch_matches ADD COLUMN NumCols INT NOT NULL DEFAULT 1 AFTER Showing;
Version 19.40.5: Oct 22, 2019 New icons to view match in several columns. (245882 lines)
Copy the following 3 icons to icon public directory: Copy the following 3 icons to icon public directory:
sudo cp -a icon/bars.svg /var/www/html/swad/icon/ sudo cp -a icon/bars.svg /var/www/html/swad/icon/
sudo cp -a icon/grip-vertical.svg /var/www/html/swad/icon/ sudo cp -a icon/grip-vertical.svg /var/www/html/swad/icon/

View File

@ -1383,10 +1383,11 @@ mysql> DESCRIBE mch_matches;
| QstInd | int(11) | NO | | 0 | | | QstInd | int(11) | NO | | 0 | |
| QstCod | int(11) | NO | | -1 | | | QstCod | int(11) | NO | | -1 | |
| Showing | enum('nothing','stem','answers','results') | NO | | nothing | | | Showing | enum('nothing','stem','answers','results') | NO | | nothing | |
| NumCols | int(11) | NO | | 1 | |
| ShowQstResults | enum('N','Y') | NO | | N | | | ShowQstResults | enum('N','Y') | NO | | N | |
| ShowUsrResults | enum('N','Y') | NO | | N | | | ShowUsrResults | enum('N','Y') | NO | | N | |
+----------------+--------------------------------------------+------+-----+---------+----------------+ +----------------+--------------------------------------------+------+-----+---------+----------------+
11 rows in set (0.00 sec) 12 rows in set (0.01 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS mch_matches (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS mch_matches ("
"MchCod INT NOT NULL AUTO_INCREMENT," "MchCod INT NOT NULL AUTO_INCREMENT,"
@ -1398,6 +1399,7 @@ mysql> DESCRIBE mch_matches;
"QstInd INT NOT NULL DEFAULT 0," "QstInd INT NOT NULL DEFAULT 0,"
"QstCod INT NOT NULL DEFAULT -1," "QstCod INT NOT NULL DEFAULT -1,"
"Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing'," "Showing ENUM('nothing','stem','answers','results') NOT NULL DEFAULT 'nothing',"
"NumCols INT NOT NULL DEFAULT 1,"
"ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N'," "ShowQstResults ENUM('N','Y') NOT NULL DEFAULT 'N',"
"ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N'," "ShowUsrResults ENUM('N','Y') NOT NULL DEFAULT 'N',"
"UNIQUE INDEX(MchCod)," "UNIQUE INDEX(MchCod),"

View File

@ -77,7 +77,7 @@ const char *Mch_ShowingStringsDB[Mch_NUM_SHOWING] =
"results", "results",
}; };
#define Mch_NUM_COLS 3 #define Mch_MAX_COLS 3
#define Mch_NUM_COLS_DEFAULT 1 #define Mch_NUM_COLS_DEFAULT 1
/*****************************************************************************/ /*****************************************************************************/
@ -241,8 +241,9 @@ void Mch_ListMatches (struct Game *Game,bool PutFormNewMatch)
"QstInd," // row[ 6] "QstInd," // row[ 6]
"QstCod," // row[ 7] "QstCod," // row[ 7]
"Showing," // row[ 8] "Showing," // row[ 8]
"ShowQstResults," // row[ 9] "NumCols," // row[ 9]
"ShowUsrResults" // row[10] "ShowQstResults," // row[10]
"ShowUsrResults" // row[11]
" FROM mch_matches" " FROM mch_matches"
" WHERE GamCod=%ld%s" " WHERE GamCod=%ld%s"
" ORDER BY MchCod", " ORDER BY MchCod",
@ -313,8 +314,9 @@ void Mch_GetDataOfMatchByCod (struct Match *Match)
"QstInd," // row[ 6] "QstInd," // row[ 6]
"QstCod," // row[ 7] "QstCod," // row[ 7]
"Showing," // row[ 8] "Showing," // row[ 8]
"ShowQstResults," // row[ 9] "NumCols," // row[ 9]
"ShowUsrResults" // row[10] "ShowQstResults," // row[10]
"ShowUsrResults" // row[11]
" FROM mch_matches" " FROM mch_matches"
" WHERE MchCod=%ld" " WHERE MchCod=%ld"
" AND GamCod IN" // Extra check " AND GamCod IN" // Extra check
@ -812,6 +814,7 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
{ {
MYSQL_ROW row; MYSQL_ROW row;
Dat_StartEndTime_t StartEndTime; Dat_StartEndTime_t StartEndTime;
long LongNum;
/***** Get match data *****/ /***** Get match data *****/
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -853,8 +856,9 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
row[ 6] QstInd row[ 6] QstInd
row[ 7] QstCod row[ 7] QstCod
row[ 8] Showing row[ 8] Showing
row[ 9] ShowQstResults row[ 9] NumCols
row[10] ShowUsrResults row[10] ShowQstResults
row[11] ShowUsrResults
*/ */
/* Current question index (row[6]) */ /* Current question index (row[6]) */
Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]); Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]);
@ -865,11 +869,17 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/* Get what to show (stem, answers, results) (row(8)) */ /* Get what to show (stem, answers, results) (row(8)) */
Match->Status.Showing = Mch_GetShowingFromStr (row[8]); Match->Status.Showing = Mch_GetShowingFromStr (row[8]);
/* Get whether to show question results or not (row(9)) */ /* Get number of columns (row[9]) */
Match->Status.ShowQstResults = (row[9][0] == 'Y'); LongNum = Str_ConvertStrCodToLongCod (row[9]);
Match->Status.NumCols = (LongNum <= 1 ) ? 1 :
((LongNum >= Mch_MAX_COLS) ? Mch_MAX_COLS :
(unsigned) LongNum);
/* Get whether to show user results or not (row(10)) */ /* Get whether to show question results or not (row(10)) */
Match->Status.ShowUsrResults = (row[10][0] == 'Y'); Match->Status.ShowQstResults = (row[10][0] == 'Y');
/* Get whether to show user results or not (row(11)) */
Match->Status.ShowUsrResults = (row[11][0] == 'Y');
/***** Get whether the match is being played or not *****/ /***** Get whether the match is being played or not *****/
if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished if (Match->Status.QstInd >= Mch_AFTER_LAST_QUESTION) // Finished
@ -1351,7 +1361,7 @@ static long Mch_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
MchCod = DB_QueryINSERTandReturnCode ("can not create match", MchCod = DB_QueryINSERTandReturnCode ("can not create match",
"INSERT mch_matches " "INSERT mch_matches "
"(GamCod,UsrCod,StartTime,EndTime,Title," "(GamCod,UsrCod,StartTime,EndTime,Title,"
"QstInd,QstCod,Showing," "QstInd,QstCod,Showing,NumCols,"
"ShowQstResults,ShowUsrResults)" "ShowQstResults,ShowUsrResults)"
" VALUES " " VALUES "
"(%ld," // GamCod "(%ld," // GamCod
@ -1362,12 +1372,14 @@ static long Mch_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
"0," // QstInd: Match has not started, so not the first question yet "0," // QstInd: Match has not started, so not the first question yet
"-1," // QstCod: Non-existent question "-1," // QstCod: Non-existent question
"'%s'," // Showing: What is being shown "'%s'," // Showing: What is being shown
"%u," // NumCols: Number of columns in answers
"'N'," // ShowQstResults: Don't show question results initially "'N'," // ShowQstResults: Don't show question results initially
"'N')", // ShowUsrResults: Don't show user results initially "'N')", // ShowUsrResults: Don't show user results initially
GamCod, GamCod,
Gbl.Usrs.Me.UsrDat.UsrCod, // Game creator Gbl.Usrs.Me.UsrDat.UsrCod, // Game creator
Title, Title,
Mch_ShowingStringsDB[Mch_SHOWING_DEFAULT]); Mch_ShowingStringsDB[Mch_SHOWING_DEFAULT],
Mch_NUM_COLS_DEFAULT);
/***** Create indexes for answers *****/ /***** Create indexes for answers *****/
Mch_CreateIndexes (GamCod,MchCod); Mch_CreateIndexes (GamCod,MchCod);
@ -1615,6 +1627,7 @@ static void Mch_UpdateMatchStatusInDB (struct Match *Match)
"mch_matches.QstInd=%u," "mch_matches.QstInd=%u,"
"mch_matches.QstCod=%ld," "mch_matches.QstCod=%ld,"
"mch_matches.Showing='%s'," "mch_matches.Showing='%s',"
"mch_matches.NumCols=%u,"
"mch_matches.ShowQstResults='%c'" "mch_matches.ShowQstResults='%c'"
" WHERE mch_matches.MchCod=%ld" " WHERE mch_matches.MchCod=%ld"
" AND mch_matches.GamCod=gam_games.GamCod" " AND mch_matches.GamCod=gam_games.GamCod"
@ -1622,6 +1635,7 @@ static void Mch_UpdateMatchStatusInDB (struct Match *Match)
MchSubQuery, MchSubQuery,
Match->Status.QstInd,Match->Status.QstCod, Match->Status.QstInd,Match->Status.QstCod,
Mch_ShowingStringsDB[Match->Status.Showing], Mch_ShowingStringsDB[Match->Status.Showing],
Match->Status.NumCols,
Match->Status.ShowQstResults ? 'Y' : 'N', Match->Status.ShowQstResults ? 'Y' : 'N',
Match->MchCod,Gbl.Hierarchy.Crs.CrsCod); Match->MchCod,Gbl.Hierarchy.Crs.CrsCod);
@ -2300,18 +2314,22 @@ static void Mch_PutMatchControlButtons (struct Match *Match)
static void Mch_ShowFormColumns (struct Match *Match) static void Mch_ShowFormColumns (struct Match *Match)
{ {
extern const char *Txt_column;
extern const char *Txt_columns; extern const char *Txt_columns;
unsigned NumCols; unsigned NumCols;
static const char *NumColsIcon[Mch_NUM_COLS] = static const char *NumColsIcon[1 + Mch_MAX_COLS] =
{ {
"", // Not used
"bars.svg", // 1 column "bars.svg", // 1 column
"grip-vertical.svg", // 2 columns "grip-vertical.svg", // 2 columns
"th.svg", // 3 columns "th.svg", // 3 columns
}; };
/***** Begin selector *****/
Set_StartOneSettingSelector (); Set_StartOneSettingSelector ();
for (NumCols = 0;
NumCols < Mch_NUM_COLS; for (NumCols = 1;
NumCols <= Mch_MAX_COLS;
NumCols++) NumCols++)
{ {
fprintf (Gbl.F.Out,"<div class=\"%s\">", fprintf (Gbl.F.Out,"<div class=\"%s\">",
@ -2321,10 +2339,19 @@ static void Mch_ShowFormColumns (struct Match *Match)
Frm_StartForm (ActChgVisResMchQst); Frm_StartForm (ActChgVisResMchQst);
Mch_PutParamMchCod (Match->MchCod); // Current match being played Mch_PutParamMchCod (Match->MchCod); // Current match being played
Ico_PutSettingIconLink (NumColsIcon[NumCols],Txt_columns); snprintf (Gbl.Title,sizeof (Gbl.Title),
"%u %s",
NumCols,NumCols == 1 ? Txt_column :
Txt_columns);
Ico_PutSettingIconLink (NumColsIcon[NumCols],Gbl.Title);
/***** End form *****/
Frm_EndForm (); Frm_EndForm ();
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
} }
/***** End selector *****/
Set_EndOneSettingSelector (); Set_EndOneSettingSelector ();
} }

View File

@ -4204,6 +4204,27 @@ const char *Txt_Color_of_the_graphic =
"Cor do gr&aacute;fico"; "Cor do gr&aacute;fico";
#endif #endif
const char *Txt_column =
#if L==1 // ca
"columna";
#elif L==2 // de
"Spalte";
#elif L==3 // en
"column";
#elif L==4 // es
"columna";
#elif L==5 // fr
"colonne";
#elif L==6 // gn
"columna"; // Okoteve traducción
#elif L==7 // it
"colonna";
#elif L==8 // pl
"kolumna";
#elif L==9 // pt
"coluna";
#endif
const char *Txt_Columns = const char *Txt_Columns =
#if L==1 // ca #if L==1 // ca
"Columnes"; "Columnes";