Example #1
0
 public function askAction()
 {
     //include_once("connect.php");
     if ($_POST) {
         $content = $_POST['content'];
         $id = $_POST['UID'];
         $title = $_POST['title'];
         $abstract = substr($content, 0, 100);
         $nowtime = date('Y-m-d H:i:s');
         $tab = $_POST['tag'];
         //$tab = 'hahaha';
         $ask = new ask();
         $question = new question();
         $tag = new tag();
         $question_arr = array('QTitle' => $title, 'Qcontent' => $content, 'Qabstract' => $abstract, 'looknum' => 0);
         $qid = $question->insertQuestion($question_arr);
         $ask_arr = array('UID' => $id, 'QID' => $qid, 'time' => $nowtime);
         $ask->insertAsk($ask_arr);
         $tag_arr = array('QID' => $qid, 'tag' => $tab);
         $tag->insertTag($tag_arr);
         //$this->view->QID = $qid;
         echo $qid;
         //$this->render('questioned');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(question_validate $request)
 {
     $request->all();
     $id = Auth::id();
     $question = new question(array('Question' => $request->get('question'), 'Content' => $request->get('content')));
     $question->id = $id;
     $question->save();
     return redirect('/Userhome');
 }
function survey_test($atts, $content = null)
{
    global $wpdb;
    global $survey_salt;
    //Empty the database and restart it.
    if (isset($_GET['restart'])) {
        //Truncate the created tables for this plugin
        $wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . "survey");
        $wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . "survey_questions");
        $wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . "survey_answers");
        $wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . "survey_users");
        $wpdb->query("TRUNCATE TABLE " . $wpdb->prefix . "survey_user_answers");
    }
    $survey1 = new survey(FALSE, "Survey 1");
    $question1 = $survey1->add_question(question::truefalse, "True/False: Order 1", -1, -1, 1);
    $question1->add_answer("TF Answer 1 DONT SHOW THIS!", 1);
    $question2 = $survey1->add_question(question::multichoice, "Multiple Choice: Order 2", -1, -1, 2);
    $question2->add_answer("MC Answer 1", 1);
    $question2->add_answer("MC Answer 2");
    $question2->add_answer("MC Answer 3", 3);
    $question3 = $survey1->add_question(question::dropdown, "Dropdown: Order 3", -1, -1, 3);
    $question3->add_answer("DD Answer 1");
    $question3->add_answer("DD Answer 2", 2);
    $question4 = $survey1->add_question(question::multiselect, "Multiple Select: Order 4", -1, -1, 1);
    $question4->add_answer("MS Answer 2", 2);
    $question4->add_answer("MS Answer 1", 1);
    $question4->add_answer("MS Answer 3", 3);
    $question5 = $survey1->add_question(question::shortanswer, "Short Answer: Order 6", -1, -1, 6);
    $question5->add_answer("SA Answer 1 DONT SHOW THIS!", 1);
    $question6 = $survey1->add_question(question::longanswer, "Long Answer: Order 5", -1, -1, 5);
    $question6->add_answer("LA Answer 1 DONT SHOW THIS!", 1);
    $question7 = $survey1->add_question(question::multichoiceother, "Multiple Choice Other: Order 7", -1, -1, 7);
    $question7->add_answer("MCO Answer 1");
    $question7->add_answer("MCO Answer 2");
    $question8 = new question(FALSE, question::multiselectother, "Multiple Select Other: Order 8", -1, -1, 8);
    $question8->add_answer("MSO Answer 1");
    $question8->add_answer("MSO Answer 2");
    $survey1->add_qobject($question8);
    //$survey1->output_survey();
    debug($survey1);
    //Empty the database and restart it.
    if (isset($_GET['restart'])) {
        $insert = $wpdb->insert($wpdb->prefix . 'survey_users', array('username' => 'tester', 'password' => sha1('tester' . $survey_salt, true), 'fullname' => 'Test User'), array('%s', '%s', '%s'));
        $id = $insert ? $wpdb->insert_id : FALSE;
        if ($id !== FALSE) {
            var_dump(bin2hex(sha1('tester' . $survey_salt, true)));
            var_dump(bin2hex($wpdb->get_var("SELECT password FROM {$wpdb->prefix}survey_users WHERE id={$id}")));
        } else {
            echo "Failed to insert!";
            var_dump(bin2hex(sha1('test' . $survey_salt, true)));
        }
        $post = array('menu_order' => 0, 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_author' => get_current_user_id(), 'post_content' => "[survey-page id={$survey1->id}]", 'post_name' => 'test-survey-page', 'post_status' => 'publish', 'post_title' => 'Test Survey Page', 'post_type' => 'page');
        wp_insert_post($post, true);
    }
}
Example #4
0
 /**
  * Returns the question.
  */
 public function get_question()
 {
     if (!isset($this->question)) {
         $this->question = question::from_id($this->qaqid);
     }
     return $this->question;
 }
