mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
initial commit for plugin-free-sort-ordered
This commit is contained in:
parent
861cd1e646
commit
7e1b0f2df5
41
packages/plugin-free-sort-ordered/CITATION.cff
Normal file
41
packages/plugin-free-sort-ordered/CITATION.cff
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
cff-version: 1.2.0
|
||||||
|
message: "If you use this software, please cite it as below."
|
||||||
|
authors:
|
||||||
|
- family-names: "Cherrie Chang" # Replace with last name
|
||||||
|
given-names: "Cherrie Chang" # Replace with first name
|
||||||
|
name-particle: "Cherrie Chang" # Replace with name particle(s)
|
||||||
|
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID
|
||||||
|
# More authors can be listed here in the same format as above
|
||||||
|
contact: # Contact person for this extension
|
||||||
|
- family-names: "Cherrie Chang"
|
||||||
|
given-names: "Cherrie Chang"
|
||||||
|
email: "{email}" # Replace with contact person's email
|
||||||
|
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID
|
||||||
|
title: "jsPsychPluginFreeSortOrdered"
|
||||||
|
version: 0.0.0
|
||||||
|
doi: 10.5281/zenodo.1234 # Replace with DOI
|
||||||
|
date-released: 2000-01-01
|
||||||
|
url: "{softwareUrl}" # Replace with URL to this extension
|
||||||
|
|
||||||
|
# If you wish to cite a paper on this extension instead, you can use the following template:
|
||||||
|
preferred-citation:
|
||||||
|
authors:
|
||||||
|
- family-names: "Cherrie Chang"
|
||||||
|
given-names: "Cherrie Chang"
|
||||||
|
name-particle: "Cherrie Chang"
|
||||||
|
orcid: "https://orcid.org/0000-0000-0000-0000"
|
||||||
|
# More authors can be listed here in the same format as above
|
||||||
|
date-published: 2023-05-11
|
||||||
|
doi: 10.21105/joss.12345
|
||||||
|
issn: 1234-5678
|
||||||
|
issue: 01
|
||||||
|
journal: Journal for Open Source Software
|
||||||
|
publisher:
|
||||||
|
name: Open Journals
|
||||||
|
start: 0001
|
||||||
|
title: "{title}"
|
||||||
|
type: article # Other options include: book, pamphlet, conference-paper...
|
||||||
|
url: "{linkToPublicationInJournal}"
|
||||||
|
volume: 1
|
||||||
|
|
||||||
|
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software
|
21
packages/plugin-free-sort-ordered/README.md
Normal file
21
packages/plugin-free-sort-ordered/README.md
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# plugin-free-sort-ordered
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The free sort core plugin, but the images have to be sorted by placing into ordered boxes.
|
||||||
|
|
||||||
|
## Loading
|
||||||
|
|
||||||
|
*Enter instructions for loading the plugin package here.*
|
||||||
|
|
||||||
|
## Compatibility
|
||||||
|
|
||||||
|
`plugin-free-sort-ordered` requires jsPsych v8.0.0 or later.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
See [documentation](/packages/plugin-free-sort-ordered/README.md)
|
||||||
|
|
||||||
|
## Author / Citation
|
||||||
|
|
||||||
|
[Cherrie Chang](https://github.com/cherriechang)
|
@ -0,0 +1,33 @@
|
|||||||
|
# plugin-free-sort-ordered
|
||||||
|
|
||||||
|
The free sort core plugin, but the images have to be sorted by placing into ordered boxes.
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
In addition to the [parameters available in all plugins](https://www.jspsych.org/latest/overview/plugins#parameters-available-in-all-plugins), this plugin accepts the following parameters. Parameters with a default value of undefined must be specified. Other parameters can be left unspecified if the default value is acceptable.
|
||||||
|
|
||||||
|
| Parameter | Type | Default Value | Description |
|
||||||
|
| ------------------- | ---------------- | ------------------ | ---------------------------------------- |
|
||||||
|
| | | | |
|
||||||
|
|
||||||
|
## Data Generated
|
||||||
|
|
||||||
|
In addition to the [default data collected by all plugins](https://www.jspsych.org/latest/overview/plugins#data-collected-by-all-plugins), this plugin collects the following data for each trial.
|
||||||
|
|
||||||
|
| Name | Type | Value |
|
||||||
|
| --------- | ------- | ---------------------------------------- |
|
||||||
|
| | | |
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
*Enter instructions for installing the plugin package here.*
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Title of Example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var trial = {
|
||||||
|
type: jsPsychPluginFreeSortOrdered
|
||||||
|
}
|
||||||
|
```
|
25
packages/plugin-free-sort-ordered/examples/index.html
Normal file
25
packages/plugin-free-sort-ordered/examples/index.html
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>jsPsychPluginFreeSortOrdered Example</title>
|
||||||
|
<script src="https://unpkg.com/jspsych"></script>
|
||||||
|
<!-- Load the published plugin package here, e.g.
|
||||||
|
<script src="https://unpkg.com/plugin-free-sort-ordered"></script>
|
||||||
|
<script src="../dist/index.global.js"></script> -->
|
||||||
|
<script src="../dist/index.global.js"></script>
|
||||||
|
<link rel="stylesheet" href="https://unpkg.com/jspsych/css/jspsych.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body></body>
|
||||||
|
<script>
|
||||||
|
const jsPsych = initJsPsych();
|
||||||
|
|
||||||
|
const trial = {
|
||||||
|
type: jsPsychPluginFreeSortOrdered
|
||||||
|
};
|
||||||
|
|
||||||
|
jsPsych.run([trial])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</html>
|
1
packages/plugin-free-sort-ordered/jest.config.cjs
Normal file
1
packages/plugin-free-sort-ordered/jest.config.cjs
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@jspsych/config/jest").makePackageConfig(__dirname);
|
53
packages/plugin-free-sort-ordered/package.json
Normal file
53
packages/plugin-free-sort-ordered/package.json
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
{
|
||||||
|
"name": "plugin-free-sort-ordered",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"description": "The free sort core plugin, but the images have to be sorted by placing into ordered boxes.",
|
||||||
|
"type": "module",
|
||||||
|
"main": "dist/index.cjs",
|
||||||
|
"exports": {
|
||||||
|
"import": "./dist/index.js",
|
||||||
|
"require": "./dist/index.cjs"
|
||||||
|
},
|
||||||
|
"typings": "dist/index.d.ts",
|
||||||
|
"unpkg": "dist/index.browser.min.js",
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"source": "src/index.ts",
|
||||||
|
"scripts": {
|
||||||
|
"test": "jest",
|
||||||
|
"test:watch": "npm test -- --watch",
|
||||||
|
"tsc": "tsc",
|
||||||
|
"build": "rollup --config",
|
||||||
|
"build:watch": "npm run build -- --watch"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/jspsych/jsPsych.git",
|
||||||
|
"directory": ""
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"jsPsych"
|
||||||
|
],
|
||||||
|
"author": {
|
||||||
|
"name": "Cherrie Chang",
|
||||||
|
"url": "https://github.com/cherriechang"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jspsych/jsPsych/issues"
|
||||||
|
},
|
||||||
|
"homepage": "/packages/plugin-free-sort-ordered/README.md",
|
||||||
|
"dependencies": {
|
||||||
|
"jspsych": "^8.0.0",
|
||||||
|
"@citation-js/core": "^0.7.14",
|
||||||
|
"@citation-js/plugin-software-formats": "^0.6.1",
|
||||||
|
"@citation-js/plugin-bibtex": "^0.7.14",
|
||||||
|
"@citation-js/plugin-cff": "^0.6.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@jspsych/config": "^3.2.2",
|
||||||
|
"@jspsych/test-utils": "^1.0.0"
|
||||||
|
}
|
||||||
|
}
|
3
packages/plugin-free-sort-ordered/rollup.config.mjs
Normal file
3
packages/plugin-free-sort-ordered/rollup.config.mjs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { makeRollupConfig } from "@jspsych/config/rollup";
|
||||||
|
|
||||||
|
export default makeRollupConfig("jsPsychPluginFreeSortOrdered");
|
19
packages/plugin-free-sort-ordered/src/index.spec.ts
Normal file
19
packages/plugin-free-sort-ordered/src/index.spec.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { startTimeline } from "@jspsych/test-utils";
|
||||||
|
|
||||||
|
import jsPsychPluginFreeSortOrdered from ".";
|
||||||
|
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
|
describe("my plugin", () => {
|
||||||
|
it("should load", async () => {
|
||||||
|
const { expectFinished, getHTML, getData, displayElement, jsPsych } = await startTimeline([
|
||||||
|
{
|
||||||
|
type: jsPsychPluginFreeSortOrdered,
|
||||||
|
parameter_name: 1,
|
||||||
|
parameter_name2: "img.png",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
await expectFinished();
|
||||||
|
});
|
||||||
|
});
|
71
packages/plugin-free-sort-ordered/src/index.ts
Normal file
71
packages/plugin-free-sort-ordered/src/index.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
|
||||||
|
|
||||||
|
import { version } from "../package.json";
|
||||||
|
|
||||||
|
const info = <const>{
|
||||||
|
name: "plugin-free-sort-ordered",
|
||||||
|
version: version,
|
||||||
|
parameters: {
|
||||||
|
/** Each element of this array is an image path or svg code. */
|
||||||
|
stimuli: {
|
||||||
|
type: ParameterType.INT | ParameterType.HTML_STRING,
|
||||||
|
default: undefined,
|
||||||
|
array: true,
|
||||||
|
},
|
||||||
|
/** The height of the images in pixels */
|
||||||
|
stim_height: {
|
||||||
|
type: ParameterType.INT,
|
||||||
|
default: 100,
|
||||||
|
},
|
||||||
|
/** The width of the images in pixels */
|
||||||
|
stim_width: {
|
||||||
|
type: ParameterType.INT,
|
||||||
|
default: 100,
|
||||||
|
},
|
||||||
|
/** How much larger to make the stimulus while moving (1 = no scaling). */
|
||||||
|
scale_factor: {
|
||||||
|
type: ParameterType.FLOAT,
|
||||||
|
default: 1.5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
/** Provide a clear description of the data1 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
|
||||||
|
data1: {
|
||||||
|
type: ParameterType.INT,
|
||||||
|
},
|
||||||
|
/** Provide a clear description of the data2 that could be used as documentation. We will eventually use these comments to automatically build documentation and produce metadata. */
|
||||||
|
data2: {
|
||||||
|
type: ParameterType.STRING,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// When you run build on your plugin, citations will be generated here based on the information in the CITATION.cff file.
|
||||||
|
citations: "__CITATIONS__",
|
||||||
|
};
|
||||||
|
|
||||||
|
type Info = typeof info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* **plugin-free-sort-ordered**
|
||||||
|
*
|
||||||
|
* The free sort core plugin, but the images have to be sorted by placing into ordered boxes.
|
||||||
|
*
|
||||||
|
* @author Cherrie Chang
|
||||||
|
* @see {@link /packages/plugin-free-sort-ordered/README.md}}
|
||||||
|
*/
|
||||||
|
class FreeSortOrderedPlugin implements JsPsychPlugin<Info> {
|
||||||
|
static info = info;
|
||||||
|
|
||||||
|
constructor(private jsPsych: JsPsych) {}
|
||||||
|
|
||||||
|
trial(display_element: HTMLElement, trial: TrialType<Info>) {
|
||||||
|
// data saving
|
||||||
|
var trial_data = {
|
||||||
|
data1: 99, // Make sure this type and name matches the information for data1 in the data object contained within the info const.
|
||||||
|
data2: "hello world!", // Make sure this type and name matches the information for data2 in the data object contained within the info const.
|
||||||
|
};
|
||||||
|
// end trial
|
||||||
|
this.jsPsych.finishTrial(trial_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FreeSortOrderedPlugin;
|
9
packages/plugin-free-sort-ordered/tsconfig.json
Normal file
9
packages/plugin-free-sort-ordered/tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "@jspsych/config/tsconfig.contrib.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user