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; }
public static function averageMoodTypePerFeelingArray($feelingID) { $array = array(); foreach (MoodType::moodTypeIDArray() as $moodTypeID) { @($array[$moodTypeID] = self::totalScaleMoodTypeAndFeeling($moodTypeID, $feelingID) / self::totalRowsMoodTypeAndFeeling($moodTypeID, $feelingID)); } return $array; }
public static function parseNewFeeling() { $newFeeling = $_POST["feeling"]; $brain = Brain::getInstance(); $array = array("name" => $newFeeling); if (!$brain->checkExists(self::$area, $array)) { $brain->learn(self::$area, array("name" => $newFeeling)); $feelingID = $brain->lastInsertID(); echo "<p> The feeling ' {$newFeeling} ' is new to me...please tell me more....."; echo "<p>" . MoodType::moodTypeForm($feelingID); } else { $feeling = new Feeling(self::IDFromName($newFeeling)); $feeling->addCount(); echo "<p> Funny you should say that; " . $feeling->displayCount() . " people felt '" . $feeling->displayFeeling() . "' the same talking to me...please tell me a bit more..."; echo "<p>" . MoodType::moodTypeForm($feeling->feelingID); } }
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(); } }