Parent: [7f6519] (diff)

Child: [77df3f] (diff)

Download this file

osseval.js    74 lines (69 with data), 2.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
var id_selected_instance=0;
$(document).ready(function () {
$('legend').click(function () {
var $this = $(this);
var parent = $this.parent();
var contents = parent.contents().not(this);
if (contents.length > 0) {
$this.data("contents", contents.remove());
} else {
$this.data("contents").appendTo(parent);
}
});
$('legend').css( 'cursor', 'pointer' );
});
var update_answers_error = function(data, textStatus, jqXHR) {
console.log("update_answers_error: " + data.response);
}
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#notes' + data[i].question_id).prop('value', data[i].notes);
}
}
function updateAnswers(id_selected_instance) {
// First I clear them all
$('input.radioquestion').prop('checked', false);
$('input.questionnotes').prop('value', '');
$.ajax({
type: 'GET',
url: 'get_answers',
dataType: 'json',
success: update_answers_success,
error: update_answers_error,
data: {id_instance: id_selected_instance }
});
}
var update_metadata_error = function(data, textStatus, jqXHR) {
console.log("update_metadata_error: " + data.response);
}
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
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);
}
}
function updateMetadata(id_selected_instance) {
//<div id="MetadataInfo{{ q.id }}">
$.ajax({
type: 'GET',
url: 'get_metadata',
dataType: 'json',
success: update_metadata_success,
error: update_metadata_error,
data: {id_instance: id_selected_instance }
});
}