コード例 #1
0
ファイル: index.php プロジェクト: adexbn/sinomedex_report
function showExcel($category_id, $courses_id_str, $exercises_id_str)
{
    initConfigTable();
    $course_ids = trim($courses_id_str) == '' ? array() : explode(",", trim($courses_id_str));
    $exercise_ids = trim($exercises_id_str) == '' ? array() : explode(",", trim($exercises_id_str));
    $student_infos = array();
    $course_score_summary = array();
    $course_score_minmax = array();
    $course_score_first = array();
    $knowledge_summary = array();
    $knowledge_score_summary = array();
    $student_knowledge_score_summary = array();
    $total_attempt_count_summary = array();
    $total_attempt_time_summary = array();
    $total_attempt_detail_summary = array();
    $total_attempt_time_start_summary = array();
    $total_attempt_time_end_summary = array();
    //读取课程
    $courses = getCourses($category_id);
    $nonConfigCourses = array();
    //输出Excel文件头
    header("Content-Type: application/vnd.ms-excel; charset=utf-8");
    header("Content-Type: application/force-download");
    header("Content-Type: application/octet-stream");
    header("Content-Type: application/download");
    header("Content-Disposition: attachment; filename=report_" . date("Ymd_His") . ".xls");
    header("Content-Transfer-Encoding: binary ");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private", false);
    echo "MIME-Version: 1.0\r\n" . "X-Document-Type: Workbook\r\n" . "Content-Type: multipart/related; boundary=\"***MY_BOUNDARY_LINE***\"\r\n" . "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<o:DocumentProperties>' . '<o:Author>Adex Lin</o:Author>' . '<o:LastAuthor>Adex Lin</o:LastAuthor>' . '<o:Created>' . date("Y-m-d H:i:s") . '</o:Created>' . '<o:LastSaved>' . date("Y-m-d H:i:s") . '</o:LastSaved>' . '<o:Company>SinoMedex</o:Company>' . '<o:Version>1.0</o:Version>' . '</o:DocumentProperties>' . '</xml>' . '<xml>' . '<x:ExcelWorkbook>' . '<x:ExcelWorksheets>';
    $index = 1;
    foreach ($course_ids as $course_id) {
        $course_name = preg_replace('/[::\\/\\\\?\\*\\& ]/u', '', $courses[$course_id]);
        $course_name = preg_replace('/课件$/u', '', $course_name);
        echo '<x:ExcelWorksheet>' . '<x:Name>' . $course_name . '</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>';
    }
    foreach ($exercise_ids as $course_id) {
        $course_name = preg_replace('/[::\\/\\\\?\\*\\& ]/u', '', $courses[$course_id]);
        $course_name = preg_replace('/练习$/u', '', $course_name);
        $course_name = preg_replace('/课件/u', '练习', $course_name);
        echo '<x:ExcelWorksheet>' . '<x:Name>' . $course_name . '</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>';
    }
    echo '<x:ExcelWorksheet>' . '<x:Name>课件学习概况</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>课件学习详情</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>练习得分汇总</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>练习最高|最低得分汇总</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>练习首次得分汇总</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>知识点最高得分汇总</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>' . '<x:ExcelWorksheet>' . '<x:Name>知识点首次得分汇总</x:Name>' . '<x:WorksheetSource HRef="cid:' . $index++ . '"/>' . '</x:ExcelWorksheet>';
    echo '</x:ExcelWorksheets>' . '</x:ExcelWorkbook>' . '</xml>' . '</head>' . '</html>';
    $index = 1;
    //读取课件浏览
    foreach ($course_ids as $course_id) {
        //读取课件
        $scores = getTracks($category_id, $course_id);
        list($student_infos1, $attempt_counts1, $attempt_start_times, $attempt_end_times, $attempt_total_times, $attempt_status, $attempt_score) = $scores;
        $student_infos += $student_infos1;
        //输出单个sheet
        echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
        echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
        drawTrackTable($course_id, $student_infos1, $attempt_counts1, $attempt_start_times, $attempt_end_times, $attempt_total_times, $attempt_status, $attempt_score, "normal");
        //汇总每个学生的课件浏览记录
        list($attempt_count_summary, $attempt_time_summary, $attempt_detail_summary, $attempt_time_start_summary, $attempt_time_end_summary) = drawTrackTable($course_id, $student_infos1, $attempt_counts1, $attempt_start_times, $attempt_end_times, $attempt_total_times, $attempt_status, $attempt_score, "summary");
        $total_attempt_count_summary += $attempt_count_summary;
        $total_attempt_time_summary += $attempt_time_summary;
        $total_attempt_detail_summary += $attempt_detail_summary;
        $total_attempt_time_start_summary += $attempt_time_start_summary;
        $total_attempt_time_end_summary += $attempt_time_end_summary;
        //输出Sheet尾
        echo '</body>' . '</html>';
    }
    //读取成绩
    foreach ($exercise_ids as $course_id) {
        //输出单个sheet
        echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
        echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
        //读取题目的分数和领域
        $quiz_configs = getConfig($category_id, $course_id, false);
        if ($quiz_configs == null) {
            array_push($nonConfigCourses, $course_id);
            //输出Sheet尾
            echo '</body>' . '</html>';
            continue;
        }
        list($elements, $element_scores, $element_knowledeges, $knowledges, $knowledge_scores) = $quiz_configs;
        $knowledge_summary += $knowledges;
        $knowledge_score_summary += $knowledge_scores;
        //读取考试成绩
        list($student_infos2, $attempt_counts, $attempt_start_times, $attempt_end_times, $attempt_total_times, $student_element_scores, $student_knowledge_scores) = getScores($category_id, $course_id, $quiz_configs);
        $student_infos += $student_infos2;
        //输出单个课件习题成绩
        echo '<table><tr><td colspan="3"><b>表:习题最高分</b></td></tr></table>';
        drawEScoreTable($course_id, $student_infos2, $attempt_counts, $attempt_start_times, $attempt_end_times, $attempt_total_times, $elements, $element_scores, $student_element_scores, "high");
        //输出单个课件的知识点成绩
        echo '<table><tr><td> </td></tr></table>';
        echo '<table><tr><td colspan="3"><b>表:知识点最高分</b></td></tr></table>';
        drawKScoreTable($course_id, $student_infos2, $attempt_counts, $knowledges, $knowledge_scores, $student_knowledge_scores, "high");
        //合并知识点成绩
        $exist_score = $knowledge_score_summary;
        $new_score = array();
        foreach (array_keys($exist_score + $knowledge_scores) as $key) {
            $new_score[$key] = (isset($exist_score[$key]) ? $exist_score[$key] : 0) + (isset($knowledge_scores[$key]) ? $knowledge_scores[$key] : 0);
        }
        $knowledge_score_summary = $new_score;
        //汇总学生各个知识点的成绩
        $exist_summary = $student_knowledge_score_summary;
        $new_summary = array();
        foreach (array_keys($exist_summary + $student_knowledge_scores) as $key) {
            $new_summary[$key] = (isset($exist_summary[$key]) ? $exist_summary[$key] : 0) + (isset($student_knowledge_scores[$key]) ? $student_knowledge_scores[$key] : 0);
        }
        $student_knowledge_score_summary = $new_summary;
        //得到汇总成绩表
        list($student_count, $element_correct_count, $max_attempt_count, $student_score_line, $student_course_summary, $student_course_minmax, $student_course_first) = drawEScoreTable($course_id, $student_infos2, $attempt_counts, $attempt_start_times, $attempt_end_times, $attempt_total_times, $elements, $element_scores, $student_element_scores, "summary");
        $course_score_summary += $student_course_summary;
        $course_score_minmax += $student_course_minmax;
        $course_score_first += $student_course_first;
        //输出Sheet尾
        echo '</body>' . '</html>';
    }
    asort($course_ids);
    asort($exercise_ids);
    asort($student_infos);
    asort($course_score_summary);
    asort($course_score_minmax);
    asort($course_score_first);
    asort($total_attempt_count_summary);
    asort($total_attempt_count_summary);
    asort($total_attempt_count_summary);
    array_unique($student_infos);
    array_unique($course_score_summary);
    array_unique($course_score_minmax);
    array_unique($course_score_first);
    array_unique($total_attempt_count_summary);
    array_unique($total_attempt_count_summary);
    array_unique($total_attempt_count_summary);
    //绘制课件学习概况Sheet
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:课件学习概况</b></td></tr></table>';
    drawTSummaryTable($student_infos, $courses, $course_ids, $total_attempt_count_summary, $total_attempt_time_summary, $total_attempt_detail_summary, $total_attempt_time_start_summary, $total_attempt_time_end_summary, "course");
    //输出Sheet尾
    echo '</body>' . '</html>';
    //绘制课件学习详情Sheet
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:课件学习详情</b></td></tr></table>';
    drawTSummaryTable($student_infos, $courses, $course_ids, $total_attempt_count_summary, $total_attempt_time_summary, $total_attempt_detail_summary, $total_attempt_time_start_summary, $total_attempt_time_end_summary, "detail");
    //输出Sheet尾
    echo '</body>' . '</html>';
    //绘制汇总成绩Sheet
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:练习得分汇总</b></td></tr></table>';
    drawESummaryTable($student_infos, $courses, $nonConfigCourses, $exercise_ids, $course_score_summary);
    //输出Sheet尾
    echo '</body>' . '</html>';
    //绘制最高最低
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:练习最高|最低得分汇总</b></td></tr></table>';
    drawEMinMaxTable($student_infos, $courses, $nonConfigCourses, $exercise_ids, $course_score_minmax);
    //输出Sheet尾
    echo '</body>' . '</html>';
    //绘制首次得分
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:练习首次得分汇总</b></td></tr></table>';
    drawEFirstTable($student_infos, $courses, $nonConfigCourses, $exercise_ids, $course_score_first);
    //输出Sheet尾
    echo '</body>' . '</html>';
    //绘制知识点得分汇总
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:知识点最高分汇总</b></td></tr></table>';
    drawKScoreTable($course_id, $student_infos, $attempt_counts, $knowledge_summary, $knowledge_score_summary, $student_knowledge_score_summary, "high");
    //绘制知识点得分汇总
    echo "\r\n" . "--***MY_BOUNDARY_LINE***\r\n" . "Content-ID: " . $index++ . "\r\n" . "Content-Type: text/html; charset=\"utf-8\"\r\n" . "\r\n";
    echo '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . '<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . '<xml>' . '<x:WorksheetOptions>' . '<x:ProtectContents>False</x:ProtectContents>' . '<x:ProtectObjects>False</x:ProtectObjects>' . '<x:ProtectScenarios>False</x:ProtectScenarios>' . '</x:WorksheetOptions>' . '</xml>' . '</head>' . '<body>';
    echo '<table><tr><td colspan="3"><b>表:知识点首次分得分汇总</b></td></tr></table>';
    drawKScoreTable($course_id, $student_infos, $attempt_counts, $knowledge_summary, $knowledge_score_summary, $student_knowledge_score_summary, "first");
    //输出Sheet尾
    echo '</body>' . '</html>';
    //输出Excel文件尾
    echo "\r\n" . "--***MY_BOUNDARY_LINE***--\r\n";
}
コード例 #2
0
ファイル: leaderboard.php プロジェクト: bigjimbeef/blaventure
}
// 1. Denyer, level 8 Barbarian 2. Silari, level 6 Wizard 3: wjoe 3.0, level 5 Fighter
function getLeadersAsString($leaders)
{
    $output = "";
    for ($i = 1; $i <= count($leaders); ++$i) {
        $leader = $leaders[$i - 1];
        $nick = $leader["nick"];
        $name = $leader["data"]->name;
        $level = $leader["data"]->level;
        $class = $leader["data"]->class;
        $maxCharacters = 16;
        if (strlen($name) > $maxCharacters) {
            $name = substr($name, 0, $maxCharacters) . "...";
        }
        $output .= "{$i}. {$name}, level {$level} {$class} ({$nick})  ";
    }
    $output = rtrim($output) . "\n";
    return $output;
}
$numLeaders = -1;
if (!empty($argv) && isset($argv[1])) {
    $num = $argv[1];
    if (is_numeric($num)) {
        $numLeaders = intval($num);
    }
}
$scores = getScores();
$leaders = buildLeaderBoard($scores, $numLeaders);
$topString = getLeadersAsString($leaders);
echo $topString;
コード例 #3
0
ファイル: launch.php プロジェクト: torypeterschild/dig-that
        <div>
            <script>
                function postScore(ws, wr) {
                console.log(ws);
            console.log(wr);
                    if (!wr)
                        wr = "guest";
                    if (wr == "")
                        wr = "guest";
                    document.location.href="/drecco/index.php?task=DigThatV2&winner="+wr+"&ws="+ws;
                }
            </script>
            <!-- <button id="score" style="display:none" onClick="postScore(winningScore, winningPlayer)" type="button">Save Score</button> -->
        </div>
    </div>
    <script type="text/javascript" src="logic.js"></script>



    <div id="last10" class="post">
        <h2 class="title">Last 10 Scores</h2>
        <?php 
// functions.php in case of an opening in the same window
// ../../functions.php in case of an opening in a new window
include '../../lastScores.php';
getScores("DigThatV2");
?>
    </div>

</body>
</html>
コード例 #4
0
ファイル: launch.php プロジェクト: arieldexler/Nanomunchers
        <tr ng-if="isPlaying(3)" style="{{isTurn(3)}}">
            <td><img src="player3.png"> </td>
            <td>{{getScore(3)}}</td>
            <td>{{getRemainingMoves(3)}}</td>
        </tr>
        </tbody>
    </table>
      <div class="post">
        <h2 class="title">Last 10 scores</h2>
        <div style="color: white;">

        <?php 
// functions.php in case of an opening in the same window
// ../../functions.php in case of an opening in a new window
include '../../lastScores.php';
getScores("NanomunchersV2");
?>
        </div>
    </div>
    <button id="score2" ng-click="postScore()" type="button" class="btn btn-success btn-lg">Save Score</button>
</div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <form>
                    Player1:
                    <input id="p1Name" type="text" name="name">
                    <input id="p1Robot" type="checkbox" checked data-toggle="toggle" data-on="Human" data-off="Computer" data-onstyle="success" data-offstyle="danger"  data-width="90" ng-disabled="1">
コード例 #5
0
ファイル: index.php プロジェクト: jfriend08/Heuristic
<h2>Instructions</h2>
<p id='instr'>
1- Select a maze by clicking on its image.
<br><br>
2-Enter the number of bombs, detection radius and choose a game type, and then submit click. The number of bombs should be in the range 1-20 and the radius should be in the range 1-3.
<br><br>
3-If game type is human vs human, then the adversary team places bonus bombs by clicking on blocks on the board.
<br><br>
4-Then the adversary team places bad bombs by clicking on blocks on the board.
<br><br>
5-After the bad bombs disappear, rover team moves the rover with arrow keys.
<br><br>
6-If game type was human vs computer, then use arrow keys to move the rover.
<br><br>
7-Once the game ends, the rover team can submit their score by entering a name in the text field 'Player Name' and clicking on 'Save My Score' button.
<p>
</div>


