From 664a18ccaba1fa3ee1545e63e9f22911044cdda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 29 Oct 2016 00:22:34 +0200 Subject: [PATCH] Version 16.46 --- swad_changelog.h | 4 +++- swad_survey.c | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index 1104db9ca..04a0815eb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -154,13 +154,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.45.10 (2016-10-28)" +#define Log_PLATFORM_VERSION "SWAD 16.46 (2016-10-29)" #define CSS_FILE "swad16.32.1.css" #define JS_FILE "swad15.238.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 16.46: Oct 29, 2016 Fixed bugs in surveys. + View only the surveys of my groups. (206032 lines) Version 16.45.10: Oct 28, 2016 Messages translated. (205995 lines) Version 16.45.9: Oct 28, 2016 Free lists of user's countries, institutions, centres and degrees. Code refactoring related to hierarchy. (205994 lines) diff --git a/swad_survey.c b/swad_survey.c index c9ee64908..0284b35a2 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -193,6 +193,10 @@ static void Svy_ListAllSurveys (struct SurveyQuestion *SvyQst) unsigned NumSvy; bool ICanEdit = Svy_CheckIfICanCreateSvy (); + /***** Get number of groups in current course *****/ + if (!Gbl.CurrentCrs.Grps.NumGrps) + Gbl.CurrentCrs.Grps.WhichGrps = Grp_ALL_GROUPS; + /***** Get list of surveys *****/ Svy_GetListSurveys (); @@ -844,7 +848,7 @@ static void Svy_PutParams (void) void Svy_GetListSurveys (void) { extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; - char SubQuery[Sco_NUM_SCOPES][128]; + char SubQuery[Sco_NUM_SCOPES][256]; char OrderBySubQuery[256]; char Query[2048]; MYSQL_RES *mysql_res; @@ -872,8 +876,9 @@ void Svy_GetListSurveys (void) Cods[Sco_SCOPE_DEG] = Gbl.CurrentDeg.Deg.DegCod; // Degree Cods[Sco_SCOPE_CRS] = Gbl.CurrentCrs.Crs.CrsCod; // Course + /* Fill subqueries for system, country, institution, centre and degree */ for (Scope = Sco_SCOPE_SYS, SubQueryFilled = false; - Scope <= Sco_SCOPE_CRS; + Scope <= Sco_SCOPE_DEG; Scope++) if (ScopesAllowed & 1 << Scope) { @@ -881,13 +886,45 @@ void Svy_GetListSurveys (void) SubQueryFilled ? " OR " : "", Sco_ScopeDB[Scope],Cods[Scope], - (ScopesAllowed & 1 << Sco_SCOPE_SYS) ? "" : - " AND Hidden='N'"); + (HiddenAllowed & 1 << Scope) ? "" : + " AND Hidden='N'"); SubQueryFilled = true; } else SubQuery[Scope][0] = '\0'; + /* Fill subquery for course */ + if (ScopesAllowed & 1 << Sco_SCOPE_CRS) + { + if (Gbl.CurrentCrs.Grps.WhichGrps == Grp_ONLY_MY_GROUPS) + sprintf (SubQuery[Scope],"%s(" + "Scope='%s' AND Cod='%ld'%s" + " AND " + "(SvyCod NOT IN" + " (SELECT SvyCod FROM svy_grp)" + " OR" + " SvyCod IN" + " (SELECT svy_grp.SvyCod" + " FROM svy_grp,crs_grp_usr" + " WHERE crs_grp_usr.UsrCod='%ld'" + " AND svy_grp.GrpCod=crs_grp_usr.GrpCod))" + ")", + SubQueryFilled ? " OR " : + "", + Sco_ScopeDB[Scope],Cods[Sco_SCOPE_CRS], + (HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" : + " AND Hidden='N'", + Gbl.Usrs.Me.UsrDat.UsrCod); + else // Gbl.CurrentCrs.Grps.WhichGrps == Grp_ALL_GROUPS + sprintf (SubQuery[Scope],"%s(Scope='%s' AND Cod='%ld'%s)", + SubQueryFilled ? " OR " : + "", + Sco_ScopeDB[Scope],Cods[Sco_SCOPE_CRS], + (HiddenAllowed & 1 << Sco_SCOPE_CRS) ? "" : + " AND Hidden='N'"); + SubQueryFilled = true; + } + if (SubQueryFilled) { switch (Gbl.Svys.SelectedOrderType)