1616
1717namespace qtype_questionpy \api ;
1818
19- use qtype_questionpy \array_converter \array_converter ;
20- use qtype_questionpy \array_converter \converter_config ;
21-
22- defined ('MOODLE_INTERNAL ' ) || die;
19+ use qtype_questionpy \array_converter \attributes \array_element_class ;
20+ use qtype_questionpy \array_converter \attributes \array_key ;
2321
2422/**
2523 * Model defining an attempt's UI source and associated data, such as parameters for placeholders.
@@ -34,24 +32,30 @@ class attempt_ui {
3432 public string $ formulation ;
3533
3634 /** @var string|null */
35+ #[array_key("general_feedback " )]
3736 public ?string $ generalfeedback = null ;
3837
3938 /** @var string|null */
39+ #[array_key("specific_feedback " )]
4040 public ?string $ specificfeedback = null ;
4141
4242 /** @var string|null */
43+ #[array_key("right_answer " )]
4344 public ?string $ rightanswer = null ;
4445
4546 /** @var array<string, string> string to string mapping of placeholder names to the values (to be replaced in the content) */
4647 public array $ placeholders = [];
4748
4849 /** @var string[]|null */
50+ #[array_key("css_files " )]
4951 public ?array $ cssfiles = null ;
5052
5153 /** @var array<string, attempt_file> specifics TBD */
54+ #[array_element_class(attempt_file::class)]
5255 public array $ files = [];
5356
5457 /** @var string specifics TBD */
58+ #[array_key("cache_control " )]
5559 public string $ cachecontrol = "PRIVATE_CACHE " ;
5660
5761 /**
@@ -63,13 +67,3 @@ public function __construct(string $formulation) {
6367 $ this ->formulation = $ formulation ;
6468 }
6569}
66-
67- array_converter::configure (attempt_ui::class, function (converter_config $ config ) {
68- $ config
69- ->rename ("generalfeedback " , "general_feedback " )
70- ->rename ("specificfeedback " , "specific_feedback " )
71- ->rename ("rightanswer " , "right_answer " )
72- ->rename ("cssfiles " , "css_files " )
73- ->rename ("cachecontrol " , "cache_control " )
74- ->array_elements ("files " , attempt_file::class);
75- });
0 commit comments