diff --git a/swad_changelog.h b/swad_changelog.h
index 1731c6c22..3ef650163 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -233,13 +233,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.220.13 (2017-05-22)"
+#define Log_PLATFORM_VERSION "SWAD 16.220.14 (2017-05-23)"
#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.14:May 23, 2017 Changes related with new role. Not finished. (220243 lines)
Version 16.220.13:May 22, 2017 Changes related with new role. Not finished. (220190 lines)
Version 16.220.12:May 22, 2017 Changes related with new role. Not finished. (220155 lines)
Version 16.220.11:May 22, 2017 Changes related with new role. Not finished. (220019 lines)
diff --git a/swad_survey.c b/swad_survey.c
index b671641e6..0e59ffa88 100644
--- a/swad_survey.c
+++ b/swad_survey.c
@@ -1020,7 +1020,7 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed,
if (Usr_CheckIfIBelongToDeg (Gbl.CurrentDeg.Deg.DegCod))
{
*ScopesAllowed |= 1 << Sco_SCOPE_DEG;
- if (Usr_CheckIfIBelongToCurrentCrs ())
+ if (Gbl.Usrs.Me.IBelongToCurrentCrs)
*ScopesAllowed |= 1 << Sco_SCOPE_CRS;
}
}
@@ -1043,7 +1043,7 @@ static void Svy_SetAllowedAndHiddenScopes (unsigned *ScopesAllowed,
if (Usr_CheckIfIBelongToDeg (Gbl.CurrentDeg.Deg.DegCod))
{
*ScopesAllowed |= 1 << Sco_SCOPE_DEG;
- if (Usr_CheckIfIBelongToCurrentCrs ())
+ if (Gbl.Usrs.Me.IBelongToCurrentCrs)
{
*ScopesAllowed |= 1 << Sco_SCOPE_CRS;
*HiddenAllowed |= 1 << Sco_SCOPE_CRS; // A non-editing teacher or teacher can view hidden course surveys
diff --git a/swad_user.c b/swad_user.c
index d6ea20567..a1b167ac7 100644
--- a/swad_user.c
+++ b/swad_user.c
@@ -1029,6 +1029,7 @@ bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat)
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_STD:
+ case Rol_NET:
case Rol_TCH:
case Rol_SYS_ADM:
return true;
@@ -1095,7 +1096,6 @@ bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat)
bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
{
char Query[256];
- bool IBelongToCurrentCrs;
bool HeBelongsToCurrentCrs;
static struct
{
@@ -1125,16 +1125,19 @@ bool Usr_CheckIfUsrSharesAnyOfMyCrs (struct UsrData *UsrDat)
return Cached.UsrSharesAnyOfMyCrs;
/***** 5. Fast check: Is course selected and we both belong to it? *****/
- IBelongToCurrentCrs = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STD ||
- Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TCH;
- HeBelongsToCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STD ||
- UsrDat->RoleInCurrentCrsDB == Rol_TCH;
- if (IBelongToCurrentCrs && HeBelongsToCurrentCrs) // Course selected and we both belong to it
- return true;
+ if (Gbl.Usrs.Me.IBelongToCurrentCrs)
+ {
+ HeBelongsToCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STD ||
+ UsrDat->RoleInCurrentCrsDB == Rol_NET ||
+ UsrDat->RoleInCurrentCrsDB == Rol_TCH;
+ if (HeBelongsToCurrentCrs) // Course selected and we both belong to it
+ return true;
+ }
/***** 6. Fast/slow check: Does he/she belong to any course? *****/
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat);
if (!(UsrDat->Roles & ((1 << Rol_STD) | // Any of his/her roles is student
+ (1 << Rol_NET) | // or non-editing teacher
(1 << Rol_TCH)))) // or teacher?
return false;
@@ -1812,25 +1815,6 @@ bool Usr_CheckIfIBelongToCrs (long CrsCod)
return false;
}
-/*****************************************************************************/
-/******************** Check if I belong to current course ********************/
-/*****************************************************************************/
-
-bool Usr_CheckIfIBelongToCurrentCrs (void)
- {
- /***** Fast check: Is no course selected *****/
- if (Gbl.CurrentCrs.Crs.CrsCod <= 0)
- return false;
-
- /***** Fast check: Is course selected and I am student or teacher *****/
- if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STD ||
- Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TCH)
- return true;
-
- /***** Slow check: query database *****/
- return Usr_CheckIfIBelongToCrs (Gbl.CurrentCrs.Crs.CrsCod);
- }
-
/*****************************************************************************/
/**************** Get the countries of a user from database ******************/
/*****************************************************************************/
@@ -2974,13 +2958,23 @@ static void Usr_SetUsrRoleAndPrefs (void)
}
/***** Check if I belong to current course *****/
- Gbl.Usrs.Me.IBelongToCurrentCrs = false;
- Gbl.Usrs.Me.UsrDat.Accepted = false;
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
- if ((Gbl.Usrs.Me.IBelongToCurrentCrs = Usr_CheckIfIBelongToCurrentCrs ()))
+ {
+ Gbl.Usrs.Me.IBelongToCurrentCrs = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STD ||
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_NET ||
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_TCH;
+ if (Gbl.Usrs.Me.IBelongToCurrentCrs)
Gbl.Usrs.Me.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.CurrentCrs.Crs.CrsCod,
true);
+ else
+ Gbl.Usrs.Me.UsrDat.Accepted = false;
+ }
+ else // No course selected
+ {
+ Gbl.Usrs.Me.IBelongToCurrentCrs = false;
+ Gbl.Usrs.Me.UsrDat.Accepted = false;
+ }
/***** Check if I belong to current degree *****/
if (Gbl.CurrentDeg.Deg.DegCod > 0)
@@ -4155,8 +4149,9 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,
/*********** Get list of users with a given role in a given scope ************/
/*****************************************************************************/
// Role can be:
-// - Rol_STD
-// - Rol_TCH
+// - Rol_STD Student
+// - Rol_NET Non-editing teacher
+// - Rol_TCH Teacher
void Usr_GetListUsrs (Rol_Role_t Role,Sco_Scope_t Scope)
{
@@ -5021,6 +5016,7 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
UsrInList->Accepted = false;
break;
case Rol_STD:
+ case Rol_NET:
case Rol_TCH:
switch (Scope)
{
@@ -5759,14 +5755,29 @@ void Usr_PutCheckboxToSelectAllUsers (Rol_Role_t Role)
"
"
""
@@ -5823,14 +5834,29 @@ static void Usr_PutCheckboxToSelectUser (struct UsrData *UsrDat,bool UsrIsTheMsg
/***** Check box *****/
fprintf (Gbl.F.Out,"RoleInCurrentCrsDB == Rol_STD)
- fprintf (Gbl.F.Out,"UsrCodStd\" value=\"%s\""
- " onclick=\"checkParent(this,'SEL_UNSEL_STDS')\"",
- UsrDat->EncryptedUsrCod);
- else // Role == Rol_TCH or Role == Rol_GST
- fprintf (Gbl.F.Out,"UsrCodTch\" value=\"%s\""
- " onclick=\"checkParent(this,'SEL_UNSEL_TCHS')\"",
- UsrDat->EncryptedUsrCod);
+ switch (UsrDat->RoleInCurrentCrsDB)
+ {
+ case Rol_STD:
+ fprintf (Gbl.F.Out,"UsrCodStd\" value=\"%s\""
+ " onclick=\"checkParent(this,'SEL_UNSEL_STDS')\"",
+ UsrDat->EncryptedUsrCod);
+ break;
+ case Rol_NET:
+ fprintf (Gbl.F.Out,"UsrCodNET\" value=\"%s\""
+ " onclick=\"checkParent(this,'SEL_UNSEL_NETS')\"",
+ UsrDat->EncryptedUsrCod);
+ break;
+ case Rol_TCH:
+ fprintf (Gbl.F.Out,"UsrCodTch\" value=\"%s\""
+ " onclick=\"checkParent(this,'SEL_UNSEL_TCHS')\"",
+ UsrDat->EncryptedUsrCod);
+ break;
+ default:
+ fprintf (Gbl.F.Out,"UsrCodGst\" value=\"%s\""
+ " onclick=\"checkParent(this,'SEL_UNSEL_GSTS')\"",
+ UsrDat->EncryptedUsrCod);
+ break;
+ }
/***** Check box must be checked? *****/
CheckboxChecked = false;
@@ -6661,6 +6687,7 @@ unsigned Usr_ListUsrsFound (Rol_Role_t Role,
if (Role == Rol_UNK)
{
Crs_GetAndWriteCrssOfAUsr (&UsrDat,Rol_TCH);
+ Crs_GetAndWriteCrssOfAUsr (&UsrDat,Rol_NET);
Crs_GetAndWriteCrssOfAUsr (&UsrDat,Rol_STD);
}
else
@@ -7379,8 +7406,7 @@ void Usr_SeeStudents (void)
Sco_SetScopesForListingStudents ();
Sco_GetScope ("ScopeUsr");
ICanViewRecords = (Gbl.Scope.Current == Sco_SCOPE_CRS &&
- (Gbl.Usrs.Me.LoggedRole == Rol_STD ||
- Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
+ (Gbl.Usrs.Me.IBelongToCurrentCrs ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM));
/***** Get groups to show ******/
@@ -8498,9 +8524,21 @@ static float Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
(unsigned) Role);
break;
case Sco_SCOPE_CRS:
- return (float) ( Role == Rol_UNK ? Gbl.CurrentCrs.Crs.NumUsrs[Rol_UNK] : // Any user
- (Role == Rol_TCH ? Gbl.CurrentCrs.Crs.NumUsrs[Rol_TCH] : // Teachers
- Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD])); // Students
+ switch (Role)
+ {
+ case Rol_UNK:
+ return (float) Gbl.CurrentCrs.Crs.NumUsrs[Rol_UNK]; // Any user
+ case Rol_STD:
+ return (float) Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]; // Students
+ case Rol_NET:
+ return (float) Gbl.CurrentCrs.Crs.NumUsrs[Rol_UNK]; // Non-editing teachers
+ case Rol_TCH:
+ return (float) Gbl.CurrentCrs.Crs.NumUsrs[Rol_UNK]; // Teachers
+ default:
+ Lay_ShowErrorAndExit ("Wrong role.");
+ break; // Not reached
+ }
+ break;
default:
Lay_ShowErrorAndExit ("Wrong scope.");
break;
diff --git a/swad_user.h b/swad_user.h
index fb201be87..1e7a3ff1c 100644
--- a/swad_user.h
+++ b/swad_user.h
@@ -276,7 +276,6 @@ bool Usr_CheckIfIBelongToIns (long InsCod);
bool Usr_CheckIfIBelongToCtr (long CtrCod);
bool Usr_CheckIfIBelongToDeg (long DegCod);
bool Usr_CheckIfIBelongToCrs (long CrsCod);
-bool Usr_CheckIfIBelongToCurrentCrs (void);
unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res);
unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res);
diff --git a/swad_web_service.c b/swad_web_service.c
index 8b86475b9..2400dc3b1 100644
--- a/swad_web_service.c
+++ b/swad_web_service.c
@@ -1308,8 +1308,9 @@ int swad__getCourseInfo (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -1412,8 +1413,9 @@ int swad__getUsers (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -1491,8 +1493,9 @@ int swad__findUsers (struct soap *soap,
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
if (Gbl.CurrentCrs.Crs.CrsCod > 0)
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -1651,8 +1654,9 @@ int swad__getGroupTypes (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -1759,8 +1763,9 @@ int swad__getGroups (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -1885,8 +1890,9 @@ int swad__sendMyGroups (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -3515,8 +3521,9 @@ int swad__getTestConfig (struct soap *soap,
"Bad course code",
"Course code must be a integer greater than 0");
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -3646,8 +3653,9 @@ int swad__getTests (struct soap *soap,
"Bad course code",
"Course code must be a integer greater than 0");
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -4278,8 +4286,9 @@ int swad__getDirectoryTree (struct soap *soap,
if ((ReturnCode = Svc_CheckCourseAndGroupCodes (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpCod)) != SOAP_OK)
return ReturnCode;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -4595,8 +4604,9 @@ int swad__getFile (struct soap *soap,
if ((ReturnCode = Svc_CheckCourseAndGroupCodes (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Grps.GrpCod)) != SOAP_OK)
return ReturnCode;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",
@@ -4737,8 +4747,9 @@ int swad__getMarks (struct soap *soap,
Gbl.Usrs.Me.Logged = true;
Gbl.Usrs.Me.LoggedRole = Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB;
- /***** Check if I am a student or teacher in the course *****/
+ /***** Check if I am a student, non-editing teacher or teacher in the course *****/
if (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_STD &&
+ Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_NET &&
Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB != Rol_TCH)
return soap_receiver_fault (Gbl.soap,
"Request forbidden",