Welcome to the LimeSurvey Community Forum

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

How to display responses of questions that are "long text" type?

  • hagerregah
  • hagerregah's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago #206433 by hagerregah
I created a plugin that creates a new menu entry. The function I aim at is to display, for a given survey, the list of answers of questions that are of "long text" type.

How can I do it?
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #206437 by DenisChenu
Moving to developement …

You need to
1. Create a page using github.com/LimeSurvey/LimeSurvey/blob/10...PluginHelper.php#L21 sidebody action on PluginHelper (I don't see example in core survey, but you must create a pluginmanager/sidebody url
2. Create a findAll request $question => \Question::model()->findAll("sid = :sid and type = :type"), array(":sid" => $surveyId,":type" => 'T'
3. When you have it : make a for each function to get the values for Response::model($surveyId)->findAll()->getAttribute($question->sid."X".$question->gig."X".$question->qid);

You have all information to do your own system, remind you can check existing source code …

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.
  • hagerregah
  • hagerregah's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 5 months ago - 3 years 5 months ago #206449 by hagerregah
@DenisChenu

So this is the code:
Code:
$questions = \Question::model()->findAll("sid = :sid and type = :type", array(":sid" => $iSurveyID,":type" => 'T'));
 
       $question = [];
        foreach ($questions as $q) {
            $question[$q->title] = $q;
      //echo $q->question;
        }
    //print_r ($question);
 
       $responses = [];
       foreach ($questions as $q) {
              $responses =Response::model($iSurveyID)->findAll()->getAttribute($q->sid."X".$q->gig."X".$q->qid);
       }
       print_r ($responses);



I could display the questions but not the responses: it says

500: Internal Server Error
Call to a member function getAttribute() on array


Should I change the "X" in the script?

Thank you in advance.
Last edit: 3 years 5 months ago by hagerregah.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 5 months ago #206506 by DenisChenu
Code:
$oResponses = Response::model($iSurveyID)->findAll();
 
foreach($oResponses as $oResponse) {
    foreach ($questions as $q) {
        $responses[] = $oResponse->getAttribute($q->sid."X".$q->gig."X".$q->qid);
    }
}

See www.yiiframework.com/doc/api/1.1/CActiveRecord#findAll-detail

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