Version 16.220.11

This commit is contained in:
Antonio Cañas Vargas 2017-05-22 14:52:11 +02:00
parent f266182842
commit a49cf929dc
13 changed files with 389 additions and 141 deletions

View File

@ -461,7 +461,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
case Rol_TCH:
NextAction = ActCnfID_Tch;
break;
default: // Guest, visitor or admin
default: // Guest, user or admin
NextAction = ActCnfID_Oth;
break;
}
@ -521,7 +521,7 @@ void ID_PutLinkToChangeUsrIDs (void)
case Rol_TCH:
NextAction = ActFrmIDsTch;
break;
default: // Guest, visitor or admin
default: // Guest, user or admin
NextAction = ActFrmIDsOth;
break;
}
@ -623,7 +623,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe)
case Rol_TCH:
NextAction = ActRemID_Tch;
break;
default: // Guest, visitor or admin
default: // Guest, user or admin
NextAction = ActRemID_Oth;
break;
}
@ -688,7 +688,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe)
case Rol_TCH:
NextAction = ActNewID_Tch;
break;
default: // Guest, visitor or admin
default: // Guest, user or admin
NextAction = ActNewID_Oth;
break;
}

View File

@ -233,13 +233,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.220.10 (2017-05-22)"
#define Log_PLATFORM_VERSION "SWAD 16.220.11 (2017-05-22)"
#define CSS_FILE "swad16.209.3.css"
#define JS_FILE "swad16.206.3.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
/*
Version 16.220.11:May 22, 2017 Changes related with new role. Not finished. (220019 lines)
Version 16.220.10:May 22, 2017 Changes related with new role. Not finished. (219775 lines)
Version 16.220.9: May 22, 2017 Changes related with new role. Not finished. (219720 lines)
Version 16.220.8: May 22, 2017 Changes related with new role. Not finished. (219663 lines)

View File

@ -55,7 +55,7 @@ static const bool Enr_ICanAdminOtherUsrs[Rol_NUM_ROLES] =
false, // Rol_GST
false, // Rol_USR
false, // Rol_STD
false, // Rol_NED_TCH
false, // Rol_NET
/* Users who can admin */
true, // Rol_TCH

View File

@ -1115,7 +1115,7 @@ const unsigned long long Brw_MAX_QUOTA_BRIEF[Rol_NUM_ROLES] = // MaxRole is used
0, // Rol_GST
0, // Rol_USR
32ULL*Brw_GiB, // Rol_STD
32ULL*Brw_GiB, // Rol_NED_TCH
32ULL*Brw_GiB, // Rol_NET
64ULL*Brw_GiB, // Rol_TCH
0, // Rol_DEG_ADM
0, // Rol_CTR_ADM

View File

