moodle2cc 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +37 -29
  3. data/lib/moodle2cc.rb +2 -0
  4. data/lib/moodle2cc/canvas_cc/assignment_writer.rb +2 -1
  5. data/lib/moodle2cc/canvas_cc/models/assessment.rb +14 -4
  6. data/lib/moodle2cc/canvas_cc/models/assignment.rb +1 -1
  7. data/lib/moodle2cc/canvas_cc/models/course.rb +7 -1
  8. data/lib/moodle2cc/canvas_cc/models/page.rb +5 -1
  9. data/lib/moodle2cc/canvas_cc/models/question.rb +3 -3
  10. data/lib/moodle2cc/canvas_cc/multiple_answers_question_writer.rb +40 -0
  11. data/lib/moodle2cc/canvas_cc/question_writer.rb +1 -0
  12. data/lib/moodle2cc/moodle2/extractor.rb +23 -0
  13. data/lib/moodle2cc/moodle2/models.rb +5 -1
  14. data/lib/moodle2cc/moodle2/models/choice.rb +12 -0
  15. data/lib/moodle2cc/moodle2/models/course.rb +8 -3
  16. data/lib/moodle2cc/moodle2/models/feedback.rb +15 -0
  17. data/lib/moodle2cc/moodle2/models/label.rb +66 -0
  18. data/lib/moodle2cc/moodle2/models/questionnaire.rb +19 -0
  19. data/lib/moodle2cc/moodle2/parsers.rb +3 -0
  20. data/lib/moodle2cc/moodle2/parsers/choice_parser.rb +52 -0
  21. data/lib/moodle2cc/moodle2/parsers/course_parser.rb +2 -0
  22. data/lib/moodle2cc/moodle2/parsers/feedback_parser.rb +54 -0
  23. data/lib/moodle2cc/moodle2/parsers/questionnaire_parser.rb +58 -0
  24. data/lib/moodle2cc/moodle2converter/assessment_converter.rb +37 -1
  25. data/lib/moodle2cc/moodle2converter/assignment_converter.rb +1 -1
  26. data/lib/moodle2cc/moodle2converter/book_converter.rb +1 -0
  27. data/lib/moodle2cc/moodle2converter/converter_helper.rb +7 -1
  28. data/lib/moodle2cc/moodle2converter/feedback_converter.rb +70 -0
  29. data/lib/moodle2cc/moodle2converter/folder_converter.rb +2 -1
  30. data/lib/moodle2cc/moodle2converter/glossary_converter.rb +3 -3
  31. data/lib/moodle2cc/moodle2converter/label_converter.rb +39 -0
  32. data/lib/moodle2cc/moodle2converter/migrator.rb +17 -3
  33. data/lib/moodle2cc/moodle2converter/question_converters/question_converter.rb +4 -1
  34. data/lib/moodle2cc/moodle2converter/questionnaire_converter.rb +58 -0
  35. data/lib/moodle2cc/moodle2converter/section_converter.rb +4 -3
  36. data/lib/moodle2cc/version.rb +1 -1
  37. data/spec/moodle2cc/canvas_cc/assignment_writer_spec.rb +2 -0
  38. data/spec/moodle2cc/canvas_cc/models/assessment_spec.rb +25 -18
  39. data/spec/moodle2cc/canvas_cc/multiple_answers_question_writer_spec.rb +47 -0
  40. data/spec/moodle2cc/moodle2/extractor_spec.rb +24 -0
  41. data/spec/moodle2cc/moodle2/models/label_spec.rb +71 -0
  42. data/spec/moodle2cc/moodle2/parsers/choice_parser_spec.rb +32 -0
  43. data/spec/moodle2cc/moodle2/parsers/course_parser_spec.rb +1 -0
  44. data/spec/moodle2cc/moodle2/parsers/feedback_parser_spec.rb +31 -0
  45. data/spec/moodle2cc/moodle2/parsers/questionnaire_parser_spec.rb +32 -0
  46. data/spec/moodle2cc/moodle2converter/assessment_converter_spec.rb +158 -3
  47. data/spec/moodle2cc/moodle2converter/converter_helper_spec.rb +24 -0
  48. data/spec/moodle2cc/moodle2converter/folder_converter_spec.rb +2 -0
  49. data/spec/moodle2cc/moodle2converter/glossary_converter_spec.rb +2 -3
  50. data/spec/moodle2cc/moodle2converter/label_converter_spec.rb +86 -0
  51. data/spec/moodle2cc/moodle2converter/migrator_spec.rb +2 -0
  52. data/spec/moodle2cc/moodle2converter/question_bank_converter_spec.rb +2 -2
  53. data/spec/moodle2cc/moodle2converter/question_converters/calculated_converter_spec.rb +1 -1
  54. data/spec/moodle2cc/moodle2converter/question_converters/matching_converter_spec.rb +1 -1
  55. data/spec/moodle2cc/moodle2converter/question_converters/multiple_blanks_converter_spec.rb +1 -1
  56. data/spec/moodle2cc/moodle2converter/question_converters/numerical_converter_spec.rb +1 -1
  57. data/spec/moodle2cc/moodle2converter/question_converters/question_converter_spec.rb +1 -1
  58. data/spec/moodle2cc/moodle2converter/question_converters/true_false_converter_spec.rb +1 -1
  59. data/spec/moodle2cc/moodle2converter/section_converter_spec.rb +7 -22
  60. data/test/fixtures/moodle2/backup/activities/choice_56547/calendar.xml +3 -0
  61. data/test/fixtures/moodle2/backup/activities/choice_56547/choice.xml +32 -0
  62. data/test/fixtures/moodle2/backup/activities/choice_56547/comments.xml +3 -0
  63. data/test/fixtures/moodle2/backup/activities/choice_56547/completion.xml +3 -0
  64. data/test/fixtures/moodle2/backup/activities/choice_56547/filters.xml +7 -0
  65. data/test/fixtures/moodle2/backup/activities/choice_56547/grades.xml +7 -0
  66. data/test/fixtures/moodle2/backup/activities/choice_56547/inforef.xml +3 -0
  67. data/test/fixtures/moodle2/backup/activities/choice_56547/module.xml +28 -0
  68. data/test/fixtures/moodle2/backup/activities/choice_56547/roles.xml +7 -0
  69. data/test/fixtures/moodle2/backup/activities/feedback_58588/feedback.xml +147 -0
  70. data/test/fixtures/moodle2/backup/activities/feedback_58588/filters.xml +7 -0
  71. data/test/fixtures/moodle2/backup/activities/feedback_58588/grades.xml +7 -0
  72. data/test/fixtures/moodle2/backup/activities/feedback_58588/inforef.xml +3 -0
  73. data/test/fixtures/moodle2/backup/activities/feedback_58588/module.xml +28 -0
  74. data/test/fixtures/moodle2/backup/activities/feedback_58588/roles.xml +7 -0
  75. data/test/fixtures/moodle2/backup/moodle_backup.xml +14 -0
  76. metadata +52 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3daa9082b4bd5b84e073f3f7df0aaa7bf2e6a41
