factoring out discussion logic (for now, anyway)
This commit is contained in:
@@ -980,6 +980,7 @@ class AnnotationInput(InputTypeBase):
|
||||
self.comment_prompt = xml.findtext('./comment_prompt', 'Type a commentary below:')
|
||||
self.tag_prompt = xml.findtext('./tag_prompt', 'Select one or more tags:')
|
||||
self.options = self._find_options()
|
||||
self.return_to_annotation = True
|
||||
|
||||
# Need to provide a value that JSON can parse if there is no
|
||||
# student-supplied value yet.
|
||||
@@ -1024,6 +1025,7 @@ class AnnotationInput(InputTypeBase):
|
||||
'comment_prompt': self.comment_prompt,
|
||||
'tag_prompt': self.tag_prompt,
|
||||
'options': self.options,
|
||||
'return_to_annotation': self.return_to_annotation,
|
||||
'debug': self.debug
|
||||
}
|
||||
unpacked_value = self._unpack_value()
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
<span class="incorrect" id="status_${id}"></span>
|
||||
% endif
|
||||
|
||||
<a class="annotation-return" href="javascript:void(0)">Return to Annotation</a><br/>
|
||||
% if return_to_annotation:
|
||||
<a class="annotation-return" href="javascript:void(0)">Return to Annotation</a><br/>
|
||||
% endif
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class @Annotatable
|
||||
_debug: true
|
||||
_debug: false
|
||||
|
||||
wrapperSelector: '.annotatable-wrapper'
|
||||
toggleSelector: '.annotatable-toggle'
|
||||
@@ -8,11 +8,9 @@ class @Annotatable
|
||||
|
||||
problemXModuleSelector: '.xmodule_CapaModule'
|
||||
problemSelector: 'section.problem'
|
||||
problemInputSelector: '.annotation-input'
|
||||
problemReturnSelector: 'section.problem .annotation-return'
|
||||
|
||||
discussionXModuleSelector: '.xmodule_DiscussionModule'
|
||||
discussionSelector: '.discussion-module'
|
||||
|
||||
constructor: (el) ->
|
||||
console.log 'loaded Annotatable' if @_debug
|
||||
@el = el
|
||||
@@ -24,7 +22,6 @@ class @Annotatable
|
||||
init: () ->
|
||||
@initEvents()
|
||||
@initTips()
|
||||
@initDiscussion()
|
||||
|
||||
initEvents: () ->
|
||||
# For handling hide/show of annotations
|
||||
@@ -36,14 +33,12 @@ class @Annotatable
|
||||
# (see the qtip2 options, this must be set explicitly, otherwise they render in the body).
|
||||
@$(@wrapperSelector).delegate @replySelector, 'click', @onClickReply
|
||||
|
||||
# This is a silly hack, but it assumes two things:
|
||||
# For handling 'return to annotation' events from capa problems. Assumes that:
|
||||
# 1) There are annotationinput capa problems rendered on the page
|
||||
# 2) Each one has its an embedded "return to annotation" link.
|
||||
# 2) Each one has an embedded "return to annotation" link (from the capa problem template).
|
||||
# The capa problem's html is injected via AJAX so this just sets a listener on the body and
|
||||
# handles the click event there.
|
||||
$('body').delegate @problemReturnSelector, 'click', @onClickReturn
|
||||
|
||||
initDiscussion: () -> 1
|
||||
|
||||
initTips: () ->
|
||||
@savedTips = []
|
||||
@@ -103,17 +98,10 @@ class @Annotatable
|
||||
|
||||
getProblem: (el) ->
|
||||
problem_id = @getProblemId(el)
|
||||
$(@problemSelector).eq(problem_id)
|
||||
|
||||
getDiscussion: () ->
|
||||
discussion_id = @getDiscussionId()
|
||||
$(@discussionXModuleSelector).find(@discussionSelector).filter("[data-discussion-id='#{discussion_id}']")
|
||||
$(@problemSelector).has(@problemInputSelector).eq(problem_id)
|
||||
|
||||
getProblemId: (el) ->
|
||||
$(el).data('problem-id')
|
||||
|
||||
getDiscussionId: () ->
|
||||
@$(@wrapperSelector).data('discussion-id')
|
||||
|
||||
toggleAnnotations: () ->
|
||||
hide = (@annotationsHidden = not @annotationsHidden)
|
||||
@@ -142,10 +130,6 @@ class @Annotatable
|
||||
offset: offset
|
||||
}) if $(el).length > 0
|
||||
|
||||
afterScrollToDiscussion: (discussion_el) ->
|
||||
btn = $('.discussion-show', discussion_el)
|
||||
btn.click() if !btn.hasClass('shown')
|
||||
|
||||
afterScrollToProblem: (problem_el) ->
|
||||
problem_el.effect 'highlight', {}, 500
|
||||
|
||||
|
||||
Reference in New Issue
Block a user