/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // Locations
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_COMPLETE, 'name' => 'Test Location 1', 'unique' => 1, 'order' => 6]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_CUSTOM, 'name' => 'Test Location 2', 'unique' => 0, 'order' => 5]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_EXPECTED, 'name' => 'Test Location 3', 'unique' => 1, 'order' => 4]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_NONE, 'name' => 'Test Location 4', 'unique' => 0, 'order' => 3]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_RANDOM, 'name' => 'Test Location 5', 'unique' => 0, 'order' => 2]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_RANDOM, 'name' => 'Test Disabled', 'unique' => 0, 'order' => 1, 'disabled' => true]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_LOCATION, 'type' => Element::TYPE_SPECIAL, 'name' => 'Test Location 6', 'unique' => 0, 'order' => 0]);
     // Encounters
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_SPECIAL, 'name' => 'Test Encounter 1', 'unique' => 0, 'order' => 6]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_RANDOM, 'name' => 'Test Encounter 2', 'unique' => 1, 'order' => 5]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_NONE, 'name' => 'Test Encounter 3', 'unique' => 0, 'order' => 4]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_CUSTOM, 'name' => 'Test Encounter 4', 'unique' => 0, 'order' => 3]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_EXPECTED, 'name' => 'Test Disabled', 'unique' => 1, 'order' => 2, 'disabled' => true]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_ENCOUNTER, 'type' => Element::TYPE_EXPECTED, 'name' => 'Test Encounter 5', 'unique' => 1, 'order' => 1]);
     // Objects
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_SPECIAL, 'name' => 'Test Object 1', 'unique' => 0, 'order' => 0]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_SPECIAL, 'name' => 'Test Disabled', 'unique' => 0, 'order' => 1, 'disabled' => true]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_RANDOM, 'name' => 'Test Object 2', 'unique' => 0, 'order' => 2]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_NONE, 'name' => 'Test Object 3', 'unique' => 1, 'order' => 3]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_CUSTOM, 'name' => 'Test Object 4', 'unique' => 0, 'order' => 4]);
     Element::create(['region_id' => 1, 'category' => Element::CATEGORY_OBJECT, 'type' => Element::TYPE_EXPECTED, 'name' => 'Test Object 5', 'unique' => 0, 'order' => 5]);
 }
 /**
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function redirect()
 {
     $array = explode("-", $_POST['key']);
     if (count($array) == 2 and $array[0] != '' and $array[1] != '') {
         $mt = explode(' ', microtime());
         if (session("user") == "") {
             session(["user" => $mt[1] * 1000 + round($mt[0] * 1000)]);
         }
         $experiment = Experiment::where("key", $array[0])->first();
         if ($experiment == null) {
             return redirect('/');
         }
         $elements = array();
         $element = Element::find($experiment->element_id);
         while ($element != null) {
             if ($element->type == Element::XORGATE) {
                 $hash = $array[1][0] . substr(md5(date("s", strtotime($element->created_at)) . $array[1][0]), -2);
                 if (trim($hash) != trim($array[1])) {
                     return redirect('/');
                 }
                 $xor = json_decode($element->ref, true);
                 $elements = array_merge($elements, $xor[$array[1][0]]);
             } else {
                 $elements[] = $element->id;
             }
             $element = $element->next();
         }
         session(['experiment' => $array[0], 'elements' => $elements]);
         $antwort = new Answer();
         $antwort->element = 0;
         $antwort->experiment = $experiment->id;
         $antwort->value = $array[1][0];
         $antwort->student = session("user");
         $antwort->save();
         return redirect('/experiment/' . $array[0] . '/0');
     } else {
         return redirect('/');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $node_id)
 {
     $data = $request->all();
     $rules = $this->provider->rules($data['module']);
     $validator = Validator::make($data, $rules);
     //TODO
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $data = Data::checkActive($data);
     $data = Data::renameField($data, 'module', 'module_id');
     //        dd($data);
     // Create Module
     $module = $this->provider->store($data);
     $data = Data::addField($data, 'row', $module['id']);
     //Create Element
     $element = \App\Element::create($data);
     $element->save();
     $data = Data::addField($data, 'node_id', $node_id);
     $data = Data::addField($data, 'element_id', $element->id);
     $content = \App\Content::create($data)->save();
     //todo: flash message
     return redirect()->route('admin.element.index', ['node' => $node_id]);
 }
 public function show($id)
 {
     $experiment = Experiment::findOrFail($id);
     $elements = array();
     $element = Element::find($experiment->element_id);
     $xor2 = array();
     $xorElement = null;
     $antworten = array();
     while ($element != null) {
         if ($element->type == 5) {
             $xorElement = $element;
             $xor = json_decode($element->ref, true);
             $xor2 = array();
             if (is_array($xor)) {
                 foreach ($xor as $pkey => $pfad) {
                     foreach ($pfad as $ekey => $el) {
                         $ele = Element::find($el);
                         if ($ele->type == 2 or $ele->type == 3 or $ele->type == 4) {
                             $xor2[$pkey][$ekey] = $ele;
                             $antwortenObjects = Answer::where("element", $ele->id)->where("experiment", $id)->get();
                             foreach ($antwortenObjects as $antwortObject) {
                                 $antworten[$antwortObject->student][$ele->id] = $antwortObject;
                             }
                         }
                     }
                 }
             }
         } elseif ($element->type == 2 or $element->type == 4 or $element->type == 3) {
             $elements[] = Element::findOrFail($element->id);
             $antwortenObjects = Answer::where("element", $element->id)->where("experiment", $id)->get();
             foreach ($antwortenObjects as $antwortObject) {
                 $antworten[$antwortObject->student][$element->id] = $antwortObject;
             }
         }
         $element = $element->next();
     }
     $elements = array_merge($elements, [$xor2]);
     $fields = array();
     $fields2 = Field::all();
     foreach ($fields2 as $field) {
         $fields[$field->id] = $field;
     }
     return view('auswertung.show', compact('experiment', 'elements', 'antworten', 'xorElement', 'fields'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $inputs = Request::all();
     Element::create($inputs);
     return redirect()->route('admin_elements_index')->with('status', 'Type created');
 }
Beispiel #6
0
 /**
  * Get Elements that are not linked to the Layout ID provided.
  *
  * @param  \Layout ID
  */
 public function getUnlinkedElements($id)
 {
     //Find all elements related to a Layout
     $linkedElements = LayoutsController::getElements($id);
     //Get the elements that are related to id
     $linkedElementsId = $linkedElements->lists('id');
     if (count($linkedElementsId) == 0) {
         //If there is no related elements, return all available elements.
         return Element::all();
     } else {
         //If there is related elements, find the ones that are not related
         return Element::whereNotIn('id', $linkedElementsId)->get();
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $element = Element::find($id);
     $element->delete();
     return \Redirect::route('element.index');
 }
                @endforeach
            @elseif($element->type == 3)
                <!--model-->
                @if(file_exists("svg/".$experiment->id."/".$element->id."_".$user->student.".png"))
                    <td><a href="http://localhost/svg/{{ $experiment->id }}/{{  $element->id }}_{{$user->student}}.png">http://localhost/svg/{{ $experiment->id }}/{{  $element->id }}_{{$user->student}}.png</a></td>
                @else
                    <td>&nbsp;</td>
                @endif
            @elseif($element->type == 4)
                <!--feedback-->
                <td>{{ \App\Answer::getValue($id, 'feedback',$user->student) }}</td>
            @elseif($element->type == 5)
                <!--xor-->
            @foreach($row as $subid => $subrow)
                <?php 
$ele = \App\Element::getElement($subid);
?>
                @if($ele->type == 3)
                    @if(file_exists("svg/".$experiment->id."/".$ele->id."_".$user->student.".png"))
                        <td style="background-color: #d9edf7"><a href="http://localhost/svg/{{ $experiment->id }}/{{  $ele->id }}_{{$user->student}}.png">http://localhost/svg/{{ $experiment->id }}/{{  $ele->id }}_{{$user->student}}.png</a></td>
                    @else
                        <td style="background-color: #d9edf7">&nbsp;</td>
                    @endif
                @elseif($ele->type == 2)
                    @foreach($subrow as $subsubrow)
                        <?php 
$fie = \App\Field::getField($subsubrow['field']);
?>
                        @if($fie->type == 3 OR $fie->type == 4 OR $fie->type == 5)
                            <td  style="background-color: #C1D4DE;">{{\App\Field::getFieldAnswers($subsubrow['field'], \App\Answer::getValue($subid, $subsubrow['field'],$user->student)) }} </td>
                        @else
 public function get()
 {
     $elements = Element::paginate(12);
     return response()->success(compact('elements'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $experiment = Experiment::where("key", $id)->first();
     if ($experiment == null) {
         return redirect('/');
     }
     $element = $experiment->element()->first();
     $allow[] = $experiment->element_id;
     $e = $experiment->element;
     while (Element::find($e->element_id) != null) {
         $allow[] = $e->element_id;
         if ($e->type == 5) {
             $fieldnr = session("field");
             $field_id = substr($fieldnr, 0, -2);
             $field_type = substr($fieldnr, -2);
             $field = Field::where('id', $field_id)->where('type', $field_type)->first();
             if ($field == null) {
                 return redirect('/');
             }
         }
         $e = Element::find($e->element_id);
     }
     session(['fields' => $allow]);
     return view('experiment.show', compact('experiment', 'element'));
 }
Beispiel #11
0
 /**
  * @param $id
  * @return mixed
  */
 public static function getElement($id)
 {
     return Element::findOrFail($id);
 }
Beispiel #12
0
<?php

include 'app/Element.php';
echo \app\Element::radio_Button('my radio', array(0 => 'radio 1', 1 => 'radio 2'));
/**
 * Created by IntelliJ IDEA.
 * User: Lakna
 * Date: 2/10/2016
 * Time: 8:22 AM
 */
include "includes/header.php";
?>
<fieldset>
<div>
<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="label">Question Name</label>
  <div class="col-md-4">
  <input id="label" name="label" type="text" placeholder="Type you label name here" class="form-control input-md">

  </div>
</div>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="helpTxt">Help text</label>
  <div class="col-md-4">
  <input id="helpTxt" name="helpTxt" type="text" placeholder="" class="form-control input-md">

  </div>
</div>
<?php

/**
 * Created by IntelliJ IDEA.
 * User: Roledene
 * Date: 2/10/2016
 * Time: 6:33 PM
 */
include 'app/Database.php';
include 'app/Element.php';
$db = new \app\Database();
$db->deleteAllElements();
$db->insertElement("textBox", \app\Element::text(array('label' => 'Tex Box', 'placeholder' => 'text', 'help' => 'help', 'require' => false), true, false), 0);
$db->insertElement("button", \app\Element::button("Button"), 0);
$db->insertElement("link", \app\Element::buttonLink("Button", "add.php"), 0);
$db->insertElement("RadioButton", \app\Element::radioButton("Radiobtn", array(0 => 'radio 1')), 0);
$db->insertElement("CheckBox", \app\Element::checkBox("Check", array(0 => 'check 1', 1 => 'check 2')), 0);
$db->insertElement("Dropdown", \app\Element::dropdownList("Drop", array(0 => 'op 1', 1 => 'op 2', 2 => 'op 3')), 0);
Beispiel #14
0
//
//    $attribute = array(
//        'class' => 'col-xs-9 col-md-9',
//        'style' => 'background: blue; height: 20px;'
//    );
//
//
//    //body
//    Boostrap::openDiv($attribute); // column open
//        // open form
//        $attribute = array(
//            'class' => 'form-horizontal',
//            'action' => 'test.php'
//        );
//        Boostrap::openForm("Form Builder",$attribute);
//
//            $result = $db->getAllElements();
//            while($row = $result->fetch_assoc()) {
//                echo  $row["code"]. "<br>";
//            }
////        echo Element::button("submit");
////        echo Element::buttonLink("submit","test.html");
//        Boostrap::closeForm();
//    Boostrap::closeDiv(); //column end
//
//Boostrap::closeDiv(); // row end
// just call it here and see weather it works
echo Element::redio_Button();
//if parameters need pass
echo Element::text(array('label' => 'my custom text box', 'placeholder' => 'custom holder', 'help' => 'your help goes here'));
include "includes/footer.php";
 public function compose(View $view)
 {
     $examList = array('' => 'Select a exam date') + DB::table('sittings')->select(DB::raw('concat (month," / ",year) as sitting,id'))->lists('sitting', 'id');
     $view->with('methodList', \App\Method::all())->with('levelList', \App\Level::all())->with('paperList', \App\Paper::all())->with('centreList', \App\Centre::all())->with('elementList', \App\Element::all())->with('examList', $examList);
 }
Beispiel #16
0
 function getElement($id, $name, $link, $options)
 {
     $element = '';
     switch ($id) {
         case 105:
             return Element::text(array('label' => $name, 'placeholder' => ''));
         case 106:
             return Element::button($name);
         case 107:
             return Element::buttonLink($name, $link);
         case 108:
             return Element::radioButton($name, $options);
         case 109:
             return Element::checkBox($name, $options);
         case 110:
             return Element::dropdownList($name, $options);
     }
 }
Beispiel #17
0
echo Boostrap::openForm("Create a new form", $attribute);
echo str_replace('{text}', 'Form Name', Element::text(array('label' => 'Form Name', 'placeholder' => '', 'help' => ''), 'textinput', false));
echo Element::button("New");
echo Boostrap::closeForm();
//////////////////////////////
// open form
$attribute = array('class' => $isBoostrap ? 'form-horizontal' : '', 'action' => 'index.php');
echo Boostrap::openForm("Add elements to form", $attribute);
// open form
// make the form body here
/////////////////////////////////////////////////
echo str_replace('{button}', ' ', Element::text(array('label' => "Question Name", 'placeholder' => "Type name tag", 'help' => "Type name tag here")));
$label = array();
$count = '';
$result = $db->getAllElements();
while ($row = $result->fetch_assoc()) {
    $label[$row['id']] = $row['label'];
    //                array_push($label,$row["id"],$row["label"]);
}
//die(print_r($label));
echo Element::dropdownList("select elements", $label);
echo str_replace('{button}', ' ', Element::text(array('label' => "If you are selecting, RadioButton, CheckBox or Dropdown list please give options as comma seperated list", 'placeholder' => "Type name tag", 'help' => "Type name tag here"), 'list'));
echo Element::button("Add element to form");
////////////////////////////////////////
Boostrap::closeForm();
// end form
Boostrap::closeDiv();
//column end
Boostrap::closeDiv();
// row end
include "includes/footer.php";
 public function orderXor(Request $request)
 {
     if (!Auth::check()) {
         return redirect('/auth/login');
     }
     $element = Element::findOrFail($request->element);
     $element->ref = json_encode($request->array);
     $element->save();
     return 'ok';
 }