Ejemplo n.º 1
0
 public function course($num = 0)
 {
     $str = null;
     $course = new courseModel();
     foreach ($course->getAllCourse() as $key => $value) {
         if ($num == $value->id) {
             $selected = "selected='selected'";
         } else {
             $selected = '';
         }
         $str .= "<option value='" . $value->id . "' " . $selected . ">" . $value->name . "</option>";
     }
     $this->smarty->assign("course", $str);
 }
Ejemplo n.º 2
0
 private function show()
 {
     $user = new userModel();
     $upload = new UploadFile("pic", "public/uploads/member");
     if (isset($_POST['send'])) {
         $user->id = $_POST['id'];
         $user->email = $_POST['email'];
         if ($_POST['pwd'] == $_POST['newpwd']) {
             $user->pwd = $_POST['newpwd'];
         } else {
             $user->pwd = md5($_POST['newpwd']);
         }
         if (is_uploaded_file($_FILES['pic']['tmp_name'])) {
             if ($upload->upload("pic")) {
                 $user->icon = $upload->getNewName();
             }
         } else {
             $user->icon = $_POST['newpic'];
             //echo "没有上传".$_POST['newpic'];
         }
         //Tools::dump($_POST);
         if ($user->updateUser()) {
             //echo "ok";
             Tools::Redirect("会员资料修改成功", $_SERVER['HTTP_REFERER']);
         } else {
             if ($user->updateUser() == 0) {
                 Tools::Redirect("会员资料没有修改", $_SERVER['HTTP_REFERER']);
                 //echo "not changed";
             } else {
                 Tools::Redirect("会员资料修改失败", $_SERVER['HTTP_REFERER'], 2);
             }
         }
     }
     $comment = new commentModel();
     $article = new articleModel();
     $product = new productModel();
     $ask = new askModel();
     $quiz = new quizModel();
     if ($_GET['id']) {
         $user->id = $_GET['id'];
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
         /////////////////////////////////
         $comment->uid = $_GET['id'];
         $allComments = $comment->getAllCommentsByUID();
         foreach ($allComments as $key => $value) {
             $article->id = $value->aid;
             $oneArticle = $article->getOneArticle();
             $value->title = $oneArticle->title;
         }
         $product->uid = $_GET['id'];
         $allOrders = $product->getAllOrdersByUID();
         foreach ($allOrders as $value) {
             $pids = explode(",", $value->pid);
             $str = null;
             foreach ($pids as $v) {
                 $product->id = $v;
                 //Tools::dump($v);
                 $oneProduct = $product->getOneProduct();
                 //Tools::dump($oneProduct);
                 $str .= $oneProduct->name . ",";
             }
             $str = rtrim($str, ",");
             //Tools::dump($str);
             $value->pid = $str;
             switch ($value->payed) {
                 case 0:
                     $value->payed = "<span style='color:red;'>[未付]</span>";
                     break;
                 case 1:
                     $value->payed = "<span style='color:green;'>[已付]</span>";
             }
             switch ($value->sent) {
                 case 0:
                     $value->sent = "<span style='color:red;'>[未发货]</span>";
                     break;
                 case 1:
                     $value->sent = "<span style='color:green;'>[已发货]</span>";
             }
         }
         $ask->aid = $_GET['id'];
         $allAsks = $ask->getAllAskByAID();
         $this->smarty->assign("allAsks", $allAsks);
         $this->smarty->assign("allOrders", $allOrders);
         $this->smarty->assign("allComments", $allComments);
         $quiz->uid = $_GET["id"];
         $allScores = $quiz->getAllScoresByUID();
         $course = new courseModel();
         foreach ($allScores as $key => $value) {
             $course->id = $value->cid;
             $oneCourse = $course->getOneCourse();
             $value->cid = $oneCourse->name;
         }
         $this->smarty->assign("allScores", $allScores);
     }
     $this->smarty->assign("show", true);
 }
