service.preclass.processors.qa_utils module

service.preclass.processors.qa_utils.get_question_type(q)[source]

Determines if a question is multiple or single choice and strips the choice indicator.

Parameters:

q (str) – The question text containing choice type indicators

Returns:

(stripped_question, question_type)
  • stripped_question (str): Question text with choice indicators removed

  • question_type (str): Either ‘multiple choice’ or ‘single choice’

Return type:

tuple

service.preclass.processors.qa_utils.parse_qa(questions)[source]

Parses a formatted string of questions into structured question-answer objects.

Parameters:

questions (str) – Multi-line string containing questions, choices, answers, and references

Returns:

List of dictionaries containing parsed QA data with keys:
  • question (str): The question text

  • question_type (str): Type of question (‘multiple choice’ or ‘single choice’)

  • selects (list): List of answer choices

  • answer (list): List of correct answer indices

  • reference (str): Reference text for the question

Return type:

list

service.preclass.processors.qa_utils.split_ans(ans_text)[source]

Converts answer choices (A, B, C, D, E) to their corresponding indices.

Parameters:

ans_text (str) – String containing answer choices (e.g., ‘A’, ‘BC’, ‘A,B,C’)

Returns:

List of integer indices corresponding to the answer choices (e.g., [0] for A, [1,2] for BC)

Return type:

list

service.preclass.processors.qa_utils.strip_select(select_text)[source]

Removes answer choice prefixes (A., B., C., etc.) from selection text.

Parameters:

select_text (str) – Text containing answer choice prefix

Returns:

Clean text with prefix removed

Return type:

str