moodle2cc 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +7 -0
  3. data/lib/moodle2cc.rb +3 -0
  4. data/lib/moodle2cc/canvas_cc/calculated_question_writer.rb +11 -0
  5. data/lib/moodle2cc/canvas_cc/matching_question_writer.rb +6 -4
  6. data/lib/moodle2cc/canvas_cc/models/assessment.rb +1 -1
  7. data/lib/moodle2cc/canvas_cc/models/calculated_question.rb +13 -1
  8. data/lib/moodle2cc/canvas_cc/models/course.rb +2 -2
  9. data/lib/moodle2cc/canvas_cc/models/multiple_dropdowns_question.rb +7 -0
  10. data/lib/moodle2cc/canvas_cc/models/page.rb +7 -1
  11. data/lib/moodle2cc/canvas_cc/models/question.rb +1 -0
  12. data/lib/moodle2cc/canvas_cc/multiple_answers_question_writer.rb +7 -6
  13. data/lib/moodle2cc/canvas_cc/multiple_dropdowns_question_writer.rb +30 -0
  14. data/lib/moodle2cc/canvas_cc/question_writer.rb +2 -1
  15. data/lib/moodle2cc/moodle2/extractor.rb +7 -0
  16. data/lib/moodle2cc/moodle2/models.rb +1 -1
  17. data/lib/moodle2cc/moodle2/models/course.rb +3 -2
  18. data/lib/moodle2cc/moodle2/models/label.rb +5 -5
  19. data/lib/moodle2cc/moodle2/models/questionnaire.rb +1 -1
  20. data/lib/moodle2cc/moodle2/models/quizzes.rb +1 -0
  21. data/lib/moodle2cc/moodle2/models/quizzes/calculated_question.rb +2 -1
  22. data/lib/moodle2cc/moodle2/models/quizzes/multichoice_question.rb +6 -0
  23. data/lib/moodle2cc/moodle2/models/quizzes/question.rb +1 -1
  24. data/lib/moodle2cc/moodle2/models/wiki.rb +10 -0
  25. data/lib/moodle2cc/moodle2/parsers.rb +1 -0
  26. data/lib/moodle2cc/moodle2/parsers/course_parser.rb +5 -5
  27. data/lib/moodle2cc/moodle2/parsers/parser_helper.rb +7 -2
  28. data/lib/moodle2cc/moodle2/parsers/question_parsers/calculated_parser.rb +11 -1
  29. data/lib/moodle2cc/moodle2/parsers/question_parsers/match_parser.rb +2 -1
  30. data/lib/moodle2cc/moodle2/parsers/question_parsers/multichoice_parser.rb +2 -0
  31. data/lib/moodle2cc/moodle2/parsers/questionnaire_parser.rb +5 -0
  32. data/lib/moodle2cc/moodle2/parsers/quiz_parser.rb +5 -0
  33. data/lib/moodle2cc/moodle2/parsers/section_parser.rb +5 -1
  34. data/lib/moodle2cc/moodle2/parsers/wiki_parser.rb +47 -0
  35. data/lib/moodle2cc/moodle2converter/assessment_converter.rb +6 -4
  36. data/lib/moodle2cc/moodle2converter/assignment_converter.rb +1 -1
  37. data/lib/moodle2cc/moodle2converter/book_converter.rb +4 -4
  38. data/lib/moodle2cc/moodle2converter/converter_helper.rb +14 -0
  39. data/lib/moodle2cc/moodle2converter/discussion_converter.rb +1 -1
  40. data/lib/moodle2cc/moodle2converter/feedback_converter.rb +3 -3
  41. data/lib/moodle2cc/moodle2converter/html_converter.rb +16 -1
  42. data/lib/moodle2cc/moodle2converter/label_converter.rb +2 -2
  43. data/lib/moodle2cc/moodle2converter/migrator.rb +70 -2
  44. data/lib/moodle2cc/moodle2converter/question_bank_converter.rb +1 -1
  45. data/lib/moodle2cc/moodle2converter/question_converters.rb +1 -0
  46. data/lib/moodle2cc/moodle2converter/question_converters/calculated_converter.rb +1 -0
  47. data/lib/moodle2cc/moodle2converter/question_converters/matching_converter.rb +3 -0
  48. data/lib/moodle2cc/moodle2converter/question_converters/multichoice_converter.rb +15 -0
  49. data/lib/moodle2cc/moodle2converter/question_converters/multiple_blanks_converter.rb +1 -1
  50. data/lib/moodle2cc/moodle2converter/question_converters/question_converter.rb +3 -5
  51. data/lib/moodle2cc/moodle2converter/questionnaire_converter.rb +44 -8
  52. data/lib/moodle2cc/moodle2converter/section_converter.rb +3 -3
  53. data/lib/moodle2cc/moodle2converter/wiki_converter.rb +37 -0
  54. data/lib/moodle2cc/version.rb +1 -1
  55. data/spec/moodle2cc/canvas_cc/calculated_question_writer_spec.rb +7 -0
  56. data/spec/moodle2cc/canvas_cc/matching_question_writer_spec.rb +2 -2
  57. data/spec/moodle2cc/canvas_cc/models/assessment_spec.rb +1 -1
  58. data/spec/moodle2cc/canvas_cc/models/calculated_question_spec.rb +25 -0
  59. data/spec/moodle2cc/canvas_cc/models/page_spec.rb +6 -0
  60. data/spec/moodle2cc/canvas_cc/multiple_answers_question_writer_spec.rb +4 -1
  61. data/spec/moodle2cc/canvas_cc/multiple_blanks_question_writer_spec.rb +1 -1
  62. data/spec/moodle2cc/canvas_cc/multiple_dropdowns_question_writer_spec.rb +46 -0
  63. data/spec/moodle2cc/moodle2/extractor_spec.rb +8 -0
  64. data/spec/moodle2cc/moodle2/models/label_spec.rb +4 -4
  65. data/spec/moodle2cc/moodle2/parsers/parser_helper_spec.rb +10 -0
  66. data/spec/moodle2cc/moodle2/parsers/question_parsers/calculated_parser_spec.rb +17 -0
  67. data/spec/moodle2cc/moodle2/parsers/questionnaire_parser_spec.rb +4 -0
  68. data/spec/moodle2cc/moodle2/parsers/quiz_parser_spec.rb +1 -1
  69. data/spec/moodle2cc/moodle2/parsers/wiki_parser_spec.rb +23 -0
  70. data/spec/moodle2cc/moodle2converter/assessment_converter_spec.rb +12 -7
  71. data/spec/moodle2cc/moodle2converter/converter_helper_spec.rb +5 -0
  72. data/spec/moodle2cc/moodle2converter/html_converter_spec.rb +7 -2
  73. data/spec/moodle2cc/moodle2converter/label_converter_spec.rb +17 -0
  74. data/spec/moodle2cc/moodle2converter/migrator_spec.rb +83 -2
  75. data/spec/moodle2cc/moodle2converter/question_converters/calculated_converter_spec.rb +2 -0
  76. data/spec/moodle2cc/moodle2converter/question_converters/matching_converter_spec.rb +2 -3
  77. data/spec/moodle2cc/moodle2converter/question_converters/multichoice_converter_spec.rb +26 -0
  78. data/spec/moodle2cc/moodle2converter/question_converters/question_converter_spec.rb +0 -3
  79. data/spec/moodle2cc/moodle2converter/wiki_converter_spec.rb +36 -0
  80. data/test/fixtures/moodle2/backup/activities/quiz_5/quiz.xml +1 -1
  81. data/test/fixtures/moodle2/backup/activities/wiki_58541/calendar.xml +3 -0
  82. data/test/fixtures/moodle2/backup/activities/wiki_58541/completion.xml +3 -0
  83. data/test/fixtures/moodle2/backup/activities/wiki_58541/grades.xml +7 -0
  84. data/test/fixtures/moodle2/backup/activities/wiki_58541/inforef.xml +47 -0
  85. data/test/fixtures/moodle2/backup/activities/wiki_58541/module.xml +28 -0
  86. data/test/fixtures/moodle2/backup/activities/wiki_58541/roles.xml +7 -0
  87. data/test/fixtures/moodle2/backup/activities/wiki_58541/wiki.xml +70 -0
  88. data/test/fixtures/moodle2/backup/moodle_backup.xml +7 -0
  89. metadata +33 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a600552337a2b45e2b9a0878149e3cb61d7a10c9
