예제 #1
0
            $responseExitMsg = "Exit Program!";
            session_destroy();
        } else {
            $num = (int) $getUSSD->getMessage();
            $data = json_decode(getSessionInfo($sessionId, $address), true);
            showView($USSDSessionID, getLyrics($data[$num]['track_id'], $API), $INFO);
            //deleteSessionInfo($sessionId);
        }
    } else {
        if ($getUSSD->getMessage() == 'P') {
            showView($USSDSessionID, getTracks(getContentInfo($sessionId, $address), $sessionId, $address, getPageInfo($sessionId, $address) - 1, $API), $INFO);
        } else {
            if ($getUSSD->getMessage() == 'N') {
                showView($USSDSessionID, getTracks(getContentInfo($sessionId, $address), $sessionId, $address, getPageInfo($sessionId, $address) + 1, $API), $INFO);
            } else {
                showView($USSDSessionID, getTracks($content, $sessionId, $address, 1, $API), $INFO);
            }
        }
    }
}
function getTracks($content, $sessionId, $address, $pagenum = 1, $API)
{
    $query = "http://api.musixmatch.com/ws/1.1/track.search?apikey={$API}&q=" . $content . "&page_size=10&f_has_lyrics=1&page=" . $pagenum;
    $jdata = file_get_contents($query);
    $data = json_decode($jdata, true);
    $result = "";
    $i = 1;
    $tem = "";
    foreach ($data["message"]["body"]["track_list"] as $t) {
        $result .= $i . ". " . $t["track"]["track_name"] . " - " . $t["track"]["artist_name"] . "\n";
        $tem[$i++] = array("track_id" => $t["track"]["track_id"]);
예제 #2
0
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";
}
<?php

require __DIR__ . '/../vendor/autoload.php';
$config = json_decode(file_get_contents(__DIR__ . '/config.json'), true);
$client = new \Survos\Client\SurvosClient($config['endpoint']);
if (!$client->authorize($config['username'], $config['password'])) {
    throw new \Exception('Wrong credentials!');
}
$project = 'behattest';
$memberCode = 'otest';
$date = '2016-01-31';
$assignments = getTrackingAssignments($client, $project, $memberCode, $date);
foreach ($assignments['items'] as $assignment) {
    $tracks = getTracks($client, $assignment['scheduled_time'], $assignment['scheduled_end_time']);
    if (false !== ($center = getTracksCenter($tracks))) {
        $assignment['center_lat_lng'] = $center;
        saveAssignment($client, $assignment);
    }
}
function getTrackingTasks($client)
{
    $resource = new \Survos\Client\Resource\TaskResource($client);
    return $resource->getList(null, null, ['task_type_code' => 'device']);
}
function getTrackingAssignments($client, $project = null, $memberCode = null, $date = null)
{
    $resource = new \Survos\Client\Resource\AssignmentResource($client, $params = []);
    $filter = ['score' => 0];
    $comparison = ['score' => \Survos\Client\SurvosCriteria::GREATER_THAN];
    $params = ['task_type_code' => 'device'];
    if (null !== $project) {