Esempio n. 1
0
function execute($request)
{
    $problem_id = intval($request['path_parts'][1]);
    $problem = api_autograder_menu_get_problem($request['user_id'], 'golf', 0, $problem_id);
    if ($problem == null) {
        return build_response_not_found("Golf Problem not found.");
    }
    $output = array('<h1>', '<a href="/golf">Code Golf</a> &gt; ', htmlspecialchars($problem['title']), '</h1>', '<div>', nl2br(htmlspecialchars($problem['statement'])), '</div>', api_autograder_generate_client_html('golf', null, '', $problem_id));
    return build_response_ok("Code Golf: " . $problem['title'], implode("\n", $output), array('js' => 'autograder.js', 'onload' => "ag_init('golf')"));
}
Esempio n. 2
0
function execute($request)
{
    $language_info = api_autograder_get_language_info($request['path_parts'][1]);
    $problem_id = intval($request['path_parts'][2]);
    if ($problem_id == 0 || $language_info == null) {
        return build_response_not_found("Problem not found.");
    }
    $problem = api_autograder_menu_get_problem($request['user_id'], $language_info['language_id'], 'practice', 0, $problem_id);
    if ($problem == null) {
        return build_response_not_found("Problem not found.");
    }
    $output = array('<h1>' . htmlspecialchars($problem['title']) . '</h1>', '<div>', nl2br(htmlspecialchars($problem['statement'])), '</div>', api_autograder_generate_client_html('practice', $language_info, $problem['template'], $problem_id));
    return build_response_ok('Problem', implode("\n", $output), array('js' => 'autograder.js', 'onload' => "ag_init('practice')"));
}
Esempio n. 3
0
function execute($request)
{
    $html = api_autograder_generate_client_html('tinker', null, '', 0);
    $output = array('<h1>Code Tinker</h1>', "<p>", "Write some code. Run it. See the output. ", "All code runs in a remote sandbox. ", "For more guided practice, see the <a href=\"/practice\">practice problems</a> or <a href=\"/tutorials\">tutorials</a> if you're just starting out. ", "</p>", $html);
    return build_response_ok("Code Tinker", implode("\n", $output), array('js' => 'autograder.js', 'onload' => "ag_init('tinker')"));
}