in2lambda.api.question.QuestionΒΆ

class in2lambda.api.question.Question(title: str = '', parts: list[Part] = <factory>, images: list[str] = <factory>, master_content: str = <property object>, _last_part: dict[str, int]=<factory>, skill: int | float | None = None, guidance: str | None = None, duration_lower_bound: int | None = None, duration_upper_bound: int | None = None, publish: bool = <default>, display_final_answer: bool = <default>, display_worked_solution: bool = <default>, display_structured_tutorial: bool = <default>, display_chatbot: bool = <default>)[source]ΒΆ

Bases: object

A full question as represented on Lambda Feedback.

Each question has a title and is composed of a list of parts.

It also carries the settings Lambda Feedback keeps per question.

Examples

>>> from in2lambda.api.question import Question
>>> Question(title="Some title", master_content="Some text")
Question(title='Some title', parts=[], images=[], master_content='Some text')
__init__(title: str = '', parts: list[Part] = <factory>, images: list[str] = <factory>, master_content: str = <property object>, _last_part: dict[str, int]=<factory>, skill: int | float | None = None, guidance: str | None = None, duration_lower_bound: int | None = None, duration_upper_bound: int | None = None, publish: bool = <default>, display_final_answer: bool = <default>, display_worked_solution: bool = <default>, display_structured_tutorial: bool = <default>, display_chatbot: bool = <default>) → NoneΒΆ

Methods

__init__(title, parts, images, ...)

add_part_text(elem)

Either adds a new part with the given text or modifies the first part with no text.

add_solution(elem)

Adds a worked solution to all question parts without one, or inserts a new empty part with the solution if all parts already have a solution.

Attributes

display_chatbot

display_final_answer

display_structured_tutorial

display_worked_solution

duration_lower_bound

duration_upper_bound

guidance

master_content

Main top-level question text.

publish

skill

title

parts

images

add_part_text(elem: Element | str) → None[source]ΒΆ

Either adds a new part with the given text or modifies the first part with no text.

Parameters:

elem – A string or panflute element denoting what the part text should be.

Examples

>>> from in2lambda.api.question import Question
>>> question = Question()
>>> question.add_part_text("part a")
>>> question.add_solution("part a solution")
>>> question
Question(title='', parts=[Part(content='part a', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part a solution', worked_solution_branches=[])], images=[], master_content='')
>>> # Supports adding the answer first.
>>> question.add_solution("part b solution")
>>> question.add_part_text("part b")
>>> question
Question(title='', parts=[Part(content='part a', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part a solution', worked_solution_branches=[]), Part(content='part b', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part b solution', worked_solution_branches=[])], images=[], master_content='')
add_solution(elem: Element | str) → None[source]ΒΆ

Adds a worked solution to all question parts without one, or inserts a new empty part with the solution if all parts already have a solution.

Parameters:

elem – A string or panflute element denoting a worked solution.

Examples

>>> from in2lambda.api.question import Question
>>> question = Question()
>>> question.add_part_text("part a")
>>> question.add_solution("part a solution")
>>> question
Question(title='', parts=[Part(content='part a', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part a solution', worked_solution_branches=[])], images=[], master_content='')
>>> question.add_part_text("part b")
>>> question.add_part_text("part c")
>>> question.add_solution("Solution for b")
>>> # Note that since c doesn't have a solution, it's set to b's solution
>>> question
Question(title='', parts=[Part(content='part a', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part a solution', worked_solution_branches=[]), Part(content='part b', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='Solution for b', worked_solution_branches=[]), Part(content='part c', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='Solution for b', worked_solution_branches=[])], images=[], master_content='')
>>> question.add_solution("We now have a solution for c!")
>>> question
Question(title='', parts=[Part(content='part a', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='part a solution', worked_solution_branches=[]), Part(content='part b', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='Solution for b', worked_solution_branches=[]), Part(content='part c', response_areas=[], tutorial='', tutorial_branches=[], answer='', worked_solution='We now have a solution for c!', worked_solution_branches=[])], images=[], master_content='')
property master_content: strΒΆ

Main top-level question text.

Setting the attribute multiple times appends to the current value with a newline. This allows question text to be dynamically appended.

Examples

>>> from in2lambda.api.question import Question
>>> question = Question()
>>> question.master_content = "hello"
>>> question.master_content = "there"
>>> question.master_content
'hello\nthere'