Version 20.68.5: Apr 29, 2021 Fixed bug in matches. Reported by Jesús Garrido Alcázar.

This commit is contained in:
acanas 2021-04-29 19:52:35 +02:00
parent c054fd3351
commit 4c2f1f3142
21 changed files with 47 additions and 108 deletions

View File

@ -13499,3 +13499,9 @@ RENAME TABLE roo_MACs TO roo_macs;
RENAME TABLE usr_IDs TO usr_ids;
RENAME TABLE pho_clicks_without_photo TO usr_clicks_without_photo;
---------------------------
SELECT gam_questions.QstCod,gam_questions.QstInd,tst_questions.AnsType,tst_questions.Shuffle FROM gam_questions,tst_questions WHERE gam_questions.GamCod=7 AND gam_questions.QstCod=tst_questions.QstCod ORDER BY gam_questions.QstInd;

View File

@ -600,13 +600,14 @@ TODO: Salvador Romero Cort
TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria.
*/
#define Log_PLATFORM_VERSION "SWAD 20.68.4 (2021-04-27)"
#define Log_PLATFORM_VERSION "SWAD 20.68.5 (2021-04-29)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.6.2.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 20.68.5: Apr 29, 2021 Fixed bug in matches. Reported by Jesús Garrido Alcázar. (309746 lines)
Version 20.68.4: Apr 27, 2021 Fixed bug in question tags. Reported by Julio Ortega Lopera. (309802 lines)
Version 20.68.3: Apr 27, 2021 Maximum file size increased from 1.5 GiB to 2000 MiB. (309809 lines)
Version 20.68.2: Apr 26, 2021 Code optimization in games and exams. (309807 lines)

View File

