/**
  * @param Request $request
  * @param Created $payload
  */
 public function created(Request $request, Created $payload)
 {
     $serializer = PerformanceStatistic::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 201, ['Location' => $resource->getLinks()['self']]);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Startgroup::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge']));
     $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = Routine::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['startgroup', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'performance-scores']));
     $resource = $resource->fields($params->getFields(['routine' => Routine::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-score' => PerformanceScore::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $params = new Parameters($request->query->all());
     $serializer = PerformanceStatistic::getSerializer();
     $resource = new Resource($payload->getModel(), $serializer);
     $resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine']));
     $resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()]));
     $document = new Document($resource);
     return new JsonResponse($document->toArray(), 200);
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = Startgroup::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['competition', 'event', 'performance-total-statistic', 'performance-execution-statistic', 'performance-choreography-statistic', 'performance-music-and-timing-statistic', 'routines', 'judges', 'routines.performance-total-statistic', 'routines.performance-execution-statistic', 'routines.performance-choreography-statistic', 'routines.performance-music-and-timing-statistic', 'routines.performance-scores', 'routines.performance-scores.judge']));
     $resource = $resource->fields($params->getFields(['startgroup' => Startgroup::getSerializer()->getFields(), 'competition' => Competition::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'performance-total-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-execution-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-choreography-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'performance-music-and-timing-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields(), 'judge' => Judge::getSerializer()->getFields()]));
     $document = new Document($resource);
     // meta
     $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]);
     // return response
     return new JsonResponse($document->toArray());
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function found(Request $request, Found $payload)
 {
     $params = new Parameters($request->query->all());
     $data = $payload->getModel();
     $serializer = PerformanceStatistic::getSerializer();
     $resource = new Collection($data, $serializer);
     $resource = $resource->with($params->getInclude(['events', 'startgroups', 'routine']));
     $resource = $resource->fields($params->getFields(['performance-statistic' => PerformanceStatistic::getSerializer()->getFields(), 'event' => Event::getSerializer()->getFields(), 'startgroup' => Startgroup::getSerializer()->getFields(), 'routine' => Routine::getSerializer()->getFields()]));
     $document = new Document($resource);
     // meta
     $document->setMeta(['total' => $data->getNbResults(), 'first' => $data->getFirstPage(), 'next' => $data->getNextPage(), 'previous' => $data->getPreviousPage(), 'last' => $data->getLastPage()]);
     // return response
     return new JsonResponse($document->toArray());
 }
Exemple #7
0
 private function analyzeRoutine(Routine $routine, PerformanceStatistic $statistic, $target)
 {
     $sum = 0;
     $min = 30;
     $max = 0;
     $scores = $routine->getPerformanceScores()->count();
     $values = [];
     foreach ($routine->getPerformanceScores() as $score) {
         $method = 'get' . $target;
         $val = $score->{$method}();
         $min = min($min, $val);
         $max = max($max, $val);
         $sum += $val;
         $values[] = $val;
     }
     $avg = $sum / $scores;
     $statistic->setAverage($avg);
     $statistic->setMin($min);
     $statistic->setMax($max);
     $statistic->setRange(abs($max - $min));
     // median
     sort($values);
     if ($scores % 2 == 0) {
         $lower = floor($scores / 2);
         $upper = ceil($scores / 2);
         $md = ($values[$lower] + $values[$upper]) / 2;
     } else {
         $md = $values[ceil($scores / 2)];
     }
     $statistic->setMedian($md);
     // sd + variance
     $sum = 0;
     foreach ($routine->getPerformanceScores() as $score) {
         $method = 'get' . $target;
         $sum += pow($val - $avg, 2);
     }
     $v = 1 / ($scores - 1) * $sum;
     $sd = sqrt($v);
     $statistic->setVariance($v);
     $statistic->setStandardDeviation($sd);
     $statistic->setVariabilityCoefficient($sd / $avg * 100);
     $statistic->save();
     return $statistic;
 }
