mirror of https://github.com/acanas/swad-core.git
Version 21.47.2: Oct 29, 2021 Queries moved to module swad_questions_database.
This commit is contained in:
parent
b5ff64cb8d
commit
0179af96e0
|
@ -3145,7 +3145,7 @@ int swad__sendAttendanceUsers (struct soap *soap,
|
|||
/* Find next string in text until comma (leading and trailing spaces are removed) */
|
||||
Str_GetNextStringUntilComma (&Ptr,LongStr,Cns_MAX_DECIMAL_DIGITS_LONG);
|
||||
if ((UsrDat.UsrCod = Str_ConvertStrCodToLongCod (LongStr)) > 0)
|
||||
if (Usr_ChkIfUsrCodExists (UsrDat.UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrDat.UsrCod))
|
||||
// The user must belong to course,
|
||||
// but it's not necessary he/she belongs to groups associated to the event
|
||||
if (Usr_CheckIfUsrBelongsToCurrentCrs (&UsrDat))
|
||||
|
|
|
@ -142,9 +142,9 @@ void Acc_ShowFormMyAccount (void)
|
|||
{
|
||||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
Usr_PutLinkToLogin ();
|
||||
Pwd_PutLinkToSendNewPasswd ();
|
||||
Lan_PutLinkToChangeLanguage ();
|
||||
Usr_PutLinkToLogin ();
|
||||
Pwd_PutLinkToSendNewPasswd ();
|
||||
Lan_PutLinkToChangeLanguage ();
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
/**** Show form to check if I have an account *****/
|
||||
|
@ -786,7 +786,7 @@ static void Acc_CreateNewEncryptedUsrCod (struct UsrData *UsrDat)
|
|||
{
|
||||
Str_CreateRandomAlphanumStr (RandomStr,LENGTH_RANDOM_STR);
|
||||
Cry_EncryptSHA256Base64 (RandomStr,UsrDat->EnUsrCod);
|
||||
if (!Usr_ChkIfEncryptedUsrCodExists (UsrDat->EnUsrCod))
|
||||
if (!Usr_DB_ChkIfEncryptedUsrCodExists (UsrDat->EnUsrCod))
|
||||
break;
|
||||
}
|
||||
if (NumTry == MAX_TRY)
|
||||
|
@ -923,7 +923,7 @@ static void Acc_AskIfRemoveOtherUsrAccount (void)
|
|||
extern const char *Txt_Do_you_really_want_to_completely_eliminate_the_following_user;
|
||||
extern const char *Txt_Eliminate_user_account;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
/***** Show question and button to remove user account *****/
|
||||
/* Begin alert */
|
||||
|
|
10
swad_admin.c
10
swad_admin.c
|
@ -149,7 +149,7 @@ static void Adm_ReqAddAdm (HieLvl_Level_t Scope,long Cod,
|
|||
(Scope == HieLvl_INS && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM));
|
||||
if (ICanRegister)
|
||||
{
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) // User is already an administrator of current institution/center/degree
|
||||
if (Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod)) // User is already an administrator of current institution/center/degree
|
||||
{
|
||||
Ale_ShowAlert (Ale_INFO,Txt_THE_USER_X_is_already_an_administrator_of_Y,
|
||||
Gbl.Usrs.Other.UsrDat.FullName,InsCtrDegName);
|
||||
|
@ -253,7 +253,7 @@ static void Adm_RegisterAdmin (struct UsrData *UsrDat,
|
|||
extern const char *Txt_THE_USER_X_has_been_enroled_as_administrator_of_Y;
|
||||
|
||||
/***** Check if user was and administrator of current institution/center/degree *****/
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod))
|
||||
if (Usr_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod))
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_THE_USER_X_is_already_an_administrator_of_Y,
|
||||
UsrDat->FullName,InsCtrDegName);
|
||||
else // User was not administrator of current institution/center/degree
|
||||
|
@ -352,7 +352,7 @@ static void Adm_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,
|
|||
if (ICanRemove)
|
||||
{
|
||||
/* Check if the other user is an admin of the current institution/center/degree */
|
||||
if (Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod))
|
||||
if (Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,Scope,Cod))
|
||||
{ // The other user is an administrator of current institution/center/degree ==> ask for removing or remove her/him
|
||||
switch (ReqDelOrDelUsr)
|
||||
{
|
||||
|
@ -399,7 +399,7 @@ static void Adm_AskIfRemAdm (bool ItsMe,HieLvl_Level_t Scope,
|
|||
[HieLvl_CRS] = ActUnk,
|
||||
};
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
/***** Show question and button to remove user as administrator *****/
|
||||
/* Begin alert */
|
||||
|
@ -432,7 +432,7 @@ static void Adm_EffectivelyRemAdm (struct UsrData *UsrDat,
|
|||
extern const char *Txt_THE_USER_X_has_been_removed_as_administrator_of_Y;
|
||||
extern const char *Txt_THE_USER_X_is_not_an_administrator_of_Y;
|
||||
|
||||
if (Usr_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) // User is administrator of current institution/center/degree
|
||||
if (Usr_DB_CheckIfUsrIsAdm (UsrDat->UsrCod,Scope,Cod)) // User is administrator of current institution/center/degree
|
||||
{
|
||||
/***** Remove user as administrator of institution, center or degree *****/
|
||||
Adm_DB_RemAdmin (UsrDat->UsrCod,Scope,Cod);
|
||||
|
|
|
@ -6407,7 +6407,7 @@ static void Brw_PasteClipboard (void)
|
|||
if (Crs_GetDataOfCourseByCod (&Hie.Crs))
|
||||
{
|
||||
Usr_UsrDataConstructor (&UsrDat);
|
||||
if (Usr_ChkIfUsrCodExists (Gbl.FileBrowser.Clipboard.WorksUsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (Gbl.FileBrowser.Clipboard.WorksUsrCod))
|
||||
|
||||
UsrDat.UsrCod = Gbl.FileBrowser.Clipboard.WorksUsrCod;
|
||||
Usr_GetAllUsrDataFromUsrCod (&UsrDat,
|
||||
|
|
|
@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
|
|||
|
||||
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.47.1 (2021-10-28)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 21.47.2 (2021-10-29)"
|
||||
#define CSS_FILE "swad20.45.css"
|
||||
#define JS_FILE "swad20.69.1.js"
|
||||
/*
|
||||
TODO: Rename CENTRE to CENTER in help wiki.
|
||||
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
|
||||
|
||||
Version 21.47.2: Oct 29, 2021 Queries moved to module swad_questions_database. (321259 lines)
|
||||
Version 21.47.1: Oct 28, 2021 Queries moved to module swad_questions_database. (321231 lines)
|
||||
Version 21.47: Oct 27, 2021 New module swad_questions_database for database queries related to test/exam/game questions. (321236 lines)
|
||||
Version 21.46.5: Oct 27, 2021 Queries moved to module swad_test_database. (321140 lines)
|
||||
|
|
|
@ -95,7 +95,7 @@ void Con_ShowConnectedUsrs (void)
|
|||
if (Gbl.Usrs.Me.Logged)
|
||||
{
|
||||
Mnu_ContextMenuBegin ();
|
||||
Log_PutLinkToLastClicks (); // Show last clicks in real time
|
||||
Log_PutLinkToLastClicks (); // Show last clicks in real time
|
||||
Mnu_ContextMenuEnd ();
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
|
|||
HTM_LI_End ();
|
||||
|
||||
/***** Get my countries *****/
|
||||
NumCtys = Usr_GetCtysFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_resCty);
|
||||
NumCtys = Usr_DB_GetCtysFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_resCty);
|
||||
for (NumCty = 0;
|
||||
NumCty < NumCtys;
|
||||
NumCty++)
|
||||
|
|
|
@ -109,7 +109,7 @@ void CrsCfg_Configuration (bool PrintView)
|
|||
Gbl.Usrs.Me.Role.Logged == Rol_USR)
|
||||
{
|
||||
Mnu_ContextMenuBegin ();
|
||||
Enr_PutLinkToRequestSignUp (); // Request enrolment in the current course
|
||||
Enr_PutLinkToRequestSignUp (); // Request enrolment in the current course
|
||||
Mnu_ContextMenuEnd ();
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ void Dpt_SeeDepts (void)
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write teachers of this institution with other department *****/
|
||||
NumTchsInsInOtherDpts = Usr_GetNumTchsCurrentInsInDepartment (0);
|
||||
NumTchsInsInOtherDpts = Usr_DB_GetNumTchsCurrentInsInDepartment (0);
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
@ -211,7 +211,7 @@ void Dpt_SeeDepts (void)
|
|||
HTM_TR_End ();
|
||||
|
||||
/***** Write teachers with no department *****/
|
||||
NumTchsInsWithNoDpt = Usr_GetNumTchsCurrentInsInDepartment (-1L);
|
||||
NumTchsInsWithNoDpt = Usr_DB_GetNumTchsCurrentInsInDepartment (-1L);
|
||||
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
|
|
|
@ -166,8 +166,8 @@ void Dup_ListDuplicateUsrs (void)
|
|||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
{
|
||||
/* Get if user has accepted all his/her courses */
|
||||
if (Usr_GetNumCrssOfUsr (UsrDat.UsrCod) != 0)
|
||||
UsrDat.Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0);
|
||||
if (Usr_DB_GetNumCrssOfUsr (UsrDat.UsrCod) != 0)
|
||||
UsrDat.Accepted = (Usr_DB_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0);
|
||||
else
|
||||
UsrDat.Accepted = false;
|
||||
|
||||
|
@ -283,8 +283,8 @@ static void Dup_ListSimilarUsrs (void)
|
|||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS))
|
||||
{
|
||||
/* Get if user has accepted all his/her courses */
|
||||
if (Usr_GetNumCrssOfUsr (UsrDat.UsrCod) != 0)
|
||||
UsrDat.Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0);
|
||||
if (Usr_DB_GetNumCrssOfUsr (UsrDat.UsrCod) != 0)
|
||||
UsrDat.Accepted = (Usr_DB_GetNumCrssOfUsrNotAccepted (UsrDat.UsrCod) == 0);
|
||||
else
|
||||
UsrDat.Accepted = false;
|
||||
|
||||
|
|
|
@ -580,31 +580,31 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
|
|||
{
|
||||
Mnu_ContextMenuBegin ();
|
||||
|
||||
switch (Role)
|
||||
{
|
||||
case Rol_STD:
|
||||
/* Put link to go to admin student */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneStd);
|
||||
switch (Role)
|
||||
{
|
||||
case Rol_STD:
|
||||
/* Put link to go to admin student */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneStd);
|
||||
|
||||
/* Put link to remove all the students in the current course */
|
||||
if (Usr_GetNumUsrsInCrss (HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
||||
1 << Rol_STD)) // This course has students
|
||||
Enr_PutLinkToRemAllStdsThisCrs ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
/* Put link to go to admin teacher */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch);
|
||||
break;
|
||||
case Rol_TCH:
|
||||
/* Put link to go to admin teacher */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch);
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
/* Put link to remove all the students in the current course */
|
||||
if (Usr_GetNumUsrsInCrss (HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
||||
1 << Rol_STD)) // This course has students
|
||||
Enr_PutLinkToRemAllStdsThisCrs ();
|
||||
break;
|
||||
case Rol_NET:
|
||||
/* Put link to go to admin teacher */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch);
|
||||
break;
|
||||
case Rol_TCH:
|
||||
/* Put link to go to admin teacher */
|
||||
Enr_PutLinkToAdminOneUsr (ActReqMdfOneTch);
|
||||
break;
|
||||
default:
|
||||
NextAction = ActUnk;
|
||||
Title = NULL;
|
||||
Err_WrongRoleExit ();
|
||||
break;
|
||||
}
|
||||
|
||||
Mnu_ContextMenuEnd ();
|
||||
}
|
||||
|
@ -1368,20 +1368,20 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe)
|
|||
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
||||
{
|
||||
/***** Check if the other user is administrator of the current institution *****/
|
||||
UsrIsInsAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
UsrIsInsAdmin = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
HieLvl_INS,
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
|
||||
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
||||
{
|
||||
/***** Check if the other user is administrator of the current center *****/
|
||||
UsrIsCtrAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
UsrIsCtrAdmin = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
HieLvl_CTR,
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
|
||||
if (Gbl.Hierarchy.Deg.DegCod > 0)
|
||||
/***** Check if the other user is administrator of the current degree *****/
|
||||
UsrIsDegAdmin = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
UsrIsDegAdmin = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Other.UsrDat.UsrCod,
|
||||
HieLvl_DEG,
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
}
|
||||
|
@ -2651,7 +2651,7 @@ static void Enr_ShowFormToEditOtherUsr (void)
|
|||
extern const char *Txt_THE_USER_X_already_exists_in_Y;
|
||||
|
||||
/***** If user exists... *****/
|
||||
if (Usr_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (Gbl.Usrs.Other.UsrDat.UsrCod))
|
||||
{
|
||||
/***** Show form to edit user *****/
|
||||
if (Gbl.Hierarchy.Level == HieLvl_CRS) // Course selected
|
||||
|
|
|
@ -133,8 +133,8 @@ void Fol_SuggestUsrsToFollowMainZone (void)
|
|||
|
||||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
Prf_PutLinkMyPublicProfile (); // My public profile
|
||||
Prf_PutLinkRequestAnotherUserProfile (); // Request another user's profile
|
||||
Prf_PutLinkMyPublicProfile (); // My public profile
|
||||
Prf_PutLinkRequestAnotherUserProfile (); // Request another user's profile
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
/***** Get users *****/
|
||||
|
|
24
swad_mail.c
24
swad_mail.c
|
@ -886,18 +886,18 @@ static void Mai_ListEmails (__attribute__((unused)) void *Args)
|
|||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
|
||||
/* Open the client email program */
|
||||
HTM_A_Begin ("href=\"mailto:%s?subject=%s&cc=%s&bcc=%s\""
|
||||
" title=\"%s\" class=\"%s\"",
|
||||
Gbl.Usrs.Me.UsrDat.Email,
|
||||
Gbl.Hierarchy.Crs.FullName,
|
||||
Gbl.Usrs.Me.UsrDat.Email,
|
||||
StrAddresses,
|
||||
Txt_Create_email_message,
|
||||
The_ClassFormOutBoxBold[Gbl.Prefs.Theme]);
|
||||
Ico_PutIconTextLink ("marker.svg",
|
||||
Txt_Create_email_message);
|
||||
HTM_A_End ();
|
||||
/* Open the client email program */
|
||||
HTM_A_Begin ("href=\"mailto:%s?subject=%s&cc=%s&bcc=%s\""
|
||||
" title=\"%s\" class=\"%s\"",
|
||||
Gbl.Usrs.Me.UsrDat.Email,
|
||||
Gbl.Hierarchy.Crs.FullName,
|
||||
Gbl.Usrs.Me.UsrDat.Email,
|
||||
StrAddresses,
|
||||
Txt_Create_email_message,
|
||||
The_ClassFormOutBoxBold[Gbl.Prefs.Theme]);
|
||||
Ico_PutIconTextLink ("marker.svg",
|
||||
Txt_Create_email_message);
|
||||
HTM_A_End ();
|
||||
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ void Mrk_ShowMyMarks (void)
|
|||
{
|
||||
if (Grp_DB_CountNumUsrsInGrp (Rol_STD,Gbl.Crs.Grps.GrpCod)) // If there are students in this group
|
||||
{
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = Usr_GetRamdomStdFromGrp (Gbl.Crs.Grps.GrpCod);
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = Usr_DB_GetRamdomStdFromGrp (Gbl.Crs.Grps.GrpCod);
|
||||
UsrDat = &Gbl.Usrs.Other.UsrDat;
|
||||
}
|
||||
else
|
||||
|
@ -572,7 +572,7 @@ void Mrk_ShowMyMarks (void)
|
|||
if (Usr_GetNumUsrsInCrss (HieLvl_CRS,Gbl.Hierarchy.Crs.CrsCod,
|
||||
1 << Rol_STD)) // If there are students in this course
|
||||
{
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = Usr_GetRamdomStdFromCrs (Gbl.Hierarchy.Crs.CrsCod);
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = Usr_DB_GetRamdomStdFromCrs (Gbl.Hierarchy.Crs.CrsCod);
|
||||
UsrDat = &Gbl.Usrs.Other.UsrDat;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -413,11 +413,11 @@ static void Msg_PutLinkToShowMorePotentialRecipients (const struct Msg_Messages
|
|||
|
||||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
Lay_PutContextualLinkIconTextOnSubmit (ActReqMsgUsr,NULL,
|
||||
Msg_PutParamsShowMorePotentialRecipients,Messages,
|
||||
"users.svg",
|
||||
Txt_Show_more_recipients,
|
||||
"CopyMessageToHiddenFields();"); // Shor more potential recipients
|
||||
Lay_PutContextualLinkIconTextOnSubmit (ActReqMsgUsr,NULL,
|
||||
Msg_PutParamsShowMorePotentialRecipients,Messages,
|
||||
"users.svg",
|
||||
Txt_Show_more_recipients,
|
||||
"CopyMessageToHiddenFields();"); // Shor more potential recipients
|
||||
Mnu_ContextMenuEnd ();
|
||||
}
|
||||
|
||||
|
|
82
swad_photo.c
82
swad_photo.c
|
@ -1914,51 +1914,51 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh
|
|||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
|
||||
/* Begin form */
|
||||
Frm_BeginForm (ActCalPhoDeg);
|
||||
Pho_PutHiddenParamTypeOfAvg (DegPhotos->TypeOfAverage);
|
||||
Pho_PutHiddenParamPhotoSize (DegPhotos->HowComputePhotoSize);
|
||||
Pho_PutHiddenParamOrderDegrees (DegPhotos->HowOrderDegrees);
|
||||
Usr_PutParamsPrefsAboutUsrList ();
|
||||
/* Begin form */
|
||||
Frm_BeginForm (ActCalPhoDeg);
|
||||
Pho_PutHiddenParamTypeOfAvg (DegPhotos->TypeOfAverage);
|
||||
Pho_PutHiddenParamPhotoSize (DegPhotos->HowComputePhotoSize);
|
||||
Pho_PutHiddenParamOrderDegrees (DegPhotos->HowOrderDegrees);
|
||||
Usr_PutParamsPrefsAboutUsrList ();
|
||||
|
||||
HTM_BUTTON_Animated_Begin (Txt_Calculate_average_photo_of_THE_DEGREE_X,
|
||||
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme],
|
||||
NULL);
|
||||
Ico_PutCalculateIconWithText (Txt_Calculate_average_photo_of_THE_DEGREE_X);
|
||||
HTM_BUTTON_End ();
|
||||
HTM_BUTTON_Animated_Begin (Txt_Calculate_average_photo_of_THE_DEGREE_X,
|
||||
The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme],
|
||||
NULL);
|
||||
Ico_PutCalculateIconWithText (Txt_Calculate_average_photo_of_THE_DEGREE_X);
|
||||
HTM_BUTTON_End ();
|
||||
|
||||
/* Selector with all the degrees with students */
|
||||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"name=\"OthDegCod\"");
|
||||
for (NumDeg = 0;
|
||||
NumDeg < Degs.Num;
|
||||
NumDeg++)
|
||||
{
|
||||
/* Get time to compute average photo of this degree */
|
||||
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
|
||||
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
||||
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
|
||||
sizeof (StrEstimatedTimeToComputeAvgPhoto) - 1);
|
||||
else
|
||||
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
|
||||
EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
||||
/* Selector with all the degrees with students */
|
||||
HTM_SELECT_Begin (HTM_DONT_SUBMIT_ON_CHANGE,
|
||||
"name=\"OthDegCod\"");
|
||||
for (NumDeg = 0;
|
||||
NumDeg < Degs.Num;
|
||||
NumDeg++)
|
||||
{
|
||||
/* Get time to compute average photo of this degree */
|
||||
EstimatedTimeToComputeAvgPhotoInMicroseconds = Pho_GetTimeToComputeAvgPhoto (Degs.Lst[NumDeg].DegCod);
|
||||
if (EstimatedTimeToComputeAvgPhotoInMicroseconds == -1L)
|
||||
Str_Copy (StrEstimatedTimeToComputeAvgPhoto,Txt_unknown_TIME,
|
||||
sizeof (StrEstimatedTimeToComputeAvgPhoto) - 1);
|
||||
else
|
||||
Sta_WriteTime (StrEstimatedTimeToComputeAvgPhoto,
|
||||
EstimatedTimeToComputeAvgPhotoInMicroseconds);
|
||||
|
||||
Selected = (Degs.Lst[NumDeg].DegCod == Deg.DegCod);
|
||||
if (Selected)
|
||||
Disabled = false;
|
||||
else
|
||||
// Too recently computed ?
|
||||
Disabled = Pho_GetTimeAvgPhotoWasComputed (Degs.Lst[NumDeg].DegCod) >=
|
||||
Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO;
|
||||
HTM_OPTION (HTM_Type_LONG,&Degs.Lst[NumDeg].DegCod,Selected,Disabled,
|
||||
"%s (%s: %s)",
|
||||
Degs.Lst[NumDeg].ShrtName,
|
||||
Txt_time,StrEstimatedTimeToComputeAvgPhoto);
|
||||
}
|
||||
HTM_SELECT_End ();
|
||||
Selected = (Degs.Lst[NumDeg].DegCod == Deg.DegCod);
|
||||
if (Selected)
|
||||
Disabled = false;
|
||||
else
|
||||
// Too recently computed ?
|
||||
Disabled = Pho_GetTimeAvgPhotoWasComputed (Degs.Lst[NumDeg].DegCod) >=
|
||||
Gbl.StartExecutionTimeUTC - Cfg_MIN_TIME_TO_RECOMPUTE_AVG_PHOTO;
|
||||
HTM_OPTION (HTM_Type_LONG,&Degs.Lst[NumDeg].DegCod,Selected,Disabled,
|
||||
"%s (%s: %s)",
|
||||
Degs.Lst[NumDeg].ShrtName,
|
||||
Txt_time,StrEstimatedTimeToComputeAvgPhoto);
|
||||
}
|
||||
HTM_SELECT_End ();
|
||||
|
||||
/* End form and contextual menu */
|
||||
Frm_EndForm ();
|
||||
/* End form and contextual menu */
|
||||
Frm_EndForm ();
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
/***** Free list of all the degrees with students *****/
|
||||
|
|
|
@ -526,7 +526,7 @@ static void Prf_ShowNumCrssWithRole (const struct UsrData *UsrDat,
|
|||
unsigned NumCrss;
|
||||
|
||||
/***** Number of courses in which the user has a given role *****/
|
||||
NumCrss = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Role);
|
||||
NumCrss = Usr_DB_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Role);
|
||||
|
||||
Prf_BeginListItem (Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex],Rol_Icons[Role]);
|
||||
|
||||
|
@ -955,7 +955,7 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod)
|
|||
MYSQL_ROW row;
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
@ -989,7 +989,7 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod)
|
|||
{
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
@ -1013,7 +1013,7 @@ static void Prf_GetNumTimelinePubsAndStoreAsUsrFigure (long UsrCod)
|
|||
{
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
@ -1037,7 +1037,7 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod)
|
|||
{
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
@ -1061,7 +1061,7 @@ static void Prf_GetNumForumPostsAndStoreAsUsrFigure (long UsrCod)
|
|||
{
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
@ -1085,7 +1085,7 @@ static void Prf_GetNumMessagesSentAndStoreAsUsrFigure (long UsrCod)
|
|||
{
|
||||
struct Prf_UsrFigures UsrFigures;
|
||||
|
||||
if (Usr_ChkIfUsrCodExists (UsrCod))
|
||||
if (Usr_DB_ChkIfUsrCodExists (UsrCod))
|
||||
{
|
||||
/***** Reset user's figures *****/
|
||||
Prf_ResetUsrFigures (&UsrFigures);
|
||||
|
|
271
swad_question.c
271
swad_question.c
|
@ -753,14 +753,13 @@ void Qst_ListQuestionsToEdit (void)
|
|||
if (Tst_GetParamsTst (&Questions,Tst_EDIT_QUESTIONS)) // Get parameters from the form
|
||||
{
|
||||
/***** Get question codes from database *****/
|
||||
Qst_GetQuestions (&Questions,&mysql_res); // Query database
|
||||
if (Questions.NumQsts)
|
||||
if ((Questions.NumQsts = Qst_DB_GetQsts (&mysql_res,&Questions)))
|
||||
{
|
||||
/* Contextual menu */
|
||||
if (QstImp_GetCreateXMLParamFromForm ())
|
||||
{
|
||||
Mnu_ContextMenuBegin ();
|
||||
QstImp_CreateXML (Questions.NumQsts,mysql_res); // Create XML file with exported questions...
|
||||
QstImp_CreateXML (Questions.NumQsts,mysql_res); // Create XML file with exported questions...
|
||||
// ...and put a link to download it
|
||||
Mnu_ContextMenuEnd ();
|
||||
}
|
||||
|
@ -795,8 +794,7 @@ void Qst_ListQuestionsToSelectForExamSet (struct Exa_Exams *Exams)
|
|||
/***** Get parameters, query the database and list the questions *****/
|
||||
if (Tst_GetParamsTst (&Questions,Tst_SELECT_QUESTIONS_FOR_EXAM)) // Get parameters from the form
|
||||
{
|
||||
Qst_GetQuestions (&Questions,&mysql_res); // Query database
|
||||
if (Questions.NumQsts)
|
||||
if ((Questions.NumQsts = Qst_DB_GetQsts (&mysql_res,&Questions)))
|
||||
/* Show the table with the questions */
|
||||
Qst_ListOneOrMoreQstsForSelectionForExamSet (Exams,Questions.NumQsts,mysql_res);
|
||||
|
||||
|
@ -826,8 +824,7 @@ void Qst_ListQuestionsToSelectForGame (struct Gam_Games *Games)
|
|||
/***** Get parameters, query the database and list the questions *****/
|
||||
if (Tst_GetParamsTst (&Questions,Tst_SELECT_QUESTIONS_FOR_GAME)) // Get parameters from the form
|
||||
{
|
||||
Qst_GetQuestions (&Questions,&mysql_res); // Query database
|
||||
if (Questions.NumQsts)
|
||||
if ((Questions.NumQsts = Qst_DB_GetQsts (&mysql_res,&Questions)))
|
||||
/* Show the table with the questions */
|
||||
Qst_ListOneOrMoreQstsForSelectionForGame (Games,Questions.NumQsts,mysql_res);
|
||||
|
||||
|
@ -1720,149 +1717,6 @@ void Qst_CheckIfNumberOfAnswersIsOne (const struct Qst_Question *Question)
|
|||
Err_WrongAnswerExit ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********** Get from the database several test questions for listing *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Qst_MAX_BYTES_QUERY_QUESTIONS (16 * 1024 - 1)
|
||||
|
||||
void Qst_GetQuestions (struct Qst_Questions *Questions,MYSQL_RES **mysql_res)
|
||||
{
|
||||
extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES];
|
||||
extern const char *Txt_No_questions_found_matching_your_search_criteria;
|
||||
char *Query = NULL;
|
||||
long LengthQuery;
|
||||
unsigned NumItemInList;
|
||||
const char *Ptr;
|
||||
char TagText[Tag_MAX_BYTES_TAG + 1];
|
||||
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||
char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
Qst_AnswerType_t AnsType;
|
||||
char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (Qst_MAX_BYTES_QUERY_QUESTIONS + 1)) == NULL)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Select questions *****/
|
||||
/* Begin query */
|
||||
Str_Copy (Query,"SELECT tst_questions.QstCod" // row[0]
|
||||
" FROM tst_questions",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
if (!Questions->Tags.All)
|
||||
Str_Concat (Query,","
|
||||
"tst_question_tags,"
|
||||
"tst_tags",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
Str_Concat (Query," WHERE tst_questions.CrsCod='",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (CrsCodStr,sizeof (CrsCodStr),"%ld",Gbl.Hierarchy.Crs.CrsCod);
|
||||
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||
(long) Gbl.DateRange.TimeUTC[Dat_STR_TIME]);
|
||||
Str_Concat (Query,LongStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
|
||||
Str_Concat (Query,LongStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"')",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
/* Add the tags selected */
|
||||
if (!Questions->Tags.All)
|
||||
{
|
||||
Str_Concat (Query," AND tst_questions.QstCod=tst_question_tags.QstCod"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
LengthQuery = strlen (Query);
|
||||
NumItemInList = 0;
|
||||
Ptr = Questions->Tags.List;
|
||||
while (*Ptr)
|
||||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tag_MAX_BYTES_TAG);
|
||||
LengthQuery = LengthQuery + 35 + strlen (TagText) + 1;
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 256)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||
" AND (tst_tags.TagTxt='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,TagText,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* Add the types of answer selected */
|
||||
if (!Questions->AnswerTypes.All)
|
||||
{
|
||||
LengthQuery = strlen (Query);
|
||||
NumItemInList = 0;
|
||||
Ptr = Questions->AnswerTypes.List;
|
||||
while (*Ptr)
|
||||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Tag_MAX_BYTES_TAG);
|
||||
AnsType = Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr);
|
||||
LengthQuery = LengthQuery + 35 + strlen (Qst_DB_StrAnswerTypes[AnsType]) + 1;
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 256)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||
" AND (tst_questions.AnsType='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,Qst_DB_StrAnswerTypes[AnsType],Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* End the query */
|
||||
Str_Concat (Query," GROUP BY tst_questions.QstCod",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
switch (Questions->SelectedOrder)
|
||||
{
|
||||
case Qst_ORDER_STEM:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_NUM_HITS:
|
||||
Str_Concat (Query," ORDER BY tst_questions.NumHits DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_AVERAGE_SCORE:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHits DESC,"
|
||||
"tst_questions.NumHits DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_NUM_HITS_NOT_BLANK:
|
||||
Str_Concat (Query," ORDER BY tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_AVERAGE_SCORE_NOT_BLANK:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make the query */
|
||||
Questions->NumQsts = (unsigned) DB_QuerySELECT (mysql_res,"can not get questions",
|
||||
"%s",
|
||||
Query);
|
||||
if (Questions->NumQsts == 0)
|
||||
Ale_ShowAlert (Ale_INFO,Txt_No_questions_found_matching_your_search_criteria);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Change format of answers text / feedback ******************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2590,24 +2444,6 @@ void Qst_FreeMediaOfQuestion (struct Qst_Question *Question)
|
|||
Med_MediaDestructor (&Question->Answer.Options[NumOpt].Media);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get answer type of a question from database *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
Qst_AnswerType_t Qst_GetQstAnswerTypeFromDB (long QstCod)
|
||||
{
|
||||
char StrAnsTypeDB[256];
|
||||
|
||||
/***** Get type of answer from database *****/
|
||||
DB_QuerySELECTString (StrAnsTypeDB,sizeof (StrAnsTypeDB) - 1,
|
||||
"can not get the type of a question",
|
||||
"SELECT AnsType"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
return Qst_ConvertFromStrAnsTypDBToAnsTyp (StrAnsTypeDB);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get data of a question from database *********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2622,23 +2458,7 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
|||
unsigned NumOpt;
|
||||
|
||||
/***** Get question data from database *****/
|
||||
QuestionExists = (DB_QuerySELECT (&mysql_res,"can not get a question",
|
||||
"SELECT UNIX_TIMESTAMP(EditTime)," // row[0]
|
||||
"AnsType," // row[1]
|
||||
"Shuffle," // row[2]
|
||||
"Stem," // row[3]
|
||||
"Feedback," // row[4]
|
||||
"MedCod," // row[5]
|
||||
"NumHits," // row[6]
|
||||
"NumHitsNotBlank," // row[7]
|
||||
"Score" // row[8]
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
Question->QstCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod) != 0);
|
||||
|
||||
if (QuestionExists)
|
||||
if ((QuestionExists = (Qst_DB_GetQstData (&mysql_res,Question->QstCod) != 0)))
|
||||
{
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
|
@ -2653,10 +2473,10 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
|||
|
||||
/* Get the stem (row[3]) and the feedback (row[4]) */
|
||||
Question->Stem [0] = '\0';
|
||||
Question->Feedback[0] = '\0';
|
||||
if (row[3])
|
||||
if (row[3][0])
|
||||
Str_Copy (Question->Stem ,row[3],Cns_MAX_BYTES_TEXT);
|
||||
Question->Feedback[0] = '\0';
|
||||
if (row[4])
|
||||
if (row[4][0])
|
||||
Str_Copy (Question->Feedback,row[4],Cns_MAX_BYTES_TEXT);
|
||||
|
@ -2667,13 +2487,12 @@ bool Qst_GetQstDataFromDB (struct Qst_Question *Question)
|
|||
|
||||
/* Get number of hits
|
||||
(number of times that the question has been answered,
|
||||
including blank answers) (row[6]) */
|
||||
if (sscanf (row[6],"%lu",&Question->NumHits) != 1)
|
||||
Question->NumHits = 0;
|
||||
|
||||
/* Get number of hits not blank
|
||||
including blank answers) (row[6])
|
||||
and number of hits not blank
|
||||
(number of times that the question has been answered
|
||||
with a not blank answer) (row[7]) */
|
||||
if (sscanf (row[6],"%lu",&Question->NumHits ) != 1)
|
||||
Question->NumHits = 0;
|
||||
if (sscanf (row[7],"%lu",&Question->NumHitsNotBlank) != 1)
|
||||
Question->NumHitsNotBlank = 0;
|
||||
|
||||
|
@ -2788,20 +2607,10 @@ long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt)
|
|||
/***** Query depending on NumOpt *****/
|
||||
if (NumOpt < 0)
|
||||
// Get media associated to stem
|
||||
return DB_QuerySELECTCode ("can not get media",
|
||||
"SELECT MedCod"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
QstCod,CrsCod);
|
||||
return Qst_DB_GetQstMedCod (CrsCod,QstCod);
|
||||
else
|
||||
// Get media associated to answer
|
||||
return DB_QuerySELECTCode ("can not get media",
|
||||
"SELECT MedCod"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND AnsInd=%u",
|
||||
QstCod,(unsigned) NumOpt);
|
||||
return Qst_DB_GetAnswerMedCod (QstCod,(unsigned) NumOpt);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3254,8 +3063,7 @@ bool Qst_CheckIfQuestionExistsInDB (struct Qst_Question *Question)
|
|||
|
||||
/***** Check if stem exists *****/
|
||||
NumQstsWithThisStem =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res_qst,"can not check"
|
||||
" if a question exists",
|
||||
(unsigned) DB_QuerySELECT (&mysql_res_qst,"can not check if a question exists",
|
||||
"SELECT QstCod"
|
||||
" FROM tst_questions"
|
||||
" WHERE CrsCod=%ld"
|
||||
|
@ -3278,14 +3086,7 @@ bool Qst_CheckIfQuestionExistsInDB (struct Qst_Question *Question)
|
|||
Err_WrongQuestionExit ();
|
||||
|
||||
/* Get answers from this question */
|
||||
NumOptsExistingQstInDB =
|
||||
(unsigned) DB_QuerySELECT (&mysql_res_ans,"can not get the answer"
|
||||
" of a question",
|
||||
"SELECT Answer" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY AnsInd",
|
||||
Question->QstCod);
|
||||
NumOptsExistingQstInDB = Qst_DB_GetTextOfAnswers (&mysql_res_ans,Question->QstCod);
|
||||
|
||||
switch (Question->Answer.Type)
|
||||
{
|
||||
|
@ -3354,7 +3155,7 @@ void Qst_MoveMediaToDefinitiveDirectories (struct Qst_Question *Question)
|
|||
|
||||
/***** Media associated to question stem *****/
|
||||
CurrentMedCodInDB = Qst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod,
|
||||
-1L); // Get current media code associated to stem
|
||||
-1); // Get current media code associated to stem
|
||||
Med_RemoveKeepOrStoreMedia (CurrentMedCodInDB,&Question->Media);
|
||||
|
||||
/****** Move media associated to answers *****/
|
||||
|
@ -3367,7 +3168,7 @@ void Qst_MoveMediaToDefinitiveDirectories (struct Qst_Question *Question)
|
|||
NumOpt++)
|
||||
{
|
||||
CurrentMedCodInDB = Qst_GetMedCodFromDB (Gbl.Hierarchy.Crs.CrsCod,Question->QstCod,
|
||||
NumOpt); // Get current media code associated to this option
|
||||
(int) NumOpt); // Get current media code associated to this option
|
||||
Med_RemoveKeepOrStoreMedia (CurrentMedCodInDB,&Question->Answer.Options[NumOpt].Media);
|
||||
}
|
||||
break;
|
||||
|
@ -3449,7 +3250,7 @@ void Qst_RemoveSelectedQsts (void)
|
|||
if (Tst_GetParamsTst (&Questions,Tst_EDIT_QUESTIONS)) // Get parameters
|
||||
{
|
||||
/***** Get question codes *****/
|
||||
Qst_GetQuestions (&Questions,&mysql_res); // Query database
|
||||
Questions.NumQsts = Qst_DB_GetQsts (&mysql_res,&Questions);
|
||||
|
||||
/***** Remove questions one by one *****/
|
||||
for (NumQst = 0;
|
||||
|
@ -3599,12 +3400,7 @@ void Qst_RemoveOneQstFromDB (long CrsCod,long QstCod)
|
|||
Tag_DB_RemoveUnusedTagsFromCrs (CrsCod);
|
||||
|
||||
/* Remove the question itself */
|
||||
DB_QueryDELETE ("can not remove a question",
|
||||
"DELETE FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
QstCod,
|
||||
CrsCod);
|
||||
Qst_DB_RemoveQst (CrsCod,QstCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -3939,19 +3735,6 @@ void Qst_RemoveCrsQsts (long CrsCod)
|
|||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove answers from a test question ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_DB_RemAnsFromQst (long QstCod)
|
||||
{
|
||||
/***** Remove answers *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
"DELETE FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Remove media associated to stem of a test question *************/
|
||||
/*****************************************************************************/
|
||||
|
@ -4058,24 +3841,6 @@ void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Get suffled/not-shuffled answers indexes of question ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get questions of a game",
|
||||
"SELECT AnsInd" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Question->Answer.Shuffle ? "RAND()" : // Use RAND() because is really random; RAND(NOW()) repeats order
|
||||
"AnsInd");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get number of test questions ************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -213,8 +213,6 @@ void Qst_WriteParamQstCod (unsigned NumQst,long QstCod);
|
|||
|
||||
void Qst_CheckIfNumberOfAnswersIsOne (const struct Qst_Question *Question);
|
||||
|
||||
void Qst_GetQuestions (struct Qst_Questions *Questions,MYSQL_RES **mysql_res);
|
||||
|
||||
void Qst_ChangeFormatAnswersText (struct Qst_Question *Question);
|
||||
void Qst_ChangeFormatAnswersFeedback (struct Qst_Question *Question);
|
||||
|
||||
|
@ -239,7 +237,6 @@ void Qst_FreeTextChoiceAnswer (struct Qst_Question *Question,unsigned NumOpt);
|
|||
void Qst_ResetMediaOfQuestion (struct Qst_Question *Question);
|
||||
void Qst_FreeMediaOfQuestion (struct Qst_Question *Question);
|
||||
|
||||
Qst_AnswerType_t Qst_GetQstAnswerTypeFromDB (long QstCod);
|
||||
bool Qst_GetQstDataFromDB (struct Qst_Question *Question);
|
||||
long Qst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt);
|
||||
void Qst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt,
|
||||
|
@ -275,15 +272,11 @@ unsigned Qst_CountNumAnswerTypesInList (const struct Qst_AnswerTypes *AnswerType
|
|||
unsigned Qst_CountNumQuestionsInList (const char *ListQuestions);
|
||||
|
||||
void Qst_RemoveCrsQsts (long CrsCod);
|
||||
void Qst_DB_RemAnsFromQst (long QstCod);
|
||||
void Qst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod);
|
||||
void Qst_RemoveMediaFromAllAnsOfQst (long CrsCod,long QstCod);
|
||||
void Qst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod);
|
||||
void Qst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod);
|
||||
|
||||
unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question);
|
||||
|
||||
unsigned Qst_GetNumQuestions (HieLvl_Level_t Scope,Qst_AnswerType_t AnsType,
|
||||
struct Qst_Stats *Stats);
|
||||
|
||||
|
|
|
@ -59,6 +59,8 @@ const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES] =
|
|||
/**************************** Private constants ******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Qst_MAX_BYTES_QUERY_QUESTIONS (16 * 1024 - 1)
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -103,14 +105,158 @@ void Qst_DB_UpdateQstScore (long QstCod,bool AnswerIsNotBlank,double Score)
|
|||
Str_SetDecimalPointToLocal (); // Return to local system
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Get several test questions from database ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Qst_DB_GetQsts (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Questions *Questions)
|
||||
{
|
||||
extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES];
|
||||
extern const char *Txt_No_questions_found_matching_your_search_criteria;
|
||||
char *Query = NULL;
|
||||
long LengthQuery;
|
||||
unsigned NumItemInList;
|
||||
const char *Ptr;
|
||||
char TagText[Tag_MAX_BYTES_TAG + 1];
|
||||
char LongStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||
char UnsignedStr[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
Qst_AnswerType_t AnsType;
|
||||
char CrsCodStr[Cns_MAX_DECIMAL_DIGITS_LONG + 1];
|
||||
unsigned NumQsts;
|
||||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (Qst_MAX_BYTES_QUERY_QUESTIONS + 1)) == NULL)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Select questions *****/
|
||||
/* Begin query */
|
||||
Str_Copy (Query,"SELECT tst_questions.QstCod" // row[0]
|
||||
" FROM tst_questions",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
if (!Questions->Tags.All)
|
||||
Str_Concat (Query,","
|
||||
"tst_question_tags,"
|
||||
"tst_tags",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
Str_Concat (Query," WHERE tst_questions.CrsCod='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (CrsCodStr,sizeof (CrsCodStr),"%ld",Gbl.Hierarchy.Crs.CrsCod);
|
||||
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"' AND tst_questions.EditTime>=FROM_UNIXTIME('",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||
(long) Gbl.DateRange.TimeUTC[Dat_STR_TIME]);
|
||||
Str_Concat (Query,LongStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"') AND tst_questions.EditTime<=FROM_UNIXTIME('",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (LongStr,sizeof (LongStr),"%ld",
|
||||
(long) Gbl.DateRange.TimeUTC[Dat_END_TIME]);
|
||||
Str_Concat (Query,LongStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"')",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
/* Add the tags selected */
|
||||
if (!Questions->Tags.All)
|
||||
{
|
||||
Str_Concat (Query," AND tst_questions.QstCod=tst_question_tags.QstCod"
|
||||
" AND tst_question_tags.TagCod=tst_tags.TagCod"
|
||||
" AND tst_tags.CrsCod='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,CrsCodStr,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
LengthQuery = strlen (Query);
|
||||
NumItemInList = 0;
|
||||
Ptr = Questions->Tags.List;
|
||||
while (*Ptr)
|
||||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tag_MAX_BYTES_TAG);
|
||||
LengthQuery = LengthQuery + 35 + strlen (TagText) + 1;
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 256)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||
" AND (tst_tags.TagTxt='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,TagText,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* Add the types of answer selected */
|
||||
if (!Questions->AnswerTypes.All)
|
||||
{
|
||||
LengthQuery = strlen (Query);
|
||||
NumItemInList = 0;
|
||||
Ptr = Questions->AnswerTypes.List;
|
||||
while (*Ptr)
|
||||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Tag_MAX_BYTES_TAG);
|
||||
AnsType = Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr);
|
||||
LengthQuery = LengthQuery + 35 + strlen (Qst_DB_StrAnswerTypes[AnsType]) + 1;
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 256)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||
" AND (tst_questions.AnsType='",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,Qst_DB_StrAnswerTypes[AnsType],Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* End the query */
|
||||
Str_Concat (Query," GROUP BY tst_questions.QstCod",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
|
||||
switch (Questions->SelectedOrder)
|
||||
{
|
||||
case Qst_ORDER_STEM:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_NUM_HITS:
|
||||
Str_Concat (Query," ORDER BY tst_questions.NumHits DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_AVERAGE_SCORE:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHits DESC,"
|
||||
"tst_questions.NumHits DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_NUM_HITS_NOT_BLANK:
|
||||
Str_Concat (Query," ORDER BY tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
case Qst_ORDER_AVERAGE_SCORE_NOT_BLANK:
|
||||
Str_Concat (Query," ORDER BY tst_questions.Score/tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.NumHitsNotBlank DESC,"
|
||||
"tst_questions.Stem",
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Make the query */
|
||||
if ((NumQsts = (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get questions",
|
||||
"%s",
|
||||
Query)) == 0)
|
||||
Ale_ShowAlert (Ale_INFO,Txt_No_questions_found_matching_your_search_criteria);
|
||||
|
||||
return NumQsts;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get questions for a new test print **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Tst_MAX_BYTES_QUERY_QUESTIONS (16 * 1024 - 1)
|
||||
|
||||
unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Questions *Questions)
|
||||
unsigned Qst_DB_GetQstsForNewTestPrint (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Questions *Questions)
|
||||
{
|
||||
extern const char *Qst_DB_StrAnswerTypes[Qst_NUM_ANS_TYPES];
|
||||
char *Query = NULL;
|
||||
|
@ -123,7 +269,7 @@ unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
|||
char StrNumQsts[Cns_MAX_DECIMAL_DIGITS_UINT + 1];
|
||||
|
||||
/***** Allocate space for query *****/
|
||||
if ((Query = malloc (Tst_MAX_BYTES_QUERY_QUESTIONS + 1)) == NULL)
|
||||
if ((Query = malloc (Qst_MAX_BYTES_QUERY_QUESTIONS + 1)) == NULL)
|
||||
Err_NotEnoughMemoryExit ();
|
||||
|
||||
/***** Select questions without hidden tags *****/
|
||||
|
@ -131,7 +277,7 @@ unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
|||
// Reject questions with any tag hidden
|
||||
// Select only questions with tags
|
||||
// DISTINCTROW is necessary to not repeat questions
|
||||
snprintf (Query,Tst_MAX_BYTES_QUERY_QUESTIONS + 1,
|
||||
snprintf (Query,Qst_MAX_BYTES_QUERY_QUESTIONS + 1,
|
||||
"SELECT DISTINCTROW tst_questions.QstCod," // row[0]
|
||||
"tst_questions.AnsType," // row[1]
|
||||
"tst_questions.Shuffle" // row[2]
|
||||
|
@ -160,17 +306,17 @@ unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
|||
{
|
||||
Par_GetNextStrUntilSeparParamMult (&Ptr,TagText,Tag_MAX_BYTES_TAG);
|
||||
LengthQuery = LengthQuery + 35 + strlen (TagText) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_QUESTIONS - 128)
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 128)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_tags.TagTxt='" :
|
||||
" AND (tst_tags.TagTxt='",
|
||||
Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,TagText,Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,TagText,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* Add answer types selected */
|
||||
|
@ -184,23 +330,23 @@ unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
|||
Par_GetNextStrUntilSeparParamMult (&Ptr,UnsignedStr,Tag_MAX_BYTES_TAG);
|
||||
AnswerType = Qst_ConvertFromUnsignedStrToAnsTyp (UnsignedStr);
|
||||
LengthQuery = LengthQuery + 35 + strlen (Qst_DB_StrAnswerTypes[AnswerType]) + 1;
|
||||
if (LengthQuery > Tst_MAX_BYTES_QUERY_QUESTIONS - 128)
|
||||
if (LengthQuery > Qst_MAX_BYTES_QUERY_QUESTIONS - 128)
|
||||
Err_QuerySizeExceededExit ();
|
||||
Str_Concat (Query,
|
||||
NumItemInList ? " OR tst_questions.AnsType='" :
|
||||
" AND (tst_questions.AnsType='",
|
||||
Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,Qst_DB_StrAnswerTypes[AnswerType],Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,Qst_DB_StrAnswerTypes[AnswerType],Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,"'",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
NumItemInList++;
|
||||
}
|
||||
Str_Concat (Query,")",Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,")",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
}
|
||||
|
||||
/* End query */
|
||||
Str_Concat (Query," ORDER BY RAND() LIMIT ",Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query," ORDER BY RAND() LIMIT ",Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
snprintf (StrNumQsts,sizeof (StrNumQsts),"%u",Questions->NumQsts);
|
||||
Str_Concat (Query,StrNumQsts,Tst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
Str_Concat (Query,StrNumQsts,Qst_MAX_BYTES_QUERY_QUESTIONS);
|
||||
/*
|
||||
if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
|
||||
Lay_ShowAlert (Lay_INFO,Query);
|
||||
|
@ -756,6 +902,63 @@ unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Scope,
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************** Get data of a question from database *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Qst_DB_GetQstData (MYSQL_RES **mysql_res,long QstCod)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get a question",
|
||||
"SELECT UNIX_TIMESTAMP(EditTime)," // row[0]
|
||||
"AnsType," // row[1]
|
||||
"Shuffle," // row[2]
|
||||
"Stem," // row[3]
|
||||
"Feedback," // row[4]
|
||||
"MedCod," // row[5]
|
||||
"NumHits," // row[6]
|
||||
"NumHitsNotBlank," // row[7]
|
||||
"Score" // row[8]
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
QstCod,
|
||||
Gbl.Hierarchy.Crs.CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get answer type of a question from database *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
Qst_AnswerType_t Qst_DB_GetQstAnswerType (long QstCod)
|
||||
{
|
||||
char StrAnsTypeDB[256];
|
||||
|
||||
/***** Get type of answer from database *****/
|
||||
DB_QuerySELECTString (StrAnsTypeDB,sizeof (StrAnsTypeDB) - 1,
|
||||
"can not get the type of a question",
|
||||
"SELECT AnsType"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
return Qst_ConvertFromStrAnsTypDBToAnsTyp (StrAnsTypeDB);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Get media code associated with the stem of a test question *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
long Qst_DB_GetQstMedCod (long CrsCod,long QstCod)
|
||||
{
|
||||
return DB_QuerySELECTCode ("can not get media",
|
||||
"SELECT MedCod"
|
||||
" FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld", // Extra check
|
||||
QstCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Get number of answers of a question from database **************/
|
||||
/*****************************************************************************/
|
||||
|
@ -815,3 +1018,63 @@ unsigned Qst_DB_GetTextOfAnswers (MYSQL_RES **mysql_res,long QstCod)
|
|||
|
||||
return NumOptions;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Get suffled/not-shuffled answers indexes of question ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question)
|
||||
{
|
||||
return (unsigned)
|
||||
DB_QuerySELECT (mysql_res,"can not get questions of a game",
|
||||
"SELECT AnsInd" // row[0]
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" ORDER BY %s",
|
||||
Question->QstCod,
|
||||
Question->Answer.Shuffle ? "RAND()" : // Use RAND() because is really random; RAND(NOW()) repeats order
|
||||
"AnsInd");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Get media code associated to an answer of a test question *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
long Qst_DB_GetAnswerMedCod (long QstCod,unsigned AnsInd)
|
||||
{
|
||||
return DB_QuerySELECTCode ("can not get media",
|
||||
"SELECT MedCod"
|
||||
" FROM tst_answers"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND AnsInd=%u",
|
||||
QstCod,
|
||||
AnsInd);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Remove a question from database **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_DB_RemoveQst (long CrsCod,long QstCod)
|
||||
{
|
||||
DB_QueryDELETE ("can not remove a question",
|
||||
"DELETE FROM tst_questions"
|
||||
" WHERE QstCod=%ld"
|
||||
" AND CrsCod=%ld",
|
||||
QstCod,
|
||||
CrsCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Remove answers from a test question ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Qst_DB_RemAnsFromQst (long QstCod)
|
||||
{
|
||||
/***** Remove answers *****/
|
||||
DB_QueryDELETE ("can not remove the answers of a question",
|
||||
"DELETE FROM tst_answers"
|
||||
" WHERE QstCod=%ld",
|
||||
QstCod);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@
|
|||
|
||||
void Qst_DB_UpdateQstScore (long QstCod,bool AnswerIsNotBlank,double Score);
|
||||
|
||||
unsigned Qst_DB_GetQuestionsForNewTestPrint (MYSQL_RES **mysql_res,
|
||||
unsigned Qst_DB_GetQsts (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Questions *Questions);
|
||||
unsigned Qst_DB_GetQstsForNewTestPrint (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Questions *Questions);
|
||||
unsigned Qst_DB_GetNumQsts (MYSQL_RES **mysql_res,
|
||||
HieLvl_Level_t Scope,Qst_AnswerType_t AnsType);
|
||||
|
@ -60,8 +62,18 @@ unsigned Qst_DB_GetNumCrssWithQsts (HieLvl_Level_t Scope,
|
|||
unsigned Qst_DB_GetNumCrssWithPluggableQsts (HieLvl_Level_t Scope,
|
||||
Qst_AnswerType_t AnsType);
|
||||
|
||||
unsigned Qst_DB_GetQstData (MYSQL_RES **mysql_res,long QstCod);
|
||||
Qst_AnswerType_t Qst_DB_GetQstAnswerType (long QstCod);
|
||||
long Qst_DB_GetQstMedCod (long CrsCod,long QstCod);
|
||||
|
||||
unsigned Qst_DB_GetNumAnswersQst (long QstCod);
|
||||
unsigned Qst_DB_GetDataOfAnswers (MYSQL_RES **mysql_res,long QstCod,bool Shuffle);
|
||||
unsigned Qst_DB_GetTextOfAnswers (MYSQL_RES **mysql_res,long QstCod);
|
||||
unsigned Qst_DB_GetShuffledAnswersIndexes (MYSQL_RES **mysql_res,
|
||||
const struct Qst_Question *Question);
|
||||
long Qst_DB_GetAnswerMedCod (long QstCod,unsigned AnsInd);
|
||||
|
||||
void Qst_DB_RemoveQst (long CrsCod,long QstCod);
|
||||
void Qst_DB_RemAnsFromQst (long QstCod);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -981,17 +981,17 @@ static void Rec_ShowRecordOneStdCrs (void)
|
|||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
|
||||
/* Edit record fields */
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH)
|
||||
Rec_PutLinkToEditRecordFields ();
|
||||
/* Edit record fields */
|
||||
if (Gbl.Usrs.Me.Role.Logged == Rol_TCH)
|
||||
Rec_PutLinkToEditRecordFields ();
|
||||
|
||||
/* Print view */
|
||||
Frm_BeginForm (ActPrnRecSevStd);
|
||||
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
|
||||
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
||||
Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
||||
Rec_ShowLinkToPrintPreviewOfRecords ();
|
||||
Frm_EndForm ();
|
||||
/* Print view */
|
||||
Frm_BeginForm (ActPrnRecSevStd);
|
||||
Usr_CreateListSelectedUsrsCodsAndFillWithOtherUsr (&Gbl.Usrs.Selected);
|
||||
Usr_PutHiddenParSelectedUsrsCods (&Gbl.Usrs.Selected);
|
||||
Usr_FreeListsSelectedEncryptedUsrsCods (&Gbl.Usrs.Selected);
|
||||
Rec_ShowLinkToPrintPreviewOfRecords ();
|
||||
Frm_EndForm ();
|
||||
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
|
|
|
@ -896,7 +896,7 @@ static void Rep_GetAndWriteMyCurrentCrss (Rol_Role_t Role,
|
|||
unsigned NumCrs;
|
||||
long CrsCod;
|
||||
|
||||
NumCrss = Usr_GetNumCrssOfUsrWithARole (Gbl.Usrs.Me.UsrDat.UsrCod,Role);
|
||||
NumCrss = Usr_DB_GetNumCrssOfUsrWithARole (Gbl.Usrs.Me.UsrDat.UsrCod,Role);
|
||||
fprintf (Gbl.F.Rep,"<li>");
|
||||
fprintf (Gbl.F.Rep,Txt_USER_in_COURSE,
|
||||
Txt_ROLES_SINGUL_Abc[Role][Gbl.Usrs.Me.UsrDat.Sex]);
|
||||
|
|
|
@ -119,18 +119,18 @@ void Rol_SetMyRoles (void)
|
|||
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
||||
{
|
||||
/* Check if I am and administrator of current institution */
|
||||
ICanBeInsAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
ICanBeInsAdm = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
HieLvl_INS,
|
||||
Gbl.Hierarchy.Ins.InsCod);
|
||||
if (Gbl.Hierarchy.Ctr.CtrCod > 0)
|
||||
{
|
||||
/* Check if I am and administrator of current center */
|
||||
ICanBeCtrAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
ICanBeCtrAdm = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
HieLvl_CTR,
|
||||
Gbl.Hierarchy.Ctr.CtrCod);
|
||||
if (Gbl.Hierarchy.Deg.DegCod > 0)
|
||||
/* Check if I am and administrator of current degree */
|
||||
ICanBeDegAdm = Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
ICanBeDegAdm = Usr_DB_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
HieLvl_DEG,
|
||||
Gbl.Hierarchy.Deg.DegCod);
|
||||
}
|
||||
|
|
|
@ -492,8 +492,8 @@ static void Sta_PutFormGblHits (struct Sta_Stats *Stats)
|
|||
|
||||
/***** Contextual menu *****/
|
||||
Mnu_ContextMenuBegin ();
|
||||
Sta_PutLinkToCourseHits (); // Course hits
|
||||
Log_PutLinkToLastClicks (); // Last clicks in real time
|
||||
Sta_PutLinkToCourseHits (); // Course hits
|
||||
Log_PutLinkToLastClicks (); // Last clicks in real time
|
||||
Mnu_ContextMenuEnd ();
|
||||
|
||||
/***** Begin form *****/
|
||||
|
|
|
@ -491,7 +491,7 @@ void Tst_PutIconsTests (__attribute__((unused)) void *Args)
|
|||
/************** Get questions for a new test from the database ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Tst_MAX_BYTES_QUERY_QUESTIONS (16 * 1024 - 1)
|
||||
#define Qst_MAX_BYTES_QUERY_QUESTIONS (16 * 1024 - 1)
|
||||
|
||||
static void Tst_GetQuestionsForNewTest (struct Qst_Questions *Questions,
|
||||
struct TstPrn_Print *Print)
|
||||
|
@ -509,7 +509,7 @@ static void Tst_GetQuestionsForNewTest (struct Qst_Questions *Questions,
|
|||
|
||||
/***** Get questions and answers from database *****/
|
||||
Print->NumQsts.All =
|
||||
Questions->NumQsts = Qst_DB_GetQuestionsForNewTestPrint (&mysql_res,Questions);
|
||||
Questions->NumQsts = Qst_DB_GetQstsForNewTestPrint (&mysql_res,Questions);
|
||||
|
||||
for (QstInd = 0;
|
||||
QstInd < Print->NumQsts.All;
|
||||
|
|
|
@ -746,7 +746,7 @@ void TstPrn_ComputeScoresAndStoreQuestionsOfPrint (struct TstPrn_Print *Print,
|
|||
/* Compute question score */
|
||||
Qst_QstConstructor (&Question);
|
||||
Question.QstCod = Print->PrintedQuestions[QstInd].QstCod;
|
||||
Question.Answer.Type = Qst_GetQstAnswerTypeFromDB (Question.QstCod);
|
||||
Question.Answer.Type = Qst_DB_GetQstAnswerType (Question.QstCod);
|
||||
TstPrn_ComputeAnswerScore (&Print->PrintedQuestions[QstInd],&Question);
|
||||
Qst_QstDestructor (&Question);
|
||||
|
||||
|
|
1453
swad_user.c
1453
swad_user.c
File diff suppressed because it is too large
Load Diff
22
swad_user.h
22
swad_user.h
|
@ -305,17 +305,17 @@ void Usr_WriteFirstNameBRSurnames (const struct UsrData *UsrDat);
|
|||
|
||||
void Usr_FlushCachesUsr (void);
|
||||
|
||||
bool Usr_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||
bool Usr_DB_CheckIfUsrIsAdm (long UsrCod,HieLvl_Level_t Scope,long Cod);
|
||||
void Usr_FlushCacheUsrIsSuperuser (void);
|
||||
bool Usr_CheckIfUsrIsSuperuser (long UsrCod);
|
||||
|
||||
bool Usr_ICanChangeOtherUsrData (const struct UsrData *UsrDat);
|
||||
bool Usr_ICanEditOtherUsr (const struct UsrData *UsrDat);
|
||||
|
||||
unsigned Usr_GetNumCrssOfUsr (long UsrCod);
|
||||
unsigned Usr_GetNumCrssOfUsrNotAccepted (long UsrCod);
|
||||
unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role);
|
||||
unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role);
|
||||
unsigned Usr_DB_GetNumCrssOfUsr (long UsrCod);
|
||||
unsigned Usr_DB_GetNumCrssOfUsrNotAccepted (long UsrCod);
|
||||
unsigned Usr_DB_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role);
|
||||
unsigned Usr_DB_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role);
|
||||
|
||||
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||
unsigned OthersRoles);
|
||||
|
@ -364,7 +364,7 @@ bool Usr_CheckIfIBelongToCtr (long CtrCod);
|
|||
bool Usr_CheckIfIBelongToDeg (long DegCod);
|
||||
bool Usr_CheckIfIBelongToCrs (long CrsCod);
|
||||
|
||||
unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res);
|
||||
unsigned Usr_DB_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res);
|
||||
unsigned Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res);
|
||||
unsigned Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res);
|
||||
unsigned Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res);
|
||||
|
@ -373,7 +373,7 @@ void Usr_GetMainDeg (long UsrCod,
|
|||
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1],
|
||||
Rol_Role_t *MaxRole);
|
||||
|
||||
bool Usr_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64]);
|
||||
bool Usr_DB_ChkIfEncryptedUsrCodExists (const char EncryptedUsrCod[Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64]);
|
||||
|
||||
void Usr_WriteLandingPage (void);
|
||||
void Usr_WriteFormLogout (void);
|
||||
|
@ -417,10 +417,10 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat,
|
|||
bool PutCheckBoxToSelectUsr,Rol_Role_t Role,
|
||||
struct SelectedUsrs *SelectedUsrs);
|
||||
|
||||
long Usr_GetRamdomStdFromCrs (long CrsCod);
|
||||
long Usr_GetRamdomStdFromGrp (long GrpCod);
|
||||
long Usr_DB_GetRamdomStdFromCrs (long CrsCod);
|
||||
long Usr_DB_GetRamdomStdFromGrp (long GrpCod);
|
||||
|
||||
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod);
|
||||
unsigned Usr_DB_GetNumTchsCurrentInsInDepartment (long DptCod);
|
||||
|
||||
void Usr_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
||||
unsigned Usr_GetNumUsrsWhoDontClaimToBelongToAnyCty (void);
|
||||
|
@ -527,7 +527,7 @@ void Usr_SeeTchClassPhotoPrn (void);
|
|||
void Usr_PutSelectorNumColsClassPhoto (void);
|
||||
|
||||
void Usr_ConstructPathUsr (long UsrCod,char PathUsr[PATH_MAX + 1 + Cns_MAX_DECIMAL_DIGITS_LONG + 1]);
|
||||
bool Usr_ChkIfUsrCodExists (long UsrCod);
|
||||
bool Usr_DB_ChkIfUsrCodExists (long UsrCod);
|
||||
|
||||
void Usr_ShowWarningNoUsersFound (Rol_Role_t Role);
|
||||
|
||||
|
|
Loading…
Reference in New Issue