static function find($search_id) { $found_topic = null; $topics = Topic::getAll(); foreach ($topics as $topic) { $id = $topic->getId(); if ($search_id == $id) { $found_topic = $topic; } } return $found_topic; }
<tr><td><input type="text" name="question" value="" id="second_td" style="display:none;"/></td></tr> <tr> <td id="first_td">Describe your Question/Problem (Min 60 characters) : </td> <td><textarea id="teatarea_td" name="question" placeholder="Describe your Question/Problem (Min 60 characters)"></textarea></td> </tr> <tr> <td id="first_td">Heading (Min 20 characters) : </td> <td><input type="text" id="second_td" name="heading" placeholder="Provide an appropriate heading for your question (minimum 20 characters)"/></td> </tr> <tr> <td id="first_td">Topic : </td> <td><select id="second_td" name="topic_id"> <option value="">--Select Topic--</option> <?php $topicObj = new Topic(); $rows = $topicObj->getAll(); foreach ($rows as $row) { ?> <option value="<?php echo $row['topic_id']; ?> "><?php echo $row['topic']; ?> </option> <?php } ?> </select>
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)); }); //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);
function test_update() { $name = "Writing"; $test_topic = new Topic($name); $test_topic->save(); $name2 = "Interview"; $test_topic->update($name2); $topics = Topic::getAll(); $result = $topics[0]->getName(); $this->assertEquals($name2, $result); }
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <?php require 'core/init.php'; $topic = new Topic(); $template = new Template('templates/frontpage.php'); $template->topics = $topic->getAll(); //echo '<pre>'; //var_dump($t); //echo '</pre>'; echo $template;