本文整理汇总了PHP中DataAccess::create_level_attempt方法的典型用法代码示例。如果您正苦于以下问题:PHP DataAccess::create_level_attempt方法的具体用法?PHP DataAccess::create_level_attempt怎么用?PHP DataAccess::create_level_attempt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess::create_level_attempt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json_encode
<?php
if ($_SERVER["REQUEST_METHOD"] !== 'POST') {
http_response_code(405);
exit;
}
require_once 'includes/data_access.php';
$json = json_decode(file_get_contents('php://input'));
$level_session_id = $json->level_id;
$program = $json->program;
$attempt_start = $json->attempt_start;
$attempt_end = $json->attempt_end;
$score = $json->score;
$used_help = $json->used_help;
$used_debugger = $json->used_debugger;
$data_access = new DataAccess();
$attempt_id = $data_access->create_level_attempt($level_session_id, $program, $attempt_start, $attempt_end);
$data_access->complete_level($attempt_id, $level_session_id, $score, $used_help, $used_debugger);
header('Content-Type: application/json');
echo json_encode(array('session_level_id' => $level_session_id, 'attempt_id' => $attempt_id));
示例2: json_encode
<?php
if ($_SERVER["REQUEST_METHOD"] !== 'POST') {
http_response_code(405);
exit;
}
require_once 'includes/data_access.php';
$json = json_decode(file_get_contents('php://input'));
$level_id = $json->level_id;
//$program = json_encode($json->program); // convert the program itself back into a json string for storage.
$program = $json->program;
$start = $json->start;
$end = $json->end;
$data_access = new DataAccess();
$attempt_id = $data_access->create_level_attempt($level_id, $program, $start, $end);
header('Content-Type: application/json');
echo json_encode(array('attempt_id' => $attempt_id));