Example #5
0
 public function get_question_details($qid)
 {
     $result = array();
     $db = new Database();
     if ($db->connect()) {
         if ($db->select('questions', 'q_id,c_id,q_name,q_tag,q_hint,q_points', NULL, 'q_id=' . $qid)) {
             $dbResult = $db->getResult();
             foreach ($dbResult as $out) {
                 $q = new question();
                 $q->set_question_information($out['q_id'], $out['c_id'], $out['q_name'], $out['q_tag'], $out['q_hint'], $out['q_points']);
                 array_push($result, $q);
             }
         }
         $db->disconnect();
     }
     return $result;
 }
 public function update($slug, QuestionFormRequest $request)
 {
     $question = question::whereSlug($slug)->firstOrFail();
     $question->question = $request->get('question');
     $question->option1 = $request->get('option1');
     $question->option2 = $request->get('option2');
     $question->option3 = $request->get('option3');
     $question->option4 = $request->get('option4');
     $question->save();
     return redirect(action('QuestionsController@edit', $question->slug))->with('status', 'The questions ' . $slug . ' has been updated!');
 }
 public function index()
 {
     //return question::all();
     // $question = question::all();
     // return view('questions.index', compact('question'));
     try {
         $response = ['question' => []];
         $statusCode = 200;
         $question = question::all();
         foreach ($question as $question) {
             $response['question'][] = ['id' => $question->id, 'question' => $question->question, 'Option 1' => $question->option1, 'Option 2' => $question->option2, 'Option 3' => $question->option3, 'Option 4' => $question->option4, 'Slug' => $question->slug];
         }
     } catch (Exception $e) {
         $statusCode = 404;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
Example #8
0
 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);
         }
     }
 }
Example #9
0
 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');
 }
