示例#1
0
function getCorrectSolves($uid, $pid)
{
    $attempts = getAnswerAttempts($uid, $pid);
    $correct = array();
    foreach ($attempts as $attempt) {
        if (checkAnswer($pid, $attempt)) {
            $correct[] = $_SESSION['answer'];
            unset($_SESSION['answer']);
        }
    }
    if (!$correct) {
        return NULL;
    }
    $correct = array_unique($correct);
    return implode(', ', $correct);
}
示例#2
0
function displayPrevAns($uid, $pid)
{
    $answers = getAnswerAttempts($uid, $pid);
    if (!$answers) {
        return;
    }
    $correct = getCorrectSolves($uid, $pid);
    if ($correct) {
        echo "<h3>Correct Answers: {$correct}</h3>";
    }
    echo '<h3>Attempted Answers:</h3>';
    echo '<ul>';
    foreach ($answers as $ans) {
        echo "<li>{$ans}</li>";
    }
    echo '</ul>';
}