当前位置: 首页>>代码示例>>PHP>>正文


PHP DataAccess::create_level_attempt方法代码示例

本文整理汇总了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));
开发者ID:medkg15,项目名称:how-to-train-your-robot,代码行数:20,代码来源:complete-level.php

示例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));
开发者ID:medkg15,项目名称:how-to-train-your-robot,代码行数:17,代码来源:failed-attempt.php


注:本文中的DataAccess::create_level_attempt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。