4
- data.tar.gz: 03628a247d0dac408fa3652352562cedd58364d9
3
+ metadata.gz: a600552337a2b45e2b9a0878149e3cb61d7a10c9
4
+ data.tar.gz: c3ac55a6630b19f53f7b3926ad5ae412cfc2de7f
5
5
  SHA512:
6
- metadata.gz: fb774702ba2892c3bd20bff77f9b4b34f9a315934c1453918a6bd0576f266c0ade005f265240ad470264e71b6270f9ad6554e79960a45b5af6f9a957b56e7cdc
7
- data.tar.gz: 530689ba43c0dd8b4d7a65065cc6019a54267d4524570e434d8da3d99837c31d0ab03ec5c2224e7985b5195b1bec04461b44a5ba9b9626a70078e91e94fd054c
6
+ metadata.gz: 30d47158a1782a2ab93acf4fba5e063e5012be0ca7b53aaeec106c2ebd7c766e3cf818dceca016a1425feb79ee9d725911ca0ee762d3b4c969bd1cc192890e1d
7
+ data.tar.gz: 6c45ffdd8a31f73d4768b21ca99795373c6dc10b86a3836cff475b1df1d023af31930b99a3ad33d129d307cff570cb07df84ea72ab0173bdea48e5e0e812760c
data/Changelog CHANGED
@@ -1,71 +1,79 @@
1
+ 2014-04-16 Version 0.2.5
2
+ * Don't default to allowing url submissions for assignments
3
+ * Long labels are converted to html pages instead of being truncated
4
+ * Handle assessments, questionnaires, choice activities, and feedback activities
5
+ * Use definition lists for glossary
6
+ * Include folder descriptions
7
+ * Handle some visibility issues better
8
+
1
9
  2014-04-09 Version 0.2.4
