I have a randomized Vignette (Text+picture), written in HTML-Code and
I want the randomised Vignette to be seen through the whole survey,
via a hover-over button or a drop down.
The first part, the randomizing and the selection and display of a random vignette WORKS!
With this code:
if (value('VI04') == 1) {
text('VI02');
} elseif (value('VI04') == 2) {
text('VI05');
} elseif (value('VI04') == 3) {
text('VI06');
} elseif (value('VI04') == 4) {
text('VI07');}
Now I want to use the same php code again later in the survey , so
that the Vignette is being displayed again. But this time I want the
Vignette to only be shown in a small window, or via a hover-over or
drop down button. I have the following php code, which i want to use
in my questionnaire, but it says, I am not allowed to use it?!
The Warning Message, that I get:
Warning: The PHP code contains functions or PHP elements that have not been released for use in the questionnaire. If you are of the opinion that the criticised constructs are harmless, please contact the administrator!
<?php // PHP-Block öffnen (nicht schließen, damit SoSciSurvey nicht meckert)
// 1. Zufallsgruppe auslesen $gruppe = value('VI04'); ?>
<style> /* Container anfangs verstecken */ #toggle-content {
display: none;
border: 1px solid #ccc;
padding: 10px;
margin-top: 10px; } </style>
<!-- Button zum Ausklappen --> <button type="button" id="toggle-btn">Vignette anzeigen</button>
<!-- Hier wird je nach Gruppe dein bereits existierender PHP-Code ausgegeben --> <div id="toggle-content"> <?php // 2. Dein existierender Code: if ($gruppe == 1) {
text('VI02'); } elseif ($gruppe == 2) {
text('VI05'); } elseif ($gruppe == 3) {
text('VI06'); } elseif ($gruppe == 4) {
text('VI07'); } ?> </div>
<script> // Klick-Logik für den Button const toggleBtn = document.getElementById('toggle-btn'); const toggleContent = document.getElementById('toggle-content');
toggleBtn.addEventListener('click', () => {
if (toggleContent.style.display === 'none') {
toggleContent.style.display = 'block';
toggleBtn.textContent = 'Vignette ausblenden';
} else {
toggleContent.style.display = 'none';
toggleBtn.textContent = 'Vignette anzeigen';
} }); </script>