Пример #1
0
 /**
  * Create a new ScoreReport object, given the set of initial attribute values.
  * @param homePoints the points won by the home team (must be non-negative)
  * @param awayPoints the points won by the away team (must be non-negative)
  * @param date the date of the match
  * @param student the Student submitting the match score report
  * @param match the Match for which the score is reported
  * @return Entity\ScoreReportImpl a new ScoreReport object instance with the given attribute values
  * @throws RDException in case any of the po$arguments is negative, either student or match is null, or if the student is not the captain of one of the teams in the match
  */
 public function createScoreReport($homePoints = null, $awayPoints = null, $date = null, $student = null, $match = null)
 {
     $aScoreReport = new Entity\ScoreReportImpl();
     if ($homePoints != null && $awayPoints != null && $date != null && $student != null && $match != null) {
         $aScoreReport->setHomePoints($homePoints);
         $aScoreReport->setAwayPoints($awayPoints);
         $aScoreReport->setDate($date);
         $aScoreReport->setMatch($match);
         $aScoreReport->setStudent($student);
     }
     return $aScoreReport;
 }
Пример #2
0
 /**
  * @param Entity\ScoreReportImpl $report
  * @throws RDException
  */
 public function delete($report)
 {
     if ($report->getId() == -1) {
         //if report isn't persistent, we are done
         return;
     }
     //Prepare mySQL query
     $q = 'DELETE FROM score_report WHERE score_report_id = ?;';
     //create Prepared statement
     $stmt = $this->dbConnection->prepare($q);
     //bind parameter to query
     $reportId = $report->getId();
     $stmt->bindParam(1, $reportId, \PDO::PARAM_INT);
     //execute query
     if ($stmt->execute()) {
         echo 'report deleted successfully';
     } else {
         throw new RDException('Deletion of report unsuccessful');
     }
 }
Пример #3
0
 /**
  * Automatically called from the end of the creation of the second score report of  a match
  *  if the scores in the two ScoreReports are the same, the score in the Match is set to be as
  * reported; otherwise, a message ConflictingScoresReported message
  *
  * @param Entity\ScoreReportImpl $report1
  * @param Entity\ScoreReportImpl $report2
  * @param Entity\MatchImpl $match
  * @throws RDException if the scores conflict. The admin needs to resolve this.
  * @return void
  */
 public function confirmMatchScore($report1, $report2, $match)
 {
     // TODO: figure out how to notify admin of a dispute
     if (!($report2->getHomePoints() == $report1->getAwayPoints() && $report1->getHomePoints() == $report2->getAwayPoints())) {
         throw new RDException($string = "There are discrepancies in the two score reports");
     }
 }