2
- * Fix Moodle book conversion for titles and order
10
+ * Fix Moodle book conversion for titles and order
3
11
 
4
12
  2014-04-09 Version 0.2.3
5
- * Add converting of HSU forums
13
+ * Add converting of HSU forums
6
14
 
7
15
  2014-04-03 Version 0.2.2
8
- * Fixed parse exception for quizzes with no configures attempt count
16
+ * Fixed parse exception for quizzes with no configures attempt count
9
17
 
10
18
  2014-04-02 Version 0.2.1
11
- * Fixed true/false questions conversion for moodle 2
19
+ * Fixed true/false questions conversion for moodle 2
12
20
 
13
21
  2014-04-01 Version 0.2.0
14
- * Add support for converting Moodle 2 exports to canvas
15
- flavored common cartridge
16
- * TODO of adding better plain CC support for Moodle 2 conversions
22
+ * Add support for converting Moodle 2 exports to canvas
23
+ flavored common cartridge
24
+ * TODO of adding better plain CC support for Moodle 2 conversions
17
25
 
18
26
  2014-01-21 Version 0.1.11
19
- * files with associated text/html content are now made into
20
- html pages with that text and a link to the file
27
+ * files with associated text/html content are now made into
28
+ html pages with that text and a link to the file
21
29
 
22
30
  2013-08-15 Version 0.1.10
23
- * improve multiple dropdown question handling
31
+ * improve multiple dropdown question handling
24
32
 
25
33
  2013-08-01 Version 0.1.9
26
- * fix whitespace handling issue with mod_type
34
+ * fix whitespace handling issue with mod_type
27
35
 
28
36
  2013-07-02 Version 0.1.8
29
- * Improved question image conversion by putting it in its own p tag
30
- * Added support for hsuforum content
37
+ * Improved question image conversion by putting it in its own p tag
38
+ * Added support for hsuforum content
31
39
 
32
40
  2013-06-27 Version 0.1.7
33
- * Include question images when converting to QTI
34
- * Added travis setup for happiness
41
+ * Include question images when converting to QTI
42
+ * Added travis setup for happiness
35
43
 
36
44
  2012-12-07 Version 0.1.6
37
- * Added Changelog
38
- * Don't error out when trying to reference non-existent quiz question
45
+ * Added Changelog
46
+ * Don't error out when trying to reference non-existent quiz question
39
47
 
40
48
  2012-08-20 Version 0.1.5
41
49
 
42
- * Readme improvements
43
- * Listed todo items for complete Common Cartridge conversion support
44
- * Added assignment conversion to plain CC
45
- * Added wiki page conversion to plain CC
50
+ * Readme improvements
51
+ * Listed todo items for complete Common Cartridge conversion support
52
+ * Added assignment conversion to plain CC
53
+ * Added wiki page conversion to plain CC
46
54
 
47
55
  2012-08-15 Version 0.1.4
48
56
 
49
- * More robust URI parsing
57
+ * More robust URI parsing
50
58
 
51
59
  2012-08-06 Version 0.1.3
52
60
 
53
- * Fix external link and attachment references
54
- * Fix ordering of module items
61
+ * Fix external link and attachment references
62
+ * Fix ordering of module items
55
63
 
56
64
 
57
65
  2012-08-03 Version 0.1.2
58
66
 
59
- * Add quiz support
60
- * Better handle wiki titles and summaries
67
+ * Add quiz support
68
+ * Better handle wiki titles and summaries
61
69
 
62
70
 
63
71
  2012-07-26 Version 0.1.1
64
72
 
65
- * Fix extra whitespace errors
66
- * Add ability to inject logger during conversion process
73
+ * Fix extra whitespace errors
74
+ * Add ability to inject logger during conversion process
67
75
 
68
76
 
69
77
  2012-7-24 Version 0.1.0
70
78
 
71
- * Initial release
79
+ * Initial release
data/lib/moodle2cc.rb CHANGED
@@ -79,6 +79,7 @@ module Moodle2CC
79
79
  autoload :CalculatedQuestionWriter, 'moodle2cc/canvas_cc/calculated_question_writer'
