Version 21.32.2: Oct 13, 2021 Queries moved from RSS to other modules.

This commit is contained in:
acanas 2021-10-13 23:34:10 +02:00
parent f2cc9b600f
commit 14bf9acd64
7 changed files with 53 additions and 55 deletions

View File

@ -29,12 +29,13 @@
#include <stddef.h> // For NULL
#include <string.h>
#include "swad_call_for_exam.h"
#include "swad_call_for_exam_database.h"
#include "swad_changelog.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_global.h"
#include "swad_notice.h"
#include "swad_notice_database.h"
#include "swad_RSS.h"
/*****************************************************************************/
@ -78,8 +79,8 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
Err_ShowErrorAndExit ("Can not create RSS file.");
/***** Write RSS header *****/
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n");
fprintf (FileRSS,"<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n"
"<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n");
/***** Write channel header *****/
fprintf (FileRSS,"<channel>\n");
@ -107,9 +108,9 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
Cfg_PLATFORM_SHORT_NAME,Crs->ShrtName);
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
Cfg_URL_SWAD_CGI,Crs->CrsCod);
fprintf (FileRSS,"<width>112</width>\n");
fprintf (FileRSS,"<height>32</height>\n");
fprintf (FileRSS,"</image>\n");
fprintf (FileRSS,"<width>112</width>\n"
"<height>32</height>\n"
"</image>\n");
// All date-times in RSS conform to the Date and Time Specification of RFC 822, with the exception that the year may be expressed with two characters or four characters (four preferred)
fprintf (FileRSS,"<pubDate>");
@ -159,22 +160,8 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
unsigned NumNot;
char Content[Cns_MAX_BYTES_TEXT + 1];
/***** Get active notices in course *****/
NumNotices = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get notices from database",
"SELECT NotCod," // row[0]
"UNIX_TIMESTAMP(CreatTime) AS T," // row[1]
"UsrCod," // row[2]
"Content" // row[3]
" FROM not_notices"
" WHERE CrsCod=%ld"
" AND Status=%u"
" ORDER BY T DESC",
Crs->CrsCod,
(unsigned) Not_ACTIVE_NOTICE);
/***** Write items with notices *****/
if (NumNotices)
/***** Write items with active notices *****/
if ((NumNotices = Not_DB_GetActiveNotices (&mysql_res,Crs->CrsCod)))
{
Usr_UsrDataConstructor (&UsrDat);
@ -185,16 +172,16 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
/***** Get data of the notice *****/
row = mysql_fetch_row (mysql_res);
/* Get notice code */
/* Get notice code (row[0]) */
if (sscanf (row[0],"%ld",&NotCod) != 1)
Err_WrongNoticeExit ();
/* Get UTC date-time of publication */
/* Get UTC date-time of publication (row[1]) */
CreatTimeUTC = 0L;
if (row[1])
sscanf (row[1],"%ld",&CreatTimeUTC);
/* Get author */
/* Get author (row[2]) */
UsrDat.UsrCod = Str_ConvertStrCodToLongCod (row[2]);
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat, // Get author's data from database
Usr_DONT_GET_PREFS,
@ -263,22 +250,8 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
if (Gbl.DB.DatabaseIsOpen)
{
/***** Get exam announcements (only future exams) in current course from database *****/
NumExams = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get calls for exams",
"SELECT ExaCod," // row[0]
"UNIX_TIMESTAMP(CallDate) AS T," // row[1]
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')" // row[2]
" FROM cfe_exams"
" WHERE CrsCod=%ld"
" AND Status=%u"
" AND ExamDate>=NOW()"
" ORDER BY T",
Gbl.Hierarchy.Crs.CrsCod,
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
/***** Write items with notices *****/
if (NumExams)
/***** Write exam announcements (only future exams) in current course *****/
if ((NumExams = Cfe_DB_GetFutureCallsForExamsInCurrentCrs (&mysql_res)))
{
Usr_UsrDataConstructor (&UsrDat);
@ -289,11 +262,11 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
/***** Get data of the call for exam *****/
row = mysql_fetch_row (mysql_res);
/* Get call for exam code */
/* Get call for exam code (row[0]) */
if (sscanf (row[0],"%ld",&ExaCod) != 1)
Err_WrongCallForExamExit ();
/* Get UTC date-time of publication */
/* Get UTC date-time of publication (row[1]) */
CallTimeUTC = 0L;
if (row[1])
sscanf (row[1],"%ld",&CallTimeUTC);
@ -308,8 +281,8 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
fprintf (FileRSS,"<link>%s/?crs=%ld</link>\n",
Cfg_URL_SWAD_CGI,Crs->CrsCod);
/* Write full content of the exam announcement */
fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n",
/* Write full content of the exam announcement (row[2]) */
fprintf (FileRSS,"<description><![CDATA[<p><em>Fecha examen: %s</em></p>]]></description>\n", // TODO: Need translation!
row[2]);
/* Write unique string for this item */

View File

@ -143,6 +143,29 @@ unsigned Cfe_DB_GetVisibleCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res)
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
}
/*****************************************************************************/
/******* Get exam announcements (only future exams) in current course ********/
/*****************************************************************************/
unsigned Cfe_DB_GetFutureCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res)
{
/***** Get exam dates (ordered from older to more recent)
of future visible calls for exams
in current course from database *****/
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get calls for exams",
"SELECT ExaCod," // row[0]
"UNIX_TIMESTAMP(CallDate)," // row[1]
"DATE_FORMAT(ExamDate,'%%d/%%m/%%Y %%H:%%i')" // row[2]
" FROM cfe_exams"
" WHERE CrsCod=%ld"
" AND Status=%u"
" AND ExamDate>=NOW()"
" ORDER BY ExamDate",
Gbl.Hierarchy.Crs.CrsCod,
(unsigned) Cfe_VISIBLE_CALL_FOR_EXAM);
}
/*****************************************************************************/
/***************** Get data of a call for exam from database *****************/
/*****************************************************************************/

