From aa0b751008884c34191eef1818f274bbee84efaa Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Thu, 25 Apr 2013 14:22:20 -0700 Subject: Server-side work for challenges. --- ajax/challenges.ajax.php | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/ajax/challenges.ajax.php b/ajax/challenges.ajax.php index 77a788d..f27f3bb 100644 --- a/ajax/challenges.ajax.php +++ b/ajax/challenges.ajax.php @@ -16,7 +16,7 @@ if ($_GET['getChallengeMap'] == 'true') { } if ($_GET['getChallenges'] == 'true') { - echo displayChallenges($_GET['challengeMapID']); + echo json_encode(getChallenges($_GET['challengeMapID'], $_GET['userID'])); exit; } @@ -89,34 +89,14 @@ function getChallengesByTier($userIdUnsanitized) { } -function displayChallenges($mapIdUnsanitized) { - $result = loadChallengesForMap($mapIdUnsanitized, 3); - while($challenge = mysql_fetch_array($result)) { +function getChallenges($mapIdUnsanitized, $userIdUnsanitized) { + $result = loadChallengesForMap($mapIdUnsanitized, $userIdUnsanitized); + while($challenge = mysql_fetch_assoc($result)) { $data[] = $challenge; } return $data; } -function displayChallengesHTML($challengeResultset) -{ - echo '
'; - echo '
Challenges
'; - echo '
    '; - while($challenge = mysql_fetch_array($challengeResultset)) - { - $challengeMapID = $_GET["challengeMapID"]; - $challengeId = $challenge["challengeID"]; - if($challenge["dateSolved"] !== NULL) - $cssClass = "challenge_complete"; - else - $cssClass = "challenge_incomplete"; - $loadSolutionString = " Load this solution"; - echo "
  • " . getChallengeDisplayString($challenge) . " $loadSolutionString
  • "; - } - echo "
"; -} - - /** * Returns a MySQL resultset for all challenges for the given mapID -- cgit v1.2.3