diff --git a/swad_changelog.h b/swad_changelog.h index 4e7b0b80..e28d0a2d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo. */ -#define Log_PLATFORM_VERSION "SWAD 21.11 (2021-09-22)" +#define Log_PLATFORM_VERSION "SWAD 21.11.1 (2021-09-22)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.69.1.js" /* TODO: Rename CENTRE to CENTER in help wiki. TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams + Version 21.11.1: Sep 22, 2021 Queries moved to module swad_info_database. (316237 lines) Version 21.11: Sep 22, 2021 New module swad_info_database for database queries related to course information. (316228 lines) Version 21.10.1: Sep 21, 2021 Fixed bugs in roles. Reported by Javier Fernández Baldomero and Mª Carmen García Miranda. (316111 lines) Version 21.10: Sep 20, 2021 New module swad_indicator_database for database queries related to course indicators. (316112 lines) diff --git a/swad_enrolment.c b/swad_enrolment.c index 6c4efa14..2b326130 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -48,6 +48,7 @@ #include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_ID.h" +#include "swad_info_database.h" #include "swad_match.h" #include "swad_message.h" #include "swad_notification.h" diff --git a/swad_info.c b/swad_info.c index 4511499c..78324d76 100644 --- a/swad_info.c +++ b/swad_info.c @@ -331,8 +331,8 @@ void Inf_ShowInfo (void) { /***** Contextual menu *****/ Mnu_ContextMenuBegin (); - Inf_PutCheckboxConfirmIHaveReadInfo (); // Checkbox to confirm that... - // ...I have read this couse info + Inf_PutCheckboxConfirmIHaveReadInfo (); // Checkbox to confirm that... + // ...I have read this couse info Mnu_ContextMenuEnd (); } break; @@ -344,9 +344,9 @@ void Inf_ShowInfo (void) { /***** Contextual menu *****/ Mnu_ContextMenuBegin (); - Disabled = (Gbl.Usrs.Me.Role.Logged == Rol_NET); // Non-editing teachers can not change the status of checkbox - Inf_PutCheckboxForceStdsToReadInfo (FromDB.MustBeRead,Disabled); // Checkbox to force students... - // ...to read this couse info + Disabled = (Gbl.Usrs.Me.Role.Logged == Rol_NET); // Non-editing teachers can not change the status of checkbox + Inf_PutCheckboxForceStdsToReadInfo (FromDB.MustBeRead,Disabled); // Checkbox to force students... + // ...to read this couse info Mnu_ContextMenuEnd (); } break; @@ -492,20 +492,7 @@ bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void) Gbl.Crs.Info.MustBeRead[InfoType] = false; /***** Get info types where students must read info *****/ - NumInfos = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get if you must read any course info", - "SELECT InfoType" // row[0] - " FROM crs_info_src" - " WHERE CrsCod=%ld" - " AND MustBeRead='Y'" - " AND InfoType NOT IN" - " (SELECT InfoType" - " FROM crs_info_read" - " WHERE UsrCod=%ld" - " AND CrsCod=%ld)", - Gbl.Hierarchy.Crs.CrsCod, - Gbl.Usrs.Me.UsrDat.UsrCod, - Gbl.Hierarchy.Crs.CrsCod); + NumInfos = Inf_DB_GetInfoTypesfIMustReadInfo (&mysql_res); /***** Set must-be-read to true for each rown in result *****/ for (NumInfo = 0; @@ -645,20 +632,6 @@ static bool Inf_GetIfIHaveReadFromForm (void) return Par_GetParToBool ("IHaveRead"); } -/*****************************************************************************/ -/********* Remove user's status about reading of course information **********/ -/*****************************************************************************/ - -void Inf_DB_RemoveUsrFromCrsInfoRead (long UsrCod,long CrsCod) - { - /***** Remove user's status about reading of course information *****/ - DB_QueryDELETE ("can not set that I have not read course info", - "DELETE FROM crs_info_read" - " WHERE UsrCod=%ld" - " AND CrsCod=%ld", - UsrCod,CrsCod); - } - /*****************************************************************************/ /************************** Check if exists a page ***************************/ /*****************************************************************************/ @@ -1835,7 +1808,7 @@ void Inf_RecAndChangePlainTxtInfo (void) /***** Change info source to "plain text" in database *****/ Inf_DB_SetInfoSrc (Txt_HTMLFormat[0] ? Inf_PLAIN_TEXT : - Inf_NONE); + Inf_NONE); if (Txt_HTMLFormat[0]) /***** Show the updated info *****/ Inf_ShowInfo (); @@ -1874,7 +1847,7 @@ void Inf_RecAndChangeRichTxtInfo (void) /***** Change info source to "rich text" in database *****/ Inf_DB_SetInfoSrc (Txt_HTMLFormat[0] ? Inf_RICH_TEXT : - Inf_NONE); + Inf_NONE); if (Txt_HTMLFormat[0]) /***** Show the updated info *****/ Inf_ShowInfo (); diff --git a/swad_info.h b/swad_info.h index 823ded90..72b1eddb 100644 --- a/swad_info.h +++ b/swad_info.h @@ -88,7 +88,6 @@ void Inf_WriteMsgYouMustReadInfo (void); void Inf_ChangeForceReadInfo (void); void Inf_ChangeIHaveReadInfo (void); bool Inf_GetIfIMustReadAnyCrsInfoInThisCrs (void); -void Inf_DB_RemoveUsrFromCrsInfoRead (long UsrCod,long CrsCod); void Inf_BuildPathPage (long CrsCod,Inf_Type_t InfoType,char PathDir[PATH_MAX + 1]); void Inf_WriteURLIntoTxtBuffer (char TxtBuffer[Cns_MAX_BYTES_WWW + 1]); void Inf_SetInfoSrc (void); diff --git a/swad_info_database.c b/swad_info_database.c index 9493e456..7fa3bf28 100644 --- a/swad_info_database.c +++ b/swad_info_database.c @@ -301,3 +301,38 @@ bool Inf_DB_CheckIfIHaveReadInfo (void) Gbl.Hierarchy.Crs.CrsCod, Inf_DB_NamesForInfoType[Gbl.Crs.Info.Type]) != 0); } + +/*****************************************************************************/ +/******************* Get info types where I must read info *******************/ +/*****************************************************************************/ + +unsigned Inf_DB_GetInfoTypesfIMustReadInfo (MYSQL_RES **mysql_res) + { + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get if you must read any course info", + "SELECT InfoType" // row[0] + " FROM crs_info_src" + " WHERE CrsCod=%ld" + " AND MustBeRead='Y'" + " AND InfoType NOT IN" + " (SELECT InfoType" + " FROM crs_info_read" + " WHERE UsrCod=%ld" + " AND CrsCod=%ld)", + Gbl.Hierarchy.Crs.CrsCod, + Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.Hierarchy.Crs.CrsCod); + } + +/*****************************************************************************/ +/********* Remove user's status about reading of course information **********/ +/*****************************************************************************/ + +void Inf_DB_RemoveUsrFromCrsInfoRead (long UsrCod,long CrsCod) + { + DB_QueryDELETE ("can not set that I have not read course info", + "DELETE FROM crs_info_read" + " WHERE UsrCod=%ld" + " AND CrsCod=%ld", + UsrCod,CrsCod); + } diff --git a/swad_info_database.h b/swad_info_database.h index 8497dfc1..ecf5749e 100644 --- a/swad_info_database.h +++ b/swad_info_database.h @@ -67,5 +67,8 @@ void Inf_DB_SetForceRead (bool MustBeRead); void Inf_DB_SetIHaveRead (bool IHaveRead); bool Inf_DB_CheckIfIHaveReadInfo (void); +unsigned Inf_DB_GetInfoTypesfIMustReadInfo (MYSQL_RES **mysql_res); + +void Inf_DB_RemoveUsrFromCrsInfoRead (long UsrCod,long CrsCod); #endif diff --git a/swad_syllabus.c b/swad_syllabus.c index 80dd3ec3..00496539 100644 --- a/swad_syllabus.c +++ b/swad_syllabus.c @@ -263,7 +263,7 @@ bool Syl_CheckAndEditSyllabus (struct Syl_Syllabus *Syllabus) { /***** Button to view *****/ Frm_BeginForm (Inf_ActionsSeeInfo[Gbl.Crs.Info.Type]); - Btn_PutConfirmButton (Txt_Done); + Btn_PutConfirmButton (Txt_Done); Frm_EndForm (); } @@ -853,29 +853,29 @@ static void Syl_PutFormItemSyllabus (struct Syl_Syllabus *Syllabus, HTM_TD_Begin ("class=\"%s LM COLOR%u\" style=\"width:%dpx;\"", StyleSyllabus[Level],Gbl.RowEvenOdd, Level * Syl_WIDTH_NUM_SYLLABUS); - if (Level == 1) + if (Level == 1) + HTM_NBSP (); + Syl_WriteNumItem (NULL,Gbl.F.Out,Level,CodItem); HTM_NBSP (); - Syl_WriteNumItem (NULL,Gbl.F.Out,Level,CodItem); - HTM_NBSP (); HTM_TD_End (); } /***** Text of the item *****/ HTM_TD_Begin ("colspan=\"%d\" class=\"LM COLOR%u\"", Syl_LstItemsSyllabus.NumLevels - Level + 1,Gbl.RowEvenOdd); - Frm_BeginForm (NewItem ? (Gbl.Crs.Info.Type == Inf_LECTURES ? ActInsIteSylLec : - ActInsIteSylPra) : - (Gbl.Crs.Info.Type == Inf_LECTURES ? ActModIteSylLec : - ActModIteSylPra)); - Syllabus->ParamNumItem = NumItem; - Syl_PutParamNumItem (&Syllabus->ParamNumItem); - HTM_INPUT_TEXT ("Txt",Syl_MAX_CHARS_TEXT_ITEM,Text, - HTM_SUBMIT_ON_CHANGE, - "size=\"60\" placeholder=\"%s\"%s", - Txt_Enter_a_new_item_here, - NewItem ? " autofocus=\"autofocus\"" : - ""); - Frm_EndForm (); + Frm_BeginForm (NewItem ? (Gbl.Crs.Info.Type == Inf_LECTURES ? ActInsIteSylLec : + ActInsIteSylPra) : + (Gbl.Crs.Info.Type == Inf_LECTURES ? ActModIteSylLec : + ActModIteSylPra)); + Syllabus->ParamNumItem = NumItem; + Syl_PutParamNumItem (&Syllabus->ParamNumItem); + HTM_INPUT_TEXT ("Txt",Syl_MAX_CHARS_TEXT_ITEM,Text, + HTM_SUBMIT_ON_CHANGE, + "size=\"60\" placeholder=\"%s\"%s", + Txt_Enter_a_new_item_here, + NewItem ? " autofocus=\"autofocus\"" : + ""); + Frm_EndForm (); HTM_TD_End (); }