second-first time answer
This commit is contained in:
parent
36e13a4cd4
commit
ca2e4c87e9
|
@ -11,8 +11,12 @@
|
|||
let isMounted = false
|
||||
$: isReady = $localeLoading === false && $authLoading === false && isMounted
|
||||
|
||||
$: console.log($user)
|
||||
|
||||
$: if (isReady && !$user) {
|
||||
if (!(location.pathname.startsWith('/login') || location.pathname.startsWith('/register'))) {
|
||||
console.log('change')
|
||||
|
||||
if (!location.pathname.startsWith('/login') && !location.pathname.startsWith('/register')) {
|
||||
navigate('/login')
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
import { navigate } from 'svelte-routing'
|
||||
import FooterItem from '../Common/NavBar_Item.svelte'
|
||||
|
||||
$: [userInfo] = collections.users.getDocument([Query.equal('userId', $user.$id)])
|
||||
$: [userInfo] = collections.users.getDocument([Query.equal('userId', $user?.$id || '')])
|
||||
$: console.log($user)
|
||||
|
||||
$: items = [
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ export const answer = async (checkPointId: string, answer: any) => {
|
|||
}
|
||||
|
||||
export const getExpiriences = async () => {
|
||||
const expiriences = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888')).documents
|
||||
const expiriences = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpApproved', true)])).documents
|
||||
let items: Array<{ location: string; name: string; link: string }> = []
|
||||
for (const expirience of expiriences) {
|
||||
items.push({
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import Button from '../../../lib/components/Buttons/Button.svelte'
|
||||
import Image from '../../../lib/components/Common/Image.svelte'
|
||||
|
||||
export let control: null | false | true | 'not-control'
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null
|
||||
export let nextQuestion
|
||||
export let imgSrc
|
||||
</script>
|
||||
|
@ -24,19 +24,21 @@
|
|||
</div>
|
||||
<div class="flex items-center justify-center flex-col w-full gap-6">
|
||||
<span class="relative"> <slot name="answers" /> </span>
|
||||
{#if control !== null || control === 'not-control'}<!--jestli jsem už odpověděl-->
|
||||
<Button on:submit={nextQuestion} primary class="w-3/4 max-w-sm min-w-[400px] h-16 bottom-0 fixed m-10 relative">Na další otázku</Button>
|
||||
{:else}<!--čeká na odpověd, na sejmutí-->
|
||||
<Button on:submit primary class="w-3/4 max-w-sm min-w-[400px] h-16 bottom-0 fixed m-10 relative">Vyhodnotit</Button>
|
||||
{#if control === 'not-control' || control === 'correct' || control === 'wrong-secondTime'}
|
||||
<Button on:submit={nextQuestion} primary class="w-3/4 max-w-sm min-w-[400px] h-16 bottom-0 m-10 relative">Na další otázku</Button>
|
||||
{:else if control === 'wrong-firstTime' || control === null}
|
||||
<Button on:submit primary class="w-3/4 max-w-sm min-w-[400px] h-16 bottom-0 m-10 relative">Vyhodnotit</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full relative bottom-[170px] flex justify-center h-fit size">
|
||||
{#if control === 'not-control' || control === null}
|
||||
<span />
|
||||
{:else if control === true}
|
||||
{:else if control === 'correct'}
|
||||
<span style="color:greenyellow">správně</span>
|
||||
{:else if control === false}
|
||||
{:else if control === 'wrong-firstTime'}
|
||||
<span style="color:red">druhypokus</span>
|
||||
{:else if control === 'wrong-secondTime'}
|
||||
<span style="color:red">špatně</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
|
|
@ -8,14 +8,19 @@
|
|||
const { checkPoint, name } = data
|
||||
let myAnswers = new Array(checkPoint.CPOptions.length).fill(false)
|
||||
|
||||
export let control = null
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null
|
||||
export let nextQuestion
|
||||
export let attempt: 1 | 2 = 1
|
||||
|
||||
const answerCheckBox = async () => {
|
||||
const arr = checkPoint.CPOptions.filter((item, i) => {
|
||||
if (myAnswers[i] === true) return item
|
||||
})
|
||||
control = await answer(checkPoint.$id, arr)
|
||||
const res = await answer(checkPoint.$id, arr)
|
||||
if (res) control = 'correct'
|
||||
else if (attempt === 1) control = 'wrong-firstTime'
|
||||
else control = 'wrong-secondTime'
|
||||
attempt++
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
const { checkPoint, name } = data
|
||||
let myAnswer = ''
|
||||
|
||||
export let control = null
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null
|
||||
export let nextQuestion
|
||||
export let attempt: 1 | 2 = 1
|
||||
|
||||
const answer_ = async () => {
|
||||
control = await answer(checkPoint.$id, myAnswer)
|
||||
const res = await answer(checkPoint.$id, myAnswer)
|
||||
if (res) control = 'correct'
|
||||
else if (attempt === 1) control = 'wrong-firstTime'
|
||||
else control = 'wrong-secondTime'
|
||||
attempt++
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
INFO: Info,
|
||||
}
|
||||
|
||||
let control = null // if true => spravne if false spatne
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null = null
|
||||
let view: 'question' | 'map' | 'end' = 'map'
|
||||
|
||||
export let gameData: any = {} //data
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
$: console.log(clientAnswers.pos === clientAnswers.end + 1)
|
||||
|
||||
$: if (control === true) clientAnswers.points += 2 //body bodování
|
||||
$: if (control === 'correct') clientAnswers.points += 2 //body bodování
|
||||
|
||||
const nextQuestion = () => {
|
||||
//další otázka
|
||||
|
|
|
@ -8,13 +8,16 @@
|
|||
const { checkPoint, name } = data
|
||||
let myAnswer = ''
|
||||
|
||||
$: console.log(data)
|
||||
|
||||
export let control = null
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null
|
||||
export let nextQuestion
|
||||
export let attempt: 1 | 2 = 1
|
||||
|
||||
const answer_ = async () => {
|
||||
control = await answer(checkPoint.$id, myAnswer)
|
||||
const res = await answer(checkPoint.$id, myAnswer)
|
||||
if (res) control = 'correct'
|
||||
else if (attempt === 1) control = 'wrong-firstTime'
|
||||
else control = 'wrong-secondTime'
|
||||
attempt++
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -25,7 +28,7 @@
|
|||
nextQuestion()
|
||||
myAnswer = ''
|
||||
}}
|
||||
on:submit={() => (control = myAnswer !== '' ? answer_() : null)}
|
||||
on:submit={() => (myAnswer !== '' ? answer_() : null)}
|
||||
>
|
||||
<span slot="title">{name}</span>
|
||||
<span slot="about">{@html checkPoint.CPText}</span>
|
||||
|
|
|
@ -8,11 +8,16 @@
|
|||
const { checkPoint, name } = data
|
||||
let myAnswer = ''
|
||||
|
||||
export let control = null
|
||||
export let control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null
|
||||
export let nextQuestion
|
||||
export let attempt: 1 | 2 = 1
|
||||
|
||||
const answer_ = async () => {
|
||||
control = await answer(checkPoint.$id, myAnswer)
|
||||
const res = await answer(checkPoint.$id, myAnswer)
|
||||
if (res) control = 'correct'
|
||||
else if (attempt === 1) control = 'wrong-firstTime'
|
||||
else control = 'wrong-secondTime'
|
||||
attempt++
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
export let purpose = 'login' //possible values login, register
|
||||
|
||||
let email = ''
|
||||
let password = ''
|
||||
let email = 'aaahoj@ahoj.ahoj'
|
||||
let password = 'ahojahoj'
|
||||
|
||||
$: console.log($user)
|
||||
|
||||
const emailLogin = async () => {
|
||||
await account.createEmailSession(email, password)
|
||||
if (navigation.canGoBack) navigation.back()
|
||||
//if (navigation.canGoBack) navigation.back()
|
||||
navigate('/')
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
import { Query } from 'appwrite'
|
||||
|
||||
export let params: { erantId: string }
|
||||
//
|
||||
$: [userInfo] = collections.users.getDocument([Query.equal('erantId', params.erantId)])
|
||||
|
||||
$: console.log($user)
|
||||
|
||||
const items = [
|
||||
{
|
||||
title: 'Account',
|
||||
|
@ -64,7 +67,7 @@
|
|||
{#if typeof link === 'function'}
|
||||
<SettingRow>
|
||||
<svelte:component this={icon} />
|
||||
<button class="font-semibold text-[18px]" on:click={() => link()}>{text}</button>
|
||||
<button class="font-semibold text-[18px]" on:click={link}>{text}</button>
|
||||
</SettingRow>
|
||||
{:else}
|
||||
<SettingRow>
|
||||
|
|
Loading…
Reference in New Issue