Class: Moodle2CC::Moodle2Converter::QuestionConverters::MultipleBlanksConverter

Inherits:
QuestionConverter
  • Object
show all
Defined in:
lib/moodle2cc/moodle2converter/question_converters/multiple_blanks_converter.rb

Constant Summary

Constants inherited from QuestionConverter

QuestionConverter::STANDARD_CONVERSIONS

Constants included from ConverterHelper

ConverterHelper::ACTIVITY_LOOKUP, ConverterHelper::ASSESSMENT_SUFFIX, ConverterHelper::ASSIGNMENT_SUFFIX, ConverterHelper::CHAPTER_SUFFIX, ConverterHelper::CHOICE_ASSESSMENT_SUFFIX, ConverterHelper::COURSE_SUFFIX, ConverterHelper::DISCUSSION_SUFFIX, ConverterHelper::EXTERNAL_URL_SUFFIX, ConverterHelper::FEEDBACK_ASSESSMENT_SUFFIX, ConverterHelper::FILE_SUFFIX, ConverterHelper::FOLDER_SUFFIX, ConverterHelper::GLOSSARY_SUFFIX, ConverterHelper::INTRO_SUFFIX, ConverterHelper::LTI_SUFFIX, ConverterHelper::MAX_TITLE_LENGTH, ConverterHelper::MODULE_SUFFIX, ConverterHelper::PAGE_SUFFIX, ConverterHelper::QUESTIONNAIRE_ASSESSMENT_SUFFIX, ConverterHelper::QUESTION_BANK_SUFFIX, ConverterHelper::SUMMARY_PAGE_SUFFIX

Instance Method Summary collapse

Methods inherited from QuestionConverter

#convert, #convert_question_text, #create_canvas_question, register_converter_type

Methods included from ConverterHelper

#activity_content_type, #generate_unique_identifier, #generate_unique_identifier_for, #generate_unique_identifier_for_activity, #generate_unique_resource_path, #get_unique_identifier_for_activity, #truncate_text, #workflow_state

Instance Method Details

#convert_question(moodle_question) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/moodle2cc/moodle2converter/question_converters/multiple_blanks_converter.rb', line 7

def convert_question(moodle_question)
  canvas_question = super

  canvas_question.material.gsub!(/\{\#(\d+)\}/) do |match|
    "[response#{$1}]"
  end

  moodle_question.embedded_questions.each_with_index do |sub_question, index|
    canvas_question.answers += sub_question.answers.select{|a| a.fraction == 1}.map do |moodle_answer|
      converted_answer = Moodle2CC::CanvasCC::Models::Answer.new(moodle_answer)
      converted_answer.resp_ident = "response#{index + 1}"
      converted_answer
    end
  end

  canvas_question
end