--- a/OSSEval/static/js/osseval.js
+++ b/OSSEval/static/js/osseval.js
@@ -33,7 +33,7 @@
var update_answers_success = function(data, textStatus, jqXHR) {
answers=eval(data);
for (i=0;i<answers.length;i++) {
- $('input#question' + data[i].question_id + "_" + data[i].value_integer).prop('checked', true);
+ $('input#choice' + data[i].choice_id).prop('checked', true);
$('input#notes' + data[i].question_id).prop('value', data[i].notes);
}
}
@@ -58,24 +58,31 @@
var update_metadata_success = function(data, textStatus, jqXHR) {
m=eval(data);
for (i=0;i<m.length;i++) {
- s='input#question'+m[i].question_id+'_';
- if (m[i].value > 0)
- if (!($(s+'1').prop('checked')) && !($(s+'2').prop('checked')) && !($(s+'3').prop('checked'))) { //if no value has been set yet
- $(s+m[i].value).prop('checked', true); //I set it according to the suggested value
- $(s+m[i].value).trigger("click");//I force a click to save the data
- m[i].description += " <b><font color=red>(Value automatically selected)</font></b>"
- } else { //at least one was already selected
- if ($(s+m[i].value).prop('checked')) //it's the one I would automatically suggest
+ if (m[i].choice_id > 0) { //there is an automatic answer
+ already_checked = false
+ rq = $('[name="radioquestion'+m[i].question_id+'"]')
+ // Is there one radio already selected?
+ for (j=0;j<rq.length;j++) {
+ already_checked = already_checked || $('input#'+rq[j].id).prop('checked')
+ }
+ if (already_checked) { //at least one was already selected
+ if ($('input#choice'+m[i].choice_id).prop('checked')) //it's the one I would automatically suggest
m[i].description += " <b>(Value automatically selected)</b>"
else //I write in the description that I have an automatic suggestion
- m[i].description += ' <b><font color=red>(Value automatically suggested: "'+$(s+m[i].value).parent().text()+'")</font></b>'
+ m[i].description += ' <b><font color=red>(Value automatically suggested: "'+$('input#choice'+m[i].choice_id).parent().text()+'")</font></b>'
+ } else { //if no value has been set yet
+ $('input#choice'+m[i].choice_id).prop('checked', true); //I set it according to the suggested value
+ $('input#choice'+m[i].choice_id).trigger("click");//I force a click to save the data
+ m[i].description += " <b><font color=red>(Value automatically selected)</font></b>"
}
+ }
$('div#MetadataInfo' + data[i].question_id).html(m[i].description);
}
}
function updateMetadata(id_selected_instance) {
//<div id="MetadataInfo{{ q.id }}">
+ $("div[id*='MetadataInfo']").html("<img src='/static/images/wait1.gif'/>")
$.ajax({
type: 'GET',
url: 'get_metadata',