Exemple #8
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aStartgroup) {
         $this->aStartgroup->removeRoutine($this);
     }
     if (null !== $this->aPerformanceTotalStatistic) {
         $this->aPerformanceTotalStatistic->removeRoutineRelatedByPerformanceTotalStatisticId($this);
     }
     if (null !== $this->aPerformanceExecutionStatistic) {
         $this->aPerformanceExecutionStatistic->removeRoutineRelatedByPerformanceExecutionStatisticId($this);
     }
     if (null !== $this->aPerformanceChoreographyStatistic) {
         $this->aPerformanceChoreographyStatistic->removeRoutineRelatedByPerformanceChoreographyStatisticId($this);
     }
     if (null !== $this->aPerformanceMusicAndTimingStatistic) {
         $this->aPerformanceMusicAndTimingStatistic->removeRoutineRelatedByPerformanceMusicAndTimingStatisticId($this);
     }
     $this->id = null;
     $this->name = null;
     $this->startgroup_id = null;
     $this->performance_total_statistic_id = null;
     $this->performance_execution_statistic_id = null;
     $this->performance_choreography_statistic_id = null;
     $this->performance_music_and_timing_statistic_id = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
 /**
  * Exclude object from result
  *
  * @param   ChildPerformanceStatistic $performanceStatistic Object to remove from the list of results
  *
  * @return $this|ChildPerformanceStatisticQuery The current query, for fluid interface
  */
 public function prune($performanceStatistic = null)
 {
     if ($performanceStatistic) {
         $this->addUsingAlias(PerformanceStatisticTableMap::COL_ID, $performanceStatistic->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Exemple #10
0
 /**
  * Filter the query by a related \iuf\junia\model\PerformanceStatistic object
  *
  * @param \iuf\junia\model\PerformanceStatistic|ObjectCollection $performanceStatistic The related object(s) to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @throws \Propel\Runtime\Exception\PropelException
  *
  * @return ChildEventQuery The current query, for fluid interface
  */
 public function filterByPerformanceMusicAndTimingStatistic($performanceStatistic, $comparison = null)
 {
     if ($performanceStatistic instanceof \iuf\junia\model\PerformanceStatistic) {
         return $this->addUsingAlias(EventTableMap::COL_PERFORMANCE_MUSIC_AND_TIMING_STATISTIC_ID, $performanceStatistic->getId(), $comparison);
     } elseif ($performanceStatistic instanceof ObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(EventTableMap::COL_PERFORMANCE_MUSIC_AND_TIMING_STATISTIC_ID, $performanceStatistic->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByPerformanceMusicAndTimingStatistic() only accepts arguments of type \\iuf\\junia\\model\\PerformanceStatistic or Collection');
     }
 }
 /**
  * @param mixed $model
  * @return Relationship
  */
 public function performanceTotalStatistic($model)
 {
     $serializer = PerformanceStatistic::getSerializer();
     $id = $serializer->getId($model->getPerformanceTotalStatistic());
     if ($id !== null) {
         $relationship = new Relationship(new Resource($model->getPerformanceTotalStatistic(), $serializer));
         $relationship->setLinks(['related' => '%apiurl%' . $serializer->getType(null) . '/' . $id]);
         return $this->addRelationshipSelfLink($relationship, $model, 'performance-total-statistic');
     }
     return null;
 }
 /**
  * @param Request $request
  * @param Found $payload
  */
 public function read(Request $request, Found $payload)
 {
     $serializer = PerformanceStatistic::getSerializer();
     $relationship = $serializer->routine($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }
 /**
  * Updates a PerformanceStatistic with the given idand the provided data
  * 
  * @param mixed $id
  * @param mixed $data
  * @return PayloadInterface
  */
 public function update($id, $data)
 {
     // find
     $model = $this->get($id);
     if ($model === null) {
         return new NotFound(['message' => 'PerformanceStatistic not found.']);
     }
     // hydrate
     $serializer = PerformanceStatistic::getSerializer();
     $model = $serializer->hydrate($model, $data);
     // validate
     $validator = $this->getValidator();
     if ($validator !== null && !$validator->validate($model)) {
         return new NotValid(['errors' => $validator->getValidationFailures()]);
     }
     // dispatch
     $event = new PerformanceStatisticEvent($model);
     $dispatcher = $this->getServiceContainer()->getDispatcher();
     $dispatcher->dispatch(PerformanceStatisticEvent::PRE_UPDATE, $event);
     $dispatcher->dispatch(PerformanceStatisticEvent::PRE_SAVE, $event);
     $rows = $model->save();
     $dispatcher->dispatch(PerformanceStatisticEvent::POST_UPDATE, $event);
     $dispatcher->dispatch(PerformanceStatisticEvent::POST_SAVE, $event);
     $payload = ['model' => $model];
     if ($rows === 0) {
         return new NotUpdated($payload);
     }
     return new Updated($payload);
 }
 /**
  * @param Request $request
  * @param Updated $payload
  */
 public function updated(Request $request, Updated $payload)
 {
     $serializer = PerformanceStatistic::getSerializer();
     $relationship = $serializer->events($payload->getModel());
     return new JsonResponse($relationship->toArray());
 }