Exemplo n.º 1
0
 public function registration()
 {
     $post = isset($_POST['EntryForm']) ? $_POST['EntryForm'] : $_POST;
     $step = !empty($post['step']) ? (int) $post['step'] : 1;
     $max = !empty($post['maxstep']) ? (int) $post['maxstep'] : 1;
     $back = !empty($post['back']) ? (int) $post['back'] : 0;
     $last = $step == $max;
     $code = 'participant_reg_member';
     $guid = $this->getGuid();
     if ($step > $max) {
         return $this->render('entry-confirm', ['model' => null]);
     }
     if ($back) {
         $step = $step - 1;
     }
     $mainmodel = new MainModel($code);
     $model = $mainmodel->initModel(new EntryForm(), $step, ['guid' => $guid, 'code' => $code, 'step' => $step]);
     $maxStep = $model->getCountStep();
     if ($back) {
         return $this->renderForm('back', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]);
     }
     if (!$model->load(Yii::$app->request->post()) || empty($post)) {
         return $this->renderForm('Load first', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]);
     }
     if (!$model->validate(null, true)) {
         return $this->renderForm('Not valid', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]);
     }
     $json = new JsonRPCClient('http://api.json/index.php');
     $value = [];
     foreach ($post as $key => $val) {
         if (in_array($key, $model->fieldList)) {
             $value[] = ['guid' => $guid, 'code' => $code, 'step' => $step, 'key' => $key, 'val' => $val, 'obj' => @$mainmodel->form->fields[$key]->obj];
         }
     }
     $test = $json->setSaveStepsForm($value, 1);
     if (!$test['success']) {
         return $this->renderForm('Not success', ['model' => $model, 'step' => $step + 1, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]);
     }
     if ($last) {
         $result = $this->saveForm($guid, $code);
         return $this->render('entry-confirm');
     }
     unset($mainmodel);
     unset($model);
     $step = $step + 1;
     $mainmodel = new MainModel($code);
     $model = $mainmodel->initModel(new EntryForm(), $step, ['guid' => $guid, 'code' => $code, 'step' => $step]);
     $maxStep = $model->getCountStep();
     return $this->renderForm('Next form', ['model' => $model, 'step' => $step, 'maxstep' => $maxStep, 'debug' => ['step' => $step, 'guid' => $guid], 'errors' => $model->getErrors()]);
 }
Exemplo n.º 2
0
<?php

// without composer this line can be used
require_once '../survey/application/libraries/jsonRPCClient.php';
require_once 'config.php';

// instanciate a new client
$myJSONRPCClient = new JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );

// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );
?>

<head>
    <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>

    <style>
        .options {
            margin : 10px;
        }
        
        .survey_container {
            width : 50%;
            display: inline-block;
        }
    </style>
</head>

<body>

<?php
Exemplo n.º 3
0
        array_push($titles, $item[1]);
    }
} else if(!empty($_GET)) {
    $survey_ids = array($_GET['id']);
    $type       = $_GET['type'];
} else {
    print "<h1>No Survey Ids passed!</h1>";
}

if(empty($lang)) {
    $lang = 'en';
}

#$survey_ids = array(147451);
// instanciate a new client
$myJSONRPCClient = new JsonRPCClient( LS_BASEURL.'/admin/remotecontrol' );

// receive session key
$sessionKey= $myJSONRPCClient->get_session_key( LS_USER, LS_PASSWORD );


$results = array();
$i = 0;
// receive all ids and info of groups belonging to a given survey
foreach($survey_ids as $survey_id) {
    $responses = $myJSONRPCClient->export_responses( $sessionKey, $survey_id, 'json', $lang, 'complete','short', 'long');
    $title = $titles[$i];
    if(!isset($responses['status'])) {
        $json = base64_decode($responses);
        $decoded = json_decode( $json, true );
        $processed_pairs = array();