Changes for page Per A.Y.

From version 39.1
edited by Andrea Omicini
on 21/01/2022 18:57
Change comment: There is no comment for this version
To version 45.7
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" excludeFirstHeading="true"/}}{{include reference="Environment" excludeFirstHeading="true"/}}{{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,6 +50,11 @@
50 50   #set( $tutorLastName = $tutordoc.display("last_name") )
51 51  #elseif ( $tutorNamePar )
52 52  ## from the URL, "tutor=UserName" parameter
63 + #if( $tutorNamePar.contains("XWiki.") )
64 + #set( $tutorName = $tutorNamePar )
65 + #else
66 + #set( $tutorName = "XWiki.$tutorNamePar" )
67 + #end
53 53   #set( $tutorName = "XWiki.$tutorNamePar" )
54 54   #set( $tutordoc = $xwiki.getDocument($tutorName) )
55 55   #set( $tutorFirstName = $tutordoc.display("first_name") )
... ... @@ -59,15 +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
77 +## who, in the end
78 +#set( $oneUser = false )
79 +#set( $oneProfessor = false )
80 +#set( $oneTutor = false )
81 +##
82 +#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
84 + #set( $professorName = $userName )
85 + #set( $tutorName = $userName )
86 + #set( $oneUser = true )
87 +#elseif( $professorName != "" )
88 +## professor takes precedence over tutor
89 + #set( $tutorName = "@@" )
90 + #set( $userName = "@@" )
91 + #set( $oneProfessor = true )
92 +#elseif( $tutorName != "" )
93 +## just tutor
94 + #set( $professorName = "@@" )
95 + #set( $userName = "@@" )
96 + #set( $oneTutor = true )
97 +#end
66 66  ##
67 -#if( $firstYearCourse )#set( $firstYear = $firstYearCourse )#end
68 68  #if( $firstYearCou )#set( $firstYear = $firstYearCou )#end
69 -#if( $lastYearCourse )#set( $lastYear = $lastYearCourse )#end
70 70  #if( $lastYearCou )#set( $lastYear = $lastYearCou )#end
101 +#if( $firstYearCourse )#set( $firstYear = $firstYearCourse )#end
102 +#if( $lastYearCourse )#set( $lastYear = $lastYearCourse )#end
71 71  #set( $firstYear1 = $firstYear + 1 )#set( $firstAYear = $firstYear + "/" + $firstYear1 )
72 72  #set( $lastYear1 = $lastYear + 1 )#set( $lastAYear = $lastYear + "/" + $lastYear1 )
73 73  #set( $yearRange = [$lastYear..$firstYear] )
... ... @@ -104,29 +104,52 @@
104 104   #set($aYear = $year + "/" + $year1 )
105 105   #end
106 106  #end
107 ->{{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"/}}
139 +#### HANDLE PARAMETERS / END
108 108  ##
109 -#if( !$oneYear )
110 -(% 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)))
111 -#end
112 -##
113 -#if( $xcontext.language== "it" )#set( $sortField = "ita")#else#set( $sortField = "eng")#end
141 +### query to structures
142 +## map & counter initialisation
143 +#set( $courseMap = {} )
114 114  #set( $courseNo = 0 )
145 +#if( $services.localization.currentLocale == "it" )#set( $sortField = "ita")#else#set( $sortField = "eng")#end
146 +##
147 +##
115 115  #foreach( $yearr in $yearList)#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 )
116 116   #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, StringProperty as prop4
117 - 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 ")
150 + 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 ")
118 118   #set( $courseFound = $xwiki.searchDocuments($sql) )
119 119   #set( $courseYearNo = $courseFound.size() )
120 120   #if( $$courseYearNo >0 )
154 + #set( $courseMap[$yearr] = $courseFound )
121 121   #set( $courseNo = $courseNo + $courseYearNo )
122 - #if( !$oneYear )
123 -(% 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']]
124 - #end
125 - #foreach( $courseDoc in $courseFound )
126 -* {{courseName}}$courseDoc{{/courseName}}
127 - #end
128 -(% 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"]]
129 129   #end
130 130  #end
131 -#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
158 +### output results
159 +## page subtitle
160 +{{id name="top"/}}
161 +>(%%)$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}(%%)
162 +##
163 +## stop if no course are found
164 +#if( $courseNo == 0 || $courseMap.keySet().size() == 0 )
165 +## redundant double check
166 + #stop
167 +#end
168 +## some course found
169 +## page index
170 +#if( $courseMap.keySet().size() > 1 )
171 +## found more than one year
172 +{{id name="index"/}}
173 +(% 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)))
174 +#end
175 +## courses displayed per academic year
176 +#foreach( $yearr in $courseMap.keySet() )#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 )
177 +(% 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']]
178 +(% style="border-style:hidden hidden hidden hidden; font-style:normal" %)
179 +#foreach( $course in $courseMap[$yearr] )
180 +* {{courseName}}$course{{/courseName}}
181 + #end
182 +(%%)
183 + #set( $courseYearNo = $courseMap[$yearr].size() )
184 +(% 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"]]
185 +#end
132 132  {{/velocity}}
187 +{{id name="bottom"/}}