80
80
  autoload :EssayQuestionWriter, 'moodle2cc/canvas_cc/essay_question_writer'
81
81
  autoload :MatchingQuestionWriter, 'moodle2cc/canvas_cc/matching_question_writer'
82
+ autoload :MultipleAnswersQuestionWriter, 'moodle2cc/canvas_cc/multiple_answers_question_writer'
82
83
  autoload :MultipleBlanksQuestionWriter, 'moodle2cc/canvas_cc/multiple_blanks_question_writer'
83
84
  autoload :MultipleChoiceQuestionWriter, 'moodle2cc/canvas_cc/multiple_choice_question_writer'
84
85
  autoload :NumericalQuestionWriter, 'moodle2cc/canvas_cc/numerical_question_writer'
@@ -126,5 +127,6 @@ module Moodle2CC
126
127
  autoload :HtmlConverter, 'moodle2cc/moodle2converter/html_converter'
127
128
  autoload :HomepageConverter, 'moodle2cc/moodle2converter/homepage_converter'
128
129
  autoload :GlossaryConverter, 'moodle2cc/moodle2converter/glossary_converter'
130
+ autoload :LabelConverter, 'moodle2cc/moodle2converter/label_converter'
129
131
  end
130
132
  end
@@ -42,6 +42,7 @@ module Moodle2CC::CanvasCC
42
42
  xml.peer_reviews assignment.peer_reviews unless assignment.peer_reviews.nil?
43
43
  xml.automatic_peer_reviews assignment.automatic_peer_reviews unless assignment.automatic_peer_reviews.nil?
44
44
  xml.grade_group_students_individually assignment.grade_group_students_individually unless assignment.grade_group_students_individually.nil?
45
+ xml.muted assignment.muted unless assignment.muted.nil?
45
46
  }
46
47
  end.to_xml
47
48
  File.open(File.join(assignment_dir, Moodle2CC::CanvasCC::Models::Assignment::ASSIGNMENT_SETTINGS_FILE), 'w') { |f| f.write(xml) }
@@ -64,4 +65,4 @@ module Moodle2CC::CanvasCC
64
65
  end
65
66
 
66
67
  end
67
- end
68
+ end
@@ -4,6 +4,7 @@ module Moodle2CC::CanvasCC::Models
4
4
  :scoring_policy, :access_code, :ip_filter, :shuffle_answers, :time_limit, :quiz_type]
5
5
  DATETIME_ATTRIBUTES = [:lock_at, :unlock_at]
6
6
 
7
+ ASSESSMENT_TYPE = 'imsqti_xmlv1p2/imscc_xmlv1p1/assessment'
7
8
  LAR_TYPE = 'associatedcontent/imscc_xmlv1p1/learning-application-resource'
8
9
  ASSESSMENT_NON_CC_FOLDER = 'non_cc_assessments'
9
10
 
@@ -14,12 +15,21 @@ module Moodle2CC::CanvasCC::Models
14
15
  end
15
16
 
16
17
  def resources
17
- [assessment_resource]
18
+ [cc_assessment_resource, canvas_assessment_resource]
18
19
  end
19
20
 
20
- def assessment_resource
21
+ def cc_assessment_resource
21
22
  resource = Moodle2CC::CanvasCC::Models::Resource.new
22
23
  resource.identifier = @identifier
24
+ resource.type = ASSESSMENT_TYPE
25
+ resource.dependencies = ["#{@identifier}_meta"]
26
+ resource.files = [] # TODO: export cc qti file
27
+ resource
28
+ end
29
+
30
+ def canvas_assessment_resource
31
+ resource = Moodle2CC::CanvasCC::Models::Resource.new
32
+ resource.identifier = "#{@identifier}_meta"
23
33
  resource.href = meta_file_path
24
34
  resource.type = LAR_TYPE
25
35
  resource.files = [meta_file_path, qti_file_path]
@@ -40,7 +50,7 @@ module Moodle2CC::CanvasCC::Models
40
50
  question = nil
41
51
  group = nil
42
52
  question_banks.each do |bank|
43
- break if (question = bank.questions.detect{|q| q.identifier.to_s == ref[:question]}) ||
53
+ break if (question = bank.questions.detect{|q| q.original_identifier.to_s == ref[:question]}) ||
44
54
  (group = bank.question_groups.detect{|g| g.identifier.to_s == ref[:question]})
