Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Randomisierung einer Mehrfachantwort unter Berücksichtigung einer offenen Option

  • ms_r2w
  • ms_r2w's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #201056 by ms_r2w
Hallo,

ich versuche bereits eine ganze Weile unter Anwendung eines hier im Forum gefundenen Codes bei einer Randomisierung einer Mehrfachantwort inkl. einer offenen Antwortoption die letzten Antworten zu fixieren.
Leider funktioniert das nicht? Hatte jemand schon mal so ein Problen?

Ich nutze Version 3.17.
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question ID
    var qID = '{QID}';
 
    // List the sub-question codes to be placed at the end of the list
    // (comma-separated)
    var lastItems = ['SQ007','SQ008'];
 
    // Insert the last items
    $.each(lastItems, function(i, val) {
      $('#question{QID} tr[id^="javatbd"]:last').after($('#question{QID} tr[id^="javatbd"][id$="X'+qID+val+'"]'));
    });
  });
</script>

Die variable in lastItems habe ich angepasst, aber trotzdem ändert sich nichts. :(
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201059 by Joffm
Das es nicht funktioniert, ist nicht weiter verwunderlich.
Im script wird ja die Option "Anderes" nicht berücksichtigt.

Aber wie so oft ist das Handbuch - die Workarounds dort - Dein Freund
manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_3.x :

Screenshots damit:




Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • ms_r2w
  • ms_r2w's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #201061 by ms_r2w
Hallo Joffm,

das Script hatte ich auch schon in der Hand, letztlich das selbe Problem. Leider! :/

The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201080 by Joffm
Dann hilft nur eins:
Schicke die Frage als "lsq Export".

Ausnahmsweise einmal lsq, ansonsten wird immer ein lss Export vorgezogen.

Und was willst Du genau?
Es soll doch irgendwie so aussehen.


Mit Einstellung:
Code:
// The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Set this to "true" if you want "Other" to be fixed in the last position
    var otherFixed = false;


Mit Einstellung:
Code:
// The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Set this to "true" if you want "Other" to be fixed in the last position
    var otherFixed = false;


Du siehst, hier bleibt das "Sonstige" unter den beiden fixierten Teilfragen.


Joffm

P.S.
Da Dein Beispiel wohl hierher stammt
forums.limesurvey.org/forum/can-i-do-thi...swers?start=0#187444

jetzt noch die Frage: "Du hast aber das Recht, javascript einzufügen?"
Oder ist eventuell der XSS-Filter eingeschaltet.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The topic has been locked.
  • ms_r2w
  • ms_r2w's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #201087 by ms_r2w
Hallo Joffm,

HTML auf XSS war zuerst an und nun aus. Geändert hat sich nichts. Ich habe dir die beiden Scripte mit denen ich es versuche auf eine lsq gepackt. Ich bin für jede Idee und Ratschlag dankbar.

Ja, es soll so aussehen wie in deinem erstem Beispiel.

Antwort 2
Antwort 3
Antwort 4
Antwort 1
Sontiges, und zwar: (fix)
weiß nicht (fix)
keine Angabe (fix)
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201098 by Joffm
Hallo,
wie man es macht, ist es verkehrt.
Ich hatte ja geschrieben "ausnahmsweise lsq", da ich für mich dachte "Ist klar, die Basissprache ist ja Deutsch".
Und dann ist die Basissprache doch eine andere, nämlich "deutsch-informal" und man kann die lsq nicht importieren.

Naja, mein Fehler.

Und jetzt kommen Deine Fehler.
Welches script hast Du denn in Deine Frage 3 eingebaut?
Vergleiche einmal die beiden scripte hier:
manual.limesurvey.org/Workarounds:_Manip...urvey_version_2.73.0 :

und
manual.limesurvey.org/Workarounds:_Manip...meSurvey_version_3.x :

Du hast also wohl das script für die LS Version 2.73 eingebaut.


Außerdem steht im Handbuch in der Anleitung zum script
Create a Multiple Options or List (radio) question with sequential response codes.
Das heißt, die Codes sind "1", "2", "3", ..., nicht "SQ001", ...

Und dann geht es auch


File Attachment:

File Name: limesurvey...2493.lss
File Size:22 KB


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ms_r2w
The topic has been locked.
  • ms_r2w
  • ms_r2w's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 10 months ago #201099 by ms_r2w
Ich habe das Problem gelöst bekommen. Mit folgendem Code, auch hier im Forum gefunden, klappt es wunderbar.
Ich kann leider nicht sagen, wo die Unterschiede liegen.
Code:
<script type="text/javascript" charset="utf-8">
  $(document).on('ready pjax:scriptcomplete',function(){
 
    // Identify this question
    var qID = {QID};
    var thisQuestion = $('#question'+qID);
 
    // Define the sub-question codes to be placed last
    var lastItems = ['SQ007', 'SQ008'];
 
    // Loop through those sub-question codes 
    $.each(lastItems, function(i, val) {
      // Move that item to the end of the list
      // Multi-choice question
      if($(thisQuestion).hasClass('multiple-opt')) {
        $('.question-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.question-item[id$=X'+qID+val+']', thisQuestion).parent());
      }
      // Array question
      if($(thisQuestion).hasClass('array-flexible-row')) {
        $('.answers-list[id$=X'+qID+val+']', thisQuestion).appendTo($('table.subquestion-list tbody:last', thisQuestion));
      }
      // List-radio question
      if($(thisQuestion).hasClass('list-radio')) {
        $('.answer-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.answer-item[id$=X'+qID+val+']', thisQuestion).parent());
      }
    });  
  });