4
- data.tar.gz: c3ac55a6630b19f53f7b3926ad5ae412cfc2de7f
3
+ metadata.gz: 822f9cffd3b238adb3b971d6bf64a300c520a1fd
4
+ data.tar.gz: 9da80263ebae391337993e9163650ea8b373a754
5
5
  SHA512:
6
- metadata.gz: 30d47158a1782a2ab93acf4fba5e063e5012be0ca7b53aaeec106c2ebd7c766e3cf818dceca016a1425feb79ee9d725911ca0ee762d3b4c969bd1cc192890e1d
7
- data.tar.gz: 6c45ffdd8a31f73d4768b21ca99795373c6dc10b86a3836cff475b1df1d023af31930b99a3ad33d129d307cff570cb07df84ea72ab0173bdea48e5e0e812760c
6
+ metadata.gz: e9047f2fab33dd05f09cdaa47681f03cedb883f544c355431a0c900ead6f343a7209bbf24c4d74e7d45a1b5d20be7f0d4827e7d7c78ab81d046e8b4351c5400d
7
+ data.tar.gz: 292b07a59bb7c6bc515039799a5bb37a7b5929c8f9af19d914dcaeccc4493adb6aaa5b50bbbd5e711f9050a6612f954b0de8db22eebc8f502c2252bac276f677
data/Changelog CHANGED
@@ -1,3 +1,10 @@
1
+ 2014-04-16 Version 0.2.6
2
+ * Substituting more variables in urls/file paths
3
+ * Many quiz settings fixes and quiz question improvements
4
+ * Wiki activity converted to html pages
5
+ * Better handle duplicate page names
6
+ * Better handling of long titles
7
+
1
8
  2014-04-16 Version 0.2.5
