Example #1
0
function displayClueEditForm(Clue $clue)
{
    $dateSelect = ui_select('date', Date::getAllDates(), $clue->getFormDate());
    $defaultStateSelect = ui_select('defaultState', State::getAllStates(), $clue->getDefaultState());
    $startDateSelect = ui_select("startDate", Date::getAllDatesNullable(), $clue->getStartFormDate());
    $hintDateSelect = ui_select("hintDate", Date::getAllDatesNullable(), $clue->getHintFormDate());
    $answerDateSelect = ui_select("answerDate", Date::getAllDatesNullable(), $clue->getAnswerFormDate());
    $startCitySelect = ui_select("startCity", City::getAllCityNames(), $clue->getStartCityID());
    $hintCitySelect = ui_select("hintCity", City::getAllCityNames(), $clue->getHintCityID());
    $answerCitySelect = ui_select("answerCity", City::getAllCityNames(), $clue->getAnswerCityID());
    $startDirectionSelect = ui_select("startDirection", Direction::getAllDirections(), $clue->getStartDirection());
    $hintDirectionSelect = ui_select("hintDirection", Direction::getAllDirections(), $clue->getHintDirection());
    $answerDirectionSelect = ui_select("answerDirection", Direction::getAllDirections(), $clue->getAnswerDirection());
    return <<<EOT
<form method="POST" action="clues.php">
Name (admin use only): <input type="hidden" name="id" value="{$clue->getID()}" />
<input type="text" name="name" value="{$clue->getName()}" />
<br />
Date (for sorting): {$dateSelect}
<input type="text" size="8" name="time" value="{$clue->getFormTime()}" />
<br />
Default state: {$defaultStateSelect}
<br />
Question: <br />
<textarea name="question" cols="45" rows="8">{$clue->getQuestion()}</textarea><br />
Hint: <br />
<textarea name="hint" cols="45" rows="4">{$clue->getHint()}</textarea><br />
Answers (1 per line, * for wildcard): <br />
<textarea name="answer" cols="45" rows="4">{$clue->getAnswerText()}</textarea><br />
<br /><br />

Answering prerequisites:<br />
<input type="text" size="4" name="startDistance" value="{$clue->getStartDistance()}" />
miles {$startDirectionSelect} {$startCitySelect} or after time
{$startDateSelect} <input type="text" size="8" name="startTime" value="{$clue->getStartFormTime()}" />.<br /><br />

Hint conditions:<br />
<input type="text" size="4" name="hintDistance" value="{$clue->getHintDistance()}" />
miles {$hintDirectionSelect} {$hintCitySelect} or after time
{$hintDateSelect} <input type="text" size="8" name="hintTime" value="{$clue->getHintFormTime()}" />.<br /><br />

Auto-answering conditions:<br />
<input type="text" size="4" name="answerDistance" value="{$clue->getAnswerDistance()}" />
miles {$answerDirectionSelect} {$answerCitySelect} or after time
{$answerDateSelect} <input type="text" size="8" name="answerTime" value="{$clue->getAnswerFormTime()}" />.<br /><br />


<input type="submit" name="edit" value="Edit Clue" />
<br /><br />
Delete clue: <input type="submit" name="delete" value="Delete Clue" />
</form>
EOT;
}
Example #2
0
 public function getHistogram()
 {
     $clueStates = $this->getClueStates();
     $teams = Team::getAllTeams();
     if (count($clueStates) == 0) {
         return "<span style=\"font-size: 12px;\"><b>All hidden</b></span>";
     }
     $counts = array(0, 0, 0, 0, 0);
     foreach ($teams as $team) {
         $clueState = $this->getClueState($team);
         $state = $clueState ? $clueState->getState() : STATE_HIDDEN;
         $counts[$state]++;
     }
     if ($counts[STATE_ANSWERED] == count($teams)) {
         return "<span style=\"font-size: 12px;\"><b>All answered</b></span>";
     }
     $text = '';
     foreach (State::getAllStates() as $key => $value) {
         if ($text != '') {
             $text .= ', ';
         }
         $text .= "<b>" . $counts[$key] . "</b> " . $value;
     }
     return '<span style="font-size: 12px;">' . $text . "</span>";
 }