File upload not working for conditional question type.
zjevik opened this issue · 7 comments
File upload is not actually uploading a file if the question is "conditional" type. See the Question ID 630580 in MyOpenMath.
The uploaded file is not displayed nor can it be used for calculating the answer.
Hmm. Yeah, Conditional questions don't execute the scoring code for the individual question types, and the actual file upload processing happens in the File type scoring code.
FWIW, even if the file was uploaded, there isn't anything you could do with it in your question code for scoring purposes.
I'll look into it, but I don't think there's an easy fix for this.
Followup: I might be able to get file uploads processed for Conditional, but the processing would happen after the question code is executed (which is the usual place question parts get processed), so you still wouldn't be able to use anything about the file in the Conditional scoring. Would that still be useful?
Hmm, processing the file after scoring is not ideal.
I would just update the documentation to indicate this.
Out of curiosity, what where you hoping/imagining you'd be able to do with a file upload in a Conditional question? Even if the upload was processed before the question code evaluation, the most you'd have access to is the file name.
I wanted to have a two part question with textarea and file upload. Students would get 100% if they wrote something in the textarea or uploaded file.
This can be done as multipart question but then students would get 100% only if they do both. I reworded the question to avoid this but it would be nice if you could give student 100% for either. Let me know if you know a way to do this.
Also, I discovered that if one has multipart question with file upload part then you cannot use $scoremethod
for the file upload part and the multipart questions. It's unfortunate that the variable names are the same - but then I understand it from system design perspective.
Gotcha. In theory this should work as a Multipart question, since stuanswers does get populated for essay questions:
$anstypes = "essay,file"
$scoremethod[0] = "takeanything"
$scoremethod[1] = "takeanything"
$answeights = "1,0"
$answeights = "0,1" if ($stuanswers[$thisq][0] == '')
$scoremethod['whole'] = "singlescore"
Also, I discovered that if one has multipart question with file upload part then you cannot use $scoremethod for the file upload part and the multipart questions.
You can, as I used it above. As described in the help file for multipart questions:
If you need to specify per-part indexed scoremethod values as well, you can define this as the array value $scoremethod['whole'] instead.
Thanks! I was working on it yesterday evening and totally missed the 'whole' parameter so I couldn't make it work.