Commit faa8f16f by Ned Batchelder

Merge pull request #1877 from edx/ned/hotfix-2013-12-04-with-temp-stuff-removed

Update 12/3 RC branch with the part of the hotfix we want permanently.
parents 050031f7 be3ab1c5
......@@ -19,7 +19,7 @@ import uuid
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.db import models
from django.db import models, IntegrityError
from django.db.models.signals import post_save
from django.dispatch import receiver, Signal
import django.dispatch
......@@ -52,7 +52,7 @@ class AnonymousUserId(models.Model):
http://docs.python.org/2/library/md5.html#md5.digest_size
"""
user = models.ForeignKey(User, db_index=True)
anonymous_user_id = models.CharField(unique=True, max_length=16)
anonymous_user_id = models.CharField(unique=True, max_length=32)
course_id = models.CharField(db_index=True, max_length=255)
unique_together = (user, course_id)
......@@ -73,12 +73,30 @@ def anonymous_id_for_user(user, course_id):
hasher.update(settings.SECRET_KEY)
hasher.update(str(user.id))
hasher.update(course_id)
digest = hasher.hexdigest()
return AnonymousUserId.objects.get_or_create(
defaults={'anonymous_user_id': hasher.hexdigest()},
user=user,
course_id=course_id
)[0].anonymous_user_id
try:
anonymous_user_id, created = AnonymousUserId.objects.get_or_create(
defaults={'anonymous_user_id': digest},
user=user,
course_id=course_id
)
if anonymous_user_id.anonymous_user_id != digest:
log.error(
"Stored anonymous user id {stored!r} for user {user!r} "
"in course {course!r} doesn't match computed id {digest!r}".format(
user=user,
course=course_id,
stored=anonymous_user_id.anonymous_user_id,
digest=digest
)
)
except IntegrityError:
# Another thread has already created this entry, so
# continue
pass
return digest
def user_by_anonymous_id(id):
......
......@@ -90,6 +90,7 @@ class LTIFields(object):
open_in_a_new_page = Boolean(help="Should LTI be opened in new page?", default=True, scope=Scope.settings)
graded = Boolean(help="Grades will be considered in overall score.", default=False, scope=Scope.settings)
weight = Float(help="Weight for student grades.", default=1.0, scope=Scope.settings)
has_score = Boolean(help="Does this LTI module have score?", default=False, scope=Scope.settings)
class LTIModule(LTIFields, XModule):
......@@ -376,7 +377,7 @@ oauth_consumer_key="", oauth_signature="frVp4JuvT1mVXlxktiAUjQ7%2F1cw%3D"'}
return params
def max_score(self):
return self.weight
return self.weight if self.has_score else None
@XBlock.handler
......@@ -582,6 +583,5 @@ class LTIDescriptor(LTIFields, MetadataOnlyEditingDescriptor, EmptyDataRawDescri
"""
Descriptor for LTI Xmodule.
"""
has_score = True
module_class = LTIModule
grade_handler = module_attr('grade_handler')
......@@ -194,6 +194,7 @@ class LTIModuleTest(LogicTest):
Response from Tool Provider is correct.
"""
self.xmodule.verify_oauth_body_sign = Mock()
self.xmodule.has_score = True
request = Request(self.environ)
request.body = self.get_request_body()
response = self.xmodule.grade_handler(request, '')
......@@ -249,3 +250,16 @@ class LTIModuleTest(LogicTest):
def test_client_key_secret(self):
pass
def test_max_score(self):
self.xmodule.weight = 100.0
self.xmodule.graded = True
self.assertEqual(self.xmodule.max_score(), None)
self.xmodule.has_score = True
self.assertEqual(self.xmodule.max_score(), 100.0)
self.xmodule.graded = False
self.assertEqual(self.xmodule.max_score(), 100.0)
......@@ -44,8 +44,8 @@ Feature: LMS.LTI component
Scenario: Graded LTI component in LMS is correctly works
Given the course has correct LTI credentials
And the course has an LTI component with correct fields:
| open_in_a_new_page | weight | is_graded |
| False | 10 | True |
| open_in_a_new_page | weight | is_graded | has_score |
| False | 10 | True | True |
And I submit answer to LTI question
And I click on the "Progress" tab
Then I see text "Problem Scores: 5/10"
......
......@@ -22,9 +22,10 @@
<h1>${_("Staff grading")}</h1>
<div class="breadcrumbs"></div>
<div class="error-container"></div>
<div class="message-container"></div>
<! -- Problem List View -->
<!-- Problem List View -->
<section class="problem-list-container">
<h2>${_("Instructions")}</h2>
<div class="instructions">
......
......@@ -16,6 +16,7 @@
<section class="container">
<div class="combined-notifications" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div>
<h1>${_("Open Ended Console")}</h1>
<h2>${_("Instructions")}</h2>
<p>${_("Here are items that could potentially need your attention.")}</p>
......
......@@ -19,6 +19,7 @@
<section class="container">
<div class="open-ended-problems" data-ajax_url="${ajax_url}">
<div class="error-container">${error_text}</div>
<h1>${_("Flagged Open Ended Problems")}</h1>
<h2>${_("Instructions")}</h2>
<p>${_("Here are a list of open ended problems for this course that have been flagged by students as potentially inappropriate.")}</p>
......
......@@ -48,4 +48,4 @@
%endif
%endif
</div>
</section>
</section>
\ No newline at end of file
......@@ -15,7 +15,7 @@
-e git+https://github.com/eventbrite/zendesk.git@d53fe0e81b623f084e91776bcf6369f8b7b63879#egg=zendesk
# Our libraries:
-e git+https://github.com/edx/XBlock.git@341d162f353289cfd3974a4f4f9354ce81ab60db#egg=XBlock
-e git+https://github.com/edx/XBlock.git@c54c63cf8294c54512887e6232d4274003afc6e3#egg=XBlock
-e git+https://github.com/edx/codejail.git@0a1b468#egg=codejail
-e git+https://github.com/edx/diff-cover.git@v0.2.6#egg=diff_cover
-e git+https://github.com/edx/js-test-tool.git@v0.1.4#egg=js_test_tool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment