function CalculTestScore($userID, $paperID) { include_once '../DAL/selectResultDal.php'; include_once '../DAL/paperDal.php'; include_once '../DAL/testResultDal.php'; $isPaperScore = 0; $sumSocre = 0; $ScoreInfo = NULL; //在这里重新查询一边,因为之前把单项的得分写入了 $userSelection = FindSelectResultByUserPaper($userID, $paperID); foreach ($userSelection as $single) { $sumSocre += $single[5]; } /*判断该试卷是否有评分标准*/ $paperResult = FindPaperByPaperID($paperID); foreach ($paperResult as $single) { $isPaperScore = $single[4]; } //如果有 if ($isPaperScore) { $ScoreInfo = GetScoreInfo($paperID, $sumSocre); //如果能正确返回结果,进行插入 if ($ScoreInfo) { InsertTestResult($userID, $paperID, $sumSocre, $ScoreInfo); } } }
<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="container"> <div class="starter-template"> <?php session_start(); include_once '../DAL/testResultDal.php'; include_once '../DAL/paperDal.php'; $userId = $_SESSION['userID']; $result = FindTestResultByUserID($userId); for ($i = 0; $i < count($result); $i++) { $paperId = $result[$i][2]; $paperName = FindPaperByPaperID($paperId)[0][1]; $score = $result[$i][3]; $info = $result[$i][4]; echo "<h2>试卷名: {$paperName}</h2>"; echo "<h2>分数是 {$score}</h2>"; echo "<h2>测试结果为:</h2>"; echo "<h3>{$info}</h3>"; echo "</br>"; } ?> </div> <a class="btn btn-default" href="showPaperName.php" role="button">进入试题选择</a> </div> </body> </html>