function followedAction() { $MUID = $_GET['UID']; //传被访问者的信息 $user = new user(); $info = $user->getAllbyUID($MUID); $answer = new answer(); $likeQ = new likeQ(); $likeA = new likeA(); $followu = new followU(); $ffnum = $followu->getFollownumbyUID($MUID); //$this->view->followednum=$ffnum; //关注你的人的人数 $uids = $followu->getUIDsbyFUID($MUID); //关注你的人的uid数组 $this->view->pinfo = array('UID' => $MUID, 'nickname' => $info['nickname'], 'sex' => $info['sex'], 'image' => $info['image'], 'institute' => $info['institute'], 'grade' => $info['grade'], 'answernum' => $answer->getAnswernumbyUID($MUID), 'likenum' => $likeA->getLikenumbyUID($MUID) + $likeQ->getLikenumbyUID($MUID), 'follownum' => $ffnum, 'followednum' => count($uids)); $FFPI = array(); for ($i = 0; $i < count($uids); $i++) { $info = $user->getAllbyUID($uids[$i]); $FFPI[$i] = array("MUID" => $uids[$i], "Mnickname" => $info['nickname'], "Mimage" => $info['image'], 'Minstitute' => $info['institute'], "Mgrade" => $info['grade']); } $this->view->FPI = $FFPI; $this->render("homepage-follower"); }
public function __construct($userid, $connection, $dbPrefix) { $GLOBALS["dbPrefix"] = $dbPrefix; $set = null; $setid = -1; $questionid = -1; $answerid = -1; foreach ($connection->query('SELECT * FROM ' . $GLOBALS["dbPrefix"] . 'question_set WHERE ownerid="' . $userid . '"') as $setRow) { $set = new cardSet(s); $set->setSetId($setRow['setid']); $setid = $setRow['setid']; $set->setSetName($setRow['setname']); $set->setSetDescription($setRow['setdescription']); foreach ($connection->query('SELECT * FROM ' . $GLOBALS["dbPrefix"] . 'question_question WHERE ' . $GLOBALS["dbPrefix"] . 'question_question.set="' . $setid . '";') as $questionRow) { $question = new question(); $question->setId($questionRow['questionid']); $question->setQuestion($questionRow['question']); $question->setMode($questionRow['mode']); $question->setRightAnswered($questionRow['rightAnswered']); $question->setWrongAnswered($questionRow['wrongAnswered']); $questionid = $questionRow['questionid']; foreach ($connection->query('SELECT * FROM ' . $GLOBALS["dbPrefix"] . 'question_answer WHERE ' . $GLOBALS["dbPrefix"] . 'question_answer.ownerquestion=' . $questionid) as $answerRow) { $answerobj = new answer(); $answerobj->setAnswer($answerRow['answertext']); $answerobj->setAnswerId($answerRow['answerid']); $question->addAnswer($answerobj); } $set->addQuestion($question); } array_push($this->sets, $set); } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store($id, $question, Answer_validate $request) { $request->all(); $id1 = Auth::id(); $answer = new answer(array('Content' => $request->get('content'))); $answer->id = $id1; $answer->qid = $id; $answer->save(); return redirect('/Userhome'); }
public function answerAction() { if ($_POST) { $content = $_POST['content']; $uid = $_POST['UID']; $qid = $_POST['QID']; $abstract = substr($content, 0, 100); $time = date('Y-m-d H:i:s'); $answer = new answer(); $answer_arr = array('UID' => $uid, 'QID' => $qid, 'Time' => $time, 'Acontent' => $content, 'Aabstract' => $abstract); $aid = $answer->insertAnswer($answer_arr); //$this->view->aid = $aid; echo $aid; //$this->render('answered'); } }
public function __construct($userid, $connection) { $set = null; $setid = -1; $questionid = -1; $answerid = -1; foreach ($connection->query('SELECT * FROM fullQuestionSet WHERE ownerid="' . $userid . '"') as $row) { if ($row['setid'] != $setid) { $set = new cardSet(); $set->setSetId($row['setid']); $set->setSetName($row['setname']); $set->setSetDescription($row['setdescription']); } if ($questionid != $row['questionid'] && $row['questionid'] != null) { $question = new question(); $question->setId($row['questionid']); $question->setQuestion($row['question']); $question->setMode($row['mode']); $question->setRightAnswered($row['rightAnswered']); $question->setWrongAnswered($row['wrongAnswered']); } if ($answerid != $row['answerid'] && $row['answerid'] != null) { $answerobj = new answer(); $answerobj->setAnswer($row['answertext']); $answerobj->setAnswerId($row['answerid']); } if ($answerid != $row['answerid'] && $row['answerid'] != null) { $question->addAnswer($answerobj); $answerid = $row['answerid']; } if ($questionid != $row['questionid'] && $row['questionid'] != null) { $set->addQuestion($question); $questionid = $row['questionid']; } if ($set != null && $row['setid'] != $setid) { $setid = $row['setid']; array_push($this->sets, $set); } } }
public function getLikedNumByUID($UID) { $likea = new likeA(); $answer = new answer(); $AIDS = $answer->getAIDsbyUID($UID); $sum = 0; for ($i = 0; $i < count($AIDS); $i++) { $sum += $likea->getLikenumbyAID($AIDS[$i]); } return $sum; }
<?php defined('DT_ADMIN') or exit('Access Denied'); $qid = isset($qid) ? intval($qid) : 0; require MD_ROOT . '/answer.class.php'; $do = new answer(); $menus = array(array('答案列表', '?moduleid=' . $moduleid . '&file=' . $file . '&qid=' . $qid), array('答案审核', '?moduleid=' . $moduleid . '&file=' . $file . '&qid=' . $qid . '&action=check')); $this_forward = '?moduleid=' . $moduleid . '&file=' . $file; if (in_array($action, array('', 'check'))) { $sfields = array('内容', '会员名', '昵称', 'IP', '问题ID', '答案ID', '参考资料'); $dfields = array('content', 'username', 'passport', 'ip', 'qid', 'itemid', 'linkurl'); $sorder = array('结果排序方式', '添加时间降序', '添加时间升序', '投票次数降序', '投票次数升序'); $dorder = array('itemid desc', 'addtime DESC', 'addtime ASC', 'vote DESC', 'vote ASC'); isset($fields) && isset($dfields[$fields]) or $fields = 0; isset($order) && isset($dorder[$order]) or $order = 0; isset($ip) or $ip = ''; $expert = isset($expert) ? intval($expert) : 0; $fields_select = dselect($sfields, 'fields', '', $fields); $order_select = dselect($sorder, 'order', '', $order); $condition = ''; if ($keyword) { $condition .= in_array($dfields[$fields], array('qid', 'itemid', 'ip')) ? " AND {$dfields[$fields]}='{$kw}'" : " AND {$dfields[$fields]} LIKE '%{$keyword}%'"; } if ($qid) { $condition .= " AND qid='{$qid}'"; } if ($ip) { $condition .= " AND ip='{$ip}'"; } if ($expert) { $condition .= " AND expert>0";
/** * abstract function which creates the form to create / edit the answers of the question * @param FormValidator $form */ function processAnswersCreation($form) { if (!self::isAnswered()) { $table = Database::get_course_table(TABLE_QUIZ_ANSWER); Database::delete($table, array('c_id = ? AND question_id = ?' => array($this->course['real_id'], $this->id))); $answer = $form->getSubmitValue('answer'); $formula = $form->getSubmitValue('formula'); $lowestValues = $form->getSubmitValue('lowestValue'); $highestValues = $form->getSubmitValue('highestValue'); $answerVariations = $form->getSubmitValue('answerVariations'); $this->weighting = $form->getSubmitValue('weighting'); // Create as many answers as $answerVariations for ($j = 0; $j < $answerVariations; $j++) { $auxAnswer = $answer; $auxFormula = $formula; $nb = preg_match_all('/\\[[^\\]]*\\]/', $auxAnswer, $blanks); if ($nb > 0) { for ($i = 0; $i < $nb; ++$i) { $blankItem = $blanks[0][$i]; $replace = array("[", "]"); $newBlankItem = str_replace($replace, "", $blankItem); $newBlankItem = "[" . trim($newBlankItem) . "]"; // take random float values when one or both edge values have a decimal point $randomValue = strpos($lowestValues[$i], '.') !== false || strpos($highestValues[$i], '.') !== false ? mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]); $auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer); $auxFormula = str_replace($blankItem, $randomValue, $auxFormula); } require_once api_get_path(LIBRARY_PATH) . 'evalmath.class.php'; $math = new EvalMath(); $result = $math->evaluate($auxFormula); $result = number_format($result, 2, ".", ""); // Remove decimal trailing zeros $result = rtrim($result, "0"); // If it is an integer (ends in .00) remove the decimal point if (mb_substr($result, -1) === ".") { $result = str_replace(".", "", $result); } // Attach formula $auxAnswer .= " [" . $result . "]@@" . $formula; } $this->save(); $objAnswer = new answer($this->id); $objAnswer->createAnswer($auxAnswer, 1, '', $this->weighting, null); $objAnswer->position = array(); $objAnswer->save(); } } }
public function start() { $this->connection->exec("CREATE TABLE IF NOT EXISTS `" . $this->getDbPrefix() . "question_set` (\r\n\t\t`setid` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t`setname` varchar(25) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t`setdescription` varchar(1000) COLLATE utf8_unicode_ci NOT NULL,\r\n\t\t`ownerid` int(11) NOT NULL,\r\n\t\t`editcount` int(11) NOT NULL,\r\n\t\t`lasttimestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\r\n\t\t`createtimestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\r\n\t\t`firstowner` int(11) NOT NULL,\r\n\t\t`tagsid` int(11) NOT NULL,\r\n\t\tPRIMARY KEY (`setid`)\r\n\t)"); $this->connection->exec("CREATE TABLE IF NOT EXISTS `" . $this->getDbPrefix() . "question_question` (\r\n\t\t`questionid` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t`set` int(11) NOT NULL,\r\n\t\t`question` varchar(100) NOT NULL,\r\n\t\t`mode` text NOT NULL,\r\n\t\t`rightAnswered` int(11) NOT NULL DEFAULT '0',\r\n\t\t`wrongAnswered` int(11) NOT NULL DEFAULT '0',\r\n\t\tPRIMARY KEY (`questionid`)\r\n\t)"); $this->connection->exec("CREATE TABLE IF NOT EXISTS `" . $this->getDbPrefix() . "question_answer` (\r\n\t\t`answerid` int(11) NOT NULL AUTO_INCREMENT,\r\n\t\t`ownerquestion` int(11) NOT NULL,\r\n\t\t`answertext` varchar(100) NOT NULL,\r\n\t\t`rightAnswer` tinyint(1) NOT NULL COMMENT 'true if it is the right answer, false if not (for multiple answers)',\r\n\t\tPRIMARY KEY (`answerid`)\r\n\t)"); $connection = $this->connection; $template = $this->templateObject; $messages = array(); $template->assign("pluginId", $_GET['plugin']); $template->assign("folder", $this->folder); require_once $this->folder . 'card.class.php'; $allSets = new allCardSets($_SESSION["user"]->getId(), $connection, $this->getDbPrefix()); switch ($_GET["action"]) { case "create": if (!isset($_GET['nrofquestions'])) { $template->assign("nrofquestions", 3); } else { $template->assign("nrofquestions", $_GET['nrofquestions']); } return $template->fetch($this->folder . 'templates/cardPlugin_create.tpl'); break; case "mkcreatecardset": if (!empty($_POST["cardsetname"])) { $newCardSet = new cardSet(); $newCardSet->setSetName($_POST["cardsetname"]); $newCardSet->setSetDescription($_POST["cardsetdescription"]); $template->assign("nrofquestions", 3); $allSets->newSet($newCardSet, $_SESSION["user"]->getId(), $connection); $index = 0; while ($_GET['nrofquestions'] != $index) { if ($_POST['question' . $index] != "" && $_POST['answer' . $index] != "") { $question = new question(); $question->setQuestion($_POST['question' . $index]); $question->setMode(1); $answer = new answer(); $answer->setAnswer($_POST['answer' . $index]); $newCardSet->newQuestion($question, $connection); $question->newAnswer($answer, $connection); } $index = $index + 1; } //$newCardSet->newQuestion($question, $connection); // $question->newAnswer($answer, $connection); array_push($messages, "Create cardset successfull!"); $template->assign("messages", $messages); $template->assign("cardsets", $allSets->getSets()); return $template->fetch($this->folder . 'templates/cardPlugin.tpl'); } break; case "singlecardset": if (!empty($_GET["setid"])) { $set = $allSets->getSetBySetId($_GET["setid"]); $template->assign("setid", $_GET['setid']); $template->assign("cardsettitle", $set->getSetName()); $template->assign("cardsetdescription", $set->getSetDescription()); $template->assign("dojorequire", array("dojox.charting.widget.Chart2D", "dojox.charting.themes.PurpleRain")); $questions = $set->getQuestions(); // TODO may better use a empty()-method if (count($questions) > 0) { $template->assign("random", $_GET['random']); if ($_GET['random'] == "yes") { if (isset($_SESSION['lastid'])) { $lastQuestionId = $_SESSION['lastid']; } $questionid = cardtools::randomArrayPosition($questions); $question = $questions[$questionid]; $_SESSION['lastid'] = $questionid; $template->assign("nextquestion", 1); } else { if (!empty($_GET['nextquestion'])) { $questionid = cardtools::oneBeforeInArray($questions, $_GET['nextquestion']); $lastQuestionId = cardtools::oneBeforeInArray($questions, $questionid); $question = $questions[$questionid]; $template->assign("questionid", $question->getQuestionId()); if (count($questions) > $_GET['nextquestion']) { $template->assign("nextquestion", $_GET['nextquestion'] + 1); } else { if (count($questions) == $_GET['nextquestion']) { $template->assign("question", $question->getQuestion()); $template->assign("nextquestion", 1); } } } else { $question = $questions[0]; $questionid = $question->getQuestionId(); $template->assign("questionid", $question->getQuestionId()); if (count($questions) > 1) { $template->assign("nextquestion", 2); } else { $template->assign("nextquestion", 1); } } } $template->assign("question", $question->getQuestion()); if (!empty($_POST['answer'])) { $answer = $question->getAnswers(); if ($questions[$lastQuestionId]->checkRightAnswer($_POST['answer'], $connection)) { array_push($messages, "Answer " . $_POST['answer'] . " was right! :) (Question was: " . $questions[$lastQuestionId]->getQuestion() . ")"); } else { $answer = $questions[$lastQuestionId]->getAnswers(); array_push($messages, "Answer was wrong! :( <br /> Question:" . $questions[$lastQuestionId]->getQuestion() . " and answer: " . $answer[0]->getAnswer()); } } if ($question->getRightAnswered() == 0 && $question->getWrongAnswered() == 0) { $template->assign("rightAnswered", "0.1"); $template->assign("wrongAnswered", "0.1"); } else { $template->assign("rightAnswered", $question->getRightAnswered()); $template->assign("wrongAnswered", $question->getWrongAnswered()); } } else { //FIXME why i don't come here in? why the array is 1 without having questions? $template->assign("question", "There are no questions!"); } $template->assign("messages", $messages); return $template->fetch($this->folder . 'templates/cardPlugin_singlecardset.tpl'); break; } case "deletecardset": $template->assign("setid", $_GET['setid']); $set = $allSets->getSetBySetId($_GET["setid"]); if ($set == false) { // TODO build a error-page $template->assign("cardsetname", "There is no set with id " . $_GET["setid"]); } else { $template->assign("what", "cardset"); $template->assign("cardsetname", $set->getSetName()); if (isset($_POST['sure'])) { if ($_POST['sure'] == "yes") { $set->deleteSet($connection); } header("Location: plugin.php?plugin=" . $_GET['plugin']); } } return $template->fetch($this->folder . 'templates/cardPlugin_delete.tpl'); break; case "editcardset": $noCardset = true; if (isset($_POST["setid"]) || isset($_GET["setid"])) { // TODO build a error-page $set = $allSets->getSetBySetId($_POST["setid"]); if ($set != false) { $noCardset = false; } else { $set = $allSets->getSetBySetId($_GET["setid"]); if ($set != false) { $noCardset = false; } } } if (!$noCardset) { $template->assign("questions", $set->getQuestions()); $template->assign("setid", $set->getSetId()); $template->assign("cardsetname", $set->getSetName()); $template->assign("cardsetdescription", $set->getSetDescription()); if (isset($_POST['sure'])) { if ($_POST['sure'] == "on") { $set->updateSetDescription($_POST['cardsetdescripton'], $connection); $set->updateSetName($_POST['cardsetname'], $connection); } header("Location: plugin.php?plugin=" . $_GET['plugin'] . "&action=singlecardset&setid=" . $set->getSetId()); } } if ($noCardset) { $template->assign("cardsetname", gettext("There is no set with id ") . $_POST["setid"] . $_GET["setid"]); } return $template->fetch($this->folder . 'templates/cardPlugin_editcardset.tpl'); break; case "editquestion": $noCardset = true; if (isset($_POST["setid"]) || isset($_GET["setid"])) { // TODO build a error-page $set = $allSets->getSetBySetId($_POST["setid"]); if ($set != false) { $template->assign("setid", $set->getSetId()); $noCardset = false; } else { $set = $allSets->getSetBySetId($_GET["setid"]); if ($set != false) { $template->assign("setid", $set->getSetId()); $noCardset = false; } } $question = $set->getQuestionById($_GET['questionid']); $template->assign("questionid", $question->getQuestionId()); } if (!$noCardset) { $template->assign("question", $question->getQuestion()); if (isset($_POST['sure'])) { if ($_POST['sure'] == "on") { $question->updateQuestion($_POST['question'], $connection); } header("Location: plugin.php?plugin=" . $_GET['plugin'] . "&action=singlecardset&setid=" . $_GET['setid']); } } if ($noCardset) { $template->assign("cardsetname", "There is no set with id " . $_POST["setid"] . $_GET["setid"]); } return $template->fetch($this->folder . 'templates/cardPlugin_editquestion.tpl'); break; case "deletequestion": $template->assign("setid", $_GET['setid']); $set = $allSets->getSetBySetId($_GET["setid"]); if ($set == false) { // TODO build a error-page $template->assign("cardsetname", "There is no set with id " . $_GET["setid"]); } else { $question = $set->getQuestionById($_GET["questionid"]); if ($question == false) { $template->assign("cardsetname", "There is no question with id " . $_GET["questionid"]); } else { $template->assign("questionid", $question->getQuestionId()); $template->assign("what", "question"); $template->assign("cardsetname", $question->getQuestion()); if (isset($_POST['sure'])) { if ($_POST['sure'] == "yes") { $question->deleteQuestion($connection); } header("Location: plugin.php?plugin=" . $_GET['plugin']); } } } return $template->fetch($this->folder . 'templates/cardPlugin_delete.tpl'); break; case "addquestion": $template->assign("cardsets", $allSets->getSets()); if (!empty($_POST["cardset"]) && !empty($_POST['question1']) && !empty($_POST['answer1'])) { $set = $allSets->getSetBySetId($_POST["cardset"]); $question = new question(); $question->setMode(1); $question->setQuestion($_POST['question1']); $answer = new answer(); $answer->setAnswer($_POST['answer1']); $set->newQuestion($question, $connection); $question->newAnswer($answer, $connection); array_push($messages, "Add question successfull"); } $template->assign("messages", $messages); return $template->fetch($this->folder . 'templates/cardPlugin_modify.tpl'); break; default: $carding = new allCardSets($_SESSION["user"]->getId(), $connection, $this->getDbPrefix()); $template->assign("cardsets", $carding->getSets()); return $template->fetch($this->folder . 'templates/cardPlugin.tpl'); } }
/** * abstract function which creates the form to create / edit the answers of the question * @param FormValidator $form */ function processAnswersCreation($form) { global $charset; $answer = $form->getSubmitValue('answer'); //remove the :: eventually written by the user $answer = str_replace('::', '', $answer); // get the blanks weightings $nb = preg_match_all('/\\[[^\\]]*\\]/', $answer, $blanks); if (isset($_GET['editQuestion'])) { $this->weighting = 0; } if ($nb > 0) { $answer .= '::'; for ($i = 0; $i < $nb; ++$i) { $blankItem = $blanks[0][$i]; $replace = array("[", "]"); $newBlankItem = str_replace($replace, "", $blankItem); $newBlankItem = "[" . trim($newBlankItem) . "]"; $answer = str_replace($blankItem, $newBlankItem, $answer); $answer .= $form->getSubmitValue('weighting[' . $i . ']') . ','; $this->weighting += $form->getSubmitValue('weighting[' . $i . ']'); } $answer = api_substr($answer, 0, -1); } $is_multiple = $form->getSubmitValue('multiple_answer'); $answer .= '@' . $is_multiple; $this->save(); $objAnswer = new answer($this->id); $objAnswer->createAnswer($answer, 0, '', 0, '1'); $objAnswer->save(); }
public function tagAction() { //封装header $auth = Zend_Auth::getinstance(); #获取当前用户实例 $UID = $auth->getIdentity(); #取得当前用户信息 if ($auth->hasIdentity() == false) { $this->render('index'); } $tuser = new user(); $user = $tuser->getAllbyUID($UID); $header = array("UID" => $user["UID"], "image" => $user["image"]); //封装tag $ttag = new tag(); $tans = new answer(); $task = new ask(); $tquestion = new question(); $tfollowq = new followQ(); $tagnum = $ttag->gerRequest()->getParam("tagnum"); $tags = $ttag->getAllTags(); for ($i = 0; $i < $tagnum; $i++) { //第i个tag $QIDs = $ttag->getQIDsbyTags($tags[$i]); for ($j = 0; $j < tagnum; $j++) { //第j个question $mUID = $task->getUIDbyQID($QIDs[$j]); $person = $tuser->getAllbyUID($mUID); $image1[$j] = $person['image']; $question = $tquestion->getAllbyQID($QIDs[$j]); $QID1[$j] = $QIDs[$i]; $title1[$j] = $question["title"]; $abstract1[$j] = $question["Qabstract"]; $follownum[$j] = $tfollowq->getFollownumbyQID($QID1[$j]); $answernum[$j] = $tans->getAnswernumbyQID($QID1[$j]); $tag1[$j] = $ttag->getTagbyQID($QID1[$j]); $time1[$j] = $task->getAskTimebyQID($QIDs[$j]); $tag[$i][$j] = array("image" => $image1[$j], "QID" => $QIDs[$j], "title" => $title1[$j], "abstract" => $abstract1[$j], "follownum" => $follownum[$j], "answernum" => $answernum[$j], "tag" => $tag1[$j], "time" => $time1[$j]); } } //传递变量,render $this->view->tag = $tag; $this->view->header = $header; $this->render('tag'); }
/** * abstract function which creates the form to create / edit the answers of the question * @param the formvalidator instance */ function processAnswersCreation($form) { global $charset; $answer = $form->getSubmitValue('answer'); //Due the fckeditor transform the elements to their HTML value $answer = api_html_entity_decode($answer, ENT_QUOTES, $charset); //remove the :: eventually written by the user $answer = str_replace('::', '', $answer); // get the blanks weightings $nb = preg_match_all('/\\[[^\\]]*\\]/', $answer, $blanks); if (isset($_GET['editQuestion'])) { $this->weighting = 0; } if ($nb > 0) { $answer .= '::'; for ($i = 0; $i < $nb; ++$i) { $answer .= $form->getSubmitValue('weighting[' . $i . ']') . ','; $this->weighting += $form->getSubmitValue('weighting[' . $i . ']'); } $answer = api_substr($answer, 0, -1); } $is_multiple = $form->getSubmitValue('multiple_answer'); $answer .= '@' . $is_multiple; $this->save(); $objAnswer = new answer($this->id); $objAnswer->createAnswer($answer, 0, '', 0, ''); $objAnswer->save(); }
<?php require_once 'answer.php'; require_once 'question.php'; require_once 'comment.php'; $ins = new answer(); $res = $ins->getAIDsbyQID(2); print_r($res); $ins = new question(); $res = $ins->getAllbyQID(2); print_r($res); // $ins = new question(); // $res =$ins->getAIDsbyQID(1); // print_r($res);
if ($_POST['sure'] == "yes") { $question->deleteQuestion($connection); } header("Location: cards.php"); } } } $template->display('cards_delete.tpl'); break; case "addquestion": $template->assign("cardsets", $allSets->getSets()); if (!empty($_POST["cardset"]) && !empty($_POST['question1']) && !empty($_POST['answer1'])) { $set = $allSets->getSetBySetId($_POST["cardset"]); $question = new question(); $question->setMode(1); $question->setQuestion($_POST['question1']); $answer = new answer(); $answer->setAnswer($_POST['answer1']); $set->newQuestion($question, $connection); $question->newAnswer($answer, $connection); array_push($messages, "Add question successfull"); } $template->assign("messages", $messages); $template->display('cards_modify.tpl'); break; default: $carding = new allCardSets($_SESSION["user"]->getId(), $connection); $template->assign("cardsets", $carding->getSets()); $template->display('cards.tpl'); break; }
" target="_blank" ><?php echo $topic->title; ?> </a></td> <td><?php echo $topic->user->profile->first_name . ' ' . $topic->user->profile->last_name; ?> </a></td> <td><?php echo lang_decode($topic->user->group->name, 'th'); ?> </a></td> <td><?php echo mysql_to_th($topic->created); ?> </a></td> <td style="text-align:center;"><?php $ans = new answer(); echo round($ans->select('user_id,session')->distinct()->where_related('questionaire', 'topic_id', $topic->id)->get()->result_count()); ?> </td> </tr> <?php } ?> </table> <?php echo $topics->pagination(); ?> </div> </div>
/** * Update the specified post in storage. * * @param int $id * @return Response */ public function update($id) { $validate = Validator::make(Input::all(), Answer::$rules); if ($validate->passes()) { $audio = Input::file('audio'); $name = time() . "-" . $audio->getClientOriginalName(); $avatar = $audio->move("./answers/", $name); $answer = new answer(); $answer->title = Input::get('title'); $answer->info = Input::get('info'); $answer->audio = $name; if (Auth::check()) { $answer->user_id = Auth::id(); } else { $answer->user_id = 0; } $answer->question_id = $id; $answer->save(); return Redirect::action('AnswerController@index'); $response = array('status' => 'success', 'msg' => 'Setting created successfully'); return Response::json($response); } return Redirect::back()->withErrors($validate)->withInput(); }