added app translations for better maintainability
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
* Android app API endpoint.
|
||||
* GET (no params) -> ordered questionnaire list with conditions
|
||||
* GET ?id=<questionnaireID> -> single questionnaire in app JSON format
|
||||
* GET ?translations=1 -> all translations merged across all tables
|
||||
* GET ?translations=1 -> global app UI strings only (not questionnaire content)
|
||||
* GET ?clients=1 -> list of clients assigned to the authenticated coach
|
||||
* POST -> submit interview answers for a client (coach / supervisor / admin)
|
||||
*/
|
||||
@ -207,33 +207,8 @@ if ($fetchClients) {
|
||||
}
|
||||
|
||||
if ($translations) {
|
||||
$result = [];
|
||||
|
||||
$rows = $pdo->query("
|
||||
SELECT q.defaultText AS stringKey, qt.languageCode, qt.text
|
||||
FROM question_translation qt
|
||||
JOIN question q ON q.questionID = qt.questionID
|
||||
")->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($rows as $r) {
|
||||
$result[$r['languageCode']][$r['stringKey']] = $r['text'];
|
||||
}
|
||||
|
||||
$rows = $pdo->query("
|
||||
SELECT ao.defaultText AS stringKey, aot.languageCode, aot.text
|
||||
FROM answer_option_translation aot
|
||||
JOIN answer_option ao ON ao.answerOptionID = aot.answerOptionID
|
||||
")->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($rows as $r) {
|
||||
$result[$r['languageCode']][$r['stringKey']] = $r['text'];
|
||||
}
|
||||
|
||||
$rows = $pdo->query("SELECT stringKey, languageCode, text FROM string_translation")->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($rows as $r) {
|
||||
$result[$r['languageCode']][$r['stringKey']] = $r['text'];
|
||||
}
|
||||
|
||||
qdb_discard($tmpDb, $lockFp);
|
||||
json_success(["translations" => $result]);
|
||||
json_success(['translations' => qdb_build_app_translations_map($pdo)]);
|
||||
}
|
||||
|
||||
if ($qnID) {
|
||||
@ -311,7 +286,11 @@ if ($qnID) {
|
||||
}
|
||||
|
||||
qdb_discard($tmpDb, $lockFp);
|
||||
json_success(["meta" => ["id" => $qnID], "questions" => $questions]);
|
||||
json_success([
|
||||
'meta' => ['id' => $qnID],
|
||||
'questions' => $questions,
|
||||
'translations' => qdb_build_questionnaire_translations_map($pdo, $qnID),
|
||||
]);
|
||||
}
|
||||
|
||||
// Default: ordered questionnaire list
|
||||
|
||||
Reference in New Issue
Block a user