45
55
  end
46
56
 
@@ -60,7 +70,7 @@ module Moodle2CC::CanvasCC::Models
60
70
 
61
71
  @items.select{|i| i.is_a?(Moodle2CC::CanvasCC::Models::QuestionGroup)}.each do |group|
62
72
  group.questions.each do |q|
63
- @items.delete_if{|i| i.identifier.to_s == q.identifier}
73
+ @items.delete_if{|i| i.respond_to?(:original_identifier) && i.original_identifier == q.original_identifier}
64
74
  end
65
75
  end
66
76
  end
@@ -3,7 +3,7 @@ module Moodle2CC::CanvasCC::Models
3
3
  attr_accessor :identifier, :title, :body, :due_at, :lock_at, :unlock_at, :all_day_date, :peer_reviews_due_at,
4
4
  :assignment_group_identifier_ref, :workflow_state, :points_possible, :grading_type, :all_day,
5
5
  :submission_types, :position, :peer_review_count, :peer_reviews_assigned, :peer_reviews,
6
- :automatic_peer_reviews, :grade_group_students_individually
6
+ :automatic_peer_reviews, :grade_group_students_individually, :muted
7
7
 
8
8
  LAR_TYPE = 'associatedcontent/imscc_xmlv1p1/learning-application-resource'
9
9
  ASSIGNMENT_SETTINGS_FILE = 'assignment_settings.xml'
@@ -26,7 +26,7 @@ module Moodle2CC::CanvasCC::Models
26
26
  end
27
27
 
28
28
  def all_resources
29
- @resources + @files + @pages + @discussions.map(&:resources).flatten + @assignments.map(&:resources).flatten
29
+ @resources + @files + @pages + @discussions.map(&:resources).flatten + @assignments.map(&:resources).flatten + @assessments.map(&:resources).flatten
30
30
  end
31
31
 
32
32
  def method_missing(m, *args, &block)
@@ -42,5 +42,11 @@ module Moodle2CC::CanvasCC::Models
42
42
  return unless @assessments && @question_banks
43
43
  @assessments.each{|a| a.resolve_question_references(@question_banks)}
44
44
  end
45
+
46
+ def mute_assignments!
47
+ @assignments.each do |assignment|
48
+ assignment.muted = true
49
+ end
50
+ end
45
51
  end
46
52
  end
@@ -24,7 +24,11 @@ module Moodle2CC::CanvasCC::Models
24
24
 
25
25
  def page_name= name
26
26
  @title = name
27
- @href = "#{WIKI_CONTENT}/#{CGI::escape(name.downcase.gsub(/\s/, '-'))}.html"
27
+ @href = "#{WIKI_CONTENT}/#{self.class.convert_name_to_url(name)}.html"
28
+ end
29
+
30
+ def self.convert_name_to_url(name)
31
+ CGI::escape(name.downcase.gsub(/\s/, '-').gsub('.', 'dot'))
28
32
  end
29
33
 
30
34
  end
@@ -2,10 +2,10 @@ module Moodle2CC::CanvasCC::Models
2
2
  class Question
3
3
  QTI_META_ATTRIBUTES = [:question_type, :points_possible, :assessment_question_identifierref]
4
4
  STANDARD_QUESTION_TYPES = ['essay_question', 'fill_in_multiple_blanks_question',
5
- 'multiple_choice_question', 'short_answer_question',
6
- 'text_only_question', 'true_false_question']
5
+ 'multiple_choice_question', 'multiple_answers_question',
6
+ 'short_answer_question', 'text_only_question', 'true_false_question']
7
7
 
8
- attr_accessor :identifier, :title, :material, :answers, :general_feedback, *QTI_META_ATTRIBUTES
8
+ attr_accessor :identifier, :original_identifier, :title, :material, :answers, :general_feedback, *QTI_META_ATTRIBUTES
9
9
 
10
10
  @@subclasses = {}
11
11
 
