err
This commit is contained in:
parent
dbf90f8028
commit
b4df394e29
|
@ -1,5 +1,10 @@
|
||||||
export type CheckPoint = {
|
export type CheckPoint = {
|
||||||
$id: string
|
$id: string
|
||||||
|
$collectionId: string
|
||||||
|
$createdAt: string
|
||||||
|
$databaseId: string
|
||||||
|
$permissions: string
|
||||||
|
$updatedAt: string
|
||||||
CPAfter: string
|
CPAfter: string
|
||||||
CPAnswerID: string
|
CPAnswerID: string
|
||||||
CPHint: string
|
CPHint: string
|
||||||
|
@ -13,6 +18,12 @@ export type CheckPoint = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Experience = {
|
export type Experience = {
|
||||||
|
$id: string
|
||||||
|
$collectionId: string
|
||||||
|
$createdAt: string
|
||||||
|
$databaseId: string
|
||||||
|
$permissions: string
|
||||||
|
$updatedAt: string
|
||||||
ExpApproved: boolean
|
ExpApproved: boolean
|
||||||
ExpCpsID: string[]
|
ExpCpsID: string[]
|
||||||
ExpCategory?: string
|
ExpCategory?: string
|
||||||
|
@ -27,5 +38,5 @@ export type Experience = {
|
||||||
ExpTestingCode: string
|
ExpTestingCode: string
|
||||||
ExpURL: string
|
ExpURL: string
|
||||||
UserID: string
|
UserID: string
|
||||||
checkPoint: Array<CheckPoint>
|
checkPoints: Array<CheckPoint>
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,17 @@
|
||||||
|
|
||||||
let className = ''
|
let className = ''
|
||||||
export { className as class }
|
export { className as class }
|
||||||
|
/*;(() => {
|
||||||
|
navigator.geolocation.getCurrentPosition(() => {
|
||||||
|
navigator.geolocation.watchPosition((e) => {
|
||||||
|
console.log(e)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})()*/
|
||||||
|
navigator.geolocation.getCurrentPosition((e) => {})
|
||||||
|
|
||||||
if (navigator.geolocation) {
|
/* if (navigator.geolocation) {
|
||||||
navigator.geolocation.getCurrentPosition(showPosition, () => dispatch('locationFailed'))
|
navigator.geolocation.watchPosition(showPosition, () => dispatch('locationFailed'))
|
||||||
} else {
|
} else {
|
||||||
alert("Can't load your location!")
|
alert("Can't load your location!")
|
||||||
}
|
}
|
||||||
|
@ -23,14 +31,16 @@
|
||||||
user.lat = position.coords.latitude
|
user.lat = position.coords.latitude
|
||||||
user.lng = position.coords.longitude
|
user.lng = position.coords.longitude
|
||||||
if (!center) center = user
|
if (!center) center = user
|
||||||
}
|
}*/
|
||||||
|
|
||||||
const userCenter = () => document.getElementsByClassName('mapboxgl-ctrl-geolocate')[0].click()
|
const userCenter = () => {
|
||||||
|
document.getElementsByClassName('mapboxgl-ctrl-geolocate')[0].click()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<NavigationBarLayout>
|
<NavigationBarLayout>
|
||||||
{#if center}
|
{#if center}
|
||||||
<Map on:ready={() => setTimeout(() => userCenter(), 40)} {center} bind:mapComponent class={className} on:move>
|
<Map on:ready={() => setTimeout(() => setInterval(() => userCenter(), 1000), 100)} {center} bind:mapComponent class={className} on:move>
|
||||||
<slot />
|
<slot />
|
||||||
<GeolocateControl
|
<GeolocateControl
|
||||||
on:geolocate={(e) => {
|
on:geolocate={(e) => {
|
||||||
|
|
|
@ -3,29 +3,32 @@ import { Query } from 'appwrite'
|
||||||
import database from 'svelte-appwrite-client/src/lib/database'
|
import database from 'svelte-appwrite-client/src/lib/database'
|
||||||
import { getLocationDataFromLatAndLong } from '../locations'
|
import { getLocationDataFromLatAndLong } from '../locations'
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { Experience } from '$lib/TStypes/experiences'
|
import { CheckPoint, Experience } from '$lib/TStypes/experiences'
|
||||||
|
|
||||||
export const load = async (pathName: string, previewQuestionsCount?: number, preview?: Function) => {
|
export const load = async (pathName: string, previewQuestionsCount?: number, preview?: Function) => {
|
||||||
const checkPoints = []
|
const checkPoints: Array<CheckPoint> = []
|
||||||
const game = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpURL', pathName)])).documents[0]
|
// @ts-ignore
|
||||||
|
const experience: Experience = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpURL', pathName)])).documents[0]
|
||||||
|
|
||||||
const checkPointsIds = game.ExpCPsID
|
const checkPointsIds = experience.ExpCpsID
|
||||||
const rating = await getRating(game.$id)
|
const rating = await getRating(experience.$id)
|
||||||
|
|
||||||
for (const checkPointId of checkPointsIds) {
|
for (const checkPointId of checkPointsIds) {
|
||||||
try {
|
try {
|
||||||
|
// @ts-ignore
|
||||||
checkPoints.push(await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId))
|
checkPoints.push(await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId))
|
||||||
if (checkPointsIds.indexOf(checkPointId) === previewQuestionsCount - 1) {
|
if (checkPointsIds.indexOf(checkPointId) === previewQuestionsCount - 1) {
|
||||||
game['rating'] = rating
|
experience['rating'] = rating
|
||||||
game['checkPoints'] = checkPoints
|
experience['checkPoints'] = checkPoints
|
||||||
preview(game)
|
preview(experience)
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
game['rating'] = rating
|
experience['rating'] = rating
|
||||||
game['checkPoints'] = checkPoints
|
experience['checkPoints'] = checkPoints
|
||||||
return game
|
|
||||||
|
return experience
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRating = async (expId: string) => {
|
const getRating = async (expId: string) => {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
const { checkPoint, name } = data
|
const { checkPoint, name } = data
|
||||||
|
|
||||||
export let nextQuestion
|
export let nextQuestion
|
||||||
|
export const control: 'wrong-firstTime' | 'wrong-secondTime' | 'correct' | 'not-control' | null = 'not-control'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Layout
|
<Layout
|
||||||
|
@ -20,4 +21,4 @@
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
</style>
|
</style>
|
|
@ -33,12 +33,11 @@
|
||||||
navigate('/error')
|
navigate('/error')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$: console.log($data)
|
|
||||||
|
|
||||||
$: assets = $data?.questions
|
/*$: assets = $data?.questions
|
||||||
?.filter((q) => q.thumbnail !== null)
|
?.filter((q) => q.thumbnail !== null)
|
||||||
?.slice(0, 8)
|
?.slice(0, 8)
|
||||||
?.map((q) => q.thumbnail)
|
?.map((q) => q.thumbnail)*/
|
||||||
|
|
||||||
let view: 'game-play' | 'game-loading' | 'game-preview' = 'game-loading'
|
let view: 'game-play' | 'game-loading' | 'game-preview' = 'game-loading'
|
||||||
|
|
||||||
|
@ -113,4 +112,4 @@
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue