Changes for page Per A.Y.
From version 31.1
edited by Andrea Omicini
on 24/11/2021 01:43
on 24/11/2021 01:43
Change comment:
There is no comment for this version
To version 45.11
edited by Andrea Omicini
on 08/02/2023 03:54
on 08/02/2023 03:54
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
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,7 @@ 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}} 4 +#set( $courseMenu = true ) 2 2 #set( $currentCourseDoc = "" ) 3 3 #### get parameters 4 4 ## when ... ... @@ -6,6 +6,10 @@ 6 6 #set( $firstYearPar = $context.getRequest().getParameter("from") ) 7 7 #set( $lastYearPar = $context.getRequest().getParameter("to") ) 8 8 ## who 12 +#set( $oneUser = false ) 13 +#set( $oneProfessor = false ) 14 +#set( $oneTutor = false ) 15 +## 9 9 #set( $userNamePar = $context.getRequest().getParameter("user") ) 10 10 #set( $professorNamePar = $context.getRequest().getParameter("professor") ) 11 11 #set( $tutorNamePar = $context.getRequest().getParameter("tutor") ) ... ... @@ -15,16 +15,18 @@ 15 15 #set( $userdoc = $xwiki.getDocument($userName) ) 16 16 #set( $userFirstName = $userdoc.display("first_name") ) 17 17 #set( $userLastName = $userdoc.display("last_name") ) 25 + #set( $oneUser = true ) 18 18 #elseif ( $userNamePar ) 19 19 ## from the URL, "user=UserName" parameter 20 - #set( $userName = "XWiki.$userNamePar" ) 28 + #if( $userNamePar.contains("XWiki.") ) 29 + #set( $userName = $userNamePar ) 30 + #else 31 + #set( $userName = "XWiki.$userNamePar" ) 32 + #end 21 21 #set( $userdoc = $xwiki.getDocument($userName) ) 22 22 #set( $userFirstName = $userdoc.display("first_name") ) 23 23 #set( $userLastName = $userdoc.display("last_name") ) 24 -#else 25 - #set( $userName = "" ) 26 - #set( $userFirstName = "" ) 27 - #set( $userLastName = "" ) 36 + #set( $oneUser = true ) 28 28 #end 29 29 #if ( $professorName ) 30 30 ## from a personal page, "XWiki.UserName" $professorName form ... ... @@ -31,16 +31,18 @@ 31 31 #set( $professordoc = $xwiki.getDocument($professorName) ) 32 32 #set( $professorFirstName = $professordoc.display("first_name") ) 33 33 #set( $professorLastName = $professordoc.display("last_name") ) 43 + #set( $oneProfessor = true ) 34 34 #elseif ( $professorNamePar ) 35 35 ## from the URL, "professor=UserName" parameter 36 - #set( $professorName = "XWiki.$professorNamePar" ) 46 + #if( $professorNamePar.contains("XWiki.") ) 47 + #set( $professorName = $professorNamePar ) 48 + #else 49 + #set( $professorName = "XWiki.$professorNamePar" ) 50 + #end 37 37 #set( $professordoc = $xwiki.getDocument($professorName) ) 38 38 #set( $professorFirstName = $professordoc.display("first_name") ) 39 39 #set( $professorLastName = $professordoc.display("last_name") ) 40 -#else 41 - #set( $professorName = "" ) 42 - #set( $professorFirstName = "" ) 43 - #set( $professorLastName = "" ) 54 + #set( $oneProfessor = true ) 44 44 #end 45 45 #if ( $tutorName ) 46 46 ## from a personal page, "XWiki.UserName" $tutorName form ... ... @@ -49,22 +49,35 @@ 49 49 #set( $tutorLastName = $tutordoc.display("last_name") ) 50 50 #elseif ( $tutorNamePar ) 51 51 ## from the URL, "tutor=UserName" parameter 52 - #set( $tutorName = "XWiki.$tutorNamePar" ) 63 + #if( $tutorNamePar.contains("XWiki.") ) 64 + #set( $tutorName = $tutorNamePar ) 65 + #else 66 + #set( $tutorName = "XWiki.$tutorNamePar" ) 67 + #end 53 53 #set( $tutordoc = $xwiki.getDocument($tutorName) ) 54 54 #set( $tutorFirstName = $tutordoc.display("first_name") ) 55 55 #set( $tutorLastName = $tutordoc.display("last_name") ) 56 -#else 57 - #set( $tutorName = "" ) 58 - #set( $tutorFirstName = "" ) 59 - #set( $tutorLastName = "" ) 71 + #set( $oneTutor = true ) 60 60 #end 61 -## professortakesprecedence over tutor62 -#if( $ professorName!= "" )#set( $tutorName= "")#end73 +## who, in the end 74 +#if( $oneUser ) 63 63 ## user takes precedence over both professor and tutor and gets them all 64 -#if( $userName != "" )#set( $professorName = $userName )#set( $tutorName = $userName )#end 76 + #set( $oneProfessor = false ) 77 + #set( $oneTutor = false ) 78 +#elseif( $oneProfessor ) 79 +## professor takes precedence over tutor 80 + #set( $oneUser = false ) 81 + #set( $oneTutor = false ) 82 +#elseif( $oneTutor ) 83 +## just tutor 84 + #set( $oneUser = false ) 85 + #set( $oneProfessor = false ) 86 +#end 65 65 ## 66 66 #if( $firstYearCou )#set( $firstYear = $firstYearCou )#end 67 67 #if( $lastYearCou )#set( $lastYear = $lastYearCou )#end 90 +#if( $firstYearCourse )#set( $firstYear = $firstYearCourse )#end 91 +#if( $lastYearCourse )#set( $lastYear = $lastYearCourse )#end 68 68 #set( $firstYear1 = $firstYear + 1 )#set( $firstAYear = $firstYear + "/" + $firstYear1 ) 69 69 #set( $lastYear1 = $lastYear + 1 )#set( $lastAYear = $lastYear + "/" + $lastYear1 ) 70 70 #set( $yearRange = [$lastYear..$firstYear] ) ... ... @@ -101,28 +101,52 @@ 101 101 #set($aYear = $year + "/" + $year1 ) 102 102 #end 103 103 #end 104 - >{{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"/}}128 +#### HANDLE PARAMETERS / END 105 105 ## 106 -#if( !$oneYear ) 107 -(% 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))) 108 -#end 109 -## 130 +### query to structures 131 +## map & counter initialisation 132 +#set( $courseMap = {} ) 110 110 #set( $courseNo = 0 ) 134 +#if( $services.localization.currentLocale == "it" )#set( $sortField = "ita")#else#set( $sortField = "eng")#end 135 +## 136 +## 111 111 #foreach( $yearr in $yearList)#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 ) 112 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3 113 - 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 prop.name = 'aY' and prop1.name = 'professor' and prop2.name = 'otherProfessors' and prop3.name = 'tutors' and prop.value like '%$yearr%' and ( prop1.value like '%$professorName%' or prop2.value like '%$professorName%' or prop3.value like '%$tutorName%')order by prop.valuedesc ")138 + #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, StringProperty as prop4 139 + 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 '%$userName%' or prop2.value like '%$userName%' or prop3.value like '%$userName%' )#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 ") 114 114 #set( $courseFound = $xwiki.searchDocuments($sql) ) 115 115 #set( $courseYearNo = $courseFound.size() ) 116 116 #if( $$courseYearNo >0 ) 143 + #set( $courseMap[$yearr] = $courseFound ) 117 117 #set( $courseNo = $courseNo + $courseYearNo ) 118 - #if( !$oneYear ) 119 -(% 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']] 120 - #end 121 - #foreach( $courseDoc in $courseFound ) 122 -* {{courseName}}$courseDoc{{/courseName}} 123 - #end 124 -(% 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"]] 125 125 #end 126 126 #end 127 -#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 147 +### output results 148 +## page subtitle 149 +{{id name="top"/}} 150 +>(%%)$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}(%%) 151 +## 152 +## stop if no course are found 153 +#if( $courseNo == 0 || $courseMap.keySet().size() == 0 ) 154 +## redundant double check 155 + #stop 156 +#end 157 +## some course found 158 +## page index 159 +#if( $courseMap.keySet().size() > 1 ) 160 +## found more than one year 161 +{{id name="index"/}} 162 +(% 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))) 163 +#end 164 +## courses displayed per academic year 165 +#foreach( $yearr in $courseMap.keySet() )#set($yearr1 = $yearr + 1)#set($ayearr = $yearr + "/" + $yearr1 ) 166 +(% 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']] 167 +(% style="border-style:hidden hidden hidden hidden; font-style:normal" %) 168 +#foreach( $course in $courseMap[$yearr] ) 169 +* {{courseName}}$course{{/courseName}} 170 + #end 171 +(%%) 172 + #set( $courseYearNo = $courseMap[$yearr].size() ) 173 +(% 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"]] 174 +#end 128 128 {{/velocity}} 176 +{{id name="bottom"/}}