From dea61286ecfabdb9f3608e3579b8c90d7bc2802c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 29 Dec 2014 00:54:56 +0100 Subject: [PATCH] Version 14.47 --- swad_centre.c | 6 +- swad_centre.h | 2 +- swad_changelog.h | 3 +- swad_country.c | 6 +- swad_country.h | 2 +- swad_course.c | 352 +++++++++++++++++++++++++++++++++++++-------- swad_degree.c | 8 +- swad_degree.h | 2 +- swad_forum.c | 4 +- swad_institution.c | 6 +- swad_institution.h | 2 +- swad_user.c | 56 ++++++-- swad_user.h | 3 +- 13 files changed, 366 insertions(+), 86 deletions(-) diff --git a/swad_centre.c b/swad_centre.c index 9235ab7a9..702318d87 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -510,13 +510,13 @@ static void Ctr_Configuration (bool PrintView) /********* Put a link (form) to view centres of current institution **********/ /*****************************************************************************/ // Gbl.CurrentIns.Ins.InsCod must be > 0 - +/* void Ctr_PutLinkToViewCentresOfCurrentIns (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Centres_of_INSTITUTION_X; - /***** Put form to view centres of current institution *****/ + ***** Put form to view centres of current institution ***** Act_FormStart (ActSeeCtr); sprintf (Gbl.Title,Txt_Centres_of_INSTITUTION_X, Gbl.CurrentIns.Ins.ShortName); @@ -524,7 +524,7 @@ void Ctr_PutLinkToViewCentresOfCurrentIns (void) Lay_PutSendIcon ("ctr",Gbl.Title,Gbl.Title); fprintf (Gbl.F.Out,""); } - +*/ /*****************************************************************************/ /*************** Show the centres of the current institution *****************/ /*****************************************************************************/ diff --git a/swad_centre.h b/swad_centre.h index 2ef3462a5..85bbff2f1 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -90,7 +90,7 @@ void Ctr_SeeCtrWithPendingDegs (void); void Ctr_ShowConfiguration (void); void Ctr_PrintConfiguration (void); -void Ctr_PutLinkToViewCentresOfCurrentIns (void); +// void Ctr_PutLinkToViewCentresOfCurrentIns (void); void Ctr_ShowCtrsOfCurrentIns (void); void Ctr_EditCentres (void); void Ctr_GetListCentres (long InsCod); diff --git a/swad_changelog.h b/swad_changelog.h index 8393b2008..35ee17b43 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -35,11 +35,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.46.2 (2014/12/28)" +#define Log_PLATFORM_VERSION "SWAD 14.47 (2014/12/29)" // 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.47 :Dic 29, 2014 Changes in listing of user's courses. (174659 lines) Version 14.46.2 :Dic 28, 2014 Code refactoring in forums. (174400 lines) Version 14.46.1 :Dic 28, 2014 Changes in listing of forums. (174342 lines) Version 14.46 :Dic 28, 2014 Course syllabus are shown in one unique option. (174340 lines) diff --git a/swad_country.c b/swad_country.c index eb2afea1b..c908161a5 100644 --- a/swad_country.c +++ b/swad_country.c @@ -475,19 +475,19 @@ static void Cty_Configuration (bool PrintView) /*****************************************************************************/ /******************** Put a link (form) to view countries ********************/ /*****************************************************************************/ - +/* void Cty_PutLinkToViewCountries (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Countries; - /***** Put form to view institutions of current country *****/ + ***** Put form to view institutions of current country ***** Act_FormStart (ActSeeCty); Act_LinkFormSubmit (Txt_Countries,The_ClassFormul[Gbl.Prefs.Theme]); Lay_PutSendIcon ("earth",Txt_Countries,Txt_Countries); fprintf (Gbl.F.Out,""); } - +*/ /*****************************************************************************/ /*************************** List all the countries **************************/ /*****************************************************************************/ diff --git a/swad_country.h b/swad_country.h index 3ab8974cc..3aa5e96f5 100644 --- a/swad_country.h +++ b/swad_country.h @@ -75,7 +75,7 @@ void Cty_SeeCtyWithPendingInss (void); void Cty_ShowConfiguration (void); void Cty_PrintConfiguration (void); -void Cty_PutLinkToViewCountries (void); +// void Cty_PutLinkToViewCountries (void); void Cty_ListCountries (void); void Cty_ListCountries1 (void); void Cty_ListCountries2 (void); diff --git a/swad_course.c b/swad_course.c index 2f65a64bc..caedd99fa 100644 --- a/swad_course.c +++ b/swad_course.c @@ -75,7 +75,7 @@ static void Crs_PutFormToConfigLogIn (bool IsForm); static void Crs_WriteListMyCoursesToSelectOne (void); -static void Crs_PutLinkToViewCoursesOfCurrentDeg (void); +// static void Crs_PutLinkToViewCoursesOfCurrentDeg (void); static void Crs_GetListCoursesInDegree (Crs_WhatCourses_t WhatCourses); static void Crs_ListCourses (void); static void Crs_EditCourses (void); @@ -538,74 +538,312 @@ static void Crs_WriteListMyCoursesToSelectOne (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_My_courses; + extern const char *Txt_TABS_FULL_TXT[Act_NUM_TABS]; extern const char *Txt_Go_to_X; - unsigned NumMyCrs; + struct Country Cty; + struct Institution Ins; + struct Centre Ctr; struct Degree Deg; struct Course Crs; - char CourseFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME+1]; // Full name of course + bool IsLastItemInLevel[1+5]; + MYSQL_RES *mysql_resCty; + MYSQL_RES *mysql_resIns; + MYSQL_RES *mysql_resCtr; + MYSQL_RES *mysql_resDeg; + MYSQL_RES *mysql_resCrs; + MYSQL_ROW row; + unsigned NumCty,NumCtys; + unsigned NumIns,NumInss; + unsigned NumCtr,NumCtrs; + unsigned NumDeg,NumDegs; + unsigned NumCrs,NumCrss; char PathRelRSSFile[PATH_MAX+1]; - /***** Start form *****/ + char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1]; + char Icon[512]; + + /***** Table start *****/ Lay_StartRoundFrameTable10 (NULL,0,Txt_My_courses); + + /***** Write link to country *****/ fprintf (Gbl.F.Out,"" - "" - "" - "" - ""); + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_resCty); + + /***** End frame *****/ Lay_EndRoundFrameTable10 (); } @@ -711,13 +949,13 @@ unsigned Crs_GetNumCrssWithUsrs (Rol_Role_t Role,const char *SubQuery) /************ Put a link (form) to view courses of current degree ************/ /*****************************************************************************/ // Gbl.CurrentDeg.Deg.DegCod must be > 0 - +/* static void Crs_PutLinkToViewCoursesOfCurrentDeg (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Courses_of_DEGREE_X; - /***** Put form to view courses of current degree *****/ + ***** Put form to view courses of current degree ***** Act_FormStart (ActSeeCrs); sprintf (Gbl.Title,Txt_Courses_of_DEGREE_X, Gbl.CurrentDeg.Deg.ShortName); @@ -725,7 +963,7 @@ static void Crs_PutLinkToViewCoursesOfCurrentDeg (void) Lay_PutSendIcon ("hierarchy",Gbl.Title,Gbl.Title); fprintf (Gbl.F.Out,""); } - +*/ /*****************************************************************************/ /************************** Show courses of a degree *************************/ /*****************************************************************************/ @@ -2768,6 +3006,7 @@ void Crs_ReqSelectOneOfMyCourses (void) /***** Search / select more courses *****/ fprintf (Gbl.F.Out,"
"); Crs_PutLinkToSearchCourses (); + /* if (Gbl.CurrentDeg.Deg.DegCod > 0) Crs_PutLinkToViewCoursesOfCurrentDeg (); else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) @@ -2778,6 +3017,7 @@ void Crs_ReqSelectOneOfMyCourses (void) Ins_PutLinkToViewInstitutionsOfCurrentCty (); else Cty_PutLinkToViewCountries (); + */ fprintf (Gbl.F.Out,"
"); /***** Select one of my courses *****/ diff --git a/swad_degree.c b/swad_degree.c index 3fe5e77b9..e787ff5b3 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -630,7 +630,7 @@ void Deg_WriteCtyInsCtrDeg (void) extern const char *Txt_TABS_FULL_TXT[Act_NUM_TABS]; char DegreeShortName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree - /***** Form to go to the country *****/ + /***** Form to go to the system *****/ Act_FormGoToStart (ActMnu); Par_PutHiddenParamUnsigned ("NxtTab",(unsigned) TabSys); Act_LinkFormSubmit (Txt_TABS_FULL_TXT[TabSys], @@ -970,13 +970,13 @@ void Deg_ReqEditDegreeTypes (void) /*********** Put a link (form) to view degrees of current centre *************/ /*****************************************************************************/ // Gbl.CurrentCtr.Ctr.CtrCod must be > 0 - +/* void Deg_PutLinkToViewDegreesOfCurrentCtr (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Degrees_of_CENTRE_X; - /***** Put form to view degrees of current centre *****/ + ***** Put form to view degrees of current centre ***** Act_FormStart (ActSeeDeg); sprintf (Gbl.Title,Txt_Degrees_of_CENTRE_X, Gbl.CurrentCtr.Ctr.ShortName); @@ -984,7 +984,7 @@ void Deg_PutLinkToViewDegreesOfCurrentCtr (void) Lay_PutSendIcon ("deg",Gbl.Title,Gbl.Title); fprintf (Gbl.F.Out,""); } - +*/ /*****************************************************************************/ /************* Show the degrees belonging to the current centre **************/ /*****************************************************************************/ diff --git a/swad_degree.h b/swad_degree.h index 1d3932fe7..e125e966b 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -114,7 +114,7 @@ void Deg_InitCurrentCourse (void); void Deg_WriteSelectorDegTypes (void); void Deg_SeeDegTypes (void); void Deg_ReqEditDegreeTypes (void); -void Deg_PutLinkToViewDegreesOfCurrentCtr (void); +// void Deg_PutLinkToViewDegreesOfCurrentCtr (void); void Deg_ShowDegsOfCurrentCtr (void); unsigned Deg_ConvStrToYear (const char *StrYear); diff --git a/swad_forum.c b/swad_forum.c index 0c26b3c50..68a9f75e0 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1648,7 +1648,7 @@ void For_ShowForumList (void) For_WriteLinksToInsForums (Gbl.Usrs.Me.MyInstitutions.Inss[NumMyIns].InsCod,(NumMyIns == Gbl.Usrs.Me.MyInstitutions.Num-1),IsLastItemInLevel); /* Get my centres in this institution from database */ - if ((NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Forum.Ins.InsCod,&mysql_resCtr)) > 0) // Degrees found in this institution + if ((NumCtrs = Usr_GetCtrsFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Forum.Ins.InsCod,&mysql_resCtr)) > 0) // Centres found in this institution for (NumCtr = 0; NumCtr < NumCtrs; NumCtr++) @@ -1861,7 +1861,7 @@ static long For_WriteLinksToCtrForums (long CtrCod,bool IsLastCtr,bool IsLastIte ICanSeeTeacherForum = (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER || Rol_GetMyMaxRoleInCtr (CtrCod) >= Rol_ROLE_TEACHER); - /***** Get data of this degree *****/ + /***** Get data of this centre *****/ Gbl.Forum.Ctr.CtrCod = CtrCod; if (!Ctr_GetDataOfCentreByCod (&Gbl.Forum.Ctr)) Lay_ShowErrorAndExit ("Centre not found."); diff --git a/swad_institution.c b/swad_institution.c index b5b492107..2dc40471c 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -463,13 +463,13 @@ static void Ins_Configuration (bool PrintView) /********* Put a link (form) to view institutions of current country *********/ /*****************************************************************************/ // Gbl.CurrentCty.Cty.CtyCod must be > 0 - +/* void Ins_PutLinkToViewInstitutionsOfCurrentCty (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Institutions_of_COUNTRY_X; - /***** Put form to view institutions of current country *****/ + ***** Put form to view institutions of current country ***** Act_FormStart (ActSeeIns); sprintf (Gbl.Title,Txt_Institutions_of_COUNTRY_X, Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]); @@ -477,7 +477,7 @@ void Ins_PutLinkToViewInstitutionsOfCurrentCty (void) Lay_PutSendIcon ("ins",Gbl.Title,Gbl.Title); fprintf (Gbl.F.Out,""); } - +*/ /*****************************************************************************/ /**************** List the institutions of the current country ***************/ /*****************************************************************************/ diff --git a/swad_institution.h b/swad_institution.h index 5cee735b3..a2efcf511 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -97,7 +97,7 @@ void Ins_SeeInsWithPendingCtrs (void); void Ins_ShowConfiguration (void); void Ins_PrintConfiguration (void); -void Ins_PutLinkToViewInstitutionsOfCurrentCty (void); +// void Ins_PutLinkToViewInstitutionsOfCurrentCty (void); void Ins_ShowInssOfCurrentCty (void); void Ins_EditInstitutions (void); void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData); diff --git a/swad_user.c b/swad_user.c index 9cf162151..52773a601 100644 --- a/swad_user.c +++ b/swad_user.c @@ -764,7 +764,7 @@ void Usr_GetMyInstitutions (void) Gbl.Usrs.Me.MyInstitutions.Num = 0; /***** Get my institutions from database *****/ - if ((NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,&mysql_res)) > 0) // Institutions found + if ((NumInss = (unsigned) Usr_GetInssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,-1L,&mysql_res)) > 0) // Institutions found for (NumIns = 0; NumIns < NumInss; NumIns++) @@ -783,7 +783,7 @@ void Usr_GetMyInstitutions (void) Gbl.Usrs.Me.MyInstitutions.Num++; } - } + } /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); @@ -1070,25 +1070,63 @@ bool Usr_CheckIfIBelongToCrs (long CrsCod) } /*****************************************************************************/ -/************** Get the institutions of a user from database *****************/ +/**************** Get the countries of a user from database ******************/ /*****************************************************************************/ // Returns the number of rows of the result -unsigned long Usr_GetInssFromUsr (long UsrCod,MYSQL_RES **mysql_res) +unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res) { + extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES]; char Query[512]; /***** Get the institutions a user belongs to from database *****/ - sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)" - " FROM crs_usr,courses,degrees,centres,institutions" + sprintf (Query,"SELECT countries.CtyCod,MAX(crs_usr.Role)" + " FROM crs_usr,courses,degrees,centres,institutions,countries" " WHERE crs_usr.UsrCod='%ld'" " AND crs_usr.CrsCod=courses.CrsCod" " AND courses.DegCod=degrees.DegCod" " AND degrees.CtrCod=centres.CtrCod" " AND centres.InsCod=institutions.InsCod" - " GROUP BY institutions.InsCod" - " ORDER BY institutions.ShortName", - UsrCod); + " AND institutions.CtyCod=countries.CtyCod" + " GROUP BY countries.CtyCod" + " ORDER BY countries.Name_%s", + UsrCod,Txt_STR_LANG_ID[Gbl.Prefs.Language]); + return (unsigned) DB_QuerySELECT (Query,mysql_res,"can not get the countries a user belongs to"); + } + +/*****************************************************************************/ +/************** Get the institutions of a user from database *****************/ +/*****************************************************************************/ +// Returns the number of rows of the result + +unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res) + { + char Query[512]; + + /***** Get the institutions a user belongs to from database *****/ + if (CtyCod > 0) + sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)" + " FROM crs_usr,courses,degrees,centres,institutions" + " WHERE crs_usr.UsrCod='%ld'" + " AND crs_usr.CrsCod=courses.CrsCod" + " AND courses.DegCod=degrees.DegCod" + " AND degrees.CtrCod=centres.CtrCod" + " AND centres.InsCod=institutions.InsCod" + " AND institutions.CtyCod='%ld'" + " GROUP BY institutions.InsCod" + " ORDER BY institutions.ShortName", + UsrCod,CtyCod); + else + sprintf (Query,"SELECT institutions.InsCod,MAX(crs_usr.Role)" + " FROM crs_usr,courses,degrees,centres,institutions" + " WHERE crs_usr.UsrCod='%ld'" + " AND crs_usr.CrsCod=courses.CrsCod" + " AND courses.DegCod=degrees.DegCod" + " AND degrees.CtrCod=centres.CtrCod" + " AND centres.InsCod=institutions.InsCod" + " GROUP BY institutions.InsCod" + " ORDER BY institutions.ShortName", + UsrCod); return DB_QuerySELECT (Query,mysql_res,"can not get the institutions a user belongs to"); } diff --git a/swad_user.h b/swad_user.h index 37af4fd16..93be331a8 100644 --- a/swad_user.h +++ b/swad_user.h @@ -218,7 +218,8 @@ bool Usr_CheckIfIBelongToIns (long InsCod); bool Usr_CheckIfIBelongToCtr (long CtrCod); bool Usr_CheckIfIBelongToDeg (long DegCod); bool Usr_CheckIfIBelongToCrs (long CrsCod); -unsigned long Usr_GetInssFromUsr (long UsrCod,MYSQL_RES **mysql_res); +unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res); +unsigned long Usr_GetInssFromUsr (long UsrCod,long CtyCod,MYSQL_RES **mysql_res); unsigned long Usr_GetCtrsFromUsr (long UsrCod,long InsCod,MYSQL_RES **mysql_res); unsigned long Usr_GetDegsFromUsr (long UsrCod,long CtrCod,MYSQL_RES **mysql_res); unsigned long Usr_GetCrssFromUsr (long UsrCod,long DegCod,MYSQL_RES **mysql_res);