2
9
  * Don't default to allowing url submissions for assignments
3
10
  * Long labels are converted to html pages instead of being truncated
data/lib/moodle2cc.rb CHANGED
@@ -82,6 +82,7 @@ module Moodle2CC
82
82
  autoload :MultipleAnswersQuestionWriter, 'moodle2cc/canvas_cc/multiple_answers_question_writer'
83
83
  autoload :MultipleBlanksQuestionWriter, 'moodle2cc/canvas_cc/multiple_blanks_question_writer'
84
84
  autoload :MultipleChoiceQuestionWriter, 'moodle2cc/canvas_cc/multiple_choice_question_writer'
85
+ autoload :MultipleDropdownsQuestionWriter, 'moodle2cc/canvas_cc/multiple_dropdowns_question_writer'
85
86
  autoload :NumericalQuestionWriter, 'moodle2cc/canvas_cc/numerical_question_writer'
86
87
  autoload :ShortAnswerQuestionWriter, 'moodle2cc/canvas_cc/short_answer_question_writer'
87
88
  autoload :TextOnlyQuestionWriter, 'moodle2cc/canvas_cc/text_only_question_writer'
@@ -96,6 +97,7 @@ module Moodle2CC
96
97
  autoload :Assessment, 'moodle2cc/canvas_cc/models/assessment'
97
98
  autoload :DiscussionTopic, 'moodle2cc/canvas_cc/models/discussion_topic'
98
99
  autoload :Question, 'moodle2cc/canvas_cc/models/question'
100
+ autoload :CalculatedQuestion, 'moodle2cc/canvas_cc/models/calculated_question'
99
101
  autoload :Answer, 'moodle2cc/canvas_cc/models/answer'
100
102
  autoload :QuestionBank, 'moodle2cc/canvas_cc/models/question_bank'
101
103
  autoload :QuestionGroup, 'moodle2cc/canvas_cc/models/question_group'
@@ -128,5 +130,6 @@ module Moodle2CC
128
130
  autoload :HomepageConverter, 'moodle2cc/moodle2converter/homepage_converter'
129
131
  autoload :GlossaryConverter, 'moodle2cc/moodle2converter/glossary_converter'
130
132
  autoload :LabelConverter, 'moodle2cc/moodle2converter/label_converter'
133
+ autoload :WikiConverter, 'moodle2cc/moodle2converter/wiki_converter'
131
134
  end
132
135
  end
@@ -53,6 +53,17 @@ module Moodle2CC::CanvasCC
53
53
  end
54
54
  end
55
55
  end
56
+
57
+ calculated_node.var_sets do |var_sets_node|
58
+ question.var_sets.each do |var_set|
59
+ ident = var_set[:vars].sort.map { |k,v| v.to_s.split('.').join }.flatten.join
60
+ var_sets_node.var_set(:ident => ident) do |var_set_node|
61
+ var_set[:vars].each do |k, v|
62
+ var_set_node.var(v, :name => k)
63
+ end
64
+ end
65
+ end
66
+ end
56
67
  end
