--- a/OSSEval/static/js/osseval.js
+++ b/OSSEval/static/js/osseval.js
@@ -33,9 +33,21 @@
console.log("update_metadata_error: " + data.response);
}
var update_metadata_success = function(data, textStatus, jqXHR) {
- answers=eval(data);
- for (i=0;i<answers.length;i++) {
- $('div#MetadataInfo' + data[i].question_id).html('...TBC');
+ 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
+ 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>'
+ }
+ $('div#MetadataInfo' + data[i].question_id).html(m[i].description);
}
}
@@ -43,7 +55,7 @@
//<div id="MetadataInfo{{ q.id }}">
$.ajax({
type: 'GET',
- url: 'get_answers',
+ url: 'get_metadata',
dataType: 'json',
success: update_metadata_success,
error: update_metadata_error,