From df5cf12a1c45f8767b5cd4f3f657fb293e19daaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 17 Sep 2015 20:41:31 +0200 Subject: [PATCH] Version 14.134 --- sql/cambios.sql | 52 ++++++++++++++++++++ swad_action.c | 46 +++++++++++------- swad_action.h | 83 ++++++++++++++++---------------- swad_changelog.h | 31 +++++++++++- swad_enrollment.c | 105 +++++++++++++++++++++++++++++++---------- swad_notification.c | 24 ++++++---- swad_notification.h | 31 ++++++------ swad_text.c | 112 ++++++++++++++++++++++++++++++++------------ 8 files changed, 350 insertions(+), 134 deletions(-) diff --git a/sql/cambios.sql b/sql/cambios.sql index 22b075a73..3c8e0f2a1 100644 --- a/sql/cambios.sql +++ b/sql/cambios.sql @@ -10612,3 +10612,55 @@ ALTER TABLE usr_webs CHANGE Web Web ENUM('www','500px','delicious','deviantart', ALTER TABLE usr_webs CHANGE Web Web ENUM('www','500px','delicious','deviantart','diaspora','edmodo','facebook','flickr','foursquare','github','gnusocial','googleplus','googlescholar','identica','instagram','linkedin','orcid','paperli','pinterest','quitter','researchgate','researcherid','scoopit','slideshare','storify','tumblr','twitter','wikipedia','youtube') NOT NULL; + +----- 2015-09-17, swad14.134 +/* +UPDATE notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE notif SET NotifyEvent=8 WHERE NotifyEvent=7; + +UPDATE sta_notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE sta_notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE sta_notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE sta_notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE sta_notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE sta_notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE sta_notif SET NotifyEvent=8 WHERE NotifyEvent=7; + +UPDATE usr_data SET NotifNtfEvents=(((NotifNtfEvents & ~0x7F) << 1) | (NotifNtfEvents & 0x7F) | 0x80); +UPDATE usr_data SET EmailNtfEvents=(((EmailNtfEvents & ~0x7F) << 1) | (EmailNtfEvents & 0x7F)); + + + + + Ntf_EVENT_UNKNOWN = 0, // old 0 + + /* Course tab */ + Ntf_EVENT_DOCUMENT_FILE = 1, // old 1 + Ntf_EVENT_SHARED_FILE = 2, // old 2 + + /* Assessment tab */ + Ntf_EVENT_ASSIGNMENT = 3, // old 3 + Ntf_EVENT_EXAM_ANNOUNCEMENT = 4, // old 4 + Ntf_EVENT_MARKS_FILE = 5, // old 5 + + /* Enrollment tab */ + Ntf_EVENT_ENROLLMENT_STUDENT = 6, // old 6 + Ntf_EVENT_ENROLLMENT_TEACHER = 7, + Ntf_EVENT_ENROLLMENT_REQUEST = 8, // old 7 + + /* Messages tab */ + Ntf_EVENT_NOTICE = 9, // old 8 + Ntf_EVENT_FORUM_POST_COURSE = 10, // old 9 + Ntf_EVENT_FORUM_REPLY = 11, // old 10 + Ntf_EVENT_MESSAGE = 12, // old 11 + + /* Statistics tab */ + Ntf_EVENT_SURVEY = 13, // old 12 + + /* Profile tab */ + Ntf_EVENT_FOLLOWER = 14, // old 13 diff --git a/swad_action.c b/swad_action.c index f7f7bc26f..31a3336e4 100644 --- a/swad_action.c +++ b/swad_action.c @@ -942,12 +942,16 @@ Users: 768b. ActCreOth Create a new user 768c. ActCreStd Create a new user 768d. ActCreTch Create a new user - 769b. ActUpdOth Update another user's data and groups - 769c. ActUpdStd Update another user's data and groups - 769d. ActUpdTch Update another user's data and groups - 770. ActReqAccEnrCrs Confirm acceptation / refusion of enrollment in current course - 771. ActAccEnrCrs Accept enrollment in current course - 772. ActRemMeCrs Refuse enrollment in current course + 769b. ActUpdOth Update another user's data and groups + 769c. ActUpdStd Update another user's data and groups + 769d. ActUpdTch Update another user's data and groups + 770b. ActReqAccEnrStd Confirm acceptation / refusion of enrollment as student in current course + 770c. ActReqAccEnrTch Confirm acceptation / refusion of enrollment as teacher in current course + 771b. ActAccEnrStd Accept enrollment as student in current course + 771c. ActAccEnrTch Accept enrollment as teacher in current course + 772b. ActRemMe_Std Reject enrollment as student in current course + 772b. ActRemMe_Tch Reject enrollment as teacher in current course + 773. ActNewAdmIns Register an administrador in this institution 774. ActRemAdmIns Remove an administrador of this institution 775. ActNewAdmCtr Register an administrador in this centre @@ -2364,9 +2368,12 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActUpdStd */{1423,-1,TabUsr,ActLstStd ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ModifyUsr ,NULL}, /* ActUpdTch */{1424,-1,TabUsr,ActLstTch ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ModifyUsr ,NULL}, - /* ActReqAccEnrCrs */{ 592,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, - /* ActAccEnrCrs */{ 558,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, - /* ActRemMeCrs */{ 559,-1,TabUsr,ActLstStd ,0x1F8,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, + /* ActReqAccEnrStd */{1456,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, + /* ActReqAccEnrTch */{1457,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqAcceptRegisterInCrs ,NULL}, + /* ActAccEnrStd */{1458,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, + /* ActAccEnrTch */{1459,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AcceptRegisterMeInCrs ,NULL}, + /* ActRemMe_Std */{1460,-1,TabUsr,ActLstStd ,0x008,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, + /* ActRemMe_Tch */{1461,-1,TabUsr,ActLstTch ,0x010,0x000,0x000,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_ReqRemMeFromCrs ,NULL}, /* ActNewAdmIns */{1337,-1,TabUsr,ActLstOth ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_AddAdmToIns ,NULL}, /* ActRemAdmIns */{1338,-1,TabUsr,ActLstOth ,0x180,0x180,0x180,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Enr_RemAdmIns ,NULL}, @@ -3302,8 +3309,8 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActEdiCrs, // #555 ActNewCrs, // #556 -1, // #557 (obsolete action) - ActAccEnrCrs, // #558 - ActRemMeCrs, // #559 + -1, // #558 (obsolete action) + -1, // #559 (obsolete action) ActRemCrs, // #560 ActChgCrsYea, // #561 ActChgCrsSem, // #562 @@ -3336,7 +3343,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActChgMyRol, // #589 ActReqRemOldUsr, // #590 ActReqAccGbl, // #591 - ActReqAccEnrCrs, // #592 + -1, // #592 (obsolete action) ActReqDelAllRcvMsg, // #593 ActReqAccCrs, // #594 ActReqRemFilMrkCrs, // #595 @@ -4194,15 +4201,21 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActCreOth, // #1444 ActCreStd, // #1445 ActCreTch, // #1446 - ActFrmIDsOth, // #1447 - ActFrmIDsStd, // #1448 - ActFrmIDsTch, // #1449 + ActFrmIDsOth, // #1447 + ActFrmIDsStd, // #1448 + ActFrmIDsTch, // #1449 ActRemID_Oth, // #1450 ActRemID_Std, // #1451 ActRemID_Tch, // #1452 ActNewID_Oth, // #1453 ActNewID_Std, // #1454 ActNewID_Tch, // #1455 + ActReqAccEnrStd, // #1456 + ActReqAccEnrTch, // #1457 + ActAccEnrStd, // #1458 + ActAccEnrTch, // #1459 + ActRemMe_Std, // #1460 + ActRemMe_Tch, // #1461 }; /*****************************************************************************/ @@ -4578,7 +4591,8 @@ void Act_AdjustCurrentAction (void) the only action possible is show a form to ask for enrollment *****/ if (!Gbl.Usrs.Me.UsrDat.Accepted && Gbl.CurrentAct != ActLogOut) { - Gbl.CurrentAct = ActReqAccEnrCrs; + Gbl.CurrentAct = (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT) ? ActReqAccEnrStd : + ActReqAccEnrTch; Tab_SetCurrentTab (); return; } diff --git a/swad_action.h b/swad_action.h index eb3c415e4..dda5f1da4 100644 --- a/swad_action.h +++ b/swad_action.h @@ -69,9 +69,9 @@ typedef enum typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+134+168+28+79) +#define Act_NUM_ACTIONS (7+52+15+90+73+68+204+182+137+168+28+79) -#define Act_MAX_ACTION_COD 1455 +#define Act_MAX_ACTION_COD 1461 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -974,51 +974,54 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica #define ActUpdStd (ActChgNumRowFooGrp+ 95) #define ActUpdTch (ActChgNumRowFooGrp+ 96) -#define ActReqAccEnrCrs (ActChgNumRowFooGrp+ 97) -#define ActAccEnrCrs (ActChgNumRowFooGrp+ 98) -#define ActRemMeCrs (ActChgNumRowFooGrp+ 99) +#define ActReqAccEnrStd (ActChgNumRowFooGrp+ 97) +#define ActReqAccEnrTch (ActChgNumRowFooGrp+ 98) +#define ActAccEnrStd (ActChgNumRowFooGrp+ 99) +#define ActAccEnrTch (ActChgNumRowFooGrp+100) +#define ActRemMe_Std (ActChgNumRowFooGrp+101) +#define ActRemMe_Tch (ActChgNumRowFooGrp+102) -#define ActNewAdmIns (ActChgNumRowFooGrp+100) -#define ActRemAdmIns (ActChgNumRowFooGrp+101) -#define ActNewAdmCtr (ActChgNumRowFooGrp+102) -#define ActRemAdmCtr (ActChgNumRowFooGrp+103) -#define ActNewAdmDeg (ActChgNumRowFooGrp+104) -#define ActRemAdmDeg (ActChgNumRowFooGrp+105) +#define ActNewAdmIns (ActChgNumRowFooGrp+103) +#define ActRemAdmIns (ActChgNumRowFooGrp+104) +#define ActNewAdmCtr (ActChgNumRowFooGrp+105) +#define ActRemAdmCtr (ActChgNumRowFooGrp+106) +#define ActNewAdmDeg (ActChgNumRowFooGrp+107) +#define ActRemAdmDeg (ActChgNumRowFooGrp+108) -#define ActRcvFrmEnrSevStd (ActChgNumRowFooGrp+106) -#define ActRcvFrmEnrSevTch (ActChgNumRowFooGrp+107) +#define ActRcvFrmEnrSevStd (ActChgNumRowFooGrp+109) +#define ActRcvFrmEnrSevTch (ActChgNumRowFooGrp+110) -#define ActFrmIDsOth (ActChgNumRowFooGrp+108) -#define ActFrmIDsStd (ActChgNumRowFooGrp+109) -#define ActFrmIDsTch (ActChgNumRowFooGrp+110) -#define ActRemID_Oth (ActChgNumRowFooGrp+111) -#define ActRemID_Std (ActChgNumRowFooGrp+112) -#define ActRemID_Tch (ActChgNumRowFooGrp+113) -#define ActNewID_Oth (ActChgNumRowFooGrp+114) -#define ActNewID_Std (ActChgNumRowFooGrp+115) -#define ActNewID_Tch (ActChgNumRowFooGrp+116) -#define ActFrmPwdOthUsr (ActChgNumRowFooGrp+117) -#define ActChgPwdOthUsr (ActChgNumRowFooGrp+118) -#define ActRemUsrCrs (ActChgNumRowFooGrp+119) -#define ActRemUsrGbl (ActChgNumRowFooGrp+120) +#define ActFrmIDsOth (ActChgNumRowFooGrp+111) +#define ActFrmIDsStd (ActChgNumRowFooGrp+112) +#define ActFrmIDsTch (ActChgNumRowFooGrp+113) +#define ActRemID_Oth (ActChgNumRowFooGrp+114) +#define ActRemID_Std (ActChgNumRowFooGrp+115) +#define ActRemID_Tch (ActChgNumRowFooGrp+116) +#define ActNewID_Oth (ActChgNumRowFooGrp+117) +#define ActNewID_Std (ActChgNumRowFooGrp+118) +#define ActNewID_Tch (ActChgNumRowFooGrp+119) +#define ActFrmPwdOthUsr (ActChgNumRowFooGrp+120) +#define ActChgPwdOthUsr (ActChgNumRowFooGrp+121) +#define ActRemUsrCrs (ActChgNumRowFooGrp+122) +#define ActRemUsrGbl (ActChgNumRowFooGrp+123) -#define ActReqRemAllStdCrs (ActChgNumRowFooGrp+121) -#define ActRemAllStdCrs (ActChgNumRowFooGrp+122) +#define ActReqRemAllStdCrs (ActChgNumRowFooGrp+124) +#define ActRemAllStdCrs (ActChgNumRowFooGrp+125) -#define ActReqRemOldUsr (ActChgNumRowFooGrp+123) -#define ActRemOldUsr (ActChgNumRowFooGrp+124) +#define ActReqRemOldUsr (ActChgNumRowFooGrp+126) +#define ActRemOldUsr (ActChgNumRowFooGrp+127) -#define ActSeePubPrf (ActChgNumRowFooGrp+125) -#define ActCal1stClkTim (ActChgNumRowFooGrp+126) -#define ActCalNumClk (ActChgNumRowFooGrp+127) -#define ActCalNumFilVie (ActChgNumRowFooGrp+128) -#define ActCalNumForPst (ActChgNumRowFooGrp+129) -#define ActCalNumMsgSnt (ActChgNumRowFooGrp+130) +#define ActSeePubPrf (ActChgNumRowFooGrp+128) +#define ActCal1stClkTim (ActChgNumRowFooGrp+129) +#define ActCalNumClk (ActChgNumRowFooGrp+130) +#define ActCalNumFilVie (ActChgNumRowFooGrp+131) +#define ActCalNumForPst (ActChgNumRowFooGrp+132) +#define ActCalNumMsgSnt (ActChgNumRowFooGrp+133) -#define ActFolUsr (ActChgNumRowFooGrp+131) -#define ActUnfUsr (ActChgNumRowFooGrp+132) -#define ActSeeFlg (ActChgNumRowFooGrp+133) -#define ActSeeFlr (ActChgNumRowFooGrp+134) +#define ActFolUsr (ActChgNumRowFooGrp+134) +#define ActUnfUsr (ActChgNumRowFooGrp+135) +#define ActSeeFlg (ActChgNumRowFooGrp+136) +#define ActSeeFlr (ActChgNumRowFooGrp+137) /*****************************************************************************/ /******************************* Messages tab ********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index 564aa6924..fe41a198a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -98,11 +98,40 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.133.1 (2015/09/17)" +#define Log_PLATFORM_VERSION "SWAD 14.134 (2015/09/17)" // 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 14.134: Sep 17, 2015 Changes in user enrollment. + Changes in notifications about enrollment. (184823 lines) + 25 changes necessary in database: +UPDATE actions SET Obsolete='Y' WHERE ActCod='592'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1456','es','N','Solicitar acept. inscrip. estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1457','es','N','Solicitar acept. inscrip. profesor'); +UPDATE actions SET Obsolete='Y' WHERE ActCod='558'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1458','es','N','Aceptar inscrip. como estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1459','es','N','Aceptar inscrip. como profesor'); +UPDATE actions SET Obsolete='Y' WHERE ActCod='559'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1460','es','N','Rechazar inscrip. como estudiante'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1461','es','N','Rechazar inscrip. como profesor'); +UPDATE notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE notif SET NotifyEvent=8 WHERE NotifyEvent=7; +UPDATE sta_notif SET NotifyEvent=14 WHERE NotifyEvent=13; +UPDATE sta_notif SET NotifyEvent=13 WHERE NotifyEvent=12; +UPDATE sta_notif SET NotifyEvent=12 WHERE NotifyEvent=11; +UPDATE sta_notif SET NotifyEvent=11 WHERE NotifyEvent=10; +UPDATE sta_notif SET NotifyEvent=10 WHERE NotifyEvent=9; +UPDATE sta_notif SET NotifyEvent=9 WHERE NotifyEvent=8; +UPDATE sta_notif SET NotifyEvent=8 WHERE NotifyEvent=7; +UPDATE usr_data SET NotifNtfEvents=(((NotifNtfEvents & ~0x7F) << 1) | (NotifNtfEvents & 0x7F) | 0x80); +UPDATE usr_data SET EmailNtfEvents=(((EmailNtfEvents & ~0x7F) << 1) | (EmailNtfEvents & 0x7F)); + Version 14.133.1: Sep 17, 2015 Changes in user enrollment. (184669 lines) Version 14.133: Sep 17, 2015 Changes in user enrollment. (184665 lines) 1 change necessary in database: diff --git a/swad_enrollment.c b/swad_enrollment.c index 93baf6942..bc04f7550 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -86,6 +86,8 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void Enr_NotifyAfterEnrollment (struct UsrData *UsrDat,Rol_Role_t NewRole); + static void Enr_ReqAdminUsrs (Rol_Role_t Role); static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role); @@ -156,9 +158,14 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat, if (NewRole != OldRole) // The role must be updated { /***** Check if user's role is allowed *****/ - if (!(NewRole == Rol_STUDENT || - NewRole == Rol_TEACHER)) - Lay_ShowErrorAndExit ("Wrong role."); + switch (NewRole) + { + case Rol_STUDENT: + case Rol_TEACHER: + break; + default: + Lay_ShowErrorAndExit ("Wrong role."); + } /***** Update the role of a user in a course *****/ sprintf (Query,"UPDATE crs_usr SET Role='%u'" @@ -166,6 +173,11 @@ void Enr_ModifyRoleInCurrentCrs (struct UsrData *UsrDat, (unsigned) NewRole,Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); DB_QueryUPDATE (Query,"can not modify user's role in course"); + /***** Create notification for this user. + If this user wants to receive notifications by e-mail, + activate the sending of a notification *****/ + Enr_NotifyAfterEnrollment (UsrDat,NewRole); + /***** Show info message *****/ if (QuietOrVerbose == Cns_VERBOSE) { @@ -194,13 +206,16 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, extern const char *Usr_StringsUsrListTypeInDB[Usr_NUM_USR_LIST_TYPES]; extern const char *Txt_THE_USER_X_has_been_enrolled_in_the_course_Y; char Query[1024]; - bool CreateNotif; - bool NotifyByEmail; /***** Check if user's role is allowed *****/ - if (!(NewRole == Rol_STUDENT || - NewRole == Rol_TEACHER)) - Lay_ShowErrorAndExit ("Wrong role."); + switch (NewRole) + { + case Rol_STUDENT: + case Rol_TEACHER: + break; + default: + Lay_ShowErrorAndExit ("Wrong role."); + } /***** Register user in current course in database *****/ sprintf (Query,"INSERT INTO crs_usr (CrsCod,UsrCod,Role,Accepted," @@ -220,20 +235,10 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, UsrDat->RoleInCurrentCrsDB = NewRole; UsrDat->Roles |= NewRole; - /***** Remove possible inscription request ******/ - Enr_RemoveEnrollmentRequest (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); - /***** Create notification for this user. If this user wants to receive notifications by e-mail, activate the sending of a notification *****/ - CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << Ntf_EVENT_ENROLLMENT)); - NotifyByEmail = CreateNotif && - (UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) && - (UsrDat->Prefs.EmailNtfEvents & (1 << Ntf_EVENT_ENROLLMENT)); - if (CreateNotif) - Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_ENROLLMENT,UsrDat,-1L, - (Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL : - 0)); + Enr_NotifyAfterEnrollment (UsrDat,NewRole); /***** Show info message *****/ if (QuietOrVerbose == Cns_VERBOSE) @@ -244,6 +249,48 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, } } +/*****************************************************************************/ +/********* Create notification after register user in current course *********/ +/*****************************************************************************/ + +static void Enr_NotifyAfterEnrollment (struct UsrData *UsrDat,Rol_Role_t NewRole) + { + bool CreateNotif; + bool NotifyByEmail; + Ntf_NotifyEvent_t NotifyEvent; + + /***** Check if user's role is allowed *****/ + switch (NewRole) + { + case Rol_STUDENT: + NotifyEvent = Ntf_EVENT_ENROLLMENT_STUDENT; + break; + case Rol_TEACHER: + NotifyEvent = Ntf_EVENT_ENROLLMENT_TEACHER; + break; + default: + NotifyEvent = Ntf_EVENT_UNKNOWN; + Lay_ShowErrorAndExit ("Wrong role."); + } + + /***** Remove possible enrollment request ******/ + Enr_RemoveEnrollmentRequest (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); + + /***** Remove old enrollment notifications before inserting the new one ******/ + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1,UsrDat->UsrCod); + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1,UsrDat->UsrCod); + + /***** Create new notification ******/ + CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << NotifyEvent)); + NotifyByEmail = CreateNotif && + (UsrDat->UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod) && + (UsrDat->Prefs.EmailNtfEvents & (1 << NotifyEvent)); + if (CreateNotif) + Ntf_StoreNotifyEventToOneUser (NotifyEvent,UsrDat,-1L, + (Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL : + 0)); + } + /*****************************************************************************/ /****** Write a form to request another user's ID, @nickname or e-mail *******/ /*****************************************************************************/ @@ -288,17 +335,20 @@ void Enr_ReqAcceptRegisterInCrs (void) fprintf (Gbl.F.Out,"
"); /***** Send button to accept register in the current course *****/ - Act_PutContextualLink (ActAccEnrCrs,NULL, - "ok_green",Txt_Confirm_my_enrollment); + Act_PutContextualLink (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? ActAccEnrStd : + ActAccEnrTch, + NULL,"ok_green",Txt_Confirm_my_enrollment); /***** Send button to refuse register in the current course *****/ - Act_PutContextualLink (ActRemMeCrs,NULL, - "delon",Txt_Remove_me_from_this_course); + Act_PutContextualLink (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? ActRemMe_Std : + ActRemMe_Tch, + NULL,"delon",Txt_Remove_me_from_this_course); fprintf (Gbl.F.Out,"
"); /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_ENROLLMENT, + Ntf_SetNotifAsSeen (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? Ntf_EVENT_ENROLLMENT_STUDENT : + Ntf_EVENT_ENROLLMENT_TEACHER, -1L, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -3183,6 +3233,13 @@ void Enr_AcceptRegisterMeInCrs (void) /***** Confirm my enrollment *****/ Enr_AcceptUsrInCrs (Gbl.Usrs.Me.UsrDat.UsrCod); + /***** Mark all notifications about enrollment (as student or as teacher) + in current course as removed *****/ + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1L, + Gbl.Usrs.Me.UsrDat.UsrCod); + Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1L, + Gbl.Usrs.Me.UsrDat.UsrCod); + /***** Confirmation message *****/ sprintf (Gbl.Message,Txt_You_have_confirmed_your_enrollment_in_the_course_X, Gbl.CurrentCrs.Crs.FullName); diff --git a/swad_notification.c b/swad_notification.c index 4e17e031d..b67a3c81d 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -68,7 +68,8 @@ const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] = "marksFile", /* Enrollment tab */ - "enrollment", + "enrollmentStudent", + "enrollmentTeacher", "enrollmentRequest", /* Messages tab */ @@ -98,7 +99,8 @@ static const Act_Action_t Ntf_DefaultActions[Ntf_NUM_NOTIFY_EVENTS] = ActSeeAdmMrk, // Ntf_EVENT_MARKS_FILE /* Users tab */ - ActReqAccEnrCrs, // Ntf_EVENT_ENROLLMENT + ActReqAccEnrStd, // Ntf_EVENT_ENROLLMENT_STUDENT + ActReqAccEnrTch, // Ntf_EVENT_ENROLLMENT_TEACHER ActSeeSignUpReq, // Ntf_EVENT_ENROLLMENT_REQUEST /* Messages tab */ @@ -133,7 +135,8 @@ static const char *Ntf_ParamNotifMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] = "NotifyNtfEventMarksFile", /* Enrollment tab */ - "NotifyNtfEventEnrollment", + "NotifyNtfEventEnrollmentStudent", + "NotifyNtfEventEnrollmentTeacher", "NotifyNtfEventEnrollmentRequest", /* Messages tab */ @@ -164,7 +167,8 @@ static const char *Ntf_ParamEmailMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] = "EmailNtfEventMarksFile", /* Enrollment tab */ - "EmailNtfEventEnrollment", + "EmailNtfEventEnrollmentStudent", + "EmailNtfEventEnrollmentTeacher", "EmailNtfEventEnrollmentRequest", /* Messages tab */ @@ -195,7 +199,8 @@ static const char *Ntf_Icons[Ntf_NUM_NOTIFY_EVENTS] = "grades", // Ntf_EVENT_MARKS_FILE /* Enrollment tab */ - "adduser", // Ntf_EVENT_ENROLLMENT + "adduser", // Ntf_EVENT_ENROLLMENT_STUDENT + "adduser", // Ntf_EVENT_ENROLLMENT_TEACHER "enrollmentrequest", // Ntf_EVENT_ENROLLMENT_REQUEST /* Messages tab */ @@ -739,7 +744,8 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_Notif case Ntf_EVENT_MARKS_FILE: Mrk_GetNotifMyMarks (SummaryStr,ContentStr,Cod,UsrCod,MaxChars,GetContent); break; - case Ntf_EVENT_ENROLLMENT: + case Ntf_EVENT_ENROLLMENT_STUDENT: + case Ntf_EVENT_ENROLLMENT_TEACHER: Enr_GetNotifEnrollment (SummaryStr,CrsCod,UsrCod,MaxChars); break; case Ntf_EVENT_ENROLLMENT_REQUEST: @@ -1067,7 +1073,8 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod) Gbl.CurrentCrs.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; - case Ntf_EVENT_ENROLLMENT: // This function should not be called in this case + case Ntf_EVENT_ENROLLMENT_STUDENT: // This function should not be called in this case + case Ntf_EVENT_ENROLLMENT_TEACHER: // This function should not be called in this case return 0; case Ntf_EVENT_ENROLLMENT_REQUEST: if (Gbl.CurrentCrs.Crs.NumTchs) @@ -1444,7 +1451,8 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign case Ntf_EVENT_ASSIGNMENT: case Ntf_EVENT_EXAM_ANNOUNCEMENT: case Ntf_EVENT_MARKS_FILE: - case Ntf_EVENT_ENROLLMENT: + case Ntf_EVENT_ENROLLMENT_STUDENT: + case Ntf_EVENT_ENROLLMENT_TEACHER: case Ntf_EVENT_ENROLLMENT_REQUEST: case Ntf_EVENT_NOTICE: case Ntf_EVENT_MESSAGE: diff --git a/swad_notification.h b/swad_notification.h index d3a234590..42adc63e3 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -37,37 +37,38 @@ /******************************** Public types *******************************/ /*****************************************************************************/ -#define Ntf_NUM_NOTIFY_EVENTS 14 +#define Ntf_NUM_NOTIFY_EVENTS 15 // If the numbers assigned to each event type change, // it is necessary to change old numbers to new ones in database tables notif and sta_notif typedef enum { - Ntf_EVENT_UNKNOWN = 0, + Ntf_EVENT_UNKNOWN = 0, // old 0 /* Course tab */ - Ntf_EVENT_DOCUMENT_FILE = 1, - Ntf_EVENT_SHARED_FILE = 2, + Ntf_EVENT_DOCUMENT_FILE = 1, // old 1 + Ntf_EVENT_SHARED_FILE = 2, // old 2 /* Assessment tab */ - Ntf_EVENT_ASSIGNMENT = 3, - Ntf_EVENT_EXAM_ANNOUNCEMENT = 4, - Ntf_EVENT_MARKS_FILE = 5, + Ntf_EVENT_ASSIGNMENT = 3, // old 3 + Ntf_EVENT_EXAM_ANNOUNCEMENT = 4, // old 4 + Ntf_EVENT_MARKS_FILE = 5, // old 5 /* Enrollment tab */ - Ntf_EVENT_ENROLLMENT = 6, - Ntf_EVENT_ENROLLMENT_REQUEST = 7, + Ntf_EVENT_ENROLLMENT_STUDENT = 6, // old 6 + Ntf_EVENT_ENROLLMENT_TEACHER = 7, + Ntf_EVENT_ENROLLMENT_REQUEST = 8, // old 7 /* Messages tab */ - Ntf_EVENT_NOTICE = 8, - Ntf_EVENT_FORUM_POST_COURSE = 9, - Ntf_EVENT_FORUM_REPLY = 10, - Ntf_EVENT_MESSAGE = 11, + Ntf_EVENT_NOTICE = 9, // old 8 + Ntf_EVENT_FORUM_POST_COURSE = 10, // old 9 + Ntf_EVENT_FORUM_REPLY = 11, // old 10 + Ntf_EVENT_MESSAGE = 12, // old 11 /* Statistics tab */ - Ntf_EVENT_SURVEY = 12, + Ntf_EVENT_SURVEY = 13, // old 12 /* Profile tab */ - Ntf_EVENT_FOLLOWER = 13, + Ntf_EVENT_FOLLOWER = 14, // old 13 } Ntf_NotifyEvent_t; diff --git a/swad_text.c b/swad_text.c index 47906a5a1..adcaec017 100644 --- a/swad_text.c +++ b/swad_text.c @@ -598,16 +598,28 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][Txt_NUM_LA "Novo arquivo de notas", }, { - // Ntf_EVENT_ENROLLMENT - "Nova inscripció", - "New Einschreibung", - "New enrollment", - "Nueva inscripción", - "Nouvelle inscription", - "Nueva inscripción", // Okoteve traducción - "Nuova iscrizione", - "Nowe zapisy", - "Nova inscrição", + // Ntf_EVENT_ENROLLMENT_STUDENT + "Nova inscripció com a estudiant", + "New Einschreibung als Student", + "New enrollment as a student", + "Nueva inscripción como estudiante", + "Nouvelle inscriptionen tant qu'étudiant", + "Nueva inscripción como estudiante", // Okoteve traducción + "Nuova iscrizione come studente", + "Nowe zapisy jako student", + "Nova inscrição como estudante", + }, + { + // Ntf_EVENT_ENROLLMENT_TEACHER + "Nova inscripció com a professor", + "New Einschreibung als Lehrkraft", + "New enrollment as a teacher", + "Nueva inscripción como profesor", + "Nouvelle inscription en tant qu'enseignant", + "Nueva inscripción como profesor", // Okoteve traducción + "Nuova iscrizione come professore", + "Nowe zapisy jako nauczyciel", + "Nova inscrição como professor", }, { // Ntf_EVENT_ENROLLMENT_REQUEST @@ -24692,24 +24704,44 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] = "Novos arquivos de notas" #endif , -#if L==0 // Ntf_EVENT_ENROLLMENT - "Novas inscripciós" +#if L==0 // Ntf_EVENT_ENROLLMENT_STUDENT + "Novas inscripciós com a estudiant" #elif L==1 - "New Einschreibungen" + "New Einschreibungen als Student" #elif L==2 - "New enrollments" + "New enrollments as a student" #elif L==3 - "Nuevas inscripciones" + "Nuevas inscripciones como estudiante" #elif L==4 - "Nouvelles inscriptions" + "Nouvelles inscriptions en tant qu'étudiant" #elif L==5 - "Nuevas inscripciones" // Okoteve traducción + "Nuevas inscripciones como estudiante" // Okoteve traducción #elif L==6 - "Nuova iscrizione" + "Nuova iscrizione come studente" #elif L==7 - "Nowe zapisy" + "Nowe zapisy jako student" #elif L==8 - "Novas inscrições" + "Novas inscrições como estudante" +#endif + , +#if L==0 // Ntf_EVENT_ENROLLMENT_TEACHER + "Novas inscripciós com a professor" +#elif L==1 + "New Einschreibungen als Lehrkraft" +#elif L==2 + "New enrollments as a teacher" +#elif L==3 + "Nuevas inscripciones como profesor/a" +#elif L==4 + "Nouvelles inscriptions en tant qu'enseignant" +#elif L==5 + "Nuevas inscripciones como profesor/a" // Okoteve traducción +#elif L==6 + "Nuova iscrizione come professore" +#elif L==7 + "Nowe zapisy jako nauczyciel" +#elif L==8 + "Novas inscrições como professor" #endif , #if L==0 // Ntf_EVENT_ENROLLMENT_REQUEST @@ -24975,24 +25007,44 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] = "Arquivo de notas" #endif , -#if L==0 // Ntf_EVENT_ENROLLMENT - "Inscripció" +#if L==0 // Ntf_EVENT_ENROLLMENT_STUDENT + "Inscripció com a estudiant" #elif L==1 - "Einschreibung" + "Einschreibung als Student" #elif L==2 - "Enrollment" + "Enrollment as a student" #elif L==3 - "Inscripción" + "Inscripción como estudiante" #elif L==4 - "Inscription" + "Inscription en tant qu'étudiant" #elif L==5 - "Inscripción" // Okoteve traducción + "Inscripción como estudiante" // Okoteve traducción #elif L==6 - "Iscrizione" + "Iscrizione come studente" #elif L==7 - "Zapisy" + "Zapisy jako student" #elif L==8 - "Inscrição" + "Inscrição como estudante" +#endif + , +#if L==0 // Ntf_EVENT_ENROLLMENT_TEACHER + "Inscripció com a professor" +#elif L==1 + "Einschreibung als Lehrkraft" +#elif L==2 + "Enrollment as a teacher" +#elif L==3 + "Inscripción como profesor/a" +#elif L==4 + "Inscription en tant qu'enseignant" +#elif L==5 + "Inscripción como profesor/a" // Okoteve traducción +#elif L==6 + "Iscrizione come professore" +#elif L==7 + "Zapisy jako nauczyciel" +#elif L==8 + "Inscrição como professor" #endif , #if L==0 // Ntf_EVENT_ENROLLMENT_REQUEST