57
68
  end
58
69
 
@@ -7,14 +7,15 @@ module Moodle2CC::CanvasCC
7
7
  def self.write_responses(presentation_node, question)
8
8
  question.matches.each do |match|
9
9
  presentation_node.response_lid(:ident => "response_#{match[:id]}") do |response_node|
10
+ next unless match[:question_text].length > 0
10
11
  response_node.material do |material_node|
11
- material_node.mattext(match[:question_text], :texttype => 'text/html')
12
+ material_node.mattext(match[:question_text], :texttype => 'text/plain')
12
13
  end
13
14
  response_node.render_choice do |choice_node|
14
15
  question.matches.each do |possible_match|
15
16
  choice_node.response_label(:ident => possible_match[:id]) do |label_node|
16
17
  label_node.material do |material_node|
17
- material_node.mattext possible_match[:answer_text]
18
+ material_node.mattext(possible_match[:answer_text], :texttype => 'text/plain')
18
19
  end
19
20
  end
20
21
  end
@@ -24,8 +25,9 @@ module Moodle2CC::CanvasCC
24
25
  end
25
26
 
26
27
  def self.write_response_conditions(processing_node, question)
27
- score = 100.0 / question.matches.length.to_i
28
- question.matches.each do |match|
28
+ real_matches = question.matches.select{|m| m[:question_text].length > 0}
29
+ score = 100.0 / real_matches.length.to_i
30
+ real_matches.each do |match|
29
31
  processing_node.respcondition do |condition_node|
30
32
  condition_node.conditionvar do |var_node|
31
33
  var_node.varequal match[:id], :respident => "response_#{match[:id]}"
@@ -44,7 +44,7 @@ module Moodle2CC::CanvasCC::Models
44
44
  "#{ASSESSMENT_NON_CC_FOLDER}/#{@identifier}.xml.qti"
45
45
  end
46
46
 
47
- def resolve_question_references(question_banks)
47
+ def resolve_question_references!(question_banks)
48
48
  @items ||= []
49
49
  @question_references.each do |ref|
50
50
  question = nil
@@ -2,6 +2,18 @@ module Moodle2CC::CanvasCC::Models
2
2
  class CalculatedQuestion < Question
3
3
  register_question_type 'calculated_question'
4
4
 
5
- attr_accessor :correct_answer_format, :correct_answer_length, :dataset_definitions, :tolerance
5
+ attr_accessor :correct_answer_format, :correct_answer_length, :dataset_definitions, :tolerance, :var_sets
6
+
7
+ def post_process!
8
+ @material.gsub!(/\{([\w\s]*?)\}/, '[\1]') if @material
9
+
10
+ return unless @answers
11
+ @answers.each do |answer|
12
+ if answer.answer_text
13
+ answer.answer_text.gsub!(/\{([\w\s]*?)\}/, '\1')
14
+ answer.answer_text = answer.answer_text.sub('=', '') if answer.answer_text.start_with?('=')
15
+ end
16
+ end
17
+ end
6
18
  end
7
19
  end
@@ -38,9 +38,9 @@ module Moodle2CC::CanvasCC::Models
38
38
  @settings[method.to_sym]
39
39
  end
40
40
 
41
- def resolve_question_references
41
+ def resolve_question_references!
42
42
  return unless @assessments && @question_banks
43
- @assessments.each{|a| a.resolve_question_references(@question_banks)}
43
+ @assessments.each{|a| a.resolve_question_references!(@question_banks)}
44
44
  end
45
45
 
46
46
  def mute_assignments!
@@ -0,0 +1,7 @@
1
+ module Moodle2CC::CanvasCC::Models
2
+ class MultipleDropdownsQuestion < Question
3
+ register_question_type 'multiple_dropdowns_question'
4
+
5
+ attr_accessor :responses
6
+ end
7
+ end
@@ -7,6 +7,8 @@ module Moodle2CC::CanvasCC::Models
7
7
 
8
8
  EDITING_ROLE_TEACHER = 'teachers'
9
9
 
10
+ MAX_URL_LENGTH = 80
11
+
10
12
  attr_accessor :workflow_state, :editing_roles, :body, :title
11
13
 
12
14
  def initialize
@@ -28,7 +30,11 @@ module Moodle2CC::CanvasCC::Models
28
30
  end
29
31
 
