Exemple #1
0
function makeAnswerAttempt($uid, $pid, $answer)
{
    if (!isTesterOnPuzzle($uid, $pid) && !isFormerTesterOnPuzzle($uid, $pid)) {
        return;
    }
    $cleanAnswer = htmlspecialchars($answer);
    $check = checkAnswer($pid, $cleanAnswer);
    if ($check === FALSE) {
        $comment = "Incorrect answer attempt: {$cleanAnswer}";
        $_SESSION['answer'] = "<div class='msg'>{$cleanAnswer} is <span class='incorr'>incorrect</span></div>";
    } else {
        $comment = "Correct answer attempt: {$cleanAnswer}";
        $_SESSION['answer'] = "<div class='msg'>{$check} is <span class='corr'>correct</span></div>";
    }
    mysql_query('START TRANSACTION');
    $sql = sprintf("INSERT INTO answer_attempts (pid, uid, answer) VALUES ('%s', '%s', '%s')", mysql_real_escape_string($pid), mysql_real_escape_string($uid), mysql_real_escape_string($cleanAnswer));
    query_db($sql);
    addComment($uid, $pid, $comment, FALSE, TRUE);
    mysql_query('COMMIT');
}
Exemple #2
0
require_once "utils.php";
// Redirect to the login page, if not logged in
$uid = isLoggedIn();
// Check for puzzle id
if (!isset($_GET['pid'])) {
    head("", "Error");
    echo "Puzzle ID not found. Please try again.";
    foot();
    exit(1);
}
$pid = $_GET['pid'];
// Start HTML
head("", "Puzzle {$pid}: Testsolving");
// Check permissions
if (!isTestingAdmin($uid)) {
    if (!isTesterOnPuzzle($uid, $pid) && !isFormerTesterOnPuzzle($uid, $pid)) {
        if (!canTestPuzzle($uid, $pid)) {
            echo "You do not have permission to test this puzzle.";
            foot();
            exit(1);
        } else {
            addPuzzleToTestQueue($uid, $pid);
        }
    }
}
$title = getTitle($pid);
if ($title == NULL) {
    $title = '(untitled)';
}
echo "<h2>Puzzle {$pid} &mdash; {$title}</h2>";
echo "<strong class='impt'>IMPORTANT:</strong> <b>Please leave feedback! We\n    need it!</b><br><br> When you are done, PLEASE leave feedback indicating\n    that you do not intend to return, <b>even if the rest is blank</b>. This\n    removes you as a tester on this puzzle, so we can track who's still\n    working.\n";