Version 21.11.1: Sep 22, 2021 Queries moved to module swad_info_database.

This commit is contained in:
acanas 2021-09-22 08:57:04 +02:00
parent babcd3df60
commit ddf9d0dfdc
7 changed files with 66 additions and 54 deletions

View File

@ -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 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)

View File

@ -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"

View File

@ -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 ***************************/
/*****************************************************************************/

View File

@ -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);

View File

@ -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);
}

View File

@ -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