$topic = Topic::find($promptr->getTopicId()); $new_question_text = $_POST['question']; $new_description = $_POST['description']; $new_question = new Question($new_question_text, $new_description); $new_question->save(); $promptr->addQuestion($new_question); return $app['twig']->render('promptr.html.twig', array('promptr' => $promptr, 'questions' => $promptr->getQuestions(), 'topic' => $topic)); }); // PROMPTRS.HTML.TWIG // ADD PROMPTR -- adds a prompter and displays promptrs within the topic $app->post("/promptrs", function () use($app) { $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)); });
static function find($search_id) { $found_promptr = null; $promptrs = Promptr::getAll(); foreach ($promptrs as $promptr) { $id = $promptr->getId(); if ($search_id == $id) { $found_promptr = $promptr; } } return $found_promptr; }
function testUpdateName() { $promptr1_name = "mikes 5 tips"; $topic_id = 20; $promptr1_id = 200; $test_promptr = new Promptr($promptr1_name, $topic_id); $test_promptr->save(); $promptr2_name = "ians 5 tips"; $test_promptr->updateName($promptr2_name); $promptrs = Promptr::getAll(); $result = $promptrs[0]->getName(); $this->assertEquals($promptr2_name, $result); }