Skip to content

Commit

Permalink
James feeling thermometer updates (#194)
Browse files Browse the repository at this point in the history
* update feeling thermometer text

* fix slider over anchoring

* update test

* Update scoring and labels

* Update package.json

* merge main

* Delete screenshot.png

* update screenshots
  • Loading branch information
JamesPHoughton authored Sep 16, 2024
1 parent 6a284ea commit 333111b
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 95 deletions.
Binary file removed cypress/screenshots/rmetTen/screenshot.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@watts-lab/surveys",
"version": "1.17.4",
"version": "1.17.5",
"description": "",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
Binary file modified surveys/TIPI/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/bipartisanshipUS/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions surveys/rmeTen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Reading the Mind in the Eye

This is a ten-item version of the Reading the Mind in the Eyes test.

Items are taken from:

Chander, Russell J., Sarah A. Grainger, John D. Crawford, Karen A. Mather, Katya Numbers, Rhiagh Cleary, Nicole A. Kochan, Henry Brodaty, Julie D. Henry, and Perminder S. Sachdev. 2020. “Development of a Short-Form Version of the Reading the Mind in the Eyes Test for Assessing Theory of Mind in Older Adults.” International Journal of Geriatric Psychiatry 35 (11): 1322–30.

10 item version, in model 3:

![alt text](chandler_fig3.png)
Binary file added surveys/rmeTen/chandler_fig3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
142 changes: 93 additions & 49 deletions surveys/rmeTen/rmeTen.cy.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import React from "react";
import { RmeTen } from "../../src/index";

const surveyJsonPath = "surveys/rmeTen/rmeTen.json";

// Initialize an empty answers object
const answers = {};

const dummy = {
set(response) {},
};
Expand All @@ -16,57 +11,106 @@ describe("RMETTen", () => {
cy.mount(<RmeTen onComplete={dummy.set} />);
cy.viewport("macbook-11");

cy.readFile(surveyJsonPath).then((surveyJson) => {
// Build the answers object by assuming each question's answer is the first choice
surveyJson.pages.forEach((page) => {
page.elements.forEach((element) => {
if (element.type === "radiogroup") {
answers[element.name] = element.choices[0].value;
}
});
});
// incorrect
cy.get('[data-name="rme_item_4"] input[value="amused"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_1`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// correct
cy.get('[data-name="rme_item_6"] input[value="fantasizing"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_2`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// Now iterate over pages to perform the survey
surveyJson.pages.forEach((page, pageIndex) => {
page.elements.forEach((element) => {
if (element.type === "image") {
// Verify the image is present
cy.get("img").should("have.attr", "src", element.imageLink);
} else if (element.type === "radiogroup") {
// Click the radio button corresponding to the question
const answerValue = answers[element.name];
cy.get(
`[data-name="${element.name}"] input[value="${answerValue}"]`
).click({ force: true });
}
});
// incorrect
cy.get('[data-name="rme_item_11"] input[value="terrified"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_3`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

cy.screenshot(`rmeTen/screenshot_${pageIndex}`, {
overwrite: true,
});
// correct
cy.get('[data-name="rme_item_15"] input[value="contemplative"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_4`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// Click "Next" button if not on the last page
if (pageIndex < surveyJson.pages.length - 1) {
cy.get('input[type="button"][value="Next"]').click({ force: true });
}
});
// incorrect
cy.get('[data-name="rme_item_17"] input[value="affectionate"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_5`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

cy.screenshot("rmetTen/screenshot", {
overwrite: true,
});
// correct
cy.get('[data-name="rme_item_22"] input[value="preoccupied"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_6`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// correct
cy.get('[data-name="rme_item_24"] input[value="pensive"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_7`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// incorrect
cy.get('[data-name="rme_item_27"] input[value="joking"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_8`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// correct
cy.get('[data-name="rme_item_28"] input[value="interested"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_9`, {
overwrite: true,
});
cy.get('input[type="button"][value="Next"]').click({ force: true });

// correct
cy.get('[data-name="rme_item_29"] input[value="reflective"]').click({
force: true,
});
cy.screenshot(`rmeTen/screenshot_10`, {
overwrite: true,
});

cy.get("form") // submit surveyJS form
.then(($form) => {
cy.wrap($form.find('input[type="button"][value="Complete"]')).click();
});
// final button
cy.get('input[type="button"][value="Complete"]').click({ force: true });

cy.get(".sv-body").should("not.exist");
cy.get(".sv-body").should("not.exist");

cy.get("@callback").should("have.been.called");
cy.get("@callback").then((spy) => {
const spyCall = spy.getCall(-1).args[0];
console.log(spyCall);
});
cy.get("@callback").should("have.been.called");
cy.get("@callback").then((spy) => {
const spyCall = spy.getCall(-1).args[0];
console.log(spyCall);
expect(spyCall["result"]["normScore"]).to.eq((0.6).toFixed(3));
expect(spyCall["responses"]["rme_item_24"]).to.eq("pensive");
});
});
});
78 changes: 44 additions & 34 deletions surveys/rmeTen/rmeTen.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions surveys/rmeTen/rmeTen.score.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const answers = {
question1: "insisting",
question2: "fantasizing",
question3: "regretful",
question4: "contemplative",
question5: "doubtful",
question6: "preoccupied",
question7: "pensive",
question8: "cautious",
question9: "interested",
question10: "reflective",
rme_item_4: "insisting",
rme_item_6: "fantasizing",
rme_item_11: "regretful",
rme_item_15: "contemplative",
rme_item_17: "doubtful",
rme_item_22: "preoccupied",
rme_item_24: "pensive",
rme_item_27: "cautious",
rme_item_28: "interested",
rme_item_29: "reflective",
};

export default function scoreFunc(responses) {
Expand All @@ -23,5 +23,5 @@ export default function scoreFunc(responses) {
}
});

return { score: score, maxScore: 10, minScore: 0, responses: responses };
return { score: score, normScore: (score / 10).toFixed(3) };
}
Binary file removed surveys/rmeTen/screenshot_0.png
Binary file not shown.
Binary file modified surveys/rmeTen/screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added surveys/rmeTen/screenshot_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified surveys/rmeTen/screenshot_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 333111b

Please sign in to comment.