Skip to content

Commit 96a6766

Browse files
committed
Remove leftovers from outdated ProFormA import
The removed code hasn't been used for quite some time. A call got commented out with 017644c and finally removed in ec48d1f.
1 parent 301d2da commit 96a6766

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

app/models/exercise.rb

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'nokogiri'
4-
53
class Exercise < ApplicationRecord
64
include Context
75
include Creation
@@ -474,54 +472,6 @@ def duplicate(attributes = {})
474472
exercise
475473
end
476474

477-
def determine_file_role_from_proforma_file(task_node, file_node)
478-
file_id = file_node.xpath('@id')
479-
file_class = file_node.xpath('@class').first.value
480-
comment = file_node.xpath('@comment').first.value
481-
is_referenced_by_test = task_node.xpath("p:tests/p:test/p:filerefs/p:fileref[@id=#{file_id}]")
482-
is_referenced_by_model_solution = task_node.xpath("p:model-solutions/p:model-solution/p:filerefs/p:fileref[@id=#{file_id}]")
483-
if is_referenced_by_test && (file_class == 'internal')
484-
return 'teacher_defined_test'
485-
elsif is_referenced_by_model_solution && (file_class == 'internal')
486-
return 'reference_implementation'
487-
elsif (file_class == 'template') && (comment == 'main')
488-
return 'main_file'
489-
end
490-
491-
'regular_file'
492-
end
493-
494-
def from_proforma_xml(xml_string)
495-
# how to extract the proforma functionality into a different module in rails?
496-
xml = Nokogiri::XML(xml_string)
497-
xml.collect_namespaces
498-
task_node = xml.xpath('/root/p:task')
499-
description = task_node.xpath('p:description/text()')[0].content
500-
self.attributes = {
501-
title: task_node.xpath('p:meta-data/p:title/text()')[0].content,
502-
description:,
503-
instructions: description,
504-
}
505-
task_node.xpath('p:files/p:file').all? do |file|
506-
file_name_split = file.xpath('@filename').first.value.split('.')
507-
file_class = file.xpath('@class').first.value
508-
role = determine_file_role_from_proforma_file(task_node, file)
509-
feedback_message_nodes = task_node.xpath('p:tests/p:test/p:test-configuration/c:feedback-message/text()')
510-
files.build({
511-
name: file_name_split.first,
512-
content: file.xpath('text()').first.content,
513-
read_only: false,
514-
hidden: file_class == 'internal',
515-
role:,
516-
feedback_message: role == 'teacher_defined_test' ? feedback_message_nodes.first.content : nil,
517-
file_type: FileType.find_by(
518-
file_extension: ".#{file_name_split.second}"
519-
),
520-
})
521-
end
522-
self.execution_environment_id = 1
523-
end
524-
525475
def generate_token
526476
self.token ||= SecureRandom.hex(4)
527477
end

0 commit comments

Comments
 (0)