Skip to content

Commit 852c567

Browse files
committed
Support Scale100 in SQM non-pairwise campaigns
1 parent 5cd1e38 commit 852c567

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

EvalView/templates/EvalView/direct-assessment-document.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,12 @@
118118
var ENABLE_UNRESTRICTED_ANNOTATION = true;
119119

120120
var scalarSliderEnabled = {{ scalar_slider|yesno:"true,false" }};
121+
var scale100 = {{ scale_100|yesno:"true,false" }};
121122
var scalarSliderOptions = {
122123
enabled: scalarSliderEnabled,
123-
valueCount: 10,
124-
min: 0,
125-
max: 100
124+
valueCount: scale100 ? 101 : 10,
125+
min: scale100 ? 0 : 0,
126+
max: scale100 ? 100 : 100
126127
};
127128
var scalarSliderRegistry = {};
128129
var collectBrowserInfo = {{ collect_browser_info|yesno:"true,false" }};
@@ -688,7 +689,7 @@
688689
var score = item_box.find('input[name="score"]').val();
689690
var index = item_box.data('item-id');
690691
if (score == -1) {
691-
alert('Sentence #' + (index + 1) + ' has no score. ' +
692+
_show_error_box(item_box, 'Sentence #' + (index + 1) + ' has no score. ' +
692693
'Please score all candidate sentences. Thanks!');
693694
return false;
694695
}
@@ -807,13 +808,13 @@
807808
var score = item_box.find('input[name="score"]').val();
808809
var index = item_box.data('item-id');
809810
if (score == -1) {
810-
alert('Please score the document translation. Thanks!');
811+
_show_error_box(item_box, 'Please score the document translation. Thanks!');
811812
return false;
812813
}
813814
// It is a security check, but this should never occur, because the last
814815
// item is disabled if there is at least one sentence that is not scored
815816
if (!_all_sentences_scored()) {
816-
alert('Please score all sentences from the document first. Thanks!');
817+
_show_error_box(item_box, 'Please score all sentences from the document first. Thanks!');
817818
return false;
818819
}
819820
// Add end timestamp
@@ -882,13 +883,18 @@
882883
}
883884

884885
function _show_error_box(item_box, msg) {
886+
// Remove any existing error boxes to prevent stacking
887+
$('.alert-danger.alert-dismissible.appraise-error').remove();
885888
// A hideable error box with a custom message displayed right above the item box
886-
item_box.before(
887-
'<div class="alert alert-danger alert-dismissible" role="alert">' +
889+
var $box = $(
890+
'<div class="alert alert-danger alert-dismissible appraise-error" role="alert">' +
888891
'<button type="button" class="close" data-dismiss="alert" aria-label="Close">' +
889892
'<span aria-hidden="true">&times;</span>' +
890893
'</button>Oops... ' + msg + '</div>'
891894
);
895+
item_box.before($box);
896+
// Auto-fade after 3 seconds
897+
setTimeout(function() { $box.fadeOut(700, function() { $box.remove(); }); }, 3000);
892898
}
893899

894900
function _has_single_sentence_document() {
@@ -1173,7 +1179,7 @@
11731179

11741180
<div class="col-sm-10">
11751181
{% if scalar_slider %}
1176-
{% with sliderid=item.itemID mono=monolingual %}
1182+
{% with sliderid=item.itemID mono=monolingual scale_100=scale_100 %}
11771183
{% include 'EvalView/_scalar_slider.html' %}
11781184
{% endwith %}
11791185
{% elif sqm %}
@@ -1223,7 +1229,7 @@
12231229
<div class="row">
12241230
<div class="col-sm-12">
12251231
{% if scalar_slider %}
1226-
{% with sliderid=item.itemID mono=monolingual %}
1232+
{% with sliderid=item.itemID mono=monolingual scale_100=scale_100 %}
12271233
{% include 'EvalView/_scalar_slider.html' %}
12281234
{% endwith %}
12291235
{% elif sqm %}

EvalView/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ def direct_assessment_document(request, code=None, campaign_name=None):
865865
speech_translation = 'speechtranslation' in campaign_opts
866866
static_context = 'staticcontext' in campaign_opts
867867
use_sqm = 'sqm' in campaign_opts
868+
scale_100 = 'scale100' in campaign_opts
868869
ui_language = 'enu'
869870
doc_guidelines = 'doclvlguideline' in campaign_opts
870871

@@ -1046,7 +1047,8 @@ def direct_assessment_document(request, code=None, campaign_name=None):
10461047
'static_context': static_context,
10471048
'sqm': use_sqm,
10481049
'ui_lang': ui_language,
1049-
'scalar_slider': 'scalarslider' in campaign_opts,
1050+
'scalar_slider': 'scalarslider' in campaign_opts or scale_100,
1051+
'scale_100': scale_100,
10501052
'collect_browser_info': 'collectbrowserinfo' in campaign_opts,
10511053
'disable_mobile': 'disablemobile' in campaign_opts,
10521054
}

0 commit comments

Comments
 (0)