@@ -85,7 +85,7 @@ fun CdzAnswerContent(
8585 " answer/order" -> OrderAnswer (task, answer, onChanged)
8686 " answer/groups" -> GroupsAnswer (task, answer, onChanged)
8787 " answer/table" -> CdzTableAnswer (task, answer, onChanged)
88- " answer/grid" -> GridAnswer (task, answer, onChanged)
88+ " answer/grid" -> CdzGridAnswer (task, answer, onChanged)
8989 " answer/inline/choice/single" -> Text (
9090 text = Words .CdzChoose .text,
9191 style = MaterialTheme .typography.bodyMedium,
@@ -415,48 +415,6 @@ private fun GroupsAnswer(
415415 }
416416}
417417
418- @Composable
419- private fun GridAnswer (
420- task : CdzTask ,
421- answer : JSONObject ,
422- onChanged : (JSONObject ) -> Unit ,
423- ) {
424- val cells = answer.optJSONArray(" cells" )
425- val count = maxOf(3 , cells?.length() ? : 0 )
426- var values by remember(task.id) {
427- mutableStateOf(
428- List (count) { index -> cells?.optJSONObject(index)?.optString(" answer" ).orEmpty() }
429- )
430- }
431-
432- fun commit (next : List <String >) {
433- values = next
434- if (next.all { it.isBlank() }) {
435- onChanged(JSONObject ())
436- return
437- }
438- val out = JSONArray ()
439- next.forEach { cell ->
440- out .put(JSONObject ().put(" input_type" , " MANUAL_INPUT" ).put(" answer" , cell))
441- }
442- onChanged(JSONObject ().put(" @answer_type" , task.type).put(" cells" , out ))
443- }
444-
445- values.forEachIndexed { index, value ->
446- OutlinedTextField (
447- value = value,
448- onValueChange = { next ->
449- val copy = values.toMutableList()
450- copy[index] = next
451- commit(copy)
452- },
453- label = { Text (Words .CdzCell (index + 1 )) },
454- singleLine = true ,
455- modifier = Modifier .fillMaxWidth(),
456- )
457- }
458- }
459-
460418@Composable
461419private fun UnsupportedAnswer (
462420 task : CdzTask ,
0 commit comments