Hallo,
ich habe Deinen Prototype nur einmal schnell geöffnet.
1. In der Matrixfrage ist das javascript-snippet ja gar nicht enthalten.
Das ist aber sicher in der Beispielstudie, die ich verlinkt habe, drin.
Denn das ist schließlich die Hauptsache.
2. Das hast Du geschrieben:
Ich habe bspw. in einer Teilfrage die Gleichung drin: F0==1 or F0==2
Aber dies ist in Deiner Studie
F0==A1 or F0==A2
Also etwas anderes.
Und das kann auch nicht funktionieren; im ersten Fall vergleichst Du mit Zahlen, "A1" und "A2" sind aber keine Zahlen, sondern Texte; also müssen sie mit Anführungszeichen versehen werden.
F0=="A1" or F0=="A2".
Daher plädiere ich immer dafür , diese default-Codes "A1", "A2", ... durch numerische Codes zu ersetzen.
Erleichtert die Auswertung später ungemein.
Denn Zahlen werden numerisch verglichen, also 1<2<10<21,
Texte aber alphabetisch, also "1"<"10"<"2"<"21"
Das javascript mache ich Dir dann später einmal hinein.
Bin etwas knapp mit der Zeit im Moment.
Joffm
Eigentlich kannst Du das auch selbst machen.
Hier noch einmal das script. Im Quelltext-Modus in den Fragetext der Matrix-Frage:
Code:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// Identify the questions
var thisQuestion = $('#question'+{QID}+'');
var nextQuestion1 = $(thisQuestion).nextAll('.text-short:eq(0)');
var nextQuestion2 = $(thisQuestion).nextAll('.text-short:eq(1)');
var nextQuestion3 = $(thisQuestion).nextAll('.text-short:eq(2)');
var nextQuestions = $(nextQuestion1).add(nextQuestion2).add(nextQuestion3);
// var nextQuestions = $(nextQuestion1);
var nextLength = nextQuestions.length;
var sqLength = ('tr.answers-list', thisQuestion).length;
// Hide the short-text questions
$(nextQuestions).hide();
// Move the hidden text inputs into the array
for (i = 0; i < nextLength; i++) {
var workingIndex = (sqLength - 1) - (nextLength - i);
var nextQ = nextQuestions[i];
$('th.answertext:eq('+workingIndex+')', thisQuestion).append($('input[type="text"]', nextQ)).closest('tr').addClass('otherRow');
}
// Some styling...
$('input[type="text"]', thisQuestion).css({
'width': '50%'
});
// Handle the "Other" radios
$('input[type="text"]', thisQuestion).on('keyup change',function(event){
event.stopPropagation();
var thisRow = $(this).closest('tr.answers-list');
if($.trim($(this).val()) == '') {
$('input:radio[value!=""]', thisRow).prop('checked',false);
$('input:radio[value=""]', thisRow).click();
}
else {
$('input:radio[value=""]', thisRow).prop('checked',false);
}
});
// Handle the "Other" text inputs
$('.otherRow input.radio', thisQuestion).on('click',function(event){
var thisRow = $(this).closest('tr.answers-list');
if($(this).attr('value') == '') {
$('input[type="text"]', thisRow).val('');
}
});
// Validate the "Other" text inputs on submit
if($('#movenextbtn, #movesubmitbtn').attr('data-inserted-other') != 'true') { // We're only doing this once on this page
$('#movenextbtn, #movesubmitbtn').attr('data-inserted-other', 'true').on('click.insertedOther', function (event) {
var otherError = 0;
$('.array-flexible-row .otherRow').each(function(i) {
if(($('input:radio[value!=""]:checked', this).length > 0 && $('input[type="text"]', this).val() == '') || ($('input:radio[value!=""]:checked', this).length == 0 && $('input[type="text"]', this).val() != '')) {
otherError = 1;
}
});
if(otherError == 1) {
alert('Please review your answer in the "Other" row(s).');
return false;
}
});
}
});
</script>
Und wenn Du dann noch ein bisschen css einbaust, sind die Items auch linklsbündig; sieht m.E. besser aus.
Code:
<style>
.ls-answers tbody .answertext {
text-align: left;
}
</style>