Ejemplo n.º 3
0
 private function result()
 {
     $this->showNav();
     if (isset($_POST['send'])) {
         $course = new courseModel();
         $course->id = $_POST['cid'];
         $oneCourse = $course->getOneCourse();
         $this->smarty->assign("oneCourse", $oneCourse);
         $user = new userModel();
         $user->id = $_SESSION['oneUserName']->id;
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
         $user->updateCountdown();
         $num = 0;
         $str .= "";
         $resultNum = 0;
         //echo $_POST['choiceNum'];
         while ($i < $_POST['choiceNum']) {
             $i++;
             $num++;
             //echo $_POST['choice'.($i)]
             $this->model->id = $_POST['choice' . $i];
             //echo $this->model->id."<br>";
             $oneChoice = $this->model->getOneChoice();
             //Tools::dump($_POST['choice'][$i]);
             //echo $_POST['choice'][$_POST['choice'.($i)]]."<br>";
             if ($oneChoice->answer == $_POST['choice'][$_POST['choice' . $i]]) {
                 $str .= "<div class='item'><dt>" . $num . "." . $oneChoice->question;
                 $str .= "<span class='glyphicon glyphicon-ok right'></span>";
                 $str .= "</dt>";
                 $resultNum++;
             } else {
                 $str .= "<div class='item'><dt>" . $num . "." . $oneChoice->question;
                 $str .= "<span class='glyphicon glyphicon-remove wrong'></span>";
                 $str .= "</dt>";
                 if ($_POST['choice'][$_POST['choice' . $i]] != '') {
                     $str .= "<dd class='failed'><b style='color:green;'>正确答案是:" . $oneChoice->answer . "</b>,";
                     $str .= "<span class='wrong'>您选择的是:" . $_POST['choice'][$_POST['choice' . $i]] . "。<span></dd>";
                     $str .= "<dd style='margin-bottom:3px;' class='alert alert-danger'><b style='color:red'>提示:</b>" . $oneChoice->tips . "</dd>";
                 } else {
                     $str .= "<dd class='wrong'>您未答此题</dd>";
                 }
             }
             $str .= "<dd>A." . $oneChoice->a . "</dd>";
             $str .= "<dd>B." . $oneChoice->b . "</dd>";
             $str .= "<dd>C." . $oneChoice->c . "</dd>";
             $str .= "<dd>D." . $oneChoice->d . "</dd></div>";
         }
         ////////judge/////////////////
         $num2 = 0;
         $str2 .= "";
         $resultNum2 = 0;
         //echo $_POST['choiceNum'];
         //echo $_POST['judgeNum'];
         while ($j < $_POST['judgeNum']) {
             $j++;
             $num2++;
             //echo $_POST['choice'.($i)]
             $this->model->id = $_POST['judge' . $j];
             $oneJudge = $this->model->getOneJudge();
             //Tools::dump($_POST['choice'][$i]);
             //echo $_POST['choice'][$_POST['choice'.($i)]]."<br>";
             if ($oneJudge->answer == $_POST['judge'][$_POST['judge' . $j]]) {
                 $str2 .= "<div class='item'><dt>" . $num2 . "." . $oneJudge->question;
                 $str2 .= "<span class='glyphicon glyphicon-ok right'></span>";
                 $str2 .= "</dt></div>";
                 $resultNum2++;
             } else {
                 $str2 .= "<div class='item'><dt>" . $num2 . "." . $oneJudge->question;
                 $str2 .= "<span class='glyphicon glyphicon-remove wrong'></span>";
                 $str2 .= "</dt>";
                 if ($_POST['judge'][$_POST['judge' . $j]] != '') {
                     switch ($oneJudge->answer) {
                         case '1':
                             $answer = "正确";
                             break;
                         case "0":
                             $answer = "错误";
                     }
                     switch ($_POST['judge'][$_POST['judge' . $j]]) {
                         case '1':
                             $answer2 = "正确";
                             break;
                         case "0":
                             $answer2 = "错误";
                     }
                     $str2 .= "<dd><span class='wrong'>正确答案是:" . $answer . "</span>,";
                     $str2 .= "<span class='wrong'>您选择的是:" . $answer2 . "。<span></dd>";
                     $str2 .= "<dd style='margin-bottom:3px;' class='alert alert-danger'><b style='color:red'>提示:</b>" . $oneJudge->tips . "</dd>";
                 } else {
                     $str2 .= "<dd class='wrong'>您未答此题</dd>";
                 }
                 $str2 .= "<dd>A.正确,";
                 $str2 .= "B.错误</dd></div>";
             }
         }
         //
         $user = new userModel();
         $examination = new examinationModel();
         $userLeaderboard = $examination->getUserLeaderboard();
         $allCourse = $course->getFrontCourse();
         $arr = array();
         foreach ($allCourse as $key => $value) {
             $examination->cid = $value->id;
             $hotExam = $examination->getExamByCID();
             foreach ($hotExam as $k => $v) {
                 $user->id = $v->uid;
                 $oneUser = $user->getOneUserByID();
                 $v->uid = $oneUser->username;
             }
             $arr[$value->name] = $hotExam;
         }
         //Tools::dump($arr);
         $this->smarty->assign("arr", $arr);
         $this->model->uid = $_POST['uid'];
         $this->model->cid = $_POST['cid'];
         $this->model->total = $_POST['choiceNum'] + $_POST['judgeNum'];
         $this->model->ticked = count($_POST['judge']) + count($_POST['choice']);
         $this->model->rightNum = $resultNum + $resultNum2;
         //$this->model->score=$resultNum*10+$resultNum2*10;
         $this->model->score = number_format(($resultNum + $resultNum2) / ($_POST['choiceNum'] + $_POST['judgeNum']) * 100, 2);
         $this->model->createExam();
     }
     $this->smarty->assign("total", $_POST['choiceNum'] + $_POST['judgeNum']);
     $this->smarty->assign("ticked", count($_POST['judge']) + count($_POST['choice']));
     $this->smarty->assign("choiceOutput", $str);
     $this->smarty->assign("judgeOutput", $str2);
     $this->smarty->assign("resultNum", $resultNum);
     $this->smarty->assign("resultNum2", $resultNum2);
     $this->smarty->assign("score", number_format(($resultNum + $resultNum2) / ($_POST['choiceNum'] + $_POST['judgeNum']) * 100, 2));
     $this->smarty->assign("result", true);
 }
