Commit d06f1545 by Andrew Dekker Committed by Andrew Dekker

Added image display in leaderboard

parent c947e165
......@@ -16,7 +16,12 @@
{% blocktrans %}{{ num_points }} points{% endblocktrans %}
</h4>
{% endwith %}
<div class="leaderboard__answer">{{ topscore.content|linebreaks }}</div>
<div class="leaderboard__answer">
{% if topscore.file %}
<img class="leaderboard__score__image" alt="{% trans "The image associated with your peer's submission." %}" src="{{ topscore.file }}" />
{% endif %}
{{ topscore.content|linebreaks }}
</div>
</li>
{% endfor %}
</ol>
......
......@@ -6,7 +6,7 @@ from xblock.core import XBlock
from openassessment.assessment.errors import SelfAssessmentError, PeerAssessmentError
from submissions import api as sub_api
from openassessment.fileupload import api as file_upload_api
class LeaderboardMixin(object):
"""Leaderboard Mixin introduces all handlers for displaying the leaderboard
......@@ -68,6 +68,8 @@ class LeaderboardMixin(object):
use_cache=False
)
for score in scores:
if 'file_key' in score['content']:
score['file'] = file_upload_api.get_download_url(score['content']['file_key'])
if 'text' in score['content']:
score['content'] = score['content']['text']
elif isinstance(score['content'], basestring):
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -299,6 +299,14 @@
border-top-left-radius: 2px;
}
.leaderboard__score__image{
max-height:150px;
max-width:100%;
margin-right:20px;
margin-bottom:20px;
float:left;
}
.leaderboard__score__title{
font-size: 15px;
color: $edx-gray-l1;
......@@ -310,7 +318,7 @@
.leaderboard__answer{
border-top: 2px solid $edx-gray-d2;
box-shadow: inset 0 0 3px 1px rgba(10, 10, 10, 0.1);
padding: 5px 10px;
padding: 10px;
max-height: 200px;
overflow-y: scroll;
font-size: 14px;
......
<openassessment submission_due="2030-03-11T18:20" leaderboard_show="10">
<openassessment submission_due="2030-03-11T18:20" leaderboard_show="10" allow_file_upload="True">
<title>
My favourite pet
</title>
......
<openassessment leaderboard_show="3" allow_file_upload="True">
<title>Open Assessment Test</title>
<prompt>
Given the state of the world today, what do you think should be done to
combat poverty? Please answer in a short essay of 200-300 words.
</prompt>
<rubric>
<prompt>Read for conciseness, clarity of thought, and form.</prompt>
<criterion>
<name>𝓒𝓸𝓷𝓬𝓲𝓼𝓮</name>
<prompt>How concise is it?</prompt>
<option points="3">
<name>ﻉซƈﻉɭɭﻉกՇ</name>
<explanation>Extremely concise</explanation>
</option>
<option points="2">
<name>Ġööḋ</name>
<explanation>Concise</explanation>
</option>
<option points="1">
<name>ק๏๏г</name>
<explanation>Wordy</explanation>
</option>
</criterion>
<criterion>
<name>Form</name>
<prompt>How well-formed is it?</prompt>
<option points="3">
<name>Good</name>
<explanation>Good</explanation>
</option>
<option points="2">
<name>Fair</name>
<explanation>Fair</explanation>
</option>
<option points="1">
<name>Poor</name>
<explanation>Poor</explanation>
</option>
</criterion>
</rubric>
<assessments>
<assessment name="peer-assessment" must_grade="1" must_be_graded_by="1" />
<assessment name="self-assessment" />
</assessments>
</openassessment>
......@@ -7,6 +7,11 @@ import mock
from django.core.cache import cache
from submissions import api as sub_api
from .base import XBlockHandlerTransactionTestCase, scenario
from django.test.utils import override_settings
from moto import mock_s3
import boto
from boto.s3.key import Key
from openassessment.fileupload import api
class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
......@@ -81,7 +86,30 @@ class TestLeaderboardRender(XBlockHandlerTransactionTestCase):
# Expect that we default to an empty string for content
self._assert_scores(xblock, [
{"content": "", "score": 1}
{"content": "", "score": 1, "file": ""}
])
@mock_s3
@override_settings(
AWS_ACCESS_KEY_ID='foobar',
AWS_SECRET_ACCESS_KEY='bizbaz',
FILE_UPLOAD_STORAGE_BUCKET_NAME="mybucket"
)
@scenario('data/leaderboard_show_allowfiles.xml')
def test_image_and_text_submission(self, xblock):
# Create a file and get the download URL
conn = boto.connect_s3()
bucket = conn.create_bucket('mybucket')
key = Key(bucket)
key.key = "submissions_attachments/foo"
key.set_contents_from_string("How d'ya do?")
downloadUrl = api.get_download_url("foo")
# Create a image and text submission
self._create_submissions_and_scores(xblock, [({"text": "test answer", "file_key": "foo"}, 1)], submission_key=None)
# Expect that we retrieve both the text and the download URL for the file
self._assert_scores(xblock, [
{"content": "test answer", "score": 1, "file": downloadUrl}
])
def _create_submissions_and_scores(
......
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