/**
  * 
  * @param Question $question
  * @return int id of the Question inserted in base. False if it didn't work.
  */
 public static function flush($question)
 {
     $questionId = $question->getId();
     $questionVar = $question->getQuestion();
     $theme = $question->getTheme()->getIdTheme();
     if ($questionId > 0) {
         $sql = 'UPDATE question SET ' . 'question = ?, ' . 'THEME_id_theme = ? ' . 'WHERE id_question = ?';
         $params = array('sii', &$questionVar, &$theme, &$questionId);
     } else {
         $sql = 'INSERT INTO question (question, THEME_id_theme) VALUES (?, ?)';
         $params = array('si', &$questionVar, &$theme);
     }
     $idInsert = BaseSingleton::insertOrEdit($sql, $params);
     if ($idInsert !== false && $questionId > 0) {
         $idInsert = $questionId;
     }
     return $idInsert;
 }
 public static function adminQuestion($id)
 {
     $title = "Question";
     $currentQuestion = Question::getCurrentQuestion();
     $remaining_time = Question::getRemainingTime($currentQuestion);
     $leading = Post::getLeadingBant($currentQuestion);
     $get_question = Question::getQuestion($id);
     return View::make('admin.questions-show')->with(['question' => $currentQuestion, 'remaining_time' => $remaining_time, 'leading' => $leading, 'questions' => $get_question, 'title' => $title]);
 }
