Commit c3f55845 by Arthur Barrett

factoring out discussion logic (for now, anyway)

parent 66ddfa29
...@@ -980,6 +980,7 @@ class AnnotationInput(InputTypeBase): ...@@ -980,6 +980,7 @@ class AnnotationInput(InputTypeBase):
self.comment_prompt = xml.findtext('./comment_prompt', 'Type a commentary below:') self.comment_prompt = xml.findtext('./comment_prompt', 'Type a commentary below:')
self.tag_prompt = xml.findtext('./tag_prompt', 'Select one or more tags:') self.tag_prompt = xml.findtext('./tag_prompt', 'Select one or more tags:')
self.options = self._find_options() self.options = self._find_options()
self.return_to_annotation = True
# Need to provide a value that JSON can parse if there is no # Need to provide a value that JSON can parse if there is no
# student-supplied value yet. # student-supplied value yet.
...@@ -1024,6 +1025,7 @@ class AnnotationInput(InputTypeBase): ...@@ -1024,6 +1025,7 @@ class AnnotationInput(InputTypeBase):
'comment_prompt': self.comment_prompt, 'comment_prompt': self.comment_prompt,
'tag_prompt': self.tag_prompt, 'tag_prompt': self.tag_prompt,
'options': self.options, 'options': self.options,
'return_to_annotation': self.return_to_annotation,
'debug': self.debug 'debug': self.debug
} }
unpacked_value = self._unpack_value() unpacked_value = self._unpack_value()
......
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
<span class="incorrect" id="status_${id}"></span> <span class="incorrect" id="status_${id}"></span>
% endif % 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> </div>
</form> </form>
......
class @Annotatable class @Annotatable
_debug: true _debug: false
wrapperSelector: '.annotatable-wrapper' wrapperSelector: '.annotatable-wrapper'
toggleSelector: '.annotatable-toggle' toggleSelector: '.annotatable-toggle'
...@@ -8,11 +8,9 @@ class @Annotatable ...@@ -8,11 +8,9 @@ class @Annotatable
problemXModuleSelector: '.xmodule_CapaModule' problemXModuleSelector: '.xmodule_CapaModule'
problemSelector: 'section.problem' problemSelector: 'section.problem'
problemInputSelector: '.annotation-input'
problemReturnSelector: 'section.problem .annotation-return' problemReturnSelector: 'section.problem .annotation-return'
discussionXModuleSelector: '.xmodule_DiscussionModule'
discussionSelector: '.discussion-module'
constructor: (el) -> constructor: (el) ->
console.log 'loaded Annotatable' if @_debug console.log 'loaded Annotatable' if @_debug
@el = el @el = el
...@@ -24,7 +22,6 @@ class @Annotatable ...@@ -24,7 +22,6 @@ class @Annotatable
init: () -> init: () ->
@initEvents() @initEvents()
@initTips() @initTips()
@initDiscussion()
initEvents: () -> initEvents: () ->
# For handling hide/show of annotations # For handling hide/show of annotations
...@@ -36,14 +33,12 @@ class @Annotatable ...@@ -36,14 +33,12 @@ class @Annotatable
# (see the qtip2 options, this must be set explicitly, otherwise they render in the body). # (see the qtip2 options, this must be set explicitly, otherwise they render in the body).
@$(@wrapperSelector).delegate @replySelector, 'click', @onClickReply @$(@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 # 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 # The capa problem's html is injected via AJAX so this just sets a listener on the body and
# handles the click event there. # handles the click event there.
$('body').delegate @problemReturnSelector, 'click', @onClickReturn $('body').delegate @problemReturnSelector, 'click', @onClickReturn
initDiscussion: () -> 1
initTips: () -> initTips: () ->
@savedTips = [] @savedTips = []
...@@ -103,17 +98,10 @@ class @Annotatable ...@@ -103,17 +98,10 @@ class @Annotatable
getProblem: (el) -> getProblem: (el) ->
problem_id = @getProblemId(el) problem_id = @getProblemId(el)
$(@problemSelector).eq(problem_id) $(@problemSelector).has(@problemInputSelector).eq(problem_id)
getDiscussion: () ->
discussion_id = @getDiscussionId()
$(@discussionXModuleSelector).find(@discussionSelector).filter("[data-discussion-id='#{discussion_id}']")
getProblemId: (el) -> getProblemId: (el) ->
$(el).data('problem-id') $(el).data('problem-id')
getDiscussionId: () ->
@$(@wrapperSelector).data('discussion-id')
toggleAnnotations: () -> toggleAnnotations: () ->
hide = (@annotationsHidden = not @annotationsHidden) hide = (@annotationsHidden = not @annotationsHidden)
...@@ -142,10 +130,6 @@ class @Annotatable ...@@ -142,10 +130,6 @@ class @Annotatable
offset: offset offset: offset
}) if $(el).length > 0 }) if $(el).length > 0
afterScrollToDiscussion: (discussion_el) ->
btn = $('.discussion-show', discussion_el)
btn.click() if !btn.hasClass('shown')
afterScrollToProblem: (problem_el) -> afterScrollToProblem: (problem_el) ->
problem_el.effect 'highlight', {}, 500 problem_el.effect 'highlight', {}, 500
......
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