pymoodef.questions

Module Contents

Classes

Questions

Defines a set of questions to be included in the Moodle question bank.

class pymoodef.questions.Questions[source]

Defines a set of questions to be included in the Moodle question bank.

define_ini(file)[source]

Define configuration values.

These values are associated with each defined question.

Parameters:

file (str) – Path to ini file.

Return type:

None

Examples

>>> q = Questions()
>>> q.define_ini('tests/questions.ini')
define_from_csv(file, sep=',')[source]

Define questions from a csv file.

Each question is in a row. Each concept in a column.

Parameters:
  • file (str) – Path to csv file.

  • sep (str) – Separator character, ‘,’ or ‘;’.

Return type:

None

Examples

>>> q = Questions()
>>> q.define_from_csv('tests/questions.csv')
define_from_excel(file, sheet_index=0)[source]

Define questions from an Excel file.

Each question is in a row. Each concept in a column.

Parameters:
  • file (str) – Path to Excel file.

  • sheet_index (int) – Number of sheet to process.

Return type:

None

Examples

>>> q = Questions()
>>> q.define_from_excel('tests/questions.xlsx')
generate_xml(file=None)[source]

Generate quiz in XML file.

Each question is in a row. Each concept in a column.

Parameters:

file (str) – Path to csv file.

Return type:

None

Examples

>>> q = Questions()
>>> q.define_from_csv('tests/questions.csv')
>>> q.generate_xml('questions.xml')
__format_questions()

Format the questions included in the class.

__get_rest_of_answers(row, columns)

Get the rest of the answers from a row of questions.

__generate_question_text(row)

Generate the statement of a question, including the image if defined.

__generate_name(row, index, type)

Generate the name of a question.

__generate_question(row, index, columns)

Determine the type of question and generate it.