From 8095c8e4a04c5087bba6ecb274a22f7325ccb85a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 5 Dec 2014 02:33:47 +0100 Subject: [PATCH] Version 14.31.1 --- swad_attendance.c | 239 +++++++++++++++++++++++++++++++++------------- swad_changelog.h | 3 +- 2 files changed, 175 insertions(+), 67 deletions(-) diff --git a/swad_attendance.c b/swad_attendance.c index 635d2b97a..5f24131f0 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -95,7 +95,8 @@ static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool P const char *CommentStd,const char *CommentTch); static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod); -static void Att_ListAttEventsWithStds (struct UsrData *UsrDat); +static void Att_ListAttEventsWithStds (void); +static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat); static void Att_WriteTableHeadSeveralAttEvents (void); static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *UsrDat); @@ -2639,6 +2640,7 @@ void Usr_ListAttendanceStdsCrs (void) extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Attendance; extern const char *Txt_Number_of_students; + extern const char *Txt_Comments; extern const char *Txt_You_must_select_one_ore_more_students; unsigned NumStd = 0; unsigned NumStdsInList; @@ -2685,7 +2687,7 @@ void Usr_ListAttendanceStdsCrs (void) Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList = Att_GetNumStdsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,LstSelectedUsrCods,NumStdsInList); /***** List those events that have students (without comments) *****/ - Att_ListAttEventsWithStds (NULL); + Att_ListAttEventsWithStds (); /***** Get my preference about photos in users' list for current course *****/ Usr_GetMyPrefAboutListWithPhotosFromDB (); @@ -2738,9 +2740,26 @@ void Usr_ListAttendanceStdsCrs (void) else Lay_EndSquareFrameTable (); - /***** List events that have students (with comments) *****/ - if (NumStdsInList == 1) // Only if one unique student in list - Att_ListAttEventsWithStds (&UsrDat); + /***** List the students with details and comments *****/ + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_StartRoundFrameTable10 (NULL,2,Txt_Comments); + else + Lay_StartSquareFrameTable (NULL,NULL,NULL,2); + for (NumStd = 0; + NumStd < NumStdsInList; + NumStd++) + { + UsrDat.UsrCod = LstSelectedUsrCods[NumStd]; + if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student + { + UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (UsrDat.UsrCod); + Att_ListAttEventsForAStd (NumStd,&UsrDat); + } + } + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_EndRoundFrameTable10 (); + else + Lay_EndSquareFrameTable (); /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDat); @@ -2764,12 +2783,9 @@ void Usr_ListAttendanceStdsCrs (void) /*****************************************************************************/ /********** Write list of those attendance events that have students *********/ /*****************************************************************************/ -// If UsrDat == NULL ==> don't show comments -// If UsrDat != NULL ==> show comments -static void Att_ListAttEventsWithStds (struct UsrData *UsrDat) +static void Att_ListAttEventsWithStds (void) { - extern const char *Txt_Comments; extern const char *Txt_Events; extern const char *Txt_Event; extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; @@ -2778,16 +2794,13 @@ static void Att_ListAttEventsWithStds (struct UsrData *UsrDat) extern const char *Txt_Student_comment; extern const char *Txt_Teachers_comment; unsigned NumAttEvent; - bool Present; - char CommentStd[Cns_MAX_BYTES_TEXT+1]; - char CommentTch[Cns_MAX_BYTES_TEXT+1]; - /***** Header *****/ + /***** Start frame *****/ if (Gbl.CurrentAct == ActSeeLstAttStd) - Lay_StartRoundFrameTable10 (NULL,2,UsrDat ? Txt_Comments : - Txt_Events); + Lay_StartRoundFrameTable10 (NULL,2,Txt_Events); else Lay_StartSquareFrameTable (NULL,NULL,NULL,2); + fprintf (Gbl.F.Out,"" "%s" "%s" @@ -2819,61 +2832,156 @@ static void Att_ListAttEventsWithStds (struct UsrData *UsrDat) Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Time.Minute, Gbl.AttEvents.Lst[NumAttEvent].Title, Gbl.AttEvents.Lst[NumAttEvent].NumStdsTotal); - - /***** Write comments for this student *****/ - if (UsrDat) - { - /* Get comments for this student */ - Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Gbl.AttEvents.Lst[NumAttEvent].AttCod,UsrDat->UsrCod,CommentStd,CommentTch); - - /* Show comments */ - fprintf (Gbl.F.Out,"" - "" - ""); - fprintf (Gbl.F.Out,"\"\" %s", - Gbl.Prefs.IconsURL, - Present ? "check" : - "check-empty", - Present ? Txt_Present : - Txt_Absent, - Present ? Txt_Present : - Txt_Absent); - if (CommentStd[0] || - CommentTch[0]) - { - fprintf (Gbl.F.Out,"
"); - if (CommentStd[0]) - { - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentStd,Cns_MAX_BYTES_TEXT,false); - fprintf (Gbl.F.Out,"
%s:
%s
", - Txt_Student_comment, - CommentStd); - } - if (CommentTch[0]) - { - Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, - CommentTch,Cns_MAX_BYTES_TEXT,false); - fprintf (Gbl.F.Out,"
%s:
%s
", - Txt_Teachers_comment, - CommentTch); - } - fprintf (Gbl.F.Out,"
"); - } - fprintf (Gbl.F.Out,"" - "" - ""); - } } - /***** Footer *****/ + /***** End frame *****/ if (Gbl.CurrentAct == ActSeeLstAttStd) Lay_EndRoundFrameTable10 (); else Lay_EndSquareFrameTable (); } +/*****************************************************************************/ +/********** Write list of those attendance events that have students *********/ +/*****************************************************************************/ +// If UsrDat == NULL ==> don't show comments +// If UsrDat != NULL ==> show comments + +static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) + { + extern const char *Txt_Present; + extern const char *Txt_Absent; + extern const char *Txt_Student_comment; + extern const char *Txt_Teachers_comment; + const char *BgColor; + char PhotoURL[PATH_MAX+1]; + bool ShowPhoto; + unsigned NumAttEvent; + bool Present; + char CommentStd[Cns_MAX_BYTES_TEXT+1]; + char CommentTch[Cns_MAX_BYTES_TEXT+1]; + + BgColor = Gbl.ColorRows[Gbl.RowEvenOdd]; + + /***** Write number of student in the list *****/ + fprintf (Gbl.F.Out,"" + "%u:", + BgColor, + UsrDat->Accepted ? "DAT_SMALL_N" : + "DAT_SMALL", + NumStd + 1); + + /***** Show student's photo *****/ + fprintf (Gbl.F.Out,"", + BgColor); + ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); + Pho_ShowUsrPhoto (UsrDat, + ShowPhoto ? PhotoURL : + NULL, + 18,24, + Act_Actions[Gbl.CurrentAct].BrowserWindow == Act_MAIN_WINDOW); + fprintf (Gbl.F.Out,""); + + /***** Write user's ID ******/ + fprintf (Gbl.F.Out,"" + "" + "" + ""); + + /***** Write student's name *****/ + fprintf (Gbl.F.Out,"" + "" + "
", + BgColor, + UsrDat->Accepted ? "DAT_SMALL_N" : + "DAT_SMALL"); + ID_WriteUsrIDs (UsrDat,true); + fprintf (Gbl.F.Out,"%s", + UsrDat->Accepted ? "DAT_SMALL_N" : + "DAT_SMALL", + UsrDat->Surname1); + if (UsrDat->Surname2[0]) + fprintf (Gbl.F.Out," %s",UsrDat->Surname2); + fprintf (Gbl.F.Out,", %s
" + "" + "", + UsrDat->FirstName); + + /***** List the events with students *****/ + for (NumAttEvent = 0; + NumAttEvent < Gbl.AttEvents.Num; + NumAttEvent++) + if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) + { + /***** Get data of the attendance event from database *****/ + Att_GetDataOfAttEventByCodAndCheckCrs (&Gbl.AttEvents.Lst[NumAttEvent]); + Att_GetNumStdsTotalWhoAreInAttEvent (&Gbl.AttEvents.Lst[NumAttEvent]); + + /***** Get comments for this student *****/ + Present = Att_CheckIfUsrIsPresentInAttEventAndGetComments (Gbl.AttEvents.Lst[NumAttEvent].AttCod,UsrDat->UsrCod,CommentStd,CommentTch); + + /***** Write a row for this event *****/ + fprintf (Gbl.F.Out,"" + "" + "%u:" + "" + "\"\"" + " %02u/%02u/%04u %02u:%02u h %s" + "", + BgColor, + BgColor, + NumAttEvent + 1, + BgColor, + Gbl.Prefs.IconsURL, + Present ? "check" : + "check-empty", + Present ? Txt_Present : + Txt_Absent, + Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Date.Day, + Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Date.Month, + Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Date.Year, + Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Time.Hour, + Gbl.AttEvents.Lst[NumAttEvent].DateTimes[Att_START_TIME].Time.Minute, + Gbl.AttEvents.Lst[NumAttEvent].Title); + + /***** Write comments for this student *****/ + if (CommentStd[0] || + CommentTch[0]) + { + fprintf (Gbl.F.Out,"" + "" + "" + "" + "
", + BgColor, + BgColor, + BgColor); + if (CommentStd[0]) + { + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + CommentStd,Cns_MAX_BYTES_TEXT,false); + fprintf (Gbl.F.Out,"
%s:
%s
", + Txt_Student_comment, + CommentStd); + } + if (CommentTch[0]) + { + Str_ChangeFormat (Str_FROM_HTML,Str_TO_RIGOROUS_HTML, + CommentTch,Cns_MAX_BYTES_TEXT,false); + fprintf (Gbl.F.Out,"
%s:
%s
", + Txt_Teachers_comment, + CommentTch); + } + fprintf (Gbl.F.Out,"
" + "" + ""); + } + } + + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; + } + /*****************************************************************************/ /* Write table heading for listing of students in several attendance events **/ /*****************************************************************************/ @@ -2885,10 +2993,9 @@ static void Att_WriteTableHeadSeveralAttEvents (void) unsigned NumAttEvent; fprintf (Gbl.F.Out,"" - ""); - if (Gbl.Usrs.Listing.WithPhotos) - fprintf (Gbl.F.Out,""); - fprintf (Gbl.F.Out,"%s", + "%s", + Gbl.Usrs.Listing.WithPhotos ? 4 : + 3, Txt_ROLES_SINGULAR_Abc[Rol_ROLE_STUDENT][Usr_SEX_UNKNOWN]); for (NumAttEvent = 0; diff --git a/swad_changelog.h b/swad_changelog.h index 7cc72ba05..bead6b2d7 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -35,12 +35,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.31 (2014/12/04)" +#define Log_PLATFORM_VERSION "SWAD 14.31.1 (2014/12/05)" // 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 | tail -1 /* + Version 14.31.1 :Dic 05, 2014 Comments are shown in list of attendances when several students are listed. (170450 lines) Version 14.31 :Dic 04, 2014 Comments are shown in list of attendances when one unique student is listed. (170353 lines) Version 14.30.2 :Dic 03, 2014 Changes in sign up. Fixed bug when deleting user's IDs. (170252 lines)