mirror of https://github.com/acanas/swad-core.git
Version 22.78.13: Mar 23, 2023 Code refactoring in rooms.
This commit is contained in:
parent
fbe759d653
commit
54bec4644d
|
@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
|
||||||
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 22.78.12 (2023-03-23)"
|
#define Log_PLATFORM_VERSION "SWAD 22.78.13 (2023-03-23)"
|
||||||
#define CSS_FILE "swad22.57.1.css"
|
#define CSS_FILE "swad22.57.1.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.78.13: Mar 23, 2023 Code refactoring in rooms. (337641 lines)
|
||||||
Version 22.78.12: Mar 23, 2023 Code refactoring in plugins. (337651 lines)
|
Version 22.78.12: Mar 23, 2023 Code refactoring in plugins. (337651 lines)
|
||||||
Version 22.78.11: Mar 23, 2023 Code refactoring in places. (337652 lines)
|
Version 22.78.11: Mar 23, 2023 Code refactoring in places. (337652 lines)
|
||||||
Version 22.78.10: Mar 23, 2023 Code refactoring in notices. (337650 lines)
|
Version 22.78.10: Mar 23, 2023 Code refactoring in notices. (337650 lines)
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ static void ExaSet_CopyQstFromBankToExamSet (const struct ExaSet_Set *Set,long Q
|
||||||
Question.QstCod = QstCod;
|
Question.QstCod = QstCod;
|
||||||
|
|
||||||
/***** Get data of question from database *****/
|
/***** Get data of question from database *****/
|
||||||
if (Qst_GetQstDataFromDB (&Question))
|
if (Qst_GetQstDataByCod (&Question))
|
||||||
{
|
{
|
||||||
/***** Clone media *****/
|
/***** Clone media *****/
|
||||||
CloneMedCod = Med_CloneMedia (&Question.Media);
|
CloneMedCod = Med_CloneMedia (&Question.Media);
|
||||||
|
|
|
@ -1756,7 +1756,7 @@ static void Gam_ListOneOrMoreQuestionsForEdition (struct Gam_Games *Games,
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Question *****/
|
/***** Question *****/
|
||||||
QuestionExists = Qst_GetQstDataFromDB (&Question);
|
QuestionExists = Qst_GetQstDataByCod (&Question);
|
||||||
Qst_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor);
|
Qst_ListQuestionForEdition (&Question,QstInd,QuestionExists,Anchor);
|
||||||
|
|
||||||
/***** End row *****/
|
/***** End row *****/
|
||||||
|
|
|
@ -2789,7 +2789,7 @@ static void Mch_ShowQuestionAndAnswersTch (const struct Mch_Match *Match)
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Get data of question from database *****/
|
/***** Get data of question from database *****/
|
||||||
if (Qst_GetQstDataFromDB (&Question))
|
if (Qst_GetQstDataByCod (&Question))
|
||||||
{
|
{
|
||||||
/***** Show question *****/
|
/***** Show question *****/
|
||||||
/* Check answer type */
|
/* Check answer type */
|
||||||
|
|
|
@ -225,7 +225,7 @@ unsigned Prg_DB_GetListItems (MYSQL_RES **mysql_res)
|
||||||
"Hidden" // row[3]
|
"Hidden" // row[3]
|
||||||
" FROM prg_items"
|
" FROM prg_items"
|
||||||
" WHERE CrsCod=%ld"
|
" WHERE CrsCod=%ld"
|
||||||
"%s"
|
"%s"
|
||||||
" ORDER BY ItmInd",
|
" ORDER BY ItmInd",
|
||||||
Gbl.Hierarchy.Crs.CrsCod,
|
Gbl.Hierarchy.Crs.CrsCod,
|
||||||
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged]);
|
HiddenSubQuery[Gbl.Usrs.Me.Role.Logged]);
|
||||||
|
|
|
@ -374,8 +374,7 @@ static void PrgRsc_GetResourceDataFromRow (MYSQL_RES *mysql_res,
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get data of item resource from database *****/
|
/***** Get row *****/
|
||||||
/* Get row */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
/*
|
/*
|
||||||
ItmCod row[0]
|
ItmCod row[0]
|
||||||
|
@ -386,21 +385,21 @@ static void PrgRsc_GetResourceDataFromRow (MYSQL_RES *mysql_res,
|
||||||
Cod row[5]
|
Cod row[5]
|
||||||
Title row[6]
|
Title row[6]
|
||||||
*/
|
*/
|
||||||
/* Get code of the program item (row[0]) */
|
/***** Get code of the program item (row[0]) *****/
|
||||||
Item->Hierarchy.ItmCod = Str_ConvertStrCodToLongCod (row[0]);
|
Item->Hierarchy.ItmCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||||
|
|
||||||
/* Get code and index of the item resource (row[1], row[2]) */
|
/***** Get code and index of the item resource (row[1], row[2]) *****/
|
||||||
Item->Resource.Hierarchy.RscCod = Str_ConvertStrCodToLongCod (row[1]);
|
Item->Resource.Hierarchy.RscCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
Item->Resource.Hierarchy.RscInd = Str_ConvertStrToUnsigned (row[2]);
|
Item->Resource.Hierarchy.RscInd = Str_ConvertStrToUnsigned (row[2]);
|
||||||
|
|
||||||
/* Get whether the program item is hidden (row(3)) */
|
/***** Get whether the program item is hidden (row(3)) *****/
|
||||||
Item->Resource.Hierarchy.Hidden = (row[3][0] == 'Y');
|
Item->Resource.Hierarchy.Hidden = (row[3][0] == 'Y');
|
||||||
|
|
||||||
/* Get link type and code (row[4], row[5]) */
|
/***** Get link type and code (row[4], row[5]) *****/
|
||||||
Item->Resource.Link.Type = PrgRsc_GetTypeFromString (row[4]);
|
Item->Resource.Link.Type = PrgRsc_GetTypeFromString (row[4]);
|
||||||
Item->Resource.Link.Cod = Str_ConvertStrCodToLongCod (row[5]);
|
Item->Resource.Link.Cod = Str_ConvertStrCodToLongCod (row[5]);
|
||||||
|
|
||||||
/* Get the title of the item resource (row[6]) */
|
/***** Get the title of the item resource (row[6]) *****/
|
||||||
Str_Copy (Item->Resource.Title,row[6],sizeof (Item->Resource.Title) - 1);
|
Str_Copy (Item->Resource.Title,row[6],sizeof (Item->Resource.Title) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,17 +1121,16 @@ static void PrgRsc_GetLinkDataFromRow (MYSQL_RES *mysql_res,
|
||||||
{
|
{
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
|
||||||
/***** Get data of item resource from database *****/
|
/***** Get row *****/
|
||||||
/* Get row */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
/*
|
/*
|
||||||
Type row[0]
|
Type row[0]
|
||||||
Cod row[1]
|
Cod row[1]
|
||||||
*/
|
*/
|
||||||
/* Get type (row[0]) */
|
/***** Get type (row[0]) *****/
|
||||||
Link->Type = PrgRsc_GetTypeFromString (row[0]);
|
Link->Type = PrgRsc_GetTypeFromString (row[0]);
|
||||||
|
|
||||||
/* Get code (row[1]) */
|
/***** Get code (row[1]) *****/
|
||||||
Link->Cod = Str_ConvertStrCodToLongCod (row[1]);
|
Link->Cod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -952,7 +952,7 @@ void Qst_WriteQuestionListing (struct Qst_Questions *Questions,unsigned QstInd)
|
||||||
char *Id;
|
char *Id;
|
||||||
|
|
||||||
/***** Get and show question data *****/
|
/***** Get and show question data *****/
|
||||||
if (Qst_GetQstDataFromDB (&Questions->Question))
|
if (Qst_GetQstDataByCod (&Questions->Question))
|
||||||
{
|
{
|
||||||
/***** Begin table row *****/
|
/***** Begin table row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -1267,7 +1267,7 @@ void Qst_WriteQuestionRowForSelection (unsigned QstInd,
|
||||||
char *Id;
|
char *Id;
|
||||||
|
|
||||||
/***** Get and show questvoidion data *****/
|
/***** Get and show questvoidion data *****/
|
||||||
if (Qst_GetQstDataFromDB (Question))
|
if (Qst_GetQstDataByCod (Question))
|
||||||
{
|
{
|
||||||
/***** Begin table row *****/
|
/***** Begin table row *****/
|
||||||
HTM_TR_Begin (NULL);
|
HTM_TR_Begin (NULL);
|
||||||
|
@ -1810,7 +1810,7 @@ void Qst_ShowFormEditOneQst (void)
|
||||||
if (Question.QstCod <= 0) // New question
|
if (Question.QstCod <= 0) // New question
|
||||||
PutFormToEditQuestion = true;
|
PutFormToEditQuestion = true;
|
||||||
else
|
else
|
||||||
PutFormToEditQuestion = Qst_GetQstDataFromDB (&Question);
|
PutFormToEditQuestion = Qst_GetQstDataByCod (&Question);
|
||||||
|
|
||||||
/***** Put form to edit question *****/
|
/***** Put form to edit question *****/
|
||||||
if (PutFormToEditQuestion)
|
if (PutFormToEditQuestion)
|
||||||
|
@ -2471,10 +2471,10 @@ void Qst_FreeMediaOfQuestion (struct Qst_Question *Question)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get data of a question from database *********************/
|
/********************* Get question data using its code **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
bool Qst_GetQstDataByCod (struct Qst_Question *Question)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
|
@ -2484,7 +2484,7 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
||||||
unsigned NumOpt;
|
unsigned NumOpt;
|
||||||
|
|
||||||
/***** Get question data from database *****/
|
/***** Get question data from database *****/
|
||||||
if ((QuestionExists = (Qst_DB_GetQstData (&mysql_res,Question->QstCod) != 0)))
|
if ((QuestionExists = (Qst_DB_GetQstDataByCod (&mysql_res,Question->QstCod) != 0)))
|
||||||
{
|
{
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
|
|
@ -236,7 +236,7 @@ void Qst_FreeTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt);
|
||||||
void Qst_ResetMediaOfQuestion (struct Qst_Question *Question);
|
void Qst_ResetMediaOfQuestion (struct Qst_Question *Question);
|
||||||
void Qst_FreeMediaOfQuestion (struct Qst_Question *Question);
|
void Qst_FreeMediaOfQuestion (struct Qst_Question *Question);
|
||||||
|
|
||||||
bool Qst_GetQstDataFromDB (struct Qst_Question *Question);
|
bool Qst_GetQstDataByCod (struct Qst_Question *Question);
|
||||||
long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt);
|
long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt);
|
||||||
void Qst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
|
void Qst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
|
||||||
struct Med_Media *Media);
|
struct Med_Media *Media);
|
||||||
|
|
|
@ -1220,7 +1220,7 @@ unsigned Qst_DB_GetRecentAnswers (MYSQL_RES **mysql_res,
|
||||||
/****************** Get data of a question from database *********************/
|
/****************** Get data of a question from database *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
unsigned Qst_DB_GetQstData (MYSQL_RES **mysql_res,long QstCod)
|
unsigned Qst_DB_GetQstDataByCod (MYSQL_RES **mysql_res,long QstCod)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get a question",
|
DB_QuerySELECT (mysql_res,"can not get a question",
|
||||||
|
|
|
@ -58,7 +58,7 @@ unsigned Qst_DB_GetRecentQuestions (MYSQL_RES **mysql_res,
|
||||||
unsigned Qst_DB_GetRecentAnswers (MYSQL_RES **mysql_res,
|
unsigned Qst_DB_GetRecentAnswers (MYSQL_RES **mysql_res,
|
||||||
long CrsCod,time_t BeginTime);
|
long CrsCod,time_t BeginTime);
|
||||||
|
|
||||||
unsigned Qst_DB_GetQstData (MYSQL_RES **mysql_res,long QstCod);
|
unsigned Qst_DB_GetQstDataByCod (MYSQL_RES **mysql_res,long QstCod);
|
||||||
Qst_AnswerType_t Qst_DB_GetQstAnswerType (long QstCod);
|
Qst_AnswerType_t Qst_DB_GetQstAnswerType (long QstCod);
|
||||||
long Qst_DB_GetQstMedCod (long CrsCod,long QstCod);
|
long Qst_DB_GetQstMedCod (long CrsCod,long QstCod);
|
||||||
unsigned Qst_DB_GetQstCodFromTypeAnsStem (MYSQL_RES **mysql_res,
|
unsigned Qst_DB_GetQstCodFromTypeAnsStem (MYSQL_RES **mysql_res,
|
||||||
|
|
|
@ -234,7 +234,7 @@ static void QstImp_ExportQuestion (struct Qst_Question *Question,FILE *FileXML)
|
||||||
extern const char *Qst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES];
|
extern const char *Qst_StrAnswerTypesXML[Qst_NUM_ANS_TYPES];
|
||||||
extern const char *Txt_NEW_LINE;
|
extern const char *Txt_NEW_LINE;
|
||||||
|
|
||||||
if (Qst_GetQstDataFromDB (Question))
|
if (Qst_GetQstDataByCod (Question))
|
||||||
{
|
{
|
||||||
/***** Write the answer type *****/
|
/***** Write the answer type *****/
|
||||||
fprintf (FileXML,"<question type=\"%s\">%s",
|
fprintf (FileXML,"<question type=\"%s\">%s",
|
||||||
|
|
|
@ -739,7 +739,7 @@ static void Rep_WriteSectionHitsPerAction (struct Rep_Report *Report)
|
||||||
mysql_data_seek (mysql_res,0);
|
mysql_data_seek (mysql_res,0);
|
||||||
|
|
||||||
/***** Write rows *****/
|
/***** Write rows *****/
|
||||||
for (NumHit = 1, NumClicks = 0;
|
for (NumHit = 1, NumClicks = 0;
|
||||||
NumHit <= NumHits;
|
NumHit <= NumHits;
|
||||||
NumHit++)
|
NumHit++)
|
||||||
{
|
{
|
||||||
|
|
120
swad_room.c
120
swad_room.c
|
@ -103,6 +103,9 @@ static void Roo_PutIconToEditRooms (void);
|
||||||
static void Roo_PutIconsEditingRooms (__attribute__((unused)) void *Args);
|
static void Roo_PutIconsEditingRooms (__attribute__((unused)) void *Args);
|
||||||
|
|
||||||
static void Roo_GetRoomDataByCod (struct Roo_Room *Room);
|
static void Roo_GetRoomDataByCod (struct Roo_Room *Room);
|
||||||
|
static void Roo_GetRoomDataFromRow (MYSQL_RES *mysql_res,
|
||||||
|
struct Roo_Room *Room,
|
||||||
|
Roo_WhichData_t WhichData);
|
||||||
static void Roo_GetBldShrtName (struct Roo_Room *Room,const char *BldShrtNameFromDB);
|
static void Roo_GetBldShrtName (struct Roo_Room *Room,const char *BldShrtNameFromDB);
|
||||||
static Roo_RoomType_t Roo_GetTypeFromString (const char *Str);
|
static Roo_RoomType_t Roo_GetTypeFromString (const char *Str);
|
||||||
|
|
||||||
|
@ -489,9 +492,7 @@ void Roo_PutIconToViewRooms (void)
|
||||||
void Roo_GetListRooms (struct Roo_Rooms *Rooms,Roo_WhichData_t WhichData)
|
void Roo_GetListRooms (struct Roo_Rooms *Rooms,Roo_WhichData_t WhichData)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
unsigned NumRoom;
|
unsigned NumRoom;
|
||||||
struct Roo_Room *Room;
|
|
||||||
|
|
||||||
/***** Get rooms from database *****/
|
/***** Get rooms from database *****/
|
||||||
if ((Rooms->Num = Roo_DB_GetListRooms (&mysql_res,Gbl.Hierarchy.Ctr.CtrCod,
|
if ((Rooms->Num = Roo_DB_GetListRooms (&mysql_res,Gbl.Hierarchy.Ctr.CtrCod,
|
||||||
|
@ -506,46 +507,7 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,Roo_WhichData_t WhichData)
|
||||||
for (NumRoom = 0;
|
for (NumRoom = 0;
|
||||||
NumRoom < Rooms->Num;
|
NumRoom < Rooms->Num;
|
||||||
NumRoom++)
|
NumRoom++)
|
||||||
{
|
Roo_GetRoomDataFromRow (mysql_res,&Rooms->Lst[NumRoom],WhichData);
|
||||||
Room = &Rooms->Lst[NumRoom];
|
|
||||||
|
|
||||||
/* Get next room */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get room code (row[0]) */
|
|
||||||
if ((Room->RooCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
|
||||||
Err_WrongRoomExit ();
|
|
||||||
|
|
||||||
switch (WhichData)
|
|
||||||
{
|
|
||||||
case Roo_ALL_DATA:
|
|
||||||
/* Get building code (row[1]) */
|
|
||||||
Room->BldCod = Str_ConvertStrCodToLongCod (row[1]);
|
|
||||||
|
|
||||||
/* Get the short name of the building (row[2]) */
|
|
||||||
Roo_GetBldShrtName (Room,row[2]);
|
|
||||||
|
|
||||||
/* Get floor (row[3]) */
|
|
||||||
Room->Floor = Str_ConvertStrCodToLongCod (row[3]);
|
|
||||||
|
|
||||||
/* Get type (row[4]) */
|
|
||||||
Room->Type = Roo_GetTypeFromString (row[4]);
|
|
||||||
|
|
||||||
/* Get the short (row[5]) and full (row[6]) names of the room */
|
|
||||||
Str_Copy (Room->ShrtName,row[5],sizeof (Room->ShrtName) - 1);
|
|
||||||
Str_Copy (Room->FullName,row[6],sizeof (Room->FullName) - 1);
|
|
||||||
|
|
||||||
/* Get seating capacity in this room (row[7]) */
|
|
||||||
if (sscanf (row[7],"%u",&Room->Capacity) != 1)
|
|
||||||
Room->Capacity = Roo_UNLIMITED_CAPACITY;
|
|
||||||
break;
|
|
||||||
case Roo_ONLY_SHRT_NAME:
|
|
||||||
default:
|
|
||||||
/* Get the short name of the room (row[1]) */
|
|
||||||
Str_Copy (Room->ShrtName,row[1],sizeof (Room->ShrtName) - 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
|
@ -559,7 +521,6 @@ void Roo_GetListRooms (struct Roo_Rooms *Rooms,Roo_WhichData_t WhichData)
|
||||||
static void Roo_GetRoomDataByCod (struct Roo_Room *Room)
|
static void Roo_GetRoomDataByCod (struct Roo_Room *Room)
|
||||||
{
|
{
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
/***** Trivial check *****/
|
/***** Trivial check *****/
|
||||||
if (Room->RooCod <= 0)
|
if (Room->RooCod <= 0)
|
||||||
|
@ -567,35 +528,60 @@ static void Roo_GetRoomDataByCod (struct Roo_Room *Room)
|
||||||
|
|
||||||
/***** Get data of a room from database *****/
|
/***** Get data of a room from database *****/
|
||||||
if (Roo_DB_GetRoomDataByCod (&mysql_res,Room->RooCod)) // Room found...
|
if (Roo_DB_GetRoomDataByCod (&mysql_res,Room->RooCod)) // Room found...
|
||||||
{
|
Roo_GetRoomDataFromRow (mysql_res,Room,Roo_ALL_DATA);
|
||||||
/* Get row */
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Get building code (row[0]) */
|
|
||||||
Room->BldCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
||||||
|
|
||||||
/* Get the short name of the building (row[1]) */
|
|
||||||
Roo_GetBldShrtName (Room,row[1]);
|
|
||||||
|
|
||||||
/* Get floor (row[2]) */
|
|
||||||
Room->Floor = Str_ConvertStrCodToLongCod (row[2]);
|
|
||||||
|
|
||||||
/* Get type (row[3]) */
|
|
||||||
Room->Type = Roo_GetTypeFromString (row[3]);
|
|
||||||
|
|
||||||
/* Get the short (row[4]) and full (row[5]) names of the room */
|
|
||||||
Str_Copy (Room->ShrtName,row[4],sizeof (Room->ShrtName) - 1);
|
|
||||||
Str_Copy (Room->FullName,row[5],sizeof (Room->FullName) - 1);
|
|
||||||
|
|
||||||
/* Get seating capacity in this room (row[6]) */
|
|
||||||
if (sscanf (row[6],"%u",&Room->Capacity) != 1)
|
|
||||||
Room->Capacity = Roo_UNLIMITED_CAPACITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Free structure that stores the query result *****/
|
/***** Free structure that stores the query result *****/
|
||||||
DB_FreeMySQLResult (&mysql_res);
|
DB_FreeMySQLResult (&mysql_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********************* Get room data from database row ***********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static void Roo_GetRoomDataFromRow (MYSQL_RES *mysql_res,
|
||||||
|
struct Roo_Room *Room,
|
||||||
|
Roo_WhichData_t WhichData)
|
||||||
|
{
|
||||||
|
MYSQL_ROW row;
|
||||||
|
|
||||||
|
/***** Get row *****/
|
||||||
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
|
/***** Get room code (row[0]) *****/
|
||||||
|
if ((Room->RooCod = Str_ConvertStrCodToLongCod (row[0])) <= 0)
|
||||||
|
Err_WrongRoomExit ();
|
||||||
|
|
||||||
|
switch (WhichData)
|
||||||
|
{
|
||||||
|
case Roo_ALL_DATA:
|
||||||
|
/***** Get building code (row[1]) *****/
|
||||||
|
Room->BldCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||||
|
|
||||||
|
/***** Get the short name of the building (row[2]) *****/
|
||||||
|
Roo_GetBldShrtName (Room,row[2]);
|
||||||
|
|
||||||
|
/***** Get floor (row[3]) *****/
|
||||||
|
Room->Floor = Str_ConvertStrCodToLongCod (row[3]);
|
||||||
|
|
||||||
|
/***** Get type (row[4]) *****/
|
||||||
|
Room->Type = Roo_GetTypeFromString (row[4]);
|
||||||
|
|
||||||
|
/***** Get the short (row[5]) and full (row[6]) names of the room *****/
|
||||||
|
Str_Copy (Room->ShrtName,row[5],sizeof (Room->ShrtName) - 1);
|
||||||
|
Str_Copy (Room->FullName,row[6],sizeof (Room->FullName) - 1);
|
||||||
|
|
||||||
|
/***** Get seating capacity in this room (row[7]) *****/
|
||||||
|
if (sscanf (row[7],"%u",&Room->Capacity) != 1)
|
||||||
|
Room->Capacity = Roo_UNLIMITED_CAPACITY;
|
||||||
|
break;
|
||||||
|
case Roo_ONLY_SHRT_NAME:
|
||||||
|
default:
|
||||||
|
/***** Get the short name of the room (row[1]) *****/
|
||||||
|
Str_Copy (Room->ShrtName,row[1],sizeof (Room->ShrtName) - 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/****************** Get building short name from database ********************/
|
/****************** Get building short name from database ********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -287,13 +287,14 @@ unsigned Roo_DB_GetRoomDataByCod (MYSQL_RES **mysql_res,long RooCod)
|
||||||
{
|
{
|
||||||
return (unsigned)
|
return (unsigned)
|
||||||
DB_QuerySELECT (mysql_res,"can not get data of a room",
|
DB_QuerySELECT (mysql_res,"can not get data of a room",
|
||||||
"SELECT roo_rooms.BldCod," // row[0]
|
"SELECT roo_rooms.RooCod," // row[0]
|
||||||
"bld_buildings.ShortName," // row[1]
|
"roo_rooms.BldCod," // row[1]
|
||||||
"roo_rooms.Floor," // row[2]
|
"bld_buildings.ShortName," // row[2]
|
||||||
"roo_rooms.Type," // row[3]
|
"roo_rooms.Floor," // row[3]
|
||||||
"roo_rooms.ShortName," // row[4]
|
"roo_rooms.Type," // row[4]
|
||||||
"roo_rooms.FullName," // row[5]
|
"roo_rooms.ShortName," // row[5]
|
||||||
"roo_rooms.Capacity" // row[6]
|
"roo_rooms.FullName," // row[6]
|
||||||
|
"roo_rooms.Capacity" // row[7]
|
||||||
" FROM roo_rooms LEFT JOIN bld_buildings"
|
" FROM roo_rooms LEFT JOIN bld_buildings"
|
||||||
" ON roo_rooms.BldCod=bld_buildings.BldCod"
|
" ON roo_rooms.BldCod=bld_buildings.BldCod"
|
||||||
" WHERE roo_rooms.RooCod=%ld",
|
" WHERE roo_rooms.RooCod=%ld",
|
||||||
|
|
|
@ -243,7 +243,7 @@ void TstPrn_ShowTestPrintToFillIt (struct TstPrn_Print *Print,
|
||||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||||
|
|
||||||
/* Show question */
|
/* Show question */
|
||||||
if (!Qst_GetQstDataFromDB (&Question)) // Question exists
|
if (!Qst_GetQstDataByCod (&Question)) // Question exists
|
||||||
Err_WrongQuestionExit ();
|
Err_WrongQuestionExit ();
|
||||||
|
|
||||||
/* Write question and answers */
|
/* Write question and answers */
|
||||||
|
@ -551,7 +551,7 @@ void TstPrn_ShowPrintAfterAssess (struct TstPrn_Print *Print)
|
||||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||||
|
|
||||||
/***** Get question data *****/
|
/***** Get question data *****/
|
||||||
QuestionExists = Qst_GetQstDataFromDB (&Question);
|
QuestionExists = Qst_GetQstDataByCod (&Question);
|
||||||
|
|
||||||
/***** Write question and answers *****/
|
/***** Write question and answers *****/
|
||||||
TstPrn_WriteQstAndAnsExam (&Gbl.Usrs.Me.UsrDat,
|
TstPrn_WriteQstAndAnsExam (&Gbl.Usrs.Me.UsrDat,
|
||||||
|
@ -2484,7 +2484,7 @@ void TstPrn_ShowPrintAnswers (struct Usr_Data *UsrDat,
|
||||||
Question.QstCod = PrintedQuestions[QstInd].QstCod;
|
Question.QstCod = PrintedQuestions[QstInd].QstCod;
|
||||||
|
|
||||||
/***** Get question data *****/
|
/***** Get question data *****/
|
||||||
QuestionExists = Qst_GetQstDataFromDB (&Question);
|
QuestionExists = Qst_GetQstDataByCod (&Question);
|
||||||
|
|
||||||
/***** Write questions and answers *****/
|
/***** Write questions and answers *****/
|
||||||
TstPrn_WriteQstAndAnsExam (UsrDat,
|
TstPrn_WriteQstAndAnsExam (UsrDat,
|
||||||
|
|
Loading…
Reference in New Issue