dsci524_group13_quizit.load_questions

Functions

_validate_question_format(question_type, has_header, ...)

Validates the format of the questions DataFrame based on the specified question type.

load_questions_from_file(→ pandas.DataFrame)

This function reads the user's questions from a CSV file.

load_questions_from_dataframe(→ pandas.DataFrame)

This function reads the user's questions from a pandas DataFrame.

Module Contents

dsci524_group13_quizit.load_questions._validate_question_format(question_type: dsci524_group13_quizit.question_type.QuestionType, has_header: bool, questions: pandas.DataFrame)[source]

Validates the format of the questions DataFrame based on the specified question type.

Parameters:
  • question_type (QuestionType) – The type of the questions (e.g., multiple choice, short answer).

  • has_header (bool) – Indicates whether the DataFrame has a header row.

  • questions (pd.DataFrame) – The DataFrame containing the questions to be validated.

  • delimiter (bool, optional) – The delimiter of the answers and options for the ‘multiple choice’ questions.

Returns:

The validated questions DataFrame with processed columns based on the question type.

Return type:

pd.DataFrame

Raises:
  • ValueError – If the question type is not specified, unsupported, or if the DataFrame does not follow the expected format.

  • TypeError – If the question type is not of type QuestionType.

dsci524_group13_quizit.load_questions.load_questions_from_file(input_file: str, question_type: dsci524_group13_quizit.question_type.QuestionType, has_header: bool = True, delimiter: str = None) pandas.DataFrame[source]

This function reads the user’s questions from a CSV file. The questions are converted into a pandas DataFrame and saved in the internal class variable.

Parameters:
  • input_file (str) – The path to the CSV file containing the questions.

  • question_type (QuestionType) – The type of questions, either ‘multiple choice’ or ‘short answer’.

  • has_header (bool, optional) – Indicates if the CSV file contains a header. Default is True.

  • delimiter (bool, optional) – The delimiter of the answers and options for the ‘multiple choice’ questions. Default is None.

Returns:

A pandas DataFrame containing the questions.

Return type:

pd.DataFrame

Raises:
  • FileNotFoundError – If the input_file path does not exist.

  • ValueError – If the file is empty or cannot be read.

dsci524_group13_quizit.load_questions.load_questions_from_dataframe(questions: pandas.DataFrame, question_type: dsci524_group13_quizit.question_type.QuestionType, has_header: bool = True, delimiter: str = None) pandas.DataFrame[source]

This function reads the user’s questions from a pandas DataFrame. The questions are converted into a pandas DataFrame and saved in the internal class variable.

Parameters:
  • questions (pd.DataFrame) – The user questions as a pandas DataFrame.

  • question_type (QuestionType) – The type of questions, either ‘multiple choice’ or ‘short answer’.

  • has_header (bool, optional) – Indicates if the DataFrame contains a header. Default is True.

  • delimiter (bool, optional) – The delimiter of the answers and options for the ‘multiple choice’ questions. Default is None.

Returns:

A pandas DataFrame containing the questions.

Return type:

pd.DataFrame

Raises:
  • TypeError – If the questions is not a pandas DataFrame.

  • ValueError – If the DataFrame is empty or if the question type is not specified.