@ -1127,6 +1127,7 @@ long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
void Mai_PutLinkToChangeOtherUsrEmails (void)
{
extern const char *Txt_Change_email;
Act_Action_t NextAction;
/***** Link for changing the password *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
@ -1135,13 +1136,26 @@ void Mai_PutLinkToChangeOtherUsrEmails (void)
Txt_Change_email,Txt_Change_email,
NULL);
else // Not me
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActFrmMaiStd :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActFrmMaiTch :
ActFrmMaiOth),
NULL,Usr_PutParamOtherUsrCodEncrypted,
{
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActFrmMaiStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActFrmMaiTch;
break;
default: // Guest, user or admin
NextAction = ActFrmMaiOth;
break;
}
Lay_PutContextualLink (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,
"msg64x64.gif",
Txt_Change_email,Txt_Change_email,
NULL);
}
}
/*****************************************************************************/
@ -1203,6 +1217,7 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
unsigned NumEmails;
unsigned NumEmail;
bool Confirmed;
Act_Action_t NextAction;
/***** Get my emails *****/
sprintf (Query,"SELECT E_mail,Confirmed FROM usr_emails"
@ -1248,9 +1263,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
Act_FormStart (ActRemMaiMe);
else
{
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActRemMaiStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActRemMaiTch :
ActRemMaiOth)); // Guest, visitor or admin
switch (UsrDat->RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActRemMaiStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActRemMaiTch;
break;
default: // Guest, user or admin
NextAction = ActRemMaiOth;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
}
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"Email\" value=\"%s\" />",
@ -1284,9 +1310,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
Act_FormStart (ActNewMaiMe);
else
{
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActNewMaiStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActNewMaiTch :
ActNewMaiOth)); // Guest, visitor or admin
switch (UsrDat->RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActNewMaiStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActNewMaiTch;
break;
default: // Guest, user or admin
NextAction = ActNewMaiOth;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
}
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"NewEmail\" value=\"%s\" />",
@ -1314,9 +1351,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
Act_FormStart (ActNewMaiMe);
else
{
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActNewMaiStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActNewMaiTch :
ActNewMaiOth)); // Guest, visitor or admin
switch (UsrDat->RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActNewMaiStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActNewMaiTch;
break;
default: // Guest, user or admin
NextAction = ActNewMaiOth;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
}
fprintf (Gbl.F.Out,"<div class=\"FORM_ACCOUNT\">"
@ -1832,18 +1880,21 @@ bool Mai_ICanSeeOtherUsrEmail (const struct UsrData *UsrDat)
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
return true;
/* Check if I have permission to see another user's email */
/***** Check if I have permission to see another user's email *****/
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_STD:
/* If I am a student in the current course,
I can see the email of confirmed teachers */
return (UsrDat->RoleInCurrentCrsDB == Rol_TCH && // A teacher
UsrDat->Accepted); // who accepted registration
return (UsrDat->RoleInCurrentCrsDB == Rol_NET || // A non-editing teacher
UsrDat->RoleInCurrentCrsDB == Rol_TCH) && // or a teacher
UsrDat->Accepted; // who accepted registration
case Rol_NET:
case Rol_TCH:
/* If I am a teacher in the current course,
I can see the email of confirmed students and teachers */
return (UsrDat->RoleInCurrentCrsDB == Rol_STD || // A student
UsrDat->RoleInCurrentCrsDB == Rol_NET || // or a non-editing teacher
UsrDat->RoleInCurrentCrsDB == Rol_TCH) && // or a teacher
UsrDat->Accepted; // who accepted registration
case Rol_DEG_ADM:

View File

@ -624,7 +624,7 @@ void Mrk_ShowMyMarks (void)
/***** Set the student whose marks will be shown *****/
if (Gbl.Usrs.Me.LoggedRole == Rol_STD) // If I am logged as student...
UsrDat = &Gbl.Usrs.Me.UsrDat; // ...use my list of IDs
else // If I am logged as teacher, administrator, superuser...
else // If I am logged as non-editing teacher, teacher or admin
{
/* Select a random student from the course */
if (Gbl.CurrentCrs.Grps.GrpCod > 0) // Group zone

View File

@ -181,8 +181,9 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
bool ShowUsrsInCrs = false;
bool GetUsrsInCrs;
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs =
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs = 0;
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs =
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs =
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs = 0;
/***** Get parameter that indicates if the message is a reply to another message *****/
if ((Gbl.Msg.Reply.IsReply = Par_GetParToBool ("IsReply")))
@ -213,10 +214,12 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
Grp_GetParCodsSeveralGrpsToShowUsrs ();
/***** Get and order lists of users from this course *****/
Usr_GetListUsrs (Rol_TCH,Sco_SCOPE_CRS);
Usr_GetListUsrs (Rol_STD,Sco_SCOPE_CRS);
NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs +
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
Usr_GetListUsrs (Rol_NET,Sco_SCOPE_CRS);
Usr_GetListUsrs (Rol_TCH,Sco_SCOPE_CRS);
NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + // Students
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + // Non-editing teachers
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; // Teachers
}
/***** Start frame *****/
@ -288,6 +291,7 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
if (ShowUsrsInCrs)
{
Usr_ListUsersToSelect (Rol_TCH); // All teachers in course
Usr_ListUsersToSelect (Rol_NET); // All non-editing teachers in course
Usr_ListUsersToSelect (Rol_STD); // All students in selected groups
}
Msg_WriteFormUsrsIDsOrNicksOtherRecipients (); // Other users (nicknames)
@ -325,6 +329,7 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
if (GetUsrsInCrs)
{
Usr_FreeUsrsList (Rol_TCH);
Usr_FreeUsrsList (Rol_NET);
Usr_FreeUsrsList (Rol_STD);
}

View File

@ -813,6 +813,7 @@ void Pwd_ShowFormOthPwd (void)
extern const char *Txt_Password;
extern const char *Txt_Change_password;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
Act_Action_t NextAction;
/***** Get user whose password must be changed *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
@ -828,9 +829,20 @@ void Pwd_ShowFormOthPwd (void)
/***** Form to change password *****/
/* Start form */
Act_FormStart ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActChgPwdStd :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActChgPwdTch :
ActChgPwdOth));
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActChgPwdStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActChgPwdTch;
break;
default: // Guest, user or admin
NextAction = ActChgPwdOth;
break;
}
Act_FormStart (NextAction);
Usr_PutParamOtherUsrCodEncrypted ();
/* New password */
@ -874,18 +886,32 @@ void Pwd_PutLinkToChangeMyPassword (void)
void Pwd_PutLinkToChangeOtherUsrPassword (void)
{
extern const char *Txt_Change_password;
Act_Action_t NextAction;
/***** Link for changing the password *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
Pwd_PutLinkToChangeMyPassword ();
else // Not me
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActFrmPwdStd :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActFrmPwdTch :
ActFrmPwdOth),
NULL,Usr_PutParamOtherUsrCodEncrypted,
{
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActFrmPwdStd;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActFrmPwdTch;
break;
default: // Guest, user or admin
NextAction = ActFrmPwdOth;
break;
}
Lay_PutContextualLink (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,
"key64x64.gif",
Txt_Change_password,Txt_Change_password,
NULL);
}
}
/*****************************************************************************/

View File

@ -140,9 +140,9 @@ bool Pho_ICanChangeOtherUsrPhoto (const struct UsrData *UsrDat)
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TCH:
/* Check 1: I can change the photo of confirmed students */
/* A teacher can change the photo of confirmed students */
if (UsrDat->RoleInCurrentCrsDB == Rol_STD && // A student
UsrDat->Accepted) // who accepted registration
UsrDat->Accepted) // who accepted registration
return true;
return false;
@ -185,6 +185,7 @@ void Pho_PutLinkToChangeOtherUsrPhoto (void)
bool PhotoExists;
char PhotoURL[PATH_MAX + 1];
const char *TitleText;
Act_Action_t NextAction;
/***** Link for changing / uploading the photo *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
@ -195,10 +196,21 @@ void Pho_PutLinkToChangeOtherUsrPhoto (void)
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
TitleText = PhotoExists ? Txt_Change_photo :
Txt_Upload_photo;
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActReqStdPho :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActReqTchPho :
ActReqOthPho), // Guest, visitor or admin
NULL,Usr_PutParamOtherUsrCodEncrypted,
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActReqStdPho;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActReqTchPho;
break;
default: // Guest, user or admin
NextAction = ActReqOthPho;
break;
}
Lay_PutContextualLink (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,
"photo64x64.gif",
TitleText,TitleText,
NULL);
@ -230,17 +242,31 @@ static void Pho_PutIconToRequestRemoveOtherUsrPhoto (void)
extern const char *Txt_Remove_photo;
char PhotoURL[PATH_MAX + 1];
bool PhotoExists;
Act_Action_t NextAction;
/***** Link to request the removal of another user's photo *****/
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
if (PhotoExists)
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActReqRemStdPho :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActReqRemTchPho :
ActReqRemOthPho), // Guest, visitor or admin
NULL,Usr_PutParamOtherUsrCodEncrypted,
{
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActReqRemStdPho;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActReqRemTchPho;
break;
default: // Guest, user or admin
NextAction = ActReqRemOthPho;
break;
}
Lay_PutContextualLink (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,
"remove-on64x64.png",
Txt_Remove_photo,NULL,
NULL);
}
}
/*****************************************************************************/
@ -295,6 +321,7 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat,const char *PhotoURL)
extern const char *Txt_File_with_the_photo;
extern const char *Txt_Upload_photo;
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
Act_Action_t NextAction;
/***** Start frame *****/
Lay_StartRoundFrame (NULL,Txt_Photo,
@ -307,9 +334,20 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat,const char *PhotoURL)
Act_FormStart (ActDetMyPho);
else
{
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActDetStdPho :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActDetTchPho :
ActDetOthPho)); // Guest, visitor or admin
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActDetStdPho;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActDetTchPho;
break;
default: // Guest, user or admin
NextAction = ActDetOthPho;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
}
@ -459,6 +497,7 @@ void Pho_ReqRemoveUsrPhoto (void)
extern const char *Txt_The_photo_no_longer_exists;
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
char PhotoURL[PATH_MAX + 1];
Act_Action_t NextAction;
/***** Get user's code from form *****/
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
@ -482,10 +521,21 @@ void Pho_ReqRemoveUsrPhoto (void)
"PHOTO186x248",Pho_NO_ZOOM,false);
/* End alert */
Ale_ShowAlertAndButton2 ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActRemStdPho :
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActRemTchPho :
ActRemOthPho), // Guest, visitor or admin
NULL,Usr_PutParamOtherUsrCodEncrypted,
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActRemStdPho;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActRemTchPho;
break;
default: // Guest, user or admin
NextAction = ActRemOthPho;
break;
}
Ale_ShowAlertAndButton2 (NextAction,NULL,
Usr_PutParamOtherUsrCodEncrypted,
Lay_REMOVE_BUTTON,Txt_Remove_photo);
}
else
@ -560,6 +610,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
unsigned Radius;
unsigned BackgroundCode;
char StrFileName[NAME_MAX + 1];
Act_Action_t NextAction;
/***** Creates directories if not exist *****/
sprintf (PathPhotosPriv,"%s/%s",
@ -648,12 +699,26 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
if (BackgroundCode == 1)
{
NumFacesGreen++;
Act_FormStart (ItsMe ? ActUpdMyPho :
(UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActUpdStdPho :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActUpdTchPho :
ActUpdOthPho))); // Guest, visitor or admin
if (!ItsMe)
if (ItsMe)
Act_FormStart (ActUpdMyPho);
else
{
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActUpdStdPho;
break;
case Rol_NET:
case Rol_TCH:
NextAction = ActUpdTchPho;
break;
default: // Guest, user or admin
NextAction = ActUpdOthPho;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
}
Par_PutHiddenParamString ("FileName",StrFileName);
Act_FormEnd ();
}

