Änderungen von Dokument Sandbox

Zuletzt geändert von Holger Engels am 2024/01/26 15:58

Von Version 19.1
bearbeitet von Holger Engels
am 2023/11/13 21:36
Änderungskommentar: Es gibt keinen Kommentar für diese Version
Auf Version 21.3
bearbeitet von Holger Engels
am 2023/11/15 12:00
Änderungskommentar: Es gibt keinen Kommentar für diese Version

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -120,13 +120,16 @@
120 120  == Rating Tests ==
121 121  
122 122  {{velocity}}
123 -#set($average = $services.ratings.aufgaben.getAverageRating($doc.space + "^" + "test"))
124 -
123 +#set($ref = $doc.space + "^" + "test")
124 +#set($average = $services.ratings.aufgaben.getAverageRating($ref))
125 +#set($myv = $services.ratings.aufgaben.getRating($ref))
126 +$ref = $average.get().averageVote
127 +$myv.get().totalVote
125 125  {{html clean="false" wiki="true"}}
126 126  <style>
127 127  star-rating { display: inline-block; width: 120px }
128 128  </style>
129 -<star-rating stars=5 rating="$average.get().averageVote" bgcolor="white" nocolor="lightgrey" color="gold" onclick="rated.call(this)"></star-rating>
132 +<star-rating stars=5 rating="$average.get().averageVote" rid="test" bgcolor="white" nocolor="lightgrey" color="gold" onclick="rated.call(this)"></star-rating>
130 130  {{/html}}
131 131  {{/velocity}}
132 132  
... ... @@ -133,16 +133,18 @@
133 133  {{html clean="false"}}
134 134  <script>
135 135   function rated() {
136 - console.log(this.getAttribute("rating"))
139 + console.log(XWiki.currentDocument.space + ".WebHome")
140 + console.log(this.getAttribute("rating"));
141 + sendRate(this.getAttribute("rid"), parseInt(this.getAttribute("rating")));
137 137   }
138 - var setVote = function (vote) {
143 + var sendRate = function (rid, vote) {
139 139   fetch(new XWiki.Document('WebHome', 'Macros.Aufgabenbewertung').getURL('get') + "?outputSyntax=plain", {
140 140   method: "POST",
141 141   headers: { "Content-Type": "application/json"},
142 142   body: JSON.stringify({
143 143   vote: vote,
144 - doc: XWiki.currentDocument.space,
145 - id: "test",
149 + doc: XWiki.currentDocument.space + ".WebHome",
150 + id: rid,
146 146   form_token: document.documentElement.getAttribute("data-xwiki-form-token")
147 147   })
148 148   }).then(data => {
... ... @@ -149,6 +149,5 @@
149 149   console.log(data.json())
150 150   });
151 151   }
152 - setVote(4)
153 153  </script>
154 154  {{/html}}