Ejemplo n.º 4
0
 private function show()
 {
     $course = new courseModel();
     $AllCourse = $course->getAllCourse();
     $courseStr = null;
     foreach ($AllCourse as $value) {
         $courseStr .= $value->id . ",";
     }
     $courseStr = rtrim($courseStr, ",");
     //echo $levelStr;
     if (empty($_GET['kind'])) {
         $this->model->kind = $courseStr;
     } else {
         $this->model->kind = $_GET['kind'];
     }
     parent::page($this->model->getAllAskTotal());
     $AllAsk = $this->model->getAllAsk();
     foreach ($AllAsk as $key => $value) {
         $course->id = $value->cid;
         $oneCourse = $course->getOneCourse();
         $value->courseName = $oneCourse->name;
         $this->model->id = $value->id;
         $value->answerNum = $this->model->getAllAnswersTotal();
     }
     $this->course($_GET['kind']);
     //Tools::dump($AllAsk);
     $this->smarty->assign("AllAsk", $AllAsk);
     $this->smarty->assign("show", true);
 }
Ejemplo n.º 5
0
 private function showCourse()
 {
     $course = new courseModel();
     $page = new Page($course->getAllCourseTotal(), 5);
     $course->limit = $page->limit;
     $allCourse = $course->getAllCourse();
     foreach ($allCourse as $key => $value) {
         switch ($value->state) {
             case 0:
                 $value->state = "<span style='color:red;'>[否]</span>\r\n\t\t\t\t\t\t\t<a href='?a=learning&action=state&flag=show&id=" . $value->id . "'>显示</a>";
                 break;
             case 1:
                 $value->state = "<span style='color:green;'>[是]</span>\r\n\t\t\t\t\t\t\t<a href='?a=learning&action=state&flag=hide&id=" . $value->id . "'>隐藏</a>\t";
         }
     }
     $this->course();
     //Tools::dump($allCourse);
     $this->smarty->assign("num", $page->listRowsBegin());
     $this->smarty->assign("page", $page->display());
     $this->smarty->assign("data", $allCourse);
     $this->smarty->assign("showCourse", true);
 }
