Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Translate category and answer in result view

  • Loading branch information...
commit 6200cfccd3c02a20b1732d2882c8d9de1bcacb54 1 parent 0b76ea1
@alexanderteinum alexanderteinum authored
View
20 backend/locale/en.json
@@ -101,6 +101,18 @@
null,
"Category"
],
+ "result_category_pass": [
+ null,
+ "Pass"
+ ],
+ "result_category_fail": [
+ null,
+ "Fail"
+ ],
+ "result_category_verify": [
+ null,
+ "Verify"
+ ],
"result_line": [
null,
"Line"
@@ -125,14 +137,6 @@
null,
"Answer"
],
- "result_answer_pass": [
- null,
- "Pass"
- ],
- "result_answer_fail": [
- null,
- "Fail"
- ],
"result_answer_auto": [
null,
"Auto"
View
15 backend/locale/en.po
@@ -78,6 +78,15 @@ msgstr "Hide automated checker results"
msgid "result_category"
msgstr "Category"
+msgid "result_category_pass"
+msgstr "Pass"
+
+msgid "result_category_fail"
+msgstr "Fail"
+
+msgid "result_category_verify"
+msgstr "Verify"
+
msgid "result_line"
msgstr "Line"
@@ -96,12 +105,6 @@ msgstr "Test title"
msgid "result_answer"
msgstr "Answer"
-msgid "result_answer_pass"
-msgstr "Pass"
-
-msgid "result_answer_fail"
-msgstr "Fail"
-
msgid "result_answer_auto"
msgstr "Auto"
View
20 backend/locale/no.json
@@ -109,6 +109,18 @@
null,
"Kategori"
],
+ "result_category_pass": [
+ null,
+ "Passert"
+ ],
+ "result_category_fail": [
+ null,
+ "Feilet"
+ ],
+ "result_category_verify": [
+ null,
+ "Verifisere"
+ ],
"result_line": [
null,
"Linje"
@@ -133,13 +145,9 @@
null,
"Svar"
],
- "result_answer_pass": [
- null,
- "Passert"
- ],
- "result_answer_fail": [
+ "result_answer_auto": [
null,
- "Feil"
+ "Auto"
],
"question_SC4.1.2-2-11": [
null,
View
16 backend/locale/no.po
@@ -84,6 +84,15 @@ msgstr "Skjul automatisk sjekkresultater"
msgid "result_category"
msgstr "Kategori"
+msgid "result_category_pass"
+msgstr "Passert"
+
+msgid "result_category_fail"
+msgstr "Feilet"
+
+msgid "result_category_verify"
+msgstr "Verifisere"
+
msgid "result_line"
msgstr "Linje"
@@ -102,14 +111,9 @@ msgstr "Testtittel"
msgid "result_answer"
msgstr "Svar"
-msgid "result_answer_pass"
-msgstr "Passert"
-
-msgid "result_answer_fail"
-msgstr "Feil"
-
msgid "result_answer_auto"
msgstr "Auto"
+
# The following are not implemented
msgid "question_SC2.4.4-1-11"
msgstr "Please check the link text of the [el]area[/el]";"<p>Human input is necessary to verify, that the alternative text of the <samp>area</samp> serves the same purpose as the selectable area of the image.</p>"
View
4 frontend/index.html
@@ -99,13 +99,13 @@
<tbody>
<% _.each(tests, function(test) { %>
<tr class="<%= test.category %> <%= test.dimClass %>">
- <td class="category"><%= test.categoryCapitalized %></td>
+ <td class="category"><%= test._category %></td>
<td><%= test.line %></td>
<td><%= test.column %></td>
<td><%= test.testId %></td>
<td><%= test.testResultId %></td>
<td><%= test.testTitle %></td>
- <td><%= test.answer %></td>
+ <td><%= test._answer %></td>
</tr>
<% }); %>
</tbody>
View
3  frontend/models/test-run.coffee
@@ -2,9 +2,9 @@ define ['backbone', 'socketio', 'collections/tests'], (Backbone, io, Tests) ->
Backbone.Model.extend {
defaults: {
'webPage': 'http://www.tingtun.no/'
- 'currentTest': 0
'state': 'loading'
'tests': []
+ 'currentTest': 0
}
initialize: (socket) ->
_.extend(this, Backbone.Events)
@@ -46,6 +46,7 @@ define ['backbone', 'socketio', 'collections/tests'], (Backbone, io, Tests) ->
this.get('currentTest') == 0
setAnswer: (answer) ->
this.verifyTests()[this.get('currentTest')].set('answer', answer)
+ this.trigger 'change:answer'
setWebPage: (url) ->
addProtocol = (url) ->
if url.substring(0, 7) isnt 'http://' and url.substring(0, 8) isnt 'https://'
View
7 frontend/models/test-run.js
@@ -4,9 +4,9 @@
return Backbone.Model.extend({
defaults: {
'webPage': 'http://www.tingtun.no/',
- 'currentTest': 0,
'state': 'loading',
- 'tests': []
+ 'tests': [],
+ 'currentTest': 0
},
initialize: function(socket) {
var that;
@@ -60,7 +60,8 @@
return this.get('currentTest') === 0;
},
setAnswer: function(answer) {
- return this.verifyTests()[this.get('currentTest')].set('answer', answer);
+ this.verifyTests()[this.get('currentTest')].set('answer', answer);
+ return this.trigger('change:answer');
},
setWebPage: function(url) {
var addProtocol;
View
59 frontend/views/result.coffee
@@ -16,41 +16,21 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
@options.locale.on('change:locale', @render , this)
@options.testRun.bind('change:state', @render, this)
- shouldHideAutomatedCheckerResults: () ->
- document.getElementById('hideAutomatedCheckerResults') == null or $('#hideAutomatedCheckerResults').is(':checked')
- transformResult: (result, verifyIndex, verifyCount, that) ->
- if result.line == 0
- result.line = ''
- if result.column == 0
- result.column = ''
- if result.category != 'verify'
- result.answer = '<em>Auto</em>'
-
- if that.shouldHideAutomatedCheckerResults()
- result.dimClass = 'dim'
- else
- result.dimClass = ''
- if result.category == 'verify' and verifyIndex < verifyCount
- result.testTitle = '<a href="' + window.location.href.split('#')[0] + '#test/' + verifyIndex + '">' + result.testTitle + '</a>'
-
- result.categoryCapitalized = result.category.charAt(0).toUpperCase() + result.category.slice(1)
-
- result
+ @options.testRun.on('change:answer', @render, this)
render: () ->
- that = this
-
if @options.testRun.get('state') == 'error'
@$el.html(_.template($('#result-template-error').html(), { webPage: @options.testRun.get('webPage') }))
else if @options.testRun.get('state') == 'loading'
@$el.html(_.template($('#result-template-loading').html(), { webPage: @options.testRun.get('webPage') }))
else
+ that = this
results = []
- verifyIndex = 0
+ testIndex = 0
_.each(@options.testRun.get('tests').models, (element, index, list) ->
- results.push(that.transformResult(element.attributes, verifyIndex, that.options.testRun.testCount(), that))
+ results.push(that.transformResult(element.attributes, testIndex, that.options.testRun.testCount(), that))
if element.attributes.category == 'verify'
- verifyIndex++
+ testIndex++
)
checked = ''
@@ -69,10 +49,35 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
_testResultId: @options.locale.translate('result_test_result_id'),
_testTitle: @options.locale.translate('result_test_title'),
_answer: @options.locale.translate('result_answer'),
- _answer_pass: @options.locale.translate('result_answer_pass'),
- _answer_fail: @options.locale.translate('result_answer_fail'),
_answer_auto: @options.locale.translate('result_answer_auto')
}))
+ transformResult: (result, testIndex, testCount, that) ->
+ if result.line == 0
+ result.line = ''
+ if result.column == 0
+ result.column = ''
+ if result.category != 'verify'
+ result._answer = @options.locale.translate('result_answer_auto')
+
+ if that.shouldHideAutomatedCheckerResults()
+ result.dimClass = 'dim'
+ else
+ result.dimClass = ''
+ else
+ if not result.answer
+ result._answer = ''
+ else
+ result._answer = @options.locale.translate('test_answer_' + result.answer)
+
+
+ if result.category == 'verify' and testIndex < testCount
+ result.testTitle = '<a href="' + window.location.href.split('#')[0] + '#test/' + testIndex + '">' + result.testTitle + '</a>'
+
+ result._category = @options.locale.translate('result_category_' + result.category)
+
+ result
+ shouldHideAutomatedCheckerResults: () ->
+ document.getElementById('hideAutomatedCheckerResults') == null or $('#hideAutomatedCheckerResults').is(':checked')
clickDim: (el) ->
@render()
}
View
69 frontend/views/result.js
@@ -16,36 +16,12 @@
}
}, this);
this.options.locale.on('change:locale', this.render, this);
- return this.options.testRun.bind('change:state', this.render, this);
- },
- shouldHideAutomatedCheckerResults: function() {
- return document.getElementById('hideAutomatedCheckerResults') === null || $('#hideAutomatedCheckerResults').is(':checked');
- },
- transformResult: function(result, verifyIndex, verifyCount, that) {
- if (result.line === 0) {
- result.line = '';
- }
- if (result.column === 0) {
- result.column = '';
- }
- if (result.category !== 'verify') {
- result.answer = '<em>Auto</em>';
- if (that.shouldHideAutomatedCheckerResults()) {
- result.dimClass = 'dim';
- } else {
- result.dimClass = '';
- }
- }
- if (result.category === 'verify' && verifyIndex < verifyCount) {
- result.testTitle = '<a href="' + window.location.href.split('#')[0] + '#test/' + verifyIndex + '">' + result.testTitle + '</a>';
- }
- result.categoryCapitalized = result.category.charAt(0).toUpperCase() + result.category.slice(1);
- return result;
+ this.options.testRun.bind('change:state', this.render, this);
+ return this.options.testRun.on('change:answer', this.render, this);
},
render: function() {
- var checked, results, that, verifyIndex;
+ var checked, results, testIndex, that;
- that = this;
if (this.options.testRun.get('state') === 'error') {
return this.$el.html(_.template($('#result-template-error').html(), {
webPage: this.options.testRun.get('webPage')
@@ -55,12 +31,13 @@
webPage: this.options.testRun.get('webPage')
}));
} else {
+ that = this;
results = [];
- verifyIndex = 0;
+ testIndex = 0;
_.each(this.options.testRun.get('tests').models, function(element, index, list) {
- results.push(that.transformResult(element.attributes, verifyIndex, that.options.testRun.testCount(), that));
+ results.push(that.transformResult(element.attributes, testIndex, that.options.testRun.testCount(), that));
if (element.attributes.category === 'verify') {
- return verifyIndex++;
+ return testIndex++;
}
});
checked = '';
@@ -79,12 +56,40 @@
_testResultId: this.options.locale.translate('result_test_result_id'),
_testTitle: this.options.locale.translate('result_test_title'),
_answer: this.options.locale.translate('result_answer'),
- _answer_pass: this.options.locale.translate('result_answer_pass'),
- _answer_fail: this.options.locale.translate('result_answer_fail'),
_answer_auto: this.options.locale.translate('result_answer_auto')
}));
}
},
+ transformResult: function(result, testIndex, testCount, that) {
+ if (result.line === 0) {
+ result.line = '';
+ }
+ if (result.column === 0) {
+ result.column = '';
+ }
+ if (result.category !== 'verify') {
+ result._answer = this.options.locale.translate('result_answer_auto');
+ if (that.shouldHideAutomatedCheckerResults()) {
+ result.dimClass = 'dim';
+ } else {
+ result.dimClass = '';
+ }
+ } else {
+ if (!result.answer) {
+ result._answer = '';
+ } else {
+ result._answer = this.options.locale.translate('test_answer_' + result.answer);
+ }
+ }
+ if (result.category === 'verify' && testIndex < testCount) {
+ result.testTitle = '<a href="' + window.location.href.split('#')[0] + '#test/' + testIndex + '">' + result.testTitle + '</a>';
+ }
+ result._category = this.options.locale.translate('result_category_' + result.category);
+ return result;
+ },
+ shouldHideAutomatedCheckerResults: function() {
+ return document.getElementById('hideAutomatedCheckerResults') === null || $('#hideAutomatedCheckerResults').is(':checked');
+ },
clickDim: function(el) {
return this.render();
}
View
1  frontend/views/test.coffee
@@ -64,7 +64,6 @@ define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
else
return '#test/' + (@options.testRun.get('currentTest') + 1)
clickAnswer: (el) ->
- console.log el.currentTarget.value
@options.testRun.setAnswer(el.currentTarget.value)
if (@options.testRun.isAtLast() == true)
return '#result'
View
1  frontend/views/test.js
@@ -87,7 +87,6 @@
}
},
clickAnswer: function(el) {
- console.log(el.currentTarget.value);
this.options.testRun.setAnswer(el.currentTarget.value);
if (this.options.testRun.isAtLast() === true) {
return '#result';
Please sign in to comment.
Something went wrong with that request. Please try again.