Giter Site home page Giter Site logo

surveyjs / surveyjs-wordpress Goto Github PK

View Code? Open in Web Editor NEW
34.0 7.0 18.0 11.31 MB

Example of integration SurveyJS: Survey Library and Survey Creator into WordPress

Home Page: https://wordpress.org/plugins/surveyjs/

PHP 93.69% CSS 2.78% JavaScript 3.53%
wordpress wordpress-plugin form forms survey quiz quiz-generator questionnaire wordpress-development survey-creator

surveyjs-wordpress's Issues

Back button returns user to potentially wrong admin URL.

The back button on pages, Edit, Results, and Clone returns the user to a URL that is hardcoded as <button onclick="window.location = '/wp-admin/admin.php?page=sjs-main-menu'">&lt&nbspBack</button>

Removing styling from button for readability.

I believe this would be a more dynamic way of returning the user to the admin page.

<button onclick="window.location = '<?php echo get_admin_url() ?>?page=sjs-main-menu'">&lt&nbspBack</button>

I bring this up because if a developer is working in a development environment then they may have a URL that looks like localhost/wordpress/site2/wp-admin/admin.php?page=sjs-main-menu as opposed to assuming the URL: localhost/wp-admin/admin.php?page=sjs-main-menu.

The problem is that in the current implementation of onclick="window.location = '/wp-admin/ will return the user to the URL localhost/wp-admin/ every time, even if it should return them to the URL localhost/wordpress/site2/wp-admin/.

shortcode documentation

in the new gutenberg editor there is no Add Survey Button.

Hard to find out the right shortcode, like [Survey id="1" name="My Grand Survey"] and add it with the Gutenberg Shortcode Block.

How can I hook into save results?

I've been trying to use a hook to send an email when the results are saved

add_action('wp_ajax_SurveyJS_SaveSurvey', 'my_SaveSurvey', 9);

However it's not firing.

Currently I'm using this workaround but it's less than ideal.

if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['Json']) && isset($_POST['SurveyId'])) {
  my_SaveSurvey();
}

Any help would be appreciated.

Custom Intro and Outro Page with different background images

I have been testing surveyjs-wordpress for quite some time now. Overall I really like it. But I am still missing some options.

I think it would be great if one could treat intro and outro for a survey as real html pages. That way you could apply different background images. BTW the completed html option doesn't work for me. I can't add HTML just plain text. If one could add background images per page, that would be awesome!

And I would really like it, if after I pressed next in a survey, there would be a smooth scroll upwards. Not sure if this deserves it's own issue.

Copying survey

It would be very handy to be able to copy a survey from the mysurveys view. So one could create a survey as a template and then copy it when needed.

Files should be uploaded as file not base64 json

Using a file input, the form gets submitted as base64 json, but results get cut off at ~ 64kb.

To allow larger file uploads, they should be uploaded via the .onUploadFiles hook.
I.e. by opening up the existing SurveyJS_UploadFile api call or adding another one survey submissions.

When activated, surveyjs plugin loads many js files from /wp-includes/js/dist/

I was wondering why there were so many js files being parsed on my WP site and figured, that if the surveyjs plugin gets activated, all the included js files in the WP dist directory are being loaded. Usually only enqueued scripts should be added, but as soon as surveyjs is activated, all (!) of them are included.

I did a bit of digging and found this post where the last post identifies register_block_type as the culprit. I did a quick search and found that the correct editor_script is used. Any idea what else might cause that?

Best regards,
Matthias

Survey entries don't show (JSON.parse: bad escaped character)

Hi,
when trying to show the results of a survey in the Wordpress/SurveyJS backend, it only shows the title and a blank page.
The browser's error log shows the following message:

Uncaught SyntaxError: JSON.parse: bad escaped character at line 1 column 280 of the JSON data
    data https://example.com/wp-admin/admin.php?page=surveyjs_results&id=5&name=RaS2024_final_de-en:444
    <anonymous> https://example.com/wp-admin/admin.php?page=surveyjs_results&id=5&name=RaS2024_final_de-en:443