Ejemplo n.º 6
0
 public function main()
 {
     if ($_SESSION['oneUserName']) {
         $this->smarty->assign("logged", true);
         $user = new userModel();
         $user->id = $_SESSION['oneUserName']->id;
         $oneUser = $user->getOneUserByID();
         $this->smarty->assign("oneUser", $oneUser);
     } else {
         $this->smarty->assign("logged", false);
     }
     switch ($_GET['action']) {
         case "vote":
             $this->castVote();
             break;
         case "logout":
             $this->logout();
             break;
     }
     $this->getUser();
     $this->showAD();
     $this->showVote();
     $this->showNav();
     $this->showArticle();
     $product = new productModel();
     $allProducts = $product->getHotProducts();
     $course = new courseModel();
     //$ask=new askModel();
     //$askLeaderboard=$ask->askLeaderboard();
     //$this->smarty->assign("askLeaderboard",$askLeaderboard);
     //Tools::dump($askLeaderboard);
     //$AllAsk=$ask->getAllAsks();
     $user = new userModel();
     $examination = new examinationModel();
     $userLeaderboard = $examination->getUserLeaderboard();
     //Tools::dump($userLeaderboard);
     $allCourse = $course->getFrontCourse();
     //$arr=[];
     // 		$arr=array();
     // 		foreach ($allCourse as $key=>$value){
     // 		    $examination->cid=$value->id;
     // 		    $hotExam=$examination->getExamByCID();
     // 		    foreach ($hotExam as $k=>$v){
     // 		        $user->id=$v->uid;
     // 		        $oneUser=$user->getOneUserByID();
     // 		        $v->uid=$oneUser->username;
     // 		    }
     // 		    $arr[$value->name]=$hotExam;
     // 		}
     foreach ($userLeaderboard as $key => $value) {
         $user->id = $value->uid;
         $course->id = $value->cid;
         $value->cid = $course->getOneCourse()->name;
         $oneUser = $user->getOneUserByID();
         $value->uid = $oneUser->username;
     }
     //Tools::dump($userLeaderboard);
     $this->smarty->assign("newExam", $userLeaderboard);
     $this->smarty->assign("userLeaderboard", $userLeaderboard);
     //Tools::dump($AllAsk);
     /* foreach ($AllAsk as $key=>$value){
     		    $user->id=$value->aid;
     		    $oneUser=$user->getOneUserByID();
     		    $course->id=$value->cid;
     		    $oneCourse=$course->getOneCourse();
     		    $value->courseName=$oneCourse->name;
     		    $ask->id=$value->id;
     		    $value->answerNum=$ask->getAllAnswersTotal();
     		    $value->username=$oneUser->username;
     		} */
     $download = new downloadModel();
     //Tools::dump($download->getDownloadNum());
     //Tools::dump($download->getDownloadNum());
     //$this->smarty->assign("downloadLeaderboard",$download->getDownloadNum());
     $this->smarty->assign("downloadLeaderboard", $download->getLatestDownload());
     //Tools::dump($AllAsk);
     /* $this->smarty->assign("AllAsk",$AllAsk); */
     $this->smarty->assign("AllAsk", false);
     $this->smarty->assign("allProducts", $allProducts);
     $product = new productModel();
     $this->smarty->assign("productRecommend", $product->getAttrArticle("recommend"));
     $this->smarty->display("home/home.html");
 }