<div id="hscores">
<?php 
include '../../functions.php';
getScores("Safe Roving");
?>
</div>


</div>
</body>
</html>
コード例 #6
0
ファイル: score.php プロジェクト: CamilleBargoin/asteroid
<?php

$file = 'score.txt';
if (isset($_POST['callFunction'])) {
    if ($_POST['callFunction'] == "saveScore") {
        saveScore();
    } else {
        if ($_POST['callFunction'] == "getScores") {
            getScores();
        }
    }
}
function saveScore()
{
    global $file;
    if (isset($_POST['pseudo']) && isset($_POST['score'])) {
        if ($_POST['pseudo'] !== '') {
            $pseudo = $_POST['pseudo'];
            $score = $_POST['score'];
            $line = $pseudo . ":" . $score . ";";
            file_put_contents($file, $line, FILE_APPEND | LOCK_EX);
            $reponse = 'ok';
        } else {
            $reponse = 'Les champs sont vides';
        }
    } else {
        $reponse = 'Tous les champs ne sont pas parvenus';
    }
    echo json_encode(['reponse' => $reponse]);
}
function getScores()
コード例 #7
0
ファイル: proc.php プロジェクト: EnheKh/cs490-1
    case "addOEQuestion":
        addOEQuestion($_POST["Question"], $_POST["Answer"]);
        break;
    case "newExam":
        newExam();
        break;
    case "createExam":
        createExam($_POST);
        break;
    case "getExams":
        getExams();
        break;
    case "takeExam":
        //takeExam($_POST["exam"],$_POST["username"],$_POST["qid"]);
        takeExam($_POST);
        break;
    case "checkAnswer":
        checkAnswer($_POST["qid"], $_POST["answer"], $_POST["exam"]);
        break;
    case "examScores":
        examScores($_POST["username"]);
        break;
    case "getScores":
        getScores($_POST["username"]);
        break;
    case "releaseScore":
        releaseScore($_POST);
        break;
    default:
        echo "You need to send me a command, for example: cmd = auth ";
}
コード例 #8
0
ファイル: index.php プロジェクト: renctan/Sudokill
<body>
<div class="post">
  <h2 class="title"><a href="#">Sudokill</a></h2>
