in project/paperbench/paperbench/gui/static/script.js [247:280]
function updateScore(taskId) {
var newScore = document.getElementById('score-' + taskId).innerText.trim();
// Convert to float and validate
newScore = parseFloat(newScore);
if (isNaN(newScore) || newScore < 0 || newScore > 1) {
alert('Score must be a number between 0 and 1.');
location.reload(); // Reload to reset the displayed score
return;
}
fetch('/update_score', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ 'node_id': taskId, 'score': newScore }),
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
console.log('Score updated for node', taskId);
location.reload(); // Reload the page to show updated scores
} else {
console.error('Error updating score:', data.message);
alert('Failed to update score: ' + data.message);
location.reload(); // Reload to reset the displayed score
}
})
.catch(error => {
console.error('Error updating score:', error);
alert('Failed to update score. Please try again.');
location.reload(); // Reload to reset the displayed score
});
}