function webauto_test_passed($grade, $url) { global $USER, $OUTPUT; success_out("Test passed - congratulations"); if ($USER->displayname === false || !isset($_SESSION['lti'])) { line_out('Not setup to return a grade..'); return false; } $LTI = $_SESSION['lti']; $old_grade = isset($LTI['grade']) ? $LTI['grade'] : 0.0; if ($grade < $old_grade) { line_out('New grade is not higher than your previous grade=' . $old_grade); line_out('Sending your previous high score'); $grade = $old_grade; } gradeUpdateJson(json_encode(array("url" => $url))); $debug_log = array(); $retval = LTIX::gradeSend($grade, false, $debug_log); $OUTPUT->dumpDebugArray($debug_log); if ($retval == true) { $success = "Grade sent to server (" . $grade . ")"; } else { if (is_string($retval)) { $failure = "Grade not sent: " . $retval; } else { echo "<pre>\n"; var_dump($retval); echo "</pre>\n"; $failure = "Internal error"; } } if (strlen($success) > 0) { success_out($success); error_log($success); } else { if (strlen($failure) > 0) { error_out($failure); error_log($failure); } else { error_log("No status"); } } return true; }
<?php require_once "../../config.php"; require_once $CFG->dirroot . "/pdo.php"; require_once $CFG->dirroot . "/core/gradebook/lib.php"; use Tsugi\Core\LTIX; // Sanity checks $LTI = LTIX::requireData(); $user_id = $USER->id; $grade = 1.0; $code = $_POST['code']; gradeUpdateJson(array("code" => $code)); $_SESSION['pythonauto_lastcode'] = $code; $debug_log = array(); $retval = LTIX::gradeSend($grade, false, $debug_log); if (is_string($retval)) { echo json_encode(array("status" => "failure", "detail" => $retval, "debug_log" => $debug_log)); return; } $retval = array("status" => "success", "debug_log" => $debug_log); echo json_encode($retval);
// Get the current user's grade data $row = gradeLoad(); $OLDCODE = false; $json = array(); $editor = 1; if ( $row !== false && isset($row['json'])) { $json = json_decode($row['json'], true); if ( isset($json["code"]) ) $OLDCODE = $json["code"]; if ( isset($json["editor"]) ) $editor = $json["editor"]; } if ( isset($_GET['editor']) && ( $_GET['editor'] == '1' || $_GET['editor'] == '0' ) ) { $neweditor = $_GET['editor']+0; if ( $editor != $neweditor ) { gradeUpdateJson(array("editor" => $neweditor)); $json['editor'] = $neweditor; $editor = $neweditor; } } $codemirror = $editor == 1; // Get any due date information $dueDate = SettingsForm::getDueDate(); $OUTPUT->header(); // Defaults $QTEXT = 'You can write any code you like in the window below. There are three files loaded and ready for you to open if you want to do file processing: "mbox-short.txt", "romeo.txt", and "words.txt".';
function webauto_test_passed($grade, $url) { global $displayname; global $OUTPUT; success_out("Test passed - congratulations"); if ($displayname === false || !isset($_SESSION['lti'])) { line_out('Not setup to return a grade..'); exit; } if (!isset($_GET['grade'])) { line_out('Dry run - grade of (' . intval($grade * 100) . '%) was not sent.'); exit; } gradeUpdateJson(json_encode(array("url" => $url))); $debug_log = array(); $retval = LTIX::gradeSend($grade, false, $debug_log); $OUTPUT->dumpDebugArray($debug_log); if ($retval == true) { $success = "Grade sent to server (" . intval($grade * 100) . "%)"; } else { if (is_string($retval)) { $failure = "Grade not sent: " . $retval; } else { echo "<pre>\n"; var_dump($retval); echo "</pre>\n"; $failure = "Internal error"; } } if (strlen($success) > 0) { success_out($success); error_log($success); } else { if (strlen($failure) > 0) { error_out($failure); error_log($failure); } else { error_log("No status"); } } }