Example #1
0
 public function checkWord()
 {
     $id = Input::get('word');
     $mode = Input::get('mode');
     $value = Input::get('value');
     $user = Auth::user();
     $words = $user->words();
     $box = 1;
     $correct = 0;
     $wrong = 0;
     $foundWord = null;
     foreach ($words->get() as $word) {
         if ($word->id == $id) {
             $foundWord = $word;
             $box = $word->box;
             $correct = $word->correct;
             $wrong = $word->wrong;
             break;
         }
     }
     if ($foundWord != null) {
         /* remove the old relation*/
         $words->detach($id);
     } else {
         $foundWord = Word::find($id);
     }
     /* check the input */
     $correctValue = $foundWord->english;
     if ($mode == 'english') {
         $correctValue = $foundWord->german;
     }
     $result = 'success';
     if (JsonController::correctInput($value, $correctValue)) {
         $correct++;
         $box++;
     } else {
         $result = 'error';
         $wrong++;
         $box--;
     }
     /* add the new word */
     if ($box < 1) {
         $box = 1;
     }
     $words->attach($id, array('box_level' => $box, 'correct' => $correct, 'wrong' => $wrong));
     /* create new box statistic */
     $jc = new JsonController();
     $words = $jc->userWords();
     $boxes = array();
     $countWords = 0;
     foreach ($words as $word) {
         $box = $word->box;
         if (!array_key_exists($box, $boxes)) {
             $boxes[$box] = 1;
         } else {
             $boxes[$box]++;
         }
         $countWords++;
     }
     ksort($boxes);
     $back = array('result' => $result, 'countWords' => $countWords, 'boxes' => $boxes);
     return json_encode($back);
 }
Example #2
0
@section('scripts')
<script type="text/javascript">var percent = 50;</script>
{{ HTML::script('js/practice.js') }}

@show

@section('content')
<div class="row">
    <div class="small-12 small-centered column">
        <div class="ui segment">
            <h3>Vokabeln üben</h3>
            <hr/>

            <?php 
$jc = new JsonController();
$words = $jc->userWords();
$boxes = array();
$countWords = 0;
foreach ($words as $word) {
    $box = $word->box;
    if (!array_key_exists($box, $boxes)) {
        $boxes[$box] = 1;
    } else {
        $boxes[$box]++;
    }
    $countWords++;
}
ksort($boxes);
?>
 public function __construct(IResourceServerContext $resource_server_context, ILogService $log_service)
 {
     parent::__construct($log_service);
     $this->resource_server_context = $resource_server_context;
 }
 public function afterExecuteRoute(Dispatcher $dispatcher)
 {
     parent::afterExecuteRoute($dispatcher);
 }
 public function __construct(ILogService $log_service)
 {
     parent::__construct($log_service);
     $this->filter_delimiter = '+';
     $this->field_delimiter = ',';
 }
Example #6
0
        $correctTmp = array_pop($statement);
        $statement2Tmp = array_pop($statement2);
        if (array_pop($language) == 'ger') {
            $inputTmp = array_pop($input);
            if (JsonController::correctInput($inputTmp, $statement2Tmp)) {
                echo "<td><font color='green'>" . $inputTmp . "</font></td>";
                $correct++;
            } else {
                echo "<td><font color='red'>" . $inputTmp . "</font></td>";
                $wrong++;
            }
            echo "<td>" . $correctTmp . "</td>";
        } else {
            $inputTmp = array_pop($input);
            echo "<td>" . $correctTmp . "</td>";
            if (JsonController::correctInput($inputTmp, $statement2Tmp)) {
                echo "<td><font color='green'>" . $inputTmp . "</font></td>";
                $correct++;
            } else {
                echo "<td><font color='red'>" . $inputTmp . "</font></td>";
                $wrong++;
            }
        }
        $counter++;
        echo "</tr>";
    }
    echo "</tbody></table>";
}
?>

        </div>