Version 17.17.5

This commit is contained in:
Antonio Cañas Vargas 2017-10-05 22:29:33 +02:00
parent 277a2efa87
commit 41c571cbda
7 changed files with 141 additions and 41 deletions

View File

@ -3235,7 +3235,7 @@ static void Att_ListStdsAttendanceTable (Att_TypeOfView_t TypeOfView,
{
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
if (Usr_CheckIfICanViewWrkTstAtt (&UsrDat))
if (Usr_CheckIfICanViewAtt (&UsrDat))
{
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
Att_WriteRowStdSeveralAttEvents (NumStd,&UsrDat);
@ -3448,7 +3448,7 @@ static void Att_ListStdsWithAttEventsDetails (Att_TypeOfView_t TypeOfView,
{
UsrDat.UsrCod = LstSelectedUsrCods[NumStd];
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student
if (Usr_CheckIfICanViewWrkTstAtt (&UsrDat))
if (Usr_CheckIfICanViewAtt (&UsrDat))
{
UsrDat.Accepted = Usr_CheckIfUsrHasAcceptedInCurrentCrs (&UsrDat);
Att_ListAttEventsForAStd (NumStd,&UsrDat);

View File

@ -254,13 +254,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 17.17.4 (2017-10-05)"
#define Log_PLATFORM_VERSION "SWAD 17.17.5 (2017-10-05)"
#define CSS_FILE "swad17.0.css"
#define JS_FILE "swad17.17.1.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 17.17.5: Oct 05, 2017 Fixed bug in contextual icons in records. (232467 lines)
Version 17.17.4: Oct 05, 2017 Department is filled automatically with user's department when creating a new project. (232385 lines)
Version 17.17.3: Oct 04, 2017 Fixed problems with icons when expanding / contracting a folder. (232383 lines)
Version 17.17.2: Oct 04, 2017 Changes related with output with status 204 No Content. (232332 lines)

View File

@ -3257,7 +3257,7 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void)
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
if (Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
if (Usr_CheckIfICanViewAsgWrk (&Gbl.Usrs.Other.UsrDat))
{
/***** Show a row with the data of the owner of the works *****/
fprintf (Gbl.F.Out,"<tr>");

View File

@ -2634,49 +2634,53 @@ static void Rec_PutIconsCommands (void)
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // A course is selected
{
if (Usr_CheckIfICanViewWrkTstAtt (Gbl.Record.UsrDat))
{
/***** Button to view user's assignments and works *****/
if (ItsMe) // I am a student
Lay_PutContextualLink (ActAdmAsgWrkUsr,NULL,NULL,
"folder64x64.gif",
Txt_View_homework,NULL,
NULL);
else // I am a teacher or superuser
Lay_PutContextualLink (ActAdmAsgWrkCrs,NULL,Rec_PutParamsWorks,
"folder64x64.gif",
Txt_View_homework,NULL,
NULL);
/***** Button to view user's test exams *****/
if (ItsMe)
Lay_PutContextualLink (ActSeeMyTstRes,NULL,NULL,
"exam64x64.png",
Txt_View_test_results,NULL,
NULL);
else
Lay_PutContextualLink (ActSeeUsrTstRes,NULL,Rec_PutParamsStudent,
"exam64x64.png",
Txt_View_test_results,NULL,
NULL);
/***** Button to view user's attendance *****/
if (Gbl.Record.UsrDat->Roles.InCurrentCrs.Role == Rol_STD)
if (Gbl.Record.UsrDat->Roles.InCurrentCrs.Role == Rol_STD) // He/she is a student in current course
{
/***** Button to view student's test exams *****/
if (Usr_CheckIfICanViewTst (Gbl.Record.UsrDat))
{
if (ItsMe)
Lay_PutContextualLink (ActSeeMyTstRes,NULL,NULL,
"exam64x64.png",
Txt_View_test_results,NULL,
NULL);
else
Lay_PutContextualLink (ActSeeUsrTstRes,NULL,Rec_PutParamsStudent,
"exam64x64.png",
Txt_View_test_results,NULL,
NULL);
}
/***** Button to view student's assignments and works *****/
if (Usr_CheckIfICanViewAsgWrk (Gbl.Record.UsrDat))
{
if (ItsMe)
Lay_PutContextualLink (ActAdmAsgWrkUsr,NULL,NULL,
"folder64x64.gif",
Txt_View_homework,NULL,
NULL);
else // I am not a student in current course
Lay_PutContextualLink (ActAdmAsgWrkCrs,NULL,Rec_PutParamsWorks,
"folder64x64.gif",
Txt_View_homework,NULL,
NULL);
}
/***** Button to view student's attendance *****/
if (Usr_CheckIfICanViewAtt (Gbl.Record.UsrDat))
{
if (ItsMe)
// As student, I can see my attendance
Lay_PutContextualLink (ActSeeLstMyAtt,NULL,NULL,
"rollcall64x64.png",
Txt_View_attendance,NULL,
NULL);
else
// I can see attendance of the student
Lay_PutContextualLink (ActSeeLstStdAtt,NULL,Rec_PutParamsStudent,
"rollcall64x64.png",
Txt_View_attendance,NULL,
NULL);
}
}
}
/***** Button to print QR code *****/
Lay_PutContextualLink (ActPrnUsrQR,NULL,Rec_PutParamUsrCodEncrypted,

View File

@ -7578,7 +7578,7 @@ void Tst_ShowUsrsTestResults (void)
/***** Header of the table with the list of users *****/
Tst_ShowHeaderTestResults ();
/***** List the assignments and works of the selected users *****/
/***** List the test exams of the selected users *****/
Ptr = Gbl.Usrs.Select[Rol_UNK];
while (*Ptr)
{
@ -7586,7 +7586,7 @@ void Tst_ShowUsrsTestResults (void)
Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64);
Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat);
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user
if (Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
if (Usr_CheckIfICanViewTst (&Gbl.Usrs.Other.UsrDat))
/***** Show test results *****/
Tst_ShowTestResults (&Gbl.Usrs.Other.UsrDat);
}
@ -8149,7 +8149,7 @@ void Tst_ShowOneTestResult (void)
/* Get data of the user who made the test */
if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
Lay_ShowErrorAndExit ("User does not exists.");
if (!Usr_CheckIfICanViewWrkTstAtt (&Gbl.Usrs.Other.UsrDat))
if (!Usr_CheckIfICanViewTst (&Gbl.Usrs.Other.UsrDat))
Lay_ShowErrorAndExit ("You can not view this test result.");
/* User */

View File

@ -1158,10 +1158,10 @@ bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat)
}
/*****************************************************************************/
/*** Check if a user belongs to any of my courses but has a different role ***/
/************** Check if I can view test exams of another user ***************/
/*****************************************************************************/
bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat)
bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat)
{
/***** 1. Fast check: Am I logged? *****/
if (!Gbl.Usrs.Me.Logged)
@ -1203,6 +1203,99 @@ bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat)
}
}
/*****************************************************************************/
/********** Check if I can view assigments / works of another user ***********/
/*****************************************************************************/
bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat)
{
/***** 1. Fast check: Am I logged? *****/
if (!Gbl.Usrs.Me.Logged)
return false;
/***** 2. Fast check: Is it a valid user code? *****/
if (UsrDat->UsrCod <= 0)
return false;
/***** 3. Fast check: Is it a course selected? *****/
if (Gbl.CurrentCrs.Crs.CrsCod <= 0)
return false;
/***** 4. Fast check: Does he/she belong to the current course? *****/
// Only users beloging to course can have files in assignments/works
if (!Usr_CheckIfUsrBelongsToCurrentCrs (UsrDat))
return false;
/***** 5. Fast check: Am I a system admin? *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
return true;
/***** 6. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs)
return false;
/***** 7. Fast check: It's me? *****/
if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod)
return true;
/***** 8. Fast / slow check depending on roles *****/
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_NET:
return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat);
case Rol_TCH:
return true;
default:
return false;
}
}
/*****************************************************************************/
/************** Check if I can view attendance of another user ***************/
/*****************************************************************************/
bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat)
{
/***** 1. Fast check: Am I logged? *****/
if (!Gbl.Usrs.Me.Logged)
return false;
/***** 2. Fast check: Is it a valid user code? *****/
if (UsrDat->UsrCod <= 0)
return false;
/***** 3. Fast check: Is it a course selected? *****/
if (Gbl.CurrentCrs.Crs.CrsCod <= 0)
return false;
/***** 4. Fast check: Is he/she a student in the current course? *****/
if (UsrDat->Roles.InCurrentCrs.Role != Rol_STD)
return false;
/***** 5. Fast check: Am I a system admin? *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
return true;
/***** 6. Fast check: Do I belong to the current course? *****/
if (!Gbl.Usrs.Me.IBelongToCurrentCrs)
return false;
/***** 7. Fast check: It's me? *****/
if (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod)
return true;
/***** 8. Fast / slow check depending on roles *****/
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_NET:
return Grp_CheckIfUsrSharesAnyOfMyGrpsInCurrentCrs (UsrDat);
case Rol_TCH:
return true;
default:
return false;
}
}
/*****************************************************************************/
/******************* Check if I can view a user's agenda *********************/
/*****************************************************************************/

View File

@ -267,7 +267,9 @@ bool Usr_CheckIfUsrHasAcceptedInCurrentCrs (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewRecordStd (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewRecordTch (struct UsrData *UsrDat);
bool Usr_CheckIfICanViewWrkTstAtt (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewTst (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewAsgWrk (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewAtt (const struct UsrData *UsrDat);
bool Usr_CheckIfICanViewUsrAgenda (struct UsrData *UsrDat);
void Usr_FlushCacheUsrSharesAnyOfMyCrs (void);