Example #3
0
    $random = new random();
    $wylosowane = null;
    for ($i = 1; $i <= $ile_wylosowac; $i++) {
        do {
            $liczba = $random->getRandom($ile_pytan);
            $losowanie_ok = true;
            $losowanie_ok = $random->checkRandom($liczba, $ile_juz_wylosowano, $wylosowane);
            if ($losowanie_ok == true) {
                $ile_juz_wylosowano++;
                $wylosowane[$ile_juz_wylosowano] = $liczba;
            }
        } while ($losowanie_ok != true);
    }
    echo '<form action="check.php?category=' . $category . '" method="post" role="form">';
    for ($i = 1; $i <= $ile_wylosowac; $i++) {
        $question = $questions->getQuestion($wylosowane[$i], $category);
        echo '<div class=" well well-lg " style="background-color:rgba(16,16,16,0.95);border:15px solid #272727;">' . '<li style="list-style-type:none;text-align:left;font-weight:bold;font-size:19px;color:white;">
    <div style="post-border><p style="font-size:20px;">' . $question['pytanie'] . '</p></div>
    <div class="radio post-border">
      <label><input type="radio" name="' . $i . '" value="A"><b>A</b>.' . $question['A'] . '</label>
    </div>
    <div class="radio post-border">
      <label><input type="radio" name="' . $i . '" value="B"><b>B</b>.' . $question['B'] . '</label>
    </div>
    <div class="radio post-border">
      <label><input type="radio" name="' . $i . '" value="C"><b>C</b>.' . $question['C'] . '</label>
    </div>
    <div class="radio post-border">
      <label><input type="radio" name="' . $i . '" value="D"><b>D</b>.' . $question['D'] . '</label>
    </div>
</li></div>';
 /**
  * Outputs the question prompt.
  *
  * @param OutputInterface $output
  * @param Question        $question
  */
 protected function writePrompt(OutputInterface $output, Question $question)
 {
     $message = $question->getQuestion();
     if ($question instanceof ChoiceQuestion) {
         $width = max(array_map('strlen', array_keys($question->getChoices())));
         $messages = (array) $question->getQuestion();
         foreach ($question->getChoices() as $key => $value) {
             $messages[] = sprintf("  [<info>%-{$width}s</info>] %s", $key, $value);
         }
         $output->writeln($messages);
         $message = $question->getPrompt();
     }
     $output->write($message);
 }
Example #5
0
function getData($limit, $quest)
{
    for ($i = 0; $i < $limit; $i++) {
        $j = $i + 1;
        $qu = new Question();
        $topics = new Topic();
        $qu->setID($quest[$i]['q_id']);
        $qu->loadQuestion();
        $qu_text = $qu->getQuestion();
        echo "<tr>";
        echo "<td class='td'>{$j}</td>";
        echo "<td class='td'>" . $quest[$i]['q_id'] . "</td>";
        echo "<td class='td'>" . stripslashes($qu_text) . "</td>";
        // array Werte ausgeben
        echo "<td class='td'> " . $quest[$i]['count'] . "</td>";
        echo "<td class='td' > " . $quest[$i]['percentagCorrect'] . "%</td>";
        echo "</tr>";
    }
}
Example #6
0
 function test_update()
 {
     //Arrange
     $test_field = "What is their name?";
     $test_description = "What you want to call your character.";
     $test_question = new Question($test_field, $test_description);
     $test_question->save();
     $new_quest = "How tall are they?";
     $new_desc = "The height you want your character to be.";
     //Act
     $test_question->update($new_quest, $new_desc);
     //Assert
     $this->assertEquals(["How tall are they?", "The height you want your character to be."], [$test_question->getQuestion(), $test_question->getDescription()]);
 }
Example #7
0
 /**
  * Docimology
  * To get the number of answers with the 'correct' status.
  *
  *
  * @param int      $exerciseId
  * @param Question $sq         questions
  *
  * @return array
  */
 private function getCorrectAnswer($exerciseId, $sq)
 {
     $em = $this->doctrine->getManager();
     $question = $sq->getQuestion();
     $responses = $em->getRepository('UJMExoBundle:Response')->getExerciseInterResponsesWithCount($exerciseId, $question->getId());
     $typeInter = $question->getType();
     $interSer = $this->container->get('ujm.exo_' . $typeInter);
     $interX = $interSer->getInteractionX($question->getId());
     $scoreMax = $interSer->maxScore($interX);
     $responsesTab = $this->responseStatus($responses, $scoreMax);
     return $responsesTab;
 }
Example #8
0
 public function newQuestion($id)
 {
     try {
         $report = new Report($id);
         if (!$report->allowQuestion()) {
             throw new fValidationException('Not allowed to ask question.');
         }
         $category = fRequest::get('category', 'integer');
         if ($category == 0) {
             throw new fValidationException('Please choose a category.');
         }
         $question = new Question();
         $question->setUsername(fAuthorization::getUserToken());
         $question->setReportId($report->getId());
         if ($category < 0) {
             $question->setCategory($category);
         } else {
             $question->setCategory(Question::ABOUT_PROBLEM_HIDDEN);
             $problem = new Problem($category);
             $question->setProblemId($problem->getId());
         }
         $question->setAskTime(new fTimestamp());
         $question->setQuestion(trim(fRequest::get('question')));
         if (strlen($question->getQuestion()) < 10) {
             throw new fValidationException('Question too short (minimum 10 bytes).');
         }
         if (strlen($question->getQuestion()) > 500) {
             throw new fValidationException('Question too long (maximum 500 bytes).');
         }
         $question->store();
         fMessaging::create('success', 'Question saved.');
     } catch (fExpectedException $e) {
         fMessaging::create('warning', $e->getMessage());
     } catch (fUnexpectedException $e) {
         fMessaging::create('error', $e->getMessage());
     }
     Util::redirect("/contest/{$id}");
 }
Example #9
0
if ($is_get_ok = isset($_GET['category'])) {
    $category = $_GET['category'];
    for ($i = 1; $i <= $how_much; $i++) {
        echo '<div class=" well well-lg " style="background-color:rgba(16,16,16,0.95);border:15px solid #272727;">';
        //   echo '<li style="list-style-type:none;text-align:center;font-weight:bold;color:white;">';
        if (!($is_ok = isset($_POST["{$i}"]))) {
            $correct_answer = $question->getAnswer($id[$i - 1], $category);
            echo "<p class=\"text-center\" style=\"font-size:20px;color:red;\">W pytaniu {$i} nie udzieliłeś żadnej odpowiedzi!</p>";
        } else {
            if ($is_ok = isset($_POST["{$i}"])) {
                $correct_answer = $question->getAnswer($id[$i - 1], $category);
                if ($correct_answer['answer'] == $_POST["{$i}"]) {
                    echo "<p class=\"text-center\" style=\"font-size:20px;color:green;\">Pytanie {$i} - poprawna odpowiedź! (" . $_POST["{$i}"] . ")</p>";
                    $score++;
                } else {
                    echo "<p class=\"text-center\" style=\"font-size:20px;color:red;\">Pytanie {$i} - błędna odpowiedz (" . $_POST["{$i}"] . ")</p>";
                }
            }
        }
        $complete_question = $question->getQuestion($id[$i - 1], $category);
        echo $twig->render('check.twig', array('question' => $complete_question['pytanie'], 'A' => $complete_question['A'], 'B' => $complete_question['B'], 'C' => $complete_question['C'], 'D' => $complete_question['D'], 'correct_answer' => $correct_answer['answer'], 'iterator' => $i));
    }
    if ($score > 3) {
        echo "<h1 class=\"score\" style=\"\">Uzyskałeś/-aś wynik {$score}/5. Dobrze!</h1>";
    } else {
        echo "<h1 class=\"score2\" style=\"\">Uzyskałeś/-aś wynik {$score}/5. Słabo!</h1>";
    }
} else {
    echo "<h1 style=\"color:grey;text-align: center;\">Wystąpił błąd, nie znaleziono kategorii!</h1>";
}
include 'footer.html';