Module: AtomicAssessmentsImport::ExamSoft::Extractor
- Defined in:
- lib/atomic_assessments_import/exam_soft/extractor.rb,
lib/atomic_assessments_import/exam_soft/extractor/options_detector.rb,
lib/atomic_assessments_import/exam_soft/extractor/feedback_detector.rb,
lib/atomic_assessments_import/exam_soft/extractor/metadata_detector.rb,
lib/atomic_assessments_import/exam_soft/extractor/question_stem_detector.rb,
lib/atomic_assessments_import/exam_soft/extractor/question_type_detector.rb,
lib/atomic_assessments_import/exam_soft/extractor/correct_answer_detector.rb
Defined Under Namespace
Classes: CorrectAnswerDetector, FeedbackDetector, MetadataDetector, OptionsDetector, QuestionStemDetector, QuestionTypeDetector
Constant Summary collapse
- SUPPORTED_TYPES =
%w[mcq ma true_false essay short_answer fill_in_the_blank matching ordering].freeze
- OPTION_TYPES =
%w[mcq ma true_false].freeze
Class Method Summary collapse
Class Method Details
.extract(nodes) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/atomic_assessments_import/exam_soft/extractor.rb', line 16 def self.extract(nodes) warnings = [] # Run detectors = OptionsDetector.new(nodes).detect = !.empty? = MetadataDetector.new(nodes).detect question_type = QuestionTypeDetector.new(nodes, has_options: ).detect stem = QuestionStemDetector.new(nodes).detect feedback = FeedbackDetector.new(nodes).detect correct_answers = ? CorrectAnswerDetector.new(nodes, ).detect : [] # Determine status status = "published" unless SUPPORTED_TYPES.include?(question_type) warnings << "Unsupported question type '#{question_type}'" status = nil end if stem.nil? warnings << "No question text found" status = nil end if OPTION_TYPES.include?(question_type) if .empty? warnings << "No options found for #{question_type} question" end if correct_answers.empty? warnings << "No correct answer found" status = nil end end # Build row_mock row = { "question id" => nil, "folder" => [:folder], "title" => [:title], "category" => [:categories] || [], "import type" => nil, "description" => nil, "question text" => stem, "question type" => question_type, "stimulus review" => nil, "instructor stimulus" => nil, "correct answer" => correct_answers.join("; "), "scoring type" => nil, "points" => nil, "distractor rationale" => nil, "sample answer" => nil, "acknowledgements" => nil, "general feedback" => feedback, "correct feedback" => nil, "incorrect feedback" => nil, "shuffle options" => nil, } # Add option keys .each_with_index do |opt, index| letter = ("a".ord + index).chr row["option #{letter}"] = opt[:text] end # For FITB questions, options ARE the answers (no asterisk marking) if question_type == "fill_in_the_blank" && row["correct answer"].blank? && !.empty? row["correct answer"] = .map { |opt| opt[:text] }.join("; ") end { row: row, status: status, warnings: warnings, } end |