Changes for page Per A.Y.

From version 38.1
edited by Andrea Omicini
on 28/11/2021 01:29
Change comment: There is no comment for this version
To version 45.8
edited by Andrea Omicini
on 08/02/2023 00:37
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,0 @@
1 -#if($xcontext.language=='it')Corsi per A.A.#{else}Courses per A.Y.#end
Content
... ... @@ -1,4 +1,6 @@
1 -{{include reference="Courses.Environment"/}}{{include reference="Environment"/}}{{velocity}}
1 += {{italiano}}Per A.A.{{/italiano}}{{english}}Per A.Y.{{/english}} =
2 +
3 +{{include reference="Courses.Environment" excludeFirstHeading="true"/}}{{velocity}}
2 2  #set( $courseMenu = true )
3 3  #set( $currentCourseDoc = "" )
4 4  #### get parameters
... ... @@ -18,7 +18,11 @@
18 18   #set( $userLastName = $userdoc.display("last_name") )
19 19  #elseif ( $userNamePar )
20 20  ## from the URL, "user=UserName" parameter
21 - #set( $userName = "XWiki.$userNamePar" )
23 + #if( $userNamePar.contains("XWiki.") )
24 + #set( $userName = $userNamePar )
25 + #else
26 + #set( $userName = "XWiki.$userNamePar" )
27 + #end
22 22   #set( $userdoc = $xwiki.getDocument($userName) )
23 23   #set( $userFirstName = $userdoc.display("first_name") )
24 24   #set( $userLastName = $userdoc.display("last_name") )
... ... @@ -34,7 +34,11 @@
34 34   #set( $professorLastName = $professordoc.display("last_name") )
35 35  #elseif ( $professorNamePar )
36 36  ## from the URL, "professor=UserName" parameter
37 - #set( $professorName = "XWiki.$professorNamePar" )
43 + #if( $professorNamePar.contains("XWiki.") )
44 + #set( $professorName = $professorNamePar )
45 + #else
46 + #set( $professorName = "XWiki.$professorNamePar" )
47 + #end
38 38   #set( $professordoc = $xwiki.getDocument($professorName) )
39 39   #set( $professorFirstName = $professordoc.display("first_name") )
40 40   #set( $professorLastName = $professordoc.display("last_name") )
... ... @@ -50,7 +50,11 @@
50 50   #set( $tutorLastName = $tutordoc.display("last_name") )
51 51  #elseif ( $tutorNamePar )
52 52  ## from the URL, "tutor=UserName" parameter
53 - #set( $tutorName = "XWiki.$tutorNamePar" )
63 + #if( $tutorNamePar.contains("XWiki.") )
64 + #set( $tutorName = $tutorNamePar )
65 + #else
66 + #set( $tutorName = "XWiki.$tutorNamePar" )
67 + #end
54 54   #set( $tutordoc = $xwiki.getDocument($tutorName) )
55 55   #set( $tutorFirstName = $tutordoc.display("first_name") )
56 56   #set( $tutorLastName = $tutordoc.display("last_name") )
... ... @@ -59,13 +59,32 @@
59 59   #set( $tutorFirstName = "" )
60 60   #set( $tutorLastName = "" )
61 61  #end
62 -## professor takes precedence over tutor
63 -#if( $professorName != "" )#set( $tutorName = "" )#end
76 +## who, in the end
77 +#set( $oneUser = false )
78 +#set( $oneProfessor = false )
79 +#set( $oneTutor = false )
80 +##
81 +#if( $userName != "" )
64 64  ## user takes precedence over both professor and tutor and gets them all
65 -#if( $userName != "" )#set( $professorName = $userName )#set( $tutorName = $userName )#end
83 + #set( $professorName = $userName )
84 + #set( $tutorName = $userName )
85 + #set( $oneUser = true )
86 +#elseif( $professorName != "" )
87 +## professor takes precedence over tutor
88 + #set( $tutorName = "@@" )
89 + #set( $userName = "@@" )
90 + #set( $oneProfessor = true )
91 +#elseif( $tutorName != "" )
92 +## just tutor
93 + #set( $professorName = "@@" )
94 + #set( $userName = "@@" )
95 + #set( $oneTutor = true )
96 +#end
66 66  ##
67 67  #if( $firstYearCou )#set( $firstYear = $firstYearCou )#end
68 68  #if( $lastYearCou )#set( $lastYear = $lastYearCou )#end
100 +#if( $firstYearCourse )#set( $firstYear = $firstYearCourse )#end
101 +#if( $lastYearCourse )#set( $lastYear = $lastYearCourse )#end
69 69  #set( $firstYear1 = $firstYear + 1 )#set( $firstAYear = $firstYear + "/" + $firstYear1 )
70 70  #set( $lastYear1 = $lastYear + 1 )#set( $lastAYear = $lastYear + "/" + $lastYear1 )
71 71  #set( $yearRange = [$lastYear..$firstYear] )
... ... @@ -102,29 +102,52 @@
102 102   #set($aYear = $year + "/" + $year1 )
103 103   #end
104 104  #end
105 ->{{stringEngIta eng = "Courses" ita = "Corsi"/}} / **#if( $oneYear )$aYear#else$firstAYear**–**$lastAYear#end**#if( $userName != "" ) / $userFirstName $userLastName#elseif( $professorName != "" ) / $professorFirstName $professorLastName#elseif( $tutorName != "" ) / $tutorFirstName $tutorLastName (tutor)#end{{id name="top"/}}
138 +#### HANDLE PARAMETERS / END
106 106  ##
107 -#if( !$oneYear )
108 -(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach ($yearr in $yearList)#set($yearr1 = $yearr + 1)#set($ayearr = "$yearr/$yearr1")#if( $velocityCount > 1 ) | #end[[$ayearr>>$doc||anchor=$yearr]]#end)))
109 -#end
110 -##
111 -#if( $xcontext.language== "it" )#set( $sortField = "ita")#else#set( $sortField = "eng")#end
140 +### query to structures
141 +## map & counter initialisation
142 +#set( $courseMap = {} )
112 112  #set( $courseNo = 0 )
144 +#if( $services.localization.currentLocale == "it" )#set( $sortField = "ita")#else#set( $sortField = "eng")#end
145 +##
146 +##
113 113  #foreach( $yearr in $yearList)#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 )
114 114   #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, StringProperty as prop4
115 - where obj.name = doc.fullName and obj.className = 'Courses.CourseClass' and obj.name <> 'Courses.CourseTemplate' and prop.id.id = obj.id and prop1.id.id = obj.id and prop2.id.id = obj.id and prop3.id.id = obj.id and prop4.id.id = obj.id and prop.name = 'ay' and prop1.name = 'professor' and prop2.name = 'otherProfessors' and prop3.name = 'tutors' and prop4.name = '$sortField' and prop.value = '$ayearr' and ( prop1.value like '%$professorName%' or prop2.value like '%$professorName%' or prop3.value like '%$tutorName%' ) order by prop4.value asc ")
149 + where obj.name = doc.fullName and obj.className = '${objectSpace}.${objectClass}' and obj.name <> '${objectSpace}.${objectTemplate}' and prop.id.id = obj.id and prop1.id.id = obj.id and prop2.id.id = obj.id and prop3.id.id = obj.id and prop4.id.id = obj.id and prop.name = 'ay' and prop1.name = 'professor' and prop2.name = 'otherProfessors' and prop3.name = 'tutors' and prop4.name = '$sortField' and prop.value = '$ayearr' #if( $oneUser )and ( prop1.value like '%$professorName%' or prop2.value like '%$professorName%' or prop3.value like '%$tutorName%' )#end#if( $oneProfessor )and ( prop1.value like '%$professorName%' or prop2.value like '%$professorName%' )#end#if( $oneTutor )and prop3.value like '%$tutorName%'#end order by prop4.value asc ")
116 116   #set( $courseFound = $xwiki.searchDocuments($sql) )
117 117   #set( $courseYearNo = $courseFound.size() )
118 118   #if( $$courseYearNo >0 )
153 + #set( $courseMap[$yearr] = $courseFound )
119 119   #set( $courseNo = $courseNo + $courseYearNo )
120 - #if( !$oneYear )
121 -(% style="border-style:solid hidden hidden solid; border-color:$theme.borderColor; text-align:left; font-style:oblique" %)|{{id name='$yearr'/}}[[$ayearr>>$doc||queryString='year=$yearr#if( $userName != "" )&user=$userName#elseif( $professorName != "" )&professor=$professorName#elseif( $tutorName != "" )&tutor=$tutorName#end']]
122 - #end
123 - #foreach( $courseDoc in $courseFound )
124 -* {{courseName}}$courseDoc{{/courseName}}
125 - #end
126 -(% style="#if( !$oneYear )border-style:hidden solid solid hidden; border-color:$theme.borderColor;#end text-align:right; font-style:oblique; font-size:smaller" %)|($courseYearNo #if( $courseYearNo == 1 ){{stringEngIta eng='course in' ita='corso nel'/}}#else{{stringEngIta eng='courses in' ita='corsi nel'/}}#end $ayearr) [[[{{stringEngIta eng='top' ita='in cima'/}}]>>||anchor="top"]] [[[{{stringEngIta eng='bottom' ita='in fondo'/}}]>>||anchor="bottom"]]
127 127   #end
128 128  #end
129 -#if( !$oneYear )(% style="text-align:right; font-style:oblique; font-size:smaller; border-bottom-style:dotted; border-color:$theme.borderColor" %)|($courseNo #if( $courseNo == 1 ){{stringEngIta eng='course' ita='corso'/}}#else{{stringEngIta eng='courses' ita='corsi'/}}#end)#end
157 +### output results
158 +## page subtitle
159 +{{id name="top"/}}
160 +>(%%)$courseNo #if( $courseNo == 1 ){{stringEngIta eng="$objectEngSingular.toLowerCase()" ita="$objectItaSingular.toLowerCase()"/}}#{else}{{stringEngIta eng="$objectEngPlural.toLowerCase()" ita="$objectItaPlural.toLowerCase()"/}}#{end} / #if( $oneYear )$aYear#else$lastAYear–$firstAYear#end#if( $oneUser ) / $userFirstName $userLastName#elseif( $oneProfessor ) / $professorFirstName $professorLastName#elseif( $oneTutor ) / $tutorFirstName $tutorLastName (tutor)#{end}(%%)
161 +##
162 +## stop if no course are found
163 +#if( $courseNo == 0 || $courseMap.keySet().size() == 0 )
164 +## redundant double check
165 + #stop
166 +#end
167 +## some course found
168 +## page index
169 +#if( $courseMap.keySet().size() > 1 )
170 +## found more than one year
171 +{{id name="index"/}}
172 +(% style="font-size:smaller; text-align:right; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $yearr in $courseMap.keySet() )#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 )#if( !$foreach.first ) | #end[[$ayearr>>||anchor="$ayearr"]]#end)))
173 +#end
174 +## courses displayed per academic year
175 +#foreach( $yearr in $courseMap.keySet() )#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 )
176 +(% style="border-style:solid hidden hidden solid; border-color:$theme.borderColor; text-align:left; font-style:oblique" %)|{{id name='$ayearr'/}}[[$ayearr>>$doc||style='text-decoration:none; color:$theme.textPrimaryColor' queryString='year=$yearr#if( $oneUser )&user=$userName#elseif( $oneProfessor )&professor=$professorName#elseif( $oneTutor )&tutor=$tutorName#end']]
177 +(% style="border-style:hidden hidden hidden hidden; font-style:normal" %)
178 +#foreach( $course in $courseMap[$yearr] )
179 +* {{courseName}}$course{{/courseName}}
180 + #end
181 +(%%)
182 + #set( $courseYearNo = $courseMap[$yearr].size() )
183 +(% style="border-style:hidden solid solid hidden; border-color:$theme.borderColor; text-align:right; font-style:oblique; font-size:smaller" %)|($courseYearNo #if( $courseYearNo == 1 ){{stringEngIta eng='course in' ita='corso nel'/}}#{else}{{stringEngIta eng='courses in' ita='corsi nel'/}}#end $yearr) [[[{{stringEngIta eng='top' ita='in cima'/}}]>>||anchor="top"]] [[[{{stringEngIta eng='bottom' ita='in fondo'/}}]>>||anchor="bottom"]]
184 +#end
130 130  {{/velocity}}
186 +{{id name="bottom"/}}