30
32
  def self.convert_name_to_url(name)
31
- CGI::escape(name.downcase.gsub(/\s/, '-').gsub('.', 'dot'))
33
+ url = CGI::escape(name.downcase.gsub(/\s/, '-').gsub('.', 'dot'))
34
+ if url.length > MAX_URL_LENGTH
35
+ url = url[0,MAX_URL_LENGTH][/.{0,#{MAX_URL_LENGTH}}/mu]
36
+ end
37
+ url
32
38
  end
33
39
 
34
40
  end
@@ -33,4 +33,5 @@ end
33
33
 
34
34
  require_relative 'calculated_question'
35
35
  require_relative 'matching_question'
36
+ require_relative 'multiple_dropdowns_question'
36
37
  require_relative 'numerical_question'
@@ -21,14 +21,15 @@ module Moodle2CC::CanvasCC
21
21
  def self.write_response_conditions(processing_node, question)
22
22
  return unless question.answers.count > 0
23
23
  processing_node.respcondition(:continue => 'No') do |condition_node|
24
- first = question.answers.first
25
- rest = question.answers[1..-1]
26
24
  condition_node.conditionvar do |var_node|
27
25
  var_node.and do |and_node|
28
- and_node.varequal first.id, :respident => 'response1'
29
- rest.each do |answer|
30
- and_node.not do |not_node|
31
- not_node.varequal answer.id, :respident => 'response1'
26
+ question.answers.each do |answer|
27
+ if answer.fraction.to_f > 0
28
+ and_node.varequal answer.id, :respident => 'response1'
29
+ else
30
+ and_node.not do |not_node|
31
+ not_node.varequal answer.id, :respident => 'response1'
32
+ end
32
33
  end
33
34
  end
34
35
  end
@@ -0,0 +1,30 @@
1
+ module Moodle2CC::CanvasCC
2
+ class MultipleDropdownsQuestionWriter < QuestionWriter
3
+ register_writer_type 'multiple_dropdowns_question'
4
+
5
+ private
6
+
7
+ def self.write_responses(presentation_node, question)
8
+ question.responses.each do |response|
9
+ presentation_node.response_lid(:ident => "response_#{response[:id]}") do |response_node|
10
+ response_node.material do |material_node|
11
+ material_node.mattext(response[:id], :texttype => 'text/plain')
12
+ end
13
+ response_node.render_choice do |choice_node|
14
+ response[:choices].each do |choice|
15
+ choice_node.response_label(:ident => choice[:id]) do |label_node|
16
+ label_node.material do |material_node|
17
+ material_node.mattext(choice[:text], :texttype => 'text/plain')
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.write_response_conditions(processing_node, question)
27
+ # this is always an answerless questionnaire question (for now), so no response conditions are necessary
28
+ end
29
+ end
30
+ end
@@ -79,7 +79,7 @@ module Moodle2CC::CanvasCC
79
79
  end
80
80
 
81
81
  def self.write_general_feedback(item_node, question)
82
- if question.general_feedback
82
+ if question.general_feedback && question.general_feedback.length > 0
83
83
  item_node.itemfeedback(:ident => 'general_fb') do |fb_node|
84
84
  fb_node.flow_mat do |flow_node|
85
85
  flow_node.material do |material_node|
@@ -122,6 +122,7 @@ require_relative 'matching_question_writer'
122
122
  require_relative 'multiple_answers_question_writer'
123
123
  require_relative 'multiple_blanks_question_writer'
124
124
  require_relative 'multiple_choice_question_writer'
125
+ require_relative 'multiple_dropdowns_question_writer'
125
126
  require_relative 'numerical_question_writer'
126
127
  require_relative 'short_answer_question_writer'
127
128
  require_relative 'text_only_question_writer'
@@ -20,6 +20,7 @@ module Moodle2CC::Moodle2
20
20
  parse_assignments(work_dir, course)
21
21
  parse_books(work_dir, course)
22
22
  parse_folders(work_dir, course)
23
+ parse_wikis(work_dir, course)
23
24
  parse_question_categories(work_dir, course)
24
25
 
25
26
  parse_quizzes(work_dir, course)
@@ -67,6 +68,12 @@ module Moodle2CC::Moodle2
67
68
  end
68
69
  end
69
70
 
71
+ def parse_wikis(work_dir, course)
72
+ if wikis = Moodle2CC::Moodle2::Parsers::WikiParser.new(work_dir).parse
73
+ course.wikis += wikis
74
+ end
75
+ end
76
+
70
77
  def parse_forums(work_dir, course)
71
78
  if forums = Moodle2CC::Moodle2::Parsers::ForumParser.new(work_dir).parse
72
79
  course.forums += forums
@@ -17,5 +17,5 @@ module Moodle2CC::Moodle2::Models
17
17
  require_relative 'models/label'
18
18
  require_relative 'models/questionnaire'
19
19
  require_relative 'models/resource'
20
-
20
+ require_relative 'models/wiki'
21
21
  end
@@ -4,7 +4,7 @@ module Moodle2CC::Moodle2::Models
4
4
  :course_id, :show_grades, :sections, :files, :pages, :forums, :assignments,
5
5
  :books, :folders, :question_categories, :quizzes, :glossaries,
6
6
  :labels, :resources, :external_urls, :choices, :questionnaires,
7
- :feedbacks
7
+ :feedbacks, :wikis
8
8
 
9
9
  def initialize
10
10
  @sections = []
@@ -23,11 +23,12 @@ module Moodle2CC::Moodle2::Models
23
23
  @labels = []
24
24
  @resources = []
25
25
  @external_urls = []
26
+ @wikis = []
26
27
  end
27
28
 
28
29
  def activities
29
30
  pages + forums + assignments + books + folders + quizzes + labels + resources + glossaries +
30
- external_urls + choices + questionnaires + feedbacks
31
+ external_urls + choices + questionnaires + feedbacks + wikis
31
32
  end
32
33
 
33
34
  end
@@ -38,9 +38,9 @@ module Moodle2CC::Moodle2::Models
38
38
  @converted_title = name_text
39
39
 
40
40
  if @converted_title == "Label" || @converted_title.end_with?("...") || @converted_title.length == 0
41
- if intro_text.length > 80
42
-
43
- @converted_title = intro_text[0..79] + "..."
41
+ if intro_text.length > Moodle2CC::Moodle2Converter::ConverterHelper::MAX_TITLE_LENGTH
42
+ @truncate = true
43
+ @converted_title = intro_text # we will truncate in the label_converter
44
44
  @convert_to_page = true
45
45
  else
46
46
  if intro_text.length > 0
@@ -52,8 +52,8 @@ module Moodle2CC::Moodle2::Models
52
52
  end
53
53
  end
54
54
 
55
- # if the intro has no text or the text is identical, then convert to page if it has tags
56
- if @converted_title == intro_text || intro_text.length == 0
55
+ # if the intro has no text or the text is identical, then convert to page only if it has tags
56
+ if (@converted_title == intro_text && !@truncate) || intro_text.length == 0
57
57
  @convert_to_page = intro_html.search('img[src]').length > 0 ||
58
58
  intro_html.search('a[href]').length > 0 ||
59
59
  intro_html.search('iframe[src]').length > 0
@@ -9,7 +9,7 @@ module Moodle2CC::Moodle2::Models
9
9
  end
10
10
 
11
11
  class Question
12
- attr_accessor :id, :name, :type_id, :content, :position, :deleted, :choices
12
+ attr_accessor :id, :name, :type_id, :content, :position, :deleted, :choices, :precise, :length
13
13
 
14
14
  def initialize
15
15
  @choices = []
@@ -6,6 +6,7 @@ module Moodle2CC::Moodle2::Models::Quizzes
6
6
  require_relative 'quizzes/calculated_question'
7
7
  require_relative 'quizzes/match_question'
8
8
  require_relative 'quizzes/multianswer_question'
9
+ require_relative 'quizzes/multichoice_question'
9
10
  require_relative 'quizzes/numerical_question'
10
11
  require_relative 'quizzes/random_sa_question'
11
12
  require_relative 'quizzes/true_false_question'
@@ -1,11 +1,12 @@
1
1
  module Moodle2CC::Moodle2::Models::Quizzes
2
2
  class CalculatedQuestion < Question
3
3
  register_question_type 'calculated'
4
- attr_accessor :correct_answer_format, :correct_answer_length, :dataset_definitions, :tolerance
4
+ attr_accessor :correct_answer_format, :correct_answer_length, :dataset_definitions, :tolerance, :var_sets
5
5
 
6
6
  def initialize
7
7
  super
8
8
  @dataset_definitions = []
9
+ @var_sets = []
9
10
  end
10
11
  end
11
12
  end
@@ -0,0 +1,6 @@
1
+ module Moodle2CC::Moodle2::Models::Quizzes
2
+ class MultichoiceQuestion < Question
3
+ register_question_type 'multichoice'
4
+ attr_accessor :single
5
+ end
6
+ end
@@ -3,7 +3,7 @@ module Moodle2CC::Moodle2::Models::Quizzes
3
3
 
4
4
  @@subclasses = {}
5
5
 
6
- STANDARD_TYPES = ['description', 'essay', 'multichoice', 'shortanswer']
6
+ STANDARD_TYPES = ['description', 'essay', 'shortanswer']
7
7
 
8
8
  def self.create(type)
9
9
  if c = @@subclasses[type]
@@ -0,0 +1,10 @@
1
+ module Moodle2CC::Moodle2::Models
2
+ class Wiki
3
+
4
+ attr_accessor :id, :module_id, :name, :intro, :intro_format, :visible, :first_page_title, :pages
5
+
6
+ def initialize
7
+ @pages = []
8
+ end
9
+ end
10
+ end
@@ -19,4 +19,5 @@ module Moodle2CC::Moodle2::Parsers
19
19
  require_relative 'parsers/label_parser'
20
20
  require_relative 'parsers/external_url_parser'
21
21
  require_relative 'parsers/resource_parser'
22
+ require_relative 'parsers/wiki_parser'
22
23
  end
@@ -13,12 +13,12 @@ module Moodle2CC::Moodle2::Parsers
13
13
  File.open(File.join(@backup_folder, COURSE_XML_PATH)) do |f|
14
14
  course_doc = Nokogiri::XML(f)
15
15
  course.course_id = course_doc.at_xpath('/course/@id').value
16
- course.id_number = course_doc.at_xpath('/course/idnumber').text
17
- course.fullname = course_doc.at_xpath('/course/fullname').text
18
- course.shortname = course_doc.at_xpath('/course/shortname').text
19
- course.summary = course_doc.at_xpath('/course/summary').text
16
+ course.id_number = parse_text(course_doc, '/course/idnumber')
17
+ course.fullname = parse_text(course_doc, '/course/fullname')
18
+ course.shortname = parse_text(course_doc, '/course/shortname')
19
+ course.summary = parse_text(course_doc, '/course/summary')
20
20
  course.show_grades = parse_boolean(course_doc, '/course/showgrades')
21
- if unix_start_date = course_doc.at_xpath('/course/startdate').text
21
+ if unix_start_date = parse_text(course_doc, '/course/startdate')
22
22
  course.startdate = Time.at(unix_start_date.to_i)
23
23
  end
24
24
 
@@ -5,6 +5,10 @@ module Moodle2CC::Moodle2::Parsers
5
5
  XML_NULL_VALUE = '$@NULL@$'
6
6
  MODULE_XML = 'module.xml'
7
7
 
8
+ MOODLE_FILEBASE_TOKEN = '$@FILEPHP@$'
9
+ IMS_FILEBASE_TOKEN = '$IMS_CC_FILEBASE$'
10
+ SLASH_TOKEN = '$@SLASH@$'
11
+
8
12
  def activity_directories(work_dir, activity_types)
9
13
  File.open(File.join(work_dir, Moodle2CC::Moodle2::Extractor::MOODLE_BACKUP_XML)) do |f|
10
14
  moodle_backup_xml = Nokogiri::XML(f)
@@ -16,13 +20,14 @@ module Moodle2CC::Moodle2::Parsers
16
20
  def parse_text(node, xpath, use_xpath=false)
17
21
  if v_node = (use_xpath && node.at_xpath(xpath)) || (!use_xpath && node.%(xpath))
18
22
  value = v_node.text
19
- value unless value == XML_NULL_VALUE
23
+ return nil if value == XML_NULL_VALUE
24
+ value.to_s.gsub(MOODLE_FILEBASE_TOKEN, IMS_FILEBASE_TOKEN).gsub(SLASH_TOKEN, '/')
20
25
  end
21
26
  end
22
27
 
23
28
  def parse_boolean(node, xpath)
24
29
  value = parse_text(node, xpath)
25
- value && (value == '1' || value.downcase == 'true') ? true : false
30
+ value && (value == '1' || value.downcase == 'true' || value.downcase == 'y') ? true : false
26
31
  end
27
32
 
28
33
  def parse_module(activity_dir, activity)