diff --git a/swad_attendance.c b/swad_attendance.c index 5f24131f0..4e7867285 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -96,9 +96,11 @@ static void Att_RegUsrInAttEventChangingComments (long AttCod,long UsrCod,bool P static void Att_RemoveUsrFromAttEvent (long AttCod,long UsrCod); static void Att_ListAttEventsWithStds (void); -static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat); +static void Att_ListStdsAttendanceTable (unsigned NumStdsInList,long *LstSelectedUsrCods); static void Att_WriteTableHeadSeveralAttEvents (void); static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *UsrDat); +static void Att_ListStdsWithAttEventsDetails (unsigned NumStdsInList,long *LstSelectedUsrCods); +static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat); /*****************************************************************************/ /********************** List all the attendance events ***********************/ @@ -2638,17 +2640,13 @@ void Usr_ReqListAttendanceStdsCrs (void) 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; + unsigned NumStd; long *LstSelectedUsrCods; + unsigned NumAttEvent; const char *Ptr; struct UsrData UsrDat; - unsigned NumAttEvent; - unsigned Total; /***** Get list of attendance events *****/ Att_GetListAttEvents (Att_OLDEST_FIRST); @@ -2679,12 +2677,16 @@ void Usr_ListAttendanceStdsCrs (void) LstSelectedUsrCods[NumStd] = UsrDat.UsrCod; } + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&UsrDat); + /***** Get number of students in each event *****/ for (NumAttEvent = 0; NumAttEvent < Gbl.AttEvents.Num; NumAttEvent++) /* Get number of students in this event */ - Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList = Att_GetNumStdsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,LstSelectedUsrCods,NumStdsInList); + Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList = Att_GetNumStdsFromAListWhoAreInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod, + LstSelectedUsrCods,NumStdsInList); /***** List those events that have students (without comments) *****/ Att_ListAttEventsWithStds (); @@ -2692,77 +2694,11 @@ void Usr_ListAttendanceStdsCrs (void) /***** Get my preference about photos in users' list for current course *****/ Usr_GetMyPrefAboutListWithPhotosFromDB (); - /***** Table head *****/ - if (Gbl.CurrentAct == ActSeeLstAttStd) - Lay_StartRoundFrameTable10 (NULL,2,Txt_Attendance); - else - Lay_StartSquareFrameTable (NULL,NULL,NULL,2); - Att_WriteTableHeadSeveralAttEvents (); - - /***** List the students *****/ - 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_WriteRowStdSeveralAttEvents (NumStd,&UsrDat); - } - } - - /***** Last row with the total of students present in each event *****/ - fprintf (Gbl.F.Out,"" - "%s:", - Gbl.Usrs.Listing.WithPhotos ? 4 : - 3, - Txt_Number_of_students); - for (NumAttEvent = 0, Total = 0; - NumAttEvent < Gbl.AttEvents.Num; - NumAttEvent++) - if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) - { - fprintf (Gbl.F.Out,"%u", - Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList); - Total += Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList; - } - fprintf (Gbl.F.Out,"%u" - "", - Total); - - /***** Table end *****/ - if (Gbl.CurrentAct == ActSeeLstAttStd) - Lay_EndRoundFrameTable10 (); - else - Lay_EndSquareFrameTable (); + /***** Show table with attendances for every student in list *****/ + Att_ListStdsAttendanceTable (NumStdsInList,LstSelectedUsrCods); /***** 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); + Att_ListStdsWithAttEventsDetails (NumStdsInList,LstSelectedUsrCods); /***** Free list of user codes *****/ free ((void *) LstSelectedUsrCods); @@ -2793,6 +2729,7 @@ static void Att_ListAttEventsWithStds (void) extern const char *Txt_Absent; extern const char *Txt_Student_comment; extern const char *Txt_Teachers_comment; + const char *BgColor; unsigned NumAttEvent; /***** Start frame *****/ @@ -2814,24 +2751,31 @@ static void Att_ListAttEventsWithStds (void) NumAttEvent++) if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) { + BgColor = Gbl.ColorRows[Gbl.RowEvenOdd]; + /***** Get data of the attendance event from database *****/ Att_GetDataOfAttEventByCodAndCheckCrs (&Gbl.AttEvents.Lst[NumAttEvent]); Att_GetNumStdsTotalWhoAreInAttEvent (&Gbl.AttEvents.Lst[NumAttEvent]); /***** Write a row for this event *****/ fprintf (Gbl.F.Out,"" - "%u:" - "%02u/%02u/%04u %02u:%02u h %s" - "%u" + "%u:" + "%02u/%02u/%04u %02u:%02u h %s" + "%u" "", + BgColor, NumAttEvent + 1, + BgColor, 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, + BgColor, Gbl.AttEvents.Lst[NumAttEvent].NumStdsTotal); + + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } /***** End frame *****/ @@ -2842,10 +2786,243 @@ static void Att_ListAttEventsWithStds (void) } /*****************************************************************************/ -/********** Write list of those attendance events that have students *********/ +/*********** Show table with attendances for every student in list ***********/ +/*****************************************************************************/ + +static void Att_ListStdsAttendanceTable (unsigned NumStdsInList,long *LstSelectedUsrCods) + { + extern const char *Txt_Attendance; + extern const char *Txt_Number_of_students; + struct UsrData UsrDat; + unsigned NumStd; + unsigned NumAttEvent; + unsigned Total; + + /***** Initialize structure with user's data *****/ + Usr_UsrDataConstructor (&UsrDat); + + /***** Start frame *****/ + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_StartRoundFrameTable10 (NULL,2,Txt_Attendance); + else + Lay_StartSquareFrameTable (NULL,NULL,NULL,2); + Att_WriteTableHeadSeveralAttEvents (); + + /***** List the students *****/ + 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_WriteRowStdSeveralAttEvents (NumStd,&UsrDat); + } + } + + /***** Last row with the total of students present in each event *****/ + fprintf (Gbl.F.Out,"" + "%s:", + Gbl.Usrs.Listing.WithPhotos ? 4 : + 3, + Txt_Number_of_students); + for (NumAttEvent = 0, Total = 0; + NumAttEvent < Gbl.AttEvents.Num; + NumAttEvent++) + if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) + { + fprintf (Gbl.F.Out,"%u", + Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList); + Total += Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList; + } + fprintf (Gbl.F.Out,"%u" + "", + Total); + + /***** End frame *****/ + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_EndRoundFrameTable10 (); + else + Lay_EndSquareFrameTable (); + + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&UsrDat); + } + +/*****************************************************************************/ +/* Write table heading for listing of students in several attendance events **/ +/*****************************************************************************/ + +static void Att_WriteTableHeadSeveralAttEvents (void) + { + extern const char *Txt_ROLES_SINGULAR_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + extern const char *Txt_Attendance; + unsigned NumAttEvent; + + fprintf (Gbl.F.Out,"" + "%s", + Gbl.Usrs.Listing.WithPhotos ? 4 : + 3, + Txt_ROLES_SINGULAR_Abc[Rol_ROLE_STUDENT][Usr_SEX_UNKNOWN]); + + for (NumAttEvent = 0; + NumAttEvent < Gbl.AttEvents.Num; + NumAttEvent++) + if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) + { + /***** Get data of this attendance event *****/ + Att_GetDataOfAttEventByCodAndCheckCrs (&Gbl.AttEvents.Lst[NumAttEvent]); + + fprintf (Gbl.F.Out,"" + "%u" + "", + Gbl.AttEvents.Lst[NumAttEvent].Title,NumAttEvent+1); + } + + fprintf (Gbl.F.Out,"%s" + "", + Txt_Attendance); + } + +/*****************************************************************************/ +/************ Write a row of a table with the data of a student **************/ +/*****************************************************************************/ + +static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *UsrDat) + { + extern const char *Txt_Present; + extern const char *Txt_Absent; + const char *BgColor; + char PhotoURL[PATH_MAX+1]; + bool ShowPhoto; + unsigned NumAttEvent; + bool Present; + unsigned NumTimesPresent; + + 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 *****/ + if (Gbl.Usrs.Listing.WithPhotos) + { + 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,"", + BgColor, + UsrDat->Accepted ? "DAT_SMALL_N" : + "DAT_SMALL"); + ID_WriteUsrIDs (UsrDat,true); + fprintf (Gbl.F.Out,""); + + /***** Write student's name *****/ + fprintf (Gbl.F.Out,"%s", + BgColor, + 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); + + /***** Icon to show if the user is already registered *****/ + for (NumAttEvent = 0, NumTimesPresent = 0; + NumAttEvent < Gbl.AttEvents.Num; + NumAttEvent++) + if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) + { + /***** Check if this student is already registered in the current event *****/ + // Here it is not necessary to get comments + Present = Att_CheckIfUsrIsPresentInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,UsrDat->UsrCod); + + fprintf (Gbl.F.Out,"" + "\"\"" + "", + Gbl.RowEvenOdd, + Gbl.Prefs.IconsURL, + Present ? "check" : + "check-empty", + Present ? Txt_Present : + Txt_Absent); + + if (Present) + NumTimesPresent++; + } + + /***** Last column with the number of times this user is present *****/ + fprintf (Gbl.F.Out,"%u" + "", + BgColor,NumTimesPresent); + + Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; + } + +/*****************************************************************************/ +/**************** List the students with details and comments ****************/ +/*****************************************************************************/ + +static void Att_ListStdsWithAttEventsDetails (unsigned NumStdsInList,long *LstSelectedUsrCods) + { + extern const char *Txt_Details; + struct UsrData UsrDat; + unsigned NumStd; + + /***** Initialize structure with user's data *****/ + Usr_UsrDataConstructor (&UsrDat); + + /***** Start frame *****/ + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_StartRoundFrameTable10 (NULL,2,Txt_Details); + else + Lay_StartSquareFrameTable (NULL,NULL,NULL,2); + + /***** List students with attendance details *****/ + 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); + } + } + + /***** End frame *****/ + if (Gbl.CurrentAct == ActSeeLstAttStd) + Lay_EndRoundFrameTable10 (); + else + Lay_EndSquareFrameTable (); + + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&UsrDat); + } + +/*****************************************************************************/ +/*************** Write list of attendance events for a student ***************/ /*****************************************************************************/ -// If UsrDat == NULL ==> don't show comments -// If UsrDat != NULL ==> show comments static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) { @@ -2981,128 +3158,3 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; } - -/*****************************************************************************/ -/* Write table heading for listing of students in several attendance events **/ -/*****************************************************************************/ - -static void Att_WriteTableHeadSeveralAttEvents (void) - { - extern const char *Txt_ROLES_SINGULAR_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - extern const char *Txt_Attendance; - unsigned NumAttEvent; - - fprintf (Gbl.F.Out,"" - "%s", - Gbl.Usrs.Listing.WithPhotos ? 4 : - 3, - Txt_ROLES_SINGULAR_Abc[Rol_ROLE_STUDENT][Usr_SEX_UNKNOWN]); - - for (NumAttEvent = 0; - NumAttEvent < Gbl.AttEvents.Num; - NumAttEvent++) - if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) - { - /***** Get data of this attendance event *****/ - Att_GetDataOfAttEventByCodAndCheckCrs (&Gbl.AttEvents.Lst[NumAttEvent]); - - fprintf (Gbl.F.Out,"" - "%u" - "", - Gbl.AttEvents.Lst[NumAttEvent].Title,NumAttEvent+1); - } - - fprintf (Gbl.F.Out,"%s" - "", - Txt_Attendance); - } - -/*****************************************************************************/ -/************ Write a row of a table with the data of a student **************/ -/*****************************************************************************/ - -static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *UsrDat) - { - extern const char *Txt_Present; - extern const char *Txt_Absent; - const char *BgColor; - char PhotoURL[PATH_MAX+1]; - bool ShowPhoto; - unsigned NumAttEvent; - bool Present; - unsigned NumTimesPresent; - - 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 *****/ - if (Gbl.Usrs.Listing.WithPhotos) - { - 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,"", - BgColor, - UsrDat->Accepted ? "DAT_SMALL_N" : - "DAT_SMALL"); - ID_WriteUsrIDs (UsrDat,true); - fprintf (Gbl.F.Out,""); - - /***** Write student's name *****/ - fprintf (Gbl.F.Out,"%s", - BgColor, - 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); - - /***** Icon to show if the user is already registered *****/ - for (NumAttEvent = 0, NumTimesPresent = 0; - NumAttEvent < Gbl.AttEvents.Num; - NumAttEvent++) - if (Gbl.AttEvents.Lst[NumAttEvent].NumStdsFromList) - { - /***** Check if this student is already registered in the current event *****/ - // Here it is not necessary to get comments - Present = Att_CheckIfUsrIsPresentInAttEvent (Gbl.AttEvents.Lst[NumAttEvent].AttCod,UsrDat->UsrCod); - - fprintf (Gbl.F.Out,"" - "\"\"" - "", - Gbl.RowEvenOdd, - Gbl.Prefs.IconsURL, - Present ? "check" : - "check-empty", - Present ? Txt_Present : - Txt_Absent); - - if (Present) - NumTimesPresent++; - } - - /***** Last column with the number of times this user is present *****/ - fprintf (Gbl.F.Out,"%u" - "", - BgColor,NumTimesPresent); - - Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; - } diff --git a/swad_changelog.h b/swad_changelog.h index bead6b2d7..5b4667168 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -35,12 +35,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.31.1 (2014/12/05)" +#define Log_PLATFORM_VERSION "SWAD 14.32 (2014/12/06)" // 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.32 :Dic 06, 2014 Changes in listing of attendance. (170509 lines) 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. diff --git a/swad_text.c b/swad_text.c index cd1408485..c787f4039 100644 --- a/swad_text.c +++ b/swad_text.c @@ -7533,6 +7533,27 @@ const char *Txt_Description = "Descrição"; #endif +const char *Txt_Details = +#if L==0 + "Detalls"; +#elif L==1 + "Einzelheiten"; +#elif L==2 + "Details"; +#elif L==3 + "Detalles"; +#elif L==4 + "Détails"; +#elif L==5 + "Detalles"; // Okoteve traducción +#elif L==6 + "Dettagli"; +#elif L==7 + "Szczegóły"; +#elif L==8 + "Detalhes"; +#endif + const char *Txt_Direct_authentication = #if L==0 "¿Autenticació directa?";