</div>

<div id="board"></div>
<script src="games/sudokilljs/sudokill.js"></script>
<br /><br />

  <!-- display the last and best scores -->
	<!-- open the connection with the dabatase -->
	<?php 
// functions.php in case of an opening in the same window
// ../../functions.php in case of an opening in a new window
include 'functions.php';
getScores("sudokilljs");
?>

  <br />
  <br />

  <!-- scraped directly from https://github.com/renctan/Sudokill/wiki/How-to-Play -->
  <h1>How to Play</h1>

  <h2>Sudoku Rules</h2>

  <p>A standard Sudoku game plays in a 9x9 board. And the board can be further subdivided into 9 sectors, each sectors containing non-overlapping 3x3 cells. The objective of the game is to fill the entire board while following these constraints:</p>

  <ol>
    <li>Only numbers 1-9 can be used.</li>
    <li>There should be no repeating numbers within a row.</li>
コード例 #9
0
    echo "\r\n";
    echo scoreString(0, 'You', 1, 0, 0, 10, 50, 1, 0, 0, 0, 0, 0, 1, 0);
    echo scoreString(0, 'are', 0, 0, 0, 0, 50, 1, 10, 0, 0, 0, 0, 2, 0);
    echo scoreString(0, 'invalid!', -1, 0, 2, 10, 0, 1, 0, 0, 0, 0, 0, 3, 0);
    exit;
}
if (isUserBanned($playerID)) {
    echo "\r\n";
    echo scoreString(0, 'You', 1, 0, 0, 10, 50, 1, 0, 0, 0, 0, 0, 1, 0);
    echo scoreString(0, 'are', 0, 0, 0, 0, 50, 1, 10, 0, 0, 0, 0, 2, 0);
    echo scoreString(0, 'banned!', -1, 0, 2, 10, 0, 1, 0, 0, 0, 0, 0, 3, 0);
    exit;
}
getScores($c, $mode, $playerID);
//personal score
getScores($c, $mode, NULL);
function scoreString($replayId, $name, $score, $combo, $count50, $count100, $count300, $countMiss, $countKatu, $countGeki, $FC, $mods, $avatarID, $rank, $timestamp)
{
    if ($timestamp != '0') {
        $actualDate = getActualDate($timestamp);
    } else {
        $actualDate = '644112000';
    }
    return "{$replayId}|{$name}|{$score}|{$combo}|{$count50}|{$count100}|{$count300}|{$countMiss}|{$countKatu}|{$countGeki}|{$FC}|{$mods}|{$avatarID}|{$rank}|{$actualDate}\r\n";
}
function getActualDate($input)
{
    $input -= 60 * 60 * 4;
    //4h
    $year = substr($input, 0, 2);
    $month = substr($input, 2, 2);
コード例 #10
0
ファイル: crz.php プロジェクト: keeyon2/DatingGameWeb
                <div id="scores"></div>
                <div id="message">Player 1 to move</div>
                <div>
		    <script>
			function postScore(ws) {
			  var wr = "<?php 
$_SESSION['login'];
?>
";
			  if (wr == "") wr = "guest";
			  document.location.href="/drecco/index.php?task=f15Grav&winner="+wr+"&ws="+ws;
			}
		    </script>
                    <button id="score" onClick="postScore('2300')" type="button">Save Score</button>
                </div>
            </div>
        </div>
	<script type="text/javascript" src="logic.js"></script>
    <div style="position:absolute; top:80%; height:10%">
	<h2 class="title">Last 10 scores</h2>
    <?php 
// functions.php in case of an opening in the same window
// ../../functions.php in case of an opening in a new window
include '../../lastScores.php';
getScores("f15Grav");
?>
    </div>
    </body>
</html>

コード例 #11
0
ファイル: jPuzzle15.php プロジェクト: joksnet/js-games
<?php

$db = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('jpuzzle15') or die(mysql_error());
if (isset($_POST['add'])) {
    $name = addslashes($_POST['name']);
    $board = addslashes($_POST['board']);
    $time = $_POST['time'];
    $moves = $_POST['moves'];
    $level = $_POST['level'];
    mysql_query("INSERT INTO puzzle (name, board, time, moves, level)\n                 VALUES ('{$name}', '{$board}', '{$time}', '{$moves}', '{$level}')");
}
function getScores($orderBy = 'time')
{
    $result = mysql_query('SELECT puzzle.*, puzzle_levels.name AS lname FROM puzzle LEFT JOIN puzzle_levels ON puzzle_levels.id = puzzle.level ORDER BY puzzle.' . $orderBy . ' ASC');
    $return = array();
    while ($row = mysql_fetch_assoc($result)) {
        $return[] = sprintf("{name:'%s',board:'%s',time:'%s',moves:'%s',level:'%s',lname:'%s'}", $row['name'], $row['board'], $row['time'], $row['moves'], $row['level'], $row['lname']);
    }
    mysql_free_result($result);
    return '[' . implode(',', $return) . ']';
}
$print = array();
$print[] = 'times:' . getScores();
$print[] = 'moves:' . getScores('moves');
echo '{' . implode(',', $print) . '}';