@@ -0,0 +1,40 @@
1
+ module Moodle2CC::CanvasCC
2
+ class MultipleAnswersQuestionWriter < QuestionWriter
3
+ register_writer_type 'multiple_answers_question'
4
+
5
+ private
6
+
7
+ def self.write_responses(presentation_node, question)
8
+ presentation_node.response_lid(:ident => 'response1', :rcardinality => 'Multiple') do |response_node|
9
+ response_node.render_choice do |choice_node|
10
+ question.answers.each do |answer|
11
+ choice_node.response_label(:ident => answer.id) do |label_node|
12
+ label_node.material do |material_node|
13
+ material_node.mattext answer.answer_text, :texttype => 'text/html'
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ def self.write_response_conditions(processing_node, question)
22
+ return unless question.answers.count > 0
23
+ processing_node.respcondition(:continue => 'No') do |condition_node|
24
+ first = question.answers.first
25
+ rest = question.answers[1..-1]
26
+ condition_node.conditionvar do |var_node|
27
+ 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'
32
+ end
33
+ end
34
+ end
35
+ end
36
+ condition_node.setvar('100', :varname => 'SCORE', :action => 'Set')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -119,6 +119,7 @@ end
119
119
  require_relative 'calculated_question_writer'
120
120
  require_relative 'essay_question_writer'
121
121
  require_relative 'matching_question_writer'
122
+ require_relative 'multiple_answers_question_writer'
122
123
  require_relative 'multiple_blanks_question_writer'
123
124
  require_relative 'multiple_choice_question_writer'
124
125
  require_relative 'numerical_question_writer'
@@ -21,7 +21,12 @@ module Moodle2CC::Moodle2
21
21
  parse_books(work_dir, course)
22
22
  parse_folders(work_dir, course)
23
23
  parse_question_categories(work_dir, course)
24
+
24
25
  parse_quizzes(work_dir, course)
26
+ parse_choices(work_dir, course)
27
+ parse_feedbacks(work_dir, course)
28
+ parse_questionnaires(work_dir, course)
29
+
25
30
  parse_glossaries(work_dir, course)
26
31
  parse_labels(work_dir, course)
27
32
  parse_external_urls(work_dir, course)
@@ -99,6 +104,24 @@ module Moodle2CC::Moodle2
99
104
  end
100
105
  end
101
106
 
107
+ def parse_choices(work_dir, course)
108
+ if choices = Moodle2CC::Moodle2::Parsers::ChoiceParser.new(work_dir).parse
109
+ course.choices += choices
110
+ end
111
+ end
112
+
113
+ def parse_feedbacks(work_dir, course)
114
+ if feedbacks = Moodle2CC::Moodle2::Parsers::FeedbackParser.new(work_dir).parse
115
+ course.feedbacks += feedbacks
116
+ end
117
+ end
118
+
119
+ def parse_questionnaires(work_dir, course)
120
+ if questionnaires = Moodle2CC::Moodle2::Parsers::QuestionnaireParser.new(work_dir).parse
121
+ course.questionnaires += questionnaires
122
+ end
123
+ end
124
+
102
125
  def parse_glossaries(work_dir, course)
103
126
  if glossaries = Moodle2CC::Moodle2::Parsers::GlossaryParser.new(work_dir).parse
104
127
  course.glossaries += glossaries
@@ -3,7 +3,10 @@ module Moodle2CC::Moodle2::Models
3
3
  require_relative 'models/assignment'
4
4
  require_relative 'models/book'
5
5
  require_relative 'models/book_chapter'
6
+ require_relative 'models/choice'
6
7
  require_relative 'models/course'
8
+ require_relative 'models/external_url'
9
+ require_relative 'models/feedback'
7
10
  require_relative 'models/folder'
8
11
  require_relative 'models/forum'
9
12
  require_relative 'models/moodle2_file'
@@ -12,6 +15,7 @@ module Moodle2CC::Moodle2::Models
12
15
  require_relative 'models/glossary'
13
16
  require_relative 'models/glossary_entry'
14
17
  require_relative 'models/label'
18
+ require_relative 'models/questionnaire'
15
19
  require_relative 'models/resource'
16
- require_relative 'models/external_url'
20
+
17
21
  end
@@ -0,0 +1,12 @@
1
+ module Moodle2CC::Moodle2::Models
2
+ class Choice
3
+
4
+ attr_accessor :id, :module_id, :name, :intro, :intro_format, :time_open, :time_close,
5
+ :time_modified, :publish, :show_results, :display, :allow_update, :show_unanswered,
6
+ :limit_answers, :completion_submit, :options, :visible
7
+
8
+ def initialize
9
+ @options = []
10
+ end
11
+ end
12
+ end
@@ -1,9 +1,10 @@
1
1
  module Moodle2CC::Moodle2::Models
