Welcome to the LimeSurvey Community Forum

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

Automated creation of questionnaire fails

  • maknase
  • maknase's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 10 months ago #119850 by maknase
Hi! When creating a survey I try to create several Questiongroups, questions and answers with a loop as I need th same questiongroup setup several times.

Within the loop the first Questiongroup is created as it should, but on the second run I get an error "Failed to insert question" with the code below.

Any idea why? Thanks!

k++;
$questiondata = array(
'parent_qid' => '',
'sid' => $iNewSurveyid,
'gid' => $sInsertgroupID,
'type' => 'L',
'title' => 'm'.$k,
'question' => 'text',
'preg' => '',
'help' => '',
'other' => 'N',
'mandatory' => 'Y',
'question_order' => '1',
'language' => $_POST,
'scale_id' => '0',
'same_default' => '0',
'relevance' => '1'
);
print_r(array_values($questiondata));
$sInsertquestionID = Question::model()->insertRecords($questiondata) or safeDie($clang->gT('Error').": Failed to insert question<br />\<br />\n");
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose