Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Participant "Dashboard" Possible?

More
8 years 2 weeks ago #157523 by limeAJ
Hello,
Can I create a "dashboard" of sorts, for my participants?

I have about 12 participants, and each participant will answer the survey 20-30 times.

Would there be a way to have the participant "login", and list:
  • their previous surveys
    surveys pending-completition (they "Save for Later")
    Create New Survey

I can do some custom coding html/javascript side... and maybe something server side.
Yet if somebody can provide some direction, I would appreciate it a lot!

Thank you!
The topic has been locked.
More
8 years 2 weeks ago #157524 by gabrieljenik
Hi AJ,

I have a custom plugin for that which I can show you and should save you plenty of time.
Please contact me at gabriel@encuesta.biz

Thanks!

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Checkout our Reporting Solutions and our plugin shop at www.encuesta.biz .

The topic has been locked.
More
8 years 1 week ago #157628 by limeAJ
Thanks for the information Gabriel!
I am in contact with you via email.

----
Question to other users:
Is there a way I can get a listing of each participant's answered surveys?

Thank you!
The topic has been locked.
More
8 years 1 week ago - 8 years 1 week ago #157662 by limeAJ
This is a work-in-progress, and thus I am positing here just to "document" my findings so far.

I think I can build the dashboard "on the side" via regular html/javascript.
Limesurvey "creates" the urls in a certain way.... and I think I could use javascript's regex to create the links.
Code:
user#1
https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/newtest/Y/lang/es/token/868
clicked on "Continue Later", and the received url via email
https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/loadall/reload/scid/38/lang/es/loadname/user#1/loadpass/PASSWORD/token/868
 
 
user#2
https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/newtest/Y/lang/es/token/qvg
clicked on "Continue Later", and the received url via email
https://LS.server.ip.addy/limesurvey/index.php/survey/index/sid/665156/loadall/reload/scid/39/lang/es/loadname/user#2/loadpass/PASSWORD/token/qvg

The variables here would be:
loadname, password, and the token.
That's what I would have to tie in.

Will keep everyone posted on what I find.

Reference Links: A tip for generating a large number of individual links which include the token already
Last edit: 8 years 1 week ago by limeAJ.
The topic has been locked.
More
8 years 6 days ago #157753 by socius
Hi limeAJ,

thanks for the question that reminded me that I thought about this some time ago.

My imagined (but not implemented) solution to this was: what about creating a survey that serves as dashboard? I.e. you could have a nicely formatted boilerplate question with personalized information (Survey Links, Due Dates, ToDo/Finished etc. with conditional formatting). This survey would have to get the information out of the other surveys resp. the token tables.

What do you think about that? Is that feasible for you? Looking forward to a discussion and possible solutions.
The following user(s) said Thank You: limeAJ
The topic has been locked.
More
8 years 3 days ago #157931 by limeAJ
Hello socius!
That's a good idea.
Seems completely plausible to me, although I'm not an expert.

At the moment, I am trying to do the following:
setup a separate html/php page
In that page, "construct" the url links to the surveys themselves.

I have something very basic running, yet it's non-extensible (everything is hardcoded) and quite fragile.
The LimeSurvey RPC (api?) seems to provide the functionality that would help here.
Reading up on its documentation, I think it's possible to have the rpc (api) return a list of surveys.

What do you think?

Thanks for the comment!
The topic has been locked.
More
8 years 3 days ago - 8 years 3 days ago #157939 by tpartner

The LimeSurvey RPC (api?) seems to provide the functionality that would help here.
Reading up on its documentation, I think it's possible to have the rpc (api) return a list of surveys.

You can use the API list_surveys() method to list details of all surveys accessible by a given user.

A PHP script something like this, when passed a valid "username" parameter in the URL, will print a table of all surveys that that user has admin access to.
(the code is intentionally a little verbose for clarity)