2
2
  class Course
3
3
  attr_accessor :id_number, :fullname, :shortname, :startdate, :summary,
4
- :course_id, :sections, :files, :pages, :forums, :assignments,
4
+ :course_id, :show_grades, :sections, :files, :pages, :forums, :assignments,
5
5
  :books, :folders, :question_categories, :quizzes, :glossaries,
6
- :labels, :resources, :external_urls
6
+ :labels, :resources, :external_urls, :choices, :questionnaires,
7
+ :feedbacks
7
8
 
8
9
  def initialize
9
10
  @sections = []
@@ -15,6 +16,9 @@ module Moodle2CC::Moodle2::Models
15
16
  @folders = []
16
17
  @question_categories = []
17
18
  @quizzes = []
19
+ @choices = []
20
+ @feedbacks = []
21
+ @questionnaires = []
18
22
  @glossaries = []
19
23
  @labels = []
20
24
  @resources = []
@@ -22,7 +26,8 @@ module Moodle2CC::Moodle2::Models
22
26
  end
23
27
 
24
28
  def activities
25
- pages + forums + assignments + books + folders + quizzes + labels + resources + glossaries + external_urls
29
+ pages + forums + assignments + books + folders + quizzes + labels + resources + glossaries +
30
+ external_urls + choices + questionnaires + feedbacks
26
31
  end
27
32
 
28
33
  end
@@ -0,0 +1,15 @@
1
+ module Moodle2CC::Moodle2::Models
2
+ class Feedback
3
+
4
+ attr_accessor :id, :module_id, :name, :intro, :intro_format, :time_open, :time_close,
5
+ :time_modified, :items, :visible
6
+
7
+ def initialize
8
+ @items = []
9
+ end
10
+
11
+ class Question
12
+ attr_accessor :id, :name, :label, :type, :position, :presentation
13
+ end
14
+ end
15
+ end
@@ -2,5 +2,71 @@ module Moodle2CC::Moodle2::Models
2
2
  class Label
3
3
  attr_accessor :id, :module_id, :name, :intro, :intro_format, :visible
4
4
 
5
+ DEFAULT_PAGE_TITLE = "Untitled Page"
6
+
7
+ def name_text
8
+ @name_text ||= (Nokogiri::HTML(@name.to_s).text.strip rescue "")
9
+ end
10
+
11
+ def intro_html
12
+ @intro_html ||= (Nokogiri::HTML(@intro.to_s) rescue Nokogiri::HTML(''))
13
+ end
14
+
15
+ def intro_text
16
+ @intro_text ||= (intro_html.text.strip rescue "")
17
+ end
18
+
19
+ def converted_title
20
+ process_for_conversion!
21
+ @converted_title
22
+ end
23
+
24
+ def convert_to_page?
25
+ process_for_conversion!
26
+ @convert_to_page
27
+ end
28
+
29
+ def convert_to_header?
30
+ process_for_conversion!
31
+ @convert_to_header
32
+ end
33
+
34
+
35
+ def process_for_conversion!
36
+ return unless @converted_title.nil? || @convert_to_page.nil? || @convert_to_header.nil?
37
+
38
+ @converted_title = name_text
39
+
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] + "..."
44
+ @convert_to_page = true
45
+ else
46
+ if intro_text.length > 0
47
+ @converted_title = intro_text
48
+ else
49
+ @converted_title = DEFAULT_PAGE_TITLE
50
+ @convert_to_header = false # if we're not going to convert it to a page, don't convert it at all
51
+ end
52
+ end
53
+ end
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
57
+ @convert_to_page = intro_html.search('img[src]').length > 0 ||
58
+ intro_html.search('a[href]').length > 0 ||
59
+ intro_html.search('iframe[src]').length > 0
60
+ elsif intro_text.length > 0
61
+ @convert_to_page = true
62
+ else
63
+ @convert_to_page = false
64
+ end
65
+
66
+ # do the opposite if we haven't already explicitly decided not to convert to a header
67
+ if @convert_to_header.nil?
68
+ @convert_to_header = !@convert_to_page
69
+ end
70
+ end
5
71
  end
6
72
  end