@@ -133,8 +133,8 @@ defmodule Cadet.Updater.XMLParser do
133133
134134 @ spec process_questions ( String . t ( ) ) :: { :ok , [ map ( ) ] } | { :error , String . t ( ) }
135135 defp process_questions ( xml ) do
136- default_library = xpath ( xml , ~x" //TASK/DEPLOYMENT " e )
137- default_grading_library = xpath ( xml , ~x" //TASK/GRADERDEPLOYMENT " e )
136+ default_library = xpath ( xml , ~x" //TASK/PROGRAMMINGLANGUAGE " e )
137+ default_grading_library = xpath ( xml , ~x" //TASK/GRADERPROGRAMMINGLANGUAGE " e )
138138
139139 questions_params =
140140 xml
@@ -278,22 +278,23 @@ defmodule Cadet.Updater.XMLParser do
278278
279279 @ spec process_question_library ( map ( ) , any ( ) , any ( ) ) :: map ( ) | { :error , String . t ( ) }
280280 defp process_question_library ( question , default_library , default_grading_library ) do
281- library = xpath ( question [ :entity ] , ~x" ./DEPLOYMENT " o ) || default_library
281+ library = xpath ( question [ :entity ] , ~x" ./PROGRAMMINGLANGUAGE " o ) || default_library
282282
283283 grading_library =
284- xpath ( question [ :entity ] , ~x" ./GRADERDEPLOYMENT" o ) || default_grading_library || library
284+ xpath ( question [ :entity ] , ~x" ./GRADERPROGRAMMINGLANGUAGE" o ) || default_grading_library ||
285+ library
285286
286287 if library do
287288 question
288- |> Map . put ( :library , process_question_library ( library ) )
289- |> Map . put ( :grading_library , process_question_library ( grading_library ) )
289+ |> Map . put ( :library , parse_programming_language ( library ) )
290+ |> Map . put ( :grading_library , parse_programming_language ( grading_library ) )
290291 else
291- { :error , "Missing DEPLOYMENT " }
292+ { :error , "Missing PROGRAMMINGLANGUAGE " }
292293 end
293294 end
294295
295- @ spec process_question_library ( any ( ) ) :: map ( )
296- defp process_question_library ( library_entity ) do
296+ @ spec parse_programming_language ( any ( ) ) :: map ( )
297+ defp parse_programming_language ( library_entity ) do
297298 globals =
298299 library_entity
299300 |> xpath (
@@ -313,6 +314,13 @@ defmodule Cadet.Updater.XMLParser do
313314 symbols: ~x" ./SYMBOL/text()" sl
314315 )
315316
317+ options_list =
318+ library_entity
319+ |> xpath ( ~x" ./OPTION" el , key: ~x" ./@key" s , value: ~x" ./@value" s )
320+
321+ options_map =
322+ options_list |> Map . new ( & { & 1 . key , & 1 . value } )
323+
316324 library_entity
317325 |> xpath (
318326 ~x" ." e ,
@@ -322,6 +330,7 @@ defmodule Cadet.Updater.XMLParser do
322330 )
323331 |> Map . put ( :globals , globals )
324332 |> Map . put ( :external , external )
333+ |> Map . put ( :language_options , options_map )
325334 end
326335
327336 @ spec process_charlist ( charlist ( ) | nil ) :: String . t ( ) | nil
0 commit comments