Code:
<?php
 
  require_once 'jsonRPCClient.php';
 
  define( 'LS_BASEURL', 'https://pathTo/limeSurvey/');  
  define( 'LS_USER', 'admin' );
  define( 'LS_PASSWORD', 'password' );
 
  if(!isset($_GET["username"])) {
    echo 'No user specified!';
    return false;
  }
  else {
    $sUsername = $_GET["username"];
  }
  // NOTE: You could do some more validation and/or conditions regarding the username here
 
  // Instantiate a new RPC client
  $myJSONRPCClient = new jsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );
 
  // Get a session key
  $sSessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
  // Get survey info for all surveys accessible by $sUsername
  $surveys = $myJSONRPCClient->list_surveys($sSessionKey, $sUsername);
 
  if(array_key_exists('status', $surveys) &amp;&amp; $surveys['status'] == 'Invalid user') {
    echo 'Invalid user specified!';
    return false;
  }
  else {
    // Sort the results by survey title - https://docs.php.net/manual/en/function.array-multisort.php
    foreach ($surveys as $key => $row) {
      $sid[$key]  = $row['sid'];
      $surveyls_title[$key] = $row['surveyls_title'];
      $startdate[$key]  = $row['startdate'];
      $expires[$key]  = $row['expires'];
      $active[$key]  = $row['active'];
    }
    array_multisort($surveyls_title, SORT_ASC, $surveys);
 
    // Print the results in a table
    $tableHTML = '<table class="surveys-list" style="border-collapse: collapse;" border=1>';
      $tableHTML .= '<tr>';
        $tableHTML .= '<th>Title</th>';
        $tableHTML .= '<th>SID</th>';
        $tableHTML .= '<th>Start Date</th>';
        $tableHTML .= '<th>Expires</th>';
        $tableHTML .= '<th>Active</th>';
        $tableHTML .= '<th>Link</th>';
      $tableHTML .= '<tr>';
 
    foreach ($surveys as $surveyInfo) {
      $tableHTML .= '<tr>';
        $tableHTML .= '<td>'.$surveyInfo['surveyls_title'].'</td>';
        $tableHTML .= '<td>'.$surveyInfo['sid'].'</td>';
        $tableHTML .= '<td>'.$surveyInfo['startdate'].'</td>';
        $tableHTML .= '<td>'.$surveyInfo['expires'].'</td>';
        $tableHTML .= '<td>'.$surveyInfo['active'].'</td>';
        $tableHTML .= '<td>';
        if($surveyInfo['active'] == 'Y') {
          $tableHTML .= '<a href="'.LS_BASEURL.'index.php/'.$surveyInfo['sid'].'?newtest=Y" target="_blank">Survey Link</a>';
        }
        $tableHTML .= '</td>';
      $tableHTML .= '<tr>';
    }
 
    $tableHTML .= '</table>';
 
    echo $tableHTML;
  }
 
  // Release the session key
  $myJSONRPCClient->release_session_key( $sSessionKey );
?>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 8 years 3 days ago by tpartner.
The topic has been locked.
More
8 years 2 days ago #157961 by tammo
Tony: aren't you referring to LimeSurvey users in stead of respondents?

Tammo


Tammo ter Hark at Respondage
For Limesurvey reporting, education and customized themes
respondage.nl
The topic has been locked.
More
8 years 2 days ago #157962 by tpartner
Yes, I thought that was the intent - to list a set of surveys authored by a specific admin.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
8 years 2 days ago #157976 by limeAJ
Ok,
So I am running into a problem in my rpc tests.
I tailed and checked various logs and http headers.
Fast forward, I enabled debug mode on the "JsonRPCClient.php" file.
The line for the rpc/api test reads:
Code:
$myJSONRPCClient = new org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'index.php?r=admin/remotecontrol', true);

From there, an error stating:

Bad Request
The CSRF token could not be verified.
The request could not be understood by the server due to malformed syntax. Please do not repeat the request without modifications.
If you think this is a server error, please contact the webmaster.
2017-08-25 16:10:41
***** End of Response *****


So I then found this link in the Limesurvey forum , which then took me to this bug report .
From there, Denis states that there is a way to disable the CSRF protection, and he mentions this wiki page.

From that wiki page, I went to modify config.php:
Code:
/limesurvey/application/config/config.php

and added the lines:
Code:
// Disable CSRF protection
        'request' => array(
            'enableCsrfValidation'=>false,    
            ),