View File

@ -95,6 +95,7 @@ static bool Rec_GetParamShowOfficeHours (void);
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
struct UsrData *UsrDat,const char *Anchor);
static void Rec_ShowMyCrsRecordUpdated (void);
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility);
static void Rec_PutIconsCommands (void);
static void Rec_PutParamUsrCodEncrypted (void);
@ -1135,7 +1136,8 @@ static void Rec_ShowRecordOneStdCrs (void)
/***** Record of the student in the course *****/
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
{
if (Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
if (Gbl.Usrs.Me.LoggedRole == Rol_NET ||
Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
{
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
@ -1264,7 +1266,8 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
/* Record of the student in the course */
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
if ( Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
if ( Gbl.Usrs.Me.LoggedRole == Rol_NET ||
Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
(Gbl.Usrs.Me.LoggedRole == Rol_STD && // I am student in this course...
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)) // ...and it's me
@ -1736,7 +1739,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
break;
}
else // It's not me ==> i am a student trying to do something forbidden
else // It's not me ==> I am a student trying to do something forbidden
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
}
@ -1913,8 +1916,7 @@ void Rec_GetFieldsCrsRecordFromForm (void)
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
{
/* Get text of the form */
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
@ -1936,8 +1938,7 @@ void Rec_UpdateCrsRecord (long UsrCod)
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
{
/***** Check if already exists this field for this user in database *****/
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
@ -2049,8 +2050,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
/* Allocate memory for the texts of the fields */
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
@ -2067,8 +2067,7 @@ void Rec_FreeMemFieldsRecordsCrs (void)
for (NumField = 0;
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
NumField++)
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
/* Free memory of the text of the field */
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text)
{
@ -2077,6 +2076,19 @@ void Rec_FreeMemFieldsRecordsCrs (void)
}
}
/*****************************************************************************/
/* Check if I can edit a field depending on my role and the field visibility */
/*****************************************************************************/
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility)
{
// Non-editing teachers can not edit fields
return Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
(Gbl.Usrs.Me.LoggedRole == Rol_STD &&
Visibility == Rec_EDITABLE_FIELD);
}
/*****************************************************************************/
/*********** Show form to sign up and edit my shared record card *************/
/*****************************************************************************/
@ -2212,7 +2224,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
Hlp_USERS_Guests, // Rol_GST
NULL, // Rol_USR
Hlp_USERS_Students_shared_record_card, // Rol_STD
Hlp_USERS_Teachers_shared_record_card, // Rol_NED_TCH
Hlp_USERS_Teachers_shared_record_card, // Rol_NET
Hlp_USERS_Teachers_shared_record_card, // Rol_TCH
NULL, // Rol_DEG_ADM
NULL, // Rol_CTR_ADM
@ -2222,39 +2234,50 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
char StrRecordWidth[10 + 1];
const char *ClassForm = "REC_DAT";
bool ItsMe;
bool IAmLoggedAsTeacher;
bool IAmLoggedAsSysAdm;
bool IAmLoggedAsTeacherOrSysAdm;
bool CountryForm;
bool ICanEdit;
bool PutFormLinks; // Put links (forms) inside record card
bool ShowData;
bool ShowIDRows;
bool ShowAddressRows;
bool StudentInCurrentCrs;
bool TeacherInCurrentCrs;
bool TeacherInAnyCrs;
bool ShowTeacherRows;
struct Instit Ins;
Act_Action_t NextAction;
/***** Initializations *****/
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TCH); // My current role is teacher
IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
IAmLoggedAsTeacherOrSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_NET || // My current role is non-editing teacher
Gbl.Usrs.Me.LoggedRole == Rol_TCH || // My current role is teacher
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is system admin
CountryForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
ShowData = (ItsMe ||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
UsrDat->Accepted);
ShowIDRows = (TypeOfView != Rec_SHA_RECORD_PUBLIC);
StudentInCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STD;
TeacherInCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_NET ||
UsrDat->RoleInCurrentCrsDB == Rol_TCH;
TeacherInAnyCrs = UsrDat->Roles & ((1 << Rol_NET) |
(1 << Rol_TCH));
ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM ||
TypeOfView == Rec_SHA_MY_RECORD_CHECK ||
((TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
(IAmLoggedAsTeacher || IAmLoggedAsSysAdm) &&
UsrDat->RoleInCurrentCrsDB == Rol_STD));
IAmLoggedAsTeacherOrSysAdm &&
StudentInCurrentCrs)); // He/she is a student in the current course
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got
ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_FORM ||
TypeOfView == Rec_SHA_MY_RECORD_CHECK) &&
(UsrDat->Roles & (1 << Rol_TCH))) || // He/she (me, really) is a teacher in any course
TeacherInAnyCrs) || // He/she (me, really) is a teacher in any course
((TypeOfView == Rec_SHA_RECORD_LIST ||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
UsrDat->RoleInCurrentCrsDB == Rol_TCH)); // He/she is a teacher in the current course
TeacherInCurrentCrs)); // He/she is a teacher in the current course
/* Data form = I can edit fields like surnames and name */
switch (TypeOfView)
@ -2358,15 +2381,41 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
Act_FormStart (ActChgMyData);
break;
case Rec_SHA_OTHER_NEW_USR_FORM:
Act_FormStart ( Gbl.Action.Act == ActReqMdfStd ? ActCreStd :
(Gbl.Action.Act == ActReqMdfTch ? ActCreTch :
ActCreOth));
switch (Gbl.Action.Act)
{
case ActReqMdfStd:
NextAction = ActCreStd;
break;
case ActReqMdfNET:
NextAction = ActCreNET;
break;
case ActReqMdfTch:
NextAction = ActCreTch;
break;
default:
NextAction = ActCreOth;
break;
}
Act_FormStart (NextAction);
ID_PutParamOtherUsrIDPlain (); // New user
break;
case Rec_SHA_OTHER_EXISTING_USR_FORM:
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActUpdStd :
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActUpdTch :
ActUpdOth));
switch (UsrDat->RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActUpdStd;
break;
case Rol_NET:
NextAction = ActUpdNET;
break;
case Rol_TCH:
NextAction = ActUpdTch;
break;
default: // Guest, user or admin
NextAction = ActUpdOth;
break;
}
Act_FormStart (NextAction);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
break;
default:
@ -2502,9 +2551,11 @@ static void Rec_PutIconsCommands (void)
extern const char *Txt_Follow;
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Record.UsrDat->UsrCod);
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STD); // My current role is student
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TCH); // My current role is teacher
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_NET || // My current role is non-editing teacher
Gbl.Usrs.Me.LoggedRole == Rol_TCH); // My current role is teacher
bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
bool ICanViewUsrProfile;
Act_Action_t NextAction;
if (!Gbl.Form.Inside && // Only if not inside another form
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW && // Only in main window
@ -2565,17 +2616,32 @@ static void Rec_PutIconsCommands (void)
(Gbl.CurrentCtr.Ctr.CtrCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_CTR_ADM) ||
(Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
Lay_PutContextualLink ( Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActReqMdfStd :
(Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActReqMdfTch :
ActReqMdfOth),
NULL,Rec_PutParamUsrCodEncrypted,
{
switch (Gbl.Record.UsrDat->RoleInCurrentCrsDB)
{
case Rol_STD:
NextAction = ActReqMdfStd;
break;
case Rol_NET:
NextAction = ActReqMdfNET;
break;
case Rol_TCH:
NextAction = ActReqMdfTch;
break;
default: // Guest, user or admin
NextAction = ActReqMdfOth;
break;
}
Lay_PutContextualLink (NextAction,NULL,
Rec_PutParamUsrCodEncrypted,
"config64x64.gif",
Txt_Administer_user,NULL,
NULL);
}
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
{
/***** Button to view user's assignments and works *****/
if (ItsMe) // I am a student
@ -2618,9 +2684,9 @@ static void Rec_PutIconsCommands (void)
/***** Button to print QR code *****/
if (ItsMe || IAmLoggedAsSysAdm ||
(Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
(Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
IAmLoggedAsTeacher)) // I am a teacher in the current course
IAmLoggedAsTeacher)) // I am a teacher in the current course
Lay_PutContextualLink (ActPrnUsrQR,NULL,Rec_PutParamUsrCodEncrypted,
"qr64x64.gif",
Txt_QR_code,NULL,
@ -2914,10 +2980,13 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
switch (TypeOfView)
{
case Rec_SHA_SIGN_UP_FORM: // I want to apply for enrolment
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TCH)) || // I am teacher in other courses
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
Rol_TCH :
Rol_STD;
if (UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod || // Creator of the course
(UsrDat->Roles & (1 << Rol_TCH))) // Teacher in other courses
DefaultRoleInCurrentCrs = Rol_TCH;
else if ((UsrDat->Roles & (1 << Rol_NET))) // Non-editing teacher in other courses
DefaultRoleInCurrentCrs = Rol_NET;
else
DefaultRoleInCurrentCrs = Rol_STD;
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
for (Role = Rol_STD;
Role <= Rol_TCH;
@ -2939,8 +3008,14 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
{
/* If there is a request of this user, default role is the requested role */
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNK)
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TCH)) ? Rol_TCH :
Rol_STD;
{
if ((UsrDat->Roles & (1 << Rol_TCH))) // Teacher in other courses
DefaultRoleInCurrentCrs = Rol_TCH;
else if ((UsrDat->Roles & (1 << Rol_NET))) // Non-editing teacher in other courses
DefaultRoleInCurrentCrs = Rol_NET;
else
DefaultRoleInCurrentCrs = Rol_STD;
}
}
else
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
@ -2950,6 +3025,7 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
case Rol_GST:
case Rol_USR:
case Rol_STD:
case Rol_NET:
fprintf (Gbl.F.Out,"<option value=\"%u\""
" selected=\"selected\""
" disabled=\"disabled\">"
@ -2981,8 +3057,9 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
else // No course selected
{
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STD) |
(1 << Rol_TCH))) ? Rol_USR :
Rol_GST;
(1 << Rol_NET) |
(1 << Rol_TCH))) ? Rol_USR : // If user belongs to any course
Rol_GST; // If user don't belong to any course
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\""
" disabled=\"disabled\">%s</option>",
(unsigned) DefaultRoleInCurrentCrs,
@ -3672,7 +3749,7 @@ void Rec_UpdateMyRecord (void)
Rol_Role_t Rec_GetRoleFromRecordForm (void)
{
Rol_Role_t Role;
bool RoleOK = false;
bool RoleOK;
/***** Get role as a parameter from form *****/
Role = (Rol_Role_t)
@ -3684,36 +3761,27 @@ Rol_Role_t Rec_GetRoleFromRecordForm (void)
/***** Check if I can register a user
with the received role in current course *****/
/* Check for other possible errors */
RoleOK = false;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_STD: // I am logged as student
/* A student can only change his/her data, but not his/her role */
if (Role == Rol_STD)
case Rol_NET: // I am logged as non-editing teacher
/* A student or a non-editing teacher can only change his/her data, but not his/her role */
if (Role == Gbl.Usrs.Me.LoggedRole)
RoleOK = true;
break;
/*
case Rol_TCH: // I am logged as teacher
// A teacher can only register another user as teacher
// if the other is already teacher in any course.
// That is, a teacher can not upgrade a student
// (in all other courses) to teacher
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Other.UsrDat);
if ( Role == Rol_STD ||
(Role == Rol_TCH && // He/she will be a teacher in current course
(Gbl.Usrs.Other.UsrDat.Roles & (1 << Rol_TCH)))) // He/she was a teacher in some courses
RoleOK = true;
break;
*/
case Rol_TCH: // I am logged as teacher
case Rol_DEG_ADM: // I am logged as degree admin
case Rol_CTR_ADM: // I am logged as centre admin
case Rol_INS_ADM: // I am logged as institution admin
if (Role == Rol_STD ||
Role == Rol_NET ||
Role == Rol_TCH)
RoleOK = true;
break;
case Rol_SYS_ADM:
if ( Role == Rol_STD ||
Role == Rol_NET ||
Role == Rol_TCH ||
(Role == Rol_GST && Gbl.CurrentCrs.Crs.CrsCod <= 0))
RoleOK = true;

View File

@ -25607,7 +25607,7 @@ const char *Txt_No_users_found[Rol_NUM_ROLES] =
"Nenhum estudante encontrado."
#endif
,
#if L==1 // Rol_NED_TCH
#if L==1 // Rol_NET
"No hi ha professors."
#elif L==2
"Keine Lehrkr&auml;ften gefunden."
@ -32437,7 +32437,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
#endif
},
{
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
"Professor/a no editor/a"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -32457,7 +32457,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professor/a n&atilde;o editor/a"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
#if L==1 // Rol_NET - Usr_SEX_FEMALE
"Professora no editora"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -32477,7 +32477,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professora n&atilde;o editora"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
#if L==1 // Rol_NET - Usr_SEX_MALE
"Professor no editor"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -32497,7 +32497,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professor n&atilde;o editor"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
#if L==1 // Rol_NET - Usr_SEX_ALL
"Professor/a no editor/a"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -33250,7 +33250,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
#endif
},
{
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
"professor/a no editor/a"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -33270,7 +33270,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professor/a n&atilde;o editor/a"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
#if L==1 // Rol_NET - Usr_SEX_FEMALE
"professora no editora"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -33290,7 +33290,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professora n&atilde;o editora"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
#if L==1 // Rol_NET - Usr_SEX_MALE
"professor no editor"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -33310,7 +33310,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professor n&atilde;o editor"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
#if L==1 // Rol_NET - Usr_SEX_ALL
"professor/a no editor/a"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -34064,7 +34064,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
#endif
},
{
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
"Professors no editors"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -34084,7 +34084,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professores n&atilde;o editores"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
#if L==1 // Rol_NET - Usr_SEX_FEMALE
"Professores no editores"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -34104,7 +34104,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professoras n&atilde;o editoras"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
#if L==1 // Rol_NET - Usr_SEX_MALE
"Professors no editors"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -34124,7 +34124,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"Professores n&atilde;o editores"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
#if L==1 // Rol_NET - Usr_SEX_ALL
"Professors no editors"
#elif L==2
"Nicht bearbeiteter Lehrkraft"
@ -34877,7 +34877,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
#endif
},
{
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
"professors no editors"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -34897,7 +34897,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professores n&atilde;o editores"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
#if L==1 // Rol_NET - Usr_SEX_FEMALE
"professores no editores"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -34917,7 +34917,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professoras n&atilde;o editoras"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
#if L==1 // Rol_NET - Usr_SEX_MALE
"professors no editors"
#elif L==2
"nicht bearbeiteter Lehrkraft"
@ -34937,7 +34937,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
"professores n&atilde;o editores"
#endif
,
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
#if L==1 // Rol_NET - Usr_SEX_ALL
"professors no editors"
#elif L==2
"nicht bearbeiteter Lehrkraft"

View File

@ -946,6 +946,7 @@ unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role)
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
Rol_Role_t OthersRole)
{
char SubQueryRole[64];
char Query[512];
unsigned NumUsrs;
// This query can be made in a unique, but slower, query
@ -956,22 +957,53 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary tables");
/***** Create temporary table with all user's courses for a role *****/
/***** Create temporary table with all user's courses as student/teacher *****/
switch (UsrRole)
{
case Rol_STD: // Student
sprintf (SubQueryRole,"Role=%u",
(unsigned) Rol_STD);
break;
case Rol_NET: // Non-editing teacher
case Rol_TCH: // or teacher
sprintf (SubQueryRole,"(Role=%u OR Role=%u)",
(unsigned) Rol_NET,(unsigned) Rol_TCH);
break;
default:
SubQueryRole[0] = '\0';
Lay_ShowErrorAndExit ("Wrong role.");
break;
}
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
" ENGINE=MEMORY"
" SELECT CrsCod FROM crs_usr"
" WHERE UsrCod=%ld AND Role=%u",
UsrCod,(unsigned) UsrRole);
" WHERE UsrCod=%ld AND %s",
UsrCod,SubQueryRole);
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table");
/***** Get the number of teachers in a course from database ******/
/***** Get the number of students/teachers in a course from database ******/
switch (OthersRole)
{
case Rol_STD: // Student
sprintf (SubQueryRole,"crs_usr.Role=%u",
(unsigned) Rol_STD);
break;
case Rol_NET: // Non-editing teacher
case Rol_TCH: // or teacher
sprintf (SubQueryRole,"(crs_usr.Role=%u OR crs_usr.Role=%u)",
(unsigned) Rol_NET,(unsigned) Rol_TCH);
break;
default:
SubQueryRole[0] = '\0';
Lay_ShowErrorAndExit ("Wrong role.");
break;
}
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
" FROM crs_usr,usr_courses_tmp"
" WHERE crs_usr.CrsCod=usr_courses_tmp.CrsCod"
" AND crs_usr.Role=%u",
(unsigned) OthersRole);
" WHERE crs_usr.CrsCod=usr_courses_tmp.CrsCod AND %s",
SubQueryRole);
NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users");
/***** Remove temporary table *****/

View File

@ -185,7 +185,7 @@ Svc_Role_t Svc_RolRole_to_SvcRole[Rol_NUM_ROLES] =
Svc_ROLE__GUEST_, // Rol_GST
Svc_ROLE_UNKNOWN, // Rol_USR
Svc_ROLE_STUDENT, // Rol_STD
Svc_ROLE_TEACHER, // Rol_NED_TCH // TODO: Create new web service role for non-editing teachers
Svc_ROLE_TEACHER, // Rol_NET // TODO: Create new web service role for non-editing teachers
Svc_ROLE_TEACHER, // Rol_TCH
Svc_ROLE_UNKNOWN, // Rol_DEG_ADM
Svc_ROLE_UNKNOWN, // Rol_CTR_ADM