</script>
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #201102 by Joffm
Hallo,
falls es Dich wirklich interessiert-
Der Unterschied ist folgender (nur exemplarisch):
Code:
$.each(lastItems, function(i, val) {
      $('#question{QID} tr[id^="javatbd"]:last').after($('#question{QID} tr[id^="javatbd"][id$="X'+qID+val+'"]'));
    });
Code:
$.each(lastItems, function(i, val) {
        $('.question-item[id$=X'+qID+val+']', thisQuestion).appendTo($('.question-item[id$=X'+qID+val+']', thisQuestion).parent());

Im ersten Fall siehst Du ein "tr".
Dies deutet darauf hin, dass die Frage als Tabelle dargestellt wird.
Ich weiß nicht, inwieweit Du mit HTML vertraut bist, aber in HTML bedeutet "tr" den Beginn bzw. das Ende einer Tabellenzeile.

Seit der Version 2.50 beruht LimeSurvey aber auf der bootstrap-Bibliothek, und seitdem werden Fragen als Listen von Items dargestellt

Insgesamt bedeutet dies, dass das script, welches Du vorher in der Frage 2 benutzt hast, nicht für 3.x. geeignet war.

Und die Unterschiede zwischen den beiden scripten an sich?
Das, mit
Code:
// Define the sub-question codes to be placed last
    var lastItems = ['SQ008', 'SQ009'];
hat eine sehr eingängige Deklaration der ans Ende zu platzierenden Items und ist in der von Dir jetzt benutzten Version für "Einfachnennung", "Mehrfachnennung", "Arrays" gleichermaßen einsetzbar.

Dieses mit der numerischen Deklaration
Code:
// The number of answers to be fixed at the end of the list
    var fixedAnswers = 2;
 
    // Set this to "true" if you want "Other" to be fixed in the last position
    var otherFixed = false;
hat dafür das flexiblere Handling des "Sonstigen".

Aber für Dich ist ja wichtig, dass Du jetzt die Darstellung hast, die Dir vorschwebt.

Und gleichzeitig die Erkenntnis gewonnen:
Für Dich: Füge am besten immer einen lss Export an (der sollte nur die relevanten Fragen enthalten; also Studie kopieren, alles Überflüssige löschen; exportieren)
Für mich: Ich sollte Scripte bis zum Ende anschauen. Dann wäre mir schon in Deinem ersten Post das "tr" aufgefallen (hoffentlich)

Alles Gute
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: ms_r2w
The topic has been locked.
Moderators: Joffm

Lime-years ahead

Online-surveys for every purse and purpose