[admin.php:444:41](https://example.com/wp-admin/admin.php?page=surveyjs_results&id=5&name=RaS2024_final_de-en)

Fortunately, I was able to locate the wp_sjs_results table, so I can see the raw JSON data. But I'd like to be able to export the entries as CSV.
Any hints what the "bad escaped character" could be or how to look for it? (I have no clue what "column 280" could mean).

Bootstrap option present on website, missing on WP Plugin

Hi SurveyJS Dev Crew,
I've had a lot of fun putting together surveys with this plugin over the past few weeks! The library makes it very straightforward to develop surveys with complex logic and I'm grateful for the work ya'll have put into it!

I had been using the surveyjs.io site to host my surveys, though I just recently made a survey that asks about some sensitive data.
I decided to check out the WP Plugin to host the results on my WP instance. In using the WP plugin I noticed that in the plugin settings the "Bootstrap framework" option is missing:
image

whereas it's present on the site in the equivalent drop-down:
image

Is this by design?

Load style in ALL Admin Wordpress

The plugin changes style in ALL the Wordpress admin. So, to avoid it, you can add this piece of code in initializer.php
public function enqueue_admin_scripts() {
if ( isset( $_GET["page"] ) &&
($_GET["page"] == "sjs-settings" ||
$_GET['page'] == "sjs-main-menu" ||
$_GET['page'] == "surveyjs_editor" ||
$_GET['page'] == "surveyjs_results"
)
) {
... (all css and jquery files)
}
}

all surveys loaded on each page

with the plugin installed all pages contain all surveys as a java script variable:

<script type='text/javascript'>
/* <![CDATA[ */
var surveys = []
...


thats wrong

Form doesn't store submissions after adding expression currentDate()

Hi,
sorry for submitting yet another issue. After fiddleing about with the timestamp thing (#48 / this comment), which I implemented semi-successfully with the expression currentDate(), my form stopped storing any submissions to the database altogether (other forms still worked fine).
I tried debugging it for a few hours — deleting the expression, copying the form, testing different browsers and devices. I couldn't get it to work again, though. The worst thing is that you didn't get a clue as a user, that your entry wasn't saved (no error message, nothing).
Trying this out on a live site in the middle of our conference registration phase running was a bad idea, obviously, but ... I also lost my confidence in the SurveyJS wordpress plugin at that point. 😞
In the end I spent the night recreating the form with ninjaforms. Now it's ugly, but it works again. Plus I have the automatic email functionality (= feature suggestion) that is great to give participants instant feedback as well as for backup, in case the stored submissions become corrupted.
To end this on a less anecdotal note: Here is my form JSON, if you'd like to have a look at it to see whether you can recreate the bug: ras24-survey.json

Best, kuchengrab

How to get the results as proper JSON?

My WP survey has dynamic panels which I am going to need to "flatten" in order to make a sensible report. First step is to get the JSON of all results.

If I click the Copy button I do not get JSON. I get a mixture of text and json as below (is an abbreviated version of data from the test survey results). Any way to get clean JSON? Am I missing something.

‹ Kindlehill School, Blue Mountains — WordPress

question9 question6 For this student ... To what extent is the school meeting your expectations of your child/young person’s education What are your thoughts about the volunteer work you do at the school? Are you intending to send your child to Kindlehill High School? Whatever your response above, please expand on your thinking about High School. How would you rate your expectation of administration in terms of: Do you read? What does Kindlehill do well?
Test 1 Show in Survey
[{"question2":{"Row 1":"Column 2"},"question3":{"Row 1":"Column 1"}},{},{}] {"0":{"Column 2":"1","improvements":"ghjk ghjkghkjg"},"To what extent do you value the balance of thinking, feeling, doing (willing) in your child/young person’s education?":{"Column 3":"1","improvements":"bhj "}}

{snip....}

} {"Kindlings":"Sometimes","Fortnightly newsletter via email":"Always"} all Show in Survey

Thanks,
Murray

very long surveys issue

We built an ISO9001 assessment survey and it was like 170 kb. The MySQL table (sjs_my_surveys) field (json) for the survey json file is of type TEXT, which is maximum 64K.
The result was that the survey was impossible to save on WP.
Maybe the field should be of type MEDIUMTEXT, this was our workaround (ALTER sjs_my_surveys TABLE)

Suggestion: CSS overrides mechanism

Thanks for the plugin. Very helpful.

I needed to set some CSS to override the WP theme and to better format the matrix tables I am using. I did that by adding the following to surveyjs/survey.css directly via the WP plugin file editor, which obviously has a downside if I update the SurveyJS plugin.

.main_color tr:nth-child(2n) { background-color: #f8f8f8 !important; }
.sv_header { background-color:#75e3b0; }
.sv_q_matrix tr th:first-child{ text-align:left !important; }
.sv_q_matrix tr td:first-child{ text-align:left !important; }
.sv_q_matrix th { text-align:center !important; }
.sv_q_matrix td { text-align:center !important; }

I was wondering whether you might consider adding some php to look for (say) surveyjs/custom.css and load it if the file exists. I am assuming the WP update process would not delete all files so this would remain in effect after any update.

I could envisage a similar JS file that could be called as a hook immediately before the

jQuery("#surveyElement-<?php echo $id ?>").Survey({model: survey<?php echo $id ?>, css: customCss});

passing the model JSON so last minute customisations could be done. eg to add other event listeners hooking into custom js code.

Just a thought to make this even more useful than it is!

Thanks,
Murray

Theme setting is not honored

Hi,

Thanks a lot for such a great plugin. I installed latest version from the store and noticed that the theme is not honored even after I change in the Settings menu.

Do I need to follow any steps after that?

Thanks,
Navneet

Order the entries by timestamp (or database id)

          This is not related to the bug anymore, but I have a follow-up question (if it makes sense, I can also repost it as a new issue/suggestion):

Is it possible to order the entries by timestamp (or database id)? Alphabetic order of any field doesn't make much sense in our case (to track new registrations and send them confirmation emails). Looks like I would need to add the timestamp as a field in the survey or something to achieve that?

Originally posted by @kuchengrab in #47 (comment)

question, result.data is key value, converting to json

Hi,¨
in app.component.ts, in this method result.data has key value format,
surveyModel.onComplete
.add(result =>
this.submitSurvey.emit(result.data)
)
like {"question1":100,"myquestion2":"Yes"}, how can i have it like this json format:
{{
name:question1.
value: 100
},
{
name: myquestion1
value: yes
}
}

Wordpress surveyjs plugin - Cannot change textftield value

Hello everyone,

I have a weird problem. I have used surveyjs plugin with a wordpress site (version : 5.1.1) and I have created a quesionnaire but I would like to keep which user is completing the questionnaire. I created a textfield and tried to complete automatically (because the user may not complete it properly) it by using this code:

  var textfield = document.getElementsByClassName('sv_q_text_root')[0];
  textfield[i].value = '<?php $current_user = wp_get_current_user(); echo $current_user->user_email ;?>';

Although I see the email shown inside the textfield when I save the survey it is not saved in the results. Then if I add by pressing in the keybord an extra letter after the email the result is saved. For example if I add by javascript the "[email protected]" in the textfiled it is not saved but if i write a letter by keyboard after it like this "[email protected]" it is saved.

Then I tried to simulate a keyboard press like this :

   jQuery(function($) {
      $( "#sv_q_text_root" ).trigger(
      jQuery.Event( 'keyup', { keyCode: "65", which: "65" } )
   )});

but still it doesn't save.
If also you know another way to save the users with the results, I couldn't find something about wordpress.
Thank you

How to implement range-slider in WordPress surveys?

Hi there!
I already posted here but it doesn't seem to get the traction that I need ;)

In short: As the title Suggests, how can I add custom widgets in WordPress? I need a range-slider urgently and don't know where to put/include the js files

<script src="https://unpkg.com/[email protected]/distribute/nouislider.js"></script>
<script src="https://surveyjs.azureedge.net/1.5.17/surveyjs-widgets.js"></script>

Any pointers are appreciated!

Best regards

Using less than character (<) causes JSON encoding problem

Are you requesting a feature, reporting a bug or asking a question?

bug

What is the current behavior?

When using the less than character in any of the input fields when configuring a survey the JSON becomes malformed as the character is wrongly encoded as an HTML entity.

What is the expected behavior?

You can use a less than or greater than character.

How would you reproduce the current behavior (if this is a bug)?

We encountered this using the WordPress SurveyJS plugin.

Provide the test code and the tested page URL (if applicable)

Sorry, don't have any repro at the moment.

Specify your

  • browser: Chrome
  • browser version: 70
  • surveyjs platform (angular or react or jquery or knockout or vue): WordPress (Knockout?)
  • surveyjs version: SurveyJS version: whatever version the WP plugin uses
  • WP plugin version: 1.0.33

HTML questions are ending up as plain text

If I have this in my survey JSON:

{
    "type": "html",
    "name": "question1",
    "html": "<h4>Welcome!</h4>"
}

the resulting html in the survey is:

<div data-bind="html: question.locHtml.koRenderedHtml">Welcome!</div>

i.e. no html tags. I am assuming WP is doing that? Not sure what to do.

Any ideas?
Thanks,
Murray

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.