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