Squashed commit of the following: commit 0f7c2af5f7b8caed575dd253a45299293b2729d7 Author: Colin-Fredericks <colin.fredericks@gmail.com> Date: Tue Jun 30 12:04:43 2015 -0400 Forgot icon commit b48970392741130f774709c54eb6e5ab0089812c Author: Colin-Fredericks <colin.fredericks@gmail.com> Date: Tue Jun 30 11:49:57 2015 -0400 OSPR-535 Partial Credit Squashed commit of the following: commit 6dd34f58f994e32d0d54bf1d67bffd04e0f8ef08 Author: Colin-Fredericks <cof945@dhcp-140-247-184-176.fas.harvard.edu> Date: Tue Jun 30 11:44:01 2015 -0400 Fixing accidental overwrite. commit 1ff8fc4b0e83b90356e8e8dce1022f49bfd162cf Author: Colin-Fredericks <cof945@dhcp-140-247-184-176.fas.harvard.edu> Date: Tue Jun 30 11:18:36 2015 -0400 OSPR-535 Partial Credit Revised after first pull discussion. Fixing scss typos Fixing check/x display problem Empty set is not [] Shuffling empty answer code to grade properly. I don't think I ever wrote this in the first place... Adding tests for MC and Checkbox including proper partial-credit marking and scoring Numerical and OptionResponse tests Also a few improvements to NumericalResponse problem type and exception-raising. CustomResponse tests and more numerical tests Increasing coverage and fixing typos Exception added for pylint false positive Hopefully fixing coverage issue Retabulating line continuation Bok Choy test for partial credit Copypasta fix Adding tooltip for partial credit Improving and expanding comments Minor fixes
126 lines
3.8 KiB
Python
126 lines
3.8 KiB
Python
"""
|
|
Problem Page.
|
|
"""
|
|
from bok_choy.page_object import PageObject
|
|
|
|
|
|
class ProblemPage(PageObject):
|
|
"""
|
|
View of problem page.
|
|
"""
|
|
|
|
url = None
|
|
|
|
def is_browser_on_page(self):
|
|
return self.q(css='.xblock-student_view').present
|
|
|
|
@property
|
|
def problem_name(self):
|
|
"""
|
|
Return the current problem name.
|
|
"""
|
|
return self.q(css='.problem-header').text[0]
|
|
|
|
@property
|
|
def problem_text(self):
|
|
"""
|
|
Return the text of the question of the problem.
|
|
"""
|
|
return self.q(css="div.problem p").text
|
|
|
|
@property
|
|
def message_text(self):
|
|
"""
|
|
Return the "message" text of the question of the problem.
|
|
"""
|
|
return self.q(css="div.problem span.message").text[0]
|
|
|
|
@property
|
|
def hint_text(self):
|
|
"""
|
|
Return the "hint" text of the problem from its div.
|
|
"""
|
|
return self.q(css="div.problem div.problem-hint").text[0]
|
|
|
|
@property
|
|
def mathjax_rendered_in_problem(self):
|
|
"""
|
|
Check that MathJax have been rendered in problem hint
|
|
"""
|
|
mathjax_container = self.q(css="div.problem p .MathJax .math")
|
|
return mathjax_container.visible and mathjax_container.present
|
|
|
|
@property
|
|
def mathjax_rendered_in_hint(self):
|
|
"""
|
|
Check that MathJax have been rendered in problem hint
|
|
"""
|
|
mathjax_container = self.q(css="div.problem div.problem-hint .MathJax .math")
|
|
return mathjax_container.visible and mathjax_container.present
|
|
|
|
def fill_answer(self, text):
|
|
"""
|
|
Fill in the answer to the problem.
|
|
"""
|
|
self.q(css='div.problem div.capa_inputtype.textline input').fill(text)
|
|
|
|
def fill_answer_numerical(self, text):
|
|
"""
|
|
Fill in the answer to a numerical problem.
|
|
"""
|
|
self.q(css='div.problem section.inputtype input').fill(text)
|
|
|
|
def click_check(self):
|
|
"""
|
|
Click the Check button!
|
|
"""
|
|
self.q(css='div.problem button.check').click()
|
|
self.wait_for_ajax()
|
|
|
|
def click_hint(self):
|
|
"""
|
|
Click the Hint button.
|
|
"""
|
|
self.q(css='div.problem button.hint-button').click()
|
|
self.wait_for_ajax()
|
|
|
|
def is_correct(self):
|
|
"""
|
|
Is there a "correct" status showing?
|
|
"""
|
|
return self.q(css="div.problem div.capa_inputtype.textline div.correct span.status").is_present()
|
|
|
|
def simpleprob_is_correct(self):
|
|
"""
|
|
Is there a "correct" status showing? Works with simple problem types.
|
|
"""
|
|
return self.q(css="div.problem section.inputtype div.correct span.status").is_present()
|
|
|
|
def simpleprob_is_partially_correct(self):
|
|
"""
|
|
Is there a "partially correct" status showing? Works with simple problem types.
|
|
"""
|
|
return self.q(css="div.problem section.inputtype div.partially-correct span.status").is_present()
|
|
|
|
def simpleprob_is_incorrect(self):
|
|
"""
|
|
Is there an "incorrect" status showing? Works with simple problem types.
|
|
"""
|
|
return self.q(css="div.problem section.inputtype div.incorrect span.status").is_present()
|
|
|
|
def click_clarification(self, index=0):
|
|
"""
|
|
Click on an inline icon that can be included in problem text using an HTML <clarification> element:
|
|
|
|
Problem <clarification>clarification text hidden by an icon in rendering</clarification> Text
|
|
"""
|
|
self.q(css='div.problem .clarification:nth-child({index}) i[data-tooltip]'.format(index=index + 1)).click()
|
|
|
|
@property
|
|
def visible_tooltip_text(self):
|
|
"""
|
|
Get the text seen in any tooltip currently visible on the page.
|
|
"""
|
|
self.wait_for_element_visibility('body > .tooltip', 'A tooltip is visible.')
|
|
return self.q(css='body > .tooltip').text[0]
|