diff --git a/classes/output/sort_voting_form.php b/classes/output/sort_voting_form.php
index 55aaf0d..2aa81a8 100644
--- a/classes/output/sort_voting_form.php
+++ b/classes/output/sort_voting_form.php
@@ -83,6 +83,7 @@ public function export_for_template(renderer_base $output): array {
return [
'sortvotingid' => $this->sortvoting->id,
'allowupdate' => $allowupdate,
+ 'alreadyvoted' => count($existingvotes) > 0,
'options' => $optionsclean,
'max' => count($options),
];
diff --git a/templates/sort_voting_form.mustache b/templates/sort_voting_form.mustache
index a9c2e9b..65ac8cc 100644
--- a/templates/sort_voting_form.mustache
+++ b/templates/sort_voting_form.mustache
@@ -73,7 +73,10 @@
{{#allowupdate}}
-
+
{{#js}}
require(['mod_sortvoting/sortvoting'], function(sortvoting) {
sortvoting.init();