예제 #1
0
파일: app.php 프로젝트: umamiMike/promptr
    $promptr_name = $_POST['promptr_name'];
    $topic_id = $_POST['topic_id'];
    $new_promptr = new Promptr($promptr_name, $topic_id);
    $new_promptr->save();
    return $app['twig']->render('promptrs.html.twig', array('promptrs' => Promptr::getAll(), 'topic' => $topic_id, 'topic_picked' => true));
    // flag for included template
});
$app->get("/topic/{id}", function ($id) use($app) {
    $topic = Topic::find($id);
    $promptrs = $topic->getPromptrs();
    $allT = Topic::getAll();
    return $app['twig']->render("topic.html.twig", array('topic' => $topic, 'promptrs' => $promptrs, 'all_topics' => $allT));
});
// PROMPTR.HTML.TWIG
//delete question from NEW PROMPTR route -- then displays promptr page
$app->get("promptr/{id}", function ($id) use($app) {
    $promptr = Promptr::find($id);
    $questions = $promptr->getQuestions();
    return $app['twig']->render("promptr.html.twig", array('promptr' => $promptr, 'questions' => $questions));
});
//delete question route
$app->delete("/promptr/{id}/delete_question/{qId}", function ($id, $qId) use($app) {
    $question_id = $qId;
    $promptr = Promptr::find($id);
    $topic = Topic::find($promptr->getTopicId());
    $question = Question::findById($question_id);
    $question->delete();
    $questions = $promptr->getQuestions();
    return $app['twig']->render("promptr.html.twig", array('promptr' => $promptr, 'questions' => $questions, 'topic' => $topic));
});
return $app;
예제 #2
0
 function testFind()
 {
     $promptr1_name = "mikes 5 tips";
     $topic_id = 20;
     $test_promptr = new Promptr($promptr1_name, $topic_id);
     $test_promptr->save();
     $promptr2_name = "ians 5 tips";
     $topic_id = 20;
     $test_promptr2 = new Promptr($promptr2_name, $topic_id);
     $test_promptr2->save();
     $result = Promptr::find($test_promptr->getId());
     $this->assertEquals($test_promptr, $result);
 }