Änderungen von Dokument Sandbox

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

Von Version 20.1
bearbeitet von Holger Engels
am 2023/11/13 21:38
Ä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,17 +133,18 @@
133 133  {{html clean="false"}}
134 134  <script>
135 135   function rated() {
139 + console.log(XWiki.currentDocument.space + ".WebHome")
136 136   console.log(this.getAttribute("rating"));
137 - sendRate(parseInt(this.getAttribute("rating")));
141 + sendRate(this.getAttribute("rid"), parseInt(this.getAttribute("rating")));
138 138   }
139 - var sendRate = function (vote) {
143 + var sendRate = function (rid, vote) {
140 140   fetch(new XWiki.Document('WebHome', 'Macros.Aufgabenbewertung').getURL('get') + "?outputSyntax=plain", {
141 141   method: "POST",
142 142   headers: { "Content-Type": "application/json"},
143 143   body: JSON.stringify({
144 144   vote: vote,
145 - doc: XWiki.currentDocument.space,
146 - id: "test",
149 + doc: XWiki.currentDocument.space + ".WebHome",
150 + id: rid,
147 147   form_token: document.documentElement.getAttribute("data-xwiki-form-token")
148 148   })
149 149   }).then(data => {