Few fixes

This commit is contained in:
Ruben 2016-09-17 22:32:42 +01:00
parent 88d3323107
commit 1d8d3c1d46
5 changed files with 16 additions and 11 deletions

View file

@ -5,7 +5,8 @@ chdir(__DIR__);
require_once __DIR__ . "/../bootstrap.php"; require_once __DIR__ . "/../bootstrap.php";
error_reporting(E_ALL);
ini_set('display_errors',)
// Show table creation statements // Show table creation statements
// And (re)generate Proxies // And (re)generate Proxies

View file

@ -72,7 +72,7 @@ class ScoreControllerProvider implements ControllerProviderInterface
$level = $this->_eh->getEm()->getRepository(Models\Level::class)->find($data['lvl_id']); $level = $this->_eh->getEm()->getRepository(Models\Level::class)->find($data['lvl_id']);
if(empty($level)) { if(empty($level)) {
return new JsonResponse(['success' => false, 'message' => "Invalid level"], 400); return new JsonResponse(['success' => false, 'message' => "Invalid level" , "lvl_id" => (int) $data['lvl_id']], 400);
} }
$game = new Models\Game(); $game = new Models\Game();
@ -193,9 +193,13 @@ class ScoreControllerProvider implements ControllerProviderInterface
if(empty($hit) || $hit->getGame()->getUser()->getId() != $user->getId()) { if(empty($hit) || $hit->getGame()->getUser()->getId() != $user->getId()) {
return new JsonResponse(['success' => false, 'message' => "Hit not found."], 400); return new JsonResponse(['success' => false, 'message' => "Hit not found."], 400);
} }
$targetFilename = $hit->getFeatureFilename($part); $targetDirname = $hit->getFeatureDirname($part);
$file->move($targetFilename); if($targetDirname == null) {
return new JsonResponse(['success' => false, 'message' => "Something went wrong. Invalid part?", "part" => (string) $part], 400);
}
$file->move($targetDirname, $hit->getId().'.jpg');
$hit->setHasImage(true); $hit->setHasImage(true);
$em->persist($hit); $em->persist($hit);
} }
@ -234,21 +238,22 @@ class ScoreControllerProvider implements ControllerProviderInterface
'pitch' => [], 'pitch' => [],
'yaw' => [], 'yaw' => [],
'inter_ocular_distance' => [], 'inter_ocular_distance' => [],
'mouth_open' => ["JawDropStretched"], // 'mouth_open' => ["JawDropStretched"],
'mouth_open' => ["UpperLipUp","lowerLipDown"],
'lip_press' => ["lowerLipUp"], 'lip_press' => ["lowerLipUp"],
'brow_raise' => ["RightOuterBrowUp","LeftOuterBrowUp"], 'brow_raise' => ["RightOuterBrowUp","LeftOuterBrowUp"],
'nose_wrinkler' => ["NasolabialDeepener"], 'nose_wrinkler' => ["NasolabialDeepener"],
'lip_depressor' => ["MouthRightPullDown","MouthLeftPullDown"], 'lip_depressor' => ["MouthRightPullDown","MouthLeftPullDown"],
'brow_furrow' => ["NoseWrinkler"], 'brow_furrow' => ["NoseWrinkler"],
'attention' => [], 'attention' => [],
'smile' => ["MouthRightPullUp","MouthLeftPullUp","UpperLipUp","lowerLipDown"], // 'smile' => ["MouthRightPullUp","MouthLeftPullUp", "UpperLipUp","lowerLipDown"],
'smile' => ["UpperLipStretched"], 'smile' => ["UpperLipStretched"],
'inner_brow_raiser' => ["RightInnerBrowUp","LeftInnerBrowUp"], 'inner_brow_raiser' => ["RightInnerBrowUp","LeftInnerBrowUp"],
'chin_raiser' => ["ChinForward"], 'chin_raiser' => ["ChinForward"],
'smirk' => ["MouthLeftPullUp"], 'smirk' => ["MouthLeftPullUp"],
'lip_suck' => ["UpperLipBackward","lowerLipBackward"], 'lip_suck' => ["UpperLipBackward","lowerLipBackward"],
'upper_lip_raiser' => ["UpperLipUp"], 'upper_lip_raiser' => ["UpperLipUp"],
'lip_pucker' => ["LipsKiss"], // 'lip_pucker' => ["LipsKiss"],
'lip_pucker' => ["UpperLipForward","lowerLipForward"], 'lip_pucker' => ["UpperLipForward","lowerLipForward"],
'eye_closure' => ["RightUpperLidClosed","LeftUpperLidClosed"], 'eye_closure' => ["RightUpperLidClosed","LeftUpperLidClosed"],
'engagement' => [], 'engagement' => [],

View file

@ -206,12 +206,12 @@ class Hit
* @return string|false false if not exists * @return string|false false if not exists
* @throws \Exception * @throws \Exception
*/ */
public function getFeatureFilename(string $feature) { public function getFeatureDirname(string $feature) {
if(!in_array($feature, static::$FEATURES)) { if(!in_array($feature, static::$FEATURES)) {
throw new \Exception("Invalid feature!"); throw new \Exception("Invalid feature!");
} }
return realpath(__DIR__ . "/../../files/hits/".$feature."/".$this->getId() . '.jpg' ); return realpath(__DIR__ . "/../../files/hits/".$feature) ;
} }
/** /**

View file

@ -19,7 +19,6 @@ class Level
* *
* @ORM\Column(name="id",type="integer") * @ORM\Column(name="id",type="integer")
* @ORM\Id * @ORM\Id
* @ORM\GeneratedValue
*/ */
private $id; private $id;

View file

@ -67,7 +67,7 @@ class UserRepository extends EntityRepository implements UserProviderInterface
$results = $query->getScalarResult(); $results = $query->getScalarResult();
$score = 0; $score = 0;
foreach($results as $result) { foreach($results as $result) {
$score += $results['score']; $score += $result['score'];
} }
$user->setTotalScore($score); $user->setTotalScore($score);