Skip to content

Commit

Permalink
Update test after tox fix
Browse files Browse the repository at this point in the history
  • Loading branch information
caseylitton committed Jan 18, 2017
1 parent 496e4dc commit 94797a8
Show file tree
Hide file tree
Showing 16 changed files with 821 additions and 476 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules/
*.pyc
*.sw[op]
.coverage
coverage.xml
.tox/
31 changes: 16 additions & 15 deletions freetextresponse/freetextresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os

import pkg_resources
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from enum import Enum
from xblock.core import XBlock
Expand Down Expand Up @@ -36,10 +35,14 @@ def workbench_scenarios():
('Free-text Response XBlock',
'''<sequence_demo>
<freetextresponse />
<freetextresponse name='My First XBlock' />
<freetextresponse
display_name="Full Credit is asdf, half is fdsa"
fullcredit_keyphrases="['asdf']"
halfcredit_keyphrases="['fdsa']"
min_word_count="2"
max_word_count="2"
max_attempts="5"
/>
<freetextresponse
display_name="Min words 2"
Expand All @@ -52,6 +55,7 @@ def workbench_scenarios():
<freetextresponse
display_name="Full credit is asdf, Max Attempts 3"
max_attempts="3"
min_word_count="2"
fullcredit_keyphrases="['asdf']"
/>
<freetextresponse
Expand Down Expand Up @@ -246,7 +250,7 @@ def _generate_validation_message(cls, msg):
"""
result = ValidationMessage(
ValidationMessage.ERROR,
_(msg)
_(unicode(msg))
)
return result

Expand All @@ -264,11 +268,6 @@ def validate_field_data(self, validation, data):
'Maximum Attempts cannot be negative'
)
validation.add(msg)
if data.max_word_count < 0:
msg = FreeTextResponse._generate_validation_message(
'Maximum Word Count cannot be negative'
)
validation.add(msg)
if data.min_word_count < 1:
msg = FreeTextResponse._generate_validation_message(
'Minimum Word Count cannot be less than 1'
Expand Down Expand Up @@ -340,7 +339,7 @@ def _get_indicator_visibility_class(self):
result = 'hidden'
return result

def _get_word_count_message(self, ignore_attempts=False):
def _get_word_count_message(self):
"""
Returns the word count message
"""
Expand All @@ -365,8 +364,9 @@ def _get_invalid_word_count_message(self, ignore_attempts=False):
(ignore_attempts or self.count_attempts > 0) and
(not self._word_count_valid())
):
word_count_message = self._get_word_count_message(ignore_attempts=ignore_attempts)
result = _("Invalid Word Count. {word_count_message}"
word_count_message = self._get_word_count_message()
result = _(
"Invalid Word Count. {word_count_message}"
).format(
word_count_message=word_count_message,
)
Expand Down Expand Up @@ -428,7 +428,8 @@ def _get_problem_progress(self):
)
else:
scaled_score = self.score * self.weight
score_string = '{0:g}'.format(scaled_score)
# No trailing zero and no scientific notation
score_string = ('%.15f' % scaled_score).rstrip('0').rstrip('.')
result = "({})".format(
ungettext(
"{score_string}/{weight} point",
Expand Down Expand Up @@ -540,9 +541,10 @@ def submit(self, data, suffix=''):
# down on the previous sumbisson
if self.max_attempts == 0 or self.count_attempts < self.max_attempts:
self.student_answer = data['student_answer']
if self._word_count_valid():
self.count_attempts += 1
self._compute_score()
# Counting the attempts and publishing a score
# even if word count is invalid.
self.count_attempts += 1
self._compute_score()
result = {
'status': 'success',
'problem_progress': self._get_problem_progress(),
Expand Down Expand Up @@ -570,7 +572,6 @@ def save_reponse(self, data, suffix=''):
result = {
'status': 'success',
'problem_progress': self._get_problem_progress(),
'indicator_class': self._get_indicator_class(),
'used_attempts_feedback': self._get_used_attempts_feedback(),
'nodisplay_class': self._get_nodisplay_class(),
'submitted_message': '',
Expand Down
1 change: 1 addition & 0 deletions freetextresponse/public/view.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.freetextresponse {


.user_input {

.status {
Expand Down
2 changes: 1 addition & 1 deletion freetextresponse/public/view.less.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 94797a8

Please sign in to comment.