Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
185 commits
Select commit Hold shift + click to select a range
1b66d3c
New show_title and custom title options
bradenmacdonald Mar 29, 2015
18243ce
Fwd port fix to OC-545 (Issues in scrollbars in Feedback pop up for l…
bradenmacdonald Mar 28, 2015
709006f
Fwd port fixes for popup heights
bradenmacdonald Mar 29, 2015
c727218
Fwd port fix to OC-89: Improve MCQ/MRQ choice HTML
bradenmacdonald Mar 29, 2015
3f4ff28
Fix: styles were not applied to Studio preview
bradenmacdonald Mar 31, 2015
1eba407
Display choices as HTML in studio editor
bradenmacdonald Apr 2, 2015
409214e
Fix bugs in the upgrade script and change it to work w/ mentoring v1 …
bradenmacdonald Apr 3, 2015
a475187
Address review comments, fix bug when a unit contains two mentoring b…
bradenmacdonald Apr 6, 2015
f6afc98
Make travis work for all branches.
Kelketek Apr 7, 2015
ba65ce0
Merge Upgrade Script Fixes - PR #2
bradenmacdonald Apr 8, 2015
7a3d51b
Removed custom deserialization code from questionnaire, tweaked tip d…
e-kolpakov Apr 7, 2015
2cf54dc
Added explicit test_requirements and included them in Travis build
e-kolpakov Apr 7, 2015
0c43ff6
Merge pull request #7 from open-craft/import-export-fix2
bradenmacdonald Apr 8, 2015
6db6db1
Merge Dashboard XBlock
bradenmacdonald Apr 9, 2015
d3c81f4
Added notifications for locking navigation on supported platforms.
Kelketek Apr 6, 2015
87a929f
Merge pull request #11 from open-craft/notification
Kelketek Apr 10, 2015
18ebc3b
Add Intellij project module filetype to .gitignore.
Kelketek Apr 8, 2015
7a0f19b
Add support for 'assessment feedback' message.
Kelketek Apr 6, 2015
00b3d93
Grammatical rigor
Kelketek Apr 9, 2015
7f0d3de
Add 'get_results' method to all assessment block types
Kelketek Apr 9, 2015
990ba62
Add scaffolding for displaying list of questions in extended feedback.
Kelketek Apr 9, 2015
2900305
Fixup! Remove erroneously added workbench scenario
Kelketek Apr 9, 2015
22e12f6
Implemented extended feedback.
Kelketek Apr 10, 2015
98dd067
Tests almost working right.
Kelketek Apr 11, 2015
c972cc8
Fix flaky dashboard test
bradenmacdonald Apr 13, 2015
918f8c8
Add front-end interface for additonal and extended feedback.
Kelketek Apr 14, 2015
3dab407
Make text fit for review message button.
Kelketek Apr 14, 2015
25873d3
Merge pull request #12 from open-craft/additional-feedback
Kelketek Apr 14, 2015
cc823f7
Fix invalid appearance in Apros due to their box-sizing global
bradenmacdonald Apr 9, 2015
615aadb
Fix alignment of font awesome icons, checkbox, and text
bradenmacdonald Apr 10, 2015
5acc98d
Re-Merge pull request #8 from open-craft/apros-fix
bradenmacdonald Apr 16, 2015
90d1317
Fix: Question titles were not visible in the LMS
bradenmacdonald Apr 10, 2015
5d42eda
Fix: MCQ question text should be editable even if there are no choice…
bradenmacdonald Apr 10, 2015
ecb5d30
Fix: Can't retry if max_attempts set to zero after answering while it…
bradenmacdonald Apr 10, 2015
11ed319
Fix: confusing behaviour of max_attempts when changing mode
bradenmacdonald Apr 10, 2015
e0f7fad
Fix: spacing around question titles/text in Firefox
bradenmacdonald Apr 10, 2015
83ae2b7
Merge pull request #13 from open-craft/hotfixes-port
bradenmacdonald Apr 16, 2015
0fc3ad5
Fix: Checkmark not shown if answer name is numeric
bradenmacdonald Apr 16, 2015
a26d9d7
Merge pull request #14 from open-craft/fix-numeric-names
bradenmacdonald Apr 17, 2015
f206f28
Fix minor unicode error
bradenmacdonald Apr 18, 2015
4992ce8
Minor fix for "<title></title>"
bradenmacdonald Apr 18, 2015
cb4538c
Fix bug when multiple mentoring blocks are in the same unit, one woul…
bradenmacdonald Apr 18, 2015
d9c256c
Support alternating HTML instructions in assessments
bradenmacdonald Apr 21, 2015
e9e5f81
Don't preserve empty <tip>s
bradenmacdonald Apr 21, 2015
8582e03
Allow hiding the title of the whole problem builder block
bradenmacdonald Apr 22, 2015
b3cb55c
Fix JS error when display_submit is False
bradenmacdonald Apr 22, 2015
4f5904c
Deal with invalid <tip> elements when the desired meaning can be infe…
bradenmacdonald Apr 22, 2015
b5a1ff3
Fix deepcopy error due to fix in 90d1317 not being applied everywhere
bradenmacdonald Apr 22, 2015
b448953
Minor: remove unused ddt
bradenmacdonald Apr 22, 2015
c3a2af3
Merge pull request #15 from open-craft/fix-upgrade-bug
bradenmacdonald Apr 22, 2015
5135afb
Fix two tip CSS issues
bradenmacdonald Apr 23, 2015
6a74d6a
Fix travis builds following xblock-sdk PR 56 change
bradenmacdonald Apr 24, 2015
3694ed4
Hotfix: mentoring and problem_builder should not both use the same db…
bradenmacdonald Apr 23, 2015
2563c83
Data migration
bradenmacdonald Apr 23, 2015
e7e2ae4
Merge pull request #20 from open-craft/hotfix-fwd-port
bradenmacdonald Apr 24, 2015
5f60d03
Bump xblock-utils to fix jump_to_id url rewriting issue
bradenmacdonald Apr 24, 2015
c1e91c8
Fix bug with "Review Grade" button when max_attempts is unlimited
bradenmacdonald Apr 24, 2015
d2100b6
Parametrize assessment tests
bradenmacdonald Apr 24, 2015
d4a7b51
Merge pull request #21 from open-craft/fix-two-more-bugs
bradenmacdonald Apr 27, 2015
dd92fd2
Merge pull request #17 from open-craft/oc-629-popup-css-issues
bradenmacdonald Apr 27, 2015
1d5391d
Moved migrations from south_migrations to migrations folder to enable…
e-kolpakov Apr 28, 2015
c8fda84
Merge pull request #23 from open-craft/eugeny/migrations-fix
Kelketek Apr 28, 2015
13e5278
New tests for messages in standard mode
bradenmacdonald Apr 28, 2015
162c74e
Fix the bug
bradenmacdonald Apr 28, 2015
2562f54
Fix appearance of messages in Studio
bradenmacdonald Apr 28, 2015
8e7eec3
Clarify the various messages and what they are supposed to do
bradenmacdonald Apr 28, 2015
f7a0d15
Remove unused code
bradenmacdonald Apr 28, 2015
cff2006
Clean up the submit handlers
bradenmacdonald Apr 28, 2015
b1db769
Minor test cleanups
bradenmacdonald Apr 29, 2015
a6fce04
Fix Travis build
bradenmacdonald Apr 29, 2015
b5db41c
Hide "Review final grade" link by default.
smarnach Apr 30, 2015
ee1c513
Merge pull request #24 from open-craft/fix-max-attempts-message
bradenmacdonald Apr 30, 2015
9162c1e
Test + fix for crash when block is deleted
bradenmacdonald Apr 30, 2015
d08ad4c
Merge remote-tracking branch 'origin/master' into smarnach/review-link
smarnach Apr 30, 2015
bde591c
Merge pull request #27 from open-craft/smarnach/review-link
smarnach Apr 30, 2015
d9f2097
Merge pull request #25 from open-craft/fix-author-changes
bradenmacdonald Apr 30, 2015
49eee8b
Tweak spacing and text boldness on assessments results
antoviaque Apr 30, 2015
4d76960
Merge pull request #26 from open-craft/assessment-styletweaks
antoviaque May 1, 2015
f13d337
Suppressed noisy loggers
e-kolpakov May 7, 2015
395c403
Preserving feedback messages and tips on page reload for standard mode
e-kolpakov May 6, 2015
40ff34f
Restoring feedback on reload for stadnard-mode mentoring + tests
e-kolpakov May 7, 2015
bfd829e
Added tests for initial state (no feedback should be shown) and for p…
e-kolpakov May 8, 2015
742c223
Showing feedback for last submission
e-kolpakov May 8, 2015
21e2923
Suppressed noisy loggers
e-kolpakov May 7, 2015
78decd9
Merged edx-release into master
e-kolpakov May 8, 2015
43ba649
Fixed showing feedback for all MRQ options on page reload and marking…
e-kolpakov May 11, 2015
2e72dce
Merge pull request #30 from open-craft/feedback-persistence
e-kolpakov May 11, 2015
5e00f92
Revert "Merged edx-release into master"
antoviaque May 12, 2015
85d12cc
Merge remote-tracking branch 'remotes/origin/edx-release' into merge-…
e-kolpakov May 12, 2015
03621b1
Merge pull request #32 from open-craft/merge-candidate
e-kolpakov May 13, 2015
2615f20
Fixed submit button being enabled after page reload
e-kolpakov May 18, 2015
625169c
Making MRQ feedback persistence in line with ordinary submission
e-kolpakov May 19, 2015
ee363ed
Merge pull request #34 from open-craft/feedback-persistence
e-kolpakov May 21, 2015
222b0ae
Fix upgrade error when <message> has no 'type' specified explicitly
bradenmacdonald May 22, 2015
4be1a4c
Test + fix an additional failure case
bradenmacdonald May 1, 2015
74ae54c
Merge pull request #28 from open-craft/fix-author-changes-ii
bradenmacdonald May 22, 2015
f9aeb06
Merge pull request #38 from open-craft/edx-release
antoviaque May 22, 2015
42901b1
Merge pull request #37 from open-craft/fix-upgrade-error
bradenmacdonald May 22, 2015
ae903e3
Minor tweaks to better match the Apros theme
bradenmacdonald Jun 12, 2015
df56ae2
Fix test failures
bradenmacdonald Jun 17, 2015
f42c7c5
Merge pull request #40 from open-craft/apros-css-fixes
bradenmacdonald Jun 18, 2015
f57916c
Celery proof of concept for data export block
bradenmacdonald Apr 23, 2015
0d101d8
Add CSV export to proof of concept
bradenmacdonald Apr 25, 2015
06b7460
Submissions API demonstration - completes the proof of concept
bradenmacdonald Apr 25, 2015
f1d6fab
Adapt code to API changes in edx-platform and edx-submissions.
smarnach Jun 1, 2015
091ccda
Make quoting in data_export.js consistent.
smarnach Jun 1, 2015
8045e0f
Disable buttons and show spinner when waiting for status update.
smarnach Jun 1, 2015
5ad49d9
Format times in the UI more nicely and consistently in UTC.
smarnach Jun 2, 2015
7e4ab4b
Add basic integration test for the data export view.
smarnach Jun 2, 2015
1efe0ad
Address final review comments by Braden.
smarnach Jun 5, 2015
ddc822a
Allow student access, answer submissions, and internationalization to…
Kelketek Jun 18, 2015
47bb71c
Stop git from freaking out over test results and IntelliJ.
Kelketek Jun 18, 2015
504935e
Merge pull request #22 from open-craft/data-export
Kelketek Jun 19, 2015
c338a1e
Filter results by block usage id, student, or block type.
Kelketek Jun 19, 2015
725ff4c
Refinement of ID handling when scoping export.
Kelketek Jun 22, 2015
0b04fbd
Addressed review notes.
Kelketek Jun 23, 2015
472a313
Merge pull request #41 from open-craft/extended-export
Kelketek Jun 23, 2015
4dcb2aa
Handle missing children gracefully.
Kelketek Jul 7, 2015
8d6fcbf
Possible fix for download race condition.
Kelketek Jul 7, 2015
48fd595
Merge pull request #42 from open-craft/export-bugfixes
Kelketek Jul 13, 2015
caccfd1
Fix issue that can occur when upgrading split mongo courses
bradenmacdonald Jul 15, 2015
6189ac3
Implement tooltips/clarifications.
mtyaka Jul 12, 2015
2bde553
Address review comments.
mtyaka Jul 15, 2015
b74d5d1
Rename "Data Export" block to "Student Answers Dashboard" (user-facing
itsjeyd Jul 3, 2015
28cebfd
Rename files that implement data export to match new name of XBlock.
itsjeyd Jul 3, 2015
caf0714
Update Student Answers Dashboard key for advanced modules.
itsjeyd Jul 6, 2015
a199b82
Display data to be exported in Student Answers Dashboard XBlock.
itsjeyd Jul 6, 2015
777a9a4
Make contents of CSV file match results displayed on page.
itsjeyd Jul 6, 2015
b9ebeee
Empty result table before adding new results.
itsjeyd Jul 6, 2015
3e4edf4
Hide results table if no data is available.
itsjeyd Jul 6, 2015
e0f62ff
Allow instructors to filter answers by content.
itsjeyd Jul 7, 2015
f463897
Rework UI of Student Answers Dashboard.
itsjeyd Jul 7, 2015
96496aa
Update and extend integration tests for problem-builder.
itsjeyd Jul 8, 2015
d1f2ef6
Paginate export results on the client.
itsjeyd Jul 13, 2015
56dc273
Make existing problem-builder tests pass.
itsjeyd Jul 14, 2015
6ee520a
Extend existing problem-builder tests.
itsjeyd Jul 14, 2015
c7fd48a
Add integration tests for pagination.
itsjeyd Jul 14, 2015
f1e8f6a
Include full MIT license for third-party libraries backbone.paginator,
itsjeyd Jul 14, 2015
b8050f2
Fix pep8 violations.
itsjeyd Jul 14, 2015
9fe9f34
Fix pylint violations.
itsjeyd Jul 14, 2015
01e30ce
Address review comments.
itsjeyd Jul 15, 2015
f57db13
Fix "ImportError: 'module' object has no attribute 'DataExportBlock'".
itsjeyd Jul 15, 2015
dae27b3
Cache answer choices for MCQs.
itsjeyd Jul 16, 2015
90e0b0e
Rename "Student Answers Dashboard" to "Instructor Tool".
itsjeyd Jul 16, 2015
6aaa3ab
Merge pull request #45 from open-craft/student-answers-dashboard
itsjeyd Jul 16, 2015
bee4e70
Allow students to download a copy of their answer table.
Kelketek Jul 8, 2015
f5953e3
Allow users to share table blocks.
Kelketek Jul 10, 2015
bba22bb
Merge pull request #43 from open-craft/download-table
Kelketek Jul 17, 2015
15945a9
Merge pull request #44 from open-craft/clarifications
mtyaka Jul 17, 2015
4a9a6d4
Merge pull request #46 from open-craft/fix-hgse-upgrade
bradenmacdonald Jul 17, 2015
498e220
Fix JS bug when HTML block is followed by an answer black
bradenmacdonald Jul 20, 2015
5be4fa3
Catch IndexError that gets thrown when user provides invalid root blo…
itsjeyd Jul 14, 2015
3fc5716
Implement client-server communication for pagination.
itsjeyd Jul 14, 2015
45bb18a
Turn "Root block ID" field into user-friendly dropdown.
itsjeyd Jul 15, 2015
9b2a4a1
Make sure spinner stays visible and result table stays hidden until
itsjeyd Jul 16, 2015
6fcbba2
Make dropdown work in workbench.
itsjeyd Jul 16, 2015
75994ad
Fix failing tests.
itsjeyd Jul 16, 2015
6e6f31c
Default to question ID (name) if question block does not have a
itsjeyd Jul 16, 2015
a2eb5c7
Refactor to create better separation of concerns in client-side code.
itsjeyd Jul 16, 2015
466b172
Add integration test for deleting export results.
itsjeyd Jul 16, 2015
5822565
Make sure not to override global beforeSend handler.
itsjeyd Jul 17, 2015
74e027c
Get rid of "Unable to find view u'studio_view' on block
itsjeyd Jul 17, 2015
a689bd2
Move code that computes block ID into separate method.
itsjeyd Jul 17, 2015
69b0a80
Take into account different key styles when computing block_type.
itsjeyd Jul 17, 2015
4cc0b2e
Move code that computes names of blocks to separate method and make sure
itsjeyd Jul 17, 2015
a856c87
Make sure dropdown excludes all choice fields (not just children of M…
itsjeyd Jul 17, 2015
418c55f
Make sure long block names can't break layout of export options.
itsjeyd Jul 17, 2015
435382f
Handle cases where "Question title" is set but "question" isn't.
itsjeyd Jul 17, 2015
51d02cf
Look up "Long Answer" submissions by question ID instead of block ID.
itsjeyd Jul 20, 2015
bb2ea26
Store question ID in "Question" column if "question" attribute is not
itsjeyd Jul 21, 2015
e0fbd14
In dropdown listing blocks, show question ID (name) instead of block ID
itsjeyd Jul 21, 2015
c6ab809
Address review comments.
itsjeyd Jul 21, 2015
7da902e
Merge pull request #47 from open-craft/dropdown-pagination
itsjeyd Jul 21, 2015
5efcf9e
Visual improvements to Table block.
Kelketek Jul 21, 2015
ea1c060
Further UI improvements.
Kelketek Jul 21, 2015
1da02fe
Merge pull request #49 from open-craft/download-table
Kelketek Jul 22, 2015
80f90e3
Merge pull request #48 from open-craft/hgse-bugs-ii
bradenmacdonald Jul 22, 2015
c5879dd
Allow toggling show_title behaviour during upgrade
bradenmacdonald Jul 24, 2015
21fc19e
Merge pull request #51 from open-craft/fix-hgse-upgrade-ii
bradenmacdonald Jul 27, 2015
94a88c5
Fix: Unhelpful tooltips shown in sequential accordion in the LMS
bradenmacdonald Jul 27, 2015
0bf1ae6
Fix: answers in the same LMS sequential should auto-refresh
bradenmacdonald Jul 28, 2015
e87453b
Merge pull request #52 from open-craft/hgse-fixes-iii
bradenmacdonald Jul 28, 2015
6ffbf05
Add an extra selector to fix CSS rule ambiguity
bradenmacdonald Jul 28, 2015
fa85907
Merge pull request #53 from open-craft/hgse-lms-theme-fix
mtyaka Jul 28, 2015
36cd10b
Update master with fixes from release
bradenmacdonald Jul 30, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
/workbench.*
/dist
/templates
*.iml
.idea/*
problem_builder.tests.*
30 changes: 30 additions & 0 deletions LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
------------------------------------------------------------------------------
This license applies to the following third-party libraries included
in this repository:

- backbone.paginator
- Backbone.js
- Underscore.js
------------------------------------------------------------------------------

The MIT License (MIT)

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file modified doc/img/mrq-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions problem_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .answer import AnswerBlock, AnswerRecapBlock
from .choice import ChoiceBlock
from .dashboard import DashboardBlock
from .instructor_tool import InstructorToolBlock
from .mcq import MCQBlock, RatingBlock
from .mrq import MRQBlock
from .message import MentoringMessageBlock
Expand Down
81 changes: 64 additions & 17 deletions problem_builder/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from xblock.validation import ValidationMessage
from xblockutils.resources import ResourceLoader
from xblockutils.studio_editable import StudioEditableXBlockMixin
from problem_builder.sub_api import SubmittingXBlockMixin, sub_api
from .step import StepMixin
import uuid

Expand Down Expand Up @@ -84,6 +85,23 @@ def get_model_object(self, name=None):
)
return answer_data

@property
def student_input(self):
if self.name:
return self.get_model_object().student_input
return ''

@XBlock.json_handler
def answer_value(self, data, suffix=''):
""" Current value of the answer, for refresh by client """
return {'value': self.student_input}

@XBlock.json_handler
def refresh_html(self, data, suffix=''):
""" Complete HTML view of the XBlock, for refresh by client """
frag = self.mentoring_view({})
return {'html': frag.content}

def validate_field_data(self, validation, data):
"""
Validate this block's field data.
Expand All @@ -102,7 +120,7 @@ def _(self, text):


@XBlock.needs("i18n")
class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
class AnswerBlock(SubmittingXBlockMixin, AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
"""
A field where the student enters an answer

Expand Down Expand Up @@ -131,7 +149,8 @@ class AnswerBlock(AnswerMixin, StepMixin, StudioEditableXBlockMixin, XBlock):
display_name=_("Question"),
help=_("Question to ask the student"),
scope=Scope.content,
default=""
default="",
multiline_editor=True,
)
weight = Float(
display_name=_("Weight"),
Expand Down Expand Up @@ -164,7 +183,7 @@ def student_input(self):

def mentoring_view(self, context=None):
""" Render this XBlock within a mentoring block. """
context = context or {}
context = context.copy() if context else {}
context['self'] = self
context['hide_header'] = context.get('hide_header', False) or not self.show_title
html = loader.render_template('templates/html/answer_editable.html', context)
Expand All @@ -179,20 +198,35 @@ def student_view(self, context=None):
""" Normal view of this XBlock, identical to mentoring_view """
return self.mentoring_view(context)

def get_results(self, previous_response=None):
# Previous result is actually stored in database table-- ignore.
return {
'student_input': self.student_input,
'status': self.status,
'weight': self.weight,
'score': 1 if self.status == 'correct' else 0,
}

def get_last_result(self):
return self.get_results(None) if self.student_input else {}

def submit(self, submission):
"""
The parent block is handling a student submission, including a new answer for this
block. Update accordingly.
"""
self.student_input = submission[0]['value'].strip()
self.save()

if sub_api:
# Also send to the submissions API:
item_key = self.student_item_key
# Need to do this by our own ID, since an answer can be referred to multiple times.
item_key['item_id'] = self.name
sub_api.create_submission(item_key, self.student_input)

log.info(u'Answer submitted for`{}`: "{}"'.format(self.name, self.student_input))
return {
'student_input': self.student_input,
'status': self.status,
'weight': self.weight,
'score': 1 if self.status == 'correct' else 0,
}
return self.get_results()

@property
def status(self):
Expand Down Expand Up @@ -258,22 +292,35 @@ class AnswerRecapBlock(AnswerMixin, StudioEditableXBlockMixin, XBlock):
)
editable_fields = ('name', 'display_name', 'description')

@property
def student_input(self):
if self.name:
return self.get_model_object().student_input
return ''
css_path = 'public/css/answer.css'

def mentoring_view(self, context=None):
""" Render this XBlock within a mentoring block. """
context = context or {}
context = context.copy() if context else {}
student_submissions_key = context.get('student_submissions_key')
context['title'] = self.display_name
context['description'] = self.description
context['student_input'] = self.student_input
if student_submissions_key:
location = self.location.replace(branch=None, version=None) # Standardize the key in case it isn't already
target_key = {
'student_id': student_submissions_key,
'course_id': unicode(location.course_key),
'item_id': self.name,
'item_type': u'pb-answer',
}
submissions = sub_api.get_submissions(target_key, limit=1)
try:
context['student_input'] = submissions[0]['answer']
except IndexError:
context['student_input'] = None
else:
context['student_input'] = self.student_input
html = loader.render_template('templates/html/answer_read_only.html', context)

fragment = Fragment(html)
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/answer.css'))
fragment.add_css_url(self.runtime.local_resource_url(self, self.css_path))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/answer_recap.js'))
fragment.initialize_js('AnswerRecapBlock')
return fragment

def student_view(self, context=None):
Expand Down
71 changes: 40 additions & 31 deletions problem_builder/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,39 @@ def _(text):
# Classes ###########################################################


class ExportMixin(object):
"""
Used by blocks which need to provide a downloadable export.
"""
def _get_user_full_name(self):
"""
Get the full name of the current user, for the downloadable report.
"""
user_service = self.runtime.service(self, 'user')
if user_service:
return user_service.get_current_user().full_name
return ""

def _get_course_name(self):
"""
Get the name of the current course, for the downloadable report.
"""
try:
course_key = self.scope_ids.usage_id.course_key
except AttributeError:
return "" # We are not in an edX runtime
try:
course_root_key = course_key.make_usage_key('course', 'course')
return self.runtime.get_block(course_root_key).display_name
except Exception: # ItemNotFoundError most likely, but we can't import that exception in non-edX environments
# We may be on old mongo:
try:
course_root_key = course_key.make_usage_key('course', course_key.run)
return self.runtime.get_block(course_root_key).display_name
except Exception:
return ""


class ColorRule(object):
"""
A rule used to conditionally set colors
Expand Down Expand Up @@ -155,7 +188,7 @@ class InvalidUrlName(ValueError):

@XBlock.needs("i18n")
@XBlock.wants("user")
class DashboardBlock(StudioEditableXBlockMixin, XBlock):
class DashboardBlock(StudioEditableXBlockMixin, ExportMixin, XBlock):
"""
A block to summarize self-assessment results.
"""
Expand Down Expand Up @@ -260,7 +293,7 @@ class DashboardBlock(StudioEditableXBlockMixin, XBlock):
'color_rules', 'visual_rules', 'visual_title', 'visual_desc', 'header_html', 'footer_html',
)
css_path = 'public/css/dashboard.css'
js_path = 'public/js/dashboard.js'
js_path = 'public/js/review_blocks.js'

def get_mentoring_blocks(self, mentoring_ids, ignore_errors=True):
"""
Expand Down Expand Up @@ -343,34 +376,6 @@ def color_for_value(self, value):
return rule.color_str
return None

def _get_user_full_name(self):
"""
Get the full name of the current user, for the downloadable report.
"""
user_service = self.runtime.service(self, 'user')
if user_service:
return user_service.get_current_user().full_name
return ""

def _get_course_name(self):
"""
Get the name of the current course, for the downloadable report.
"""
try:
course_key = self.scope_ids.usage_id.course_key
except AttributeError:
return "" # We are not in an edX runtime
try:
course_root_key = course_key.make_usage_key('course', 'course')
return self.runtime.get_block(course_root_key).display_name
except Exception: # ItemNotFoundError most likely, but we can't import that exception in non-edX environments
# We may be on old mongo:
try:
course_root_key = course_key.make_usage_key('course', course_key.run)
return self.runtime.get_block(course_root_key).display_name
except Exception:
return ""

def _get_problem_questions(self, mentoring_block):
""" Generator returning only children of specified block that are MCQs """
for child_id in mentoring_block.children:
Expand Down Expand Up @@ -469,7 +474,11 @@ def student_view(self, context=None): # pylint: disable=unused-argument
fragment = Fragment(html)
fragment.add_css_url(self.runtime.local_resource_url(self, self.css_path))
fragment.add_javascript_url(self.runtime.local_resource_url(self, self.js_path))
fragment.initialize_js('PBDashboardBlock', {'reportTemplate': report_template})
fragment.initialize_js(
'PBDashboardBlock', {
'reportTemplate': report_template,
'reportContentSelector': '.dashboard-report'
})
return fragment

def validate_field_data(self, validation, data):
Expand Down
Loading