@@ -135,8 +135,8 @@ defmodule Cadet.Updater.XMLParser do
135135
136136 @ spec process_questions ( String . t ( ) ) :: { :ok , [ map ( ) ] } | { :error , String . t ( ) }
137137 defp process_questions ( xml ) do
138- default_library = xpath ( xml , ~x" //TASK/DEPLOYMENT " e )
139- default_grading_library = xpath ( xml , ~x" //TASK/GRADERDEPLOYMENT " e )
138+ default_library = xpath ( xml , ~x" //TASK/PROGRAMMINGLANGUAGE " e )
139+ default_grading_library = xpath ( xml , ~x" //TASK/GRADERPROGRAMMINGLANGUAGE " e )
140140
141141 questions_params =
142142 xml
@@ -281,22 +281,23 @@ defmodule Cadet.Updater.XMLParser do
281281
282282 @ spec process_question_library ( map ( ) , any ( ) , any ( ) ) :: map ( ) | { :error , String . t ( ) }
283283 defp process_question_library ( question , default_library , default_grading_library ) do
284- library = xpath ( question [ :entity ] , ~x" ./DEPLOYMENT " o ) || default_library
284+ library = xpath ( question [ :entity ] , ~x" ./PROGRAMMINGLANGUAGE " o ) || default_library
285285
286286 grading_library =
287- xpath ( question [ :entity ] , ~x" ./GRADERDEPLOYMENT" o ) || default_grading_library || library
287+ xpath ( question [ :entity ] , ~x" ./GRADERPROGRAMMINGLANGUAGE" o ) || default_grading_library ||
288+ library
288289
289290 if library do
290291 question
291- |> Map . put ( :library , process_question_library ( library ) )
292- |> Map . put ( :grading_library , process_question_library ( grading_library ) )
292+ |> Map . put ( :library , parse_programming_language ( library ) )
293+ |> Map . put ( :grading_library , parse_programming_language ( grading_library ) )
293294 else
294- { :error , "Missing DEPLOYMENT " }
295+ { :error , "Missing PROGRAMMINGLANGUAGE " }
295296 end
296297 end
297298
298- @ spec process_question_library ( any ( ) ) :: map ( )
299- defp process_question_library ( library_entity ) do
299+ @ spec parse_programming_language ( any ( ) ) :: map ( )
300+ defp parse_programming_language ( library_entity ) do
300301 globals =
301302 library_entity
302303 |> xpath (
@@ -316,6 +317,13 @@ defmodule Cadet.Updater.XMLParser do
316317 symbols: ~x" ./SYMBOL/text()" sl
317318 )
318319
320+ options_list =
321+ library_entity
322+ |> xpath ( ~x" ./OPTION" el , key: ~x" ./@key" s , value: ~x" ./@value" s )
323+
324+ options_map =
325+ options_list |> Map . new ( & { & 1 . key , & 1 . value } )
326+
319327 library_entity
320328 |> xpath (
321329 ~x" ." e ,
@@ -325,6 +333,7 @@ defmodule Cadet.Updater.XMLParser do
325333 )
326334 |> Map . put ( :globals , globals )
327335 |> Map . put ( :external , external )
336+ |> Map . put ( :language_options , options_map )
328337 end
329338
330339 @ spec process_charlist ( charlist ( ) | nil ) :: String . t ( ) | nil
0 commit comments