View File

@ -41,6 +41,7 @@ long Cfe_DB_CreateCallForExam (const struct Cfe_CallForExam *CallForExam);
unsigned Cfe_DB_GetCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res,bool ICanEdit);
unsigned Cfe_DB_GetVisibleCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res);
unsigned Cfe_DB_GetFutureCallsForExamsInCurrentCrs (MYSQL_RES **mysql_res);
unsigned Cfe_DB_GetDataCallForExam (MYSQL_RES **mysql_res,long ExaCod);
void Cfe_DB_ModifyCallForExam (const struct Cfe_CallForExam *CallForExam,

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.32.1 (2021-10-13)"
#define Log_PLATFORM_VERSION "SWAD 21.32.2 (2021-10-13)"
#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.32.2: Oct 13, 2021 Queries moved from RSS to other modules. (319785 lines)
Version 21.32.1: Oct 13, 2021 Queries moved to module swad_role_database. (319787 lines)
Version 21.32: Oct 13, 2021 New module swad_role_database for database queries related to user roles. (319611 lines)
Version 21.31.2: Oct 13, 2021 Queries moved to module swad_log_database. (319542 lines)

View File

@ -333,7 +333,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
switch (TypeNoticesListing)
{
case Not_LIST_BRIEF_NOTICES:
NumNotices = Not_DB_GetActiveNotices (&mysql_res);
NumNotices = Not_DB_GetActiveNotices (&mysql_res,Gbl.Hierarchy.Crs.CrsCod);
break;
case Not_LIST_FULL_NOTICES:
NumNotices = Not_DB_GetAllNotices (&mysql_res);

View File

@ -172,20 +172,20 @@ unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res)
/***************************** Get active notices ****************************/
/*****************************************************************************/
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res)
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get notices from database",
"SELECT NotCod," // row[0]
"UNIX_TIMESTAMP(CreatTime) AS F," // row[1]
"UsrCod," // row[2]
"Content," // row[3]
"Status" // row[4]
"SELECT NotCod," // row[0]
"UNIX_TIMESTAMP(CreatTime)," // row[1]
"UsrCod," // row[2]
"Content," // row[3]
"Status" // row[4]
" FROM not_notices"
" WHERE CrsCod=%ld"
" AND Status=%u"
" ORDER BY CreatTime DESC",
Gbl.Hierarchy.Crs.CrsCod,
CrsCod,
(unsigned) Not_ACTIVE_NOTICE);
}

View File

@ -50,7 +50,7 @@ void Not_DB_UpdateNumUsrsNotifiedByEMailAboutNotice (long NotCod,
unsigned Not_DB_GetDataOfNotice (MYSQL_RES **mysql_res,long NotCod);
unsigned Not_DB_ContentNotice (MYSQL_RES **mysql_res,long NotCod);
unsigned Not_DB_GetAllNotices (MYSQL_RES **mysql_res);
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res);
unsigned Not_DB_GetActiveNotices (MYSQL_RES **mysql_res,long CrsCod);
unsigned Not_DB_GetNumNotices (MYSQL_RES **mysql_res,
HieLvl_Level_t Scope,Not_Status_t Status);
unsigned Not_DB_GetNumNoticesDeleted (MYSQL_RES **mysql_res,