function normalize_punctuation($str) { global $OP_COMMA, $OP_PERIOD; $ops = lexify_punctuation($str); $ops = simplify_punctuation($ops); if ($ops and $ops[count($ops) - 1] === $OP_COMMA) { $ops[count($ops) - 1] = $OP_PERIOD; } return serialize_sentence_part($ops); }
$wrap = $quiz->get_wrap(); if ($wrap) { $result_json[] = ["wrap", $wrap]; } $help = $quiz->get_help(); if ($help) { $result_json[] = ["help", $help]; } $cquiz_answers = []; $_mini = []; $allow_space = FALSE; $n = 0; $cquiz_answers = []; $refresh = function ($finish = false) use(&$result_json, &$_mini, &$allow_space, &$cquiz_answers) { if ($_mini) { $result_json[] = ["text", serialize_sentence_part($_mini, $allow_space) . (($finish and $allow_space) ? " " : "")]; $_mini = []; } }; $dopick = function ($answer, $mode = TRUE) use(&$reason, &$selections) { return $mode ? do_pick($answer, NULL, $selections, $reason) : _process_value($answer, $selections, defaultDB()); }; foreach ($sentence as $word) { if (ISHTML($word)) { $refresh(); $result_json[] = ["html", $word->text]; } elseif ($word === $OP_MULTIPLE_CHOICE or $word === $OP_MATCHING_CHOICES) { $refresh(1); $shuffle = true; $stop = FALSE; $correct = [];
function serialize_sentence($vector) { return serialize_sentence_part($vector) . "."; }