Skip to content

Commit

Permalink
swtich from survey-jquery to survey-knockout-ui, remove outdated imports
Browse files Browse the repository at this point in the history
  • Loading branch information
becky-gilbert committed Apr 23, 2024
1 parent 98dcaca commit 9fda752
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 27 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/plugin-survey/css/survey.scss
@@ -1,4 +1,4 @@
@use "survey-jquery/defaultV2.min.css";
@use "survey-core/defaultV2.min.css";

// move buttons to right (couldn't figure out a way to do this with the SurveyJS class name map
div#sv-nav-complete.sv-action, div#sv-nav-next.sv-action {
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-survey/package.json
Expand Up @@ -50,8 +50,7 @@
"sass": "^1.43.5"
},
"dependencies": {
"jquery": "^3.7.1",
"survey-core": "^1.9.138",
"survey-jquery": "^1.9.138"
"survey-knockout-ui": "^1.9.139"
}
}
16 changes: 7 additions & 9 deletions packages/plugin-survey/src/index.ts
@@ -1,10 +1,6 @@
// import SurveyJS dependencies: survey-core and survey-jquery (UI theme): https://surveyjs.io/documentation/surveyjs-architecture#surveyjs-packages
import $ from "jquery";
// import SurveyJS dependencies: survey-core and survey-knockout-ui (UI theme): https://surveyjs.io/documentation/surveyjs-architecture#surveyjs-packages
import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
import { StylesManager } from "survey-core";
// TO DO: decide whether to apply this theme or remove it
import { PlainLightPanelless } from "survey-core/themes/plain-light-panelless";
import * as SurveyJS from "survey-jquery";
import * as SurveyJS from "survey-knockout-ui";

const info = <const>{
name: "survey",
Expand Down Expand Up @@ -76,7 +72,7 @@ const jsPsychSurveyCssClassMap = {
*/
class SurveyPlugin implements JsPsychPlugin<Info> {
static info = info;
private survey: $.Survey;
private survey: SurveyJS.Survey;
private start_time: number;

constructor(private jsPsych: JsPsych) {
Expand All @@ -87,6 +83,8 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
// TO DO: this method of applying custom styles is deprecated, but I'm
// saving this here for reference while we make decisions about default style

// import { StylesManager } from "survey-core";

// const colors = StylesManager.ThemeColors["default"];

// colors["$background-dim"] = "#f3f3f3";
Expand Down Expand Up @@ -157,7 +155,7 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
"Survey plugin: you must define the survey using a non-empty JSON object and/or a survey function."
);
}
this.survey = new SurveyJS.Model(trial.survey_json);
this.survey = new SurveyJS.Survey(trial.survey_json);

if (trial.survey_function !== null) {
trial.survey_function(this.survey);
Expand Down Expand Up @@ -197,7 +195,7 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
// remove flex display from jspsych-content-wrapper to get formatting to work
document.querySelector<HTMLElement>(".jspsych-content-wrapper").style.display = "block";

$(display_element).Survey({ model: this.survey });
this.survey.render(display_element);

this.start_time = performance.now();
}
Expand Down

0 comments on commit 9fda752

Please sign in to comment.