My particular Survey in this case will be 100% company internal, and it will not get published to the internet.
So I consider disabling CSRF protection to be ok.

Yet, once I disable it in config.php, I get the following error on the webpage calling the rpc/api:

***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response *****
CException
Application runtime path "/var/www/html/limesurvey/application/runtime" is not valid. Please make sure it is a directory writable by the Web server process.
***** End of Response *****


So I went to check the path: /var/www/html/limesurvey/application/runtime

Yet it does not exist.

Any idea what I am doing wrong?
How can I fix this?

This is the php api example page I am looking at.
The topic has been locked.
More
8 years 2 days ago #157977 by limeAJ
Ok, so I just created the directory /runtime in the path:
Code:
/var/www/html/limesurvey/application
For a final path of:
Code:
/var/www/html/limesurvey/application/runtime
I made www-data the owner and group of that directory.

Now I reloaded the page I have for the rpc/api test, and a new error message states:

***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response *****
Internal Server Error
Property "LSYii_Application.request" is read only.
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
Thank you.
2017-08-25 16:23:33
***** End of Response *****

The topic has been locked.
More
8 years 2 days ago - 8 years 2 days ago #157978 by limeAJ
Ok, in the
Code:
/var/www/html/limesurvey/application/runtime

I uncommented the line, and modified it to the directory:
Code:
'runtimePath'=>'/var/www/html/limesurvey/application/runtime/'

Now I am not getting the previous error.
Yet the json reply... I am not sure if that's what I need.

I have at the moment:

***** Request ***** {"method":"get_session_key","params":["admin","password"],"id":1} ***** Response ***** ***** End of Response *****

Last edit: 8 years 2 days ago by limeAJ.
The topic has been locked.
More
7 years 9 months ago #160801 by socius
Hi all,

@limeAJ were you successful in the end? I came back to this thread after some weeks and I now look for a way to build an overview page where respondents can see a number of surveys they are invited to participate.

I think this is somehow similar to what you try/tried to accomplish, but also different since this overview page should be integrated in its own survey - while in your case the surveylist is to be integrated in a separate webpage (plus you say it's a company internal survey while mine should become a larger "external" survey where security is decisive (that's why I thought that to use a survey for this case is a good idea...).

Thus (I hope this does not count as double post) I posted a new question www.limesurvey.org/forum/can-i-do-this-w...re-invited-to#160781 - If this is considered a double post, please move my posting in here @admin - thanks!

Thanks for your time and best,
G
The topic has been locked.
More
7 years 9 months ago #160812 by limeAJ
Hello socius!
I think your idea is different from this "dashboard" I was thinking, and you idea is good!
Yet *I* titled this thread with a mis-informative word selection: my idea isn't a *participant* dashboard.
I believe your idea falls better into that side.

Anyway, what I ended up doing, and it is still in-development, is:
I setup a simple php login page - at the moment, users (+ passwords) are hardcoded into the database.
Once the user logs in, I use php to read data from the limesurvey database directly.
I created a side-database in the same server, which I use to sort of keep track of surveys on my side.
This side-database has the name of the responder, the token used by limesurvey, and some other useful information for my usage.

I can then present everything prettily to the user in my dashboard.

When they click a link on a survey the want to use/finish, the php "constructs the URL" with the correct information, plus the limesurvey token used. Then I send the user off to limesurvey, which knows how to do everything on its own (plus it has the token information).

Does this help you?
Let me know if I can be of more assistance!
The following user(s) said Thank You: socius
The topic has been locked.
More
7 years 9 months ago #160888 by socius
Hi @limeAJ,

thanks for your response! Great. Yes I think reading the Limesurvey DB directly could also be a solution in my case - but since I'm not a programmer I better stay within Limesurvey ;-)

@cairomckencie came up with a great solution for a participant dashboard, i.e. a parent survey with a number of children-surveys - which seems exactly what I need - maybe it's also interesting for you: www.limesurvey.org/forum/can-i-do-this-w...re-invited-to#160831

If I come across questions for which I have to enter the DB directly I get back to you :-)

Cheers,
G
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose