mirror of https://github.com/acanas/swad-core.git
Version 20.68: Apr 26, 2021 New module swad_error.
This commit is contained in:
parent
660147563c
commit
9af6b0d4f9
2
Makefile
2
Makefile
|
@ -35,7 +35,7 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
|
|||
swad_course_config.o swad_cryptography.o \
|
||||
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
|
||||
swad_degree_type.o swad_department.o swad_duplicate.o \
|
||||
swad_enrolment.o swad_exam.o swad_exam_log.o \
|
||||
swad_enrolment.o swad_error.o swad_exam.o swad_exam_log.o \
|
||||
swad_exam_print.o swad_exam_result.o swad_exam_session.o \
|
||||
swad_exam_set.o \
|
||||
swad_figure.o swad_figure_cache.o swad_file.o swad_file_browser.o \
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
11
swad_API.c
11
swad_API.c
|
@ -105,6 +105,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
|
|||
#include "swad_API.h"
|
||||
#include "swad_attendance.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_file_browser.h"
|
||||
#include "swad_forum.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -1653,7 +1654,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
|
|||
/***** Write page from file to text buffer *****/
|
||||
/* Open file */
|
||||
if ((FileHTML = fopen (PathRelFileHTML,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open XML file.");
|
||||
Err_ShowErrorAndExit ("Can not open XML file.");
|
||||
|
||||
/* Compute file size */
|
||||
fseek (FileHTML,0L,SEEK_END);
|
||||
|
@ -1664,7 +1665,7 @@ static int API_WritePageIntoHTMLBuffer (struct soap *soap,
|
|||
if ((*HTMLBuffer = malloc (Length + 1)) == NULL)
|
||||
{
|
||||
fclose (FileHTML);
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
return soap_receiver_fault (soap,
|
||||
"Web page can not be copied into buffer",
|
||||
"Not enough memory for buffer");
|
||||
|
@ -2262,7 +2263,7 @@ int swad__sendMyGroups (struct soap *soap,
|
|||
/***** Create a list of groups selected from myGroups *****/
|
||||
if ((LstGrpsIWant.GrpCods = calloc (LstGrpsIWant.NumGrps,
|
||||
sizeof (*LstGrpsIWant.GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
for (NumGrp = 0, Ptr = myGroups;
|
||||
*Ptr;
|
||||
NumGrp++)
|
||||
|
@ -2836,7 +2837,7 @@ static void API_GetLstGrpsSel (const char *Groups)
|
|||
// Here NestedCalls is always 1
|
||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
|
||||
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
for (Ptr = Groups, NumGrp = 0;
|
||||
*Ptr;
|
||||
|
@ -3636,7 +3637,7 @@ int swad__sendMessage (struct soap *soap,
|
|||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (API_MAX_BYTES_QUERY_RECIPIENTS + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Build query for recipients from database *****/
|
||||
if (ReplyUsrCod > 0)
|
||||
|
|
57
swad_HTML.c
57
swad_HTML.c
|
@ -30,6 +30,7 @@
|
|||
#include <stdio.h> // For vasprintf
|
||||
#include <stdlib.h> // For free
|
||||
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
||||
|
@ -128,7 +129,7 @@ void HTM_TABLE_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Class,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<table class=\"%s\">",Class);
|
||||
|
@ -252,7 +253,7 @@ void HTM_TBODY_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<tbody %s>",Attr);
|
||||
|
@ -294,7 +295,7 @@ void HTM_TR_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<tr %s>",Attr);
|
||||
|
@ -391,7 +392,7 @@ static void HTM_TH_BeginAttr (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<th %s>",Attr);
|
||||
|
@ -453,7 +454,7 @@ void HTM_TD_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<td %s>",Attr);
|
||||
|
@ -528,7 +529,7 @@ void HTM_DIV_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<div %s>",Attr);
|
||||
|
@ -619,7 +620,7 @@ void HTM_SPAN_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<span %s>",Attr);
|
||||
|
@ -685,7 +686,7 @@ void HTM_UL_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<ul %s>",Attr);
|
||||
|
@ -734,7 +735,7 @@ void HTM_LI_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<li %s>",Attr);
|
||||
|
@ -838,7 +839,7 @@ void HTM_A_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<a %s>",Attr);
|
||||
|
@ -915,7 +916,7 @@ void HTM_PARAM (const char *Name,
|
|||
NumBytesPrinted = vasprintf (&Value,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("\n<param name=\"%s\" value=\"%s\">",Name,Value);
|
||||
|
@ -942,7 +943,7 @@ void HTM_LABEL_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<label %s>",Attr);
|
||||
|
@ -996,7 +997,7 @@ void HTM_INPUT_TEXT (const char *Name,unsigned MaxLength,const char *Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1030,7 +1031,7 @@ void HTM_INPUT_SEARCH (const char *Name,unsigned MaxLength,const char *Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1061,7 +1062,7 @@ void HTM_INPUT_TEL (const char *Name,const char *Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1095,7 +1096,7 @@ void HTM_INPUT_EMAIL (const char *Name,unsigned MaxLength,const char *Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1126,7 +1127,7 @@ void HTM_INPUT_URL (const char *Name,const char *Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1161,7 +1162,7 @@ void HTM_INPUT_FILE (const char *Name,const char *Accept,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1221,7 +1222,7 @@ void HTM_INPUT_PASSWORD (const char *Name,const char *PlaceHolder,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1254,7 +1255,7 @@ void HTM_INPUT_LONG (const char *Name,long Min,long Max,long Value,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1301,7 +1302,7 @@ void HTM_INPUT_FLOAT (const char *Name,double Min,double Max,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1330,7 +1331,7 @@ void HTM_INPUT_RADIO (const char *Name,bool SubmitOnClick,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1362,7 +1363,7 @@ void HTM_INPUT_CHECKBOX (const char *Name,HTM_SubmitOnChange_t SubmitOnChange,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1476,7 +1477,7 @@ void HTM_TEXTAREA_Begin (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<textarea %s>",Attr);
|
||||
|
@ -1526,7 +1527,7 @@ void HTM_SELECT_Begin (HTM_SubmitOnChange_t SubmitOnChange,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_TxtF ("<select %s",Attr);
|
||||
|
@ -1614,7 +1615,7 @@ void HTM_OPTION (HTM_Type_t Type,const void *ValuePtr,bool Selected,bool Disable
|
|||
NumBytesPrinted = vasprintf (&Content,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_Txt (Content);
|
||||
|
@ -1661,7 +1662,7 @@ void HTM_IMG (const char *URL,const char *Icon,const char *Title,
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print attributes *****/
|
||||
HTM_SPTxt (Attr);
|
||||
|
@ -1762,7 +1763,7 @@ void HTM_TxtF (const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Attr,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Print HTML *****/
|
||||
HTM_Txt (Attr);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_account.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -151,7 +152,7 @@ void ID_ReallocateListIDs (struct UsrData *UsrDat,unsigned NumIDs)
|
|||
|
||||
/***** Allocate space for the list *****/
|
||||
if ((UsrDat->IDs.List = malloc (NumIDs * sizeof (*UsrDat->IDs.List))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -197,7 +198,7 @@ unsigned ID_GetListUsrCodsFromUsrID (struct UsrData *UsrDat,
|
|||
/***** Allocate memory for subquery string *****/
|
||||
MaxLength = 512 + UsrDat->IDs.Num * (1 + ID_MAX_BYTES_USR_ID + 1) - 1;
|
||||
if ((SubQueryAllUsrs = malloc (MaxLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
SubQueryAllUsrs[0] = '\0';
|
||||
|
||||
/***** Get user's code(s) from database *****/
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -80,7 +81,7 @@ void MFU_AllocateMFUActions (struct MFU_ListMFUActions *ListMFUActions,unsigned
|
|||
{
|
||||
if ((ListMFUActions->Actions = malloc (MaxActionsShown *
|
||||
sizeof (*ListMFUActions->Actions))) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
|
||||
Err_ShowErrorAndExit ("Can not allocate memory for list of most frequently used actions.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -357,7 +358,7 @@ void MFU_UpdateMFUActions (void)
|
|||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%lf",&Score) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting score for current action.");
|
||||
Err_ShowErrorAndExit ("Error when getting score for current action.");
|
||||
Score *= MFU_INCREASE_FACTOR;
|
||||
if (Score > MFU_MAX_SCORE)
|
||||
Score = MFU_MAX_SCORE;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdlib.h> // For free
|
||||
|
||||
#include "swad_action.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_ID.h"
|
||||
|
@ -118,7 +119,7 @@ void QR_ImageQRCode (const char *QRString)
|
|||
|
||||
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&chs=%ux%u&chl=%s",
|
||||
QR_CODE_SIZE,QR_CODE_SIZE,QRString) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,NULL,QRString,
|
||||
"style=\"width:%upx;height:%upx;border:1px dashed silver;\"",
|
||||
QR_CODE_SIZE,QR_CODE_SIZE);
|
||||
|
@ -141,13 +142,13 @@ void QR_LinkTo (unsigned Size,const char *ParamName,long Cod)
|
|||
{
|
||||
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&chs=%ux%u&chl=%s/?%s=%ld",
|
||||
Size,Size,Cfg_URL_SWAD_CGI,ParamName,Cod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&URL,"https://chart.googleapis.com/chart?cht=qr&chs=%ux%u&chl=%s/",
|
||||
Size,Size,Cfg_URL_SWAD_CGI) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
HTM_IMG (URL,NULL,Txt_Shortcut,
|
||||
"style=\"width:%upx;height:%upx;\"",Size,Size);
|
||||
|
@ -170,7 +171,7 @@ void QR_ExamAnnnouncement (void)
|
|||
300,300,
|
||||
Cfg_URL_SWAD_CGI,Gbl.Hierarchy.Crs.CrsCod,
|
||||
Act_GetActCod (ActSeeAllExaAnn)) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,NULL,Txt_Link_to_call_for_exam,
|
||||
"style=\"width:250px;height:250px;\"");
|
||||
free (URL);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_call_for_exam.h"
|
||||
#include "swad_changelog.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_notice.h"
|
||||
#include "swad_RSS.h"
|
||||
|
@ -74,7 +75,7 @@ void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs)
|
|||
snprintf (PathRelPublRSSFile,sizeof (PathRelPublRSSFile),"%s/%s",
|
||||
PathRelPublRSSDir,Cfg_RSS_FILE);
|
||||
if ((FileRSS = fopen (PathRelPublRSSFile,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not create RSS file.");
|
||||
Err_ShowErrorAndExit ("Can not create RSS file.");
|
||||
|
||||
/***** Write RSS header *****/
|
||||
fprintf (FileRSS,"<?xml version=\"1.0\" encoding=\"windows-1252\"?>\n");
|
||||
|
@ -186,7 +187,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs)
|
|||
|
||||
/* Get notice code */
|
||||
if (sscanf (row[0],"%ld",&NotCod) != 1)
|
||||
Lay_WrongNoticeExit ();
|
||||
Err_WrongNoticeExit ();
|
||||
|
||||
/* Get UTC date-time of publication */
|
||||
CreatTimeUTC = 0L;
|
||||
|
@ -290,7 +291,7 @@ static void RSS_WriteCallsForExams (FILE *FileRSS,struct Crs_Course *Crs)
|
|||
|
||||
/* Get call for exam code */
|
||||
if (sscanf (row[0],"%ld",&ExaCod) != 1)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/* Get UTC date-time of publication */
|
||||
CallTimeUTC = 0L;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_duplicate.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -738,7 +739,7 @@ void Acc_CreateNewUsr (struct UsrData *UsrDat,bool CreatingMyOwnAccount)
|
|||
|
||||
/***** Trivial check: user's code should be <= 0 *****/
|
||||
if (UsrDat->UsrCod > 0)
|
||||
Lay_ShowErrorAndExit ("Can not create new user.");
|
||||
Err_ShowErrorAndExit ("Can not create new user.");
|
||||
|
||||
/***** Create encrypted user's code *****/
|
||||
Acc_CreateNewEncryptedUsrCod (UsrDat);
|
||||
|
@ -844,7 +845,7 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
|
|||
break;
|
||||
}
|
||||
if (NumTry == MAX_TRY)
|
||||
Lay_ShowErrorAndExit ("Can not create a new encrypted user's code.");
|
||||
Err_ShowErrorAndExit ("Can not create a new encrypted user's code.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_group.h"
|
||||
|
@ -821,7 +822,7 @@ static void Agd_ShowOneEvent (struct Agd_Agenda *Agenda,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"agd_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LB COLOR%u\"",
|
||||
Id,
|
||||
AgdEvent.Hidden ? Dat_TimeStatusClassHidden[AgdEvent.TimeStatus] :
|
||||
|
@ -1074,7 +1075,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
|||
{
|
||||
if (asprintf (&UsrSubQuery,"UsrCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (AgendaType == Agd_MY_AGENDA_TODAY)
|
||||
Str_Copy (Past__FutureEventsSubQuery,
|
||||
" AND DATE(StartTime)<=CURDATE()"
|
||||
|
@ -1131,7 +1132,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
|||
case Agd_ANOTHER_AGENDA:
|
||||
if (asprintf (&UsrSubQuery,"UsrCod=%ld",
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (AgendaType == Agd_ANOTHER_AGENDA_TODAY)
|
||||
Str_Copy (Past__FutureEventsSubQuery,
|
||||
" AND DATE(StartTime)<=CURDATE()"
|
||||
|
@ -1170,7 +1171,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
|||
/***** Create list of events *****/
|
||||
if ((Agenda->LstAgdCods = calloc ((size_t) Agenda->Num,
|
||||
sizeof (*Agenda->LstAgdCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the events codes *****/
|
||||
for (NumEvent = 0;
|
||||
|
@ -1178,7 +1179,7 @@ static void Agd_GetListEvents (struct Agd_Agenda *Agenda,
|
|||
NumEvent++)
|
||||
/* Get next event code */
|
||||
if ((Agenda->LstAgdCods[NumEvent] = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -1327,7 +1328,7 @@ void Agd_AskRemEvent (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1363,7 +1364,7 @@ void Agd_RemoveEvent (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1402,7 +1403,7 @@ void Agd_HideEvent (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1438,7 +1439,7 @@ void Agd_UnhideEvent (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1475,7 +1476,7 @@ void Agd_MakeEventPrivate (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1516,7 +1517,7 @@ void Agd_MakeEventPublic (void)
|
|||
|
||||
/***** Get event code *****/
|
||||
if ((AgdEvent.AgdCod = Agd_GetParamAgdCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the event from database *****/
|
||||
AgdEvent.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
|
@ -1932,7 +1933,7 @@ unsigned Agd_GetNumUsrsWithEvents (Hie_Lvl_Level_t Scope)
|
|||
" AND crs_users.UsrCod=agd_agendas.UsrCod",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -2023,7 +2024,7 @@ unsigned Agd_GetNumEvents (Hie_Lvl_Level_t Scope)
|
|||
" AND crs_users.UsrCod=agd_agendas.UsrCod",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
}
|
||||
|
|
15
swad_alert.c
15
swad_alert.c
|
@ -33,6 +33,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_alert.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -78,7 +79,7 @@ void Ale_CreateAlert (Ale_AlertType_t Type,const char *Section,
|
|||
size_t i;
|
||||
|
||||
if (Gbl.Alerts.Num + 1 > Ale_MAX_ALERTS)
|
||||
Lay_ShowErrorAndExit ("Too many alerts.");
|
||||
Err_ShowErrorAndExit ("Too many alerts.");
|
||||
|
||||
i = Gbl.Alerts.Num;
|
||||
Gbl.Alerts.Num++;
|
||||
|
@ -90,13 +91,13 @@ void Ale_CreateAlert (Ale_AlertType_t Type,const char *Section,
|
|||
if (Section[0])
|
||||
if (asprintf (&Gbl.Alerts.List[i].Section,"%s",
|
||||
Section) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
va_start (ap,fmt);
|
||||
NumBytesPrinted = vasprintf (&Gbl.Alerts.List[i].Text,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -203,7 +204,7 @@ static void Ale_ResetAlert (size_t i)
|
|||
void Ale_ShowAlertsAndExit ()
|
||||
{
|
||||
Ale_ShowAlerts (NULL);
|
||||
Lay_ShowErrorAndExit (NULL);
|
||||
Err_ShowErrorAndExit (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -254,7 +255,7 @@ void Ale_ShowAlert (Ale_AlertType_t AlertType,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Show alert *****/
|
||||
Ale_ShowFixAlert (AlertType,Txt);
|
||||
|
@ -328,7 +329,7 @@ void Ale_ShowAlertAndButton (Act_Action_t NextAction,const char *Anchor,const ch
|
|||
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/****** Print fix alert and button ******/
|
||||
Ale_ShowFixAlertAndButton1 (AlertType,Txt);
|
||||
|
@ -355,7 +356,7 @@ void Ale_ShowAlertAndButton1 (Ale_AlertType_t AlertType,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Txt,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/****** Print start of fix alert and button ******/
|
||||
Ale_ShowFixAlertAndButton1 (AlertType,Txt);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "swad_announcement.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -155,7 +156,7 @@ void Ann_ShowAllAnnouncements (void)
|
|||
|
||||
/* Get announcement code (row[0]) */
|
||||
if (sscanf (row[0],"%ld",&AnnCod) != 1)
|
||||
Lay_WrongAnnouncementExit ();
|
||||
Err_WrongAnnouncementExit ();
|
||||
|
||||
/* Get status of the announcement (row[1]) */
|
||||
Status = Ann_OBSOLETE_ANNOUNCEMENT;
|
||||
|
@ -165,7 +166,7 @@ void Ann_ShowAllAnnouncements (void)
|
|||
|
||||
/* Get roles (row[2]) */
|
||||
if (sscanf (row[2],"%u",&Roles) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when reading roles of announcement.");
|
||||
Err_ShowErrorAndExit ("Error when reading roles of announcement.");
|
||||
|
||||
/* Get the subject (row[3]), the content (row[4]), and insert links */
|
||||
Str_Copy (Subject,row[3],sizeof (Subject) - 1);
|
||||
|
@ -260,7 +261,7 @@ void Ann_ShowMyAnnouncementsNotMarkedAsSeen (void)
|
|||
|
||||
/* Get announcement code (row[0]) */
|
||||
if (sscanf (row[0],"%ld",&AnnCod) != 1)
|
||||
Lay_WrongAnnouncementExit ();
|
||||
Err_WrongAnnouncementExit ();
|
||||
|
||||
/* Get the subject (row[1]), the content (row[2]), and insert links */
|
||||
Str_Copy (Subject,row[1],sizeof (Subject) - 1);
|
||||
|
@ -395,7 +396,7 @@ static long Ann_GetParamAnnCod (void)
|
|||
|
||||
/***** Get announcement code *****/
|
||||
if ((AnnCod = Par_GetParToLong ("AnnCod")) <= 0)
|
||||
Lay_WrongAnnouncementExit ();
|
||||
Err_WrongAnnouncementExit ();
|
||||
|
||||
return AnnCod;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_assignment.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -416,7 +417,7 @@ static void Asg_ShowOneAssignment (struct Asg_Assignments *Assignments,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"asg_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (PrintView)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LB\"",
|
||||
Id,
|
||||
|
@ -549,7 +550,7 @@ static void Asg_WriteAssignmentFolder (struct Asg_Assignment *Asg,bool PrintView
|
|||
Frm_BeginForm (ActFrmCreAsgCrs);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
||||
|
@ -734,7 +735,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
|||
/***** Create list of assignments *****/
|
||||
if ((Assignments->LstAsgCods = calloc (NumAsgs,
|
||||
sizeof (*Assignments->LstAsgCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the assignments codes *****/
|
||||
for (NumAsg = 0;
|
||||
|
@ -743,7 +744,7 @@ static void Asg_GetListAssignments (struct Asg_Assignments *Assignments)
|
|||
{
|
||||
/* Get next assignment code */
|
||||
if ((Assignments->LstAsgCods[NumAsg] = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongAssignmentExit ();
|
||||
Err_WrongAssignmentExit ();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -985,7 +986,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
Length = strlen (row[1]);
|
||||
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*ContentStr,row[1],Length);
|
||||
}
|
||||
}
|
||||
|
@ -1034,7 +1035,7 @@ void Asg_ReqRemAssignment (void)
|
|||
|
||||
/***** Get assignment code *****/
|
||||
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
|
||||
Lay_WrongAssignmentExit ();
|
||||
Err_WrongAssignmentExit ();
|
||||
|
||||
/***** Get data of the assignment from database *****/
|
||||
Asg_GetDataOfAssignmentByCod (&Asg);
|
||||
|
@ -1071,7 +1072,7 @@ void Asg_RemoveAssignment (void)
|
|||
|
||||
/***** Get assignment code *****/
|
||||
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
|
||||
Lay_WrongAssignmentExit ();
|
||||
Err_WrongAssignmentExit ();
|
||||
|
||||
/***** Get data of the assignment from database *****/
|
||||
Asg_GetDataOfAssignmentByCod (&Asg); // Inside this function, the course is checked to be the current one
|
||||
|
@ -1121,7 +1122,7 @@ void Asg_HideAssignment (void)
|
|||
|
||||
/***** Get assignment code *****/
|
||||
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
|
||||
Lay_WrongAssignmentExit ();
|
||||
Err_WrongAssignmentExit ();
|
||||
|
||||
/***** Get data of the assignment from database *****/
|
||||
Asg_GetDataOfAssignmentByCod (&Asg);
|
||||
|
@ -1158,7 +1159,7 @@ void Asg_ShowAssignment (void)
|
|||
|
||||
/***** Get assignment code *****/
|
||||
if ((Asg.AsgCod = Asg_GetParamAsgCod ()) <= 0)
|
||||
Lay_WrongAssignmentExit ();
|
||||
Err_WrongAssignmentExit ();
|
||||
|
||||
/***** Get data of the assignment from database *****/
|
||||
Asg_GetDataOfAssignmentByCod (&Asg);
|
||||
|
@ -1926,7 +1927,7 @@ unsigned Asg_GetNumCoursesWithAssignments (Hie_Lvl_Level_t Scope)
|
|||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -2014,20 +2015,20 @@ unsigned Asg_GetNumAssignments (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of assignments *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumAssignments) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of assignments.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of assignments.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications of assignments.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of assignments.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_attendance.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_group.h"
|
||||
|
@ -486,7 +487,7 @@ static void Att_ShowOneAttEvent (struct Att_Events *Events,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"att_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (ShowOnlyThisAttEventComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LB\"",
|
||||
Id,
|
||||
|
@ -711,7 +712,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
|||
{
|
||||
/***** Create list of attendance events *****/
|
||||
if ((Events->Lst = calloc (Events->Num,sizeof (*Events->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the attendance events codes *****/
|
||||
for (NumAttEvent = 0;
|
||||
|
@ -720,7 +721,7 @@ static void Att_GetListAttEvents (struct Att_Events *Events,
|
|||
{
|
||||
/* Get next attendance event code */
|
||||
if ((Events->Lst[NumAttEvent].AttCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -739,10 +740,10 @@ static void Att_GetDataOfAttEventByCodAndCheckCrs (struct Att_Event *Event)
|
|||
if (Att_GetDataOfAttEventByCod (Event))
|
||||
{
|
||||
if (Event->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
}
|
||||
else // Attendance event not found
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -920,7 +921,7 @@ void Att_AskRemAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the attendance event from database *****/
|
||||
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
||||
|
@ -955,7 +956,7 @@ void Att_GetAndRemAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the attendance event from database *****/
|
||||
// Inside this function, the course is checked to be the current one
|
||||
|
@ -998,7 +999,7 @@ void Att_HideAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the attendance event from database *****/
|
||||
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
||||
|
@ -1026,7 +1027,7 @@ void Att_ShowAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Get data of the attendance event from database *****/
|
||||
Att_GetDataOfAttEventByCodAndCheckCrs (&Event);
|
||||
|
@ -1753,7 +1754,7 @@ unsigned Att_GetNumCoursesWithAttEvents (Hie_Lvl_Level_t Scope)
|
|||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -1825,20 +1826,20 @@ unsigned Att_GetNumAttEvents (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of attendance events *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumAttEvents) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of attendance events.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of attendance events.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications of attendance events.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of attendance events.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
|
@ -1862,7 +1863,7 @@ void Att_SeeOneAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Events.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
|
||||
/***** Show event *****/
|
||||
Att_ShowEvent (&Events);
|
||||
|
@ -2097,7 +2098,7 @@ static void Att_WriteRowUsrToCallTheRoll (unsigned NumUsr,
|
|||
// A student can see only her/his attendance
|
||||
ItsMe = Usr_ItsMe (UsrDat->UsrCod);
|
||||
if (!ItsMe)
|
||||
Lay_ShowErrorAndExit ("Wrong call.");
|
||||
Err_ShowErrorAndExit ("Wrong call.");
|
||||
ICanChangeStdAttendance = false;
|
||||
ICanEditStdComment = Event->Open; // Attendance event is open
|
||||
ICanEditTchComment = false;
|
||||
|
@ -2260,7 +2261,7 @@ static void Att_PutParamsCodGrps (long AttCod)
|
|||
{
|
||||
MaxLengthGrpCods = NumGrps * (1 + 20) - 1;
|
||||
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
GrpCods[0] = '\0';
|
||||
|
||||
/* Get groups */
|
||||
|
@ -2307,7 +2308,7 @@ void Att_RegisterMeAsStdInAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
|
||||
|
||||
if (Event.Open)
|
||||
|
@ -2372,7 +2373,7 @@ void Att_RegisterStudentsInAttEvent (void)
|
|||
|
||||
/***** Get attendance event code *****/
|
||||
if ((Event.AttCod = Att_GetParamAttCod ()) < 0)
|
||||
Lay_WrongEventExit ();
|
||||
Err_WrongEventExit ();
|
||||
Att_GetDataOfAttEventByCodAndCheckCrs (&Event); // This checks that event belong to current course
|
||||
|
||||
/***** Get groups selected *****/
|
||||
|
@ -2739,7 +2740,7 @@ static void Att_ReqListOrPrintUsrsAttendanceCrs (void *TypeOfView)
|
|||
Att_FreeListAttEvents (&Events);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongTypeOfViewExit ();
|
||||
Err_WrongTypeOfViewExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2807,7 +2808,7 @@ static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
|
|||
NULL,Box_NOT_CLOSABLE);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongTypeOfViewExit ();
|
||||
Err_WrongTypeOfViewExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2837,7 +2838,7 @@ static void Att_ListOrPrintMyAttendanceCrs (Att_TypeOfView_t TypeOfView)
|
|||
Att_FreeListAttEvents (&Events);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongTypeOfViewExit ();
|
||||
Err_WrongTypeOfViewExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2923,7 +2924,7 @@ static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView)
|
|||
NULL,Box_NOT_CLOSABLE);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongTypeOfViewExit ();
|
||||
Err_WrongTypeOfViewExit ();
|
||||
}
|
||||
|
||||
/***** List events to select *****/
|
||||
|
@ -2957,7 +2958,7 @@ static void Att_ListOrPrintUsrsAttendanceCrs (void *TypeOfView)
|
|||
Grp_FreeListCodSelectedGrps ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongTypeOfViewExit ();
|
||||
Err_WrongTypeOfViewExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2982,7 +2983,7 @@ static void Att_GetListSelectedAttCods (struct Att_Events *Events)
|
|||
/***** Allocate memory for list of attendance events selected *****/
|
||||
MaxSizeListAttCodsSelected = (size_t) Events->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||
if ((Events->StrAttCodsSelected = malloc (MaxSizeListAttCodsSelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of attendance events selected *****/
|
||||
Par_GetParMultiToText ("AttCods",Events->StrAttCodsSelected,MaxSizeListAttCodsSelected);
|
||||
|
@ -3241,7 +3242,7 @@ static void Att_ListEventsToSelect (const struct Att_Events *Events,
|
|||
HTM_TD_End ();
|
||||
|
||||
if (asprintf (&Id,"att_date_start_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
HTM_LABEL_Begin ("for=\"Event%u\"",NumAttEvent);
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
|
@ -3684,7 +3685,7 @@ static void Att_ListAttEventsForAStd (const struct Att_Events *Events,
|
|||
HTM_TD_End ();
|
||||
|
||||
if (asprintf (&Id,"att_date_start_%u_%u",NumUsr,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("class=\"DAT LT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
HTM_SPAN_End ();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -311,7 +312,7 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
|||
|
||||
/***** Create list with banners *****/
|
||||
if ((Banners->Lst = calloc ((size_t) Banners->Num,sizeof (*Banners->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the banners *****/
|
||||
for (NumBan = 0;
|
||||
|
@ -325,7 +326,7 @@ static void Ban_GetListBanners (struct Ban_Banners *Banners,
|
|||
|
||||
/* Get banner code (row[0]) */
|
||||
if ((Ban->BanCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/* Get if banner is hidden (row[1]) */
|
||||
Ban->Hidden = (row[1][0] == 'Y');
|
||||
|
@ -573,7 +574,7 @@ void Ban_RemoveBanner (void)
|
|||
|
||||
/***** Get banner code *****/
|
||||
if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/***** Get data of the banner from database *****/
|
||||
Ban_GetDataOfBannerByCod (&Ban);
|
||||
|
@ -637,7 +638,7 @@ static void Ban_ShowOrHideBanner (struct Ban_Banner *Ban,bool Hide)
|
|||
{
|
||||
/***** Get banner code *****/
|
||||
if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/***** Get data of the banner from database *****/
|
||||
Ban_GetDataOfBannerByCod (Ban);
|
||||
|
@ -724,7 +725,7 @@ static void Ban_RenameBanner (struct Ban_Banner *Ban,
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the banner */
|
||||
if ((Ban->BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/* Get the new name for the banner */
|
||||
Par_GetParToText (ParamName,NewBanName,MaxBytes);
|
||||
|
@ -816,7 +817,7 @@ void Ban_ChangeBannerImg (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the banner */
|
||||
if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/* Get the new WWW for the banner */
|
||||
Par_GetParToText ("Img",NewImg,Ban_MAX_BYTES_IMAGE);
|
||||
|
@ -867,7 +868,7 @@ void Ban_ChangeBannerWWW (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the banner */
|
||||
if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/* Get the new WWW for the banner */
|
||||
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
||||
|
@ -1156,7 +1157,7 @@ void Ban_ClickOnBanner (void)
|
|||
|
||||
/***** Get banner code *****/
|
||||
if ((Ban.BanCod = Ban_GetParamBanCod ()) <= 0)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
|
||||
/***** Get data of the banner from database *****/
|
||||
Ban_GetDataOfBannerByCod (&Ban);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_help.h"
|
||||
|
@ -124,7 +125,7 @@ static void Box_BoxInternalBegin (const char *Width,const char *Title,
|
|||
|
||||
/***** Check level of nesting *****/
|
||||
if (Gbl.Box.Nested >= Box_MAX_NESTED - 1) // Can not nest a new box
|
||||
Lay_ShowErrorAndExit ("Box nesting limit reached.");
|
||||
Err_ShowErrorAndExit ("Box nesting limit reached.");
|
||||
|
||||
/***** Increase level of nesting *****/
|
||||
Gbl.Box.Nested++;
|
||||
|
@ -133,7 +134,7 @@ static void Box_BoxInternalBegin (const char *Width,const char *Title,
|
|||
if (Closable == Box_CLOSABLE)
|
||||
{
|
||||
if ((Gbl.Box.Ids[Gbl.Box.Nested] = malloc (Frm_MAX_BYTES_ID + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
Gbl.Box.Ids[Gbl.Box.Nested] = NULL;
|
||||
|
@ -224,7 +225,7 @@ void Box_BoxEnd (void)
|
|||
{
|
||||
/***** Check level of nesting *****/
|
||||
if (Gbl.Box.Nested < 0)
|
||||
Lay_ShowErrorAndExit ("Trying to end a box not open.");
|
||||
Err_ShowErrorAndExit ("Trying to end a box not open.");
|
||||
|
||||
/***** Free memory allocated for box id string *****/
|
||||
if (Gbl.Box.Ids[Gbl.Box.Nested])
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_building.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -355,7 +356,7 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
|||
{
|
||||
/***** Create list with courses in center *****/
|
||||
if ((Buildings->Lst = calloc ((size_t) Buildings->Num,sizeof (*Buildings->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the buildings *****/
|
||||
for (NumBuilding = 0;
|
||||
|
@ -369,7 +370,7 @@ void Bld_GetListBuildings (struct Bld_Buildings *Buildings,
|
|||
|
||||
/* Get building code (row[0]) */
|
||||
if ((Building->BldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongBuildingExit ();
|
||||
Err_WrongBuildingExit ();
|
||||
|
||||
/* Get the short name of the building (row[1]) */
|
||||
Str_Copy (Building->ShrtName,row[1],sizeof (Building->ShrtName) - 1);
|
||||
|
@ -552,7 +553,7 @@ void Bld_RemoveBuilding (void)
|
|||
|
||||
/***** Get building code *****/
|
||||
if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0)
|
||||
Lay_WrongBuildingExit ();
|
||||
Err_WrongBuildingExit ();
|
||||
|
||||
/***** Get data of the building from database *****/
|
||||
Bld_GetDataOfBuildingByCod (Bld_EditingBuilding);
|
||||
|
@ -649,7 +650,7 @@ static void Bld_RenameBuilding (Cns_ShrtOrFullName_t ShrtOrFullName)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the building */
|
||||
if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0)
|
||||
Lay_WrongBuildingExit ();
|
||||
Err_WrongBuildingExit ();
|
||||
|
||||
/* Get the new name for the building */
|
||||
Par_GetParToText (ParamName,NewClaName,MaxBytes);
|
||||
|
@ -742,7 +743,7 @@ void Bld_ChangeBuildingLocation (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the building */
|
||||
if ((Bld_EditingBuilding->BldCod = Bld_GetParamBldCod ()) <= 0)
|
||||
Lay_WrongBuildingExit ();
|
||||
Err_WrongBuildingExit ();
|
||||
|
||||
/* Get the new location for the building */
|
||||
Par_GetParToText ("Location",NewLocation,Bld_MAX_BYTES_LOCATION);
|
||||
|
@ -942,11 +943,11 @@ static void Bld_EditingBuildingConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Bld_EditingBuilding != NULL)
|
||||
Lay_WrongBuildingExit ();
|
||||
Err_WrongBuildingExit ();
|
||||
|
||||
/***** Allocate memory for building *****/
|
||||
if ((Bld_EditingBuilding = malloc (sizeof (*Bld_EditingBuilding))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset building *****/
|
||||
Bld_EditingBuilding->BldCod = -1L;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_call_for_exam.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
|
@ -262,25 +263,25 @@ static long Cfe_GetParamsCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
|||
static void Cfe_AllocMemCallForExam (struct Cfe_CallsForExams *CallsForExams)
|
||||
{
|
||||
if ((CallsForExams->CallForExam.Place = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.Mode = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.Structure = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.DocRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.MatRequired = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.MatAllowed = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((CallsForExams->CallForExam.OtherInfo = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -424,7 +425,7 @@ void Cfe_PrintCallForExam (void)
|
|||
|
||||
/***** Get the code of the call for exam *****/
|
||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Read call for exam from the database *****/
|
||||
Cfe_GetDataCallForExamFromDB (&CallsForExams,ExaCod);
|
||||
|
@ -453,7 +454,7 @@ void Cfe_ReqRemoveCallForExam (void)
|
|||
|
||||
/***** Get the code of the call for exam *****/
|
||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Show question and button to remove call for exam *****/
|
||||
/* Begin alert */
|
||||
|
@ -489,7 +490,7 @@ void Cfe_RemoveCallForExam1 (void)
|
|||
|
||||
/***** Get the code of the call for exam *****/
|
||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Mark the call for exam as deleted in the database *****/
|
||||
DB_QueryUPDATE ("can not remove call for exam",
|
||||
|
@ -538,7 +539,7 @@ void Cfe_HideCallForExam (void)
|
|||
|
||||
/***** Get the code of the call for exam *****/
|
||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Mark the call for exam as hidden in the database *****/
|
||||
DB_QueryUPDATE ("can not hide call for exam",
|
||||
|
@ -570,7 +571,7 @@ void Cfe_UnhideCallForExam (void)
|
|||
|
||||
/***** Get the code of the call for exam *****/
|
||||
if ((ExaCod = Cfe_GetParamExaCod ()) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Mark the call for exam as visible in the database *****/
|
||||
DB_QueryUPDATE ("can not unhide call for exam",
|
||||
|
@ -737,7 +738,7 @@ static void Cfe_ListCallsForExams (struct Cfe_CallsForExams *CallsForExams,
|
|||
{
|
||||
/***** Get the code of the call for exam (row[0]) *****/
|
||||
if ((ExaCod = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Allocate memory for the call for exam *****/
|
||||
Cfe_AllocMemCallForExam (CallsForExams);
|
||||
|
@ -921,7 +922,7 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
|||
{
|
||||
/***** Allocate memory for the list *****/
|
||||
if ((CallsForExams->Lst = calloc (NumExaAnns,sizeof (*CallsForExams->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the dates of the existing calls for exams *****/
|
||||
for (NumExaAnn = 0;
|
||||
|
@ -939,7 +940,7 @@ void Cfe_CreateListCallsForExams (struct Cfe_CallsForExams *CallsForExams)
|
|||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Year,
|
||||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Month,
|
||||
&CallsForExams->Lst[CallsForExams->NumCallsForExams].ExamDate.Day) != 3)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Increment number of elements in list *****/
|
||||
CallsForExams->NumCallsForExams++;
|
||||
|
@ -999,7 +1000,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
" FROM cfe_exams"
|
||||
" WHERE ExaCod=%ld",
|
||||
ExaCod) != 1)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/***** Get the data of the call for exam *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1009,9 +1010,9 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
|
||||
/* Status of the call for exam (row[1]) */
|
||||
if (sscanf (row[1],"%u",&UnsignedNum) != 1)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
if (UnsignedNum >= Cfe_NUM_STATUS)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
CallsForExams->CallForExam.Status = (Cfe_Status_t) UnsignedNum;
|
||||
|
||||
/* Name of the course (row[2]) */
|
||||
|
@ -1020,7 +1021,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
|
||||
/* Year (row[3]) */
|
||||
if (sscanf (row[3],"%u",&CallsForExams->CallForExam.Year) != 1)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/* Exam session (row[4]) */
|
||||
Str_Copy (CallsForExams->CallForExam.Session,row[4],
|
||||
|
@ -1034,7 +1035,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
&Hour,
|
||||
&Minute,
|
||||
&Second) != 6)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/* Date of exam (row[6]) */
|
||||
if (sscanf (row[6],"%04u-%02u-%02u %02u:%02u:%02u",
|
||||
|
@ -1044,7 +1045,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
&CallsForExams->CallForExam.StartTime.Hour,
|
||||
&CallsForExams->CallForExam.StartTime.Minute,
|
||||
&Second) != 6)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
snprintf (CallsForExams->CallForExam.ExamDate.YYYYMMDD,
|
||||
sizeof (CallsForExams->CallForExam.ExamDate.YYYYMMDD),"%04u%02u%02u",
|
||||
CallsForExams->CallForExam.ExamDate.Year,
|
||||
|
@ -1056,7 +1057,7 @@ static void Cfe_GetDataCallForExamFromDB (struct Cfe_CallsForExams *CallsForExam
|
|||
&CallsForExams->CallForExam.Duration.Hour,
|
||||
&CallsForExams->CallForExam.Duration.Minute,
|
||||
&Second) != 3)
|
||||
Lay_WrongCallForExamExit ();
|
||||
Err_WrongCallForExamExit ();
|
||||
|
||||
/* Place (row[8]), exam mode (row[9]), structure (row[10]),
|
||||
documentation required (row[11]), material required (row[12]),
|
||||
|
@ -1837,5 +1838,5 @@ static void Cfe_GetNotifContentCallForExam (const struct Cfe_CallsForExams *Call
|
|||
Txt_CALL_FOR_EXAM_Material_required,CallsForExams->CallForExam.MatRequired,
|
||||
Txt_CALL_FOR_EXAM_Material_allowed,CallsForExams->CallForExam.MatAllowed,
|
||||
Txt_CALL_FOR_EXAM_Other_information,CallsForExams->CallForExam.OtherInfo) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_center.h"
|
||||
#include "swad_center_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -577,7 +578,7 @@ void Ctr_GetBasicListOfCenters (long InsCod)
|
|||
/***** Create list with courses in degree *****/
|
||||
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
||||
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the centers *****/
|
||||
for (NumCtr = 0;
|
||||
|
@ -663,7 +664,7 @@ void Ctr_GetFullListOfCenters (long InsCod)
|
|||
/***** Create list with courses in degree *****/
|
||||
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
|
||||
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the centers *****/
|
||||
for (NumCtr = 0;
|
||||
|
@ -750,7 +751,7 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row)
|
|||
{
|
||||
/***** Get center code (row[0]) *****/
|
||||
if ((Ctr->CtrCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
|
||||
/***** Get institution code (row[1]) *****/
|
||||
Ctr->InsCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
@ -760,7 +761,7 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row)
|
|||
|
||||
/***** Get center status (row[3]) *****/
|
||||
if (sscanf (row[3],"%u",&(Ctr->Status)) != 1)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
|
||||
/***** Get requester user's code (row[4]) *****/
|
||||
Ctr->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
|
@ -881,7 +882,7 @@ void Ctr_WriteSelectorOfCenter (void)
|
|||
|
||||
/* Get center code (row[0]) */
|
||||
if ((CtrCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
|
||||
/* Write option */
|
||||
HTM_OPTION (HTM_Type_LONG,&CtrCod,
|
||||
|
@ -1185,7 +1186,7 @@ long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of center *****/
|
||||
if ((CtrCod = Par_GetParToLong ("OthCtrCod")) < MinCodAllowed)
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
|
||||
return CtrCod;
|
||||
}
|
||||
|
@ -1518,7 +1519,7 @@ void Ctr_ChangeCtrStatus (void)
|
|||
(unsigned long) Ctr_MAX_STATUS,
|
||||
(unsigned long) Ctr_WRONG_STATUS);
|
||||
if (Status == Ctr_WRONG_STATUS)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
StatusTxt = Ctr_GetStatusTxtFromStatusBits (Status);
|
||||
Status = Ctr_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
|
@ -1603,7 +1604,7 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places)
|
|||
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
||||
Frm_BeginForm (ActReqCtr);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Begin box and table *****/
|
||||
Box_BoxTableBegin (NULL,Txt_New_center,
|
||||
|
@ -2283,11 +2284,11 @@ static void Ctr_EditingCenterConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Ctr_EditingCtr != NULL)
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
|
||||
/***** Allocate memory for center *****/
|
||||
if ((Ctr_EditingCtr = malloc (sizeof (*Ctr_EditingCtr))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset center *****/
|
||||
Ctr_EditingCtr->CtrCod = -1L;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "swad_center.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -464,10 +465,10 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
|
|||
Cfg_URL_CTR_PUBLIC,
|
||||
(unsigned) (Gbl.Hierarchy.Ctr.CtrCod % 100),
|
||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Icon,"%u.jpg",
|
||||
(unsigned) Gbl.Hierarchy.Ctr.CtrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,Icon,Gbl.Hierarchy.Ctr.FullName,
|
||||
"class=\"%s\"",PrintView ? "CENTER_PHOTO_PRINT CENTER_PHOTO_WIDTH" :
|
||||
"CENTER_PHOTO_SHOW CENTER_PHOTO_WIDTH");
|
||||
|
@ -531,7 +532,7 @@ static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
|
|||
{
|
||||
Length = strlen (row[0]);
|
||||
if (((*PhotoAttribution) = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*PhotoAttribution,row[0],Length);
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +971,7 @@ void CtrCfg_ReceivePhoto (void)
|
|||
PathFileImg);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running command to process image.");
|
||||
Err_ShowErrorAndExit ("Error when running command to process image.");
|
||||
|
||||
/***** Write message depending on return code *****/
|
||||
ReturnCode = WEXITSTATUS(ReturnCode);
|
||||
|
@ -980,7 +981,7 @@ void CtrCfg_ReceivePhoto (void)
|
|||
"Image could not be processed successfully.<br />"
|
||||
"Error code returned by the program of processing: %d",
|
||||
ReturnCode);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
|
||||
/***** Remove temporary 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.67.11 (2021-04-26)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.68 (2021-04-26)"
|
||||
#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: Apr 26, 2021 New module swad_error. (309853 lines)
|
||||
Version 20.67.11: Apr 26, 2021 Fixed bug in departments. (309677 lines)
|
||||
Version 20.67.10: Apr 25, 2021 Fixed bug in notification about new assignment, reported by Eva Martínez Ortigosa. (? lines)
|
||||
Version 20.67.9: Apr 25, 2021 Fixed bug in users' works, reported by Eva Martínez Ortigosa. (309675 lines)
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_chat.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -176,7 +177,7 @@ void Cht_ShowListOfAvailableChatRooms (void)
|
|||
/* Get data of this degree */
|
||||
Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod;
|
||||
if (!Deg_GetDataOfDegreeByCod (&Deg))
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/* Link to the room of this degree */
|
||||
IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegs.Num - 1);
|
||||
|
@ -399,9 +400,9 @@ void Cht_OpenChatWindow (void)
|
|||
Par_GetParToText ("RoomFullName",RoomFullName,Cht_MAX_BYTES_ROOM_FULL_NAME);
|
||||
|
||||
if (!RoomCode[0] || !RoomShrtName[0] || !RoomFullName[0])
|
||||
Lay_ShowErrorAndExit ("Wrong code or name of chat room.");
|
||||
Err_ShowErrorAndExit ("Wrong code or name of chat room.");
|
||||
if (strcspn (RoomCode," \t\n\r") != strlen (RoomCode)) // If RoomCode contiene espacios
|
||||
Lay_ShowErrorAndExit ("Wrong code of chat room.");
|
||||
Err_ShowErrorAndExit ("Wrong code of chat room.");
|
||||
|
||||
/***** Fill the lists with the degrees and courses I belong to *****/
|
||||
Usr_GetMyDegrees ();
|
||||
|
@ -521,7 +522,7 @@ void Cht_OpenChatWindow (void)
|
|||
|
||||
/***** Open index.html file with the HTML page for the chat *****/
|
||||
if ((FileChat = fopen (Cfg_PATH_AND_FILE_REL_CHAT_PRIVATE,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open chat.");
|
||||
Err_ShowErrorAndExit ("Can not open chat.");
|
||||
|
||||
/***** Start writing the index.html file to the output *****/
|
||||
HTM_Txt ("Content-type: text/html; charset=windows-1252\n\n"); // Two carriage returns at the end of the line are mandatory!
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <string.h> // For strcasecmp...
|
||||
|
||||
#include "swad_config.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_layout.h"
|
||||
#include "swad_string.h"
|
||||
|
@ -78,7 +79,7 @@ void Cfg_GetConfigFromFile (void)
|
|||
/***** Read config from file to string *****/
|
||||
/* Open config file */
|
||||
if ((FileCfg = fopen (Cfg_FILE_CONFIG,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open config file.");
|
||||
Err_ShowErrorAndExit ("Can not open config file.");
|
||||
|
||||
/* Compute file size */
|
||||
fseek (FileCfg,0L,SEEK_END);
|
||||
|
@ -89,14 +90,14 @@ void Cfg_GetConfigFromFile (void)
|
|||
if ((Config = malloc (Length + 1)) == NULL)
|
||||
{
|
||||
fclose (FileCfg);
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Copy file content into buffer */
|
||||
if (fread (Config,sizeof (char),Length,FileCfg) != Length)
|
||||
{
|
||||
fclose (FileCfg);
|
||||
Lay_ShowErrorAndExit ("Can not read config.");
|
||||
Err_ShowErrorAndExit ("Can not read config.");
|
||||
}
|
||||
Config[Length] = '\0';
|
||||
|
||||
|
@ -116,5 +117,5 @@ void Cfg_GetConfigFromFile (void)
|
|||
|
||||
if (!Gbl.Config.DatabasePassword[0] ||
|
||||
!Gbl.Config.SMTPPassword[0])
|
||||
Lay_ShowErrorAndExit ("Bad config format.");
|
||||
Err_ShowErrorAndExit ("Bad config format.");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy_level.h"
|
||||
|
@ -104,7 +105,7 @@ void Con_ShowConnectedUsrs (void)
|
|||
if (asprintf (&Title,"%s"
|
||||
"<div id=\"connected_current_time\"></div>",
|
||||
Txt_Connected_users) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Box_BoxBegin (NULL,Title,
|
||||
Con_PutIconToUpdateConnected,NULL,
|
||||
Hlp_USERS_Connected,Box_NOT_CLOSABLE);
|
||||
|
@ -597,7 +598,7 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -741,12 +742,12 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t
|
|||
(unsigned) Role);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -754,11 +755,11 @@ static void Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_Role_t
|
|||
|
||||
/***** Get number of users (row[0]) *****/
|
||||
if (sscanf (row[0],"%u",&(Usrs->NumUsrs)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of connected users who belong to this location.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of connected users who belong to this location.");
|
||||
|
||||
/***** Get number of distinct sexs (row[1]) *****/
|
||||
if (sscanf (row[1],"%u",&NumSexs) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of sexs in connected users who belong to this location.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of sexs in connected users who belong to this location.");
|
||||
|
||||
/***** Get users' sex (row[2]) *****/
|
||||
Usrs->Sex = Usr_SEX_UNKNOWN;
|
||||
|
@ -910,7 +911,7 @@ static void Con_WriteRowConnectedUsrOnRightColumn (Rol_Role_t Role)
|
|||
Frm_BeginFormUnique (ActSeeRecOneTch);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
|
||||
|
@ -1111,12 +1112,12 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
|
|||
(unsigned) Role);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
if (NumUsrs)
|
||||
|
@ -1176,7 +1177,7 @@ static void Con_ShowConnectedUsrsCurrentLocationOneByOneOnMainZone (Rol_Role_t R
|
|||
Frm_BeginForm (ActSeeRecOneTch);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Usr_PutParamUsrCodEncrypted (UsrDat.EnUsrCod);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_country_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -564,7 +565,7 @@ void Cty_DrawCountryMap (struct Cty_Countr *Cty,const char *Class)
|
|||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_ICON_COUNTRIES_PUBLIC,
|
||||
Cty->Alpha2) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,Str_BuildStringStr ("%s.png",Cty->Alpha2),
|
||||
Cty->Name[Gbl.Prefs.Language],
|
||||
"class=\"%s\"",Class);
|
||||
|
@ -772,7 +773,7 @@ void Cty_GetBasicListOfCountries (void)
|
|||
/***** Create list with countries *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the countries *****/
|
||||
for (NumCty = 0;
|
||||
|
@ -786,7 +787,7 @@ void Cty_GetBasicListOfCountries (void)
|
|||
|
||||
/* Get numerical country code (row[0]) */
|
||||
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
/* Get Alpha-2 country code (row[1]) */
|
||||
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
|
||||
|
@ -862,7 +863,7 @@ void Cty_GetFullListOfCountries (void)
|
|||
/* Build order subquery */
|
||||
if (asprintf (&OrderBySubQuery,OrderBySubQueryFmt[Gbl.Hierarchy.Ctys.SelectedOrder],
|
||||
Lan_STR_LANG_ID[Gbl.Prefs.Language]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Query database */
|
||||
Gbl.Hierarchy.Ctys.Num = (unsigned)
|
||||
|
@ -898,7 +899,7 @@ void Cty_GetFullListOfCountries (void)
|
|||
/***** Create list with countries *****/
|
||||
if ((Gbl.Hierarchy.Ctys.Lst = calloc ((size_t) Gbl.Hierarchy.Ctys.Num,
|
||||
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the countries *****/
|
||||
for (NumCty = 0;
|
||||
|
@ -912,7 +913,7 @@ void Cty_GetFullListOfCountries (void)
|
|||
|
||||
/* Get numerical country code (row[0]) */
|
||||
if ((Cty->CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
/* Get Alpha-2 country code (row[1]) */
|
||||
Str_Copy (Cty->Alpha2,row[1],sizeof (Cty->Alpha2) - 1);
|
||||
|
@ -981,7 +982,7 @@ void Cty_WriteSelectorOfCountry (void)
|
|||
|
||||
/* Get country code (row[0]) */
|
||||
if ((CtyCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
/* Write option */
|
||||
HTM_OPTION (HTM_Type_LONG,&CtyCod,
|
||||
|
@ -1302,7 +1303,7 @@ long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of country *****/
|
||||
if ((CtyCod = Cty_GetParamOtherCtyCod ()) < MinCodAllowed)
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
return CtyCod;
|
||||
}
|
||||
|
@ -2119,11 +2120,11 @@ static void Cty_EditingCountryConstructor (void)
|
|||
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Cty_EditingCty != NULL)
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
/***** Allocate memory for country *****/
|
||||
if ((Cty_EditingCty = malloc (sizeof (*Cty_EditingCty))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset country *****/
|
||||
Cty_EditingCty->CtyCod = -1L;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -257,7 +258,7 @@ static void CtyCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
" AND ctr_centers.Latitude<>0"
|
||||
" AND ctr_centers.Longitude<>0",
|
||||
Gbl.Hierarchy.Cty.CtyCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
}
|
||||
|
@ -593,7 +594,7 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
|||
{
|
||||
Length = strlen (row[0]);
|
||||
if ((*MapAttribution = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*MapAttribution,row[0],Length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_course.h"
|
||||
#include "swad_course_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -215,7 +216,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/***** Get data of this institution *****/
|
||||
Hie.Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Cty_GetDataOfCountryByCod (&Hie.Cty))
|
||||
Lay_WrongCountrExit ();
|
||||
Err_WrongCountrExit ();
|
||||
|
||||
/***** Write link to country *****/
|
||||
Highlight = (Gbl.Hierarchy.Ins.InsCod <= 0 &&
|
||||
|
@ -249,7 +250,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/***** Get data of this institution *****/
|
||||
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Write link to institution *****/
|
||||
Highlight = (Gbl.Hierarchy.Ctr.CtrCod <= 0 &&
|
||||
|
@ -283,7 +284,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/***** Get data of this center *****/
|
||||
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr))
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
|
||||
/***** Write link to center *****/
|
||||
Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CTR &&
|
||||
|
@ -317,7 +318,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/***** Get data of this degree *****/
|
||||
Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/***** Write link to degree *****/
|
||||
Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_DEG &&
|
||||
|
@ -351,7 +352,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
/***** Get data of this course *****/
|
||||
Hie.Crs.CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/***** Write link to course *****/
|
||||
Highlight = (Gbl.Hierarchy.Level == Hie_Lvl_CRS &&
|
||||
|
@ -711,7 +712,7 @@ void Crs_WriteSelectorOfCourse (void)
|
|||
|
||||
/* Get course code (row[0]) */
|
||||
if ((CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/* Write option */
|
||||
HTM_OPTION (HTM_Type_LONG,&CrsCod,
|
||||
|
@ -812,7 +813,7 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses)
|
|||
/***** Create list with courses in degree *****/
|
||||
if ((Gbl.Hierarchy.Crss.Lst = calloc (NumCrss,
|
||||
sizeof (*Gbl.Hierarchy.Ctys.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the courses in degree *****/
|
||||
for (NumCrs = 0;
|
||||
|
@ -1464,7 +1465,7 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
||||
Frm_BeginForm (ActReqCrs);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Begin box and table *****/
|
||||
Box_BoxTableBegin (NULL,Txt_New_course,
|
||||
|
@ -1772,7 +1773,7 @@ void Crs_RemoveCourse (void)
|
|||
}
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1833,7 +1834,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
|
|||
{
|
||||
/***** Get course code (row[0]) *****/
|
||||
if ((Crs->CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/***** Get code of degree (row[1]) *****/
|
||||
Crs->DegCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
@ -1846,7 +1847,7 @@ static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row)
|
|||
|
||||
/***** Get course status (row[4]) *****/
|
||||
if (sscanf (row[4],"%u",&(Crs->Status)) != 1)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
|
||||
/***** Get requester user'code (row[5]) *****/
|
||||
Crs->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
@ -2128,7 +2129,7 @@ void Crs_ChangeInsCrsCod (void)
|
|||
Crs_EditingCrs->ShrtName);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2191,7 +2192,7 @@ void Crs_ChangeCrsYear (void)
|
|||
NewYear);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2332,7 +2333,7 @@ void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullNam
|
|||
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2397,7 +2398,7 @@ void Crs_ChangeCrsStatus (void)
|
|||
(unsigned long) Crs_MAX_STATUS,
|
||||
(unsigned long) Crs_WRONG_STATUS);
|
||||
if (Status == Crs_WRONG_STATUS)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
StatusTxt = Crs_GetStatusTxtFromStatusBits (Status);
|
||||
Status = Crs_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
|
@ -2619,7 +2620,7 @@ static long Crs_GetAndCheckParamOtherCrsCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of course *****/
|
||||
if ((CrsCod = Par_GetParToLong ("OthCrsCod")) < MinCodAllowed)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
return CrsCod;
|
||||
}
|
||||
|
@ -2647,12 +2648,12 @@ void Crs_GetAndWriteCrssOfAUsr (const struct UsrData *UsrDat,Rol_Role_t Role)
|
|||
if (Role == Rol_UNK) // Role == Rol_UNK ==> any role
|
||||
{
|
||||
if (asprintf (&SubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&SubQuery," AND crs_users.Role=%u",(unsigned) Role) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
NumCrss = (unsigned)
|
||||
DB_QuerySELECT (&mysql_res,"can not get courses of a user",
|
||||
|
@ -2826,13 +2827,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)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
if (!Deg_GetDataOfDegreeByCod (&Deg))
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/***** Get course code (row[1]) *****/
|
||||
if ((CrsCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/***** Get number of teachers and students in this course *****/
|
||||
NumStds = Usr_GetNumUsrsInCrss (Hie_Lvl_CRS,CrsCod,1 << Rol_STD);
|
||||
|
@ -3024,7 +3025,7 @@ void Crs_RemoveOldCrss (void)
|
|||
Crs_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS,
|
||||
UINT_MAX);
|
||||
if (MonthsWithoutAccess == UINT_MAX)
|
||||
Lay_ShowErrorAndExit ("Wrong number of months without clicks.");
|
||||
Err_ShowErrorAndExit ("Wrong number of months without clicks.");
|
||||
SecondsWithoutAccess = (unsigned long) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
||||
|
||||
/***** Get old courses from database *****/
|
||||
|
@ -3071,11 +3072,11 @@ static void Crs_EditingCourseConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Crs_EditingCrs != NULL)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/***** Allocate memory for course *****/
|
||||
if ((Crs_EditingCrs = malloc (sizeof (*Crs_EditingCrs))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset course *****/
|
||||
Crs_EditingCrs->CrsCod = -1L;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
|
@ -445,7 +446,7 @@ static void CrsCfg_Indicators (void)
|
|||
if (asprintf (&Title,"%u %s %u",
|
||||
IndicatorsCrs.NumIndicators,
|
||||
Txt_of_PART_OF_A_TOTAL,Ind_NUM_INDICATORS) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,"BT_LINK DAT",NULL);
|
||||
HTM_TxtF ("%s ",Title);
|
||||
Ico_PutIcon ((IndicatorsCrs.NumIndicators == Ind_NUM_INDICATORS) ? "check-circle.svg" :
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_language.h"
|
||||
|
@ -3741,7 +3742,7 @@ static void DB_CreateTable (const char *Query)
|
|||
void DB_OpenDBConnection (void)
|
||||
{
|
||||
if (mysql_init (&Gbl.mysql) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not init MySQL.");
|
||||
Err_ShowErrorAndExit ("Can not init MySQL.");
|
||||
|
||||
if (mysql_real_connect (&Gbl.mysql,Cfg_DATABASE_HOST,
|
||||
Cfg_DATABASE_USER,Gbl.Config.DatabasePassword,
|
||||
|
@ -3774,13 +3775,13 @@ void DB_BuildQuery (char **Query,const char *fmt,...)
|
|||
int NumBytesPrinted;
|
||||
|
||||
if (*Query != NULL)
|
||||
Lay_ShowErrorAndExit ("Error building query.");
|
||||
Err_ShowErrorAndExit ("Error building query.");
|
||||
|
||||
va_start (ap,fmt);
|
||||
NumBytesPrinted = vasprintf (Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3799,7 +3800,7 @@ unsigned long DB_QuerySELECT (MYSQL_RES **mysql_res,const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
return DB_QuerySELECTusingQueryStr (Query,mysql_res,MsgError);
|
||||
|
@ -3823,7 +3824,7 @@ long DB_QuerySELECTCode (const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
||||
|
@ -3856,7 +3857,7 @@ unsigned DB_QuerySELECTUnsigned (const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
||||
|
@ -3891,7 +3892,7 @@ double DB_QuerySELECTDouble (const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
||||
|
@ -3926,7 +3927,7 @@ Rol_Role_t DB_QuerySELECTRole (const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
if (DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError)) // Row found
|
||||
|
@ -3963,7 +3964,7 @@ void DB_QuerySELECTString (char *Str,size_t StrSize,const char *MsgError,
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Do SELECT query *****/
|
||||
Str[0] = '\0';
|
||||
|
@ -3985,7 +3986,7 @@ void DB_QuerySELECTString (char *Str,size_t StrSize,const char *MsgError,
|
|||
"Too large string from database,"
|
||||
" it exceed the maximum allowed size (%zu bytes).",
|
||||
StrSize);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4002,7 +4003,7 @@ static unsigned long DB_QuerySELECTusingQueryStr (char *Query,
|
|||
/***** Check that query string pointer
|
||||
does point to an allocated string *****/
|
||||
if (Query == NULL)
|
||||
Lay_ShowErrorAndExit ("Wrong query string.");
|
||||
Err_ShowErrorAndExit ("Wrong query string.");
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4060,7 +4061,7 @@ unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Make query "SELECT COUNT(*) FROM..." *****/
|
||||
DB_QuerySELECTusingQueryStr (Query,&mysql_res,MsgError);
|
||||
|
@ -4068,7 +4069,7 @@ unsigned long DB_QueryCOUNT (const char *MsgError,const char *fmt,...)
|
|||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%lu",&NumRows) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when counting number of rows.");
|
||||
Err_ShowErrorAndExit ("Error when counting number of rows.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -4091,7 +4092,7 @@ void DB_QueryINSERT (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4115,7 +4116,7 @@ long DB_QueryINSERTandReturnCode (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4142,7 +4143,7 @@ void DB_QueryREPLACE (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4166,7 +4167,7 @@ void DB_QueryUPDATE (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4190,7 +4191,7 @@ void DB_QueryDELETE (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4214,7 +4215,7 @@ void DB_Query (const char *MsgError,const char *fmt,...)
|
|||
NumBytesPrinted = vasprintf (&Query,fmt,ap);
|
||||
va_end (ap);
|
||||
if (NumBytesPrinted < 0) // -1 if no memory or any other error
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Query database and free query string pointer *****/
|
||||
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
|
||||
|
@ -4247,5 +4248,5 @@ void DB_ExitOnMySQLError (const char *Message)
|
|||
|
||||
snprintf (BigErrorMsg,sizeof (BigErrorMsg),"Database error: %s (%s).",
|
||||
Message,mysql_error (&Gbl.mysql));
|
||||
Lay_ShowErrorAndExit (BigErrorMsg);
|
||||
Err_ShowErrorAndExit (BigErrorMsg);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -384,7 +385,7 @@ struct tm *Dat_GetLocalTimeFromClock (const time_t *timep)
|
|||
struct tm *tm_ptr;
|
||||
|
||||
if ((tm_ptr = localtime (timep)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not get local time from clock.");
|
||||
Err_ShowErrorAndExit ("Can not get local time from clock.");
|
||||
|
||||
/***** Convert from sunday, monday, tuesday...
|
||||
to monday, tuesday, wednesday... *****/
|
||||
|
@ -716,9 +717,9 @@ void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id,
|
|||
|
||||
/***** Hidden field with UTC time (seconds since 1970) used to send time *****/
|
||||
if (asprintf (&IdTimeUTC,"%sTimeUTC",Id) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&ParamNameTimeUTC,"%sTimeUTC",ParamName) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Par_PutHiddenParamLong (IdTimeUTC,ParamNameTimeUTC,(long) TimeUTC);
|
||||
free (ParamNameTimeUTC);
|
||||
free (IdTimeUTC);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_degree.h"
|
||||
#include "swad_degree_config.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -296,7 +297,7 @@ void Deg_WriteSelectorOfDegree (void)
|
|||
|
||||
/* Get degree code (row[0]) */
|
||||
if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/* Write option */
|
||||
HTM_OPTION (HTM_Type_LONG,&DegCod,
|
||||
|
@ -604,7 +605,7 @@ static void Deg_PutFormToCreateDegree (void)
|
|||
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
||||
Frm_BeginForm (ActReqDeg);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Begin box and table *****/
|
||||
Box_BoxTableBegin (NULL,Txt_New_degree,
|
||||
|
@ -904,7 +905,7 @@ static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg)
|
|||
/***** Get data of type of degree of this degree *****/
|
||||
DegTyp.DegTypCod = Deg->DegTypCod;
|
||||
if (!DT_GetDataOfDegreeTypeByCod (&DegTyp))
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
if (Deg->Status & Deg_STATUS_BIT_PENDING)
|
||||
{
|
||||
|
@ -1103,7 +1104,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs)
|
|||
{
|
||||
/***** Create list with degrees *****/
|
||||
if ((Degs->Lst = calloc (Degs->Num,sizeof (*Degs->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the degrees *****/
|
||||
for (NumDeg = 0;
|
||||
|
@ -1155,7 +1156,7 @@ void Deg_GetListDegsInCurrentCtr (void)
|
|||
/***** Create list with degrees of this center *****/
|
||||
if ((Gbl.Hierarchy.Degs.Lst = calloc ((size_t) Gbl.Hierarchy.Degs.Num,
|
||||
sizeof (*Gbl.Hierarchy.Degs.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the degrees of this center *****/
|
||||
for (NumDeg = 0;
|
||||
|
@ -1339,7 +1340,7 @@ long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of degree *****/
|
||||
if ((DegCod = Par_GetParToLong ("OthDegCod")) < MinCodAllowed)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
return DegCod;
|
||||
}
|
||||
|
@ -1404,7 +1405,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
|
|||
{
|
||||
/***** Get degree code (row[0]) *****/
|
||||
if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/***** Get center code (row[1]) *****/
|
||||
Deg->CtrCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
@ -1414,7 +1415,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row)
|
|||
|
||||
/* Get course status (row[3]) */
|
||||
if (sscanf (row[3],"%u",&(Deg->Status)) != 1)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
|
||||
/* Get requester user's code (row[4]) */
|
||||
Deg->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[4]);
|
||||
|
@ -1512,7 +1513,7 @@ void Deg_RemoveDegreeCompletely (long DegCod)
|
|||
{
|
||||
/* Get next course */
|
||||
if ((CrsCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/* Remove course */
|
||||
Crs_RemoveCourseCompletely (CrsCod);
|
||||
|
@ -1807,7 +1808,7 @@ void Deg_ChangeDegStatus (void)
|
|||
(unsigned long) Deg_MAX_STATUS,
|
||||
(unsigned long) Deg_WRONG_STATUS);
|
||||
if (Status == Deg_WRONG_STATUS)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
StatusTxt = Deg_GetStatusTxtFromStatusBits (Status);
|
||||
Status = Deg_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
|
@ -2197,11 +2198,11 @@ static void Deg_EditingDegreeConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Deg_EditingDeg != NULL)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/***** Allocate memory for degree *****/
|
||||
if ((Deg_EditingDeg = malloc (sizeof (*Deg_EditingDeg))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset degree *****/
|
||||
Deg_EditingDeg->DegCod = -1L;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_degree.h"
|
||||
#include "swad_degree_type.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -697,7 +698,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
OrderBySubQuery[Order]);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -707,7 +708,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
/***** Create a list of degree types *****/
|
||||
if ((Gbl.DegTypes.Lst = calloc (Gbl.DegTypes.Num,
|
||||
sizeof (*Gbl.DegTypes.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get degree types *****/
|
||||
for (NumTyp = 0;
|
||||
|
@ -719,7 +720,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
|
||||
/* Get degree type code (row[0]) */
|
||||
if ((Gbl.DegTypes.Lst[NumTyp].DegTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
/* Get degree type name (row[1]) */
|
||||
Str_Copy (Gbl.DegTypes.Lst[NumTyp].DegTypName,row[1],
|
||||
|
@ -727,7 +728,7 @@ void DT_GetListDegreeTypes (Hie_Lvl_Level_t Scope,DT_Order_t Order)
|
|||
|
||||
/* Number of degrees of this type (row[2]) */
|
||||
if (sscanf (row[2],"%u",&Gbl.DegTypes.Lst[NumTyp].NumDegs) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of degrees of a type");
|
||||
Err_ShowErrorAndExit ("Error when getting number of degrees of a type");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -804,7 +805,7 @@ void DT_RemoveDegreeType (void)
|
|||
|
||||
/***** Get data of the degree type from database *****/
|
||||
if (!DT_GetDataOfDegreeTypeByCod (DT_EditingDegTyp))
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
/***** Check if this degree type has degrees *****/
|
||||
if (DT_EditingDegTyp->NumDegs) // Degree type has degrees => don't remove
|
||||
|
@ -842,7 +843,7 @@ long DT_GetAndCheckParamOtherDegTypCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of degree type *****/
|
||||
if ((DegTypCod = Par_GetParToLong ("OthDegTypCod")) < MinCodAllowed)
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
return DegTypCod;
|
||||
}
|
||||
|
@ -921,7 +922,7 @@ static void DT_RemoveDegreeTypeCompletely (long DegTypCod)
|
|||
{
|
||||
/* Get next degree */
|
||||
if ((DegCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/* Remove degree */
|
||||
Deg_RemoveDegreeCompletely (DegCod);
|
||||
|
@ -960,7 +961,7 @@ void DT_RenameDegreeType (void)
|
|||
|
||||
/***** Get from the database the old name of the degree type *****/
|
||||
if (!DT_GetDataOfDegreeTypeByCod (DT_EditingDegTyp))
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
/***** Check if new name is empty *****/
|
||||
if (NewNameDegTyp[0])
|
||||
|
@ -1045,11 +1046,11 @@ static void DT_EditingDegreeTypeConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (DT_EditingDegTyp != NULL)
|
||||
Lay_WrongDegTypExit ();
|
||||
Err_WrongDegTypExit ();
|
||||
|
||||
/***** Allocate memory for degree type *****/
|
||||
if ((DT_EditingDegTyp = malloc (sizeof (*DT_EditingDegTyp))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset degree type *****/
|
||||
DT_EditingDegTyp->DegTypCod = -1L;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_constant.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -377,7 +378,7 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
|
|||
/***** Create list with courses in degree *****/
|
||||
if ((Departments->Lst = calloc (Departments->Num,
|
||||
sizeof (*Departments->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the departments *****/
|
||||
for (NumDpt = 0;
|
||||
|
@ -391,11 +392,11 @@ static void Dpt_GetListDepartments (struct Dpt_Departments *Departments,long Ins
|
|||
|
||||
/* Get department code (row[0]) */
|
||||
if ((Dpt->DptCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongDepartmentExit ();
|
||||
Err_WrongDepartmentExit ();
|
||||
|
||||
/* Get institution code (row[1]) */
|
||||
if ((Dpt->InsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/* Get short name (row[2]), full name (row[3])
|
||||
and URL (row[4]) of the department */
|
||||
|
@ -644,7 +645,7 @@ long Dpt_GetAndCheckParamDptCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of department *****/
|
||||
if ((DptCod = Par_GetParToLong (Dpt_PARAM_DPT_COD_NAME)) < MinCodAllowed)
|
||||
Lay_WrongDepartmentExit ();
|
||||
Err_WrongDepartmentExit ();
|
||||
|
||||
return DptCod;
|
||||
}
|
||||
|
@ -1206,11 +1207,11 @@ static void Dpt_EditingDepartmentConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Dpt_EditingDpt != NULL)
|
||||
Lay_WrongDepartmentExit ();
|
||||
Err_WrongDepartmentExit ();
|
||||
|
||||
/***** Allocate memory for department *****/
|
||||
if ((Dpt_EditingDpt = malloc (sizeof (*Dpt_EditingDpt))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset department *****/
|
||||
Dpt_EditingDpt->DptCod = -1L;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_duplicate.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -204,7 +205,7 @@ void Dup_ListDuplicateUsrs (void)
|
|||
|
||||
/* Write number of informants (row[1]) if greater than 1 */
|
||||
if (sscanf (row[1],"%u",&NumInformants) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong number of informants.");
|
||||
Err_ShowErrorAndExit ("Wrong number of informants.");
|
||||
if (NumInformants > 1)
|
||||
{
|
||||
HTM_TxtColonNBSP (Txt_Informants);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_duplicate.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -243,7 +244,7 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole)
|
|||
case Rol_TCH:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
|
||||
/***** Update the role of a user in a course *****/
|
||||
|
@ -289,7 +290,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
|
|||
case Rol_TCH:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
|
||||
/***** Register user in current course in database *****/
|
||||
|
@ -363,7 +364,7 @@ static void Enr_NotifyAfterEnrolment (struct UsrData *UsrDat,Rol_Role_t NewRole)
|
|||
break;
|
||||
default:
|
||||
NotifyEvent = Ntf_EVENT_UNKNOWN;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
|
||||
/***** Remove possible enrolment request ******/
|
||||
|
@ -453,7 +454,7 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
Frm_BeginForm (ActAccEnrTch);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Btn_PutCreateButtonInline (Txt_Confirm_my_enrolment);
|
||||
Frm_EndForm ();
|
||||
|
@ -471,7 +472,7 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
Frm_BeginForm (ActRemMe_Tch);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Btn_PutRemoveButtonInline (Txt_Remove_me_from_this_course);
|
||||
Frm_EndForm ();
|
||||
|
@ -493,7 +494,7 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
break;
|
||||
default:
|
||||
NotifyEvent = Ntf_EVENT_UNKNOWN;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Ntf_MarkNotifAsSeen (NotifyEvent,-1L,Gbl.Hierarchy.Crs.CrsCod,
|
||||
|
@ -560,7 +561,7 @@ void Enr_UpdateUsrData (struct UsrData *UsrDat)
|
|||
|
||||
/***** Check if user's code is initialized *****/
|
||||
if (UsrDat->UsrCod <= 0)
|
||||
Lay_ShowErrorAndExit ("Can not update user's data. Wrong user's code.");
|
||||
Err_ShowErrorAndExit ("Can not update user's data. Wrong user's code.");
|
||||
|
||||
/***** Filter some user's data before updating */
|
||||
Enr_FilterUsrDat (UsrDat);
|
||||
|
@ -672,7 +673,7 @@ static void Enr_ReqAdminUsrs (Rol_Role_t Role)
|
|||
Enr_ReqAnotherUsrIDToRegisterRemove (Role);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +727,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -751,7 +752,7 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
|
@ -888,7 +889,7 @@ void Enr_RemoveOldUsrs (void)
|
|||
Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS,
|
||||
(unsigned long) UINT_MAX);
|
||||
if (MonthsWithoutAccess == UINT_MAX)
|
||||
Lay_ShowErrorAndExit ("Wrong number of months.");
|
||||
Err_ShowErrorAndExit ("Wrong number of months.");
|
||||
SecondsWithoutAccess = (time_t) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH;
|
||||
|
||||
/***** Get old users from database *****/
|
||||
|
@ -1106,16 +1107,16 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
|||
case Rol_STD:
|
||||
if (Gbl.Usrs.Me.Role.Logged < Rol_TCH) // Can I register/remove students?
|
||||
// No, I can not
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
if (Gbl.Usrs.Me.Role.Logged < Rol_DEG_ADM) // Can I register/remove teachers?
|
||||
// No, I can not
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1169,10 +1170,10 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
|||
WhatToDo.RegisterUsrs = false;
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Wrong registering / removing specification.");
|
||||
Err_ShowErrorAndExit ("Wrong registering / removing specification.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1206,7 +1207,7 @@ static void Enr_ReceiveFormUsrsCrs (Rol_Role_t Role)
|
|||
|
||||
/***** Get list of users' IDs *****/
|
||||
if ((ListUsrsIDs = malloc (ID_MAX_BYTES_LIST_USRS_IDS + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Par_GetParToText ("UsrsIDs",ListUsrsIDs,ID_MAX_BYTES_LIST_USRS_IDS);
|
||||
|
||||
/***** Initialize structure with user's data *****/
|
||||
|
@ -1810,7 +1811,7 @@ static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole,
|
|||
/***** Check if I can register this user *****/
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH &&
|
||||
RegRemRole != Rol_STD)
|
||||
Lay_ShowErrorAndExit ("A teacher only can register several users as students.");
|
||||
Err_ShowErrorAndExit ("A teacher only can register several users as students.");
|
||||
|
||||
/***** Check if the record of the user exists and get the type of user *****/
|
||||
if (UsrDat->UsrCod > 0) // User exists in database
|
||||
|
@ -1982,7 +1983,7 @@ void Enr_ReqSignUpInCrs (void)
|
|||
/***** Show form to modify only the user's role or the user's data *****/
|
||||
Rec_ShowFormSignUpInCrsWithMySharedRecord ();
|
||||
else
|
||||
Lay_ShowErrorAndExit ("You must be logged to sign up in a course."); // This never should happen
|
||||
Err_ShowErrorAndExit ("You must be logged to sign up in a course."); // This never should happen
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2016,7 +2017,7 @@ void Enr_SignUpInCrs (void)
|
|||
if (!(RoleFromForm == Rol_STD ||
|
||||
RoleFromForm == Rol_NET ||
|
||||
RoleFromForm == Rol_TCH))
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
|
||||
/***** Try to get and old request of the same user in the same course from database *****/
|
||||
ReqCod = DB_QuerySELECTCode ("can not get enrolment request",
|
||||
|
@ -2115,7 +2116,7 @@ void Enr_GetNotifEnrolmentRequest (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
if (asprintf (ContentStr,
|
||||
"%s", // TODO: Write more info in this content
|
||||
Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Free memory used for user's data */
|
||||
Usr_UsrDataDestructor (&UsrDat);
|
||||
|
@ -2179,7 +2180,7 @@ void Enr_AskIfRejectSignUp (void)
|
|||
Btn_REMOVE_BUTTON,Txt_Reject);
|
||||
}
|
||||
else
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2247,7 +2248,7 @@ void Enr_ShowEnrolmentRequests (void)
|
|||
(1 << Rol_TCH));
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2465,7 +2466,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2617,7 +2618,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2731,7 +2732,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2813,7 +2814,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2866,7 +2867,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2894,12 +2895,12 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
RolesSelected);
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3026,7 +3027,7 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected)
|
|||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
|
@ -3172,7 +3173,7 @@ void Enr_PutLinkToAdminSeveralUsrs (Rol_Role_t Role)
|
|||
default:
|
||||
NextAction = ActUnk;
|
||||
TitleText = NULL;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
Lay_PutContextualLinkIconText (NextAction,NULL,
|
||||
NULL,NULL,
|
||||
|
@ -3252,7 +3253,7 @@ static void Enr_ReqAnotherUsrIDToRegisterRemove (Rol_Role_t Role)
|
|||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Enr_WriteFormToReqAnotherUsrID (NextAction,NULL);
|
||||
|
@ -3890,7 +3891,7 @@ void Enr_CreateNewUsr1 (void)
|
|||
Gbl.Action.Act = ActCreTch;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Tab_SetCurrentTab ();
|
||||
|
@ -4021,7 +4022,7 @@ void Enr_ModifyUsr1 (void)
|
|||
Gbl.Action.Act = ActUpdTch;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Tab_SetCurrentTab ();
|
||||
|
@ -4186,7 +4187,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat)
|
|||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
|
|
|
@ -0,0 +1,600 @@
|
|||
// swad_layout.c: page layout
|
||||
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_layout.h"
|
||||
#include "swad_log.h"
|
||||
#include "swad_statistic.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when not enough memory **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_NotEnoughMemoryExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Not enough memory.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong action ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongActionExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong action.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong scope *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongScopeExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong scope.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit *********/
|
||||
/********* when wrong country, institution, center, degree or course *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongCountrExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong country.");
|
||||
}
|
||||
|
||||
void Err_WrongInstitExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong institution.");
|
||||
}
|
||||
|
||||
void Err_WrongCenterExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong center.");
|
||||
}
|
||||
|
||||
void Err_WrongDegTypExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong degree type.");
|
||||
}
|
||||
|
||||
void Err_WrongDegreeExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong degree.");
|
||||
}
|
||||
|
||||
void Err_WrongCourseExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong course.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong department **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongDepartmentExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong department.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong place ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongPlaceExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong department.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong order *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongOrderExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong order.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong status ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongStatusExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong status.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong date ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongDateExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong date.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong plugin ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongPluginExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong plugin.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong items list/item **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongItemsListExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong items list.");
|
||||
}
|
||||
|
||||
void Err_WrongItemExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong item.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong syllabus format **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongSyllabusFormatExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong syllabus format.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong file browser ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongFileBrowserExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong file browser.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong copy source *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongCopySrcExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("The copy source does not exist.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong number of rows ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongNumberOfRowsExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong number of rows.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit when wrong group type/group **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongGrpTypExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong group type.");
|
||||
}
|
||||
|
||||
void Err_WrongGroupExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong group.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong order *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongTypeOfViewExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong type of view.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong banner/link *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongBannerExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong banner.");
|
||||
}
|
||||
|
||||
void Err_WrongLinkExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong link.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong holiday ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongHolidayExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong holiday.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong building/room ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongBuildingExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong building.");
|
||||
}
|
||||
|
||||
void Err_WrongRoomExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong room.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong record field ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongRecordFieldExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong record field.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong assignment **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongAssignmentExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong assignment.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong project ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongProjectExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong project.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong call for exam ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongCallForExamExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong call for exam.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong tag *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongTagExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong tag.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong test *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongTestExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong test.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong exam *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongExamExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong exam.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit when wrong set of questions **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongSetExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong set of questions.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong question **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongQuestionExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong question.");
|
||||
}
|
||||
|
||||
void Err_WrongQuestionIndexExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong question index.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong answer ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongAnswerExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong answer.");
|
||||
}
|
||||
|
||||
void Err_WrongAnswerIndexExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong answer index.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong exam session ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongExamSessionExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong exam session.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong game/match *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongGameExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong game.");
|
||||
}
|
||||
|
||||
void Err_WrongMatchExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong match.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong survey ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongSurveyExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong survey.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Write error message and exit when wrong parameter "who" (which users) ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongWhoExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong parameter who.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Write error message and exit when wrong event **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongEventExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong event.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong announcement ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongAnnouncementExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong announcement.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong notice ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongNoticeExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong notice.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong forum/post *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongForumExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong forum.");
|
||||
}
|
||||
|
||||
void Err_WrongPostExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong post.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong message **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongMessageExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong message.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong mail domain ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongMailDomainExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong mail domain.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show error message about wrong role and exit ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongRoleExit (void)
|
||||
{
|
||||
Err_ShowErrorAndExit ("Wrong role.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when user does not exists *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_WrongUserExit (void)
|
||||
{
|
||||
extern const char *Txt_The_user_does_not_exist;
|
||||
|
||||
Err_ShowErrorAndExit (Txt_The_user_does_not_exist);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Write error message and exit when no permission to perform an action ****/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_NoPermissionExit (void)
|
||||
{
|
||||
extern const char *Txt_You_dont_have_permission_to_perform_this_action;
|
||||
|
||||
Err_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Write error message, close files, remove lock file, and exit ********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_ShowErrorAndExit (const char *Txt)
|
||||
{
|
||||
/***** Unlock tables if locked *****/
|
||||
if (Gbl.DB.LockedTables)
|
||||
{
|
||||
Gbl.DB.LockedTables = false;
|
||||
mysql_query (&Gbl.mysql,"UNLOCK TABLES");
|
||||
}
|
||||
|
||||
if (!Gbl.WebService.IsWebService)
|
||||
{
|
||||
/****** If start of page is not written yet, do it now ******/
|
||||
if (!Gbl.Layout.HTMLStartWritten)
|
||||
Lay_WriteStartOfPage ();
|
||||
|
||||
/***** Write possible error message *****/
|
||||
if (Txt)
|
||||
Ale_ShowAlert (Ale_ERROR,Txt);
|
||||
|
||||
/***** Finish the page, except </body> and </html> *****/
|
||||
Lay_WriteEndOfPage ();
|
||||
}
|
||||
|
||||
/***** Free memory and close all the open files *****/
|
||||
Gbl_Cleanup ();
|
||||
|
||||
/***** Page is generated (except </body> and </html>).
|
||||
Compute time to generate page *****/
|
||||
if (!Gbl.Action.IsAJAXAutoRefresh)
|
||||
Gbl.TimeGenerationInMicroseconds = (long) Sta_ComputeTimeToGeneratePage ();
|
||||
|
||||
if (Gbl.WebService.IsWebService) // Serving a plugin request
|
||||
{
|
||||
/***** Log access *****/
|
||||
Gbl.TimeSendInMicroseconds = 0L;
|
||||
Log_LogAccess (Txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
/***** Send page.
|
||||
The HTML output is now in Gbl.F.Out file ==>
|
||||
==> copy it to standard output *****/
|
||||
rewind (Gbl.F.Out);
|
||||
Fil_FastCopyOfOpenFiles (Gbl.F.Out,stdout);
|
||||
Fil_CloseAndRemoveFileForHTMLOutput ();
|
||||
|
||||
if (!Gbl.Action.IsAJAXAutoRefresh)
|
||||
{
|
||||
/***** Compute time to send page *****/
|
||||
Sta_ComputeTimeToSendPage ();
|
||||
|
||||
/***** Log access *****/
|
||||
Log_LogAccess (Txt);
|
||||
|
||||
/***** Update last data for next time *****/
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
Usr_UpdateMyLastData ();
|
||||
Crs_UpdateCrsLast ();
|
||||
}
|
||||
|
||||
/***** End the output *****/
|
||||
if (!Gbl.Layout.HTMLEndWritten)
|
||||
{
|
||||
// Here Gbl.F.Out is stdout
|
||||
if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
|
||||
Lay_WriteAboutZone ();
|
||||
|
||||
HTM_Txt ("</body>\n"
|
||||
"</html>\n");
|
||||
Gbl.Layout.HTMLEndWritten = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***** Close database connection *****/
|
||||
DB_CloseDBConnection ();
|
||||
|
||||
/***** Exit *****/
|
||||
if (Gbl.WebService.IsWebService)
|
||||
API_Exit (Txt);
|
||||
exit (0);
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// swad_error.h: exit on error
|
||||
|
||||
#ifndef _SWAD_ERR
|
||||
#define _SWAD_ERR
|
||||
/*
|
||||
SWAD (Shared Workspace At a Distance in Spanish),
|
||||
is a web platform developed at the University of Granada (Spain),
|
||||
and used to support university teaching.
|
||||
|
||||
This file is part of SWAD core.
|
||||
Copyright (C) 1999-2021 Antonio Cañas Vargas
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*****************************************************************************/
|
||||
/********************************* Headers ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************************* Public types ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Err_NotEnoughMemoryExit (void);
|
||||
void Err_WrongActionExit (void);
|
||||
void Err_WrongScopeExit (void);
|
||||
void Err_WrongCountrExit (void);
|
||||
void Err_WrongInstitExit (void);
|
||||
void Err_WrongCenterExit (void);
|
||||
void Err_WrongDegTypExit (void);
|
||||
void Err_WrongDegreeExit (void);
|
||||
void Err_WrongCourseExit (void);
|
||||
void Err_WrongDepartmentExit (void);
|
||||
void Err_WrongPlaceExit (void);
|
||||
void Err_WrongOrderExit (void);
|
||||
void Err_WrongStatusExit (void);
|
||||
void Err_WrongDateExit (void);
|
||||
void Err_WrongPluginExit (void);
|
||||
void Err_WrongItemsListExit (void);
|
||||
void Err_WrongItemExit (void);
|
||||
void Err_WrongSyllabusFormatExit (void);
|
||||
void Err_WrongFileBrowserExit (void);
|
||||
void Err_WrongCopySrcExit (void);
|
||||
void Err_WrongNumberOfRowsExit (void);
|
||||
void Err_WrongGrpTypExit (void);
|
||||
void Err_WrongGroupExit (void);
|
||||
void Err_WrongTypeOfViewExit (void);
|
||||
void Err_WrongBannerExit (void);
|
||||
void Err_WrongLinkExit (void);
|
||||
void Err_WrongHolidayExit (void);
|
||||
void Err_WrongBuildingExit (void);
|
||||
void Err_WrongRoomExit (void);
|
||||
void Err_WrongRecordFieldExit (void);
|
||||
void Err_WrongAssignmentExit (void);
|
||||
void Err_WrongProjectExit (void);
|
||||
void Err_WrongCallForExamExit (void);
|
||||
void Err_WrongTagExit (void);
|
||||
void Err_WrongTestExit (void);
|
||||
void Err_WrongExamExit (void);
|
||||
void Err_WrongSetExit (void);
|
||||
void Err_WrongQuestionExit (void);
|
||||
void Err_WrongQuestionIndexExit (void);
|
||||
void Err_WrongAnswerExit (void);
|
||||
void Err_WrongAnswerIndexExit (void);
|
||||
void Err_WrongExamSessionExit (void);
|
||||
void Err_WrongGameExit (void);
|
||||
void Err_WrongMatchExit (void);
|
||||
void Err_WrongSurveyExit (void);
|
||||
void Err_WrongWhoExit (void);
|
||||
void Err_WrongEventExit (void);
|
||||
void Err_WrongAnnouncementExit (void);
|
||||
void Err_WrongNoticeExit (void);
|
||||
void Err_WrongForumExit (void);
|
||||
void Err_WrongPostExit (void);
|
||||
void Err_WrongMessageExit (void);
|
||||
void Err_WrongMailDomainExit (void);
|
||||
void Err_WrongRoleExit (void);
|
||||
void Err_WrongUserExit (void);
|
||||
void Err_NoPermissionExit (void);
|
||||
void Err_ShowErrorAndExit (const char *Txt);
|
||||
|
||||
#endif
|
49
swad_exam.c
49
swad_exam.c
|
@ -35,6 +35,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_exam_result.h"
|
||||
|
@ -425,7 +426,7 @@ void Exa_SeeOneExam (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
|
||||
/***** Get exam data *****/
|
||||
|
@ -525,7 +526,7 @@ static void Exa_ShowOneExam (struct Exa_Exams *Exams,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"exa_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Color = Exam->NumOpenSess ? (Exam->Hidden ? "DATE_GREEN_LIGHT":
|
||||
"DATE_GREEN") :
|
||||
(Exam->Hidden ? "DATE_RED_LIGHT":
|
||||
|
@ -812,7 +813,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
|||
{
|
||||
case Rol_STD:
|
||||
if (asprintf (&HiddenSubQuery," AND exa_exams.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
|
@ -821,10 +822,10 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
|||
case Rol_INS_ADM:
|
||||
case Rol_SYS_ADM:
|
||||
if (asprintf (&HiddenSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -853,7 +854,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
|||
/***** Create list of exams *****/
|
||||
if ((Exams->Lst = malloc ((size_t) Exams->Num *
|
||||
sizeof (*Exams->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the exams codes *****/
|
||||
for (NumExam = 0;
|
||||
|
@ -863,7 +864,7 @@ void Exa_GetListExams (struct Exa_Exams *Exams,Exa_Order_t SelectedOrder)
|
|||
/* Get next exam code (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if ((Exams->Lst[NumExam].ExaCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -888,7 +889,7 @@ void Exa_GetListSelectedExaCods (struct Exa_Exams *Exams)
|
|||
/***** Allocate memory for list of exams selected *****/
|
||||
MaxSizeListExaCodsSelected = Exams->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||
if ((Exams->ExaCodsSelected = malloc (MaxSizeListExaCodsSelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of exams selected *****/
|
||||
Par_GetParMultiToText ("ExaCod",Exams->ExaCodsSelected,MaxSizeListExaCodsSelected);
|
||||
|
@ -1083,7 +1084,7 @@ void Exa_AskRemExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1092,7 +1093,7 @@ void Exa_AskRemExam (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
|
||||
/***** Get data of the exam from database *****/
|
||||
|
@ -1123,7 +1124,7 @@ void Exa_RemoveExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1131,7 +1132,7 @@ void Exa_RemoveExam (void)
|
|||
|
||||
/***** Get exam code *****/
|
||||
if ((Exam.ExaCod = Exa_GetParamExamCod ()) <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
|
||||
/***** Get data of the exam from database *****/
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
|
@ -1304,7 +1305,7 @@ void Exa_HideExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1313,7 +1314,7 @@ void Exa_HideExam (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
|
||||
/***** Get data of the exam from database *****/
|
||||
|
@ -1342,7 +1343,7 @@ void Exa_UnhideExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1351,7 +1352,7 @@ void Exa_UnhideExam (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
|
||||
/***** Get data of the exam from database *****/
|
||||
|
@ -1400,7 +1401,7 @@ void Exa_RequestCreatOrEditExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1578,7 +1579,7 @@ void Exa_ReceiveFormExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -1746,7 +1747,7 @@ unsigned Exa_GetParamQstInd (void)
|
|||
long QstInd;
|
||||
|
||||
if ((QstInd = Par_GetParToLong ("QstInd")) <= 0)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
return (unsigned) QstInd;
|
||||
}
|
||||
|
@ -1768,7 +1769,7 @@ long Exa_GetQstCodFromQstInd (long ExaCod,unsigned QstInd)
|
|||
ExaCod,
|
||||
QstInd);
|
||||
if (QstCod <= 0)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
return QstCod;
|
||||
}
|
||||
|
@ -1909,7 +1910,7 @@ unsigned Exa_GetNumCoursesWithExams (Hie_Lvl_Level_t Scope)
|
|||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -1979,7 +1980,7 @@ unsigned Exa_GetNumExams (Hie_Lvl_Level_t Scope)
|
|||
" WHERE CrsCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -2072,7 +2073,7 @@ double Exa_GetNumQstsPerCrsExam (Hie_Lvl_Level_t Scope)
|
|||
" GROUP BY exa_set_questions.ExaCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0.0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -2096,7 +2097,7 @@ void Exa_GetScoreRange (long ExaCod,double *MinScore,double *MaxScore)
|
|||
" GROUP BY tst_answers.QstCod",
|
||||
ExaCod);
|
||||
if (NumAnswers < 2)
|
||||
Lay_ShowErrorAndExit ("Wrong number of answers.");
|
||||
Err_ShowErrorAndExit ("Wrong number of answers.");
|
||||
|
||||
/***** Set minimum and maximum scores *****/
|
||||
*MinScore = *MaxScore = 0.0;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_log.h"
|
||||
#include "swad_global.h"
|
||||
|
||||
|
@ -231,7 +232,7 @@ static void ExaLog_LogUsrAgent (long LogCod,long PrnCod)
|
|||
else
|
||||
MaxBytes = 0;
|
||||
if ((UserAgentDB = malloc (MaxBytes + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (UserAgent)
|
||||
{
|
||||
Str_Copy (UserAgentDB,UserAgent,MaxBytes);
|
||||
|
@ -389,7 +390,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
/* Get session id (row[6]) */
|
||||
if (asprintf (&UserAgent,"%s",row[6] ? row[6] :
|
||||
"=") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Set color of row depending on action *****/
|
||||
if (UsrCouldAnswer)
|
||||
|
@ -422,7 +423,7 @@ void ExaLog_ShowExamLog (const struct ExaPrn_Print *Print)
|
|||
|
||||
/* Write click time */
|
||||
if (asprintf (&Id,"click_date_%u",NumClick) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT COLOR%u %s\"",Id,Gbl.RowEvenOdd,Class);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,ClickTimeUTC,
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_exam_log.h"
|
||||
#include "swad_exam_print.h"
|
||||
|
@ -415,7 +416,7 @@ static void ExaPrn_GetQuestionsForNewPrintFromDB (struct ExaPrn_Print *Print,lon
|
|||
|
||||
/***** Check *****/
|
||||
if (Print->NumQsts.All != NumQstInPrint)
|
||||
Lay_ShowErrorAndExit ("Wrong number of questions.");
|
||||
Err_ShowErrorAndExit ("Wrong number of questions.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -556,7 +557,7 @@ static void ExaPrn_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *Printed
|
|||
else
|
||||
ErrorInIndex = true;
|
||||
if (ErrorInIndex)
|
||||
Lay_WrongAnswerIndexExit ();
|
||||
Err_WrongAnswerIndexExit ();
|
||||
|
||||
if (NumOpt == 0)
|
||||
snprintf (StrInd,sizeof (StrInd),"%u",Index);
|
||||
|
@ -635,16 +636,16 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
|||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get set code (row[1]) */
|
||||
if ((Print->PrintedQuestions[NumQst].SetCod = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
|
||||
/* Get score (row[2]) */
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[2],"%lf",&Print->PrintedQuestions[NumQst].Score) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong question score.");
|
||||
Err_ShowErrorAndExit ("Wrong question score.");
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
|
||||
/* Get indexes for this question (row[3]) */
|
||||
|
@ -660,7 +661,7 @@ void ExaPrn_GetPrintQuestionsFromDB (struct ExaPrn_Print *Print)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (Print->NumQsts.All > ExaPrn_MAX_QUESTIONS_PER_EXAM_PRINT)
|
||||
Lay_ShowErrorAndExit ("Too many questions.");
|
||||
Err_ShowErrorAndExit ("Too many questions.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1066,22 +1067,22 @@ void ExaPrn_ReceivePrintAnswer (void)
|
|||
Print.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
|
||||
ExaPrn_GetDataOfPrintBySesCodAndUsrCod (&Print);
|
||||
if (Print.PrnCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
|
||||
/***** Get session data *****/
|
||||
Session.SesCod = Print.SesCod;
|
||||
ExaSes_GetDataOfSessionByCod (&Session);
|
||||
if (Session.SesCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.SesCod = Session.SesCod;
|
||||
|
||||
/***** Get exam data *****/
|
||||
Exam.ExaCod = Session.ExaCod;
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
if (Exam.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
if (Exam.CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.ExaCod = Exam.ExaCod;
|
||||
|
||||
/***** Get question index from form *****/
|
||||
|
@ -1153,7 +1154,7 @@ static unsigned ExaPrn_GetParamQstInd (void)
|
|||
|
||||
NumQst = Par_GetParToLong ("NumQst");
|
||||
if (NumQst < 0)
|
||||
Lay_ShowErrorAndExit ("Wrong number of question.");
|
||||
Err_ShowErrorAndExit ("Wrong number of question.");
|
||||
|
||||
return (unsigned) NumQst;
|
||||
}
|
||||
|
@ -1289,7 +1290,7 @@ static void ExaPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question)
|
|||
/***** Get correct answer *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%ld",&Question->Answer.Integer) != 1)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -1312,7 +1313,7 @@ static void ExaPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question)
|
|||
|
||||
/***** Check if number of rows is correct *****/
|
||||
if (Question->Answer.NumOptions != 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Get float range *****/
|
||||
for (NumOpt = 0;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_action.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_exam_log.h"
|
||||
#include "swad_exam_print.h"
|
||||
|
@ -204,7 +205,7 @@ void ExaRes_ShowMyResultsInExa (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
|
||||
/***** Get exam data from database *****/
|
||||
|
@ -256,10 +257,10 @@ void ExaRes_ShowMyResultsInSes (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0)
|
||||
Lay_WrongExamSessionExit ();
|
||||
Err_WrongExamSessionExit ();
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
Exams.ExaCod = Exam.ExaCod;
|
||||
ExaSes_GetDataOfSessionByCod (&Session);
|
||||
|
@ -406,7 +407,7 @@ void ExaRes_ShowAllResultsInExa (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
Exams.ExaCod = Exam.ExaCod;
|
||||
|
@ -493,10 +494,10 @@ void ExaRes_ShowAllResultsInSes (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
if ((Session.SesCod = ExaSes_GetParamSesCod ()) <= 0)
|
||||
Lay_WrongExamSessionExit ();
|
||||
Err_WrongExamSessionExit ();
|
||||
|
||||
/***** Get exam data and session *****/
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
|
@ -777,7 +778,7 @@ static void ExaRes_BuildExamsSelectedCommas (struct Exa_Exams *Exams,
|
|||
/***** Allocate memory for subquery of exams selected *****/
|
||||
MaxLength = (size_t) Exams->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||
if ((*ExamsSelectedCommas = malloc (MaxLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Build subquery with list of selected exams *****/
|
||||
(*ExamsSelectedCommas)[0] = '\0';
|
||||
|
@ -845,12 +846,12 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
if (SesCod > 0) // One unique session
|
||||
{
|
||||
if (asprintf (&SesSubQuery," AND exa_prints.SesCod=%ld",SesCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // All sessions of selected exams
|
||||
{
|
||||
if (asprintf (&SesSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Subquery: get hidden sessions?
|
||||
|
@ -861,11 +862,11 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
{
|
||||
case Usr_ME: // A student watching her/his results
|
||||
if (asprintf (&HidSesSubQuery," AND exa_sessions.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default: // A teacher/admin watching the results of other users
|
||||
if (asprintf (&HidSesSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -873,7 +874,7 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
if (ExaCod > 0) // One unique exams
|
||||
{
|
||||
if (asprintf (&ExaSubQuery," AND exa_sessions.ExaCod=%ld",ExaCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else if (ExamsSelectedCommas)
|
||||
{
|
||||
|
@ -881,18 +882,18 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
{
|
||||
if (asprintf (&ExaSubQuery," AND exa_sessions.ExaCod IN (%s)",
|
||||
ExamsSelectedCommas) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&ExaSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
else // All exams
|
||||
{
|
||||
if (asprintf (&ExaSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Subquery: get hidden exams?
|
||||
|
@ -903,11 +904,11 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
{
|
||||
case Usr_ME: // A student watching her/his results
|
||||
if (asprintf (&HidExaSubQuery," AND exa_exams.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default: // A teacher/admin watching the results of other users
|
||||
if (asprintf (&HidExaSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -951,7 +952,7 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
{
|
||||
/* Get print code (row[0]) */
|
||||
if ((Print.PrnCod = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
|
||||
/* Get print data */
|
||||
ExaPrn_GetDataOfPrintByPrnCod (&Print);
|
||||
|
@ -975,7 +976,7 @@ static void ExaRes_ShowResults (struct Exa_Exams *Exams,
|
|||
{
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"exa_res_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"",
|
||||
Id,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime],
|
||||
|
@ -1457,9 +1458,9 @@ static void ExaRes_ShowExamResult (const struct Exa_Exam *Exam,
|
|||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
Lay_WrongUserExit ();
|
||||
Err_WrongUserExit ();
|
||||
if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWideMarginPadding (10);
|
||||
|
@ -1674,7 +1675,7 @@ static void ExaRes_ShowExamResultTime (struct ExaPrn_Print *Print)
|
|||
|
||||
/***** Time *****/
|
||||
if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Print->TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_exam_print.h"
|
||||
#include "swad_exam_result.h"
|
||||
|
@ -163,7 +164,7 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
|||
{
|
||||
case Rol_STD:
|
||||
if (asprintf (&HiddenSubQuery," AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
|
@ -172,10 +173,10 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
|||
case Rol_INS_ADM:
|
||||
case Rol_SYS_ADM:
|
||||
if (asprintf (&HiddenSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -193,11 +194,11 @@ void ExaSes_ListSessions (struct Exa_Exams *Exams,
|
|||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND exa_groups.GrpCod=grp_users.GrpCod))",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
if (asprintf (&GroupsSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get data of sessions from database *****/
|
||||
NumSessions = (unsigned)
|
||||
|
@ -402,7 +403,7 @@ static void ExaSes_ListOneOrMoreSessions (struct Exa_Exams *Exams,
|
|||
{
|
||||
/***** Build anchor string *****/
|
||||
if (asprintf (&Anchor,"evt_%ld_%ld",Exam->ExaCod,Session.SesCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Begin row for this exam session ****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -591,7 +592,7 @@ static void ExaSes_ListOneOrMoreSessionsTimes (const struct ExaSes_Session *Sess
|
|||
"DATE_RED");
|
||||
|
||||
if (asprintf (&Id,"exa_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
||||
Id,Color,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Session->TimeUTC[StartEndTime],
|
||||
|
@ -737,7 +738,7 @@ static void ExaSes_ListOneOrMoreSessionsResult (struct Exa_Exams *Exams,
|
|||
ExaSes_ListOneOrMoreSessionsResultTch (Exams,Session);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -821,7 +822,7 @@ void ExaSes_ToggleVisResultsSesUsr (void)
|
|||
|
||||
/***** Check if visibility of session results can be changed *****/
|
||||
if (!ExaSes_CheckIfVisibilityOfResultsCanBeChanged (&Session))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Toggle visibility of exam session results *****/
|
||||
Session.ShowUsrResults = !Session.ShowUsrResults;
|
||||
|
@ -870,11 +871,11 @@ static void ExaSes_GetSessionDataFromRow (MYSQL_RES *mysql_res,
|
|||
/***** Get session data *****/
|
||||
/* Code of the session (row[0]) */
|
||||
if ((Session->SesCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongExamSessionExit ();
|
||||
Err_WrongExamSessionExit ();
|
||||
|
||||
/* Code of the exam (row[1]) */
|
||||
if ((Session->ExaCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
|
||||
/* Get whether the session is hidden (row[2]) */
|
||||
Session->Hidden = (row[2][0] == 'Y');
|
||||
|
@ -956,7 +957,7 @@ void ExaSes_RemoveSession (void)
|
|||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove the exam session from all database tables *****/
|
||||
ExaSes_RemoveSessionFromAllTables (Session.SesCod);
|
||||
|
@ -1157,7 +1158,7 @@ void ExaSes_HideSession (void)
|
|||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Hide session *****/
|
||||
DB_QueryUPDATE ("can not hide exam sessions",
|
||||
|
@ -1197,7 +1198,7 @@ void ExaSes_UnhideSession (void)
|
|||
|
||||
/***** Check if I can remove this exam session *****/
|
||||
if (!ExaSes_CheckIfICanEditThisSession (&Session))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Unhide session *****/
|
||||
DB_QueryUPDATE ("can not unhide exam session",
|
||||
|
@ -1250,22 +1251,22 @@ void ExaSes_GetAndCheckParameters (struct Exa_Exams *Exams,
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (Exams);
|
||||
if (Exams->ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam->ExaCod = Exams->ExaCod;
|
||||
Grp_GetParamWhichGroups ();
|
||||
if ((Session->SesCod = ExaSes_GetParamSesCod ()) <= 0)
|
||||
Lay_WrongExamSessionExit ();
|
||||
Err_WrongExamSessionExit ();
|
||||
|
||||
/***** Get exam data from database *****/
|
||||
Exa_GetDataOfExamByCod (Exam);
|
||||
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams->ExaCod = Exam->ExaCod;
|
||||
|
||||
/***** Get set data from database *****/
|
||||
ExaSes_GetDataOfSessionByCod (Session);
|
||||
if (Session->ExaCod != Exam->ExaCod)
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
Exams->SesCod = Session->SesCod;
|
||||
}
|
||||
|
||||
|
@ -1445,7 +1446,7 @@ void ExaSes_RequestCreatOrEditSession (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
Grp_GetParamWhichGroups ();
|
||||
Session.SesCod = ExaSes_GetParamSesCod ();
|
||||
|
@ -1454,7 +1455,7 @@ void ExaSes_RequestCreatOrEditSession (void)
|
|||
/***** Get exam data from database *****/
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
if (Exam.CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.ExaCod = Exam.ExaCod;
|
||||
|
||||
/***** Get session data *****/
|
||||
|
@ -1466,7 +1467,7 @@ void ExaSes_RequestCreatOrEditSession (void)
|
|||
/* Get session data from database */
|
||||
ExaSes_GetDataOfSessionByCod (&Session);
|
||||
if (Exam.ExaCod != Session.ExaCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.SesCod = Session.SesCod;
|
||||
}
|
||||
|
||||
|
@ -1496,7 +1497,7 @@ void ExaSes_ReceiveFormSession (void)
|
|||
/***** Get main parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
Grp_GetParamWhichGroups ();
|
||||
Session.SesCod = ExaSes_GetParamSesCod ();
|
||||
|
@ -1505,7 +1506,7 @@ void ExaSes_ReceiveFormSession (void)
|
|||
/***** Get exam data from database *****/
|
||||
Exa_GetDataOfExamByCod (&Exam);
|
||||
if (Exam.CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.ExaCod = Exam.ExaCod;
|
||||
|
||||
/***** Get session data from database *****/
|
||||
|
@ -1520,7 +1521,7 @@ void ExaSes_ReceiveFormSession (void)
|
|||
/* Get session data from database */
|
||||
ExaSes_GetDataOfSessionByCod (&Session);
|
||||
if (Session.ExaCod != Exam.ExaCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams.SesCod = Session.SesCod;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_exam_result.h"
|
||||
#include "swad_exam_session.h"
|
||||
|
@ -367,7 +368,7 @@ void ExaSet_ReceiveFormSet (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Set.ExaCod = Exam.ExaCod = Exams.ExaCod;
|
||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
||||
ItsANewSet = (Set.SetCod <= 0);
|
||||
|
@ -378,7 +379,7 @@ void ExaSet_ReceiveFormSet (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** If I can edit exams ==> receive set from form *****/
|
||||
ExaSet_ReceiveSetFieldsFromForm (&Set);
|
||||
|
@ -454,7 +455,7 @@ void ExaSet_ChangeSetTitle (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -466,7 +467,7 @@ void ExaSet_ChangeSetTitle (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Receive new title from form *****/
|
||||
Par_GetParToText ("Title",NewTitle,ExaSet_MAX_BYTES_TITLE);
|
||||
|
@ -498,7 +499,7 @@ void ExaSet_ChangeNumQstsToExam (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -510,7 +511,7 @@ void ExaSet_ChangeNumQstsToExam (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get number of questions in set to appear in exam print *****/
|
||||
NumQstsToPrint = (unsigned) Par_GetParToUnsignedLong ("NumQstsToPrint",
|
||||
|
@ -667,7 +668,7 @@ void ExaSet_RequestCreatOrEditSet (void)
|
|||
|
||||
/***** Check if I can edit exams *****/
|
||||
if (!Exa_CheckIfICanEditExams ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Reset exams context *****/
|
||||
Exa_ResetExams (&Exams);
|
||||
|
@ -677,7 +678,7 @@ void ExaSet_RequestCreatOrEditSet (void)
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (&Exams);
|
||||
if (Exams.ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam.ExaCod = Exams.ExaCod;
|
||||
Exams.SetCod = Set.SetCod = ExaSet_GetParamSetCod ();
|
||||
ItsANewSet = (Set.SetCod <= 0);
|
||||
|
@ -785,7 +786,7 @@ static unsigned ExaSet_GetSetIndFromSetCod (long ExaCod,long SetCod)
|
|||
" WHERE SetCod=%u"
|
||||
" AND ExaCod=%ld", // Extra check
|
||||
SetCod,ExaCod))
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
|
||||
/***** Get set code (row[0]) *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -814,7 +815,7 @@ static long ExaSet_GetSetCodFromSetInd (long ExaCod,unsigned SetInd)
|
|||
ExaCod,
|
||||
SetInd);
|
||||
if (SetCod <= 0)
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
|
||||
return SetCod;
|
||||
}
|
||||
|
@ -1323,7 +1324,7 @@ Tst_AnswerType_t ExaSet_GetQstAnswerTypeFromDB (long QstCod)
|
|||
" FROM exa_set_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod))
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get type of answer */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1414,7 +1415,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
break;
|
||||
case Tst_ANS_FLOAT:
|
||||
if (Question->Answer.NumOptions != 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]);
|
||||
break;
|
||||
case Tst_ANS_TRUE_FALSE:
|
||||
|
@ -1426,7 +1427,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
case Tst_ANS_TEXT:
|
||||
/* Check number of options */
|
||||
if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/* Allocate space for text and feedback */
|
||||
if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt))
|
||||
|
@ -1464,7 +1465,7 @@ void ExaSet_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (!QuestionExists)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1596,7 +1597,7 @@ void ExaSet_AddQstsToSet (void)
|
|||
/* Get next code */
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
||||
if (sscanf (LongStr,"%ld",&QstCod) != 1)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
ExaSet_CopyQstFromBankToExamSet (&Set,QstCod);
|
||||
}
|
||||
|
@ -1621,7 +1622,7 @@ static void ExaSet_AllocateListSelectedQuestions (struct Exa_Exams *Exams)
|
|||
if (!Exams->ListQuestions)
|
||||
{
|
||||
if ((Exams->ListQuestions = malloc (ExaSet_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Exams->ListQuestions[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -1756,7 +1757,7 @@ void ExaSet_RequestRemoveSet (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show question and button to remove question *****/
|
||||
Ale_ShowAlertAndButton (ActRemExaSet,NULL,NULL,
|
||||
|
@ -1791,7 +1792,7 @@ void ExaSet_RemoveSet (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove the set from all the tables *****/
|
||||
/* Remove questions associated to set */
|
||||
|
@ -1813,7 +1814,7 @@ void ExaSet_RemoveSet (void)
|
|||
Set.SetCod,
|
||||
Set.ExaCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_ShowErrorAndExit ("The set to be removed does not exist.");
|
||||
Err_ShowErrorAndExit ("The set to be removed does not exist.");
|
||||
|
||||
/* Change index of sets greater than this */
|
||||
DB_QueryUPDATE ("can not update indexes of sets",
|
||||
|
@ -1855,7 +1856,7 @@ void ExaSet_MoveUpSet (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get set index *****/
|
||||
SetIndBottom = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
||||
|
@ -1866,7 +1867,7 @@ void ExaSet_MoveUpSet (void)
|
|||
/* Indexes of sets to be exchanged */
|
||||
SetIndTop = ExaSet_GetPrevSetIndexInExam (Exam.ExaCod,SetIndBottom);
|
||||
if (!SetIndTop)
|
||||
Lay_ShowErrorAndExit ("Wrong set index.");
|
||||
Err_ShowErrorAndExit ("Wrong set index.");
|
||||
|
||||
/* Exchange sets */
|
||||
ExaSet_ExchangeSets (Exam.ExaCod,SetIndTop,SetIndBottom);
|
||||
|
@ -1903,7 +1904,7 @@ void ExaSet_MoveDownSet (void)
|
|||
|
||||
/***** Check if exam is editable *****/
|
||||
if (!Exa_CheckIfEditable (&Exam))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get set index *****/
|
||||
SetIndTop = ExaSet_GetSetIndFromSetCod (Exam.ExaCod,Set.SetCod);
|
||||
|
@ -1917,7 +1918,7 @@ void ExaSet_MoveDownSet (void)
|
|||
/* Indexes of sets to be exchanged */
|
||||
SetIndBottom = ExaSet_GetNextSetIndexInExam (Exam.ExaCod,SetIndTop);
|
||||
if (!SetIndBottom)
|
||||
Lay_ShowErrorAndExit ("Wrong set index.");
|
||||
Err_ShowErrorAndExit ("Wrong set index.");
|
||||
|
||||
/* Exchange sets */
|
||||
ExaSet_ExchangeSets (Exam.ExaCod,SetIndTop,SetIndBottom);
|
||||
|
@ -2008,7 +2009,7 @@ void ExaSet_RemoveQstFromSet (void)
|
|||
QstCod,
|
||||
Set.SetCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/***** Write message *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_Question_removed);
|
||||
|
@ -2141,22 +2142,22 @@ static void ExaSet_GetAndCheckParameters (struct Exa_Exams *Exams,
|
|||
/***** Get parameters *****/
|
||||
Exa_GetParams (Exams);
|
||||
if (Exams->ExaCod <= 0)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exam->ExaCod = Exams->ExaCod;
|
||||
Grp_GetParamWhichGroups ();
|
||||
if ((Set->SetCod = ExaSet_GetParamSetCod ()) <= 0)
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
|
||||
/***** Get exam data from database *****/
|
||||
Exa_GetDataOfExamByCod (Exam);
|
||||
if (Exam->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
Exams->ExaCod = Exam->ExaCod;
|
||||
|
||||
/***** Get set data from database *****/
|
||||
ExaSet_GetDataOfSetByCod (Set);
|
||||
if (Set->ExaCod != Exam->ExaCod)
|
||||
Lay_WrongSetExit ();
|
||||
Err_WrongSetExit ();
|
||||
Exams->SetCod = Set->SetCod;
|
||||
}
|
||||
|
||||
|
|
107
swad_figure.c
107
swad_figure.c
|
@ -34,6 +34,7 @@
|
|||
#include "swad_agenda.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_file_browser.h"
|
||||
|
@ -674,7 +675,7 @@ static void Fig_GetAndShowHierarchyWithInss (void)
|
|||
case Hie_Lvl_CRS:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -717,7 +718,7 @@ static void Fig_GetAndShowHierarchyWithCtrs (void)
|
|||
case Hie_Lvl_CRS:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -766,7 +767,7 @@ static void Fig_GetAndShowHierarchyWithDegs (void)
|
|||
case Hie_Lvl_CRS:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -823,7 +824,7 @@ static void Fig_GetAndShowHierarchyWithCrss (void)
|
|||
case Hie_Lvl_CRS:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -904,7 +905,7 @@ static void Fig_GetAndShowHierarchyWithUsrs (Rol_Role_t Role)
|
|||
NumCrssWithUsrs = Crs_GetCachedNumCrssWithUsrs (Role,SubQuery,Hie_Lvl_CRS,Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -962,7 +963,7 @@ static void Fig_GetAndShowHierarchyTotal (void)
|
|||
case Hie_Lvl_CRS:
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1115,7 +1116,7 @@ static void Fig_GetAndShowInssOrderedByNumCtrs (void)
|
|||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1191,7 +1192,7 @@ static void Fig_GetAndShowInssOrderedByNumDegs (void)
|
|||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1273,7 +1274,7 @@ static void Fig_GetAndShowInssOrderedByNumCrss (void)
|
|||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1361,7 +1362,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void)
|
|||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1433,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void)
|
|||
Gbl.Hierarchy.Ins.InsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NumInss = 0; // Not reached. Initialized to avoid warning.
|
||||
break;
|
||||
}
|
||||
|
@ -1577,11 +1578,11 @@ static unsigned Fig_GetInsAndStat (struct Ins_Instit *Ins,MYSQL_RES *mysql_res)
|
|||
/***** Get data of this institution (row[0]) *****/
|
||||
Ins->InsCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
if (!Ins_GetDataOfInstitutionByCod (Ins))
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Get statistic (row[1]) *****/
|
||||
if (sscanf (row[1],"%u",&NumberThisRow) != 1)
|
||||
Lay_ShowErrorAndExit ("Error in statistic");
|
||||
Err_ShowErrorAndExit ("Error in statistic");
|
||||
|
||||
return NumberThisRow;
|
||||
}
|
||||
|
@ -1800,7 +1801,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -1978,7 +1979,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2144,7 +2145,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2298,7 +2299,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2440,7 +2441,7 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2570,12 +2571,12 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) FileBrowser);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2591,37 +2592,37 @@ static void Fig_GetSizeOfFileZoneFromDB (Hie_Lvl_Level_t Scope,
|
|||
/* Get number of courses (row[0]) */
|
||||
if (row[0])
|
||||
if (sscanf (row[0],"%d",&(SizeOfFileZones->NumCrss)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of courses.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of courses.");
|
||||
|
||||
/* Get number of groups (row[1]) */
|
||||
if (row[1])
|
||||
if (sscanf (row[1],"%d",&(SizeOfFileZones->NumGrps)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of groups.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of groups.");
|
||||
|
||||
/* Get number of users (row[2]) */
|
||||
if (row[2])
|
||||
if (sscanf (row[2],"%d",&(SizeOfFileZones->NumUsrs)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of users.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of users.");
|
||||
|
||||
/* Get maximum number of levels (row[3]) */
|
||||
if (row[3])
|
||||
if (sscanf (row[3],"%u",&(SizeOfFileZones->MaxLevels)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting maximum number of levels.");
|
||||
Err_ShowErrorAndExit ("Error when getting maximum number of levels.");
|
||||
|
||||
/* Get number of folders (row[4]) */
|
||||
if (row[4])
|
||||
if (sscanf (row[4],"%lu",&(SizeOfFileZones->NumFolders)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of folders.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of folders.");
|
||||
|
||||
/* Get number of files (row[5]) */
|
||||
if (row[5])
|
||||
if (sscanf (row[5],"%lu",&(SizeOfFileZones->NumFiles)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of files.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of files.");
|
||||
|
||||
/* Get total size (row[6]) */
|
||||
if (row[6])
|
||||
if (sscanf (row[6],"%llu",&(SizeOfFileZones->Size)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting toal size.");
|
||||
Err_ShowErrorAndExit ("Error when getting toal size.");
|
||||
|
||||
/* Free structure that stores the query result */
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -3079,7 +3080,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Lvl_Level_t Scope,
|
|||
(unsigned) License);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3099,7 +3100,7 @@ static void Fig_GetNumberOfOERsFromDB (Hie_Lvl_Level_t Scope,
|
|||
|
||||
/* Get number of files (row[1]) */
|
||||
if (sscanf (row[1],"%lu",&NumFiles[Public]) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of files.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of files.");
|
||||
}
|
||||
|
||||
/* Free structure that stores the query result */
|
||||
|
@ -3681,7 +3682,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
|||
(unsigned) NoteType);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NumRows = 0; // Initialized to avoid warning
|
||||
break;
|
||||
}
|
||||
|
@ -3822,7 +3823,7 @@ static void Fig_GetAndShowTimelineActivityStats (void)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NumRows = 0; // Initialized to avoid warning
|
||||
break;
|
||||
}
|
||||
|
@ -4016,7 +4017,7 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
FieldDB[Fol]);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NumUsrs = 0; // Not reached. Initialized to av oid warning
|
||||
break;
|
||||
}
|
||||
|
@ -4155,7 +4156,7 @@ static void Fig_GetAndShowFollowStats (void)
|
|||
FieldDB[1 - Fol]);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
Average = 0.0; // Not reached
|
||||
break;
|
||||
}
|
||||
|
@ -4283,7 +4284,7 @@ static void Fig_GetAndShowForumStats (void)
|
|||
Fig_ShowStatOfAForumType (For_FORUM_COURSE_TCHS,-1L,-1L,-1L,-1L,Gbl.Hierarchy.Crs.CrsCod,&FiguresForum);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4418,7 +4419,7 @@ static void Fig_WriteForumTitleAndStats (For_ForumType_t ForumType,
|
|||
HTM_TD_Begin ("class=\"BT\"");
|
||||
if (asprintf (&ForumName,"%s%s",
|
||||
ForumName1,ForumName2) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ico_PutIcon (Icon,ForumName,"ICO16x16");
|
||||
free (ForumName);
|
||||
HTM_TD_End ();
|
||||
|
@ -4581,7 +4582,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
/* Get the number of users who want to be notified by email on this event, from database */
|
||||
if (asprintf (&SubQuery,"((usr_data.EmailNtfEvents & %u)<>0)",
|
||||
(1 << NotifyEvent)) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[NotifyEvent] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -4665,7 +4666,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
(unsigned) NotifyEvent);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4675,7 +4676,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
if (row[0])
|
||||
{
|
||||
if (sscanf (row[0],"%u",&NumEvents[NotifyEvent]) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting the number of notifications by email.");
|
||||
Err_ShowErrorAndExit ("Error when getting the number of notifications by email.");
|
||||
}
|
||||
else
|
||||
NumEvents[NotifyEvent] = 0;
|
||||
|
@ -4684,7 +4685,7 @@ static void Fig_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",&NumMails[NotifyEvent]) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting the number of emails to notify events3.");
|
||||
Err_ShowErrorAndExit ("Error when getting the number of emails to notify events3.");
|
||||
}
|
||||
else
|
||||
NumMails[NotifyEvent] = 0;
|
||||
|
@ -5146,7 +5147,7 @@ static void Fig_GetAndShowNumUsrsPerPrivacyForAnObject (const char *TxtObject,
|
|||
/* Get the number of users who have chosen this privacy option from database */
|
||||
if (asprintf (&SubQuery,"usr_data.%s='%s'",
|
||||
FieldName,Pri_VisibilityDB[Visibility]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[Visibility] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5234,7 +5235,7 @@ static void Fig_GetAndShowNumUsrsPerCookies (void)
|
|||
/* Get number of users who have chosen this menu from database */
|
||||
if (asprintf (&SubQuery,"usr_data.ThirdPartyCookies='%c'",
|
||||
AcceptedInDB[i]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[i] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5310,7 +5311,7 @@ static void Fig_GetAndShowNumUsrsPerLanguage (void)
|
|||
/* Get the number of users who have chosen this language from database */
|
||||
if (asprintf (&SubQuery,"usr_data.Language='%s'",
|
||||
Lan_STR_LANG_ID[Lan]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[Lan] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5389,7 +5390,7 @@ static void Fig_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
/* Get number of users who have chosen this first day of week from database */
|
||||
if (asprintf (&SubQuery,"usr_data.FirstDayOfWeek=%u",
|
||||
(unsigned) FirstDayOfWeek) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[FirstDayOfWeek] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5408,7 +5409,7 @@ static void Fig_GetAndShowNumUsrsPerFirstDayOfWeek (void)
|
|||
HTM_TD_Begin ("class=\"CM\"");
|
||||
if (asprintf (&Icon,"first-day-of-week-%u.png",
|
||||
FirstDayOfWeek) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ico_PutIcon (Icon,
|
||||
Str_BuildStringStr (Txt_First_day_of_the_week_X,
|
||||
Txt_DAYS_SMALL[FirstDayOfWeek]),
|
||||
|
@ -5472,7 +5473,7 @@ static void Fig_GetAndShowNumUsrsPerDateFormat (void)
|
|||
/* Get number of users who have chosen this date format from database */
|
||||
if (asprintf (&SubQuery,"usr_data.DateFormat=%u",
|
||||
(unsigned) Format) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[Format] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5550,7 +5551,7 @@ static void Fig_GetAndShowNumUsrsPerIconSet (void)
|
|||
/* Get the number of users who have chosen this icon set from database */
|
||||
if (asprintf (&SubQuery,"usr_data.IconSet='%s'",
|
||||
Ico_IconSetId[IconSet]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[IconSet] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5568,7 +5569,7 @@ static void Fig_GetAndShowNumUsrsPerIconSet (void)
|
|||
HTM_TD_Begin ("class=\"LM\"");
|
||||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_ICON_SETS_PUBLIC,Ico_IconSetId[IconSet]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,"cog.svg",Ico_IconSetNames[IconSet],
|
||||
"class=\"ICO40x40\"");
|
||||
free (URL);
|
||||
|
@ -5631,7 +5632,7 @@ static void Fig_GetAndShowNumUsrsPerMenu (void)
|
|||
/* Get number of users who have chosen this menu from database */
|
||||
if (asprintf (&SubQuery,"usr_data.Menu=%u",
|
||||
(unsigned) Menu) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[Menu] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5708,7 +5709,7 @@ static void Fig_GetAndShowNumUsrsPerTheme (void)
|
|||
/* Get number of users who have chosen this theme from database */
|
||||
if (asprintf (&SubQuery,"usr_data.Theme='%s'",
|
||||
The_ThemeId[Theme]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[Theme] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5726,7 +5727,7 @@ static void Fig_GetAndShowNumUsrsPerTheme (void)
|
|||
HTM_TD_Begin ("class=\"CM\"");
|
||||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_ICON_THEMES_PUBLIC,The_ThemeId[Theme]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,"theme_32x20.gif",The_ThemeNames[Theme],
|
||||
"style=\"width:40px;height:25px;\"");
|
||||
free (URL);
|
||||
|
@ -5789,7 +5790,7 @@ static void Fig_GetAndShowNumUsrsPerSideColumns (void)
|
|||
/* Get the number of users who have chosen this layout of columns from database */
|
||||
if (asprintf (&SubQuery,"usr_data.SideCols=%u",
|
||||
SideCols) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NumUsrs[SideCols] = Fig_GetNumUsrsWhoChoseAnOption (SubQuery);
|
||||
free (SubQuery);
|
||||
|
||||
|
@ -5807,7 +5808,7 @@ static void Fig_GetAndShowNumUsrsPerSideColumns (void)
|
|||
HTM_TD_Begin ("class=\"CM\"");
|
||||
if (asprintf (&Icon,"layout%u%u_32x20.gif",
|
||||
SideCols >> 1,SideCols & 1) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,Txt_LAYOUT_SIDE_COLUMNS[SideCols],
|
||||
"style=\"width:40px;height:25px;\"");
|
||||
free (Icon);
|
||||
|
@ -5925,7 +5926,7 @@ unsigned Fig_GetNumUsrsWhoChoseAnOption (const char *SubQuery)
|
|||
Gbl.Hierarchy.Crs.CrsCod,SubQuery);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NumUsrs = 0; // Not reached. Initialized to avoid warning.
|
||||
break;
|
||||
}
|
||||
|
|
39
swad_file.c
39
swad_file.c
|
@ -39,6 +39,7 @@
|
|||
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_file.h"
|
||||
#include "swad_string.h"
|
||||
|
@ -84,7 +85,7 @@ void Fil_CreateFileForHTMLOutput (void)
|
|||
if ((Gbl.F.Out = fopen (Gbl.HTMLOutput.FileName,"w+t")) == NULL)
|
||||
{
|
||||
Gbl.F.Out = stdout;
|
||||
Lay_ShowErrorAndExit ("Can not create output file.");
|
||||
Err_ShowErrorAndExit ("Can not create output file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +119,7 @@ bool Fil_ReadStdinIntoTmpFile (void)
|
|||
if ((Gbl.F.Tmp = tmpfile ()) == NULL)
|
||||
{
|
||||
Fil_EndOfReadingStdin ();
|
||||
Lay_ShowErrorAndExit ("Can not create temporary file.");
|
||||
Err_ShowErrorAndExit ("Can not create temporary file.");
|
||||
}
|
||||
for (TmpFileSize = 0;
|
||||
!feof (stdin) && !FileIsTooBig && !TimeExceeded;
|
||||
|
@ -233,13 +234,13 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile,
|
|||
return Param;
|
||||
}
|
||||
if (Param->FileName.Length > PATH_MAX)
|
||||
Lay_ShowErrorAndExit ("Error while getting filename.");
|
||||
Err_ShowErrorAndExit ("Error while getting filename.");
|
||||
|
||||
/* Copy filename */
|
||||
fseek (Gbl.F.Tmp,Param->FileName.Start,SEEK_SET);
|
||||
if (fread (FileName,sizeof (char),Param->FileName.Length,Gbl.F.Tmp) !=
|
||||
Param->FileName.Length)
|
||||
Lay_ShowErrorAndExit ("Error while getting filename.");
|
||||
Err_ShowErrorAndExit ("Error while getting filename.");
|
||||
FileName[Param->FileName.Length] = '\0';
|
||||
|
||||
/***** Get MIME type *****/
|
||||
|
@ -247,13 +248,13 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile,
|
|||
if (Param->ContentType.Start == 0 ||
|
||||
Param->ContentType.Length == 0 ||
|
||||
Param->ContentType.Length > Brw_MAX_BYTES_MIME_TYPE)
|
||||
Lay_ShowErrorAndExit ("Error while getting content type.");
|
||||
Err_ShowErrorAndExit ("Error while getting content type.");
|
||||
|
||||
/* Copy MIME type */
|
||||
fseek (Gbl.F.Tmp,Param->ContentType.Start,SEEK_SET);
|
||||
if (fread (MIMEType,sizeof (char),Param->ContentType.Length,Gbl.F.Tmp) !=
|
||||
Param->ContentType.Length)
|
||||
Lay_ShowErrorAndExit ("Error while getting content type.");
|
||||
Err_ShowErrorAndExit ("Error while getting content type.");
|
||||
MIMEType[Param->ContentType.Length] = '\0';
|
||||
|
||||
return Param;
|
||||
|
@ -272,12 +273,12 @@ bool Fil_EndReceptionOfFile (char *FileNameDataTmp,struct Param *Param)
|
|||
|
||||
/***** Open destination file *****/
|
||||
if ((FileDataTmp = fopen (FileNameDataTmp,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open temporary file.");
|
||||
Err_ShowErrorAndExit ("Can not open temporary file.");
|
||||
|
||||
/***** Copy file *****/
|
||||
/* Go to start of source */
|
||||
if (Param->Value.Start == 0)
|
||||
Lay_ShowErrorAndExit ("Error while copying file.");
|
||||
Err_ShowErrorAndExit ("Error while copying file.");
|
||||
fseek (Gbl.F.Tmp,Param->Value.Start,SEEK_SET);
|
||||
|
||||
/* Copy part of Gbl.F.Tmp to FileDataTmp */
|
||||
|
@ -336,7 +337,7 @@ void Fil_CreateUpdateFile (const char CurrentName[PATH_MAX + 1],
|
|||
{
|
||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||
"Can not create file <strong>%s</strong>.",NewName);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,14 +361,14 @@ void Fil_CloseUpdateFile (const char CurrentName[PATH_MAX + 1],
|
|||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||
"Can not rename the file <strong>%s</strong> as <strong>%s</strong>.",
|
||||
CurrentName,OldName);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
if (rename (NewName,CurrentName)) // mv NewName CurrentName Ej: mv file.new file.html
|
||||
{
|
||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||
"Can not rename the file <strong>%s</strong> as <strong>%s</strong>.",
|
||||
NewName,CurrentName);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -397,7 +398,7 @@ void Fil_CreateDirIfNotExists (const char Path[PATH_MAX + 1])
|
|||
{
|
||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||
"Can not create folder <strong>%s</strong>.",Path);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +419,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
|||
if (Fil_CheckIfPathExists (Path))
|
||||
{
|
||||
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
{
|
||||
if (rmdir (Path))
|
||||
|
@ -447,7 +448,7 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
|||
free (FileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
|
||||
/***** Remove of new the directory, now empty *****/
|
||||
if (rmdir (Path))
|
||||
|
@ -459,13 +460,13 @@ void Fil_RemoveTree (const char Path[PATH_MAX + 1])
|
|||
{
|
||||
snprintf (ErrorMsg,sizeof (ErrorMsg),
|
||||
"Can not remove folder %s.",Path);
|
||||
Lay_ShowErrorAndExit (ErrorMsg);
|
||||
Err_ShowErrorAndExit (ErrorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // It's a file
|
||||
if (unlink (Path))
|
||||
Lay_ShowErrorAndExit ("Can not remove file.");
|
||||
Err_ShowErrorAndExit ("Can not remove file.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -516,7 +517,7 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,
|
|||
rmdir (Path);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
else // Not a directory
|
||||
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||
|
@ -535,11 +536,11 @@ void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt)
|
|||
|
||||
/***** Open source file *****/
|
||||
if ((FileSrc = fopen (PathSrc,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open source file.");
|
||||
Err_ShowErrorAndExit ("Can not open source file.");
|
||||
|
||||
/***** Open destination file *****/
|
||||
if ((FileTgt = fopen (PathTgt,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open target file.");
|
||||
Err_ShowErrorAndExit ("Can not open target file.");
|
||||
|
||||
/***** Copy source file into destination file *****/
|
||||
Fil_FastCopyOfOpenFiles (FileSrc,FileTgt);
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_file_browser.h"
|
||||
#include "swad_file_extension.h"
|
||||
|
@ -1977,7 +1978,7 @@ void Brw_GetParAndInitFileBrowser (void)
|
|||
Brw_ADMI_MRK_CRS;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -2079,7 +2080,7 @@ void Brw_GetParAndInitFileBrowser (void)
|
|||
Gbl.FileBrowser.Type = Brw_ADMI_BRF_USR;
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("The type of file browser can not be determined.");
|
||||
Err_ShowErrorAndExit ("The type of file browser can not be determined.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2278,9 +2279,9 @@ static void Brw_GetDataCurrentGrp (void)
|
|||
/***** For security, check if group file zones are enabled,
|
||||
and check if I belongs to the selected group *****/
|
||||
if (!GrpDat.FileZones)
|
||||
Lay_ShowErrorAndExit ("The group has no file zones.");
|
||||
Err_ShowErrorAndExit ("The group has no file zones.");
|
||||
else if (!Grp_GetIfIBelongToGrp (Gbl.Crs.Grps.GrpCod))
|
||||
Lay_ShowErrorAndExit ("You don't have access to the group.");
|
||||
Err_ShowErrorAndExit ("You don't have access to the group.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2378,7 +2379,7 @@ static void Brw_GetParamsPathInTreeAndFileName (void)
|
|||
|
||||
/* Check if path contains ".." */
|
||||
if (strstr (Gbl.FileBrowser.FilFolLnk.Path,"..")) // ".." is not allowed in path
|
||||
Lay_ShowErrorAndExit ("Wrong path.");
|
||||
Err_ShowErrorAndExit ("Wrong path.");
|
||||
|
||||
/***** Get the name of the file, folder or link *****/
|
||||
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_UNKNOWN;
|
||||
|
@ -2397,7 +2398,7 @@ static void Brw_GetParamsPathInTreeAndFileName (void)
|
|||
Gbl.FileBrowser.FilFolLnk.Name,
|
||||
FileNameToShow);
|
||||
if (strstr (FileNameToShow,"..")) // ".." is not allowed in filename
|
||||
Lay_ShowErrorAndExit ("Wrong file name.");
|
||||
Err_ShowErrorAndExit ("Wrong file name.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3361,13 +3362,13 @@ static void Brw_GetSelectedGroupData (struct GroupData *GrpDat,bool AbortOnError
|
|||
if (!GrpDat->FileZones)
|
||||
{
|
||||
if (AbortOnError)
|
||||
Lay_ShowErrorAndExit ("The file browser is disabled.");
|
||||
Err_ShowErrorAndExit ("The file browser is disabled.");
|
||||
GrpDat->GrpCod = -1L;
|
||||
}
|
||||
else if (!Grp_GetIfIBelongToGrp (GrpDat->GrpCod))
|
||||
{
|
||||
if (AbortOnError)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
GrpDat->GrpCod = -1L;
|
||||
}
|
||||
}
|
||||
|
@ -3403,7 +3404,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
|
|||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
Frm_BeginForm (NextAction);
|
||||
|
@ -4035,7 +4036,7 @@ static void Brw_WriteSubtitleOfFileBrowser (void)
|
|||
break;
|
||||
default:
|
||||
Subtitle[0] = '\0';
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -5148,7 +5149,7 @@ void Brw_CreateDirDownloadTmp (void)
|
|||
snprintf (PathUniqueDirR,sizeof (PathUniqueDirR),"%s/%s",
|
||||
PathUniqueDirL,Gbl.FileBrowser.TmpPubDir.R);
|
||||
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
|
||||
Lay_ShowErrorAndExit ("Can not create a temporary folder for download.");
|
||||
Err_ShowErrorAndExit ("Can not create a temporary folder for download.");
|
||||
|
||||
/* 4. Increase number of directory for next call */
|
||||
NumDir++;
|
||||
|
@ -5234,10 +5235,10 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void)
|
|||
if (row[0] == NULL)
|
||||
Gbl.Usrs.Me.TimeLastAccToThisFileBrowser = 0;
|
||||
else if (sscanf (row[0],"%ld",&Gbl.Usrs.Me.TimeLastAccToThisFileBrowser) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when reading date-time of last access to a file browser.");
|
||||
Err_ShowErrorAndExit ("Error when reading date-time of last access to a file browser.");
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error when getting date-time of last access to a file browser.");
|
||||
Err_ShowErrorAndExit ("Error when getting date-time of last access to a file browser.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -5285,13 +5286,13 @@ static long Brw_GetGrpLastAccZone (const char *FieldNameDB)
|
|||
if (row[0])
|
||||
{
|
||||
if (sscanf (row[0],"%ld",&GrpCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when reading the group of your last access to a file browser.");
|
||||
Err_ShowErrorAndExit ("Error when reading the group of your last access to a file browser.");
|
||||
}
|
||||
else
|
||||
GrpCod = -1L;
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error when getting the group of your last access to a file browser.");
|
||||
Err_ShowErrorAndExit ("Error when getting the group of your last access to a file browser.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -5359,7 +5360,7 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
|||
snprintf (PathFileRel,sizeof (PathFileRel),"%s/%s",
|
||||
Path,FileList[NumFile]->d_name);
|
||||
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
{
|
||||
Gbl.FileBrowser.Size.NumFolds++;
|
||||
|
@ -5377,7 +5378,7 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
|||
free (FileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -5431,7 +5432,7 @@ static void Brw_ListDir (unsigned Level,const char *ParentRowId,
|
|||
|
||||
/***** Get file or folder status *****/
|
||||
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
{
|
||||
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
|
||||
|
@ -5456,7 +5457,7 @@ static void Brw_ListDir (unsigned Level,const char *ParentRowId,
|
|||
free (SubdirFileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
|
||||
/***** Write a row for the subdirectory *****/
|
||||
|
@ -5483,7 +5484,7 @@ static void Brw_ListDir (unsigned Level,const char *ParentRowId,
|
|||
free (FileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -5601,7 +5602,7 @@ static bool Brw_WriteRowFileBrowser (unsigned Level,const char *RowId,
|
|||
/***** Start this row *****/
|
||||
if (asprintf (&Anchor,"fil_brw_%u_%s",
|
||||
Gbl.FileBrowser.Id,RowId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
switch (IconThisRow)
|
||||
{
|
||||
case Brw_ICON_TREE_NOTHING:
|
||||
|
@ -6236,7 +6237,7 @@ static void Brw_PutIconFile (Brw_FileType_t FileType,const char *FileName,
|
|||
{
|
||||
if (asprintf (&URL,"%s32x32",
|
||||
CfG_URL_ICON_FILEXT_PUBLIC) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
for (DocType = 0, NotFound = true;
|
||||
DocType < Ext_NUM_FILE_EXT_ALLOWED && NotFound;
|
||||
DocType++)
|
||||
|
@ -6244,18 +6245,18 @@ static void Brw_PutIconFile (Brw_FileType_t FileType,const char *FileName,
|
|||
{
|
||||
if (asprintf (&Icon,"%s32x32.gif",
|
||||
Ext_FileExtensionsAllowed[DocType]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Title,Txt_X_file,
|
||||
Ext_FileExtensionsAllowed[DocType]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
NotFound = false;
|
||||
}
|
||||
if (NotFound)
|
||||
{
|
||||
if (asprintf (&Icon,"xxx32x32.gif") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Title,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
if (Input)
|
||||
|
@ -6371,7 +6372,7 @@ static void Brw_WriteFileName (unsigned Level,bool IsPublic)
|
|||
|
||||
/* Link to the form and to the file */
|
||||
if (asprintf (&Class,"BT_LINK FILENAME %s",Gbl.FileBrowser.TxtStyle) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin ((Gbl.FileBrowser.Type == Brw_SHOW_MRK_CRS ||
|
||||
Gbl.FileBrowser.Type == Brw_SHOW_MRK_GRP) ? Txt_Check_marks_in_the_file :
|
||||
Txt_Download,
|
||||
|
@ -6436,7 +6437,7 @@ void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile,
|
|||
Gbl.FileBrowser.TmpPubDir.R,
|
||||
FileName);
|
||||
if (symlink (FullPathIncludingFile,Link) != 0)
|
||||
Lay_ShowErrorAndExit ("Can not create temporary link.");
|
||||
Err_ShowErrorAndExit ("Can not create temporary link.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -6461,7 +6462,7 @@ static void Brw_WriteDatesAssignment (void)
|
|||
|
||||
/***** Write start date *****/
|
||||
if (asprintf (&Id,"asg_start_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
@ -6474,7 +6475,7 @@ static void Brw_WriteDatesAssignment (void)
|
|||
|
||||
/***** Write end date *****/
|
||||
if (asprintf (&Id,"asg_end_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
@ -6518,7 +6519,7 @@ static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata)
|
|||
{
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"filedate%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
HTM_SPAN_End ();
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,FileMetadata->Time,
|
||||
|
@ -6598,7 +6599,7 @@ void Brw_AskRemFileFromTree (void)
|
|||
FileNameToShow);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
|
||||
|
||||
/***** Show again file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -6627,7 +6628,7 @@ void Brw_RemFileFromTree (void)
|
|||
|
||||
/***** Check if is a file/link or a folder *****/
|
||||
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISREG (FileStatus.st_mode)) // It's a file or a link
|
||||
{
|
||||
/* Name of the file/link to be shown */
|
||||
|
@ -6649,10 +6650,10 @@ void Brw_RemFileFromTree (void)
|
|||
FileNameToShow);
|
||||
}
|
||||
else // File / link not found
|
||||
Lay_ShowErrorAndExit ("File / link not found.");
|
||||
Err_ShowErrorAndExit ("File / link not found.");
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_remove_this_file_or_link);
|
||||
|
||||
/***** Show again file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -6680,7 +6681,7 @@ void Brw_RemFolderFromTree (void)
|
|||
|
||||
/***** Check if it's a file or a folder *****/
|
||||
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
if (Brw_RemoveFolderFromDiskAndDB (Path,
|
||||
Gbl.FileBrowser.FilFolLnk.Full))
|
||||
|
@ -6688,7 +6689,7 @@ void Brw_RemFolderFromTree (void)
|
|||
if (errno == ENOTEMPTY) // The directory is not empty
|
||||
Brw_AskConfirmRemoveFolderNotEmpty ();
|
||||
else // The directory is empty
|
||||
Lay_ShowErrorAndExit ("Can not remove folder.");
|
||||
Err_ShowErrorAndExit ("Can not remove folder.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6702,10 +6703,10 @@ void Brw_RemFolderFromTree (void)
|
|||
Gbl.FileBrowser.FilFolLnk.Name);
|
||||
}
|
||||
else // Folder not found
|
||||
Lay_ShowErrorAndExit ("Folder not found.");
|
||||
Err_ShowErrorAndExit ("Folder not found.");
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_remove_this_folder);
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_remove_this_folder);
|
||||
|
||||
/***** Show again file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -7160,7 +7161,7 @@ static bool Brw_GetMyClipboard (void)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (NumRows > 1)
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
|
||||
return (bool) (NumRows == 1);
|
||||
}
|
||||
|
@ -7953,7 +7954,7 @@ static void Brw_PasteClipboard (void)
|
|||
(unsigned) Hie.Ins.InsCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_DOC_CTR:
|
||||
case Brw_ADMI_SHR_CTR:
|
||||
|
@ -7965,7 +7966,7 @@ static void Brw_PasteClipboard (void)
|
|||
(unsigned) Hie.Ctr.CtrCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_DOC_DEG:
|
||||
case Brw_ADMI_SHR_DEG:
|
||||
|
@ -7977,7 +7978,7 @@ static void Brw_PasteClipboard (void)
|
|||
(unsigned) Hie.Deg.DegCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_DOC_CRS:
|
||||
case Brw_ADMI_TCH_CRS:
|
||||
|
@ -7989,7 +7990,7 @@ static void Brw_PasteClipboard (void)
|
|||
Cfg_PATH_CRS_PRIVATE,Hie.Crs.CrsCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_DOC_GRP:
|
||||
case Brw_ADMI_TCH_GRP:
|
||||
|
@ -8004,7 +8005,7 @@ static void Brw_PasteClipboard (void)
|
|||
GrpDat.GrpCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_ASG_CRS:
|
||||
case Brw_ADMI_WRK_CRS:
|
||||
|
@ -8026,7 +8027,7 @@ static void Brw_PasteClipboard (void)
|
|||
Usr_UsrDataDestructor (&UsrDat);
|
||||
}
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_ASG_USR:
|
||||
case Brw_ADMI_WRK_USR:
|
||||
|
@ -8038,7 +8039,7 @@ static void Brw_PasteClipboard (void)
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_DOC_PRJ:
|
||||
case Brw_ADMI_ASS_PRJ:
|
||||
|
@ -8051,7 +8052,7 @@ static void Brw_PasteClipboard (void)
|
|||
PrjCod,
|
||||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
else
|
||||
Lay_WrongCopySrcExit ();
|
||||
Err_WrongCopySrcExit ();
|
||||
break;
|
||||
case Brw_ADMI_BRF_USR:
|
||||
snprintf (PathOrg,sizeof (PathOrg),"%s/%s",
|
||||
|
@ -8059,7 +8060,7 @@ static void Brw_PasteClipboard (void)
|
|||
Gbl.FileBrowser.Clipboard.FilFolLnk.Full);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongFileBrowserExit ();
|
||||
Err_WrongFileBrowserExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -8119,7 +8120,7 @@ static void Brw_PasteClipboard (void)
|
|||
Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (Gbl.FileBrowser.FilFolLnk.Full);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_paste_file_or_folder_here); // It's difficult, but not impossible that a user sees this message
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_paste_file_or_folder_here); // It's difficult, but not impossible that a user sees this message
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -8185,7 +8186,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
|
|||
/***** Is it a file or a folder? *****/
|
||||
FileType = Brw_IS_UNKNOWN;
|
||||
if (lstat (PathOrg,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
FileType = Brw_IS_FOLDER;
|
||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||
|
@ -8233,7 +8234,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
|
|||
FileNameToShow);
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Can not paste unknown file type.");
|
||||
Err_ShowErrorAndExit ("Can not paste unknown file type.");
|
||||
}
|
||||
CopyIsGoingSuccessful = false;
|
||||
}
|
||||
|
@ -8326,7 +8327,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
|
|||
{
|
||||
/* Create directory */
|
||||
if (mkdir (PathDstWithFile,(mode_t) 0xFFF) != 0)
|
||||
Lay_ShowErrorAndExit ("Can not create folder.");
|
||||
Err_ShowErrorAndExit ("Can not create folder.");
|
||||
|
||||
/* Add entry to the table of files/folders */
|
||||
Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,FileType,
|
||||
|
@ -8358,7 +8359,7 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
|
|||
free (FileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
|
||||
if (CopyIsGoingSuccessful &&
|
||||
LevelOrg != 0) // When copying all files inside root folder,
|
||||
|
@ -8417,7 +8418,7 @@ void Brw_ShowFormFileBrowser (void)
|
|||
}
|
||||
else
|
||||
{
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_create_folders_files_or_links_here); // It's difficult, but not impossible that a user sees this message
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_create_folders_files_or_links_here); // It's difficult, but not impossible that a user sees this message
|
||||
|
||||
/***** Show again file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -8636,7 +8637,7 @@ static void Brw_PutFormToCreateALink (const char *FileNameToShow)
|
|||
|
||||
/* Label */
|
||||
if (asprintf (&Label,"%s (%s): ",Txt_Save_as,Txt_optional) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Frm_LabelColumn ("RT","NewLinkName",Label);
|
||||
free (Label);
|
||||
|
||||
|
@ -8685,7 +8686,7 @@ void Brw_RecFolderFileBrowser (void)
|
|||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
|
||||
if (strlen (Path) + 1 + strlen (Gbl.FileBrowser.NewFilFolLnkName) > PATH_MAX)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
Err_ShowErrorAndExit ("Path is too long.");
|
||||
Str_Concat (Path,"/",sizeof (Path) - 1);
|
||||
Str_Concat (Path,Gbl.FileBrowser.NewFilFolLnkName,sizeof (Path) - 1);
|
||||
|
||||
|
@ -8739,10 +8740,10 @@ void Brw_RecFolderFileBrowser (void)
|
|||
Gbl.FileBrowser.NewFilFolLnkName);
|
||||
break;
|
||||
case EACCES:
|
||||
Lay_ShowErrorAndExit ("Write forbidden.");
|
||||
Err_ShowErrorAndExit ("Write forbidden.");
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Can not create folder.");
|
||||
Err_ShowErrorAndExit ("Can not create folder.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8751,7 +8752,7 @@ void Brw_RecFolderFileBrowser (void)
|
|||
Ale_ShowAlerts (NULL);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_create_folders_here); // It's difficult, but not impossible that a user sees this message
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_create_folders_here); // It's difficult, but not impossible that a user sees this message
|
||||
|
||||
/***** Show again the file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -8792,7 +8793,7 @@ void Brw_RenFolderFileBrowser (void)
|
|||
if (strlen (Gbl.FileBrowser.Priv.PathAboveRootFolder) + 1 +
|
||||
strlen (Gbl.FileBrowser.FilFolLnk.Path) + 1 +
|
||||
strlen (Gbl.FileBrowser.NewFilFolLnkName) > PATH_MAX)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
Err_ShowErrorAndExit ("Path is too long.");
|
||||
snprintf (NewPathInTree,sizeof (NewPathInTree),"%s/%s",
|
||||
Gbl.FileBrowser.FilFolLnk.Path,
|
||||
Gbl.FileBrowser.NewFilFolLnkName);
|
||||
|
@ -8814,10 +8815,10 @@ void Brw_RenFolderFileBrowser (void)
|
|||
Gbl.FileBrowser.FilFolLnk.Name,Gbl.FileBrowser.NewFilFolLnkName);
|
||||
break;
|
||||
case EACCES:
|
||||
Lay_ShowErrorAndExit ("Write forbidden.");
|
||||
Err_ShowErrorAndExit ("Write forbidden.");
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Can not rename folder.");
|
||||
Err_ShowErrorAndExit ("Can not rename folder.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8858,7 +8859,7 @@ void Brw_RenFolderFileBrowser (void)
|
|||
Ale_ShowAlerts (NULL);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_rename_this_folder);
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_rename_this_folder);
|
||||
|
||||
/***** Show again file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -8968,7 +8969,7 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
|
|||
if (strlen (Path) + 1 +
|
||||
strlen (Gbl.FileBrowser.NewFilFolLnkName) +
|
||||
strlen (".tmp") > PATH_MAX)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
Err_ShowErrorAndExit ("Path is too long.");
|
||||
Str_Concat (Path,"/",sizeof (Path) - 1);
|
||||
Str_Concat (Path,Gbl.FileBrowser.NewFilFolLnkName,sizeof (Path) - 1);
|
||||
|
||||
|
@ -9165,7 +9166,7 @@ void Brw_RecLinkFileBrowser (void)
|
|||
Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
||||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
if (strlen (Path) + 1 + strlen (FileName) + strlen (".url") > PATH_MAX)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
Err_ShowErrorAndExit ("Path is too long.");
|
||||
Str_Concat (Path,"/",sizeof (Path) - 1);
|
||||
Str_Concat (Path,FileName,sizeof (Path) - 1);
|
||||
Str_Concat (Path,".url",sizeof (Path) - 1);
|
||||
|
@ -9258,7 +9259,7 @@ void Brw_RecLinkFileBrowser (void)
|
|||
Ale_ShowAlert (Ale_WARNING,Txt_UPLOAD_FILE_Invalid_link);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit (Txt_You_can_not_create_links_here); // It's difficult, but not impossible that a user sees this message
|
||||
Err_ShowErrorAndExit (Txt_You_can_not_create_links_here); // It's difficult, but not impossible that a user sees this message
|
||||
|
||||
/***** Show again the file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -10345,7 +10346,7 @@ void Brw_ChgFileMetadata (void)
|
|||
}
|
||||
else
|
||||
/***** Write error message and exit *****/
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/***** Show again the file browser *****/
|
||||
|
@ -11876,7 +11877,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
Txt_Uploaded_by,
|
||||
FileHasPublisher ? PublisherUsrDat.FullName :
|
||||
Txt_ROLES_SINGUL_Abc[Rol_UNK][Usr_SEX_UNKNOWN]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Free memory used for publisher's data */
|
||||
if (FileMetadata.PublisherUsrCod > 0)
|
||||
|
@ -12380,7 +12381,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
|
|||
// Folder st_mtime must be saved before remove files inside it
|
||||
// because st_mtime is updated by the deletion
|
||||
if (lstat (Path,&FolderStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
/***** Scan directory *****/
|
||||
else if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
||||
{
|
||||
|
@ -12400,7 +12401,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
|
|||
|
||||
/***** Get file or folder status *****/
|
||||
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
Err_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||
else if (S_ISDIR (FileStatus.st_mode)) // It's a folder
|
||||
/* Scan subtree starting at this this directory recursively */
|
||||
Brw_ScanDirRemovingOldFiles (Level + 1,PathFileRel,
|
||||
|
@ -12440,7 +12441,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
|
|||
free (FileList);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
|
||||
if (NumFiles <= 2 && // It's an empty folder
|
||||
|
@ -12448,7 +12449,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
|
|||
{
|
||||
/* Remove folder from disk and database */
|
||||
if (Brw_RemoveFolderFromDiskAndDB (Path,PathInTree))
|
||||
Lay_ShowErrorAndExit ("Can not remove folder.");
|
||||
Err_ShowErrorAndExit ("Can not remove folder.");
|
||||
|
||||
/* Update number of files/links removed */
|
||||
(Removed->NumFolds)++;
|
||||
|
@ -12456,7 +12457,7 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,
|
|||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||
Err_ShowErrorAndExit ("Error while scanning directory.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -12468,7 +12469,7 @@ static void Brw_RemoveFileFromDiskAndDB (const char Path[PATH_MAX + 1],
|
|||
{
|
||||
/***** Remove file from disk *****/
|
||||
if (unlink (Path))
|
||||
Lay_ShowErrorAndExit ("Can not remove file / link.");
|
||||
Err_ShowErrorAndExit ("Can not remove file / link.");
|
||||
|
||||
/***** If a file is removed,
|
||||
it is necessary to remove it from the database *****/
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -1496,7 +1497,7 @@ void Fol_GetAndShowRankingFollowers (void)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For free
|
||||
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -271,7 +272,7 @@ void Frm_SetAnchorStr (long Cod,char **Anchor)
|
|||
{
|
||||
if (asprintf (Anchor,"cod_%ld",
|
||||
Cod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
*Anchor = NULL;
|
||||
|
|
57
swad_forum.c
57
swad_forum.c
|
@ -37,6 +37,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_forum.h"
|
||||
|
@ -490,7 +491,7 @@ void For_DisablePost (void)
|
|||
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_banned);
|
||||
}
|
||||
else
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -651,9 +652,9 @@ static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod)
|
|||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumPsts) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
||||
if (sscanf (row[1],"%ld",ThrCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
||||
}
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
|
@ -842,7 +843,7 @@ static long For_GetLastPstCod (long ThrCod)
|
|||
" LIMIT 1",
|
||||
ThrCod);
|
||||
if (LastPstCod <= 0)
|
||||
Lay_ShowErrorAndExit ("Error when getting the most recent post of a thread of a forum.");
|
||||
Err_ShowErrorAndExit ("Error when getting the most recent post of a thread of a forum.");
|
||||
|
||||
return LastPstCod;
|
||||
}
|
||||
|
@ -1123,7 +1124,7 @@ static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
|||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
if (sscanf (row[0],"%ld",&Forums->PstCod) != 1)
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
|
||||
CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
||||
|
||||
|
@ -1385,7 +1386,7 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
|||
" FROM for_posts"
|
||||
" WHERE PstCod=%ld",
|
||||
PstCod) != 1)
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
|
||||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -1442,7 +1443,7 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1
|
|||
Length = strlen (row[1]);
|
||||
|
||||
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if (Length)
|
||||
Str_Copy (*ContentStr,row[1],Length);
|
||||
|
@ -2215,13 +2216,13 @@ void For_SetForumName (const struct For_Forum *Forum,
|
|||
case For_FORUM_INSTIT_USRS:
|
||||
Hie.Ins.InsCod = Forum->Location;
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||
break;
|
||||
case For_FORUM_INSTIT_TCHS:
|
||||
Hie.Ins.InsCod = Forum->Location;
|
||||
if (!Ins_GetDataOfInstitutionByCod (&Hie.Ins))
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||
Hie.Ins.ShrtName,
|
||||
UseHTMLEntities ? Txt_only_teachers :
|
||||
|
@ -2230,13 +2231,13 @@ void For_SetForumName (const struct For_Forum *Forum,
|
|||
case For_FORUM_CENTER_USRS:
|
||||
Hie.Ctr.CtrCod = Forum->Location;
|
||||
if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr))
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
Str_Copy (ForumName,Hie.Ctr.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||
break;
|
||||
case For_FORUM_CENTER_TCHS:
|
||||
Hie.Ctr.CtrCod = Forum->Location;
|
||||
if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr))
|
||||
Lay_WrongCenterExit ();
|
||||
Err_WrongCenterExit ();
|
||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||
Hie.Ctr.ShrtName,
|
||||
UseHTMLEntities ? Txt_only_teachers :
|
||||
|
@ -2245,13 +2246,13 @@ void For_SetForumName (const struct For_Forum *Forum,
|
|||
case For_FORUM_DEGREE_USRS:
|
||||
Hie.Deg.DegCod = Forum->Location;
|
||||
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
Str_Copy (ForumName,Hie.Deg.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||
break;
|
||||
case For_FORUM_DEGREE_TCHS:
|
||||
Hie.Deg.DegCod = Forum->Location;
|
||||
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||
Hie.Deg.ShrtName,
|
||||
UseHTMLEntities ? Txt_only_teachers :
|
||||
|
@ -2260,13 +2261,13 @@ void For_SetForumName (const struct For_Forum *Forum,
|
|||
case For_FORUM_COURSE_USRS:
|
||||
Hie.Crs.CrsCod = Forum->Location;
|
||||
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
Str_Copy (ForumName,Hie.Crs.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
||||
break;
|
||||
case For_FORUM_COURSE_TCHS:
|
||||
Hie.Crs.CrsCod = Forum->Location;
|
||||
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
||||
Hie.Crs.ShrtName,
|
||||
UseHTMLEntities ? Txt_only_teachers :
|
||||
|
@ -2512,7 +2513,7 @@ static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums
|
|||
NumThr++, NumThrInScreen++)
|
||||
/* Get thread code(row[0]) */
|
||||
if ((ThrCods[NumThrInScreen] = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_ShowErrorAndExit ("Error when getting thread of a forum.");
|
||||
Err_ShowErrorAndExit ("Error when getting thread of a forum.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -3452,13 +3453,13 @@ unsigned For_GetNumTotalPstsInForumsOfType (For_ForumType_t ForumType,
|
|||
|
||||
/* Get number of posts (row[0]) */
|
||||
if (sscanf (row[0],"%u",&NumPosts) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting the total number of forums of a type.");
|
||||
Err_ShowErrorAndExit ("Error when getting the total number of forums of a type.");
|
||||
|
||||
/* Get number of users notified (row[1]) */
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumUsrsToBeNotifiedByEMail) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting the total number of forums of a type.");
|
||||
Err_ShowErrorAndExit ("Error when getting the total number of forums of a type.");
|
||||
}
|
||||
else
|
||||
*NumUsrsToBeNotifiedByEMail = 0;
|
||||
|
@ -3605,7 +3606,7 @@ static void For_ListForumThrs (struct For_Forums *Forums,
|
|||
TimeUTC = Thr.WriteTime[Order];
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"thr_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT %s\"",Id,Style,BgColor);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,TimeUTC,
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
||||
|
@ -3677,7 +3678,7 @@ static void For_GetThreadData (struct For_Thread *Thr)
|
|||
" AND for_threads.FirstPstCod=m0.PstCod"
|
||||
" AND for_threads.LastPstCod=m1.PstCod",
|
||||
Thr->ThrCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting data of a thread of a forum.");
|
||||
Err_ShowErrorAndExit ("Error when getting data of a thread of a forum.");
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/***** Get the code of the first post in this thread (row[0]) *****/
|
||||
|
@ -3689,9 +3690,9 @@ static void For_GetThreadData (struct For_Thread *Thr)
|
|||
/***** Get the code of the first message (row[0])
|
||||
and the last message (row[1]) in this thread *****/
|
||||
if (sscanf (row[0],"%ld",&(Thr->PstCod[Dat_START_TIME])) != 1)
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
if (sscanf (row[1],"%ld",&(Thr->PstCod[Dat_END_TIME])) != 1)
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
|
||||
/***** Get the author of the first post in this thread (row[2]) *****/
|
||||
Thr->UsrCod[Dat_START_TIME] = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
@ -4005,7 +4006,7 @@ static void For_RestrictAccess (const struct For_Forums *Forums)
|
|||
break;
|
||||
}
|
||||
if (!ICanSeeForum)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4266,16 +4267,16 @@ void For_RemovePost (void)
|
|||
/***** Check if I can remove the post *****/
|
||||
/* Check if the message really exists, if it has not been removed */
|
||||
if (!For_GetIfForumPstExists (Forums.PstCod))
|
||||
Lay_WrongPostExit ();
|
||||
Err_WrongPostExit ();
|
||||
|
||||
/* Check if I am the author of the message */
|
||||
ItsMe = Usr_ItsMe (UsrDat.UsrCod);
|
||||
if (!ItsMe)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/* Check if the message is the last message in the thread */
|
||||
if (Forums.PstCod != For_GetLastPstCod (Forums.Thread.Current))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove the post *****/
|
||||
ThreadDeleted = For_RemoveForumPst (Forums.PstCod,Media.MedCod);
|
||||
|
@ -4411,7 +4412,7 @@ void For_RemoveThread (void)
|
|||
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Txt_Thread_removed);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4626,7 +4627,7 @@ static void For_MoveThrToCurrentForum (const struct For_Forums *Forums)
|
|||
Forums->Thread.Current);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongForumExit ();
|
||||
Err_WrongForumExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
91
swad_game.c
91
swad_game.c
|
@ -34,6 +34,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_game.h"
|
||||
|
@ -469,7 +470,7 @@ void Gam_SeeOneGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Show game *****/
|
||||
|
@ -580,7 +581,7 @@ static void Gam_ShowOneGame (struct Gam_Games *Games,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"gam_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Color = Game->NumUnfinishedMchs ? (Game->Hidden ? "DATE_GREEN_LIGHT":
|
||||
"DATE_GREEN") :
|
||||
(Game->Hidden ? "DATE_RED_LIGHT":
|
||||
|
@ -878,7 +879,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
|||
{
|
||||
case Rol_STD:
|
||||
if (asprintf (&HiddenSubQuery," AND gam_games.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
|
@ -887,10 +888,10 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
|||
case Rol_INS_ADM:
|
||||
case Rol_SYS_ADM:
|
||||
if (asprintf (&HiddenSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -919,7 +920,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
|||
/***** Create list of games *****/
|
||||
if ((Games->Lst = malloc ((size_t) Games->Num *
|
||||
sizeof (*Games->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the games codes *****/
|
||||
for (NumGame = 0;
|
||||
|
@ -929,7 +930,7 @@ void Gam_GetListGames (struct Gam_Games *Games,Gam_Order_t SelectedOrder)
|
|||
/* Get next game code (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if ((Games->Lst[NumGame].GamCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -961,7 +962,7 @@ void Gam_GetListSelectedGamCods (struct Gam_Games *Games)
|
|||
/***** Allocate memory for list of games selected *****/
|
||||
MaxSizeListGamCodsSelected = Games->Num * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||
if ((Games->GamCodsSelected = malloc (MaxSizeListGamCodsSelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of games selected *****/
|
||||
Par_GetParMultiToText ("GamCod",Games->GamCodsSelected,MaxSizeListGamCodsSelected);
|
||||
|
@ -1154,12 +1155,12 @@ void Gam_AskRemGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Get data of the game from database *****/
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show question and button to remove game *****/
|
||||
Games.GamCod = Game.GamCod;
|
||||
|
@ -1191,12 +1192,12 @@ void Gam_RemoveGame (void)
|
|||
|
||||
/***** Get game code *****/
|
||||
if ((Game.GamCod = Gam_GetParamGameCod ()) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Get data of the game from database *****/
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove game from all tables *****/
|
||||
Gam_RemoveGameFromAllTables (Game.GamCod);
|
||||
|
@ -1273,12 +1274,12 @@ void Gam_HideGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Get data of the game from database *****/
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Hide game *****/
|
||||
DB_QueryUPDATE ("can not hide game",
|
||||
|
@ -1308,12 +1309,12 @@ void Gam_UnhideGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Get data of the game from database *****/
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show game *****/
|
||||
DB_QueryUPDATE ("can not show game",
|
||||
|
@ -1362,11 +1363,11 @@ void Gam_ListGame (void)
|
|||
|
||||
/***** Check if I can list game questions *****/
|
||||
if (!Gam_CheckIfICanListGameQuestions ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Get game data *****/
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
@ -1397,7 +1398,7 @@ void Gam_RequestCreatOrEditGame (void)
|
|||
|
||||
/***** Check if I can edit games *****/
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get parameters *****/
|
||||
ItsANewGame = ((Game.GamCod = Gam_GetParams (&Games)) <= 0);
|
||||
|
@ -1555,7 +1556,7 @@ void Gam_ReceiveFormGame (void)
|
|||
|
||||
/***** Check if I can edit games *****/
|
||||
if (!Gam_CheckIfICanEditGames ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get parameters *****/
|
||||
ItsANewGame = ((Game.GamCod = Gam_GetParams (&Games)) <= 0);
|
||||
|
@ -1594,7 +1595,7 @@ void Gam_ReceiveFormGame (void)
|
|||
}
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
static void Gam_ReceiveGameFieldsFromForm (struct Gam_Game *Game,
|
||||
|
@ -1738,12 +1739,12 @@ void Gam_ReqSelectQstsToAddToGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show form to create a new question in this game *****/
|
||||
Games.GamCod = Game.GamCod;
|
||||
|
@ -1772,12 +1773,12 @@ void Gam_ListQstsToAddToGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** List several test questions for selection *****/
|
||||
Games.GamCod = Game.GamCod;
|
||||
|
@ -1802,7 +1803,7 @@ unsigned Gam_GetParamQstInd (void)
|
|||
long QstInd;
|
||||
|
||||
if ((QstInd = Par_GetParToLong ("QstInd")) <= 0)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
return (unsigned) QstInd;
|
||||
}
|
||||
|
@ -1858,7 +1859,7 @@ long Gam_GetQstCodFromQstInd (long GamCod,unsigned QstInd)
|
|||
GamCod,
|
||||
QstInd);
|
||||
if (QstCod <= 0)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
return QstCod;
|
||||
}
|
||||
|
@ -2169,12 +2170,12 @@ void Gam_AddQstsToGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get selected questions *****/
|
||||
/* Allocate space for selected question codes */
|
||||
|
@ -2195,7 +2196,7 @@ void Gam_AddQstsToGame (void)
|
|||
/* Get next code */
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
||||
if (sscanf (LongStr,"%ld",&QstCod) != 1)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Check if question is already present in game */
|
||||
if (Gam_GetQstIndFromQstCod (Game.GamCod,QstCod) == 0) // This question is not yet in this game
|
||||
|
@ -2244,7 +2245,7 @@ static void Gam_AllocateListSelectedQuestions (struct Gam_Games *Games)
|
|||
if (!Games->ListQuestions)
|
||||
{
|
||||
if ((Games->ListQuestions = malloc (Gam_MAX_BYTES_LIST_SELECTED_QUESTIONS + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Games->ListQuestions[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -2282,12 +2283,12 @@ void Gam_RequestRemoveQstFromGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get question index *****/
|
||||
QstInd = Gam_GetParamQstInd ();
|
||||
|
@ -2326,12 +2327,12 @@ void Gam_RemoveQstFromGame (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get question index *****/
|
||||
QstInd = Gam_GetParamQstInd ();
|
||||
|
@ -2348,7 +2349,7 @@ void Gam_RemoveQstFromGame (void)
|
|||
Game.GamCod,
|
||||
QstInd);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Change index of questions greater than this */
|
||||
DB_QueryUPDATE ("can not update indexes of questions in table of answers",
|
||||
|
@ -2397,12 +2398,12 @@ void Gam_MoveUpQst (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get question index *****/
|
||||
QstIndBottom = Gam_GetParamQstInd ();
|
||||
|
@ -2413,7 +2414,7 @@ void Gam_MoveUpQst (void)
|
|||
/* Indexes of questions to be exchanged */
|
||||
QstIndTop = Gam_GetPrevQuestionIndexInGame (Game.GamCod,QstIndBottom);
|
||||
if (!QstIndTop)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
/* Exchange questions */
|
||||
Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom);
|
||||
|
@ -2448,12 +2449,12 @@ void Gam_MoveDownQst (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Check if game has matches *****/
|
||||
if (!Gam_CheckIfEditable (&Game))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get question index *****/
|
||||
QstIndTop = Gam_GetParamQstInd ();
|
||||
|
@ -2467,7 +2468,7 @@ void Gam_MoveDownQst (void)
|
|||
/* Indexes of questions to be exchanged */
|
||||
QstIndBottom = Gam_GetNextQuestionIndexInGame (Game.GamCod,QstIndTop);
|
||||
if (!QstIndBottom)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
/* Exchange questions */
|
||||
Gam_ExchangeQuestions (Game.GamCod,QstIndTop,QstIndBottom);
|
||||
|
@ -2598,7 +2599,7 @@ void Gam_RequestNewMatch (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Show game *****/
|
||||
|
@ -2845,7 +2846,7 @@ double Gam_GetNumQstsPerCrsGame (Hie_Lvl_Level_t Scope)
|
|||
" GROUP BY gam_questions.GamCod) AS NumQstsTable",
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0.0; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -2896,7 +2897,7 @@ void Gam_GetScoreRange (long GamCod,double *MinScore,double *MaxScore)
|
|||
" GROUP BY tst_answers.QstCod",
|
||||
GamCod);
|
||||
if (NumAnswers < 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Set minimum and maximum scores *****/
|
||||
*MinScore = *MaxScore = 0.0;
|
||||
|
|
83
swad_group.c
83
swad_group.c
|
@ -35,6 +35,7 @@
|
|||
#include "swad_attendance.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_session.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_game.h"
|
||||
|
@ -503,7 +504,7 @@ void Grp_PutParamsCodGrps (void)
|
|||
{
|
||||
MaxLengthGrpCods = Gbl.Crs.Grps.LstGrpsSel.NumGrps * (Cns_MAX_DECIMAL_DIGITS_LONG + 1) - 1;
|
||||
if ((GrpCods = malloc (MaxLengthGrpCods + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
GrpCods[0] = '\0';
|
||||
|
||||
for (NumGrpSel = 0;
|
||||
|
@ -554,7 +555,7 @@ void Grp_GetParCodsSeveralGrpsToShowUsrs (void)
|
|||
/* Allocate space for list of selected groups */
|
||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (LstGrpsIBelong.NumGrps,
|
||||
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Fill list of selected groups with list of groups I belong to */
|
||||
for (NumGrp = 0;
|
||||
|
@ -592,7 +593,7 @@ void Grp_GetParCodsSeveralGrps (void)
|
|||
{
|
||||
/***** Allocate memory for the list of group codes selected *****/
|
||||
if ((ParamLstCodGrps = malloc (MaxSizeLstGrpCods + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter with list of groups to list *****/
|
||||
Par_GetParMultiToText ("GrpCods",ParamLstCodGrps,MaxSizeLstGrpCods);
|
||||
|
@ -611,7 +612,7 @@ void Grp_GetParCodsSeveralGrps (void)
|
|||
/***** Create a list of groups selected from LstCodGrps *****/
|
||||
if ((Gbl.Crs.Grps.LstGrpsSel.GrpCods = calloc (Gbl.Crs.Grps.LstGrpsSel.NumGrps,
|
||||
sizeof (*Gbl.Crs.Grps.LstGrpsSel.GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
for (Ptr = ParamLstCodGrps, NumGrp = 0;
|
||||
*Ptr;
|
||||
NumGrp++)
|
||||
|
@ -1068,7 +1069,7 @@ static void Grp_ConstructorListGrpAlreadySelec (struct ListGrpsAlreadySelec **Al
|
|||
/***** Allocate memory to a list of booleanos that indica if already se ha selected a group of cada type *****/
|
||||
if ((*AlreadyExistsGroupOfType = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||
sizeof (**AlreadyExistsGroupOfType))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Initialize the list *****/
|
||||
for (NumGrpTyp = 0;
|
||||
|
@ -2406,7 +2407,7 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp)
|
|||
{
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"open_time_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BR ();
|
||||
HTM_TxtColonNBSP (Txt_Opening_of_groups);
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
|
@ -2829,7 +2830,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
/***** Create a list of group types *****/
|
||||
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||
sizeof (*Gbl.Crs.Grps.GrpTypes.LstGrpTypes))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get group types *****/
|
||||
for (NumGrpTyp = 0;
|
||||
|
@ -2841,7 +2842,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
|
||||
/* Get group type code (row[0]) */
|
||||
if ((Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/* Get group type name (row[1]) */
|
||||
Str_Copy (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,row[1],
|
||||
|
@ -2862,7 +2863,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
|
||||
/* Number of groups of this type (row[6]) */
|
||||
if (sscanf (row[6],"%u",&Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong number of groups of a type.");
|
||||
Err_ShowErrorAndExit ("Wrong number of groups of a type.");
|
||||
|
||||
/* Add number of groups to total number of groups */
|
||||
Gbl.Crs.Grps.GrpTypes.NumGrpsTotal += Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps;
|
||||
|
@ -2959,7 +2960,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
/***** Create list with groups of this type *****/
|
||||
if ((GrpTyp->LstGrps = calloc ((size_t) GrpTyp->NumGrps,
|
||||
sizeof (*GrpTyp->LstGrps))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the groups of this type *****/
|
||||
for (NumGrp = 0;
|
||||
|
@ -2973,7 +2974,7 @@ void Grp_GetListGrpTypesAndGrpsInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
|
|||
|
||||
/* Get group code (row[0]) */
|
||||
if ((Grp->GrpCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/* Get group name (row[1]) */
|
||||
Str_Copy (Grp->GrpName,row[1],sizeof (Grp->GrpName) - 1);
|
||||
|
@ -3123,7 +3124,7 @@ static void Grp_GetDataOfGroupTypeByCod (struct GroupType *GrpTyp)
|
|||
" WHERE CrsCod=%ld"
|
||||
" AND GrpTypCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,GrpTyp->GrpTypCod) != 1)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/***** Get some data of group type *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3154,7 +3155,7 @@ static bool Grp_GetMultipleEnrolmentOfAGroupType (long GrpTypCod)
|
|||
" FROM grp_types"
|
||||
" WHERE GrpTypCod=%ld",
|
||||
GrpTypCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting type of enrolment.");
|
||||
Err_ShowErrorAndExit ("Error when getting type of enrolment.");
|
||||
|
||||
/***** Get multiple enrolment *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3215,11 +3216,11 @@ void Grp_GetDataOfGroupByCod (struct GroupData *GrpDat)
|
|||
|
||||
/* Get the code of the group type (row[0]) */
|
||||
if ((GrpDat->GrpTypCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/* Get the code of the course (row[1]) */
|
||||
if ((GrpDat->CrsCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/* Get the name of the group type (row[2]) */
|
||||
Str_Copy (GrpDat->GrpTypName,row[2],sizeof (GrpDat->GrpTypName) - 1);
|
||||
|
@ -3270,7 +3271,7 @@ static long Grp_GetTypeOfGroupOfAGroup (long GrpCod)
|
|||
" WHERE GrpCod=%ld",
|
||||
GrpCod);
|
||||
if (GrpTypCod <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
return GrpTypCod;
|
||||
}
|
||||
|
@ -3504,14 +3505,14 @@ bool Grp_GetIfAvailableGrpTyp (long GrpTypCod)
|
|||
{
|
||||
if (asprintf (&SubQueryGrpTypes,"grp_types.GrpTypCod=%ld",
|
||||
GrpTypCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // all mandatory group types in the current course
|
||||
{
|
||||
if (asprintf (&SubQueryGrpTypes,"grp_types.CrsCod=%ld"
|
||||
" AND grp_types.Mandatory='Y'",
|
||||
Gbl.Hierarchy.Crs.CrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Get the number of types of group in this course
|
||||
|
@ -3644,13 +3645,13 @@ static void Grp_GetLstCodGrpsUsrBelongs (long CrsCod,long GrpTypCod,
|
|||
/***** Create a list of groups the user belongs to *****/
|
||||
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
|
||||
sizeof (*LstGrps->GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
for (NumGrp = 0;
|
||||
NumGrp < LstGrps->NumGrps;
|
||||
NumGrp++)
|
||||
/* Get the code of group (row[0]) */
|
||||
if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -3689,13 +3690,13 @@ void Grp_GetLstCodGrpsWithFileZonesIBelong (struct ListCodGrps *LstGrps)
|
|||
/***** Create a list of groups I belong to *****/
|
||||
if ((LstGrps->GrpCods = calloc (LstGrps->NumGrps,
|
||||
sizeof (*LstGrps->GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
for (NumGrp = 0;
|
||||
NumGrp < LstGrps->NumGrps;
|
||||
NumGrp++)
|
||||
/* Get the code of group */
|
||||
if ((LstGrps->GrpCods[NumGrp] = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -3992,7 +3993,7 @@ void Grp_ReqRemGroupType (void)
|
|||
|
||||
/***** Get the code of the group type *****/
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/***** Check if this group type has groups *****/
|
||||
if ((NumGrps = Grp_CountNumGrpsInThisCrsOfType (Gbl.Crs.Grps.GrpTyp.GrpTypCod))) // Group type has groups ==> Ask for confirmation
|
||||
|
@ -4009,7 +4010,7 @@ void Grp_ReqRemGroup (void)
|
|||
{
|
||||
/***** Get group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Confirm removing *****/
|
||||
Grp_AskConfirmRemGrp ();
|
||||
|
@ -4106,7 +4107,7 @@ void Grp_RemoveGroupType (void)
|
|||
{
|
||||
/***** Get param with code of group type *****/
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/***** Remove group type and its groups *****/
|
||||
Grp_RemoveGroupTypeCompletely ();
|
||||
|
@ -4120,7 +4121,7 @@ void Grp_RemoveGroup (void)
|
|||
{
|
||||
/***** Get param with group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Remove group *****/
|
||||
Grp_RemoveGroupCompletely ();
|
||||
|
@ -4262,7 +4263,7 @@ void Grp_OpenGroup (void)
|
|||
|
||||
/***** Get group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Get group data from database *****/
|
||||
GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod;
|
||||
|
@ -4297,7 +4298,7 @@ void Grp_CloseGroup (void)
|
|||
|
||||
/***** Get group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Get group data from database *****/
|
||||
GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod;
|
||||
|
@ -4332,7 +4333,7 @@ void Grp_EnableFileZonesGrp (void)
|
|||
|
||||
/***** Get group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Get group data from database *****/
|
||||
GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod;
|
||||
|
@ -4368,7 +4369,7 @@ void Grp_DisableFileZonesGrp (void)
|
|||
|
||||
/***** Get group code *****/
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/***** Get group data from database *****/
|
||||
GrpDat.GrpCod = Gbl.Crs.Grps.GrpCod;
|
||||
|
@ -4408,7 +4409,7 @@ void Grp_ChangeGroupType (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get group code */
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/* Get the new group type */
|
||||
NewGrpTypCod = Grp_GetParamGrpTypCod ();
|
||||
|
@ -4462,7 +4463,7 @@ void Grp_ChangeGroupRoom (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get group code */
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/* Get the new room */
|
||||
NewRooCod = Roo_GetParamRooCod ();
|
||||
|
@ -4507,7 +4508,7 @@ void Grp_ChangeMandatGrpTyp (void)
|
|||
/***** Get parameters of the form *****/
|
||||
/* Get the código of type of group */
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/* Get the new type of enrolment (mandatory or voluntaria) of this type of group */
|
||||
NewMandatoryEnrolment = Par_GetParToBool ("MandatoryEnrolment");
|
||||
|
@ -4565,7 +4566,7 @@ void Grp_ChangeMultiGrpTyp (void)
|
|||
/***** Get parameters from the form *****/
|
||||
/* Get the code of type of group */
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/* Get the new type of enrolment (single or multiple) of this type of group */
|
||||
NewMultipleEnrolment = Par_GetParToBool ("MultipleEnrolment");
|
||||
|
@ -4617,7 +4618,7 @@ void Grp_ChangeOpenTimeGrpTyp (void)
|
|||
|
||||
/***** Get the code of type of group *****/
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/***** Get from the database the data of this type of group *****/
|
||||
Grp_GetDataOfGroupTypeByCod (&Gbl.Crs.Grps.GrpTyp);
|
||||
|
@ -4663,7 +4664,7 @@ void Grp_ChangeMaxStdsGrp (void)
|
|||
/***** Get parameters of the form *****/
|
||||
/* Get group code */
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/* Get the new maximum number of students of the group */
|
||||
NewMaxStds = (unsigned)
|
||||
|
@ -4758,7 +4759,7 @@ void Grp_RenameGroupType (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the group type */
|
||||
if ((Gbl.Crs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) <= 0)
|
||||
Lay_WrongGrpTypExit ();
|
||||
Err_WrongGrpTypExit ();
|
||||
|
||||
/* Get the new name for the group type */
|
||||
Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_BYTES_GROUP_TYPE_NAME);
|
||||
|
@ -4837,7 +4838,7 @@ void Grp_RenameGroup (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the group */
|
||||
if ((Gbl.Crs.Grps.GrpCod = Grp_GetParamGrpCod ()) <= 0)
|
||||
Lay_WrongGroupExit ();
|
||||
Err_WrongGroupExit ();
|
||||
|
||||
/* Get the new name for the group */
|
||||
Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_BYTES_GROUP_NAME);
|
||||
|
@ -4953,7 +4954,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
|||
/***** Allocate memory for the strings with group codes in each type *****/
|
||||
if ((LstStrCodGrps = calloc (Gbl.Crs.Grps.GrpTypes.Num,
|
||||
sizeof (*LstStrCodGrps))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get lists with the groups that I want in each type
|
||||
in order to count the total number of groups selected *****/
|
||||
|
@ -4964,7 +4965,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
|||
/***** Allocate memory for the list of group codes of this type *****/
|
||||
if ((LstStrCodGrps[NumGrpTyp] = malloc (Gbl.Crs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].NumGrps *
|
||||
(Cns_MAX_DECIMAL_DIGITS_LONG + 1))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the multiple parameter code of group of this type *****/
|
||||
snprintf (Param,sizeof (Param),"GrpCod%ld",
|
||||
|
@ -4990,7 +4991,7 @@ void Grp_GetLstCodsGrpWanted (struct ListCodGrps *LstGrpsWanted)
|
|||
{
|
||||
if ((LstGrpsWanted->GrpCods = calloc (LstGrpsWanted->NumGrps,
|
||||
sizeof (*LstGrpsWanted->GrpCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the groups *****/
|
||||
for (NumGrpTyp = 0, NumGrpWanted = 0;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdlib.h> // For free
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
|
@ -195,7 +196,7 @@ void Hie_WriteHierarchyInBreadcrumb (void)
|
|||
|
||||
/***** Create CSS class of links *****/
|
||||
if (asprintf (&ClassLink,"BT_LINK %s",ClassTxt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Form to go to the system *****/
|
||||
HTM_DIV_Begin ("class=\"BC %s\"",ClassTxt);
|
||||
|
@ -768,7 +769,7 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
|||
}
|
||||
break;
|
||||
default: // There are no administrators in other scopes
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
HTM_TD_End ();
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_calendar.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_holiday.h"
|
||||
|
@ -370,7 +371,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
|||
/***** Create list of holidays *****/
|
||||
if ((Holidays->Lst = calloc (Holidays->Num,
|
||||
sizeof (*Holidays->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the holidays *****/
|
||||
for (NumHld = 0;
|
||||
|
@ -384,7 +385,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
|||
|
||||
/* Get holiday code (row[0]) */
|
||||
if ((Hld->HldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/* Get place code (row[1]) */
|
||||
Hld->PlcCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
@ -398,7 +399,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
|||
|
||||
/* Get start date (row[4] holds the start date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->StartDate),row[4])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Set / get end date */
|
||||
switch (Hld->HldTyp)
|
||||
|
@ -410,7 +411,7 @@ void Hld_GetListHolidays (struct Hld_Holidays *Holidays)
|
|||
case Hld_NON_SCHOOL_PERIOD: // One or more days
|
||||
/* Get end date (row[5] holds the end date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->EndDate),row[5])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -445,7 +446,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
|
|||
|
||||
/***** Check if holiday code is correct *****/
|
||||
if (Hld->HldCod <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/***** Get data of holiday from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get data of a holiday",
|
||||
|
@ -496,7 +497,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
|
|||
|
||||
/* Get start date (row[3] holds the start date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->StartDate),row[3])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Set / get end date */
|
||||
switch (Hld->HldTyp)
|
||||
|
@ -508,7 +509,7 @@ static void Hld_GetDataOfHolidayByCod (struct Hld_Holiday *Hld)
|
|||
case Hld_NON_SCHOOL_PERIOD: // One or more days
|
||||
/* Get end date (row[4] holds the end date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&(Hld->EndDate),row[4])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -542,10 +543,10 @@ static Hld_HolidayType_t Hld_GetTypeOfHoliday (const char *UnsignedStr)
|
|||
unsigned UnsignedNum;
|
||||
|
||||
if (sscanf (UnsignedStr,"%u",&UnsignedNum) != 1)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
if (UnsignedNum >= Hld_NUM_TYPES_HOLIDAY)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
return (Hld_HolidayType_t) UnsignedNum;
|
||||
}
|
||||
|
@ -721,7 +722,7 @@ void Hld_RemoveHoliday (void)
|
|||
|
||||
/***** Get holiday code *****/
|
||||
if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/***** Get data of the holiday from database *****/
|
||||
Hld_GetDataOfHolidayByCod (Hld_EditingHld);
|
||||
|
@ -753,7 +754,7 @@ void Hld_ChangeHolidayPlace (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the holiday */
|
||||
if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/* Get the new place for the holiday */
|
||||
NewPlace.PlcCod = Plc_GetParamPlcCod ();
|
||||
|
@ -794,7 +795,7 @@ void Hld_ChangeHolidayType (void)
|
|||
|
||||
/***** Get the code of the holiday *****/
|
||||
if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/***** Get from the database the data of the holiday *****/
|
||||
Hld_GetDataOfHolidayByCod (Hld_EditingHld);
|
||||
|
@ -853,7 +854,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate)
|
|||
|
||||
/***** Get the code of the holiday *****/
|
||||
if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/***** Get from the database the data of the holiday *****/
|
||||
Hld_GetDataOfHolidayByCod (Hld_EditingHld);
|
||||
|
@ -926,7 +927,7 @@ void Hld_RenameHoliday (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the holiday */
|
||||
if ((Hld_EditingHld->HldCod = Hld_GetParamHldCod ()) <= 0)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/* Get the new name for the holiday */
|
||||
Par_GetParToText ("Name",NewHldName,Hld_MAX_BYTES_HOLIDAY_NAME);
|
||||
|
@ -1214,11 +1215,11 @@ static void Hld_EditingHolidayConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Hld_EditingHld != NULL)
|
||||
Lay_WrongHolidayExit ();
|
||||
Err_WrongHolidayExit ();
|
||||
|
||||
/***** Allocate memory for holiday *****/
|
||||
if ((Hld_EditingHld = malloc (sizeof (*Hld_EditingHld))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset place *****/
|
||||
Hld_EditingHld->HldCod = -1L;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_forum.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -636,7 +637,7 @@ static unsigned Ind_GetTableOfCourses (const struct Ind_Indicators *Indicators,
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -723,7 +724,7 @@ static void Ind_GetNumCoursesWithIndicators (unsigned NumCrssWithIndicatorYes[1
|
|||
|
||||
/* Get course code (row[2]) */
|
||||
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/* Get stored number of indicators of this course */
|
||||
NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod);
|
||||
|
@ -991,7 +992,7 @@ static void Ind_ShowTableOfCoursesWithIndicators (const struct Ind_Indicators *I
|
|||
|
||||
/* Get course code (row[2]) */
|
||||
if ((CrsCod = Str_ConvertStrCodToLongCod (row[2])) < 0)
|
||||
Lay_WrongCourseExit ();
|
||||
Err_WrongCourseExit ();
|
||||
|
||||
/* Get stored number of indicators of this course */
|
||||
NumIndicators = Ind_GetAndUpdateNumIndicatorsCrs (CrsCod);
|
||||
|
@ -1385,7 +1386,7 @@ int Ind_GetNumIndicatorsCrsFromDB (long CrsCod)
|
|||
|
||||
/***** Get number of indicators (row[0]) *****/
|
||||
if (sscanf (row[0],"%d",&NumIndicatorsFromDB) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of indicators.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of indicators.");
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_action.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -1834,7 +1835,7 @@ static bool Inf_CheckAndShowRichTxt (void)
|
|||
|
||||
/* Open Markdown file for writing */
|
||||
if ((FileMD = fopen (PathFileMD,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not create temporary Markdown file.");
|
||||
Err_ShowErrorAndExit ("Can not create temporary Markdown file.");
|
||||
|
||||
/* Write text into Markdown file */
|
||||
fprintf (FileMD,"%s",TxtMD);
|
||||
|
@ -1877,7 +1878,7 @@ static bool Inf_CheckAndShowRichTxt (void)
|
|||
PathFileHTML);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running command to convert from Markdown to HTML.");
|
||||
Err_ShowErrorAndExit ("Error when running command to convert from Markdown to HTML.");
|
||||
|
||||
/***** Remove Markdown file *****/
|
||||
unlink (PathFileMD);
|
||||
|
@ -1885,7 +1886,7 @@ static bool Inf_CheckAndShowRichTxt (void)
|
|||
/***** Copy HTML file just created to HTML output *****/
|
||||
/* Open temporary HTML file for reading */
|
||||
if ((FileHTML = fopen (PathFileHTML,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open temporary HTML file.");
|
||||
Err_ShowErrorAndExit ("Can not open temporary HTML file.");
|
||||
|
||||
/* Copy from temporary HTML file to output file */
|
||||
Fil_FastCopyOfOpenFiles (FileHTML,Gbl.F.Out);
|
||||
|
@ -2261,7 +2262,7 @@ void Inf_ReceivePagInfo (void)
|
|||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Can not unzip file.");
|
||||
Err_ShowErrorAndExit ("Can not unzip file.");
|
||||
}
|
||||
else
|
||||
Ale_ShowAlert (Ale_ERROR,"Error uploading file.");
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -651,7 +652,7 @@ void Ins_GetBasicListOfInstitutions (long CtyCod)
|
|||
/***** Create list with institutions *****/
|
||||
if ((Gbl.Hierarchy.Inss.Lst = calloc ((size_t) Gbl.Hierarchy.Inss.Num,
|
||||
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the institutions *****/
|
||||
for (NumIns = 0;
|
||||
|
@ -733,7 +734,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod)
|
|||
/***** Create list with institutions *****/
|
||||
if ((Gbl.Hierarchy.Inss.Lst = calloc ((size_t) Gbl.Hierarchy.Inss.Num,
|
||||
sizeof (*Gbl.Hierarchy.Inss.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the institutions *****/
|
||||
for (NumIns = 0;
|
||||
|
@ -835,14 +836,14 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
|
|||
{
|
||||
/***** Get institution code (row[0]) *****/
|
||||
if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Get country code (row[1]) *****/
|
||||
Ins->CtyCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
|
||||
/***** Get institution status (row[2]) *****/
|
||||
if (sscanf (row[2],"%u",&(Ins->Status)) != 1)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
|
||||
/***** Get requester user's code (row[3]) *****/
|
||||
Ins->RequesterUsrCod = Str_ConvertStrCodToLongCod (row[3]);
|
||||
|
@ -1030,7 +1031,7 @@ void Ins_WriteSelectorOfInstitution (void)
|
|||
|
||||
/* Get institution code (row[0]) */
|
||||
if ((InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/* Write option */
|
||||
HTM_OPTION (HTM_Type_LONG,&InsCod,
|
||||
|
@ -1314,7 +1315,7 @@ long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed)
|
|||
|
||||
/***** Get and check parameter with code of institution *****/
|
||||
if ((InsCod = Ins_GetParamOtherInsCod ()) < MinCodAllowed)
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
return InsCod;
|
||||
}
|
||||
|
@ -1346,7 +1347,7 @@ void Ins_RemoveInstitution (void)
|
|||
|
||||
/***** Check if this institution has users *****/
|
||||
if (!Ins_CheckIfICanEdit (Ins_EditingIns))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
else if (Ctr_GetNumCtrsInIns (Ins_EditingIns->InsCod))
|
||||
// Institution has centers ==> don't remove
|
||||
Ale_CreateAlert (Ale_WARNING,NULL,
|
||||
|
@ -1618,7 +1619,7 @@ void Ins_ChangeInsStatus (void)
|
|||
(unsigned long) Ins_MAX_STATUS,
|
||||
(unsigned long) Ins_WRONG_STATUS);
|
||||
if (Status == Ins_WRONG_STATUS)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
StatusTxt = Ins_GetStatusTxtFromStatusBits (Status);
|
||||
Status = Ins_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
|
@ -1702,7 +1703,7 @@ static void Ins_PutFormToCreateInstitution (void)
|
|||
else if (Gbl.Usrs.Me.Role.Max >= Rol_GST)
|
||||
Frm_BeginForm (ActReqIns);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Begin box and table *****/
|
||||
Box_BoxTableBegin (NULL,Txt_New_institution,
|
||||
|
@ -2174,11 +2175,11 @@ static void Ins_EditingInstitutionConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Ins_EditingIns != NULL)
|
||||
Lay_WrongInstitExit ();
|
||||
Err_WrongInstitExit ();
|
||||
|
||||
/***** Allocate memory for institution *****/
|
||||
if ((Ins_EditingIns = malloc (sizeof (*Ins_EditingIns))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset institution *****/
|
||||
Ins_EditingIns->InsCod = -1L;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -264,7 +265,7 @@ static void InsCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
" AND Latitude<>0"
|
||||
" AND Longitude<>0",
|
||||
Gbl.Hierarchy.Ins.InsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
}
|
||||
|
|
553
swad_layout.c
553
swad_layout.c
|
@ -39,6 +39,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_connected.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_session.h"
|
||||
#include "swad_firewall.h"
|
||||
#include "swad_follow.h"
|
||||
|
@ -86,8 +87,6 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Lay_WriteEndOfPage (void);
|
||||
|
||||
static void Lay_WritePageTitle (void);
|
||||
|
||||
static void Lay_WriteRedirToMyLangOnLogIn (void);
|
||||
|
@ -107,7 +106,6 @@ static void Lay_WriteTitleAction (void);
|
|||
static void Lay_ShowLeftColumn (void);
|
||||
static void Lay_ShowRightColumn (void);
|
||||
|
||||
static void Lay_WriteAboutZone (void);
|
||||
static void Lay_WriteFootFromHTMLFile (void);
|
||||
|
||||
static void Lay_HelpTextEditor (const char *Text,const char *InlineMath,const char *Equation);
|
||||
|
@ -412,7 +410,7 @@ void Lay_WriteHTTPStatus204NoContent (void)
|
|||
/************************ Write the end of the page **************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Lay_WriteEndOfPage (void)
|
||||
void Lay_WriteEndOfPage (void)
|
||||
{
|
||||
if (!Gbl.Layout.DivsEndWritten)
|
||||
{
|
||||
|
@ -1369,556 +1367,11 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction,
|
|||
// jumping to the next line on narrow screens
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when not enough memory **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_NotEnoughMemoryExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Not enough memory.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong action ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongActionExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong action.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong scope *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongScopeExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit *********/
|
||||
/********* when wrong country, institution, center, degree or course *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongCountrExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong country.");
|
||||
}
|
||||
|
||||
void Lay_WrongInstitExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong institution.");
|
||||
}
|
||||
|
||||
void Lay_WrongCenterExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong center.");
|
||||
}
|
||||
|
||||
void Lay_WrongDegTypExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong degree type.");
|
||||
}
|
||||
|
||||
void Lay_WrongDegreeExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong degree.");
|
||||
}
|
||||
|
||||
void Lay_WrongCourseExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong course.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong department **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongDepartmentExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong department.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong place ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongPlaceExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong department.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong order *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongOrderExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong order.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong status ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongStatusExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong status.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong date ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongDateExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong date.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong plugin ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongPluginExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong plugin.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong items list/item **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongItemsListExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong items list.");
|
||||
}
|
||||
|
||||
void Lay_WrongItemExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong item.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong syllabus format **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongSyllabusFormatExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong syllabus format.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong file browser ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongFileBrowserExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong file browser.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong copy source *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongCopySrcExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("The copy source does not exist.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong number of rows ***********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongNumberOfRowsExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong number of rows.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit when wrong group type/group **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongGrpTypExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong group type.");
|
||||
}
|
||||
|
||||
void Lay_WrongGroupExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong group.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong order *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongTypeOfViewExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong type of view.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong banner/link *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongBannerExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong banner.");
|
||||
}
|
||||
|
||||
void Lay_WrongLinkExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong link.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong holiday ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongHolidayExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong holiday.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong building/room ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongBuildingExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong building.");
|
||||
}
|
||||
|
||||
void Lay_WrongRoomExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong room.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong record field ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongRecordFieldExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong record field.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong assignment **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongAssignmentExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong assignment.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong project ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongProjectExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong project.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Write error message and exit when wrong call for exam ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongCallForExamExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong call for exam.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong tag *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongTagExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong tag.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong test *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongTestExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong test.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong exam *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongExamExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong exam.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Write error message and exit when wrong set of questions **********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongSetExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong set of questions.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Write error message and exit when wrong question **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongQuestionExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong question.");
|
||||
}
|
||||
|
||||
void Lay_WrongQuestionIndexExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong question index.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong answer ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongAnswerExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong answer.");
|
||||
}
|
||||
|
||||
void Lay_WrongAnswerIndexExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong answer index.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong exam session ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongExamSessionExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong exam session.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong game/match *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongGameExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong game.");
|
||||
}
|
||||
|
||||
void Lay_WrongMatchExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong match.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong survey ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongSurveyExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong survey.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Write error message and exit when wrong parameter "who" (which users) ***/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongWhoExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong parameter who.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Write error message and exit when wrong event **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongEventExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong event.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Write error message and exit when wrong announcement ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongAnnouncementExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong announcement.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong notice ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongNoticeExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong notice.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong forum/post *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongForumExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong forum.");
|
||||
}
|
||||
|
||||
void Lay_WrongPostExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong post.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Write error message and exit when wrong message **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongMessageExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong message.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when wrong mail domain ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongMailDomainExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong mail domain.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show error message about wrong role and exit ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongRoleExit (void)
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Wrong role.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Write error message and exit when user does not exists *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_WrongUserExit (void)
|
||||
{
|
||||
extern const char *Txt_The_user_does_not_exist;
|
||||
|
||||
Lay_ShowErrorAndExit (Txt_The_user_does_not_exist);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Write error message and exit when no permission to perform an action ****/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_NoPermissionExit (void)
|
||||
{
|
||||
extern const char *Txt_You_dont_have_permission_to_perform_this_action;
|
||||
|
||||
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******* Write error message, close files, remove lock file, and exit ********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Lay_ShowErrorAndExit (const char *Txt)
|
||||
{
|
||||
/***** Unlock tables if locked *****/
|
||||
if (Gbl.DB.LockedTables)
|
||||
{
|
||||
Gbl.DB.LockedTables = false;
|
||||
mysql_query (&Gbl.mysql,"UNLOCK TABLES");
|
||||
}
|
||||
|
||||
if (!Gbl.WebService.IsWebService)
|
||||
{
|
||||
/****** If start of page is not written yet, do it now ******/
|
||||
if (!Gbl.Layout.HTMLStartWritten)
|
||||
Lay_WriteStartOfPage ();
|
||||
|
||||
/***** Write possible error message *****/
|
||||
if (Txt)
|
||||
Ale_ShowAlert (Ale_ERROR,Txt);
|
||||
|
||||
/***** Finish the page, except </body> and </html> *****/
|
||||
Lay_WriteEndOfPage ();
|
||||
}
|
||||
|
||||
/***** Free memory and close all the open files *****/
|
||||
Gbl_Cleanup ();
|
||||
|
||||
/***** Page is generated (except </body> and </html>).
|
||||
Compute time to generate page *****/
|
||||
if (!Gbl.Action.IsAJAXAutoRefresh)
|
||||
Gbl.TimeGenerationInMicroseconds = (long) Sta_ComputeTimeToGeneratePage ();
|
||||
|
||||
if (Gbl.WebService.IsWebService) // Serving a plugin request
|
||||
{
|
||||
/***** Log access *****/
|
||||
Gbl.TimeSendInMicroseconds = 0L;
|
||||
Log_LogAccess (Txt);
|
||||
}
|
||||
else
|
||||
{
|
||||
/***** Send page.
|
||||
The HTML output is now in Gbl.F.Out file ==>
|
||||
==> copy it to standard output *****/
|
||||
rewind (Gbl.F.Out);
|
||||
Fil_FastCopyOfOpenFiles (Gbl.F.Out,stdout);
|
||||
Fil_CloseAndRemoveFileForHTMLOutput ();
|
||||
|
||||
if (!Gbl.Action.IsAJAXAutoRefresh)
|
||||
{
|
||||
/***** Compute time to send page *****/
|
||||
Sta_ComputeTimeToSendPage ();
|
||||
|
||||
/***** Log access *****/
|
||||
Log_LogAccess (Txt);
|
||||
|
||||
/***** Update last data for next time *****/
|
||||
if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
Usr_UpdateMyLastData ();
|
||||
Crs_UpdateCrsLast ();
|
||||
}
|
||||
|
||||
/***** End the output *****/
|
||||
if (!Gbl.Layout.HTMLEndWritten)
|
||||
{
|
||||
// Here Gbl.F.Out is stdout
|
||||
if (Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB)
|
||||
Lay_WriteAboutZone ();
|
||||
|
||||
HTM_Txt ("</body>\n"
|
||||
"</html>\n");
|
||||
Gbl.Layout.HTMLEndWritten = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***** Close database connection *****/
|
||||
DB_CloseDBConnection ();
|
||||
|
||||
/***** Exit *****/
|
||||
if (Gbl.WebService.IsWebService)
|
||||
API_Exit (Txt);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Write about zone at the end of the page *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Lay_WriteAboutZone (void)
|
||||
void Lay_WriteAboutZone (void)
|
||||
{
|
||||
extern const char *Txt_About_X;
|
||||
extern const char *Txt_Questions_and_problems;
|
||||
|
|
|
@ -50,6 +50,8 @@ void Lay_WriteStartOfPage (void);
|
|||
|
||||
void Lay_WriteHTTPStatus204NoContent (void);
|
||||
|
||||
void Lay_WriteEndOfPage (void);
|
||||
|
||||
void Lay_PutContextualLinkOnlyIcon (Act_Action_t NextAction,const char *Anchor,
|
||||
void (*FuncParams) (void *Args),void *Args,
|
||||
const char *Icon,
|
||||
|
@ -69,63 +71,7 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction,
|
|||
bool Checked,bool Disabled,
|
||||
const char *Title,const char *Text);
|
||||
|
||||
void Lay_NotEnoughMemoryExit (void);
|
||||
void Lay_WrongActionExit (void);
|
||||
void Lay_WrongScopeExit (void);
|
||||
void Lay_WrongCountrExit (void);
|
||||
void Lay_WrongInstitExit (void);
|
||||
void Lay_WrongCenterExit (void);
|
||||
void Lay_WrongDegTypExit (void);
|
||||
void Lay_WrongDegreeExit (void);
|
||||
void Lay_WrongCourseExit (void);
|
||||
void Lay_WrongDepartmentExit (void);
|
||||
void Lay_WrongPlaceExit (void);
|
||||
void Lay_WrongOrderExit (void);
|
||||
void Lay_WrongStatusExit (void);
|
||||
void Lay_WrongDateExit (void);
|
||||
void Lay_WrongPluginExit (void);
|
||||
void Lay_WrongItemsListExit (void);
|
||||
void Lay_WrongItemExit (void);
|
||||
void Lay_WrongSyllabusFormatExit (void);
|
||||
void Lay_WrongFileBrowserExit (void);
|
||||
void Lay_WrongCopySrcExit (void);
|
||||
void Lay_WrongNumberOfRowsExit (void);
|
||||
void Lay_WrongGrpTypExit (void);
|
||||
void Lay_WrongGroupExit (void);
|
||||
void Lay_WrongTypeOfViewExit (void);
|
||||
void Lay_WrongBannerExit (void);
|
||||
void Lay_WrongLinkExit (void);
|
||||
void Lay_WrongHolidayExit (void);
|
||||
void Lay_WrongBuildingExit (void);
|
||||
void Lay_WrongRoomExit (void);
|
||||
void Lay_WrongRecordFieldExit (void);
|
||||
void Lay_WrongAssignmentExit (void);
|
||||
void Lay_WrongProjectExit (void);
|
||||
void Lay_WrongCallForExamExit (void);
|
||||
void Lay_WrongTagExit (void);
|
||||
void Lay_WrongTestExit (void);
|
||||
void Lay_WrongExamExit (void);
|
||||
void Lay_WrongSetExit (void);
|
||||
void Lay_WrongQuestionExit (void);
|
||||
void Lay_WrongQuestionIndexExit (void);
|
||||
void Lay_WrongAnswerExit (void);
|
||||
void Lay_WrongAnswerIndexExit (void);
|
||||
void Lay_WrongExamSessionExit (void);
|
||||
void Lay_WrongGameExit (void);
|
||||
void Lay_WrongMatchExit (void);
|
||||
void Lay_WrongSurveyExit (void);
|
||||
void Lay_WrongWhoExit (void);
|
||||
void Lay_WrongEventExit (void);
|
||||
void Lay_WrongAnnouncementExit (void);
|
||||
void Lay_WrongNoticeExit (void);
|
||||
void Lay_WrongForumExit (void);
|
||||
void Lay_WrongPostExit (void);
|
||||
void Lay_WrongMessageExit (void);
|
||||
void Lay_WrongMailDomainExit (void);
|
||||
void Lay_WrongRoleExit (void);
|
||||
void Lay_WrongUserExit (void);
|
||||
void Lay_NoPermissionExit (void);
|
||||
void Lay_ShowErrorAndExit (const char *Txt);
|
||||
void Lay_WriteAboutZone (void);
|
||||
|
||||
void Lay_RefreshNotifsAndConnected (void);
|
||||
void Lay_RefreshLastClicks (void);
|
||||
|
|
15
swad_link.c
15
swad_link.c
|
@ -33,6 +33,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -307,7 +308,7 @@ void Lnk_GetListLinks (void)
|
|||
/***** Create list with places *****/
|
||||
if ((Gbl.Links.Lst = calloc ((size_t) Gbl.Links.Num,
|
||||
sizeof (*Gbl.Links.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the links *****/
|
||||
for (NumLnk = 0;
|
||||
|
@ -321,7 +322,7 @@ void Lnk_GetListLinks (void)
|
|||
|
||||
/* Get link code (row[0]) */
|
||||
if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongLinkExit ();
|
||||
Err_WrongLinkExit ();
|
||||
|
||||
/* Get the short name (row[0]), the full name (row[1])
|
||||
and de URL (row[2]) of the link */
|
||||
|
@ -494,7 +495,7 @@ void Lnk_RemoveLink (void)
|
|||
|
||||
/***** Get link code *****/
|
||||
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
||||
Lay_WrongLinkExit ();
|
||||
Err_WrongLinkExit ();
|
||||
|
||||
/***** Get data of the link from database *****/
|
||||
Lnk_GetDataOfLinkByCod (Lnk_EditingLnk);
|
||||
|
@ -571,7 +572,7 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the link */
|
||||
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
||||
Lay_WrongLinkExit ();
|
||||
Err_WrongLinkExit ();
|
||||
|
||||
/* Get the new name for the link */
|
||||
Par_GetParToText (ParamName,NewLnkName,MaxBytes);
|
||||
|
@ -660,7 +661,7 @@ void Lnk_ChangeLinkWWW (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the link */
|
||||
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
||||
Lay_WrongLinkExit ();
|
||||
Err_WrongLinkExit ();
|
||||
|
||||
/* Get the new WWW for the link */
|
||||
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
||||
|
@ -864,11 +865,11 @@ static void Lnk_EditingLinkConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Lnk_EditingLnk != NULL)
|
||||
Lay_WrongLinkExit ();
|
||||
Err_WrongLinkExit ();
|
||||
|
||||
/***** Allocate memory for link *****/
|
||||
if ((Lnk_EditingLnk = malloc (sizeof (*Lnk_EditingLnk))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset link *****/
|
||||
Lnk_EditingLnk->LnkCod = -1L;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -163,16 +164,16 @@ void Lgo_DrawLogo (Hie_Lvl_Level_t Scope,long Cod,const char *AltText,
|
|||
Cfg_URL_SWAD_PUBLIC,Folder,
|
||||
(unsigned) (Cod % 100),
|
||||
(unsigned) Cod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Icon,"%u.png",(unsigned) Cod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&URL,"%s",Cfg_URL_ICON_PUBLIC) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Icon,"%s",HieIcon[Scope]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
ClassNotEmpty = false;
|
||||
if (Class)
|
||||
|
|
21
swad_mail.c
21
swad_mail.c
|
@ -34,6 +34,7 @@
|
|||
#include "swad_account.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -312,7 +313,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
/***** Create list with places *****/
|
||||
if ((Gbl.Mails.Lst = calloc ((size_t) Gbl.Mails.Num,
|
||||
sizeof (*Gbl.Mails.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the mail domains *****/
|
||||
for (NumMai = 0;
|
||||
|
@ -326,7 +327,7 @@ static void Mai_GetListMailDomainsAllowedForNotif (void)
|
|||
|
||||
/* Get mail code (row[0]) */
|
||||
if ((Mai->MaiCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongMailDomainExit ();
|
||||
Err_WrongMailDomainExit ();
|
||||
|
||||
/* Get the mail domain (row[1]) and the mail domain info (row[2]) */
|
||||
Str_Copy (Mai->Domain,row[1],sizeof (Mai->Domain) - 1);
|
||||
|
@ -575,7 +576,7 @@ void Mai_RemoveMailDomain (void)
|
|||
|
||||
/***** Get mail code *****/
|
||||
if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) <= 0)
|
||||
Lay_WrongMailDomainExit ();
|
||||
Err_WrongMailDomainExit ();
|
||||
|
||||
/***** Get data of the mail from database *****/
|
||||
Mai_GetDataOfMailDomainByCod (Mai_EditingMai);
|
||||
|
@ -652,7 +653,7 @@ static void Mai_RenameMailDomain (Cns_ShrtOrFullName_t ShrtOrFullName)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the mail */
|
||||
if ((Mai_EditingMai->MaiCod = Mai_GetParamMaiCod ()) <= 0)
|
||||
Lay_WrongMailDomainExit ();
|
||||
Err_WrongMailDomainExit ();
|
||||
|
||||
/* Get the new name for the mail */
|
||||
Par_GetParToText (ParamName,NewMaiName,MaxBytes);
|
||||
|
@ -971,12 +972,12 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
|
|||
HTM_Txt (", ");
|
||||
LengthStrAddr ++;
|
||||
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
||||
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||
Err_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||
Str_Concat (StrAddresses,",",sizeof (StrAddresses) - 1);
|
||||
}
|
||||
LengthStrAddr += strlen (UsrDat.Email);
|
||||
if (LengthStrAddr > Mai_MAX_BYTES_STR_ADDR)
|
||||
Lay_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||
Err_ShowErrorAndExit ("The space allocated to store email addresses is full.");
|
||||
Str_Concat (StrAddresses,UsrDat.Email,sizeof (StrAddresses) - 1);
|
||||
HTM_A_Begin ("href=\"mailto:%s?subject=%s\"",
|
||||
UsrDat.Email,Gbl.Hierarchy.Crs.FullName);
|
||||
|
@ -1697,7 +1698,7 @@ bool Mai_SendMailMsgToConfirmEmail (void)
|
|||
FileNameMail);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running script to send email.");
|
||||
Err_ShowErrorAndExit ("Error when running script to send email.");
|
||||
|
||||
/***** Remove temporary file *****/
|
||||
unlink (FileNameMail);
|
||||
|
@ -1851,7 +1852,7 @@ void Mai_CreateFileNameMail (char FileNameMail[PATH_MAX + 1],FILE **FileMail)
|
|||
snprintf (FileNameMail,PATH_MAX + 1,"%s/%s_mail.txt",
|
||||
Cfg_PATH_OUT_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||
if ((*FileMail = fopen (FileNameMail,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open file to send email.");
|
||||
Err_ShowErrorAndExit ("Can not open file to send email.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1941,11 +1942,11 @@ static void Mai_EditingMailDomainConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Mai_EditingMai != NULL)
|
||||
Lay_WrongMailDomainExit ();
|
||||
Err_WrongMailDomainExit ();
|
||||
|
||||
/***** Allocate memory for mail domain *****/
|
||||
if ((Mai_EditingMai = malloc (sizeof (*Mai_EditingMai))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset place *****/
|
||||
Mai_EditingMai->MaiCod = -1L;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_connected.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_firewall.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
|
@ -149,7 +150,7 @@ int main (void)
|
|||
|
||||
/***** Check if the user have permission to execute the action *****/
|
||||
if (!Act_CheckIfIHavePermissionToExecuteAction (Gbl.Action.Act))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Update most frequently used actions *****/
|
||||
MFU_UpdateMFUActions ();
|
||||
|
@ -202,7 +203,7 @@ int main (void)
|
|||
}
|
||||
|
||||
/***** Cleanup and exit *****/
|
||||
Lay_ShowErrorAndExit (NULL);
|
||||
Err_ShowErrorAndExit (NULL);
|
||||
|
||||
return 0; // Control don't reach this point. Used to avoid warning.
|
||||
}
|
||||
|
|
21
swad_mark.c
21
swad_mark.c
|
@ -34,6 +34,7 @@
|
|||
#include <unistd.h> // For unlink
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -197,11 +198,11 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
|||
|
||||
/* Header (row[0]) */
|
||||
if (sscanf (row[0],"%u",&(Marks->Header)) != 1)
|
||||
Lay_WrongNumberOfRowsExit ();
|
||||
Err_WrongNumberOfRowsExit ();
|
||||
|
||||
/* Footer (row[1]) */
|
||||
if (sscanf (row[1],"%u",&(Marks->Footer)) != 1)
|
||||
Lay_WrongNumberOfRowsExit ();
|
||||
Err_WrongNumberOfRowsExit ();
|
||||
}
|
||||
else // Unknown numbers of header and footer rows
|
||||
Marks->Header =
|
||||
|
@ -268,7 +269,7 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter)
|
|||
NumRows);
|
||||
}
|
||||
else
|
||||
Lay_WrongNumberOfRowsExit ();
|
||||
Err_WrongNumberOfRowsExit ();
|
||||
|
||||
/***** Show again the file browser *****/
|
||||
Brw_ShowAgainFileBrowserOrWorks ();
|
||||
|
@ -648,14 +649,14 @@ void Mrk_ShowMyMarks (void)
|
|||
snprintf (FileNameUsrMarks,sizeof (FileNameUsrMarks),"%s/%s.html",
|
||||
Cfg_PATH_MARK_PRIVATE,Gbl.UniqueNameEncrypted);
|
||||
if ((FileUsrMarks = fopen (FileNameUsrMarks,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open file for my marks.");
|
||||
Err_ShowErrorAndExit ("Can not open file for my marks.");
|
||||
|
||||
/***** Show my marks *****/
|
||||
if (Mrk_GetUsrMarks (FileUsrMarks,UsrDat,PathPrivate,&Marks))
|
||||
{
|
||||
fclose (FileUsrMarks);
|
||||
if ((FileUsrMarks = fopen (FileNameUsrMarks,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open file with my marks.");
|
||||
Err_ShowErrorAndExit ("Can not open file with my marks.");
|
||||
|
||||
/* Start HTML output */
|
||||
/* Do not write charset here.
|
||||
|
@ -764,11 +765,11 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
/* Header (row[3]) */
|
||||
if (sscanf (row[3],"%u",&(Marks.Header)) != 1)
|
||||
Lay_WrongNumberOfRowsExit ();
|
||||
Err_WrongNumberOfRowsExit ();
|
||||
|
||||
/* Footer (row[4]) */
|
||||
if (sscanf (row[4],"%u",&(Marks.Footer)) != 1)
|
||||
Lay_WrongNumberOfRowsExit ();
|
||||
Err_WrongNumberOfRowsExit ();
|
||||
|
||||
if (UsrDat.IDs.Num)
|
||||
{
|
||||
|
@ -822,7 +823,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
fclose (FileUsrMarks);
|
||||
if (asprintf (ContentStr,"<![CDATA[%s]]>",
|
||||
Ale_GetTextOfLastAlert ()) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ale_ResetAllAlerts ();
|
||||
}
|
||||
}
|
||||
|
@ -830,7 +831,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
if (asprintf (ContentStr,"<![CDATA[%s]]>",
|
||||
"Can not open file of marks.") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
unlink (FileNameUsrMarks); // File with marks is no longer necessary
|
||||
}
|
||||
|
@ -838,7 +839,7 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
if (asprintf (ContentStr,"<![CDATA[%s]]>",
|
||||
"User's IDs not found!") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
71
swad_match.c
71
swad_match.c
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_game.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -317,11 +318,11 @@ void Mch_ListMatches (struct Gam_Games *Games,
|
|||
" WHERE grp_users.UsrCod=%ld"
|
||||
" AND grp_users.GrpCod=mch_groups.GrpCod))",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
if (asprintf (&SubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Make query */
|
||||
NumMatches = (unsigned)
|
||||
|
@ -513,7 +514,7 @@ static void Mch_ListOneOrMoreMatches (struct Gam_Games *Games,
|
|||
{
|
||||
/***** Build anchor string *****/
|
||||
if (asprintf (&Anchor,"mch_%ld",Match.MchCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** First row for this match with match data ****/
|
||||
/* Begin first row */
|
||||
|
@ -708,7 +709,7 @@ static void Mch_ListOneOrMoreMatchesTimes (const struct Mch_Match *Match,unsigne
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"mch_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
||||
Id,
|
||||
Match->Status.Showing == Mch_END ? "DATE_RED" :
|
||||
|
@ -886,7 +887,7 @@ static void Mch_ListOneOrMoreMatchesResult (struct Gam_Games *Games,
|
|||
Mch_ListOneOrMoreMatchesResultTch (Games,Match);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -972,7 +973,7 @@ void Mch_ToggleVisResultsMchUsr (void)
|
|||
|
||||
/***** Check if visibility of match results can be changed *****/
|
||||
if (!Mch_CheckIfVisibilityOfResultsCanBeChanged (&Match))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Toggle visibility of match results *****/
|
||||
Match.Status.ShowUsrResults = !Match.Status.ShowUsrResults;
|
||||
|
@ -1014,11 +1015,11 @@ static void Mch_GetMatchDataFromRow (MYSQL_RES *mysql_res,
|
|||
/***** Get match data *****/
|
||||
/* Code of the match (row[0]) */
|
||||
if ((Match->MchCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
|
||||
/* Code of the game (row[1]) */
|
||||
if ((Match->GamCod = Str_ConvertStrCodToLongCod (row[1])) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/* Get match teacher (row[2]) */
|
||||
Match->UsrCod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
@ -1151,7 +1152,7 @@ void Mch_RemoveMatch (void)
|
|||
|
||||
/***** Check if I can remove this match *****/
|
||||
if (!Mch_CheckIfICanEditThisMatch (&Match))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove the match from all database tables *****/
|
||||
Mch_RemoveMatchFromAllTables (Match.MchCod);
|
||||
|
@ -1355,7 +1356,7 @@ void Mch_EditMatch (void)
|
|||
|
||||
/***** Check if I can edit this match *****/
|
||||
if (!Mch_CheckIfICanEditThisMatch (&Match))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show current game *****/
|
||||
Gam_ShowOnlyOneGame (&Games,&Game,
|
||||
|
@ -1409,20 +1410,20 @@ void Mch_GetAndCheckParameters (struct Gam_Games *Games,
|
|||
/***** Get parameters *****/
|
||||
/* Get parameters of game */
|
||||
if ((Game->GamCod = Gam_GetParams (Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Grp_GetParamWhichGroups ();
|
||||
Gam_GetDataOfGameByCod (Game);
|
||||
|
||||
/* Get match code */
|
||||
if ((Match->MchCod = Mch_GetParamMchCod ()) <= 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
Mch_GetDataOfMatchByCod (Match);
|
||||
|
||||
/***** Ensure parameters are correct *****/
|
||||
if (Game->GamCod != Match->GamCod)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
if (Game->CrsCod != Gbl.Hierarchy.Crs.CrsCod)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/***** Initialize context *****/
|
||||
Games->GamCod = Game->GamCod;
|
||||
|
@ -1625,7 +1626,7 @@ void Mch_CreateNewMatch (void)
|
|||
/***** Get form parameters *****/
|
||||
/* Get match code */
|
||||
if ((GamCod = Gam_GetParamGameCod ()) < 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
|
||||
/* Get match title */
|
||||
Par_GetParToText ("Title",Title,Mch_MAX_BYTES_TITLE);
|
||||
|
@ -1662,7 +1663,7 @@ void Mch_ChangeMatch (void)
|
|||
|
||||
/***** Check if I can update this match *****/
|
||||
if (!Mch_CheckIfICanEditThisMatch (&Match))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get match title and groups *****/
|
||||
/* Get match title */
|
||||
|
@ -1725,7 +1726,7 @@ void Mch_ResumeMatch (void)
|
|||
|
||||
/***** Check if I have permission to resume match *****/
|
||||
if (!Mch_CheckIfICanEditThisMatch (&Match))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Update match status in database *****/
|
||||
Mch_UpdateMatchStatusInDB (&Match);
|
||||
|
@ -1830,17 +1831,17 @@ static void Mch_CreateIndexes (long GamCod,long MchCod)
|
|||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get question index (row[1]) */
|
||||
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) <= 0)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
QstInd = (unsigned) LongNum;
|
||||
|
||||
/* Get answer type (row[2]) */
|
||||
Question.Answer.Type = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[2]);
|
||||
if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/* Get shuffle (row[3]) */
|
||||
Question.Answer.Shuffle = (row[3][0] == 'Y');
|
||||
|
@ -1895,7 +1896,7 @@ static void Mch_ReorderAnswer (long MchCod,unsigned QstInd,
|
|||
|
||||
/* Get answer index (row[0]) */
|
||||
if ((LongNum = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongAnswerIndexExit ();
|
||||
Err_WrongAnswerIndexExit ();
|
||||
AnsInd = (unsigned) LongNum;
|
||||
snprintf (StrOneAnswer,sizeof (StrOneAnswer),"%u",AnsInd);
|
||||
|
||||
|
@ -1938,7 +1939,7 @@ void Mch_GetIndexes (long MchCod,unsigned QstInd,
|
|||
MchCod,
|
||||
QstInd);
|
||||
if (!StrIndexesOneQst[0])
|
||||
Lay_ShowErrorAndExit ("No indexes found for a question.");
|
||||
Err_ShowErrorAndExit ("No indexes found for a question.");
|
||||
|
||||
/***** Get indexes from string *****/
|
||||
TstPrn_GetIndexesFromStr (StrIndexesOneQst,Indexes);
|
||||
|
@ -2009,12 +2010,12 @@ static void Mch_UpdateMatchStatusInDB (const struct Mch_Match *Match)
|
|||
if (Match->Status.Playing) // Match is being played
|
||||
{
|
||||
if (asprintf (&MchSubQuery,"mch_matches.EndTime=NOW(),") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Match is paused, not being played
|
||||
{
|
||||
if (asprintf (&MchSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Update match status in database *****/
|
||||
|
@ -2482,7 +2483,7 @@ static void Mch_ShowMatchStatusForStd (struct Mch_Match *Match,Mch_Update_t Upda
|
|||
/***** Can I play this match? *****/
|
||||
ICanPlayThisMatchBasedOnGrps = Mch_CheckIfICanPlayThisMatchBasedOnGrps (Match);
|
||||
if (!ICanPlayThisMatchBasedOnGrps)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Get student's answer to this question
|
||||
(<0 ==> no answer) *****/
|
||||
|
@ -2811,7 +2812,7 @@ static void Mch_PutFormCountdown (struct Mch_Match *Match,long Seconds,const cha
|
|||
" return false;", // return false is necessary to not submit form
|
||||
Act_GetActCod (ActMchCntDwn),Gbl.Session.Id,
|
||||
Match->MchCod,Seconds) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Frm_BeginFormOnSubmit (ActUnk,OnSubmit);
|
||||
}
|
||||
|
||||
|
@ -3274,7 +3275,7 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match)
|
|||
/***** Show question *****/
|
||||
/* Check answer type */
|
||||
if (Question.Answer.Type != Tst_ANS_UNIQUE_CHOICE)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/* Begin container */
|
||||
HTM_DIV_Begin ("class=\"MCH_BOTTOM\""); // Bottom
|
||||
|
@ -3472,7 +3473,7 @@ static bool Mch_ShowQuestionAndAnswersStd (const struct Mch_Match *Match,
|
|||
Update == Mch_CHANGE_STATUS_BY_STUDENT ? " MCH_STD_ANSWER_SELECTED" :
|
||||
"",
|
||||
'A' + (char) NumOpt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_OnMouseDown_Begin (NULL,Class);
|
||||
HTM_TxtF ("%c",'a' + (char) NumOpt);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -3684,7 +3685,7 @@ static void Mch_DrawScoreRow (double Score,double MinScore,double MaxScore,
|
|||
/* Draw bar and write number of users for this score */
|
||||
HTM_TD_Begin ("class=\"MCH_SCO_NUM%s\"",Mch_GetClassBorder (NumRow));
|
||||
if (asprintf (&Icon,"score%u_1x1.png",Color) < 0) // Background
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,
|
||||
Str_BuildStringLongStr ((long) NumUsrs,
|
||||
NumUsrs == 1 ? Txt_ROLES_SINGUL_abc[Rol_STD][Usr_SEX_UNKNOWN] :
|
||||
|
@ -3728,7 +3729,7 @@ static unsigned Mch_GetParamNumOpt (void)
|
|||
|
||||
NumOpt = Par_GetParToLong ("NumOpt");
|
||||
if (NumOpt < 0)
|
||||
Lay_ShowErrorAndExit ("Wrong number of option.");
|
||||
Err_ShowErrorAndExit ("Wrong number of option.");
|
||||
|
||||
return (unsigned) NumOpt;
|
||||
}
|
||||
|
@ -3921,7 +3922,7 @@ void Mch_GetMatchBeingPlayed (void)
|
|||
|
||||
/***** Get match code ****/
|
||||
if ((MchCodBeingPlayed = Mch_GetParamMchCod ()) <= 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
|
||||
Mch_SetMchCodBeingPlayed (MchCodBeingPlayed);
|
||||
}
|
||||
|
@ -4145,11 +4146,11 @@ void Mch_GetQstAnsFromDB (long MchCod,long UsrCod,unsigned QstInd,
|
|||
|
||||
/***** Get number of option index (row[0]) *****/
|
||||
if (sscanf (row[0],"%d",&(UsrAnswer->NumOpt)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting student's answer to a match question.");
|
||||
Err_ShowErrorAndExit ("Error when getting student's answer to a match question.");
|
||||
|
||||
/***** Get answer index (row[1]) *****/
|
||||
if (sscanf (row[1],"%d",&(UsrAnswer->AnsInd)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting student's answer to a match question.");
|
||||
Err_ShowErrorAndExit ("Error when getting student's answer to a match question.");
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
|
@ -4314,11 +4315,11 @@ void Mch_GetMatchQuestionsFromDB (struct MchPrn_Print *Print)
|
|||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get question index (row[1]) */
|
||||
if ((LongNum = Str_ConvertStrCodToLongCod (row[1])) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
QstInd = (unsigned) LongNum;
|
||||
|
||||
/* Get indexes for this question (row[2]) */
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_action.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -169,7 +170,7 @@ void MchRes_ShowMyMchResultsInGam (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Game begin *****/
|
||||
|
@ -219,9 +220,9 @@ void MchRes_ShowMyMchResultsInMch (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
Mch_GetDataOfMatchByCod (&Match);
|
||||
|
||||
|
@ -373,7 +374,7 @@ void MchRes_ShowAllMchResultsInGam (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
|
||||
/***** Game begin *****/
|
||||
|
@ -462,9 +463,9 @@ void MchRes_ShowAllMchResultsInMch (void)
|
|||
|
||||
/***** Get parameters *****/
|
||||
if ((Game.GamCod = Gam_GetParams (&Games)) <= 0)
|
||||
Lay_WrongGameExit ();
|
||||
Err_WrongGameExit ();
|
||||
if ((Match.MchCod = Mch_GetParamMchCod ()) <= 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
Gam_GetDataOfGameByCod (&Game);
|
||||
Mch_GetDataOfMatchByCod (&Match);
|
||||
|
||||
|
@ -734,7 +735,7 @@ static void MchRes_BuildGamesSelectedCommas (struct Gam_Games *Games,
|
|||
/***** Allocate memory for subquery of games selected *****/
|
||||
MaxLength = (size_t) Games->NumSelected * (Cns_MAX_DECIMAL_DIGITS_LONG + 1);
|
||||
if ((*GamesSelectedCommas = malloc (MaxLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Build subquery with list of selected games *****/
|
||||
(*GamesSelectedCommas)[0] = '\0';
|
||||
|
@ -795,19 +796,19 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
if (MchCod > 0)
|
||||
{
|
||||
if (asprintf (&MchSubQuery," AND mch_results.MchCod=%ld",MchCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&MchSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Build games subquery *****/
|
||||
if (GamCod > 0)
|
||||
{
|
||||
if (asprintf (&GamSubQuery," AND mch_matches.GamCod=%ld",GamCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else if (GamesSelectedCommas)
|
||||
{
|
||||
|
@ -815,18 +816,18 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
{
|
||||
if (asprintf (&GamSubQuery," AND mch_matches.GamCod IN (%s)",
|
||||
GamesSelectedCommas) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&GamSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&GamSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/***** Subquery: get hidden games?
|
||||
|
@ -837,11 +838,11 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
{
|
||||
case Usr_ME: // A student watching her/his results
|
||||
if (asprintf (&HidGamSubQuery," AND gam_games.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default: // A teacher/admin watching the results of other users
|
||||
if (asprintf (&HidGamSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -883,7 +884,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
/* Get match code */
|
||||
MchPrn_ResetPrint (&Print);
|
||||
if ((Print.MchCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongMatchExit ();
|
||||
Err_WrongMatchExit ();
|
||||
|
||||
/* Get match result data */
|
||||
Print.UsrCod = UsrDat->UsrCod;
|
||||
|
@ -908,7 +909,7 @@ static void MchRes_ShowMchResults (struct Gam_Games *Games,
|
|||
{
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"mch_res_time_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id =\"%s\" class=\"DAT LT COLOR%u\"",
|
||||
Id,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime],
|
||||
|
@ -1213,9 +1214,9 @@ void MchRes_ShowOneMchResult (void)
|
|||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
Lay_WrongUserExit ();
|
||||
Err_WrongUserExit ();
|
||||
if (!Usr_CheckIfICanViewTstExaMchResult (UsrDat))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/* User */
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -1249,7 +1250,7 @@ void MchRes_ShowOneMchResult (void)
|
|||
HTM_TD_End ();
|
||||
|
||||
if (asprintf (&Id,"match_%u",(unsigned) StartEndTime) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"DAT LB\"",Id);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime],
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
@ -1355,7 +1356,7 @@ void MchRes_ShowOneMchResult (void)
|
|||
Box_BoxEnd ();
|
||||
}
|
||||
else // I am not allowed to view this match result
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
47
swad_media.c
47
swad_media.c
|
@ -40,6 +40,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_cookie.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_file.h"
|
||||
#include "swad_file_browser.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -308,7 +309,7 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
|||
Length = Cns_MAX_BYTES_WWW;
|
||||
|
||||
if ((Media->URL = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (Media->URL,row[2],Length);
|
||||
}
|
||||
|
||||
|
@ -324,12 +325,12 @@ void Med_GetMediaDataByCod (struct Med_Media *Media)
|
|||
Length = Med_MAX_BYTES_TITLE;
|
||||
|
||||
if ((Media->Title = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (Media->Title,row[3],Length);
|
||||
}
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Internal error in database when getting media data.");
|
||||
Err_ShowErrorAndExit ("Internal error in database when getting media data.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -496,7 +497,7 @@ static void Med_PutHiddenFormTypeMediaUploader (const char UniqueId[Frm_MAX_BYTE
|
|||
|
||||
/***** Hidden field with form type *****/
|
||||
if (asprintf (&Id,"%s_%s",UniqueId,MediaUploader->ParamSuffix) < 0) // <id>_ParamSuffix
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Par_PutHiddenParamUnsignedDisabled (Id,ParamUploadMedia->FormType,
|
||||
(unsigned) MediaUploader->FormType);
|
||||
free (Id);
|
||||
|
@ -662,7 +663,7 @@ static void Usr_GetURLFromForm (const char *ParamName,struct Med_Media *Media)
|
|||
with the URL coming from the form */
|
||||
Med_FreeMediaURL (Media);
|
||||
if ((Media->URL = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (Media->URL,URL,Length);
|
||||
}
|
||||
}
|
||||
|
@ -686,7 +687,7 @@ static void Usr_GetTitleFromForm (const char *ParamName,struct Med_Media *Media)
|
|||
with the title coming from the form */
|
||||
Med_FreeMediaTitle (Media);
|
||||
if ((Media->Title = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (Media->Title,Title,Length);
|
||||
}
|
||||
}
|
||||
|
@ -983,7 +984,7 @@ static int Med_ResizeImage (struct Med_Media *Media,
|
|||
PathFileProcessed);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running command to process media.");
|
||||
Err_ShowErrorAndExit ("Error when running command to process media.");
|
||||
|
||||
ReturnCode = WEXITSTATUS(ReturnCode);
|
||||
return ReturnCode;
|
||||
|
@ -1006,7 +1007,7 @@ static int Med_GetFirstFrame (const char PathFileOriginal[PATH_MAX + 1],
|
|||
PathFileProcessed);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running command to process media.");
|
||||
Err_ShowErrorAndExit ("Error when running command to process media.");
|
||||
|
||||
ReturnCode = WEXITSTATUS(ReturnCode);
|
||||
|
||||
|
@ -1501,7 +1502,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
|
|||
Media->Name,Med_Extensions[Med_JPG]);
|
||||
if (asprintf (&FullPathJPGPriv,"%s/%s",
|
||||
PathMedPriv,FileNameJPG) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Check if private media file exists *****/
|
||||
if (Fil_CheckIfPathExists (FullPathJPGPriv))
|
||||
|
@ -1524,7 +1525,7 @@ static void Med_ShowJPG (const struct Med_Media *Media,
|
|||
/***** Show media *****/
|
||||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_FILE_BROWSER_TMP_PUBLIC,TmpPubDir) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (URL,FileNameJPG,Media->Title,
|
||||
"class=\"%s\" lazyload=\"on\"",ClassMedia); // Lazy load of the media
|
||||
free (URL);
|
||||
|
@ -1559,13 +1560,13 @@ static void Med_ShowGIF (const struct Med_Media *Media,
|
|||
Media->Name,Med_Extensions[Med_GIF]);
|
||||
if (asprintf (&FullPathGIFPriv,"%s/%s", // The animated GIF image
|
||||
PathMedPriv,FileNameGIF) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Build private path to static PNG image *****/
|
||||
snprintf (FileNamePNG,sizeof (FileNamePNG),"%s.png",Media->Name);
|
||||
if (asprintf (&FullPathPNGPriv,"%s/%s",
|
||||
PathMedPriv,FileNamePNG) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Check if private media file exists *****/
|
||||
if (Fil_CheckIfPathExists (FullPathGIFPriv)) // The animated GIF image
|
||||
|
@ -1589,11 +1590,11 @@ static void Med_ShowGIF (const struct Med_Media *Media,
|
|||
/***** Create URLs pointing to symbolic links *****/
|
||||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_FILE_BROWSER_TMP_PUBLIC,TmpPubDir) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&URL_GIF,"%s/%s",URL,FileNameGIF) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&URL_PNG,"%s/%s",URL,FileNamePNG) < 0) // The static PNG image
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Check if private media file exists *****/
|
||||
if (Fil_CheckIfPathExists (FullPathPNGPriv)) // The static PNG image
|
||||
|
@ -1651,7 +1652,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
|
|||
Media->Name,Med_Extensions[Media->Type]);
|
||||
if (asprintf (&FullPathVideoPriv,"%s/%s",
|
||||
PathMedPriv,FileNameVideo) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Check if private media file exists *****/
|
||||
if (Fil_CheckIfPathExists (FullPathVideoPriv))
|
||||
|
@ -1674,7 +1675,7 @@ static void Med_ShowVideo (const struct Med_Media *Media,
|
|||
/***** Create URL pointing to symbolic link *****/
|
||||
if (asprintf (&URL,"%s/%s",
|
||||
Cfg_URL_FILE_BROWSER_TMP_PUBLIC,TmpPubDir) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Show media *****/
|
||||
HTM_TxtF ("<video src=\"%s/%s\""
|
||||
|
@ -1847,7 +1848,7 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
|||
if (Length > Cns_MAX_BYTES_WWW)
|
||||
Length = Cns_MAX_BYTES_WWW;
|
||||
if ((MediaDst.URL = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (MediaDst.URL,MediaSrc->URL,Length);
|
||||
}
|
||||
|
||||
|
@ -1860,7 +1861,7 @@ long Med_CloneMedia (const struct Med_Media *MediaSrc)
|
|||
if (Length > Cns_MAX_BYTES_WWW)
|
||||
Length = Cns_MAX_BYTES_WWW;
|
||||
if ((MediaDst.Title = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (MediaDst.Title,MediaSrc->Title,Length);
|
||||
}
|
||||
|
||||
|
@ -1994,7 +1995,7 @@ void Med_RemoveMedia (long MedCod)
|
|||
/***** Remove private JPG file *****/
|
||||
if (asprintf (&FullPathMediaPriv,"%s/%s.%s",
|
||||
PathMedPriv,Media.Name,Med_Extensions[Med_JPG]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
unlink (FullPathMediaPriv);
|
||||
free (FullPathMediaPriv);
|
||||
break;
|
||||
|
@ -2002,14 +2003,14 @@ void Med_RemoveMedia (long MedCod)
|
|||
/***** Remove private GIF file *****/
|
||||
if (asprintf (&FullPathMediaPriv,"%s/%s.%s",
|
||||
PathMedPriv,Media.Name,Med_Extensions[Med_GIF]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
unlink (FullPathMediaPriv);
|
||||
free (FullPathMediaPriv);
|
||||
|
||||
/***** Remove private PNG file *****/
|
||||
if (asprintf (&FullPathMediaPriv,"%s/%s.png",
|
||||
PathMedPriv,Media.Name) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
unlink (FullPathMediaPriv);
|
||||
free (FullPathMediaPriv);
|
||||
|
||||
|
@ -2020,7 +2021,7 @@ void Med_RemoveMedia (long MedCod)
|
|||
/***** Remove private video file *****/
|
||||
if (asprintf (&FullPathMediaPriv,"%s/%s.%s",
|
||||
PathMedPriv,Media.Name,Med_Extensions[Media.Type]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
unlink (FullPathMediaPriv);
|
||||
free (FullPathMediaPriv);
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_course.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_forum.h"
|
||||
|
@ -257,7 +258,7 @@ static void Msg_PutFormMsgUsrs (struct Msg_Messages *Messages,
|
|||
if ((Messages->Reply.IsReply = Par_GetParToBool ("IsReply")))
|
||||
/* Get original message code */
|
||||
if ((Messages->Reply.OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Get user's code of possible preselected recipient *****/
|
||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) // There is a preselected recipient
|
||||
|
@ -620,7 +621,7 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (struct Msg_Messages *Messag
|
|||
" FROM msg_content"
|
||||
" WHERE MsgCod=%ld",
|
||||
MsgCod) != 1)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -770,7 +771,7 @@ void Msg_RecMsgFromUsr (void)
|
|||
if ((IsReply = Par_GetParToBool ("IsReply")))
|
||||
/* Get original message code */
|
||||
if ((OriginalMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/* Get user's code of possible preselected recipient */
|
||||
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
||||
|
@ -1197,7 +1198,7 @@ void Msg_DelSntMsg (void)
|
|||
|
||||
/***** Get the code of the message to delete *****/
|
||||
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Delete the message *****/
|
||||
/* Delete the sent message */
|
||||
|
@ -1219,7 +1220,7 @@ void Msg_DelRecMsg (void)
|
|||
|
||||
/***** Get the code of the message to delete *****/
|
||||
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Delete the message *****/
|
||||
/* Delete the received message */
|
||||
|
@ -1243,7 +1244,7 @@ void Msg_ExpSntMsg (void)
|
|||
|
||||
/***** Get the code of the message to expand *****/
|
||||
if ((Messages.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Expand the message *****/
|
||||
Msg_ExpandSentMsg (Messages.ExpandedMsgCod);
|
||||
|
@ -1265,7 +1266,7 @@ void Msg_ExpRecMsg (void)
|
|||
|
||||
/***** Get the code of the message to expand *****/
|
||||
if ((Messages.ExpandedMsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Expand the message *****/
|
||||
Msg_ExpandReceivedMsg (Messages.ExpandedMsgCod);
|
||||
|
@ -1289,7 +1290,7 @@ void Msg_ConSntMsg (void)
|
|||
|
||||
/***** Get the code of the message to contract *****/
|
||||
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Contract the message *****/
|
||||
Msg_ContractSentMsg (MsgCod);
|
||||
|
@ -1308,7 +1309,7 @@ void Msg_ConRecMsg (void)
|
|||
|
||||
/***** Get the code of the message to contract *****/
|
||||
if ((MsgCod = Msg_GetParamMsgCod ()) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Contract the message *****/
|
||||
Msg_ContractReceivedMsg (MsgCod);
|
||||
|
@ -1481,7 +1482,7 @@ static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Mess
|
|||
NumMsg++)
|
||||
{
|
||||
if ((MsgCod = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
switch (Messages->TypeOfMessages)
|
||||
{
|
||||
|
@ -1777,7 +1778,7 @@ static unsigned Msg_GetNumUnreadMsgs (const struct Msg_Messages *Messages,
|
|||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Messages->FilterCrsCod,
|
||||
FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1790,7 +1791,7 @@ static unsigned Msg_GetNumUnreadMsgs (const struct Msg_Messages *Messages,
|
|||
" AND msg_snt.CrsCod=%ld",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Messages->FilterCrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
else // If no origin course selected
|
||||
|
@ -1805,7 +1806,7 @@ static unsigned Msg_GetNumUnreadMsgs (const struct Msg_Messages *Messages,
|
|||
" AND msg_snt.UsrCod=usr_data.UsrCod%s",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1814,7 +1815,7 @@ static unsigned Msg_GetNumUnreadMsgs (const struct Msg_Messages *Messages,
|
|||
" WHERE UsrCod=%ld"
|
||||
" AND Open='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2010,7 +2011,7 @@ static void Msg_ShowSentOrReceivedMessages (struct Msg_Messages *Messages)
|
|||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%ld",&MsgCod) != 1)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
if (MsgCod == Messages->ExpandedMsgCod) // Expanded message found
|
||||
{
|
||||
|
@ -2045,7 +2046,7 @@ static void Msg_ShowSentOrReceivedMessages (struct Msg_Messages *Messages)
|
|||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
if (sscanf (row[0],"%ld",&MsgCod) != 1)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
NumMsg = NumRows - NumRow + 1;
|
||||
Msg_ShowASentOrReceivedMessage (Messages,NumMsg,MsgCod);
|
||||
}
|
||||
|
@ -2133,7 +2134,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" AND msg_snt_deleted.UsrCod=usr_data.UsrCod%s)",
|
||||
UsrCod,StrUnreadMsg,Messages->FilterCrsCod,FilterFromToSubquery,
|
||||
UsrCod,StrUnreadMsg,Messages->FilterCrsCod,FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2154,7 +2155,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" AND msg_snt_deleted.CrsCod=%ld)",
|
||||
UsrCod,StrUnreadMsg,Messages->FilterCrsCod,
|
||||
UsrCod,StrUnreadMsg,Messages->FilterCrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
break;
|
||||
case Msg_SENT:
|
||||
|
@ -2181,7 +2182,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
"%s)",
|
||||
UsrCod,Messages->FilterCrsCod,FilterFromToSubquery,
|
||||
UsrCod,Messages->FilterCrsCod,FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2190,7 +2191,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" WHERE UsrCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
UsrCod,Messages->FilterCrsCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
break;
|
||||
default: // Not aplicable here
|
||||
|
@ -2225,7 +2226,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
"%s)",
|
||||
UsrCod,StrUnreadMsg,FilterFromToSubquery,
|
||||
UsrCod,StrUnreadMsg,FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2236,7 +2237,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" WHERE UsrCod=%ld"
|
||||
"%s",
|
||||
UsrCod,StrUnreadMsg) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
break;
|
||||
case Msg_SENT:
|
||||
|
@ -2259,7 +2260,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" AND msg_rcv_deleted.UsrCod=usr_data.UsrCod%s)",
|
||||
UsrCod,FilterFromToSubquery,
|
||||
UsrCod,FilterFromToSubquery) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2267,7 +2268,7 @@ static unsigned Msg_GetSentOrReceivedMsgs (const struct Msg_Messages *Messages,
|
|||
" FROM msg_snt"
|
||||
" WHERE UsrCod=%ld",
|
||||
UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
break;
|
||||
default: // Not aplicable here
|
||||
|
@ -2720,12 +2721,12 @@ static void Msg_SetNumMsgsStr (const struct Msg_Messages *Messages,
|
|||
{
|
||||
if (asprintf (NumMsgsStr,"1 %s, 1 %s",
|
||||
Txt_message_received,Txt_unread_MESSAGE) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (NumMsgsStr,"1 %s",Txt_message_received) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2734,21 +2735,21 @@ static void Msg_SetNumMsgsStr (const struct Msg_Messages *Messages,
|
|||
{
|
||||
if (asprintf (NumMsgsStr,"%u %s",
|
||||
Messages->NumMsgs,Txt_messages_received) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else if (NumUnreadMsgs == 1)
|
||||
{
|
||||
if (asprintf (NumMsgsStr,"%u %s, 1 %s",
|
||||
Messages->NumMsgs,Txt_messages_received,
|
||||
Txt_unread_MESSAGE) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (NumMsgsStr,"%u %s, %u %s",
|
||||
Messages->NumMsgs,Txt_messages_received,
|
||||
NumUnreadMsgs,Txt_unread_MESSAGES) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2756,13 +2757,13 @@ static void Msg_SetNumMsgsStr (const struct Msg_Messages *Messages,
|
|||
if (Messages->NumMsgs == 1)
|
||||
{
|
||||
if (asprintf (NumMsgsStr,"1 %s",Txt_message_sent) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (NumMsgsStr,"%u %s",
|
||||
Messages->NumMsgs,Txt_messages_sent) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -3105,7 +3106,7 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod,
|
|||
|
||||
/* Result should have a unique row */
|
||||
if (NumRows != 1)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/* Get number of rows */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3158,7 +3159,7 @@ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT
|
|||
" FROM msg_content"
|
||||
" WHERE MsgCod=%ld",
|
||||
MsgCod) != 1)
|
||||
Lay_WrongMessageExit ();
|
||||
Err_WrongMessageExit ();
|
||||
|
||||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3216,7 +3217,7 @@ static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,boo
|
|||
" AND UsrCod=%ld",
|
||||
MsgCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting if a received message has been replied/expanded.");
|
||||
Err_ShowErrorAndExit ("Error when getting if a received message has been replied/expanded.");
|
||||
|
||||
/***** Get number of rows *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -3461,7 +3462,7 @@ void Msg_GetNotifMessage (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
Length = strlen (row[1]);
|
||||
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*ContentStr,row[1],Length);
|
||||
}
|
||||
}
|
||||
|
@ -3949,7 +3950,7 @@ void Msg_WriteMsgDate (time_t TimeUTC,const char *ClassBackground)
|
|||
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"msg_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Start cell *****/
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s RT\" style=\"width:106px;\"",
|
||||
|
@ -4053,7 +4054,7 @@ void Msg_BanSenderWhenShowingMsgs (void)
|
|||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
Lay_WrongUserExit ();
|
||||
Err_WrongUserExit ();
|
||||
|
||||
/***** Insert pair (sender's code - my code) in table of banned senders if not inserted *****/
|
||||
DB_QueryREPLACE ("can not ban sender",
|
||||
|
@ -4113,7 +4114,7 @@ static void Msg_UnbanSender (void)
|
|||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
Lay_WrongUserExit ();
|
||||
Err_WrongUserExit ();
|
||||
|
||||
/***** Remove pair (sender's code - my code) from table of banned senders *****/
|
||||
DB_QueryDELETE ("can not ban sender",
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -534,7 +535,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -571,7 +572,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
|||
{
|
||||
/* Get number of users (row[1]) */
|
||||
if (sscanf (row[1],"%u",&NumUsrs) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of files.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of files.");
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -447,7 +448,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,long HighlightNotCod)
|
|||
|
||||
/* Get notice code (row[0]) */
|
||||
if (sscanf (row[0],"%ld",&NotCod) != 1)
|
||||
Lay_WrongNoticeExit ();
|
||||
Err_WrongNoticeExit ();
|
||||
|
||||
/* Get creation time (row[1] holds the UTC date-time) */
|
||||
TimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
||||
|
@ -720,7 +721,7 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing,
|
|||
HTM_BUTTON_SUBMIT_Begin (Txt_See_full_notice,"BT_LINK RT",NULL);
|
||||
}
|
||||
if (asprintf (&Id,"not_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_SPAN_Begin ("id=\"%s\"",Id);
|
||||
HTM_SPAN_End ();
|
||||
if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES)
|
||||
|
@ -825,7 +826,7 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
Length = strlen (row[0]);
|
||||
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*ContentStr,row[0],Length);
|
||||
}
|
||||
}
|
||||
|
@ -928,20 +929,20 @@ unsigned Not_GetNumNotices (Hie_Lvl_Level_t Scope,Not_Status_t Status,unsigned *
|
|||
Status);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notices.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notices.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications of notices.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of notices.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
|
@ -1034,20 +1035,20 @@ unsigned Not_GetNumNoticesDeleted (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of notices *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumNotices) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of deleted notices.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of deleted notices.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of deleted notices.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -455,7 +456,7 @@ void Ntf_ShowMyNotifications (void)
|
|||
|
||||
/* Get status (row[8]) */
|
||||
if (sscanf (row[8],"%u",&Status) != 1)
|
||||
Lay_WrongStatusExit ();
|
||||
Err_WrongStatusExit ();
|
||||
StatusTxt = Ntf_GetStatusTxtFromStatusBits (Status);
|
||||
|
||||
if (Status & Ntf_STATUS_BIT_REMOVED) // The source of the notification was removed
|
||||
|
@ -1851,7 +1852,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
|
|||
FileNameMail);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running script to send email.");
|
||||
Err_ShowErrorAndExit ("Error when running script to send email.");
|
||||
|
||||
/***** Remove temporary file *****/
|
||||
unlink (FileNameMail);
|
||||
|
@ -1928,9 +1929,9 @@ static void Ntf_GetNumNotifSent (long DegCod,long CrsCod,
|
|||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",NumEvents) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
|
||||
if (sscanf (row[1],"%u",NumMails) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications sent by email.");
|
||||
}
|
||||
else
|
||||
*NumEvents = *NumMails = 0;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_agenda.h"
|
||||
#include "swad_attendance.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_forum.h"
|
||||
|
@ -269,9 +270,9 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
break;
|
||||
}
|
||||
if (asprintf (&ClassLink,"BT_LINK LT %s",ClassTxt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
|
||||
free (Title);
|
||||
free (ClassLink);
|
||||
|
@ -296,7 +297,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
if (Pagination->MoreThanOnePage)
|
||||
{
|
||||
if (asprintf (&ClassLink,"BT_LINK PAG %s",ClassTxt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Possible link to page 1 *****/
|
||||
if (Pagination->StartPage > 1)
|
||||
|
@ -396,7 +397,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
break;
|
||||
}
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,1,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
|
||||
HTM_Unsigned (1);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -510,7 +511,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
}
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,
|
||||
Pagination->LeftPage,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
|
||||
HTM_Unsigned (Pagination->LeftPage);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -530,7 +531,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
NumPage++)
|
||||
{
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,NumPage,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (!LinkToPagCurrent && NumPage == Pagination->CurrentPage)
|
||||
{
|
||||
HTM_SPAN_Begin ("title=\"%s\" class=\"PAG_CUR %s\"",Title,ClassTxt);
|
||||
|
@ -747,7 +748,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
}
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,
|
||||
Pagination->RightPage,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
|
||||
HTM_Unsigned (Pagination->RightPage);
|
||||
HTM_BUTTON_End ();
|
||||
|
@ -860,7 +861,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
|||
}
|
||||
if (asprintf (&Title,Txt_Page_X_of_Y,
|
||||
Pagination->NumPags,Pagination->NumPags) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,ClassLink,NULL);
|
||||
HTM_Unsigned (Pagination->NumPags);
|
||||
HTM_BUTTON_End ();
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_parameter.h"
|
||||
|
@ -179,7 +180,7 @@ static void Par_GetBoundary (void)
|
|||
|
||||
/***** Check that boundary string is not too long *****/
|
||||
if (2 + 2 + strlen (PtrToBoundary) > Par_MAX_BYTES_BOUNDARY_WITH_CR_LF)
|
||||
Lay_ShowErrorAndExit ("Delimiter string too long.");
|
||||
Err_ShowErrorAndExit ("Delimiter string too long.");
|
||||
|
||||
/***** Create boundary strings *****/
|
||||
snprintf (Gbl.Boundary.StrWithoutCRLF,sizeof (Gbl.Boundary.StrWithoutCRLF),
|
||||
|
@ -258,7 +259,7 @@ static void Par_CreateListOfParamsFromQueryString (void)
|
|||
{
|
||||
/* Allocate space for a new parameter initialized to 0 */
|
||||
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Link the previous element in list with the current element */
|
||||
if (CurPos == 0)
|
||||
|
@ -334,7 +335,7 @@ static void Par_CreateListOfParamsFromTmpFile (void)
|
|||
{
|
||||
/* Allocate space for a new parameter initialized to 0 */
|
||||
if ((NewParam = calloc (1,sizeof (*NewParam))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Link the previous element in list with the current element */
|
||||
if (CurPos == 0)
|
||||
|
@ -565,7 +566,7 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
|
|||
"Multiple parameter <strong>%s</strong> too large,"
|
||||
" it exceed the maximum allowed size (%lu bytes).",
|
||||
ParamName,(unsigned long) MaxBytes);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
|
||||
/* Copy separator */
|
||||
|
@ -584,7 +585,7 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
|
|||
"Parameter <strong>%s</strong> too large,"
|
||||
" it exceed the maximum allowed size (%lu bytes).",
|
||||
ParamName,(unsigned long) MaxBytes);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
|
||||
/* Copy parameter value */
|
||||
|
@ -602,7 +603,7 @@ unsigned Par_GetParameter (tParamType ParamType,const char *ParamName,
|
|||
fseek (Gbl.F.Tmp,Param->Value.Start,SEEK_SET);
|
||||
if (fread (PtrDst,sizeof (char),Param->Value.Length,Gbl.F.Tmp) !=
|
||||
Param->Value.Length)
|
||||
Lay_ShowErrorAndExit ("Error while getting value of parameter.");
|
||||
Err_ShowErrorAndExit ("Error while getting value of parameter.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -382,14 +383,14 @@ void Pwd_ChkIdLoginAndSendNewPwd (void)
|
|||
Pwd_SetMyPendingPassword (NewRandomPlainPassword);
|
||||
break;
|
||||
case 1:
|
||||
Lay_ShowErrorAndExit (Txt_There_was_a_problem_sending_an_email_automatically);
|
||||
Err_ShowErrorAndExit (Txt_There_was_a_problem_sending_an_email_automatically);
|
||||
break;
|
||||
default:
|
||||
snprintf (ErrorTxt,sizeof (ErrorTxt),
|
||||
"Internal error: an email message has not been sent successfully."
|
||||
" Error code returned by the script: %d",
|
||||
ReturnCode);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -457,7 +458,7 @@ int Pwd_SendNewPasswordByEmail (char NewRandomPlainPassword[Pwd_MAX_BYTES_PLAIN_
|
|||
FileNameMail);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running script to send email.");
|
||||
Err_ShowErrorAndExit ("Error when running script to send email.");
|
||||
|
||||
/***** Remove temporary file *****/
|
||||
unlink (FileNameMail);
|
||||
|
@ -578,7 +579,7 @@ static unsigned Pwd_GetNumOtherUsrsWhoUseThisPassword (const char *EncryptedPass
|
|||
if (UsrCod > 0)
|
||||
{
|
||||
if (asprintf (&SubQuery," AND UsrCod<>%ld",UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
SubQuery = "";
|
||||
|
|
27
swad_photo.c
27
swad_photo.c
|
@ -40,6 +40,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_file.h"
|
||||
#include "swad_file_browser.h"
|
||||
#include "swad_follow.h"
|
||||
|
@ -671,7 +672,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
|||
FileNamePhotoTmp);
|
||||
ReturnCode = system (Command);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running command to process photo and detect faces.");
|
||||
Err_ShowErrorAndExit ("Error when running command to process photo and detect faces.");
|
||||
|
||||
/***** Write message depending on return code *****/
|
||||
ReturnCode = WEXITSTATUS(ReturnCode);
|
||||
|
@ -682,7 +683,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
|||
snprintf (FileNameTxtMap,sizeof (FileNameTxtMap),"%s/%s_map.txt",
|
||||
Cfg_PATH_PHOTO_TMP_PUBLIC,Gbl.UniqueNameEncrypted);
|
||||
if ((FileTxtMap = fopen (FileNameTxtMap,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
|
||||
Err_ShowErrorAndExit ("Can not read text file with coordinates of detected faces.");
|
||||
|
||||
/***** Read file with coordinates for image map and compute the number of faces *****/
|
||||
NumLastForm = Gbl.Form.Num;
|
||||
|
@ -730,7 +731,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
|||
"Photo could not be processed successfully.<br />"
|
||||
"Error code returned by the program of processing: %d",
|
||||
ReturnCode);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -906,7 +907,7 @@ static void Pho_UpdatePhoto2 (void)
|
|||
{
|
||||
HTM_TD_Begin ("class=\"DAT CT\" style=\"width:33%%;\"");
|
||||
if (asprintf (&Img,"%s_paso%u.jpg",Gbl.Usrs.FileNamePhoto,NumPhoto + 1) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (Cfg_URL_PHOTO_TMP_PUBLIC,Img,Txt_PHOTO_PROCESSING_CAPTIONS[NumPhoto],
|
||||
"style=\"width:%upx;height:%upx;\"",
|
||||
Pho_PHOTO_REAL_WIDTH,Pho_PHOTO_REAL_HEIGHT);
|
||||
|
@ -1048,7 +1049,7 @@ bool Pho_BuildLinkToPhoto (const struct UsrData *UsrDat,char PhotoURL[PATH_MAX +
|
|||
/***** Create a symbolic link to the private photo, if not exists *****/
|
||||
if (!Fil_CheckIfPathExists (PathPublPhoto))
|
||||
if (symlink (PathPrivPhoto,PathPublPhoto) != 0)
|
||||
Lay_ShowErrorAndExit ("Can not create public link"
|
||||
Err_ShowErrorAndExit ("Can not create public link"
|
||||
" to access to user's private photo");
|
||||
|
||||
/***** Create the public URL of the photo *****/
|
||||
|
@ -1387,7 +1388,7 @@ void Pho_CalcPhotoDegree (void)
|
|||
/***** Prevent the computing of an average photo too recently updated *****/
|
||||
if (Pho_GetTimeAvgPhotoWasComputed (DegCod) >=
|
||||
Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO)
|
||||
Lay_ShowErrorAndExit ("Average photo has been computed recently.");
|
||||
Err_ShowErrorAndExit ("Average photo has been computed recently.");
|
||||
|
||||
/***** Get list of students in this degree *****/
|
||||
Usr_GetUnorderedStdsCodesInDeg (DegCod);
|
||||
|
@ -1590,7 +1591,7 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
|
|||
/***** Build name for file with average photo *****/
|
||||
if (asprintf (&PathRelAvgPhoto,"%s/%ld_%s.jpg",
|
||||
DirAvgPhotosRelPath,DegCod,Usr_StringsSexDB[Sex]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Remove old file if exists *****/
|
||||
if (Fil_CheckIfPathExists (PathRelAvgPhoto)) // If file exists
|
||||
|
@ -1599,9 +1600,9 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
|
|||
/***** Build names for text file with photo paths *****/
|
||||
if (asprintf (&FileNamePhotoNames,"%s/%ld.txt",
|
||||
Cfg_PATH_PHOTO_TMP_PRIVATE,DegCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if ((FilePhotoNames = fopen (FileNamePhotoNames,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open file to compute average photo.");
|
||||
Err_ShowErrorAndExit ("Can not open file to compute average photo.");
|
||||
|
||||
/***** Loop writing file names in text file *****/
|
||||
for (NumUsr = 0;
|
||||
|
@ -1632,11 +1633,11 @@ static void Pho_ComputeAveragePhoto (long DegCod,Usr_Sex_t Sex,Rol_Role_t Role,
|
|||
FileNamePhotoNames,PathRelAvgPhoto);
|
||||
ReturnCode = system (StrCallToProgram);
|
||||
if (ReturnCode == -1)
|
||||
Lay_ShowErrorAndExit ("Error when running program that computes the average photo.");
|
||||
Err_ShowErrorAndExit ("Error when running program that computes the average photo.");
|
||||
|
||||
/* Write message depending on the return code */
|
||||
if (WEXITSTATUS(ReturnCode))
|
||||
Lay_ShowErrorAndExit ("The average photo has not been computed successfully.");
|
||||
Err_ShowErrorAndExit ("The average photo has not been computed successfully.");
|
||||
}
|
||||
|
||||
free (PathRelAvgPhoto);
|
||||
|
@ -2135,7 +2136,7 @@ static void Pho_ShowOrPrintClassPhotoDegrees (struct Pho_DegPhotos *DegPhotos,
|
|||
{
|
||||
/***** Get next degree *****/
|
||||
if ((Deg.DegCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/* Get data of degree */
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
@ -2232,7 +2233,7 @@ static void Pho_ShowOrPrintListDegrees (struct Pho_DegPhotos *DegPhotos,
|
|||
|
||||
/* Get degree code (row[0]) */
|
||||
if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongDegreeExit ();
|
||||
Err_WrongDegreeExit ();
|
||||
|
||||
/* Get data of degree */
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
|
13
swad_place.c
13
swad_place.c
|
@ -32,6 +32,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -399,7 +400,7 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
|
|||
/***** Create list with courses in center *****/
|
||||
if ((Places->Lst = calloc ((size_t) Places->Num,
|
||||
sizeof (*Places->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the places *****/
|
||||
for (NumPlc = 0;
|
||||
|
@ -413,7 +414,7 @@ void Plc_GetListPlaces (struct Plc_Places *Places)
|
|||
|
||||
/* Get place code (row[0]) */
|
||||
if ((Plc->PlcCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongPlaceExit ();
|
||||
Err_WrongPlaceExit ();
|
||||
|
||||
/* Get the short (row[1]) and full (row[2]) names of the place */
|
||||
Str_Copy (Plc->ShrtName,row[1],sizeof (Plc->ShrtName) - 1);
|
||||
|
@ -616,7 +617,7 @@ void Plc_RemovePlace (void)
|
|||
|
||||
/***** Get place code *****/
|
||||
if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0)
|
||||
Lay_WrongPlaceExit ();
|
||||
Err_WrongPlaceExit ();
|
||||
|
||||
/***** Get data of the place from database *****/
|
||||
Plc_GetDataOfPlaceByCod (Plc_EditingPlc);
|
||||
|
@ -700,7 +701,7 @@ static void Plc_RenamePlace (Cns_ShrtOrFullName_t ShrtOrFullName)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the place */
|
||||
if ((Plc_EditingPlc->PlcCod = Plc_GetParamPlcCod ()) <= 0)
|
||||
Lay_WrongPlaceExit ();
|
||||
Err_WrongPlaceExit ();
|
||||
|
||||
/* Get the new name for the place */
|
||||
Par_GetParToText (ParamName,NewPlcName,MaxBytes);
|
||||
|
@ -941,11 +942,11 @@ static void Plc_EditingPlaceConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Plc_EditingPlc != NULL)
|
||||
Lay_WrongPlaceExit ();
|
||||
Err_WrongPlaceExit ();
|
||||
|
||||
/***** Allocate memory for place *****/
|
||||
if ((Plc_EditingPlc = malloc (sizeof (*Plc_EditingPlc))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset place *****/
|
||||
Plc_EditingPlc->PlcCod = -1L;
|
||||
|
|
|
@ -39,6 +39,7 @@ TODO: Check if web service is called from an authorized IP.
|
|||
#include "swad_constant.h"
|
||||
#include "swad_cryptography.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -247,7 +248,7 @@ static void Plg_GetListPlugins (void)
|
|||
/***** Create list with plugins *****/
|
||||
if ((Gbl.Plugins.Lst = calloc ((size_t) Gbl.Plugins.Num,
|
||||
sizeof (*Gbl.Plugins.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the plugins *****/
|
||||
for (NumPlg = 0;
|
||||
|
@ -261,7 +262,7 @@ static void Plg_GetListPlugins (void)
|
|||
|
||||
/* Get plugin code (row[0]) */
|
||||
if ((Plg->PlgCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get name (row[1]), description (row[2), logo (row[3]),
|
||||
* application key (row[4]), URL (row[5]) and IP (row[6]) of the plugin */
|
||||
|
@ -493,7 +494,7 @@ void Plg_RemovePlugin (void)
|
|||
|
||||
/***** Get plugin code *****/
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/***** Get data of the plugin from database *****/
|
||||
Plg_GetDataOfPluginByCod (Plg_EditingPlg);
|
||||
|
@ -527,7 +528,7 @@ void Plg_RenamePlugin (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new name for the plugin */
|
||||
Par_GetParToText ("Name",NewPlgName,Plg_MAX_BYTES_PLUGIN_NAME);
|
||||
|
@ -606,7 +607,7 @@ void Plg_ChangePlgDescription (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new description for the plugin */
|
||||
Par_GetParToText ("Description",NewDescription,Plg_MAX_BYTES_PLUGIN_DESCRIPTION);
|
||||
|
@ -653,7 +654,7 @@ void Plg_ChangePlgLogo (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new logo for the plugin */
|
||||
Par_GetParToText ("Logo",NewLogo,Plg_MAX_BYTES_PLUGIN_LOGO);
|
||||
|
@ -699,7 +700,7 @@ void Plg_ChangePlgAppKey (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new logo for the plugin */
|
||||
Par_GetParToText ("AppKey",NewAppKey,Plg_MAX_BYTES_PLUGIN_APP_KEY);
|
||||
|
@ -745,7 +746,7 @@ void Plg_ChangePlgURL (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new URL for the plugin */
|
||||
Par_GetParToText ("URL",NewURL,Cns_MAX_BYTES_WWW);
|
||||
|
@ -791,7 +792,7 @@ void Plg_ChangePlgIP (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get the code of the plugin */
|
||||
if ((Plg_EditingPlg->PlgCod = Plg_GetParamPlgCod ()) <= 0)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/* Get the new IP for the plugin */
|
||||
Par_GetParToText ("IP",NewIP,Cns_MAX_BYTES_IP);
|
||||
|
@ -1047,11 +1048,11 @@ static void Plg_EditingPluginConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Plg_EditingPlg != NULL)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
|
||||
/***** Allocate memory for plugin *****/
|
||||
if ((Plg_EditingPlg = malloc (sizeof (*Plg_EditingPlg))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset plugin *****/
|
||||
Plg_EditingPlg->PlgCod = -1L;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -976,7 +977,7 @@ static void Prf_ShowRanking (unsigned Rank,unsigned NumUsrs)
|
|||
Par_PutHiddenParamUnsigned (NULL,"FigureType",(unsigned) Fig_USERS_RANKING);
|
||||
if (asprintf (&Title,"#%u %s %u",
|
||||
Rank,Txt_of_PART_OF_A_TOTAL,NumUsrs) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_BUTTON_SUBMIT_Begin (Title,The_ClassFormLinkOutBox[Gbl.Prefs.Theme],NULL);
|
||||
free (Title);
|
||||
HTM_TxtF ("#%u",Rank);
|
||||
|
@ -1605,7 +1606,7 @@ static void Prf_GetAndShowRankingFigure (const char *FieldName)
|
|||
FieldName,FieldName);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1645,7 +1646,7 @@ void Prf_ShowRankingFigure (MYSQL_RES **mysql_res,unsigned NumUsrs)
|
|||
|
||||
/* Get figure (row[1]) */
|
||||
if (sscanf (row[1],"%ld",&Figure) != 1)
|
||||
Lay_ShowErrorAndExit ("Error reading user's figure.");
|
||||
Err_ShowErrorAndExit ("Error reading user's figure.");
|
||||
|
||||
if (Figure < FigureHigh)
|
||||
{
|
||||
|
@ -1834,7 +1835,7 @@ void Prf_GetAndShowRankingClicksPerDay (void)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -495,7 +496,7 @@ static void Prg_WriteRowItem (unsigned NumItem,struct ProgramItem *Item,
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"scd_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (PrintView)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"PRG_DATE %s LT\"",
|
||||
Id,
|
||||
|
@ -602,7 +603,7 @@ static void Prg_SetTitleClass (char **TitleClass,unsigned Level,bool LightStyle)
|
|||
5,
|
||||
LightStyle ? "PRG_HIDDEN" :
|
||||
"") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
static void Prg_FreeTitleClass (char *TitleClass)
|
||||
|
@ -668,7 +669,7 @@ static void Prg_CreateLevels (void)
|
|||
*/
|
||||
if ((Prg_Gbl.Levels = calloc (1 + MaxLevel + 1,
|
||||
sizeof (*Prg_Gbl.Levels))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
Prg_Gbl.Levels = NULL;
|
||||
|
@ -993,7 +994,7 @@ static void Prg_GetListItems (void)
|
|||
/***** Create list of program items *****/
|
||||
if ((Prg_Gbl.List.Items = calloc (Prg_Gbl.List.NumItems,
|
||||
sizeof (*Prg_Gbl.List.Items))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the program items codes *****/
|
||||
for (NumItem = 0;
|
||||
|
@ -1005,7 +1006,7 @@ static void Prg_GetListItems (void)
|
|||
|
||||
/* Get code of the program item (row[0]) */
|
||||
if ((Prg_Gbl.List.Items[NumItem].ItmCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/* Get index of the program item (row[1]) */
|
||||
Prg_Gbl.List.Items[NumItem].Index = Str_ConvertStrToUnsigned (row[1]);
|
||||
|
@ -1201,7 +1202,7 @@ static unsigned Prg_GetNumItemFromItmCod (long ItmCod)
|
|||
|
||||
/***** List of items must be filled *****/
|
||||
if (!Prg_Gbl.List.IsRead || Prg_Gbl.List.Items == NULL)
|
||||
Lay_WrongItemsListExit ();
|
||||
Err_WrongItemsListExit ();
|
||||
|
||||
/***** Find item code in list *****/
|
||||
for (NumItem = 0;
|
||||
|
@ -1211,7 +1212,7 @@ static unsigned Prg_GetNumItemFromItmCod (long ItmCod)
|
|||
return NumItem;
|
||||
|
||||
/***** Not found *****/
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
return 0; // Not reached
|
||||
}
|
||||
|
||||
|
@ -1233,7 +1234,7 @@ void Prg_ReqRemItem (void)
|
|||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&Item);
|
||||
if (Item.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Show question and button to remove the program item *****/
|
||||
Ale_ShowAlertAndButton (ActRemPrgItm,NULL,NULL,
|
||||
|
@ -1269,7 +1270,7 @@ void Prg_RemoveItem (void)
|
|||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&Item);
|
||||
if (Item.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Indexes of items *****/
|
||||
Prg_SetItemRangeWithAllChildren (Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod),
|
||||
|
@ -1326,7 +1327,7 @@ static void Prg_HideUnhideItem (char YN)
|
|||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&Item);
|
||||
if (Item.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Hide/unhide program item *****/
|
||||
DB_QueryUPDATE ("can not change program item",
|
||||
|
@ -1381,7 +1382,7 @@ static void Prg_MoveUpDownItem (Prg_MoveUpDown_t UpDown)
|
|||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&Item);
|
||||
if (Item.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Move up/down item *****/
|
||||
NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod);
|
||||
|
@ -1615,7 +1616,7 @@ static void Prg_MoveLeftRightItem (Prg_MoveLeftRight_t LeftRight)
|
|||
Item.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&Item);
|
||||
if (Item.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Move up/down item *****/
|
||||
NumItem = Prg_GetNumItemFromItmCod (Item.Hierarchy.ItmCod);
|
||||
|
@ -1663,7 +1664,7 @@ static void Prg_SetItemRangeEmpty (struct ItemRange *ItemRange)
|
|||
{
|
||||
/***** List of items must be filled *****/
|
||||
if (!Prg_Gbl.List.IsRead)
|
||||
Lay_WrongItemsListExit ();
|
||||
Err_WrongItemsListExit ();
|
||||
|
||||
/***** Range is empty *****/
|
||||
if (Prg_Gbl.List.NumItems)
|
||||
|
@ -1678,7 +1679,7 @@ static void Prg_SetItemRangeOnlyItem (unsigned Index,struct ItemRange *ItemRange
|
|||
{
|
||||
/***** List of items must be filled *****/
|
||||
if (!Prg_Gbl.List.IsRead)
|
||||
Lay_WrongItemsListExit ();
|
||||
Err_WrongItemsListExit ();
|
||||
|
||||
/***** Range includes only this item *****/
|
||||
ItemRange->Begin =
|
||||
|
@ -1689,11 +1690,11 @@ static void Prg_SetItemRangeWithAllChildren (unsigned NumItem,struct ItemRange *
|
|||
{
|
||||
/***** List of items must be filled *****/
|
||||
if (!Prg_Gbl.List.IsRead)
|
||||
Lay_WrongItemsListExit ();
|
||||
Err_WrongItemsListExit ();
|
||||
|
||||
/***** Number of item must be in the correct range *****/
|
||||
if (NumItem >= Prg_Gbl.List.NumItems)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Range includes this item and all its children *****/
|
||||
ItemRange->Begin = Prg_Gbl.List.Items[NumItem ].Index;
|
||||
|
@ -1712,7 +1713,7 @@ static unsigned Prg_GetLastChild (int NumItem)
|
|||
/***** Trivial check: if item is wrong, there are no children *****/
|
||||
if (NumItem < 0 ||
|
||||
NumItem >= (int) Prg_Gbl.List.NumItems)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Get next brother after item *****/
|
||||
// 0 <= NumItem < Prg_Gbl.List.NumItems
|
||||
|
@ -2013,7 +2014,7 @@ void Prg_ReceiveFormChgItem (void)
|
|||
NewItem.Hierarchy.ItmCod = Prg_GetParamItmCod ();
|
||||
Prg_GetDataOfItemByCod (&NewItem);
|
||||
if (NewItem.Hierarchy.ItmCod <= 0)
|
||||
Lay_WrongItemExit ();
|
||||
Err_WrongItemExit ();
|
||||
|
||||
/***** Get data of the old (current) program item from database *****/
|
||||
OldItem.Hierarchy.ItmCod = NewItem.Hierarchy.ItmCod;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -383,7 +384,7 @@ static void Prj_ShowProjects (struct Prj_Projects *Projects)
|
|||
Prj_GetSelectedUsrsAndShowTheirPrjs (Projects);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongWhoExit ();
|
||||
Err_WrongWhoExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -876,7 +877,7 @@ static Prj_HiddenVisibl_t Prj_GetHiddenParamHidVis (void)
|
|||
(unsigned) Prj_FILTER_HIDDEN_DEFAULT |
|
||||
(unsigned) Prj_FILTER_VISIBL_DEFAULT);
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
return Prj_NEW_PRJ_HIDDEN_VISIBL_DEFAULT; // Not reached
|
||||
}
|
||||
}
|
||||
|
@ -1303,7 +1304,7 @@ static void Prj_ShowOneProject (struct Prj_Projects *Projects,
|
|||
/* Creation date/time */
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"prj_creat_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
switch (ProjectView)
|
||||
{
|
||||
case Prj_LIST_PROJECTS:
|
||||
|
@ -1324,7 +1325,7 @@ static void Prj_ShowOneProject (struct Prj_Projects *Projects,
|
|||
/* Modification date/time */
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"prj_modif_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
switch (ProjectView)
|
||||
{
|
||||
case Prj_LIST_PROJECTS:
|
||||
|
@ -1691,7 +1692,7 @@ static void Prj_ShowTableAllProjectsOneRow (struct Prj_Project *Prj)
|
|||
/***** Start date/time *****/
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"prj_creat_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s COLOR%u\"",
|
||||
Id,ClassDate,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Prj->CreatTime,
|
||||
|
@ -1703,7 +1704,7 @@ static void Prj_ShowTableAllProjectsOneRow (struct Prj_Project *Prj)
|
|||
/***** End date/time *****/
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"prj_modif_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LT %s COLOR%u\"",
|
||||
Id,ClassDate,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Prj->ModifTime,
|
||||
|
@ -2431,12 +2432,12 @@ static void Prj_FormToSelectUsrs (struct Prj_Projects *Projects,
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (Projects);
|
||||
if ((Projects->PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) <= 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Put form to select users *****/
|
||||
if (asprintf (&TxtButton,Txt_Add_USERS,
|
||||
Txt_PROJECT_ROLES_PLURAL_abc[RoleInProject]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Usr_PutFormToSelectUsrsToGoToAct (&Prj_MembersToAdd,
|
||||
ActionAddUsr[RoleInProject],
|
||||
Prj_PutCurrentParams,Projects,
|
||||
|
@ -2509,7 +2510,7 @@ static void Prj_AddUsrsToProject (Prj_RoleInProject_t RoleInProject)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Projects.PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) <= 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Add the selected users to project *****/
|
||||
Ptr = Prj_MembersToAdd.List[Rol_UNK];
|
||||
|
@ -2611,7 +2612,7 @@ static void Prj_ReqRemUsrFromPrj (struct Prj_Projects *Projects,
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (Projects);
|
||||
if ((Projects->PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -2696,7 +2697,7 @@ static void Prj_RemUsrFromPrj (Prj_RoleInProject_t RoleInProject)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Projects.PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -2879,15 +2880,15 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
{
|
||||
case (1 << Prj_ASSIGNED): // Assigned projects
|
||||
if (asprintf (&PreNonSubQuery," AND prj_projects.Assigned='Y'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case (1 << Prj_NONASSIG): // Non-assigned projects
|
||||
if (asprintf (&PreNonSubQuery," AND prj_projects.Assigned='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default: // All projects
|
||||
if (asprintf (&PreNonSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2896,7 +2897,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
{
|
||||
case Rol_STD: // Students can view only visible projects
|
||||
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
case Rol_TCH:
|
||||
|
@ -2905,20 +2906,20 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
{
|
||||
case (1 << Prj_HIDDEN): // Hidden projects
|
||||
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='Y'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
case (1 << Prj_VISIBL): // Visible projects
|
||||
if (asprintf (&HidVisSubQuery," AND prj_projects.Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
default: // All projects
|
||||
if (asprintf (&HidVisSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2927,12 +2928,12 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
{
|
||||
if (asprintf (&DptCodSubQuery," AND prj_projects.DptCod=%ld",
|
||||
Projects->Filter.DptCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Any department
|
||||
{
|
||||
if (asprintf (&DptCodSubQuery,"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Query */
|
||||
|
@ -3101,7 +3102,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongWhoExit ();
|
||||
Err_WrongWhoExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3115,7 +3116,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
/***** Create list of projects *****/
|
||||
if ((Projects->LstPrjCods = calloc ((size_t) NumPrjsFromDB,
|
||||
sizeof (*Projects->LstPrjCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the projects codes *****/
|
||||
for (NumPrj = 0;
|
||||
|
@ -3124,7 +3125,7 @@ static void Prj_GetListProjects (struct Prj_Projects *Projects)
|
|||
{
|
||||
/* Get next project code */
|
||||
if ((PrjCod = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/* Filter projects depending on faultiness */
|
||||
switch (Projects->Filter.Faulti)
|
||||
|
@ -3354,7 +3355,7 @@ void Prj_ReqRemProject (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -3370,7 +3371,7 @@ void Prj_ReqRemProject (void)
|
|||
Prj.Title);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -3399,7 +3400,7 @@ void Prj_RemoveProject (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj); // Inside this function, the course is checked to be the current one
|
||||
|
@ -3442,7 +3443,7 @@ void Prj_RemoveProject (void)
|
|||
Prj.Title);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -3469,7 +3470,7 @@ void Prj_HideProject (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -3484,7 +3485,7 @@ void Prj_HideProject (void)
|
|||
Prj.PrjCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -3511,7 +3512,7 @@ void Prj_UnhideProject (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -3526,7 +3527,7 @@ void Prj_UnhideProject (void)
|
|||
Prj.PrjCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -3566,7 +3567,7 @@ void Prj_RequestEditPrj (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Projects.PrjCod = Prj.PrjCod = Prj_GetParamPrjCod ()) <= 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Form to edit project *****/
|
||||
Prj_RequestCreatOrEditPrj (&Projects,&Prj);
|
||||
|
@ -3844,13 +3845,13 @@ static void Prj_EditOneProjectTxtArea (const char *Id,
|
|||
void Prj_AllocMemProject (struct Prj_Project *Prj)
|
||||
{
|
||||
if ((Prj->Description = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((Prj->Knowledge = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
if ((Prj->Materials = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3985,7 +3986,7 @@ void Prj_ReceiveFormProject (void)
|
|||
Prj_RequestCreatOrEditPrj (&Projects,&Prj);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -4295,7 +4296,7 @@ void Prj_ReqLockSelectedPrjsEdition (void)
|
|||
Prj_FreeListProjects (&Projects);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show projects again *****/
|
||||
Prj_ShowProjects (&Projects);
|
||||
|
@ -4334,7 +4335,7 @@ void Prj_ReqUnloSelectedPrjsEdition (void)
|
|||
Prj_FreeListProjects (&Projects);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show projects again *****/
|
||||
Prj_ShowProjects (&Projects);
|
||||
|
@ -4375,7 +4376,7 @@ void Prj_LockSelectedPrjsEdition (void)
|
|||
Prj_FreeListProjects (&Projects);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show projects again *****/
|
||||
Prj_ShowProjects (&Projects);
|
||||
|
@ -4412,7 +4413,7 @@ void Prj_UnloSelectedPrjsEdition (void)
|
|||
Prj_FreeListProjects (&Projects);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show projects again *****/
|
||||
Prj_ShowProjects (&Projects);
|
||||
|
@ -4446,7 +4447,7 @@ static void Prj_FormLockUnlock (const struct Prj_Project *Prj)
|
|||
Act_GetActCod (Prj_LockActions[Prj->Locked]),
|
||||
Gbl.Session.Id,
|
||||
Prj->PrjCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Frm_BeginFormOnSubmit (ActUnk,OnSubmit);
|
||||
Ico_PutIconLink (Prj_LockIcons[Prj->Locked],Txt_LOCKED_UNLOCKED[Prj->Locked]);
|
||||
Frm_EndForm ();
|
||||
|
@ -4485,7 +4486,7 @@ void Prj_LockProjectEdition (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -4500,7 +4501,7 @@ void Prj_LockProjectEdition (void)
|
|||
Prj_FormLockUnlock (&Prj);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
@ -4535,7 +4536,7 @@ void Prj_UnloProjectEdition (void)
|
|||
/***** Get parameters *****/
|
||||
Prj_GetParams (&Projects);
|
||||
if ((Prj.PrjCod = Prj_GetParamPrjCod ()) < 0)
|
||||
Lay_WrongProjectExit ();
|
||||
Err_WrongProjectExit ();
|
||||
|
||||
/***** Get data of the project from database *****/
|
||||
Prj_GetDataOfProjectByCod (&Prj);
|
||||
|
@ -4550,7 +4551,7 @@ void Prj_UnloProjectEdition (void)
|
|||
Prj_FormLockUnlock (&Prj);
|
||||
}
|
||||
else
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Free memory of the project *****/
|
||||
Prj_FreeMemProject (&Prj);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "swad_database.h"
|
||||
#include "swad_department.h"
|
||||
#include "swad_enrolment.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -219,7 +220,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
|||
/***** Create a list of fields *****/
|
||||
if ((Gbl.Crs.Records.LstFields.Lst = calloc (Gbl.Crs.Records.LstFields.Num,
|
||||
sizeof (*Gbl.Crs.Records.LstFields.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the fields *****/
|
||||
for (NumRow = 0;
|
||||
|
@ -231,7 +232,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
|||
|
||||
/* Get the code of field (row[0]) */
|
||||
if ((Gbl.Crs.Records.LstFields.Lst[NumRow].FieldCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/* Name of the field (row[1]) */
|
||||
Str_Copy (Gbl.Crs.Records.LstFields.Lst[NumRow].Name,row[1],
|
||||
|
@ -242,7 +243,7 @@ void Rec_GetListRecordFieldsInCurrentCrs (void)
|
|||
|
||||
/* Visible or editable by students? (row[3]) */
|
||||
if (sscanf (row[3],"%u",&Vis) != 1)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
if (Vis < Rec_NUM_TYPES_VISIBILITY)
|
||||
Gbl.Crs.Records.LstFields.Lst[NumRow].Visibility = (Rec_VisibilityRecordFields_t) Vis;
|
||||
else
|
||||
|
@ -568,7 +569,7 @@ void Rec_ReqRemField (void)
|
|||
|
||||
/***** Get the code of field *****/
|
||||
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/***** Check if exists any record with that field filled *****/
|
||||
if ((NumRecords = Rec_CountNumRecordsInCurrCrsWithField (Gbl.Crs.Records.Field.FieldCod))) // There are records with that field filled
|
||||
|
@ -694,7 +695,7 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
|
|||
" WHERE CrsCod=%ld"
|
||||
" AND FieldCod=%ld",
|
||||
Gbl.Hierarchy.Crs.CrsCod,FieldCod) != 1)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/***** Get the field *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
@ -707,7 +708,7 @@ static void Rec_GetFieldByCod (long FieldCod,char Name[Rec_MAX_BYTES_NAME_FIELD
|
|||
|
||||
/* Visible or editable by students? (row[2]) */
|
||||
if (sscanf (row[2],"%u",&Vis) != 1)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
if (Vis < Rec_NUM_TYPES_VISIBILITY)
|
||||
*Visibility = (Rec_VisibilityRecordFields_t) Vis;
|
||||
else
|
||||
|
@ -725,7 +726,7 @@ void Rec_RemoveField (void)
|
|||
{
|
||||
/***** Get the code of the field *****/
|
||||
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/***** Borrarlo from the database *****/
|
||||
Rec_RemoveFieldFromDB ();
|
||||
|
@ -745,7 +746,7 @@ void Rec_RenameField (void)
|
|||
/***** Get parameters of the form *****/
|
||||
/* Get the code of the field */
|
||||
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/* Get the new group name */
|
||||
Par_GetParToText ("FieldName",NewFieldName,Rec_MAX_BYTES_NAME_FIELD);
|
||||
|
@ -808,7 +809,7 @@ void Rec_ChangeLinesField (void)
|
|||
/***** Get parameters of the form *****/
|
||||
/* Get the code of field */
|
||||
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/* Get the new number of lines */
|
||||
NewNumLines = (unsigned)
|
||||
|
@ -858,7 +859,7 @@ void Rec_ChangeVisibilityField (void)
|
|||
/***** Get parameters of the form *****/
|
||||
/* Get the code of field */
|
||||
if ((Gbl.Crs.Records.Field.FieldCod = Rec_GetFieldCod ()) <= 0)
|
||||
Lay_WrongRecordFieldExit ();
|
||||
Err_WrongRecordFieldExit ();
|
||||
|
||||
/* Get the new visibility of the field */
|
||||
NewVisibility = (Rec_VisibilityRecordFields_t)
|
||||
|
@ -1691,7 +1692,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
|||
case Rec_CRS_PRINT_SEVERAL_RECORDS:
|
||||
break;
|
||||
default:
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1708,7 +1709,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
|||
}
|
||||
}
|
||||
else // Not me ==> I am a student trying to do something forbidden
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
break;
|
||||
|
@ -1727,7 +1728,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
}
|
||||
|
||||
/***** Begin box and table *****/
|
||||
|
@ -2015,7 +2016,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
|
|||
if (Rec_CheckIfICanEditField (Gbl.Crs.Records.LstFields.Lst[NumField].Visibility))
|
||||
/* Allocate memory for the texts of the fields */
|
||||
if ((Gbl.Crs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3363,11 +3364,11 @@ static void Rec_ShowPhone (struct UsrData *UsrDat,bool ShowData,bool PutForm,
|
|||
|
||||
/***** Internal name / id *****/
|
||||
if (asprintf (&Name,"Phone%u",NumPhone) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Label to show *****/
|
||||
if (asprintf (&Label,"%s %u",Txt_Phone,NumPhone + 1) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Phone *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -3697,7 +3698,7 @@ Rol_Role_t Rec_GetRoleFromRecordForm (void)
|
|||
break;
|
||||
}
|
||||
if (!RoleOK)
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
return Role;
|
||||
}
|
||||
|
||||
|
@ -3764,7 +3765,7 @@ static void Rec_GetUsrCommentsFromForm (struct UsrData *UsrDat)
|
|||
{
|
||||
/***** Check if memory is allocated for comments *****/
|
||||
if (!UsrDat->Comments)
|
||||
Lay_ShowErrorAndExit ("Can not read comments of a user.");
|
||||
Err_ShowErrorAndExit ("Can not read comments of a user.");
|
||||
|
||||
/***** Get the parameter with the comments *****/
|
||||
Par_GetParToHTML ("Comments",UsrDat->Comments,Cns_MAX_BYTES_TEXT);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -392,7 +393,7 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
|
|||
PathUniqueDirL,
|
||||
&Gbl.UniqueNameEncrypted[2]);
|
||||
if (mkdir (PathUniqueDirR,(mode_t) 0xFFF))
|
||||
Lay_ShowErrorAndExit ("Can not create directory for report.");
|
||||
Err_ShowErrorAndExit ("Can not create directory for report.");
|
||||
|
||||
/***** Path of the public file with the report */
|
||||
snprintf (Report->FilenameReport,sizeof (Report->FilenameReport),
|
||||
|
@ -401,7 +402,7 @@ static void Rep_CreateNewReportFile (struct Rep_Report *Report)
|
|||
snprintf (PathFileReport,sizeof (PathFileReport),"%s/%s",
|
||||
PathUniqueDirR,Report->FilenameReport);
|
||||
if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not create report file.");
|
||||
Err_ShowErrorAndExit ("Can not create report file.");
|
||||
|
||||
/***** Permalink *****/
|
||||
snprintf (Permalink,sizeof (Permalink),"%s/%c%c/%s/%s",
|
||||
|
@ -964,7 +965,7 @@ static void Rep_GetMaxHitsPerYear (struct Rep_Report *Report)
|
|||
row = mysql_fetch_row (mysql_res);
|
||||
if (row[0]) // There are questions
|
||||
if (sscanf (row[0],"%lu",&Report->MaxHitsPerYear) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting maximum hits.");
|
||||
Err_ShowErrorAndExit ("Error when getting maximum hits.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -1285,7 +1286,7 @@ static void Rep_ShowMyHitsPerYear (bool AnyCourse,long CrsCod,Rol_Role_t Role,
|
|||
|
||||
/* Get the year (in row[0] is the date in YYYY format) */
|
||||
if (sscanf (row[0],"%04u",&ReadYear) != 1)
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number hits (in row[1]) */
|
||||
if (sscanf (row[1],"%lu",&Report->Hits.Num) != 1)
|
||||
|
|
23
swad_room.c
23
swad_room.c
|
@ -32,6 +32,7 @@
|
|||
#include "swad_box.h"
|
||||
#include "swad_building.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -381,7 +382,7 @@ void Roo_ChangeMAC (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Par_GetParToLong ("Cod")) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get the old MAC address of the room */
|
||||
OldMACnum = MAC_GetMACnumFromForm ("MAC");
|
||||
|
@ -606,7 +607,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
|
|||
/***** Create list with courses in center *****/
|
||||
if ((Rooms->Lst = calloc ((size_t) Rooms->Num,
|
||||
sizeof (*Rooms->Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the rooms *****/
|
||||
for (NumRoom = 0;
|
||||
|
@ -620,7 +621,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,
|
|||
|
||||
/* Get room code (row[0]) */
|
||||
if ((Room->RooCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
switch (WhichData)
|
||||
{
|
||||
|
@ -1006,7 +1007,7 @@ void Roo_RemoveRoom (void)
|
|||
|
||||
/***** Get room code *****/
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/***** Get data of the room from database *****/
|
||||
Roo_GetDataOfRoomByCod (Roo_EditingRoom);
|
||||
|
@ -1059,7 +1060,7 @@ void Roo_ChangeBuilding (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get room building */
|
||||
NewBldCod = Bld_GetParamBldCod ();
|
||||
|
@ -1112,7 +1113,7 @@ void Roo_ChangeFloor (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get room floor */
|
||||
NewFloor = Roo_GetParamFloor ();
|
||||
|
@ -1164,7 +1165,7 @@ void Roo_ChangeType (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get room type */
|
||||
NewType = Roo_GetParamType ();
|
||||
|
@ -1261,7 +1262,7 @@ static void Roo_RenameRoom (Cns_ShrtOrFullName_t ShrtOrFullName)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get the new name for the room */
|
||||
Par_GetParToText (ParamName,NewClaName,MaxBytes);
|
||||
|
@ -1355,7 +1356,7 @@ void Roo_ChangeCapacity (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get room code */
|
||||
if ((Roo_EditingRoom->RooCod = Roo_GetParamRooCod ()) <= 0)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/* Get the seating capacity of the room */
|
||||
NewCapacity = (unsigned)
|
||||
|
@ -1656,11 +1657,11 @@ static void Roo_EditingRoomConstructor (void)
|
|||
{
|
||||
/***** Pointer must be NULL *****/
|
||||
if (Roo_EditingRoom != NULL)
|
||||
Lay_WrongRoomExit ();
|
||||
Err_WrongRoomExit ();
|
||||
|
||||
/***** Allocate memory for room *****/
|
||||
if ((Roo_EditingRoom = malloc (sizeof (*Roo_EditingRoom))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Reset room *****/
|
||||
Roo_EditingRoom->RooCod = -1L;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_config.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_parameter.h"
|
||||
|
@ -111,7 +112,7 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh
|
|||
WriteScope = true;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -164,7 +165,7 @@ void Sco_PutSelectorScope (const char *ParamName,HTM_SubmitOnChange_t SubmitOnCh
|
|||
Gbl.Hierarchy.Crs.ShrtName);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_connected.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_timeline_database.h"
|
||||
|
@ -84,7 +85,7 @@ void Ses_CreateSession (void)
|
|||
|
||||
/***** Check that session is not open *****/
|
||||
if (Ses_CheckIfSessionExists (Gbl.Session.Id))
|
||||
Lay_ShowErrorAndExit ("Can not create session.");
|
||||
Err_ShowErrorAndExit ("Can not create session.");
|
||||
|
||||
/***** Add session to database *****/
|
||||
Ses_InsertSessionInDB ();
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "swad_cookie.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_date.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -158,7 +159,7 @@ void Set_GetSettingsFromIP (void)
|
|||
if (NumRows)
|
||||
{
|
||||
if (NumRows != 1)
|
||||
Lay_ShowErrorAndExit ("Internal error while getting settings.");
|
||||
Err_ShowErrorAndExit ("Internal error while getting settings.");
|
||||
|
||||
/***** Get settings from database *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "swad_banner.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_hierarchy.h"
|
||||
|
@ -941,7 +942,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
|||
/***** Select clicks from the table of log *****/
|
||||
/* Allocate memory for the query */
|
||||
if ((Query = malloc (Sta_MAX_BYTES_QUERY_ACCESS + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/* Start the query */
|
||||
switch (Stats.ClicksGroupedBy)
|
||||
|
@ -1280,7 +1281,7 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse)
|
|||
{
|
||||
LengthQuery = LengthQuery + 25 + 10 + 1;
|
||||
if (LengthQuery > Sta_MAX_BYTES_QUERY_ACCESS - 128)
|
||||
Lay_ShowErrorAndExit ("Query is too large.");
|
||||
Err_ShowErrorAndExit ("Query is too large.");
|
||||
sprintf (QueryAux,
|
||||
NumUsr ? " OR %s.UsrCod=%ld" :
|
||||
" AND (%s.UsrCod=%ld",
|
||||
|
@ -1726,7 +1727,7 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats,
|
|||
|
||||
/* Get logged role */
|
||||
if (sscanf (row[2],"%u",&RoleFromLog) != 1)
|
||||
Lay_WrongRoleExit ();
|
||||
Err_WrongRoleExit ();
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
@ -1754,7 +1755,7 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats,
|
|||
|
||||
/* Write the date-time (row[3]) */
|
||||
if (asprintf (&Id,"log_date_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"LOG RT COLOR%u\"",Id,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Dat_GetUNIXTimeFromStr (row[3]),
|
||||
Gbl.Prefs.DateFormat,Dat_SEPARATOR_COMMA,
|
||||
|
@ -1764,7 +1765,7 @@ static void Sta_ShowDetailedAccessesList (const struct Sta_Stats *Stats,
|
|||
|
||||
/* Write the action */
|
||||
if (sscanf (row[4],"%ld",&ActCod) != 1)
|
||||
Lay_WrongActionExit ();
|
||||
Err_WrongActionExit ();
|
||||
HTM_TD_Begin ("class=\"LOG LT COLOR%u\"",Gbl.RowEvenOdd);
|
||||
if (ActCod >= 0)
|
||||
HTM_TxtF ("%s ",Act_GetActionText (Act_FromActCodToAction[ActCod]));
|
||||
|
@ -1964,7 +1965,7 @@ static void Sta_ShowNumHitsPerDay (Sta_CountType_t CountType,
|
|||
|
||||
/* Get year, month and day (row[0] holds the date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&ReadDate,row[0])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number of pages generated (in row[1]) */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[1]);
|
||||
|
@ -2172,11 +2173,11 @@ static void Sta_ShowDistrAccessesPerDayAndHour (const struct Sta_Stats *Stats,
|
|||
|
||||
/* Get year, month and day (row[0] holds the date in YYYYMMDD format) */
|
||||
if (!(Dat_GetDateFromYYYYMMDD (&CurrentReadDate,row[0])))
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get the hour (in row[1] is the hour in formato HH) */
|
||||
if (sscanf (row[1],"%02u",&ReadHour) != 1)
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number of pages generated (in row[2]) */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[2]);
|
||||
|
@ -2542,7 +2543,7 @@ static void Sta_ShowNumHitsPerWeek (Sta_CountType_t CountType,
|
|||
|
||||
/* Get year and week (row[0] holds date in YYYYWW format) */
|
||||
if (sscanf (row[0],"%04u%02u",&ReadDate.Year,&ReadDate.Week) != 2)
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number of pages generated (in row[1]) */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[1]);
|
||||
|
@ -2643,7 +2644,7 @@ static void Sta_ShowNumHitsPerMonth (Sta_CountType_t CountType,
|
|||
|
||||
/* Get the year and the month (in row[0] is the date in YYYYMM format) */
|
||||
if (sscanf (row[0],"%04u%02u",&ReadDate.Year,&ReadDate.Month) != 2)
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number of pages generated (in row[1]) */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[1]);
|
||||
|
@ -2744,7 +2745,7 @@ static void Sta_ShowNumHitsPerYear (Sta_CountType_t CountType,
|
|||
|
||||
/* Get the year (in row[0] is the date in YYYY format) */
|
||||
if (sscanf (row[0],"%04u",&ReadDate.Year) != 1)
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
/* Get number of pages generated (in row[1]) */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[1]);
|
||||
|
@ -2844,7 +2845,7 @@ static void Sta_ShowNumHitsPerHour (unsigned NumHits,
|
|||
row = mysql_fetch_row (mysql_res); // Get next result
|
||||
NumHit++;
|
||||
if (sscanf (row[0],"%02u",&ReadHour) != 1) // In row[0] is the date in HH format
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
|
||||
for (H = Hour;
|
||||
H < ReadHour;
|
||||
|
@ -2939,7 +2940,7 @@ static void Sta_ShowAverageAccessesPerMinute (unsigned NumHits,MYSQL_RES *mysql_
|
|||
row = mysql_fetch_row (mysql_res); // Get next result
|
||||
NumHit++;
|
||||
if (sscanf (row[0],"%02u%02u",&ReadHour,&MinuteRead) != 2) // In row[0] is the date in formato HHMM
|
||||
Lay_WrongDateExit ();
|
||||
Err_WrongDateExit ();
|
||||
/* Get number of pages generated */
|
||||
Hits.Num = Str_GetDoubleFromStr (row[1]);
|
||||
MinuteDayRead = ReadHour * 60 + MinuteRead;
|
||||
|
@ -3221,7 +3222,7 @@ static void Sta_ShowNumHitsPerPlugin (Sta_CountType_t CountType,
|
|||
|
||||
/* Write the plugin */
|
||||
if (sscanf (row[0],"%ld",&Plg.PlgCod) != 1)
|
||||
Lay_WrongPluginExit ();
|
||||
Err_WrongPluginExit ();
|
||||
HTM_TD_Begin ("class=\"LOG RT\"");
|
||||
if (Plg_GetDataOfPluginByCod (&Plg))
|
||||
HTM_Txt (Plg.Name);
|
||||
|
@ -3277,7 +3278,7 @@ static void Sta_ShowNumHitsPerWSFunction (Sta_CountType_t CountType,
|
|||
|
||||
/* Write the plugin */
|
||||
if (sscanf (row[0],"%ld",&FunCod) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong function code.");
|
||||
Err_ShowErrorAndExit ("Wrong function code.");
|
||||
|
||||
HTM_TD_Begin ("class=\"LOG LT\"");
|
||||
HTM_TxtF ("%s ",API_GetFunctionNameFromFunCod (FunCod));
|
||||
|
@ -3343,7 +3344,7 @@ static void Sta_ShowNumHitsPerBanner (Sta_CountType_t CountType,
|
|||
|
||||
/* Write the banner */
|
||||
if (sscanf (row[0],"%ld",&(Ban.BanCod)) != 1)
|
||||
Lay_WrongBannerExit ();
|
||||
Err_WrongBannerExit ();
|
||||
Ban_GetDataOfBannerByCod (&Ban);
|
||||
HTM_TD_Begin ("class=\"LOG LT\"");
|
||||
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"DAT\" target=\"_blank\"",
|
||||
|
@ -3884,7 +3885,7 @@ static void Sta_DrawBarNumHits (char Color,
|
|||
if (BarWidth == 0)
|
||||
BarWidth = 1;
|
||||
if (asprintf (&Icon,"%c1x1.png",Color) < 0) // Background
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_IMG (Cfg_URL_ICON_PUBLIC,Icon,NULL,
|
||||
"style=\"width:%upx;height:10px;\"",BarWidth);
|
||||
free (Icon);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <stdlib.h> // For malloc and free
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_ID.h"
|
||||
|
@ -323,7 +324,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
ParamsStr);
|
||||
Anchor1NickLength = strlen (Anchor1Nick);
|
||||
if ((Links[NumLinks].Anchor1Nick = malloc (Anchor1NickLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
strcpy (Links[NumLinks].Anchor1Nick,Anchor1Nick);
|
||||
Links[NumLinks].Anchor1NickLength = Anchor1NickLength;
|
||||
|
||||
|
@ -336,7 +337,7 @@ void Str_InsertLinks (char *Txt,unsigned long MaxLength,size_t MaxCharsURLOnScre
|
|||
Gbl.Form.Id);
|
||||
Anchor2NickLength = strlen (Anchor2Nick);
|
||||
if ((Links[NumLinks].Anchor2Nick = malloc (Anchor2NickLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
strcpy (Links[NumLinks].Anchor2Nick,Anchor2Nick);
|
||||
Links[NumLinks].Anchor2NickLength = Anchor2NickLength;
|
||||
|
||||
|
@ -961,7 +962,7 @@ void Str_DoubleNumToStr (char **Str,double Number)
|
|||
{
|
||||
if (asprintf (Str,"%.15lg",
|
||||
Number) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -980,7 +981,7 @@ void Str_DoubleNumToStrFewDigits (char **Str,double Number)
|
|||
if (FractionaryPart == 0.0)
|
||||
{
|
||||
if (asprintf (Str,"%.0f",IntegerPart) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -999,7 +1000,7 @@ void Str_DoubleNumToStrFewDigits (char **Str,double Number)
|
|||
else
|
||||
Format = "%le";
|
||||
if (asprintf (Str,Format,Number) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1033,7 +1034,7 @@ double Str_GetDoubleFromStr (const char *Str)
|
|||
|
||||
/***** Copy source string to temporary string to convert to point *****/
|
||||
if (asprintf (&StrPoint,"%s",Str) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** The string is "scanned" in floating point
|
||||
(it must have a point, not a comma as decimal separator) *****/
|
||||
|
@ -1149,7 +1150,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
|||
{
|
||||
/***** Allocate memory for a destination string where to do the changes *****/
|
||||
if ((StrDst = malloc (MaxLengthStr + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Make the change *****/
|
||||
for (PtrSrc = Str, PtrDst = StrDst;
|
||||
|
@ -1548,7 +1549,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
|||
|
||||
/* Check new length of destination string after the copy */
|
||||
if (LengthStrDst + LengthSpecStrDst > MaxLengthStr)
|
||||
Lay_ShowErrorAndExit ("Space allocated to string is full.");
|
||||
Err_ShowErrorAndExit ("Space allocated to string is full.");
|
||||
|
||||
/* Copy to appropiate place the special character string */
|
||||
// strncpy (PtrDst,StrSpecialChar,LengthSpecStrDst);
|
||||
|
@ -1565,7 +1566,7 @@ void Str_ChangeFormat (Str_ChangeFrom_t ChangeFrom,Str_ChangeTo_t ChangeTo,
|
|||
{
|
||||
/* Check new length of destination string after the copy */
|
||||
if (LengthStrDst >= MaxLengthStr)
|
||||
Lay_ShowErrorAndExit ("Space allocated to string is full.");
|
||||
Err_ShowErrorAndExit ("Space allocated to string is full.");
|
||||
|
||||
/* Copy char from source to destination and increment pointers */
|
||||
*PtrDst++ = *PtrSrc++;
|
||||
|
@ -2503,7 +2504,7 @@ void Str_CopyStrChangingSpaces (const char *StringWithSpaces,char *StringWithout
|
|||
*PtrDst = '\0';
|
||||
|
||||
if (Length > MaxLength)
|
||||
Lay_ShowErrorAndExit ("Path is too long.");
|
||||
Err_ShowErrorAndExit ("Path is too long.");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2758,7 +2759,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,
|
|||
return 1;
|
||||
}
|
||||
if (LengthBoundaryStr > Str_MAX_BYTES_BOUNDARY_STR)
|
||||
Lay_ShowErrorAndExit ("Delimiter string too large.");
|
||||
Err_ShowErrorAndExit ("Delimiter string too large.");
|
||||
Ptr = StrDst;
|
||||
|
||||
StartIndex = 0;
|
||||
|
@ -3018,7 +3019,7 @@ void Str_Copy (char *Dst,const char *Src,size_t DstSize)
|
|||
snprintf (ErrorTxt,sizeof (ErrorTxt),
|
||||
"Trying to copy %zu chars into a %zu-chars buffer.",
|
||||
SrcLength,DstSize);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
|
||||
/***** Copy source into destination *****/
|
||||
|
@ -3043,7 +3044,7 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize)
|
|||
{
|
||||
snprintf (ErrorTxt,sizeof (ErrorTxt),"%lu-chars buffer has %lu chars!",
|
||||
DstSize,DstLength);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
|
||||
/***** Check if buffer has enough space for source *****/
|
||||
|
@ -3056,7 +3057,7 @@ void Str_Concat (char *Dst,const char *Src,size_t DstSize)
|
|||
"Trying to concatenate %zu chars to a %zu-chars buffer"
|
||||
" with free space for only %zu chars!",
|
||||
SrcLength,DstSize,FreeSpace);
|
||||
Lay_ShowErrorAndExit (ErrorTxt);
|
||||
Err_ShowErrorAndExit (ErrorTxt);
|
||||
}
|
||||
|
||||
/***** Concatenate ******/
|
||||
|
@ -3076,7 +3077,7 @@ char *Str_BuildStringStr (const char *fmt,const char *Str)
|
|||
{
|
||||
Str_FreeString ();
|
||||
if (asprintf (&Str_String,fmt,Str) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
return Str_String;
|
||||
}
|
||||
|
@ -3088,7 +3089,7 @@ char *Str_BuildStringLong (const char *fmt,long Num)
|
|||
{
|
||||
Str_FreeString ();
|
||||
if (asprintf (&Str_String,fmt,Num) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
return Str_String;
|
||||
}
|
||||
|
@ -3099,7 +3100,7 @@ char *Str_BuildStringLongStr (long Num,const char *Str)
|
|||
{
|
||||
Str_FreeString ();
|
||||
if (asprintf (&Str_String,"%ld %s",Num,Str) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
return Str_String;
|
||||
}
|
||||
|
|
129
swad_survey.c
129
swad_survey.c
|
@ -35,6 +35,7 @@
|
|||
#include "swad_attendance.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -434,7 +435,7 @@ void Svy_SeeOneSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Show survey *****/
|
||||
Svy_ShowOneSurvey (&Surveys,Svy.SvyCod,true);
|
||||
|
@ -500,7 +501,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
/* Start date/time */
|
||||
UniqueId++;
|
||||
if (asprintf (&Id,"svy_date_start_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (ShowOnlyThisSvyComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
||||
Id,
|
||||
|
@ -524,7 +525,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
|
||||
/* End date/time */
|
||||
if (asprintf (&Id,"svy_date_end_%u",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (ShowOnlyThisSvyComplete)
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT\"",
|
||||
Id,
|
||||
|
@ -650,7 +651,7 @@ static void Svy_ShowOneSurvey (struct Svy_Surveys *Surveys,
|
|||
switch (Svy.Scope)
|
||||
{
|
||||
case Hie_Lvl_UNK: // Unknown
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
case Hie_Lvl_SYS: // System
|
||||
HTM_Txt (Cfg_PLATFORM_SHORT_NAME);
|
||||
|
@ -972,13 +973,13 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
Sco_GetDBStrFromScope (Scope),Cods[Scope],
|
||||
(HiddenAllowed & 1 << Scope) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&SubQuery[Scope],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Fill subquery for course */
|
||||
|
@ -1007,7 +1008,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
(HiddenAllowed & 1 << Hie_Lvl_CRS) ? "" :
|
||||
" AND Hidden='N'",
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else // Gbl.Crs.Grps.WhichGrps == Grp_ALL_GROUPS
|
||||
{
|
||||
|
@ -1017,14 +1018,14 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
Sco_GetDBStrFromScope (Hie_Lvl_CRS),Cods[Hie_Lvl_CRS],
|
||||
(HiddenAllowed & 1 << Hie_Lvl_CRS) ? "" :
|
||||
" AND Hidden='N'") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
SubQueryFilled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&SubQuery[Hie_Lvl_CRS],"%s","") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
/* Make query */
|
||||
|
@ -1043,7 +1044,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
OrderBySubQuery[Surveys->SelectedOrder]);
|
||||
else
|
||||
{
|
||||
Lay_ShowErrorAndExit ("Can not get list of surveys.");
|
||||
Err_ShowErrorAndExit ("Can not get list of surveys.");
|
||||
NumRows = 0; // Not reached. Initialized to avoid warning
|
||||
}
|
||||
|
||||
|
@ -1060,7 +1061,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
/***** Create list of surveys *****/
|
||||
if ((Surveys->LstSvyCods = calloc (NumRows,
|
||||
sizeof (*Surveys->LstSvyCods))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get the surveys codes *****/
|
||||
for (NumSvy = 0;
|
||||
|
@ -1068,7 +1069,7 @@ static void Svy_GetListSurveys (struct Svy_Surveys *Surveys)
|
|||
NumSvy++)
|
||||
/* Get next survey code */
|
||||
if ((Surveys->LstSvyCods[NumSvy] = DB_GetNextCode (mysql_res)) < 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
}
|
||||
else
|
||||
Surveys->Num = 0;
|
||||
|
@ -1282,7 +1283,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
|||
|
||||
/* Get survey scope (row[1]) */
|
||||
if ((Svy->Scope = Sco_GetScopeFromDBStr (row[1])) == Hie_Lvl_UNK)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
|
||||
/* Get code of the country, institution, center, degree or course (row[2]) */
|
||||
Svy->Cod = Str_ConvertStrCodToLongCod (row[2]);
|
||||
|
@ -1292,7 +1293,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
|||
|
||||
/* Get roles (row[4]) */
|
||||
if (sscanf (row[4],"%u",&Svy->Roles) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when reading roles of survey.");
|
||||
Err_ShowErrorAndExit ("Error when reading roles of survey.");
|
||||
|
||||
/* Get author of the survey (row[5]) */
|
||||
Svy->UsrCod = Str_ConvertStrCodToLongCod (row[5]);
|
||||
|
@ -1320,7 +1321,7 @@ void Svy_GetDataOfSurveyByCod (struct Svy_Survey *Svy)
|
|||
switch (Svy->Scope)
|
||||
{
|
||||
case Hie_Lvl_UNK: // Unknown
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
case Hie_Lvl_SYS: // System
|
||||
Svy->Status.IBelongToScope = Gbl.Usrs.Me.Logged;
|
||||
|
@ -1525,7 +1526,7 @@ void Svy_GetNotifSurvey (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
{
|
||||
Length = strlen (row[1]);
|
||||
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (*ContentStr,row[1],Length);
|
||||
}
|
||||
}
|
||||
|
@ -1574,12 +1575,12 @@ void Svy_AskRemSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show question and button to remove survey *****/
|
||||
Surveys.SvyCod = Svy.SvyCod;
|
||||
|
@ -1613,12 +1614,12 @@ void Svy_RemoveSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove all the users in this survey *****/
|
||||
DB_QueryDELETE ("can not remove users who are answered a survey",
|
||||
|
@ -1681,12 +1682,12 @@ void Svy_AskResetSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Ask for confirmation of reset *****/
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_Do_you_really_want_to_reset_the_survey_X,
|
||||
|
@ -1734,12 +1735,12 @@ void Svy_ResetSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Remove all the users in this survey *****/
|
||||
DB_QueryDELETE ("can not remove users who are answered a survey",
|
||||
|
@ -1783,12 +1784,12 @@ void Svy_HideSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Hide survey *****/
|
||||
DB_QueryUPDATE ("can not hide survey",
|
||||
|
@ -1820,12 +1821,12 @@ void Svy_UnhideSurvey (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/***** Show survey *****/
|
||||
DB_QueryUPDATE ("can not show survey",
|
||||
|
@ -1901,7 +1902,7 @@ void Svy_RequestCreatOrEditSvy (void)
|
|||
{
|
||||
/***** Put link (form) to create new survey *****/
|
||||
if (!Svy_CheckIfICanCreateSvy ())
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/* Initialize to empty survey */
|
||||
Svy.SvyCod = -1L;
|
||||
|
@ -1926,7 +1927,7 @@ void Svy_RequestCreatOrEditSvy (void)
|
|||
/* Get data of the survey from database */
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
if (!Svy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/* Get text of the survey from database */
|
||||
Svy_GetSurveyTxtFromDB (Svy.SvyCod,Txt);
|
||||
|
@ -2116,7 +2117,7 @@ static void Svy_SetDefaultAndAllowedScope (struct Svy_Survey *Svy)
|
|||
}
|
||||
|
||||
if (!ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2215,7 +2216,7 @@ void Svy_ReceiveFormSurvey (void)
|
|||
OldSvy.SvyCod = NewSvy.SvyCod;
|
||||
Svy_GetDataOfSurveyByCod (&OldSvy);
|
||||
if (!OldSvy.Status.ICanEdit)
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
NewSvy.Scope = OldSvy.Scope;
|
||||
}
|
||||
|
||||
|
@ -2226,46 +2227,46 @@ void Svy_ReceiveFormSurvey (void)
|
|||
{
|
||||
case Hie_Lvl_SYS:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_SYS;
|
||||
NewSvy.Cod = -1L;
|
||||
break;
|
||||
case Hie_Lvl_CTY:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_CTY;
|
||||
NewSvy.Cod = Gbl.Hierarchy.Cty.CtyCod;
|
||||
break;
|
||||
case Hie_Lvl_INS:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
||||
Gbl.Usrs.Me.Role.Logged != Rol_INS_ADM)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_INS;
|
||||
NewSvy.Cod = Gbl.Hierarchy.Ins.InsCod;
|
||||
break;
|
||||
case Hie_Lvl_CTR:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
||||
Gbl.Usrs.Me.Role.Logged != Rol_CTR_ADM)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_CTR;
|
||||
NewSvy.Cod = Gbl.Hierarchy.Ctr.CtrCod;
|
||||
break;
|
||||
case Hie_Lvl_DEG:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
||||
Gbl.Usrs.Me.Role.Logged != Rol_DEG_ADM)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_DEG;
|
||||
NewSvy.Cod = Gbl.Hierarchy.Deg.DegCod;
|
||||
break;
|
||||
case Hie_Lvl_CRS:
|
||||
if (Gbl.Usrs.Me.Role.Logged != Rol_SYS_ADM &&
|
||||
Gbl.Usrs.Me.Role.Logged != Rol_TCH)
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
NewSvy.Scope = Hie_Lvl_CRS;
|
||||
NewSvy.Cod = Gbl.Hierarchy.Crs.CrsCod;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2686,7 +2687,7 @@ void Svy_RequestEditQuestion (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/* Get the question code */
|
||||
SvyQst.QstCod = Svy_GetParamQstCod ();
|
||||
|
@ -2747,7 +2748,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|||
|
||||
/* Get question index inside survey (row[0]) */
|
||||
if (sscanf (row[0],"%u",&(SvyQst->QstInd)) != 1)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
|
||||
/* Get the type of answer (row[1]) */
|
||||
SvyQst->AnswerType = Svy_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
|
||||
|
@ -2767,7 +2768,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
|
||||
/* Abort on error */
|
||||
Ale_ShowAlertsAndExit ();
|
||||
|
@ -2787,7 +2788,7 @@ static void Svy_ShowFormEditOneQst (struct Svy_Surveys *Surveys,
|
|||
Surveys->QstCod = SvyQst->QstCod;
|
||||
|
||||
if (asprintf (&Title,"%s %u",Txt_Question,SvyQst->QstInd + 1) < 0) // Question index may be 0, 1, 2, 3,...
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Box_BoxBegin (NULL,Title,
|
||||
Svy_PutIconToRemoveOneQst,Surveys,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
|
@ -3084,7 +3085,7 @@ void Svy_ReceiveQst (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get survey code */
|
||||
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/* Get question code */
|
||||
SvyQst.QstCod = Svy_GetParamQstCod ();
|
||||
|
@ -3270,7 +3271,7 @@ static unsigned Svy_GetNextQuestionIndexInSvy (long SvyCod)
|
|||
if (row[0]) // There are questions
|
||||
{
|
||||
if (sscanf (row[0],"%u",&QstInd) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting last question index.");
|
||||
Err_ShowErrorAndExit ("Error when getting last question index.");
|
||||
QstInd++;
|
||||
}
|
||||
|
||||
|
@ -3363,7 +3364,7 @@ static void Svy_ListSvyQuestions (struct Svy_Surveys *Surveys,
|
|||
|
||||
/* row[0] holds the code of the question */
|
||||
if (sscanf (row[0],"%ld",&(SvyQst.QstCod)) != 1)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
@ -3389,7 +3390,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)
|
||||
Lay_WrongQuestionIndexExit ();
|
||||
Err_WrongQuestionIndexExit ();
|
||||
HTM_Unsigned (SvyQst.QstInd + 1);
|
||||
HTM_TD_End ();
|
||||
|
||||
|
@ -3488,7 +3489,7 @@ static void Svy_WriteQstStem (const char *Stem)
|
|||
/* Convert the stem, that is in HTML, to rigorous HTML */
|
||||
Length = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
||||
if ((HeadingRigorousHTML = malloc (Length + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (HeadingRigorousHTML,Stem,Length);
|
||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||
HeadingRigorousHTML,Length,false);
|
||||
|
@ -3523,7 +3524,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
|||
{
|
||||
/* Check number of answers */
|
||||
if (NumAnswers > Svy_MAX_ANSWERS_PER_QUESTION)
|
||||
Lay_ShowErrorAndExit ("Wrong number of answers.");
|
||||
Err_ShowErrorAndExit ("Wrong number of answers.");
|
||||
|
||||
/* Write one row for each answer */
|
||||
HTM_TABLE_BeginPadding (5);
|
||||
|
@ -3536,7 +3537,7 @@ static void Svy_WriteAnswersOfAQst (struct Svy_Survey *Svy,
|
|||
|
||||
/* Get number of users who have marked this answer (row[1]) */
|
||||
if (sscanf (row[1],"%u",&NumUsrsThisAnswer) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of users who have marked an answer.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of users who have marked an answer.");
|
||||
|
||||
/* Convert the answer (row[2]), that is in HTML, to rigorous HTML */
|
||||
if (!Svy_AllocateTextChoiceAnswer (SvyQst,NumAns))
|
||||
|
@ -3623,13 +3624,13 @@ static void Svy_DrawBarNumUsrs (unsigned NumUsrs,unsigned MaxUsrs)
|
|||
NumUsrs,
|
||||
(unsigned) ((((double) NumUsrs * 100.0) / (double) MaxUsrs) + 0.5),
|
||||
Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (asprintf (&Title,"0 (0%% %s %u)",
|
||||
Txt_of_PART_OF_A_TOTAL,MaxUsrs) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
}
|
||||
|
||||
HTM_TD_Begin ("class=\"DAT LT\" style=\"width:%upx;\"",Svy_MAX_BAR_WIDTH + 125);
|
||||
|
@ -3696,11 +3697,11 @@ void Svy_RequestRemoveQst (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get survey code */
|
||||
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/* Get question code */
|
||||
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get question index */
|
||||
SvyQst.QstInd = Svy_GetQstIndFromQstCod (SvyQst.QstCod);
|
||||
|
@ -3738,11 +3739,11 @@ void Svy_RemoveQst (void)
|
|||
/***** Get parameters from form *****/
|
||||
/* Get survey code */
|
||||
if ((SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/* Get question code */
|
||||
if ((SvyQst.QstCod = Svy_GetParamQstCod ()) <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get question index */
|
||||
SvyQst.QstInd = Svy_GetQstIndFromQstCod (SvyQst.QstCod);
|
||||
|
@ -3757,7 +3758,7 @@ void Svy_RemoveQst (void)
|
|||
" WHERE QstCod=%ld",
|
||||
SvyQst.QstCod);
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Change index of questions greater than this */
|
||||
DB_QueryUPDATE ("can not update indexes of questions",
|
||||
|
@ -3791,7 +3792,7 @@ void Svy_ReceiveSurveyAnswers (void)
|
|||
|
||||
/***** Get survey code *****/
|
||||
if ((Svy.SvyCod = Svy_GetParamSvyCod ()) <= 0)
|
||||
Lay_WrongSurveyExit ();
|
||||
Err_WrongSurveyExit ();
|
||||
|
||||
/***** Get data of the survey from database *****/
|
||||
Svy_GetDataOfSurveyByCod (&Svy);
|
||||
|
@ -3844,7 +3845,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
|
|||
{
|
||||
/* Get next question */
|
||||
if ((QstCod = DB_GetNextCode (mysql_res)) <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get possible parameter with the user's answer */
|
||||
snprintf (ParamName,sizeof (ParamName),"Ans%010u",(unsigned) QstCod);
|
||||
|
@ -3863,7 +3864,7 @@ static void Svy_ReceiveAndStoreUserAnswersToASurvey (long SvyCod)
|
|||
}
|
||||
}
|
||||
else // This survey has no questions
|
||||
Lay_ShowErrorAndExit ("Error: this survey has no questions.");
|
||||
Err_ShowErrorAndExit ("Error: this survey has no questions.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -4116,20 +4117,20 @@ unsigned Svy_GetNumCrsSurveys (Hie_Lvl_Level_t Scope,unsigned *NumNotif)
|
|||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of surveys *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&NumSurveys) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of surveys.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of surveys.");
|
||||
|
||||
/***** Get number of notifications by email *****/
|
||||
if (row[1])
|
||||
{
|
||||
if (sscanf (row[1],"%u",NumNotif) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of notifications of surveys.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of notifications of surveys.");
|
||||
}
|
||||
else
|
||||
*NumNotif = 0;
|
||||
|
@ -4239,7 +4240,7 @@ double Svy_GetNumQstsPerCrsSurvey (Hie_Lvl_Level_t Scope)
|
|||
" GROUP BY svy_questions.SvyCod) AS NumQstsTable",
|
||||
Sco_GetDBStrFromScope (Hie_Lvl_CRS),Gbl.Hierarchy.Crs.CrsCod);
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
return 0.0; // Not reached
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "swad_changelog.h"
|
||||
#include "swad_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_forum.h"
|
||||
#include "swad_global.h"
|
||||
|
@ -350,7 +351,7 @@ static void Syl_SetSyllabusTypeFromAction (struct Syl_Syllabus *Syllabus)
|
|||
Gbl.Crs.Info.Type = Inf_PRACTICALS;
|
||||
break;
|
||||
default:
|
||||
Lay_WrongActionExit ();
|
||||
Err_WrongActionExit ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -381,7 +382,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
|||
|
||||
/***** Go to the start of the list of items *****/
|
||||
if (!Str_FindStrInFile (Gbl.F.XML,"<lista>",Str_NO_SKIP_HTML_COMMENTS))
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
|
||||
/***** Save the position of the start of the list *****/
|
||||
PostBeginList = ftell (Gbl.F.XML);
|
||||
|
@ -394,7 +395,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
|||
/***** Allocate memory for the list of items *****/
|
||||
if ((Syl_LstItemsSyllabus.Lst = calloc (Syl_LstItemsSyllabus.NumItems + 1,
|
||||
sizeof (*Syl_LstItemsSyllabus.Lst))) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Return to the start of the list *****/
|
||||
fseek (Gbl.F.XML,PostBeginList,SEEK_SET);
|
||||
|
@ -429,7 +430,7 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
|||
{
|
||||
/* Go to the start of the item */
|
||||
if (!Str_FindStrInFile (Gbl.F.XML,"<item",Str_NO_SKIP_HTML_COMMENTS))
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
|
||||
/* Get the level */
|
||||
Syl_LstItemsSyllabus.Lst[NumItem].Level = Syl_ReadLevelItemSyllabus ();
|
||||
|
@ -454,10 +455,10 @@ void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
|
|||
if (Result == 0) // Str too long
|
||||
{
|
||||
if (!Str_FindStrInFile (Gbl.F.XML,"</item>",Str_NO_SKIP_HTML_COMMENTS)) // End the search
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
}
|
||||
else if (Result == -1)
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
}
|
||||
|
||||
/***** Close the file with the syllabus *****/
|
||||
|
@ -507,12 +508,12 @@ int Syl_ReadLevelItemSyllabus (void)
|
|||
char StrlLevel[11 + 1];
|
||||
|
||||
if (!Str_FindStrInFile (Gbl.F.XML,"nivel=\"",Str_NO_SKIP_HTML_COMMENTS))
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
if (Str_ReadFileUntilBoundaryStr (Gbl.F.XML,StrlLevel,"\"",1,
|
||||
(unsigned long long) (11 + 1)) != 1)
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
if (sscanf (StrlLevel,"%d",&Level) != 1)
|
||||
Lay_WrongSyllabusFormatExit ();
|
||||
Err_WrongSyllabusFormatExit ();
|
||||
Str_FindStrInFile (Gbl.F.XML,">",Str_NO_SKIP_HTML_COMMENTS);
|
||||
if (Level < 1)
|
||||
Level = 1;
|
||||
|
@ -1400,18 +1401,18 @@ static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
|
|||
{
|
||||
/* Can't open the file */
|
||||
if (!Fil_CheckIfPathExists (Syllabus->PathDir)) // Strange error, since it is just created
|
||||
Lay_ShowErrorAndExit ("Can not open syllabus file.");
|
||||
Err_ShowErrorAndExit ("Can not open syllabus file.");
|
||||
else
|
||||
{
|
||||
/* Create a new empty syllabus */
|
||||
if ((Gbl.F.XML = fopen (PathFile,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not create syllabus file.");
|
||||
Err_ShowErrorAndExit ("Can not create syllabus file.");
|
||||
Syl_WriteStartFileSyllabus (Gbl.F.XML);
|
||||
Syl_WriteEndFileSyllabus (Gbl.F.XML);
|
||||
Fil_CloseXMLFile ();
|
||||
/* Open of new the file for reading */
|
||||
if ((Gbl.F.XML = fopen (PathFile,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open syllabus file.");
|
||||
Err_ShowErrorAndExit ("Can not open syllabus file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_course.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_figure_cache.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_help.h"
|
||||
|
@ -210,7 +211,7 @@ static void SysCfg_GetCoordAndZoom (struct Coordinates *Coord,unsigned *Zoom)
|
|||
" FROM ctr_centers"
|
||||
" WHERE Latitude<>0"
|
||||
" AND Longitude<>0") < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Map_GetCoordAndZoom (Coord,Zoom,Query);
|
||||
free (Query);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_tag.h"
|
||||
|
@ -230,7 +231,7 @@ static long Tag_GetParamTagCode (void)
|
|||
|
||||
/***** Get tag code *****/
|
||||
if ((TagCod = Par_GetParToLong ("TagCod")) <= 0)
|
||||
Lay_WrongTagExit ();
|
||||
Err_WrongTagExit ();
|
||||
|
||||
return TagCod;
|
||||
}
|
||||
|
@ -286,7 +287,7 @@ void Tag_RenameTag (void)
|
|||
change old tag to new tag in tst_question_tags *****/
|
||||
/* Get tag code of the old tag */
|
||||
if ((OldTagCod = Tag_GetTagCodFromTagTxt (OldTagTxt)) <= 0)
|
||||
Lay_WrongTagExit ();
|
||||
Err_WrongTagExit ();
|
||||
|
||||
/* Create a temporary table with all the question codes
|
||||
that had the new tag as one of their tags */
|
||||
|
@ -578,7 +579,7 @@ void Tag_ShowFormEditTags (void)
|
|||
row[2] TagHidden
|
||||
*/
|
||||
if ((TagCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongTagExit ();
|
||||
Err_WrongTagExit ();
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
|
91
swad_test.c
91
swad_test.c
|
@ -40,6 +40,7 @@
|
|||
#include "swad_action.h"
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_exam_set.h"
|
||||
#include "swad_figure.h"
|
||||
#include "swad_form.h"
|
||||
|
@ -435,7 +436,7 @@ void Tst_ReceiveTestDraft (void)
|
|||
/* Get test exam code from form */
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0)
|
||||
Lay_WrongTestExit ();
|
||||
Err_WrongTestExit ();
|
||||
|
||||
/* Get number of this test from form */
|
||||
NumTst = Tst_GetParamNumTst ();
|
||||
|
@ -491,7 +492,7 @@ void Tst_AssessTest (void)
|
|||
/* Get test exam code from form */
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0)
|
||||
Lay_WrongTestExit ();
|
||||
Err_WrongTestExit ();
|
||||
|
||||
/* Get number of this test from form */
|
||||
NumTst = Tst_GetParamNumTst ();
|
||||
|
@ -619,7 +620,7 @@ static bool Tst_CheckIfNextTstAllowed (void)
|
|||
TimeNextTestUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error when reading date of next allowed access to test.");
|
||||
Err_ShowErrorAndExit ("Error when reading date of next allowed access to test.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -677,7 +678,7 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void)
|
|||
NumExamsGeneratedByMe = 0;
|
||||
}
|
||||
else
|
||||
Lay_ShowErrorAndExit ("Error when getting number of hits to test.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of hits to test.");
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -818,7 +819,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible)
|
|||
/* Convert the stem, that is in HTML, to rigorous HTML */
|
||||
StemLength = strlen (Stem) * Str_MAX_BYTES_PER_CHAR;
|
||||
if ((StemRigorousHTML = malloc (StemLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (StemRigorousHTML,Stem,StemLength);
|
||||
|
||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||
|
@ -917,7 +918,7 @@ void Tst_WriteQstFeedback (const char *Feedback,const char *ClassFeedback)
|
|||
/***** Convert the feedback, that is in HTML, to rigorous HTML *****/
|
||||
FeedbackLength = strlen (Feedback) * Str_MAX_BYTES_PER_CHAR;
|
||||
if ((FeedbackRigorousHTML = malloc (FeedbackLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (FeedbackRigorousHTML,Feedback,FeedbackLength);
|
||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||
FeedbackRigorousHTML,FeedbackLength,false);
|
||||
|
@ -1753,7 +1754,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
|||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Select questions *****/
|
||||
/* Start query */
|
||||
|
@ -1794,7 +1795,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
|||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tag_MAX_BYTES_TAG);
|
||||
LengthQuery = LengthQuery + 35 + strlen (TagText) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 256)
|
||||
Lay_ShowErrorAndExit ("Query size exceed.");
|
||||
Err_ShowErrorAndExit ("Query size exceed.");
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||
" AND (tst_tags.TagTxt='",
|
||||
|
@ -1818,7 +1819,7 @@ static void Tst_GetQuestions (struct Tst_Test *Test,MYSQL_RES **mysql_res)
|
|||
AnsType = Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr);
|
||||
LengthQuery = LengthQuery + 35 + strlen (Tst_StrAnswerTypesDB[AnsType]) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 256)
|
||||
Lay_ShowErrorAndExit ("Query size exceed.");
|
||||
Err_ShowErrorAndExit ("Query size exceed.");
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||
" AND (tst_questions.AnsType='",
|
||||
|
@ -1894,11 +1895,11 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
/***** Trivial check: number of questions *****/
|
||||
if (Test->NumQsts == 0 ||
|
||||
Test->NumQsts > TstCfg_MAX_QUESTIONS_PER_TEST)
|
||||
Lay_ShowErrorAndExit ("Wrong number of questions.");
|
||||
Err_ShowErrorAndExit ("Wrong number of questions.");
|
||||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (Tst_MAX_BYTES_QUERY_TEST + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Select questions without hidden tags *****/
|
||||
/* Start query */
|
||||
|
@ -1935,7 +1936,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tag_MAX_BYTES_TAG);
|
||||
LengthQuery = LengthQuery + 35 + strlen (TagText) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 128)
|
||||
Lay_ShowErrorAndExit ("Query size exceed.");
|
||||
Err_ShowErrorAndExit ("Query size exceed.");
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||
" AND (tst_tags.TagTxt='",
|
||||
|
@ -1959,7 +1960,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
AnswerType = Tst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr);
|
||||
LengthQuery = LengthQuery + 35 + strlen (Tst_StrAnswerTypesDB[AnswerType]) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_TEST - 128)
|
||||
Lay_ShowErrorAndExit ("Query size exceed.");
|
||||
Err_ShowErrorAndExit ("Query size exceed.");
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||
" AND (tst_questions.AnsType='",
|
||||
|
@ -2000,7 +2001,7 @@ static void Tst_GetQuestionsForNewTestFromDB (struct Tst_Test *Test,
|
|||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_ShowErrorAndExit ("Wrong code of question.");
|
||||
Err_ShowErrorAndExit ("Wrong code of question.");
|
||||
|
||||
/* Get answer type (row[1]) */
|
||||
AnswerType = Tst_ConvertFromStrAnsTypDBToAnsTyp (row[1]);
|
||||
|
@ -2086,7 +2087,7 @@ void Tst_GenerateChoiceIndexes (struct TstPrn_PrintedQuestion *PrintedQuestion,
|
|||
else
|
||||
ErrorInIndex = true;
|
||||
if (ErrorInIndex)
|
||||
Lay_ShowErrorAndExit ("Wrong index of answer.");
|
||||
Err_ShowErrorAndExit ("Wrong index of answer.");
|
||||
|
||||
snprintf (StrInd,sizeof (StrInd),NumOpt ? ",%u" :
|
||||
"%u",Index);
|
||||
|
@ -2169,7 +2170,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)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/***** Write question row *****/
|
||||
Tst_WriteQuestionListing (Test,NumQst);
|
||||
|
@ -2290,7 +2291,7 @@ static void Tst_WriteQuestionListing (struct Tst_Test *Test,unsigned NumQst)
|
|||
|
||||
/* Date (row[0] has the UTC date-time) */
|
||||
if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\"",
|
||||
Id,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Test->Question.EditTime,
|
||||
|
@ -2432,7 +2433,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)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question row */
|
||||
Tst_WriteQuestionRowForSelection (NumQst,&Question);
|
||||
|
@ -2517,7 +2518,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)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question row */
|
||||
Tst_WriteQuestionRowForSelection (NumQst,&Question);
|
||||
|
@ -2593,7 +2594,7 @@ static void Tst_WriteQuestionRowForSelection (unsigned NumQst,
|
|||
|
||||
/* Write the date (row[0] has the UTC date-time) */
|
||||
if (asprintf (&Id,"tst_date_%u",++UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"DAT_SMALL CT COLOR%u\">",
|
||||
Id,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Question->EditTime,
|
||||
|
@ -2903,7 +2904,7 @@ void Tst_WriteParamQstCod (unsigned NumQst,long QstCod)
|
|||
void Tst_CheckIfNumberOfAnswersIsOne (const struct Tst_Question *Question)
|
||||
{
|
||||
if (Question->Answer.NumOptions != 1)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2985,7 +2986,7 @@ static bool Tst_GetParamsTst (struct Tst_Test *Test,
|
|||
|
||||
/* Get the tags */
|
||||
if ((Test->Tags.List = malloc (Tag_MAX_BYTES_TAGS_LIST + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Par_GetParMultiToText ("ChkTag",Test->Tags.List,Tag_MAX_BYTES_TAGS_LIST);
|
||||
|
||||
/* Check number of tags selected */
|
||||
|
@ -3148,7 +3149,7 @@ unsigned Tst_CountNumQuestionsInList (const char *ListQuestions)
|
|||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
||||
if (sscanf (LongStr,"%ld",&QstCod) != 1)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
NumQuestions++;
|
||||
}
|
||||
return NumQuestions;
|
||||
|
@ -3519,7 +3520,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
|
|||
"",
|
||||
NumOpt);
|
||||
if (asprintf (&Title,"%s %c)",Txt_Expand,'a' + (char) NumOpt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ico_PutIcon ("caret-right.svg",Title,"ICO16x16");
|
||||
free (Title);
|
||||
HTM_A_End ();
|
||||
|
@ -3532,7 +3533,7 @@ static void Tst_PutFormEditOneQst (struct Tst_Question *Question)
|
|||
" style=\"display:none;\"", // Answer does not have content ==> Hide icon
|
||||
NumOpt);
|
||||
if (asprintf (&Title,"%s %c)",Txt_Contract,'a' + (char) NumOpt) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Ico_PutIcon ("caret-down.svg",Title,"ICO16x16");
|
||||
free (Title);
|
||||
HTM_A_End ();
|
||||
|
@ -3658,11 +3659,11 @@ void Tst_QstConstructor (struct Tst_Question *Question)
|
|||
|
||||
/***** Allocate memory for stem and feedback *****/
|
||||
if ((Question->Stem = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Question->Stem[0] = '\0';
|
||||
|
||||
if ((Question->Feedback = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Question->Feedback[0] = '\0';
|
||||
|
||||
/***** Initialize answers *****/
|
||||
|
@ -3944,7 +3945,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
break;
|
||||
case Tst_ANS_FLOAT:
|
||||
if (Question->Answer.NumOptions != 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
Question->Answer.FloatingPoint[NumOpt] = Str_GetDoubleFromStr (row[1]);
|
||||
break;
|
||||
case Tst_ANS_TRUE_FALSE:
|
||||
|
@ -3956,7 +3957,7 @@ bool Tst_GetQstDataFromDB (struct Tst_Question *Question)
|
|||
case Tst_ANS_TEXT:
|
||||
/* Check number of options */
|
||||
if (Question->Answer.NumOptions > Tst_MAX_OPTIONS_PER_QUESTION)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/* Allocate space for text and feedback */
|
||||
if (!Tst_AllocateTextChoiceAnswer (Question,NumOpt))
|
||||
|
@ -4067,9 +4068,9 @@ static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *Unsigned
|
|||
unsigned AnsType;
|
||||
|
||||
if (sscanf (UnsignedStr,"%u",&AnsType) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong type of answer. 2");
|
||||
Err_ShowErrorAndExit ("Wrong type of answer. 2");
|
||||
if (AnsType >= Tst_NUM_ANS_TYPES)
|
||||
Lay_ShowErrorAndExit ("Wrong type of answer. 3");
|
||||
Err_ShowErrorAndExit ("Wrong type of answer. 3");
|
||||
return (Tst_AnswerType_t) AnsType;
|
||||
}
|
||||
|
||||
|
@ -4142,7 +4143,7 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
|
|||
Tst_NUM_ANS_TYPES - 1,
|
||||
(unsigned long) Tst_ANS_UNKNOWN);
|
||||
if (Question->Answer.Type == Tst_ANS_UNKNOWN)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Get question tags *****/
|
||||
for (NumTag = 0;
|
||||
|
@ -4279,9 +4280,9 @@ static void Tst_GetQstFromForm (struct Tst_Question *Question)
|
|||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
if (sscanf (UnsignedStr,"%u",&NumCorrectAns) != 1)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
if (NumCorrectAns >= Tst_MAX_OPTIONS_PER_QUESTION)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
Question->Answer.Options[NumCorrectAns].Correct = true;
|
||||
}
|
||||
}
|
||||
|
@ -4530,7 +4531,7 @@ bool Tst_CheckIfQuestionExistsInDB (struct Tst_Question *Question)
|
|||
{
|
||||
/* Get question code */
|
||||
if ((Question->QstCod = DB_GetNextCode (mysql_res_qst)) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get answers from this question */
|
||||
NumOptsExistingQstInDB =
|
||||
|
@ -4714,7 +4715,7 @@ void Tst_RemoveSelectedQsts (void)
|
|||
/* Get question code (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if ((QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Remove test question from database */
|
||||
Tst_RemoveOneQstFromDB (Gbl.Hierarchy.Crs.CrsCod,QstCod);
|
||||
|
@ -4759,7 +4760,7 @@ void Tst_RequestRemoveOneQst (void)
|
|||
/* Get the question code */
|
||||
Test.Question.QstCod = Tst_GetParamQstCod ();
|
||||
if (Test.Question.QstCod <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get a parameter that indicates whether it's necessary
|
||||
to continue listing the rest of questions */
|
||||
|
@ -4768,7 +4769,7 @@ void Tst_RequestRemoveOneQst (void)
|
|||
/* Get other parameters */
|
||||
if (!EditingOnlyThisQst)
|
||||
if (!Tst_GetParamsTst (&Test,Tst_EDIT_TEST))
|
||||
Lay_ShowErrorAndExit ("Wrong test parameters.");
|
||||
Err_ShowErrorAndExit ("Wrong test parameters.");
|
||||
|
||||
/***** Show question and button to remove question *****/
|
||||
if (EditingOnlyThisQst)
|
||||
|
@ -4820,7 +4821,7 @@ void Tst_RemoveOneQst (void)
|
|||
/***** Get the question code *****/
|
||||
QstCod = Tst_GetParamQstCod ();
|
||||
if (QstCod <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/***** Get a parameter that indicates whether it's necessary
|
||||
to continue listing the rest of questions ******/
|
||||
|
@ -4862,7 +4863,7 @@ static void Tst_RemoveOneQstFromDB (long CrsCod,long QstCod)
|
|||
CrsCod);
|
||||
|
||||
if (!mysql_affected_rows (&Gbl.mysql))
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -4883,7 +4884,7 @@ void Tst_ChangeShuffleQst (void)
|
|||
/***** Get the question code *****/
|
||||
Test.Question.QstCod = Tst_GetParamQstCod ();
|
||||
if (Test.Question.QstCod <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/***** Get a parameter that indicates whether it's necessary to continue listing the rest of questions ******/
|
||||
EditingOnlyThisQst = Par_GetParToBool ("OnlyThisQst");
|
||||
|
@ -5503,23 +5504,23 @@ static unsigned Tst_GetNumTstQuestions (Hie_Lvl_Level_t Scope,Tst_AnswerType_t A
|
|||
Tst_StrAnswerTypesDB[AnsType]);
|
||||
break;
|
||||
default:
|
||||
Lay_WrongScopeExit ();
|
||||
Err_WrongScopeExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
/***** Get number of questions *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%u",&(Stats->NumQsts)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting number of test questions.");
|
||||
Err_ShowErrorAndExit ("Error when getting number of test questions.");
|
||||
|
||||
if (Stats->NumQsts)
|
||||
{
|
||||
if (sscanf (row[1],"%lu",&(Stats->NumHits)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting total number of hits in test questions.");
|
||||
Err_ShowErrorAndExit ("Error when getting total number of hits in test questions.");
|
||||
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[2],"%lf",&(Stats->TotalScore)) != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting total score in test questions.");
|
||||
Err_ShowErrorAndExit ("Error when getting total score in test questions.");
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
else
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "swad_box.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -202,7 +203,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
|
|||
Gbl.FileBrowser.TmpPubDir.L,
|
||||
Gbl.FileBrowser.TmpPubDir.R);
|
||||
if ((FileXML = fopen (PathPubFile,"wb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open target file.");
|
||||
Err_ShowErrorAndExit ("Can not open target file.");
|
||||
|
||||
/***** Start XML file *****/
|
||||
XML_WriteStartFile (FileXML,"test",false);
|
||||
|
@ -219,7 +220,7 @@ void TsI_CreateXML (unsigned NumQsts,MYSQL_RES *mysql_res)
|
|||
/* Get question code (row[0]) */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if ((Question.QstCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
TsI_ExportQuestion (&Question,FileXML);
|
||||
|
||||
|
@ -445,7 +446,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
|
|||
|
||||
/***** Open file *****/
|
||||
if ((FileXML = fopen (FileNameXML,"rb")) == NULL)
|
||||
Lay_ShowErrorAndExit ("Can not open XML file.");
|
||||
Err_ShowErrorAndExit ("Can not open XML file.");
|
||||
|
||||
/***** Compute file size *****/
|
||||
fseek (FileXML,0L,SEEK_END);
|
||||
|
@ -454,7 +455,7 @@ static void TsI_ReadQuestionsFromXMLFileAndStoreInDB (const char *FileNameXML)
|
|||
|
||||
/***** Allocate memory for XML buffer *****/
|
||||
if ((XMLBuffer = malloc (FileSize + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
else
|
||||
{
|
||||
/***** Read file contents into XML buffer *****/
|
||||
|
@ -646,12 +647,12 @@ static void TsI_ImportQuestionsFromXMLBuffer (const char *XMLBuffer)
|
|||
Question.QstCod = -1L;
|
||||
Tst_InsertOrUpdateQstTagsAnsIntoDB (&Question);
|
||||
if (Question.QstCod <= 0)
|
||||
Lay_ShowErrorAndExit ("Can not create question.");
|
||||
Err_ShowErrorAndExit ("Can not create question.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Answer type not found
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Destroy test question *****/
|
||||
Tst_QstDestructor (&Question);
|
||||
|
@ -687,7 +688,7 @@ static Tst_AnswerType_t TsI_ConvertFromStrAnsTypXMLToAnsTyp (const char *StrAnsT
|
|||
if (!strcasecmp (StrAnsTypeXML,Tst_StrAnswerTypesXML[AnsType]))
|
||||
return AnsType;
|
||||
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
return (Tst_AnswerType_t) 0; // Not reached
|
||||
}
|
||||
|
||||
|
@ -1001,7 +1002,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
|||
AnswerTextLength = strlen (Question->Answer.Options[NumOpt].Text) *
|
||||
Str_MAX_BYTES_PER_CHAR;
|
||||
if ((AnswerText = malloc (AnswerTextLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (AnswerText,Question->Answer.Options[NumOpt].Text,
|
||||
AnswerTextLength);
|
||||
Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML,
|
||||
|
@ -1016,7 +1017,7 @@ static void TsI_WriteRowImportedQst (struct XMLElement *StemElem,
|
|||
AnswerFeedbackLength = strlen (Question->Answer.Options[NumOpt].Feedback) *
|
||||
Str_MAX_BYTES_PER_CHAR;
|
||||
if ((AnswerFeedback = malloc (AnswerFeedbackLength + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
Str_Copy (AnswerFeedback,
|
||||
Question->Answer.Options[NumOpt].Feedback,
|
||||
AnswerFeedbackLength);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "swad_action.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_HTML.h"
|
||||
|
@ -309,7 +310,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
|||
|
||||
/* Show question */
|
||||
if (!Tst_GetQstDataFromDB (&Question)) // Question exists
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Write question and answers */
|
||||
TstPrn_WriteQstAndAnsToFill (&Print->PrintedQuestions[NumQst],NumQst,&Question);
|
||||
|
@ -890,7 +891,7 @@ static void TstPrn_GetCorrectIntAnswerFromDB (struct Tst_Question *Question)
|
|||
/***** Get correct answer *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
if (sscanf (row[0],"%ld",&Question->Answer.Integer) != 1)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
@ -913,7 +914,7 @@ static void TstPrn_GetCorrectFltAnswerFromDB (struct Tst_Question *Question)
|
|||
|
||||
/***** Check if number of rows is correct *****/
|
||||
if (Question->Answer.NumOptions != 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Get float range *****/
|
||||
for (NumOpt = 0;
|
||||
|
@ -1257,10 +1258,10 @@ void TstPrn_GetIndexesFromStr (const char StrIndexesOneQst[Tst_MAX_BYTES_INDEXES
|
|||
Par_GetNextStrUntilComma (&Ptr,StrOneIndex,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
|
||||
if (sscanf (StrOneIndex,"%u",&(Indexes[NumOpt])) != 1)
|
||||
Lay_WrongAnswerIndexExit ();
|
||||
Err_WrongAnswerIndexExit ();
|
||||
|
||||
if (Indexes[NumOpt] >= Tst_MAX_OPTIONS_PER_QUESTION)
|
||||
Lay_WrongAnswerIndexExit ();
|
||||
Err_WrongAnswerIndexExit ();
|
||||
}
|
||||
|
||||
/***** Initialize remaining to 0 *****/
|
||||
|
@ -1296,10 +1297,10 @@ void TstPrn_GetAnswersFromStr (const char StrAnswersOneQst[Tst_MAX_BYTES_ANSWERS
|
|||
Par_GetNextStrUntilComma (&Ptr,StrOneAnswer,Cns_MAX_DECIMAL_DIGITS_UINT);
|
||||
|
||||
if (sscanf (StrOneAnswer,"%u",&AnsUsr) != 1)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
if (AnsUsr >= Tst_MAX_OPTIONS_PER_QUESTION)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
UsrAnswers[AnsUsr] = true;
|
||||
}
|
||||
|
@ -1454,7 +1455,7 @@ static void TstPrn_WriteFltAnsPrint (struct UsrData *UsrDat,
|
|||
|
||||
/***** Check if number of rows is correct *****/
|
||||
if (Question->Answer.NumOptions != 2)
|
||||
Lay_WrongAnswerExit ();
|
||||
Err_WrongAnswerExit ();
|
||||
|
||||
/***** Header with the title of each column *****/
|
||||
HTM_TABLE_BeginPadding (2);
|
||||
|
@ -2104,7 +2105,7 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
|||
|
||||
/* Get print code (row[0]) */
|
||||
if ((Print.PrnCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongTestExit ();
|
||||
Err_WrongTestExit ();
|
||||
|
||||
/* Get print data */
|
||||
TstPrn_GetPrintDataByPrnCod (&Print);
|
||||
|
@ -2124,7 +2125,7 @@ static void TstPrn_ShowUsrPrints (struct UsrData *UsrDat)
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"tst_date_%u_%u",(unsigned) StartEndTime,UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
HTM_TD_Begin ("id=\"%s\" class=\"%s LT COLOR%u\"",
|
||||
Id,ClassDat,Gbl.RowEvenOdd);
|
||||
Dat_WriteLocalDateHMSFromUTC (Id,Print.TimeUTC[StartEndTime],
|
||||
|
@ -2399,7 +2400,7 @@ void TstPrn_ShowOnePrint (void)
|
|||
/***** Get the code of the test *****/
|
||||
TstPrn_ResetPrint (&Print);
|
||||
if ((Print.PrnCod = TstPrn_GetParamPrnCod ()) <= 0)
|
||||
Lay_WrongTestExit ();
|
||||
Err_WrongTestExit ();
|
||||
|
||||
/***** Get test exam data *****/
|
||||
TstPrn_GetPrintDataByPrnCod (&Print);
|
||||
|
@ -2431,9 +2432,9 @@ void TstPrn_ShowOnePrint (void)
|
|||
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,
|
||||
Usr_DONT_GET_PREFS,
|
||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
Lay_WrongUserExit ();
|
||||
Err_WrongUserExit ();
|
||||
if (!Usr_CheckIfICanViewTstExaMchResult (&Gbl.Usrs.Other.UsrDat))
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
|
||||
/* User */
|
||||
HTM_TR_Begin (NULL);
|
||||
|
@ -2461,7 +2462,7 @@ void TstPrn_ShowOnePrint (void)
|
|||
StartEndTime++)
|
||||
{
|
||||
if (asprintf (&Id,"tst_date_%u",(unsigned) StartEndTime) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
@ -2573,7 +2574,7 @@ void TstPrn_ShowOnePrint (void)
|
|||
Box_BoxEnd ();
|
||||
}
|
||||
else // I am not allowed to view this test exam
|
||||
Lay_NoPermissionExit ();
|
||||
Err_NoPermissionExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2782,12 +2783,12 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
|||
|
||||
/* Get question code (row[0]) */
|
||||
if ((Print->PrintedQuestions[NumQst].QstCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
||||
Lay_WrongQuestionExit ();
|
||||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get score (row[1]) */
|
||||
Str_SetDecimalPointToUS (); // To get the decimal point as a dot
|
||||
if (sscanf (row[1],"%lf",&Print->PrintedQuestions[NumQst].Score) != 1)
|
||||
Lay_ShowErrorAndExit ("Wrong question score.");
|
||||
Err_ShowErrorAndExit ("Wrong question score.");
|
||||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
|
||||
/* Get indexes for this question (row[2]) */
|
||||
|
@ -2803,7 +2804,7 @@ void TstPrn_GetPrintQuestionsFromDB (struct TstPrn_Print *Print)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
if (NumQsts != Print->NumQsts.All)
|
||||
Lay_WrongExamExit ();
|
||||
Err_WrongExamExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For malloc, free
|
||||
|
||||
#include "swad_error.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_test_visibility.h"
|
||||
|
@ -94,7 +95,7 @@ void TstVis_ShowVisibilityIcons (unsigned SelectedVisibility,bool Hidden)
|
|||
if (asprintf (&Title,"%s: %s",
|
||||
Txt_TST_STR_VISIBILITY[Visibility],
|
||||
Txt_TST_HIDDEN_VISIBLE[ItemVisible]) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
if (ItemVisible && !Hidden)
|
||||
Ico_PutIconOn (Icons[Visibility][ItemVisible],Title);
|
||||
else
|
||||
|
@ -162,7 +163,7 @@ unsigned TstVis_GetVisibilityFromForm (void)
|
|||
/***** Allocate memory for list of attendance events selected *****/
|
||||
MaxSizeListVisibilitySelected = TstVis_NUM_ITEMS_VISIBILITY * (Cns_MAX_DECIMAL_DIGITS_UINT + 1);
|
||||
if ((StrVisibilitySelected = malloc (MaxSizeListVisibilitySelected + 1)) == NULL)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Get parameter multiple with list of visibility items selected *****/
|
||||
Par_GetParMultiToText ("Visibility",StrVisibilitySelected,MaxSizeListVisibilitySelected);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For free
|
||||
|
||||
#include "swad_error.h"
|
||||
#include "swad_forum.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_message.h"
|
||||
|
@ -496,7 +497,7 @@ static void Tml_Com_PutIconToToggleComms (const char *UniqueId,
|
|||
|
||||
/***** Build onclick text *****/
|
||||
if (asprintf (&OnClick,"toggleComments('%s')",UniqueId) < 0)
|
||||
Lay_NotEnoughMemoryExit ();
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Link to toggle on/off some divs *****/
|
||||
HTM_BUTTON_BUTTON_Begin (Text,The_ClassFormLinkInBox[Gbl.Prefs.Theme],OnClick);
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
/*****************************************************************************/
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_error.h"
|
||||
#include "swad_follow.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_timeline.h"
|
||||
|
@ -743,7 +744,7 @@ void Tml_DB_CreateSubQueryPublishers (const struct Tml_Timeline *Timeline,
|
|||
SubQueries->Publishers[0] = '\0';
|
||||
break;
|
||||
default:
|
||||
Lay_WrongWhoExit ();
|
||||
Err_WrongWhoExit ();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue