diff --git a/sql/cambios.sql b/sql/cambios.sql index ba353113..8d6d8472 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -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; + + \ No newline at end of file diff --git a/swad_changelog.h b/swad_changelog.h index 133807e2..9919f960 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -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) diff --git a/swad_connected.c b/swad_connected.c index b86e512d..15608f8e 100644 --- a/swad_connected.c +++ b/swad_connected.c @@ -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) diff --git a/swad_country.c b/swad_country.c index b5aba60d..cceebe02 100644 --- a/swad_country.c +++ b/swad_country.c @@ -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 */ diff --git a/swad_course.c b/swad_course.c index 378b502b..9486dfd8 100644 --- a/swad_course.c +++ b/swad_course.c @@ -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 *****/ diff --git a/swad_degree.c b/swad_degree.c index 0453c909..08a5ed97 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -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]) *****/ diff --git a/swad_exam.c b/swad_exam.c index 2d978925..f71419e6 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -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 **********/ /*****************************************************************************/ diff --git a/swad_exam.h b/swad_exam.h index e8aed2f9..7a99703e 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -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); diff --git a/swad_exam_print.c b/swad_exam_print.c index 4418f72d..2a7d37ee 100644 --- a/swad_exam_print.c +++ b/swad_exam_print.c @@ -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; diff --git a/swad_game.c b/swad_game.c index e419e594..c3461f27 100644 --- a/swad_game.c +++ b/swad_game.c @@ -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 */ diff --git a/swad_indicator.c b/swad_indicator.c index cc97640c..ae5cb3d2 100644 --- a/swad_indicator.c +++ b/swad_indicator.c @@ -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 */ diff --git a/swad_institution.c b/swad_institution.c index 2644c332..cc5bc006 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -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 */ diff --git a/swad_match.c b/swad_match.c index 8a480691..2f7b97ce 100644 --- a/swad_match.c +++ b/swad_match.c @@ -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], diff --git a/swad_message.c b/swad_message.c index c37feded..4af31456 100644 --- a/swad_message.c +++ b/swad_message.c @@ -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; diff --git a/swad_photo.c b/swad_photo.c index a0d1a667..4778fcb4 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -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 */ diff --git a/swad_project.c b/swad_project.c index 57d54b1b..21b7f528 100644 --- a/swad_project.c +++ b/swad_project.c @@ -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; diff --git a/swad_survey.c b/swad_survey.c index 7224057a..77d1ced2 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -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 (); diff --git a/swad_test.c b/swad_test.c index 914d9092..72e98114 100644 --- a/swad_test.c +++ b/swad_test.c @@ -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 */ diff --git a/swad_test_print.c b/swad_test_print.c index 431fd8d2..98cb7e50 100644 --- a/swad_test_print.c +++ b/swad_test_print.c @@ -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 */ diff --git a/swad_timetable.c b/swad_timetable.c index dd9231d0..b07b46ed 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -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: diff --git a/swad_user.c b/swad_user.c index 54271b42..b61b378f 100644 --- a/swad_user.c +++ b/swad_user.c @@ -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.");