Skip to content

Commit 8eb466b

Browse files
committed
fix(codaveri): include file_object encoding for codaveri question creation
1 parent 59bdee1 commit 8eb466b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app/services/course/assessment/question/programming_codaveri/java/java_package_service.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,15 @@ def extract_supporting_tests_files
106106
def extract_supporting_file(filename, content)
107107
supporting_solution_object = default_codaveri_data_file_template
108108

109-
supporting_solution_object[:type] = 'internal'
109+
supporting_solution_object[:type] = 'internal' # 'external' s3 upload not yet implemented by codaveri
110110
supporting_solution_object[:path] = filename.to_s
111-
supporting_solution_object[:content] = content
111+
if content.force_encoding('UTF-8').valid_encoding?
112+
supporting_file_object[:content] = content
113+
supporting_file_object[:encoding] = 'utf8'
114+
else
115+
supporting_file_object[:content] = Base64.strict_encode64(content)
116+
supporting_file_object[:encoding] = 'base64'
117+
end
112118

113119
@data_files.append(supporting_solution_object)
114120
end

0 commit comments

Comments
 (0)