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