Welcome to the LimeSurvey Community Forum

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

Want to Hire Dev to code display of data in PHP

  • h0rr0rOrg
  • h0rr0rOrg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago - 4 years 6 months ago #189103 by h0rr0rOrg
Hello!
I am the webmaster for the HWA, and I need help getting my Limesurvey data to display on my PHP/Wordpress website. I've done some of the coding and managed to get it set up, but it's not showing the data the way I want it to.

I know JSON only a little, having learned a bit since moving to the Online LimeSurvey.

I doubt it's difficult, but I cannot make it work. At this point, I'm willing to pay someone to code me a script and PHP page to make it happen. You probably don't need to start from scratch, if you don't want to, but could just fix the code I have.

We are the Horror Writers Association, and we're a non-profit org run by volunteers, so please know that we can't pay as much as a corporation.

If you're interested, email me at webmaster@horror.org, let me know your experience and how much you would need to charge us to do this.

It may be a bit more complicated than the standard. I need it to sort on X, then take those results, sort them on Y, Z, A, B, then display only a portion of the data.

Thanks for your time.
Angel Leigh McCoy, HWA Webmaster
Last edit: 4 years 6 months ago by h0rr0rOrg.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189114 by tpartner

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu, gabrieljenik
The topic has been locked.
  • h0rr0rOrg
  • h0rr0rOrg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago - 4 years 6 months ago #189122 by h0rr0rOrg
Replied by h0rr0rOrg on topic Want to Hire Dev to code display of data in PHP
Thanks, Tpartner, but that page is where I started. It isn't helping me beyond a certain point. I have another post where I go into detail.

I finally tried hiring someone else to fix it, but they borked it. So now I'm here, hoping someone here has the expertise I need to fix it.

Old post: www.limesurvey.org/community/forums/can-...html?start=15#185143

I'm FRANKLY at my wits end.
Last edit: 4 years 6 months ago by h0rr0rOrg.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189127 by DenisChenu
Replied by DenisChenu on topic Want to Hire Dev to code display of data in PHP
Didn't understand : you want some dev contact, @tparner give you the official partner page. Then you have the contact ?
No ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: gabrieljenik
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189142 by Joffm
Regarding your old post.

There is this line
// THE FOLLOWING LINE IS WHERE I NEED TO ECHO ONLY SPECIFIED $item DATA
echo '<td style="border: 1px solid #CCC; padding: 2px 7px;">A: ' . $item . '</td>';

Why don't you define your desired items
$categories = array("title", "author", "publisher");

and then
if (in_array($category, $categories)) {
echo '<td style="border: 1px solid #CCC; padding: 2px 7px;">A: ' . $item . '</td>';
}

And somewhere you mentioned some sorting.
Well, you have your array.
Here some examples how to sort:
www.virendrachandak.com/techtalk/how-to-...ray-by-value-in-php/


Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 6 months ago by Joffm.
The topic has been locked.
  • h0rr0rOrg
  • h0rr0rOrg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189171 by h0rr0rOrg
Replied by h0rr0rOrg on topic Want to Hire Dev to code display of data in PHP
Oh! You're right. That's not the page I thought it was. Sorry!
The topic has been locked.
  • h0rr0rOrg
  • h0rr0rOrg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189172 by h0rr0rOrg
Replied by h0rr0rOrg on topic Want to Hire Dev to code display of data in PHP
Thanks, Joffm! I'll take another look and see if I can sort it out.

Much appreciated.
The topic has been locked.
  • h0rr0rOrg
  • h0rr0rOrg's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 6 months ago #189173 by h0rr0rOrg
Replied by h0rr0rOrg on topic Want to Hire Dev to code display of data in PHP
Sorry, tpartner. I thought that was a different link. Much appreciated!
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago - 4 years 6 months ago #189212 by Joffm
Hi,
I played around a bit with your php file and got the following:

Styling is up to you.
As far as I understood your explanation this is near to your ideas.
If not you ought to show us (screenshot, drawing, etc)

Here the script:
Code:
<html>
<head>
<title>HWA Bram Stoker Award Recommendations</title>
<script language="JavaScript" type="text/JavaScript">
// THE FOLLOWING IS LIMESURVEY CODE
 function get_session_key(USERNAME $username, PASSWORD $password)
</script>
</head>
 
