public function start() { if (isset($_POST) && count($_POST) > 0) { if (isset($_POST["newFeeling"])) { Feeling::parseNewFeeling(); } if (isset($_POST["newMoodsArray"])) { Feeling::parseNewMoodsArray(); } if (isset($_POST["newMoods"])) { Feeling::parseNewMoods(); } } else { $this->feelingID = Feeling::mostCommonFeelingID(); $feeling = new Feeling($this->feelingID); echo "<p>I am feeling " . $feeling->name() . "</p><p>"; echo "<p>On average, humans who are feeling " . $feeling->name() . " have the mood characteristics below:</p>"; echo "<p>"; echo MoodType::moodTypeArrayForm($this->feelingID, $feeling->moods); echo $feeling->overallMoodValue(); } }
public static function moodTypeArrayForm($feelingID, $moodTypeArray) { $feeling = new Feeling($feelingID); $html = "<form action ='index.php' method = 'POST' id='moodArrayForm'>"; $html .= "If you were feeling " . $feeling->name() . ", on a scale of 1 - 10, how would you rate how the following " . "mood states reflected your feeling?" . " (1 being that you don't feel like that, 10 being you definitely do feel like that)<br/>"; foreach ($moodTypeArray as $moodTypeID => $currentAverageScale) { $MoodType = new MoodType($moodTypeID); $html .= "<strong>" . $MoodType->name() . "</strong></br>"; $html .= "<input type='text' name ='" . $MoodType->moodTypeID . "' value ='{$currentAverageScale}'><br/>"; } $html .= "<input type='hidden' name ='newMoodsArray'>"; $html .= "<input type='hidden' name ='feelingID' value = '{$feelingID}'>"; $html .= "</form>"; $html .= "<button type='submit' form='moodArrayForm' value='Submit'>Submit</button>"; return $html; }