@ -1139,8 +1139,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
{
/* Get course code (row[1]) */
ThisCrs = (Str_ConvertStrCodToLongCod (row[1]) ==
Gbl.Hierarchy.Crs.CrsCod);
ThisCrs = (Str_ConvertStrCodToLongCod (row[1]) == Gbl.Hierarchy.Crs.CrsCod);
/* Compute time from last access */
if (sscanf (row[2],"%ld",&TimeDiff) != 1)

View File

@ -786,7 +786,7 @@ void Cty_GetBasicListOfCountries (void)
row = mysql_fetch_row (mysql_res);
/* Get numerical country code (row[0]) */
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongCountrExit ();
/* Get Alpha-2 country code (row[1]) */
@ -912,7 +912,7 @@ void Cty_GetFullListOfCountries (void)
row = mysql_fetch_row (mysql_res);
/* Get numerical country code (row[0]) */
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongCountrExit ();
/* Get Alpha-2 country code (row[1]) */
@ -981,7 +981,7 @@ void Cty_WriteSelectorOfCountry (void)
row = mysql_fetch_row (mysql_res);
/* Get country code (row[0]) */
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongCountrExit ();
/* Write option */

View File

@ -711,7 +711,7 @@ void Crs_WriteSelectorOfCourse (void)
row = mysql_fetch_row (mysql_res);
/* Get course code (row[0]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongCourseExit ();
/* Write option */
@ -1833,7 +1833,7 @@ bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs)
static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
{
/***** Get course code (row[0]) *****/
if ((Crs->CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Crs->CrsCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongCourseExit ();
/***** Get code of degree (row[1]) *****/
@ -2826,13 +2826,13 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA
*/
/***** Get degree code (row[0]) *****/
if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongDegreeExit ();
if (!Deg_GetDataOfDegreeByCod (&Deg))
Err_WrongDegreeExit ();
/***** Get course code (row[1]) *****/
if ((CrsCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
if ((CrsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
Err_WrongCourseExit ();
/***** Get number of teachers and students in this course *****/

View File

@ -296,7 +296,7 @@ void Deg_WriteSelectorOfDegree (void)
row = mysql_fetch_row (mysql_res);
/* Get degree code (row[0]) */
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongDegreeExit ();
/* Write option */
@ -1404,7 +1404,7 @@ bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg)
static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
{
/***** Get degree code (row[0]) *****/
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongDegreeExit ();
/***** Get center code (row[1]) *****/

View File

@ -1729,51 +1729,6 @@ static void Exa_UpdateExam (struct Exa_Exam *Exam,const char *Txt)
Ale_ShowAlert (Ale_SUCCESS,Txt_The_exam_has_been_modified);
}
/*****************************************************************************/
/****************** Write parameter with index of question *******************/
/*****************************************************************************/
void Exa_PutParamQstInd (unsigned QstInd)
{
Par_PutHiddenParamUnsigned (NULL,"QstInd",QstInd);
}
/*****************************************************************************/
/******************* Get parameter with index of question ********************/
/*****************************************************************************/
unsigned Exa_GetParamQstInd (void)
{
long QstInd;
if ((QstInd = Par_GetParToLong ("QstInd")) <= 0)
Err_WrongQuestionIndexExit ();
return (unsigned) QstInd;
}
/*****************************************************************************/
/************ Get question code given exam and index of question *************/
/*****************************************************************************/
long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd)
{
long QstCod;
/***** Get question code of the question to be moved up *****/
QstCod = DB_QuerySELECTCode ("can not get question code",
"SELECT QstCod"
" FROM exa_set_questions"
" WHERE ExaCod=%ld"
" AND QstInd=%u",
ExaCod,
QstInd);
if (QstCod <= 0)
Err_WrongQuestionIndexExit ();
return QstCod;
}
/*****************************************************************************/
/********** Get number of sessions and check is edition is possible **********/
/*****************************************************************************/

View File

@ -89,10 +89,6 @@ void Exa_PutFormEditionExam (struct Exa_Exams *Exams,
void Exa_ReceiveFormExam (void);
void Exa_PutParamQstInd (unsigned QstInd);
unsigned Exa_GetParamQstInd (void);
long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd);
bool Exa_CheckIfEditable (const struct Exa_Exam *Exam);
unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope);

View File

@ -635,11 +635,11 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
row = mysql_fetch_row (mysql_res);
/* Get question code (row[0]) */
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/* Get set code (row[1]) */
if ((Print->PrintedQuestions[QstInd].SetCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
if ((Print->PrintedQuestions[QstInd].SetCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
Err_WrongSetExit ();
/* Get score (row[2]) */
@ -1152,7 +1152,7 @@ static unsigned ExaPrn_GetParamQstInd (void)
{
long QstInd;
if ((QstInd = Par_GetParToLong ("QstInd")) < 0)
if ((QstInd = Par_GetParToLong ("QstInd")) < 0) // In exams, question index should be 0, 1, 2, 3...
Err_WrongQuestionIndexExit ();
return (unsigned) QstInd;

View File

@ -1802,7 +1802,7 @@ unsigned Gam_GetParamQstInd (void)
{
long QstInd;
if ((QstInd = Par_GetParToLong ("QstInd")) <= 0)
if ((QstInd = Par_GetParToLong ("QstInd")) <= 0) // In games, question index should be 1, 2, 3...
Err_WrongQuestionIndexExit ();
return (unsigned) QstInd;
@ -1859,7 +1859,7 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd)
GamCod,
QstInd);
if (QstCod <= 0)
Err_WrongQuestionIndexExit ();
Err_WrongQuestionExit ();
return QstCod;
}
@ -2404,11 +2404,11 @@ void Gam_MoveUpQst (void)
QstIndBottom = Gam_GetParamQstInd ();
/***** Move up question *****/
if (QstIndBottom > 1)
if (QstIndBottom > 1) // 2, 3, 4...
{
/* Indexes of questions to be exchanged */
QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom);
if (!QstIndTop)
if (QstIndTop == 0)
Err_WrongQuestionIndexExit ();
/* Exchange questions */

View File

@ -723,7 +723,7 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1
row = mysql_fetch_row (mysql_res);
/* Get course code (row[2]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) <= 0)
Err_WrongCourseExit ();
/* Get stored number of indicators of this course */
@ -991,7 +991,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *I
row = mysql_fetch_row (mysql_res);
/* Get course code (row[2]) */
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) <= 0)
Err_WrongCourseExit ();
/* Get stored number of indicators of this course */

View File

@ -835,7 +835,7 @@ bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins)
static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
{
/***** Get institution code (row[0]) *****/
if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongInstitExit ();
/***** Get country code (row[1]) *****/
@ -1030,7 +1030,7 @@ void Ins_WriteSelectorOfInstitution (void)
row = mysql_fetch_row (mysql_res);
/* Get institution code (row[0]) */
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongInstitExit ();
/* Write option */

View File

@ -1796,7 +1796,6 @@ static void Mch_CreateIndexes (long GamCod,long MchCod)
unsigned NumQsts;
unsigned NumQst;
struct Tst_Question Question;
long LongNum;
unsigned QstInd;
/***** Get questions of the game *****/
@ -1835,9 +1834,7 @@ static void Mch_CreateIndexes (long GamCod,long MchCod)
Err_WrongQuestionExit ();
/* Get question index (row[1]) */
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) <= 0)
Err_WrongQuestionIndexExit ();
QstInd = (unsigned) LongNum;
QstInd = Str_ConvertStrToUnsigned (row[1]);
/* Get answer type (row[2]) */
Question.Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[2]);
@ -1869,7 +1866,6 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
MYSQL_ROW row;
unsigned NumAnss;
unsigned NumAns;
long LongNum;
unsigned AnsInd;
char StrOneAnswer[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS_ONE_QST + 1];
@ -1896,9 +1892,7 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
row = mysql_fetch_row (mysql_res);
/* Get answer index (row[0]) */
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongAnswerIndexExit ();
AnsInd = (unsigned) LongNum;
AnsInd = Str_ConvertStrToUnsigned (row[0]);
snprintf (StrOneAnswer,sizeof (StrOneAnswer),"%u",AnsInd);
/* Concatenate answer index to list of answers */
@ -4290,7 +4284,6 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumQst;
long LongNum;
unsigned QstInd;
struct Mch_UsrAnswer UsrAnswer;
@ -4315,13 +4308,11 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
row = mysql_fetch_row (mysql_res);
/* Get question code (row[0]) */
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/* Get question index (row[1]) */
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0)
Err_WrongQuestionExit ();
QstInd = (unsigned) LongNum;
QstInd = Str_ConvertStrToUnsigned (row[1]);
/* Get indexes for this question (row[2]) */
Str_Copy (Print->PrintedQuestions[NumQst].StrIndexes,row[2],

View File

@ -2936,7 +2936,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages)
/* Get next course */
row = mysql_fetch_row (mysql_res);
Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
if (Crs.CrsCod >= 0 && Messages->NumCourses < Crs_MAX_COURSES_PER_USR)
if (Crs.CrsCod > 0 && Messages->NumCourses < Crs_MAX_COURSES_PER_USR)
if (Crs_GetDataOfCourseByCod (&Crs))
{
Messages->Courses[Messages->NumCourses].CrsCod = Crs.CrsCod;

View File

@ -2232,7 +2232,7 @@ static void Pho_ShowOrPrintListDegrees (struct Pho_DegPhotos *DegPhotos,
row = mysql_fetch_row (mysql_res);
/* Get degree code (row[0]) */
if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongDegreeExit ();
/* Get data of degree */

View File

@ -1557,7 +1557,6 @@ static bool Prj_CheckIfPrjIsFaulty (long PrjCod,struct Prj_Faults *Faults)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long LongNum;
bool IsAssigned;
bool HasTitle;
bool HasDescription;
@ -1591,9 +1590,7 @@ static bool Prj_CheckIfPrjIsFaulty (long PrjCod,struct Prj_Faults *Faults)
IsAssigned = (row[0][0] != '0');
/* Get if project is assigned or not (row[1]) */
LongNum = Str_ConvertStrCodToLongCod (row[1]);
NumProposedStds = (LongNum > 0) ? (unsigned) LongNum :
0;
NumProposedStds = Str_ConvertStrToUnsigned (row[1]);
/* Get the title of the project (row[2]) */
HasTitle = (row[2][0] != '0');
@ -3179,7 +3176,6 @@ void Prj_GetDataOfProjectByCod (struct Prj_Project *Prj)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
long LongNum;
Prj_Proposal_t Proposal;
if (Prj->PrjCod > 0)
@ -3235,9 +3231,7 @@ void Prj_GetDataOfProjectByCod (struct Prj_Project *Prj)
Prj_NONASSIG;
/* Get number of students (row[6]) */
LongNum = Str_ConvertStrCodToLongCod (row[6]);
Prj->NumStds = (LongNum > 0) ? (unsigned) LongNum :
0;
Prj->NumStds = Str_ConvertStrToUnsigned (row[6]);
/* Get project status (row[7]) */
Prj->Proposal = Prj_PROPOSAL_DEFAULT;

View File

@ -2747,8 +2747,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
row = mysql_fetch_row (mysql_res);
/* Get question index inside survey (row[0]) */
if (sscanf (row[0],"%u",&(SvyQst->QstInd)) != 1)
Err_WrongQuestionIndexExit ();
SvyQst->QstInd = Str_ConvertStrToUnsigned (row[0]);
/* Get the type of answer (row[1]) */
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
@ -3389,8 +3388,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys,
/* Write index of question inside survey (row[1]) */
HTM_TD_Begin ("class=\"DAT_SMALL CT COLOR%u\"",Gbl.RowEvenOdd);
if (sscanf (row[1],"%u",&(SvyQst.QstInd)) != 1)
Err_WrongQuestionIndexExit ();
SvyQst.QstInd = Str_ConvertStrToUnsigned (row[1]);
HTM_Unsigned (SvyQst.QstInd + 1);
HTM_TD_End ();

View File

@ -2000,7 +2000,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
*/
/* Get question code (row[0]) */
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Print->PrintedQuestions[QstInd].QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_ShowErrorAndExit ("Wrong code of question.");
/* Get answer type (row[1]) */
@ -2169,7 +2169,7 @@ static void Tst_ListOneOrMoreQuestionsForEdition (struct Tst_Test *Test,
/***** Get question code (row[0]) *****/
row = mysql_fetch_row (mysql_res);
if ((Test->Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Test->Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/***** Write question row *****/
@ -2432,7 +2432,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForSet (struct Exa_Exams *Exam
/* Get question code (row[0]) */
row = mysql_fetch_row (mysql_res);
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/* Write question row */
@ -2517,7 +2517,7 @@ static void Tst_ListOneOrMoreQuestionsForSelectionForGame (struct Gam_Games *Gam
/* Get question code (row[0]) */
row = mysql_fetch_row (mysql_res);
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/* Write question row */
@ -4714,7 +4714,7 @@ void Tst_RemoveSelectedQsts (void)
{
/* Get question code (row[0]) */
row = mysql_fetch_row (mysql_res);
if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongQuestionExit ();
/* Remove test question from database */

View File

@ -2106,7 +2106,7 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
row = mysql_fetch_row (mysql_res);
/* Get print code (row[0]) */
if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
Err_WrongTestExit ();
/* Get print data */

View File

@ -1050,7 +1050,7 @@ static void Tmt_FillTimeTableFromDB (struct Tmt_Timetable *Timetable,
/* Course code (row[6]) */
Tmt_TimeTable[Weekday][Interval].Columns[FirstFreeColumn].CrsCod =
(Timetable->Type == Tmt_MY_TIMETABLE ? Str_ConvertStrCodToLongCod (row[6]) :
Gbl.Hierarchy.Crs.CrsCod);
Gbl.Hierarchy.Crs.CrsCod);
/* falls through */
/* no break */
case Tmt_TUTORING_TIMETABLE:

View File

@ -1791,8 +1791,7 @@ void Usr_GetMyCourses (void)
row = mysql_fetch_row (mysql_res);
/* Get course code */
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
if (CrsCod > 0)
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) > 0)
{
if (Gbl.Usrs.Me.MyCrss.Num == Crs_MAX_COURSES_PER_USR)
Err_ShowErrorAndExit ("Maximum number of courses of a user exceeded.");