<body>
<!-- START OF CONTENT -->
<table border=1><tr bgcolor="#bbbbbb"><td colspan=8><br><center><h1>HWA Bram Stoker Award&amp;reg; Member Recommendations for Works Published in 2018</h1></td></tr>
 
<?php
require_once 'jsonrpcphp/JsonRPCClient.php';
 
define( 'LS_BASEURL', 'https://www.myServer.de/survey');  // adjust this one to your actual LimeSurvey URL
define( 'LS_USER', 'user' );
define( 'LS_PASSWORD', 'password' );
 
// the survey to process
$survey_id=977824;
// instantiate a new client
$myJSONRPCClient = new \org\jsonrpcphp\JsonRPCClient( LS_BASEURL.'/index.php/admin/remotecontrol' );
// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
 
if(is_array($sessionKey))
{
    header("Content-type: application/json");
    echo json_encode($sessionKey);
    echo '<br />This is another test with sesssion key.<br />';
    die();
}
else if($sessionKey) // Is a valid session
{
/* Get the responses */
  $rawResponses = $myJSONRPCClient->export_responses( $sessionKey, $survey_id,
    'json', // Document type : pdf,csv,xls,doc,json
    null, // Language code : null : default from survey
    'complete', // Stautus complete|incomplete|all
    'code', // Heading : code|full|abbreviated : question text, default code
    'short', // answer : short|long , default : long
    null,
    null
  );
  $category= array ("","Novel","First Novel","Graphic Novel","Young adult novel","Long Fiction","Short Fiction","Screenplay","Anthology","Fiction Collection");
  $columns = array("title", "author", "publisher", "venue", "month");
 
  if(is_array($rawResponses))
  {
    print_r($rawResponses);
  }
  else {
    $decodedString = base64_decode($rawResponses); // The decodedString variable turns the data into an array and contains the entire array of data for the survey in English
    $responseArr = json_decode($decodedString, True); // Creates the json-decoded array of data for use in PHP.
 
    for ($i=1;$i<9;$i++) {
      echo '<tr bgcolor="#bbbbbb"><td colspan="8" style="font-size:14pt;font-weight:bold;text-align:center">'.$category[$i].'</td></tr>';
      foreach($responseArr['responses'] as $rownumber => $row) {
        foreach($row as $column => $item) {
 
          if ($item["category"]=="A".$i) {
            echo '<tr bgcolor="#bbbbbb">';
            foreach($columns as $col) {
              echo '<td style="border: 1px solid #CCC; padding: 2px 7px;">' . $item[$col] . '</td>';
            }
          }
          echo '</tr>';
        }
      }
    }
    echo '</table>';
  }
}
 
  // Release the session key
  $myJSONRPCClient->release_session_key( $sSessionKey );
 
 
 
?>
</table>
<!-- END OF CONTENT -->
</body>
</html>

1. You should have the same structure in the codes of the categories (Why did you change after "A9"?)
Therefore the script only works up to category "A9"; as you see I check for "A".$i in the loop.
2. The same in "month". Why the change? Here I used the short name of the month as code

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 4 years 6 months ago by Joffm.
The topic has been locked.
More
4 years 6 months ago #189239 by jelo
Nice effort.

What external library did you use for JSON-RPC?
The one linked in the LimeSurvey manual?
github.com/weberhofer/jsonrpcphp

Since there many php libs around JSON-RPC, it's worth pointing out what external dependence we have.

Since PHP 7 is more and more the norm, this JSON PHP lib is worth a look.
github.com/datto/php-json-rpc

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189240 by Joffm
Yes, it is weberhofer.

I never used the API, here just a try to help.

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 6 months ago #189241 by DenisChenu
Replied by DenisChenu on topic Want to Hire Dev to code display of data in PHP

jelo wrote: Nice effort.

What external library did you use for JSON-RPC?
The one linked in the LimeSurvey manual?
github.com/weberhofer/jsonrpcphp

Since there many php libs around JSON-RPC, it's worth pointing out what external dependence we have.

Since PHP 7 is more and more the norm, this JSON PHP lib is worth a look.
github.com/datto/php-json-rpc

datto lib seems for jsonRPC spec 2, we are on spec 1 : manual.limesurvey.org/RemoteControl_2_API#How_to_use_LSRC2

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose