Skip to content

Commit

Permalink
Merge pull request #841 from BIDMCDigitalPsychiatry/portal-update
Browse files Browse the repository at this point in the history
Portal update
  • Loading branch information
sarithapillai8 authored Nov 20, 2024
2 parents 7e2f4ff + aece2dc commit eb8ad07
Show file tree
Hide file tree
Showing 9 changed files with 16,249 additions and 32,254 deletions.
48,391 changes: 16,169 additions & 32,222 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"jsonata": "^1.8.4",
"jsonexport": "^3.2.0",
"jspdf": "^2.3.1",
"lamp-core": "^2024.10.16",
"lamp-core": "2022.3.8",
"material-icons": "^1.10.11",
"monaco-editor": "^0.33.0",
"notistack": "^2.0.5",
Expand Down
6 changes: 3 additions & 3 deletions src/components/ActivityPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ const useStyles = makeStyles((theme: Theme) =>
},
closeButton: {
position: "absolute",
right: theme.spacing(1),
top: theme.spacing(1),
right: 0,
top: 0,
color: theme.palette.grey[500],
},
dialogueStyle: {
Expand Down Expand Up @@ -149,7 +149,7 @@ const useStyles = makeStyles((theme: Theme) =>
},
},
dialogtitle: { padding: 0 },
dialogueCurve: { borderRadius: 10, maxWidth: 400 },
dialogueCurve: { borderRadius: 10, maxWidth: 400, minWidth: 325 },
niceWork: {
"& h5": { fontSize: 25, fontWeight: 600, color: "rgba(0, 0, 0, 0.75)" },
},
Expand Down
52 changes: 29 additions & 23 deletions src/components/PreventSelectedActivities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,33 @@ const useStyles = makeStyles((theme: Theme) =>

export const strategies = {
"lamp.survey": (slices, activity, scopedItem) =>
(slices ?? [])
.filter((x, idx) => (scopedItem !== undefined ? idx === scopedItem : true))
.map((x, idx) => {
let question = (Array.isArray(activity.settings) ? activity.settings : []).filter((y) => y.text === x.item)[0]
if (!!question && typeof x?.value !== "undefined")
return ["Yes", "True"].includes(x.value) ? 1 : ["No", "False"].includes(x.value) ? 0 : Number(x.value) || 0
else if (!!question && !!!question.options) return Math.max((question.options || []).indexOf(x.value), 0)
else if (typeof x?.value !== "number" && typeof x?.value !== "string") {
let sum = 0
Object.keys(x.value || []).map((val) => {
if (!!x.value[val]?.value && x.value[val]?.value.length > 0) {
sum += (x.value[val]?.value || [])
.map((elt) => {
// assure the value can be converted into an integer
return !isNaN(Number(elt)) ? Number(elt) : 0
})
.reduce((sum, current) => sum + current)
}
})
return sum
} else return Number(x?.value) || 0
})
.reduce((prev, curr) => prev + curr, 0),
(slices || []).map((x) => x.duration).reduce((prev, cur) => prev + cur, 0) / slices.length / 1000,

// (slices ?? [])
// .filter((x, idx) => (scopedItem !== undefined ? idx === scopedItem : true))
// .map((x, idx) => {
// console.log(slices)

// let question = (Array.isArray(activity.settings) ? activity.settings : []).filter((y) => y.text === x.item)[0]
// if (!!question && typeof x?.value !== "undefined")
// return ["Yes", "True"].includes(x.value) ? 1 : ["No", "False"].includes(x.value) ? 0 : Number(x.value) || 0
// else if (!!question && !!!question.options) return Math.max((question.options || []).indexOf(x.value), 0)
// else if (typeof x?.value !== "number" && typeof x?.value !== "string") {
// let sum = 0
// Object.keys(x.value || []).map((val) => {
// if (!!x.value[val]?.value && x.value[val]?.value.length > 0) {
// sum += (x.value[val]?.value || [])
// .map((elt) => {
// // assure the value can be converted into an integer
// return !isNaN(Number(elt)) ? Number(elt) : 0
// })
// .reduce((sum, current) => sum + current)
// }
// })
// return sum
// } else return Number(x?.value) || 0
// })
// .reduce((prev, curr) => prev + curr, 0),

"lamp.spin_wheel": (slices, activity, scopedItem) => slices[slices.length - 1]?.type ?? 0,
"lamp.jewels_a": (slices, activity, scopedItem) =>
Expand Down Expand Up @@ -250,6 +254,8 @@ export const strategies = {
},
"lamp.cats_and_dogs": (slices, activity, scopedItem) => (slices.correct_answers / slices.total_questions) * 100,
"lamp.memory_game": (slices, activity, scopedItem) => (slices.correct_answers / slices.total_questions) * 100,
"lamp.simple_memory": (slices, activity, scopedItem) =>
(slices.number_of_correct_pairs_recalled / slices.number_of_total_pairs) * 100,
"lamp.scratch_image": (slices, activity, scopedItem) =>
((parseInt(slices?.duration ?? 0) / 1000).toFixed(1) || 0) > 100
? 100
Expand Down
2 changes: 1 addition & 1 deletion src/components/Researcher/ActivityList/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export const games = [
"lamp.balloon_risk",
"lamp.spin_wheel",
"lamp.maze_game",
"lamp.simple_memory",
"lamp.emotion_recognition",
"lamp.symbol_digit_substitution",
"lamp.gyroscope",
"lamp.dcog",
"lamp.simple_memory",
]

const useStyles = makeStyles((theme: Theme) =>
Expand Down
42 changes: 42 additions & 0 deletions src/components/Researcher/ActivityList/ActivityMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,48 @@ export const SchemaList = () => {
},
},
},
"lamp.simple_memory": {
type: "object",
properties: {
settings: {
title: i18n.t("Activity Settings"),
type: "object",
required: ["delayBeforeRecall", "numberOfTrials", "imageExposureTime"],
properties: {
delayBeforeRecall: {
title: i18n.t("Delay before recall"),
description: i18n.t("Minutes"),
type: "number",
enum: [1, 2, 3, 5],
enumNames: [i18n.t("1"), i18n.t("2"), i18n.t("3"), i18n.t("5")],
"ui:grid": {
xs: 4,
},
},
numberOfTrials: {
title: i18n.t("Number of Learning trials"),
type: "number",
enum: [1, 2, 3],
enumNames: [i18n.t("1"), i18n.t("2"), i18n.t("3")],
"ui:grid": {
xs: 4,
},
},
imageExposureTime: {
title: i18n.t("Image Exposure Time"),
description: i18n.t("Seconds"),
type: "number",
enum: [2, 5],
enumNames: [i18n.t("2"), i18n.t("5")],
default: 2,
"ui:grid": {
xs: 4,
},
},
},
},
},
},
"lamp.pop_the_bubbles": {
type: "object",
properties: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Researcher/ActivityList/AddActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Link,
} from "@material-ui/core"

import LAMP, { ActivitySpec } from "lamp-core"
import LAMP from "lamp-core"
import { useTranslation } from "react-i18next"

const useStyles = makeStyles((theme: Theme) =>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Researcher/ActivityList/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export const availableActivitySpecs = [
"lamp.balloon_risk",
"lamp.recording",
"lamp.spin_wheel",
"lamp.simple_memory",
"lamp.maze_game",
"lamp.emotion_recognition",
"lamp.symbol_digit_substitution",
"lamp.simple_memory",
]
export const games = [
"lamp.jewels_a",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Sparkline.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Core Imports
import React, { useState, useCallback } from "react"
import React, { useState, useCallback, useEffect } from "react"
import { useMediaQuery, useTheme } from "@material-ui/core"
import { Vega } from "react-vega"
import { Handler } from "vega-tooltip"
Expand Down Expand Up @@ -102,7 +102,7 @@ export default function Sparkline({ ...props }) {
},
encoding: {
x: { field: "x", type: "ordinal", timeUnit: "yearmonthdate" },
y: { field: "y", type: "quantitative" },
y: { field: "y", type: "ordinal" },
strokeWidth: { value: 2 },
tooltip: [
{
Expand Down

0 comments on commit eb8ad07

Please sign in to comment.