From 23c7e8baf50db750c2db2665c5dfbf115be65149 Mon Sep 17 00:00:00 2001 From: acanas Date: Tue, 14 Apr 2020 02:37:24 +0200 Subject: [PATCH] Version19.183.2 --- sql/cambios.sql | 19 ++++++++++++++++++ swad_changelog.h | 5 +++-- swad_test.c | 2 +- swad_test_exam.c | 51 +++++++++++++++++++++++++++--------------------- 4 files changed, 52 insertions(+), 25 deletions(-) diff --git a/sql/cambios.sql b/sql/cambios.sql index 4bcad1f3..ec2a86bb 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -13303,4 +13303,23 @@ Si se quieren eliminar todos los datos de una partici ALTER TABLE log TRUNCATE PARTITION p2014; + + + + +// Cambios realizados el 14 de abril de 2020 +// Ahora la pareja ExaCod,QstCod deben ser única en la tabla tst_exam_questions. +// Detecté los siguientes exámenes que tenían preguntas repetidas, y los eliminé de la tabla tst_exam_questions pero no de tst_exams; + +SELECT DISTINCT (ExaCod) FROM (SELECT ExaCod,COUNT(*) AS N FROM tst_exam_questions GROUP BY ExaCod,QstCod HAVING N>1) AS E; + +SELECT * FROM tst_exam_questions WHERE ExaCod IN (138946,149939,153732,155072,158845,160028,163616,163617,165036,176633,177040,177140,177221,180469,182532,189061,189169,189179,189207,189245,189273,200335,200336,200337,203975,205562,206021,207224,215085,218272,218294,218300,218317,218665,218851,218869,218880,218955,219045,219074,219082,219086,219089,219092,219095,219097,219104,219107,219189,252548,252549,252550,259574,259825); + +DELETE FROM tst_exam_questions WHERE ExaCod IN (138946,149939,153732,155072,158845,160028,163616,163617,165036,176633,177040,177140,177221,180469,182532,189061,189169,189179,189207,189245,189273,200335,200336,200337,203975,205562,206021,207224,215085,218272,218294,218300,218317,218665,218851,218869,218880,218955,219045,219074,219082,219086,219089,219092,219095,219097,219104,219107,219189,252548,252549,252550,259574,259825); + +SELECT ExaCod,CrsCod FROM tst_exams WHERE ExaCod IN (138946,149939,153732,155072,158845,160028,163616,163617,165036,176633,177040,177140,177221,180469,182532,189061,189169,189179,189207,189245,189273,200335,200336,200337,203975,205562,206021,207224,215085,218272,218294,218300,218317,218665,218851,218869,218880,218955,219045,219074,219082,219086,219089,219092,219095,219097,219104,219107,219189,252548,252549,252550,259574,259825); + +SELECT * FROM tst_exams WHERE ExaCod IN (138946,149939,153732,155072,158845,160028,163616,163617,165036,176633,177040,177140,177221,180469,182532,189061,189169,189179,189207,189245,189273,200335,200336,200337,203975,205562,206021,207224,215085,218272,218294,218300,218317,218665,218851,218869,218880,218955,219045,219074,219082,219086,219089,219092,219095,219097,219104,219107,219189,252548,252549,252550,259574,259825); + + \ No newline at end of file diff --git a/swad_changelog.h b/swad_changelog.h index 5ea66722..96ea292e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.183.1 (2020-04-14)" +#define Log_PLATFORM_VERSION "SWAD 19.183.2 (2020-04-14)" #define CSS_FILE "swad19.146.css" #define JS_FILE "swad19.172.1.js" /* @@ -548,6 +548,7 @@ Funci // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores // TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub + Version 19.183.2: Apr 14, 2020 Fixed bug in test exams. (285684 lines) Version 19.183.1: Apr 14, 2020 Fixed bug in forums, reported by Javier Fernández Baldomero. (285677 lines) Version 19.183: Apr 13, 2020 Code refactoring in holidays. (285689 lines) Version 19.182: Apr 13, 2020 Code refactoring in places. (285685 lines) @@ -672,7 +673,7 @@ ALTER TABLE tst_exams CHANGE COLUMN EndTime EndTime DATETIME NOT NULL; Version 19.148: Mar 17, 2020 Code refactoring in tests. New actions to remove several test questions. (282868 lines) Version 19.147: Mar 14, 2020 Change MathJax to version 3.0.1. (282550 lines) -Install MathJax 3.0.1 +Install MathJax 3.0.1 or later Copy the following JavaScript file to public directory: sudo cp js/mathjax-config.js /var/www/html/swad/ diff --git a/swad_test.c b/swad_test.c index f9d01d55..a1f5b674 100644 --- a/swad_test.c +++ b/swad_test.c @@ -4546,7 +4546,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question) row = mysql_fetch_row (mysql_res); /* Get edition time (row[0] holds the start UTC time) */ - Question->EditTime = Dat_GetUNIXTimeFromStr (row[3]); + Question->EditTime = Dat_GetUNIXTimeFromStr (row[0]); /* Get the type of answer (row[1]) */ Question->Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]); diff --git a/swad_test_exam.c b/swad_test_exam.c index a8661d4d..5e7a1c55 100644 --- a/swad_test_exam.c +++ b/swad_test_exam.c @@ -1811,7 +1811,7 @@ static void TstExa_ShowExams (struct UsrData *UsrDat) } else { - HTM_TD_ColouredEmpty (7); + HTM_TD_ColouredEmpty (8); HTM_TR_End (); } @@ -2296,10 +2296,11 @@ void TstExa_GetExamQuestionsFromDB (struct TstExa_Exam *Exam) { MYSQL_RES *mysql_res; MYSQL_ROW row; + unsigned NumQsts; unsigned NumQst; /***** Get questions of a test exam from database *****/ - Exam->NumQsts = + NumQsts = (unsigned) DB_QuerySELECT (&mysql_res,"can not get questions" " of a test exam", "SELECT QstCod," // row[0] @@ -2310,33 +2311,39 @@ void TstExa_GetExamQuestionsFromDB (struct TstExa_Exam *Exam) " ORDER BY QstInd", Exam->ExaCod); - /***** Get questions codes *****/ - for (NumQst = 0; - NumQst < Exam->NumQsts; - NumQst++) - { - row = mysql_fetch_row (mysql_res); + /***** List questions *****/ + // The number of questions in table of exam questions + // should match the number of questions got from exam + if (NumQsts == Exam->NumQsts) + for (NumQst = 0; + NumQst < NumQsts; + NumQst++) + { + row = mysql_fetch_row (mysql_res); - /* Get question code */ - if ((Exam->Questions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) - Lay_ShowErrorAndExit ("Wrong code of question."); + /* Get question code */ + if ((Exam->Questions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0) + Lay_ShowErrorAndExit ("Wrong code of question."); - /* Get indexes for this question (row[1]) */ - Str_Copy (Exam->Questions[NumQst].StrIndexes,row[1], - TstExa_MAX_BYTES_INDEXES_ONE_QST); + /* Get indexes for this question (row[1]) */ + Str_Copy (Exam->Questions[NumQst].StrIndexes,row[1], + TstExa_MAX_BYTES_INDEXES_ONE_QST); - /* Get answers selected by user for this question (row[2]) */ - Str_Copy (Exam->Questions[NumQst].StrAnswers,row[2], - TstExa_MAX_BYTES_ANSWERS_ONE_QST); + /* Get answers selected by user for this question (row[2]) */ + Str_Copy (Exam->Questions[NumQst].StrAnswers,row[2], + TstExa_MAX_BYTES_ANSWERS_ONE_QST); - /* Replace each comma by a separator of multiple parameters */ - /* In database commas are used as separators instead of special chars */ - Par_ReplaceCommaBySeparatorMultiple (Exam->Questions[NumQst].StrIndexes); - Par_ReplaceCommaBySeparatorMultiple (Exam->Questions[NumQst].StrAnswers); - } + /* Replace each comma by a separator of multiple parameters */ + /* In database commas are used as separators instead of special chars */ + Par_ReplaceCommaBySeparatorMultiple (Exam->Questions[NumQst].StrIndexes); + Par_ReplaceCommaBySeparatorMultiple (Exam->Questions[NumQst].StrAnswers); + } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); + + if (NumQsts != Exam->NumQsts) + Lay_ShowErrorAndExit ("Wrong exam."); } /*****************************************************************************/