Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,27 +249,21 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa
if (answerMap.containsKey(q.serverId)) {
answer = answerMap[q.serverId]
try {
answer = q.clean_answer(answer, q.options, false)
val jo = JSONObject()
jo.put("answer", answer)
jo.put("question", q.serverId)
jo.put("question", q.serverId) // server expects question server_id here
if (q.askDuringCheckIn) {
givenAnswers.put(jo)
}
if (q.showDuringCheckIn) {
shownAnswers.add(TicketCheckProvider.QuestionAnswer(q, questionJson, answer))
}
} catch (e: QuestionLike.ValidationException) {
answer = ""
if (q.askDuringCheckIn) {
askQuestions = true
}
} catch (e: JSONException) {
} catch (_: JSONException) {
answer = ""
if (q.askDuringCheckIn) {
askQuestions = true
}
}
if (q.showDuringCheckIn) {
shownAnswers.add(TicketCheckProvider.QuestionAnswer(q, questionJson, answer))
}
} else {
if (q.askDuringCheckIn) {
askQuestions = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class OnlineCheckProvider(
}
}
}
res.shownAnswers = shownAnswers
res.shownAnswers = shownAnswers.sortedBy { it.question.position }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ private fun parseAnswersWithOptionIds(json: JSONObject): Map<Long, String>? {
val res: MutableMap<Long, String> = HashMap()
for (i in 0 until arr.length()) {
val a = arr.getJSONObject(i)
val opts = a.getJSONArray("options")
if (opts.length() > 0) {
val opts = a.optJSONArray("options")
if (opts != null && opts.length() > 0) {
val aw = StringBuilder()
for (j in 0 until opts.length()) {
if (aw.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ WHERE Question.id IN (
SELECT Question_Item.QuestionId
FROM Question_Item
WHERE Question_Item.ItemId = :item_id
);
)
ORDER BY Question.position ASC;

selectByServerIdListAndEventSlug:
SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.util.ArrayList

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Ignore

class AsyncCheckProviderTest : BaseDatabaseTest() {
private var configStore: FakeConfigStore? = null
Expand Down Expand Up @@ -959,7 +960,7 @@ class AsyncCheckProviderTest : BaseDatabaseTest() {
assertEquals("[{\"answer\":\"True\",\"question\":1}]", qciList[0].answers)
}

@Test
@Test @Ignore("Validation happens in the question dialog already, validation dropped from checkin itself")
fun testQuestionsInvalidInput() {
QuestionSyncAdapter(db, FakeFileStorage(), "demo", fakeApi!!, "", null).standaloneRefreshFromJSON(
jsonResource("questions/question2.json")
Expand All @@ -971,7 +972,7 @@ class AsyncCheckProviderTest : BaseDatabaseTest() {
val ra = r.requiredAnswers!![0]

val answers = ArrayList<Answer>()
answers.add(Answer(ra.question.toModel(), "True"))
answers.add(Answer(ra.question.toModel(), "True")) // should be a number

r = p!!.check(mapOf("demo" to 1L), "kfndgffgyw4tdgcacx6bb3bgemq69cxj", "barcode", answers, false, false, TicketCheckProvider.CheckInType.ENTRY)
assertEquals(TicketCheckProvider.CheckResult.Type.ANSWERS_REQUIRED, r.type)
Expand Down
5 changes: 4 additions & 1 deletion libpretixsync/src/testFixtures/resources/orders/order4.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
"answers": [
{
"question": 1,
"answer": "True"
"answer": "True",
"question_identifier": "AAAABBBC",
"options": [],
"option_identifiers": []
}
],
"tax_rule": null,
Expand Down
Loading