Example #10
0
 /**
  * Create a new question
  * @param question $question
  * @param unknown_type $connection
  */
 public function newQuestion($question, $connection)
 {
     $connection->exec("INSERT INTO `" . $GLOBALS['dbPrefix'] . "question_question` (`set`, `question`, `mode`) VALUES (" . $this->setid . ", '" . $question->getQuestion() . "', '" . $question->getMode() . "')");
     $question->setId($connection->lastInsertId());
     array_push($this->questions, $question);
 }
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
$question = new question();
$list_Pending = $question->getQueslist("8", "1");
$list_Processed = $question->getQueslist("8", "2");
if ($_POST['Login']) {
    $flag = $question->checklogin($_POST[username], $_POST[password]);
    if ($flag == 1) {
        echo "<script>alert('登錄成功!');location.href='index.php';</script>";
    } elseif ($flag == -1) {
        echo "<script>alert('用戶名錯誤!');location.href='index.php';</script>";
    } else {
        echo "<script>alert('用戶密碼錯誤!');location.href='index.php';</script>";
    }
}
if ($_GET['action'] == loginout) {
    unset($_SESSION);
    echo "<script>alert('用戶成功退出!');</script>";
}
//unset($_SESSION);
$smarty->assign("right", $_SESSION[usrinfo][username]);
$smarty->assign("username", $_SESSION[usrinfo][username]);
$smarty->assign("tname", $_SESSION[usrinfo][tname]);
$smarty->assign("list_Pending", $list_Pending);
$smarty->assign("list_Processed", $list_Processed);
$smarty->display("service.html");
Example #12
0
    function qcm($val = 0)
    {
        // Declaration des variables:
        global $idutilisateur;
        global $adresserepertoiresite;
        //En tete du QCM :
        ?>
		<div id="form_questionnaire">
			<script type="text/javascript">
				<!--
				<?php 
        //Calcul des identifiants des questions precedante et suivante
        $prec = $val - 1;
        if ($prec < 0) {
            $prec = 0;
        }
        $suiv = $val + 1;
        if (isset($_POST["reponse"])) {
            $suiv = $suiv - 1;
        }
        if ($suiv + 1 > $this->nbquestion_nonrep()) {
            $suiv = $suiv - 1;
        }
        if ($prec != $val) {
            ?>
					function fprec(){
						if (document.getElementById("formulaire_qcm").reponse!=undefined && document.getElementById("formulaire_qcm").reponse.value==undefined)
						{
							document.getElementById('formulaire_qcm').val.value = "<?php 
            echo $prec;
            ?>
";
						}
						document.getElementById('formulaire_qcm').submit();
					}
					<?php 
        }
        if ($suiv != $val || isset($_POST["reponse"])) {
            ?>
					function fsuiv(){
						if (document.getElementById("formulaire_qcm").reponse!=undefined && document.getElementById("formulaire_qcm").reponse.value==undefined)
						{
							document.getElementById('formulaire_qcm').val.value = "<?php 
            echo $suiv;
            ?>
";
						}
						document.getElementById('formulaire_qcm').submit();
					}
					<?php 
        }
        ?>
				//-->
			</script>
			<form action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
" method="post" id="formulaire_qcm">
	    		<div class="fielset">
					<fieldset><legend><?php 
        echo $this->titre;
        ?>
</legend>
						<div id="intitule_questionnaire">
							<?php 
        echo $this->intitule;
        ?>
						</div><?php 
        //Creation de variables temporaires:
        require_once $adresserepertoiresite . '/scripts/php/class.question.php';
        require_once $adresserepertoiresite . '/scripts/php/class.reponse.php';
        $vtemp = new question();
        $vreponse = new reponse();
        // Recherche de la nieme question pour laquelle l'utilisateur n'a pas encore repondu:
        $select_sql = "select T1.* \r\n\t\t\t\t\t\tFROM {$vtemp->table} AS T1 \r\n\t\t\t\t\t\tLEFT JOIN {$vreponse->table} AS T2 ON (T1.idquestion=T2.idquestion_rel AND T2.idutilisateur_rel='{$idutilisateur}' AND T2.visible='1')\r\n\t\t\t\t\t\tWHERE T2.idreponse IS NULL AND T1.visible='1' AND T1.idquestionnaire_rel='{$this->identifiant}' AND T1.validation='1'\r\n\t\t\t\t\t\tORDER BY T1.ordre LIMIT {$val}, 1;";
        $select_sql = requete_sql($select_sql);
        if (compte_sql($select_sql) > 0) {
            //affichage de la question voulue non encore repondue
            if (!isset($_GET['num'])) {
                $question_sql = tableau_sql($select_sql);
                $num = $question_sql[$vtemp->champ_identifiant];
            }
            $question = new question($num);
            $question->formulaire_question();
        } else {
            //affichage du score de l'utilisateur pour ce questionnaire
            $score = $this->score_qcm();
            //calcul de l'angle de l'arc de reponse(s) fausse(s)
            if ($score[0] > 0) {
                $rapport_total_sur_faux = $score[3] / $score[0];
            } else {
                $rapport_total_sur_faux = 0;
            }
            $vanglefaux = 360 * $rapport_total_sur_faux;
            $vpctvrai = 1 - $rapport_total_sur_faux;
            $vpctvrai = $vpctvrai * 100;
            // French notation
            $nombre_format_francais = number_format($vpctvrai, 2, ',', ' ');
            $vtextepctvrai = $nombre_format_francais . "%";
            $vtextevrai = _REPONSES_VRAI . $score[2] . "/" . $score[0];
            //calcul de l'angle de l'arc du score
            if ($score[7] - $score[6] != 0) {
                $rapport_score_ecart = ($score[4] - $score[6]) / ($score[7] - $score[6]);
            } else {
                $rapport_score_ecart = 0;
            }
            $vanglescore = 360 * (1 - $rapport_score_ecart);
            $vpctscore = $rapport_score_ecart;
            $vpctscore = $vpctscore * 100;
            // French notation
            $nombre_format_francais_score = number_format($vpctscore, 2, ',', ' ');
            $vtextepctscore = $nombre_format_francais_score . "%";
            $vtextescore = _SCORE . $score[4] . "/" . $score[7];
            $vtextescoremin = _MIN . $score[6];
            //texte alternatif pour l'image :
            $vtexte_alt = $vtextevrai . " ==> " . $vtextepctvrai . "  / " . $vtextescore . " ==> " . $vtextepctscore . " (" . $vtextescoremin . ")";
            ?>
							
							<img src="image.scorequestionnaire.php?i=<?php 
            echo $this->identifiant;
            ?>
&amp;u=<?php 
            echo $idutilisateur;
            ?>
" alt="<?php 
            echo $vtexte_alt;
            ?>
" />
							
							<?php 
        }
        ?>
<div class="bouton_cadre"><?php 
        //Calcul du nombre de question(s) restante(s)
        $nombre_question = $this->nbquestion_nonrep();
        //Affichage des boutons de suivi du questionnaire
        if ($prec != $val && !isset($_POST["reponse"]) && $nombre_question > 0) {
            ?>
<input type="button" value="<?php 
            echo _QUESTION_PRECEDANTE;
            ?>
" onclick="fprec()" /> <?php 
        }
        if ($suiv != $val && !isset($_POST["reponse"]) && $nombre_question > 0) {
            ?>
<input type="button" value="<?php 
            echo _QUESTION_SUIVANTE;
            ?>
" onclick="fsuiv()"/>
							<?php 
        }
        if (isset($_POST["reponse"]) && $nombre_question > 0) {
            ?>
<input type="button" value="<?php 
            echo _QUESTION_SUIVANTE;
            ?>
" onclick="fsuiv()"/>
							<?php 
        }
        if (isset($_POST["reponse"]) && $nombre_question == 0) {
            ?>
<input type="button" value="<?php 
            echo _RESULTAT_QUESTIONNAIRE;
            ?>
" onclick="fsuiv()"/>
							<?php 
        }
        ?>
<input type="hidden" name="val" value="0" /><input type="hidden" name="v" value="<?php 
        echo $this->identifiant;
        ?>
" />
						</div>
					</fieldset>
				</div>
			</form>
		</div>
		<?php 
    }
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
//include_once dirname(__FILE__).'/libs/editor/fckeditor.php';
//$oFCKeditor = new FCKeditor('anscontent');
//$oFCKeditor->BasePath ='./libs/editor/'; //定义其路径
//$oFCKeditor->ToolbarStartExpanded = false; //设置
//$oFCKeditor->ToolbarStart = 'Basic';
//$oFCKeditor->Width = "620";
//$oFCKeditor->Height = "280";
$question = new question();
$k_id = $_GET['k_id'];
$list = $question->getQuesInfo($k_id);
if (count($list) > 0) {
    for ($i = 0; $i < count($list); $i++) {
        $list[$i]['question_time'] = date("Y-m-d i:m:s", $list[$i]['question_time']);
        switch ($list[$i]['status']) {
            case 1:
                $list[$i]['newstatus'] = "<font color='red'>未解決</font>";
                break;
            case 2:
                $list[$i]['newstatus'] = "<font color='green'>已解決</font>";
                break;
            case 3:
                $list[$i]['newstatus'] = "<font color='blue'>已鎖定</font>";
                break;
            default:
                $list[$i]['newstatus'] = "<font color='red'>未解決</font>";
                break;
Example #14
0
<?php

session_start();
include "../inc/config.php";
include "../inc/classes/class.question.php";
if (!isset($_POST["action"]) && ($_POST["action"] != "vote" && $_POST["action"] != "unvote")) {
    echo json_encode(array("ERROR" => "true", "ERROR_CODE" => "ACTION_NOT_FOUND", "ERROR_TEXT" => "Ação não encontrada"));
}
if (!isset($_POST["url"])) {
    echo json_encode(array("ERROR" => "true", "ERROR_CODE" => "QUESTION_NOT_FOUND", "ERROR_TEXT" => "Pergunta não encontrada"));
} else {
    $question = new question();
    try {
        $question->loadQuestion($_POST["url"]);
    } catch (exception $e) {
        echo json_encode(array("ERROR" => "true", "ERROR_CODE" => "QUESTION_NOT_FOUND", "ERROR_TEXT" => "Pergunta não encontrada"));
    }
    if (!isset($_SESSION['login_provider'])) {
        echo json_encode(array("ERROR" => "true", "ERROR_CODE" => "NOT_LOGGEDIN", "ERROR_TEXT" => "Conecte-se para realizar esta ação"));
        exit;
    }
    $question->loadQuestion($_POST["url"]);
    $userId = $_SESSION["login_provider"] . "_" . $_SESSION["id"];
    $name = $_SESSION["name"];
    $email = $_SESSION["email"];
    if (!isset($name)) {
        $name = "";
    }
    if (!isset($email)) {
        $email = "";
    }
Example #15
0
<?php

$qaclass = new question();
$qaclass->wheres = 'patient_id=' . $_SESSION['patient_id'] . ' and actionkey=' . $actionkey;
$qalist = $qaclass->getList();
if ($qalist) {
    echo "<a name='qa'></a>";
}
foreach ($qalist as $rs) {
    ?>
            <div class="doctorsSignoffBox">
			  <div><?php 
    echo $rs['UserName'];
    ?>
 Date: <?php 
    echo $rs['date_added'];
    ?>
			  </div>
			  <div>
				<?php 
    echo nl2br($rs['content']);
    ?>
			  </div>
			  <div class="clearfloat"></div>
			</div>
<?php 
}
function survey_submit_question_ajax_callback()
{
    check_ajax_referer('survey_submit_question_nonce', 'security');
    //Make sure they're logged in with the appropriate permissions.
    if (!current_user_can('manage_options')) {
        wp_die(__('You do not have sufficient permissions to access this page.'));
    }
    //Set up the basic structure for the question array.
    $question = array('qtype' => '', 'qtext' => '', 'answers' => array());
    //This array will keep track of all of the answer ids being edited.
    $edit = array();
    //Fill in the array properly using the posted data.
    foreach ($_POST['question'] as $posted) {
        //If the name is answer then it's a brand new answer and not being edited.
        if ($posted['name'] == 'answer') {
            $question['answers'][] = $posted['value'];
        } elseif (strstr($posted['name'], '-answer') !== FALSE) {
            $answer_id = strstr($posted['name'], '-answer', TRUE);
            $question['answers'][$answer_id] = $posted['value'];
            $edit[] = $answer_id;
        } else {
            $question[$posted['name']] = $posted['value'];
        }
    }
    //If the question is being edited, then this will use the id of that question to create the qobject.
    if (isset($question['survey_edit'])) {
        $qobject = new question(intval($question['survey_edit']));
        $qobject->edit_question($question['qtext']);
        $qobject->edit_type($question['qtype']);
        $qobject->edit_dependency($question['depquestion'], $question['depanswer']);
    } else {
        $qobject = new question(FALSE, $question['qtype'], $question['qtext'], $question['depquestion'], $question['depanswer']);
    }
    switch ($question['qtype']) {
        case question::truefalse:
        case question::shortanswer:
        case question::longanswer:
            //These question types don't have answers.
            break;
        default:
            foreach ($question['answers'] as $answer_id => $answer) {
                //If the answer id is in the array, then it must be edited, otherwise it's a new answer.
                if (in_array($answer_id, $edit)) {
                    $qobject->edit_answer($answer_id, $answer);
                } else {
                    $qobject->add_answer($answer);
                }
            }
    }
    //Don't add a new question to the survey list if it's being edited.
    if (!isset($question['survey_edit'])) {
        $survey = new survey(intval($_POST['survey']));
        $survey->add_qobject($qobject);
    }
    echo "Success!";
    die;
    // this is required to return a proper result
}
Example #17
0
        $res_rand = array();
        $pid_num = count($res_all);
        $temp = array();
        if ($pid_num < $que_of_num) {
            $que_of_num = $pid_num;
        }
        for ($i = 0; $i < $que_of_num; $i++) {
            $rand_num = rand(0, $pid_num - $i - 1);
            $res_rand[$i] = $res_all[$rand_num];
            $temp = $res_all[$rand_num];
            $res_all[$rand_num] = $res_all[$pid_num - $i - 1];
            $res_all[$pid_num - $i - 1] = $temp;
        }
        return $res_rand;
    }
}
$que = new question();
$que->getRandJud(1, 60);
//$que->addMulAns(" #QI'm a ?  #man #Qfengjei #plant", 1);
//$que->addMulJud("#Qfengjiu# Y#Qchenyou# N", 1);
//echo $que->addMulSel("#Qque#A#B#C#D# C#QUE#AA#BB#CC#DD#  E", 1);
//$que->getSel(-1,'凤姐');
//$que->addOneAns("fengjie", "man", 1);
//$que->addOneJud("fengji", " Y ", 1);
//$que->addOneSel("fengjie", "Y", "B", "C", "D"," A ", 1);
?>




<?php

require_once '../../../../../class/autoload.inc';
$test_type = new test_type();
$test_type_panel = $test_type->getTestTypePanel();
if (isset($_POST["quetext"])) {
    $question = new question();
    $result = $question->addMulSel($_POST["quetext"], $_POST["deg"]);
} elseif (isset($_POST["sinque"])) {
    $question = new question();
    $result = $question->addOneSel($_POST["sinque"], $_POST["sela"], $_POST["selb"], $_POST["selc"], $_POST["seld"], $_POST["chos"], $_POST["deg"]);
}
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="../../../../js/jquery-1.9.0.js" type='text/javascript'></script>
        <script src="../../../../jquery-ui/js/jquery-ui-1.10.1.custom.js" type='text/javascript'></script>
        <script src="../../../../js/common.js" type='text/javascript'></script>
        <script src="index.js" type='text/javascript'></script>
        <link rel="stylesheet" href="../../../../jquery-ui/development-bundle/themes/sunny/jquery-ui.css" />
        <link rel="stylesheet" href="common.css" />
        <title>添加选择题</title>
    </head>
    <body>
        <script language="javascript">
            <?php 
if (isset($result)) {
    echo "\n                    \$(function(){\n                        \$('#dialog').html('{$result}').dialog('open');\n                    });";
}
?>
Example #19
0
 public function tagAction()
 {
     if ($_GET) {
         $key = $this->getRequest()->getParam('tag', '');
         $P = $this->getRequest()->getParam('P', '1');
     }
     $perpage = 10;
     //question number per page
     $answer = new answer();
     $followQ = new followQ();
     $question = new question();
     $tag = new tag();
     $ask = new ask();
     $QID = $tag->getQIDsbyTag($key);
     $result = array();
     for ($i = 0; $i < count($QID); $i++) {
         $result[$i] = $question->getAllbyQID($QID[$i]);
         $result[$i]['time'] = $ask->getAskTimebyQID($result[$i]['QID']);
         $result[$i]['answernum'] = $answer->getAnswernumbyQID($result[$i]['QID']);
         $result[$i]['follownum'] = $followQ->getFollownumbyQID($result[$i]['QID']);
         $result[$i]['tag'] = $tag->getTagbyQID($result[$i]['QID']);
     }
     $answer = new answer();
     $likeA = new likeA();
     $user = new user();
     for ($i = 0; $i < count($result); $i++) {
         $maxansid = -1;
         $maxsum = -1;
         //the id of most liked answer, the like number of the answer
         $AID = $answer->getAIDsbyQID($QID[$i]);
         for ($j = 0; $j < count($AID); $j++) {
             $likenum = $likeA->getLikenumbyAID($AID[$j]);
             if ($likenum > $maxsum) {
                 $maxansid = $AID[$j];
                 $maxsum = $likenum;
             }
         }
         if ($maxansid != -1) {
             $result[$i]['AAbstract'] = $answer->getAbstractbyAID($maxansid);
             $tmp = $user->getAllbyUID($answer->getUIDbyAID($maxansid));
             $result[$i]['image'] = $tmp['image'];
         }
     }
     $sum = count($result);
     //divide into several pages
     $Pnum = floor($sum / $perpage);
     if ($sum % $perpage > 0) {
         $Pnum++;
     }
     $presult = array();
     $length = min($P * $perpage, $sum);
     for ($i = ($P - 1) * $perpage; $i < $length; $i++) {
         $presult[$i] = $result[$i];
     }
     $this->view->P = $P;
     $this->view->Pnum = $Pnum;
     $this->view->Qresult = $presult;
     $tmp = $tag->getAllTags();
     //warning: bad situation:$tmp[1] is empty,but $tmp[0] && $tmp[2] is exist
     $i = 0;
     foreach ($tmp as $a) {
         $result[$i++] = $a;
     }
     $this->view->tag = $result;
     //HotQlist
     $mans = new answer();
     $mquestion = new question();
     $mfollowq = new followQ();
     $hquestion = $mans->getMostAnsweredQID(1, 6);
     for ($i = 0; $i < count($hquestion); $i++) {
         $qq = $mquestion->getAllbyQID($hquestion[$i]);
         $HotQlist[$i]["QID"] = $qq["QID"];
         $HotQlist[$i]["title"] = $qq["qtitle"];
         $HotQlist[$i]["follownum"] = $mfollowq->getFollownumbyQID($qq["QID"]);
         $HotQlist[$i]["answernum"] = $mans->getAnswernumbyQID($qq["QID"]);
     }
     $lefter = array("hotQlist" => $HotQlist);
     $this->view->lefter = $lefter;
     $this->view->url = "/search/tag";
     $this->render('tagresult');
     //
 }
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
include_once dirname(__FILE__) . '/inc/page.inc.php';
$question = new question();
$w = "";
$arr = array();
$_GET['status'] = $_GET['status'] ? $_GET['status'] : $_POST['status'];
$_GET['type'] = $_GET['type'] ? $_GET['type'] : $_POST['type'];
$_GET['begintime'] = $_GET['begintime'] ? $_GET['begintime'] : $_POST['begintime'];
$_GET['endtime'] = $_GET['endtime'] ? $_GET['endtime'] : $_POST['endtime'];
$_GET['keyword'] = $_GET['keyword'] ? $_GET['keyword'] : $_POST['keyword'];
if ($_GET['status']) {
    $w .= " and status='{$_GET['status']}' ";
    $arr['status'] = $_GET[status];
    $smarty->assign("status", $_GET[status]);
}
if ($_SESSION[usrinfo][username]) {
    //如果登陆的话
    if (!($_SESSION[usrinfo][privileges] == 1)) {
        //如果不为admin  为群组成员
        if ($_SESSION[usrinfo][is_admin]) {
            //如果为群组的管理人员  则只能看到群组的问题 和 游客的问题
            $w .= " and (groupid=" . $_SESSION[usrinfo][groupid] . " or admin_user='******')";
        } else {
            //如果为群组的普通成员则只能 查看到自己的问题 和 游客的问题
            $w .= " and (groupid=" . $_SESSION[usrinfo][groupid] . " or admin_user='******')";
        }
    }
Example #21
0
                $_SESSION['WELL_DONE'] = "Bad Luck. Try Again";
            }
        } catch (Exception $e) {
            $_SESSION['WELL_DONE'] = $e->getMessage();
        }
        header('Location: /question?q=' . $qid);
    }
} elseif (!isset($_GET['q'])) {
    include_once "content.inc";
} else {
    $qid = intval($_GET['q']);
    if ($qid <= 0 || $qid >= 65535) {
        header("Location: /challenges.php");
    }
    include_once "includes/puzzle.php";
    $qObj = new question();
    $result = $qObj->get_question_details($qid);
    if (count($result) != 0) {
        if (isset($_SESSION['WELL_DONE']) && $_SESSION['WELL_DONE'] != "") {
            ?>
	<h2><font color="green"><?php 
            echo $_SESSION['WELL_DONE'];
            $_SESSION['WELL_DONE'] = "";
            ?>
</font></h2>
<?php 
        } else {
            ?>
	<p>&nbsp;</p>
<?php 
        }
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
include_once dirname(__FILE__) . '/inc/page.inc.php';
$question = new question();
$w = "";
$arr = array();
if ($_GET['status']) {
    $w = empty($w) ? "" : $w . " and ";
    $w = " status='{$_GET['status']}' ";
    $arr['status'] = $_GET[status];
}
$num = $question->getListCount($w, null);
$p = new show_page();
$p->setvar($arr);
$p->pvar = "p";
$p->set(10, $num);
$limit = " limit " . $p->limit();
$pages = $p->output(1);
$list = $question->getListInfo($w, $limit);
for ($i = 0; $i < count($list); $i++) {
    switch ($list[$i]['status']) {
        case 1:
            $list[$i]['newstatus'] = "<font color='red'>未解决</font>";
            break;
        case 2:
            $list[$i]['newstatus'] = "<font color='green'>已解决</font>";
            break;
        case 3:
<?php

require_once '../../../../../class/autoload.inc';
$test_type = new test_type();
$test_type_panel = $test_type->getTestTypePanel();
if (isset($_POST["quetext"])) {
    $question = new question();
    $result = $question->addMulAns($_POST["quetext"], $_POST["deg"]);
} elseif (isset($_POST["sinque"])) {
    $question = new question();
    $result = $question->addOneAns($_POST["sinque"], $_POST["sinqueAns"], $_POST["deg"]);
}
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="../../../../js/jquery-1.9.0.js" type='text/javascript'></script>
        <script src="../../../../jquery-ui/js/jquery-ui-1.10.1.custom.js" type='text/javascript'></script>
        <script src="../../../../js/common.js" type='text/javascript'></script>
        <script src="index.js" type='text/javascript'></script>
        <link rel="stylesheet" href="../../../../jquery-ui/development-bundle/themes/sunny/jquery-ui.css" />
        <link rel="stylesheet" href="index.css" />
    </head>
    <body>
        <script language="javascript">
            <?php 
if (isset($result)) {
    echo "\n                    \$(function(){\n                        \$('#dialog').html('{$result}').dialog('open');\n                    });";
}
?>
            function alert(error){
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
//include_once dirname(__FILE__).'/libs/editor/fckeditor.php';
//$oFCKeditor = new FCKeditor('anscontent');
//$oFCKeditor->BasePath ='./libs/editor/'; //定义其路径
//$oFCKeditor->ToolbarStartExpanded = false; //设置
//$oFCKeditor->ToolbarStart = 'Basic';
//$oFCKeditor->Width = "620";
//$oFCKeditor->Height = "280";
$question = new question();
$k_id = $_GET['k_id'];
$list = $question->getQuesInfo($k_id);
if (count($list) > 0) {
    for ($i = 0; $i < count($list); $i++) {
        $list[$i]['question_time'] = date("Y-m-d i:m:s", $list[$i]['question_time']);
        switch ($list[$i]['status']) {
            case 1:
                $list[$i]['newstatus'] = "<font color='red'>未解決</font>";
                break;
            case 2:
                $list[$i]['newstatus'] = "<font color='green'>已解決</font>";
                break;
            case 3:
                $list[$i]['newstatus'] = "<font color='blue'>已鎖定</font>";
                break;
            default:
                $list[$i]['newstatus'] = "<font color='red'>未解決</font>";
                break;
Example #25
0
 public function tagAction()
 {
     //封装header
     $tuser = new user();
     $auth = Zend_Auth::getinstance();
     #获取auth用户实例
     $auth->getIdentity();
     #取得当前用户信息
     $email = $auth->getIdentity();
     $tuser = new user();
     $user = $tuser->getAllbyEmail($email);
     $header = array("UID" => $user[0]["UID"], "image" => $user[0]["image"]);
     //封装tag
     $ttag = new tag();
     $tans = new answer();
     $task = new ask();
     $tquestion = new question();
     $tfollowq = new followQ();
     $tags = $ttag->getAllTags();
     $tagnum = count($tags);
     $this->view->tags = $tags;
     //print_r($tags);
     for ($i = 0; $i < count($tags); $i++) {
         //第i个tag
         $QIDs = $ttag->getQIDsbyTag($tags[$i]);
         $questionnum = count($QIDs);
         $tag[$i]["tag"] = $tags[$i];
         $questiontmp[0] = 0;
         $answernum[0] = 0;
         for ($j = 0; $j < $questionnum; $j++) {
             //第j个question
             $question = $tquestion->getAllbyQID($QIDs[$j]);
             $QID = $QIDs[$j];
             $title = $question["qtitle"];
             if (strlen($title) > 75) {
                 $title = substr($title, 0, 72);
                 $title = $title . "...";
             }
             $follownum = $tfollowq->getFollownumbyQID($QID);
             $answernum[$j] = $tans->getAnswernumbyQID($QID);
             $questiontmp[$j] = array("QID" => $QID, "title" => $title, "follownum" => $follownum, "answernum" => $answernum[$j]);
         }
         array_multisort($answernum, SORT_DESC, $questiontmp);
         for ($j = 0; $j < min(3, count($questiontmp)); $j++) {
             $Qresult[$i][$j] = $questiontmp[$j];
         }
     }
     $this->view->tag = $tags;
     $this->view->Qresult = $Qresult;
     $this->view->header = $header;
     $this->render('tag');
 }
Example #26
0
<?php

include_once dirname(__FILE__) . '/inc/init.php';
include_once dirname(__FILE__) . '/libs/editor/fckeditor.php';
include_once dirname(__FILE__) . '/inc/db.inc.php';
include_once dirname(__FILE__) . '/inc/class_question.php';
$question = new question();
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->BasePath = './libs/editor/';
//定义其路径
$oFCKeditor->ToolbarStartExpanded = false;
//设置
$oFCKeditor->ToolbarStart = 'Basic';
$oFCKeditor->Width = "620";
$oFCKeditor->Height = "480";
//内容区域的模板变量
if ($_POST['action'] == 'add') {
    $arr['question_no'] = time();
    $arr['user_no'] = '123';
    $arr['title'] = $_POST['title'];
    $arr['question'] = $_POST['content'];
    $arr['question_time'] = time();
    $arr['agree_rate'] = '0';
    $arr['status'] = '1';
    $question->insertTable("mpos_question ", $arr);
    echo "<script>alert('添加提问成功!');location.href='index.php';</script>";
}
$contentarea = $oFCKeditor->CreateHtml();
$smarty->assign("contentarea", $contentarea);
$smarty->display("ask.html");
Example #27
0
"><h2><?php 
    echo $_SESSION["name"];
    ?>
</h2>
			</div>
			<table class="ui celled table">
				<thead>
					<tr>
						<th style="width: 90%;">Pergunta</th>
						<th>Votos</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<?php 
    $question = new question();
    $questions = $question->getQuestionsByUser($_SESSION["id"]);
    ?>
						<?php 
    if ($questions == null) {
        ?>
							<tr><td colspan="2" style="text-align: center">Você ainda não fez nenhuma pergunta! :(</td></tr>
						<?php 
    } else {
        ?>
							<?php 
        foreach ($questions as $single) {
            ?>
								<tr>
								<td><a href="<?php 
            echo WEB_PATH;
Example #28
0
 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');
     }
 }
Example #29
0
     for ($i = 0; $i < $actionkey; $i++) {
         if (empty($status[$i])) {
             $status[$i] = 0;
         }
     }
     $status[$actionkey] = 0;
     $baseinfo['qa_status'] = join(",", $status);
     $class->edit($baseinfo, $_POST["id"]);
 }
 // 提問狀態
 if ($_POST["do"] == "qa") {
     $post['patient_id'] = $_POST["id"];
     $post['user_id'] = $_SESSION['customer_id'];
     $post['actionkey'] = $actionkey;
     $post['content'] = $_POST["content"];
     $class = new question();
     $qid = $class->add($post);
     if ($qid) {
         $class = new patient();
         $info = $class->getInfo((int) $_POST["id"]);
         $baseinfo = array();
         $status = explode(",", $info['qa_status']);
         for ($i = 0; $i < $actionkey; $i++) {
             if (empty($status[$i])) {
                 $status[$i] = 0;
             }
         }
         $status[$actionkey] = 1;
         $baseinfo['qa_status'] = join(",", $status);
         $class->edit($baseinfo, $_POST["id"]);
         // echo $baseinfo['qa_status'];
Example #30
0
<?php

session_start();
require_once "./inc/config.php";
require_once "./inc/classes/class.question.php";
if (!isset($_GET["url"])) {
    header("Location: " . WEB_PATH . "question/not-found");
} else {
    $question = new question();
    try {
        $question->loadQuestion($_GET["url"]);
    } catch (exception $e) {
        header("Location: " . WEB_PATH . "question/not-found");
    }
}
?>
<html>
	<head>
		<title><?php 
echo $question->getTitleA();
?>
 ou <?php 
echo $question->getTitleB();
?>
? | Qual dos dois?</title>
		<?php 
require_once "./inc/header_includes.php";
?>
		<meta property="og:url"           content="<?php 
echo "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
?>