public static function update($id)
 {
     if (!self::check_logged_in()) {
         Redirect::to('/login', array('error' => 'You must log in to access this resource.'));
         return;
     }
     $params = $_POST;
     $oldsurvey = Survey::find($id);
     $user = self::get_user_logged_in();
     $attributes = array('person' => $user->id, 'id' => $id, 'description' => $params['description'], 'type' => $oldsurvey->type);
     if ($attributes['type'] == 'int-value') {
         if ($params['min_value']) {
             if (is_numeric($params['min_value'])) {
                 $attributes['min_value'] = $params['min_value'];
             }
         }
         if ($params['max_value']) {
             if (is_numeric($params['max_value'])) {
                 $attributes['max_value'] = $params['max_value'];
             }
         }
     }
     $survey = new Survey($attributes);
     $errors = $survey->errors();
     if (count($errors) == 0) {
         $survey->update();
         Redirect::to('/survey/' . $survey->id, array('message' => 'Survey successfully updated!'));
     } else {
         Redirect::to('/survey/' . $survey->id . '/edit', array('errors' => $errors, 'attributes' => $attributes));
     }
 }
 public static function sandbox()
 {
     // Testaa koodiasi täällä
     $eka = Survey::find(1);
     $kaikki = Survey::all();
     Kint::dump($eka);
     Kint::dump($kaikki);
 }
 public function completePreSurvey()
 {
     $input = Input::all();
     //$inputSurvey=$input['survey'];
     $survey = Survey::find($input['surveyid']);
     $group = Group::find($input['groupid']);
     $user = Auth::user();
     $response = new SurveyResponse();
     $response->user_id = $user->id;
     $response->group_id = $input['groupid'];
     $response->survey_id = $input['surveyid'];
     $response->type = "pre";
     $response->response = serialize("");
     $response->save();
     return "";
 }
示例#4
0
 public function survey_get($user_id)
 {
     $ans = [];
     // $Get = $this->request->getGet(['item_id','datemin','datemax','limit']);
     $validation = new UserDataValidation();
     $messages = $validation->validate($_GET);
     foreach ($messages as $message) {
         throw new Exception($message, 102);
     }
     $conditions = 'item = :i_id: AND user_id = :u_id:';
     $parameters = ['i_id' => $_GET['item_id'], 'u_id' => $user_id];
     if (isset($datemin)) {
         $conditions .= 'AND date >= :min: ';
         $parameters['min'] = $_GET['datemin'];
     }
     if (isset($datamax)) {
         $conditions .= 'AND date <= :max: ';
         $parameters['max'] = $_GET['datemax'];
     }
     $result = Survey::find([$conditions, 'bind' => $parameters]);
     $ans['data'] = [];
     $p = 0;
     foreach ($result as $item) {
         $ans['data'][$p] = ['value' => $item->value, 'date' => $item->date];
         $p++;
     }
     // print_r($ans);
     return $ans;
 }
@section('content')
<?php 
$survey = Survey::find($group->survey);
if (!is_null($survey)) {
    $data = unserialize($survey->data);
    $fields = json_decode($data[0])->fields;
}
?>
<!-- REMOVED AS PER FEEDBACK -->
<!--<div class="banner">
    <img src="{{ asset('images/survey_page_bg.png') }}" alt="banner" width="100%" />
    <div class="container-fluid">
        <div class="row intro">
            <div class="col-md-4"></div>
            <div class="front-page-intro col-md-4 col-sm-5">
                <span class="intro-frame intro-top">
                    {{ trans('master.surveypageintrotop') }}
                </span>
                <span class="intro-frame intro-bottom">
                    {{ trans('master.surveypageintrobottom') }}
                </span>
            </div>
        </div>
    </div>
</div>-->
<div class="clearfix"></div>
@if(!is_null($survey))
<div class="survey-container">
    <div class="container">
        <div class="row">
            <div class="survey-heading col-md-4 col-md-offset-4">
@extends('layouts.master')

@section('content')

@if(!empty($surveyResponse))
<table>
    <thead>
        <tr>
            <th>Name</th>
            <th>Type</th>
            <th>Response</th>
        </tr>
        @foreach($surveyResponse as $response)
        <?php 
$survey = Survey::find($response->survey_id);
$user = User::find($response->user_id);
if (!is_null($survey)) {
    $data = unserialize($survey->data);
    $fields = json_decode($data[0])->fields;
    //            echo '<pre>';
    //            print_r($fields);
    //            echo '</pre>';
    //            die;
}
?>
        <tr>
            <td>{{ $user->fullName() }}</td>
            <td>{{ $response->type }}</td>
            <td>
                @foreach(unserialize($response->response) as $key => $val)
                @if($key!='_token' && $key!='' && $key!='' && $key!='' )
 public function surveyMessages($id)
 {
     $survey = Survey::find($id);
     return View::make('survey.prepostmessage')->with('survey', $survey);
 }
@section('content')
<?php 
$survey = Survey::find($group->postsurvey);
if (!is_null($survey)) {
    $data = unserialize($survey->data);
    $fields = json_decode($data[0])->fields;
}
?>
<!-- REMOVED AS PER FEEDBACK -->
@if(!is_null($survey))
<div class="clearfix"></div>

<div class="survey-container">
    <div class="container">
        <div class="row">
            <div class="survey-heading col-md-4 col-md-offset-4">
                <h3>{{ trans('master.postsurveyhead') }}</h3>
            </div>
        </div>
        <p>{{ $survey->getPostMessage() }}</p>
        <div class="row">
            <div class="survey-form">
                {{ Form::open(['url'=>'survey/response/save','parsley-validate'=>'','id'=>'postsurveyform']) }}
                {{ Form::hidden('userid',$user->id) }}
                {{ Form::hidden('groupid',$group->id) }}
                {{ Form::hidden('surveyid',$survey->id) }}
                {{ Form::hidden('type','post') }}
                <?php 
$count = 0;
?>
                @foreach($fields as $field)