コード例 #1
0
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // delete jury
     $this->jury->delete();
     $this->executed();
     // forward
     HeaderUtil::redirect('index.php?page=ContestJury&contestID=' . $this->jury->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
コード例 #2
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     AbstractForm::save();
     // save entry
     $this->entry->update($this->entry->contestID, $this->entry->userID, $this->entry->groupID, $this->state);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestJury&contestID=' . $this->entry->contestID . SID_ARG_2ND_NOT_ENCODED . '#entry' . $this->entry->juryID);
     exit;
 }
コード例 #3
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     AbstractForm::save();
     // save jurytalk
     $this->entry->update($this->message);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestJurytalk&contestID=' . $this->entry->contestID . '&jurytalkID=' . $this->entry->jurytalkID . SID_ARG_2ND_NOT_ENCODED . '#jurytalk' . $this->entry->jurytalkID);
     exit;
 }
コード例 #4
0
 public function testContestPage()
 {
     $user = $this->user;
     $contest = $this->contest;
     // save two jurytalk entries
     require_once WCF_DIR . 'lib/data/contest/jurytalk/ContestJurytalkEditor.class.php';
     $this->deleteArray[] = $jurytalk = ContestJurytalkEditor::create($contestID = $contest->contestID, $jurytalk = __METHOD__ . ' jurytalk #1', $userID = $user->userID, $username = $user->username);
     $this->deleteArray[] = $jurytalk = ContestJurytalkEditor::create($contestID = $contest->contestID, $jurytalk = __METHOD__ . ' jurytalk #2', $userID = $user->userID, $username = $user->username);
     $raised = false;
     try {
         $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     } catch (Exception $e) {
         $raised = true;
     }
     $this->assertTrue($raised, "user should not be allowed to access a private contest");
     // now try with owner
     $this->setCurrentUser($user);
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 2);
     // now try with jury member who was invited
     $this->deleteArray[] = $juryuser = $this->createUser();
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = $contest->contestID, $userID = $juryuser->userID, $groupID = 0, $state = 'invited');
     $this->setCurrentUser($juryuser);
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     // invited members should only see first entry
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 1);
     // accepted members should have 2 entries
     $jury->update($contestID, $userID, $groupID, 'accepted');
     $this->runHTTP('page=ContestJurytalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('jurytalks')), 2);
 }
コード例 #5
0
 /**
  * finish the contest
  */
 public function close()
 {
     if (!($this->contest->state == 'scheduled' && $this->contest->untilTime < time())) {
         throw new Exception('contest needs to be scheduled, and time has to be over.');
     }
     // make a jury instance from the contst owner
     $jury = ContestJury::find($this->contest->contestID, $this->contest->userID, $this->contest->groupID);
     if ($jury === null) {
         $jury = ContestJuryEditor::create($this->contest->contestID, $this->contest->userID, $this->contest->groupID, $state = 'accepted');
     }
     $userID = $this->contest->userID;
     if ($userID == 0 && $this->contest->groupID > 0) {
         $sql = "SELECT          userID\n\t\t\t\tFROM            wcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE           groupID = " . intval($this->contest->groupID);
         $row = WCF::getDB()->getFirstRow($sql);
         $userID = $row['userID'];
     }
     if (!$userID) {
         throw new Exception('cannot determine a user from which the ratings will be added.');
     }
     $classIDs = array_keys($this->contest->getClasses());
     $ratingoptionIDs = array_keys(ContestRatingoption::getByClassIDs($classIDs));
     if (empty($ratingoptionIDs)) {
         throw new Exception('cannot determine a ratingoption from classes [' . implode(',', $classIDs) . '] needed for contest ratings to be added.');
     }
     // get interactions
     $interactionList = new ContestInteractionList($this->contest);
     $interactionList->sqlLimit = 0;
     $interactionList->readObjects();
     $owners = $interactionList->getObjects();
     foreach ($owners as $owner) {
         $this->sum += $owner->c;
     }
     // get prices
     $priceList = new ContestPriceList();
     $priceList->sqlConditions .= 'contest_price.state = "accepted" AND contest_price.contestID = ' . intval($this->contest->contestID);
     $priceList->sqlLimit = 0;
     $priceList->readObjects();
     $score = 5 + $priceList->countObjects();
     foreach ($priceList->getObjects() as $price) {
         // choose a winner
         $owner = $this->chooseWinner($price, $owners);
         // error, there are more prices than participants
         if (!$owner) {
             throw new Exception('there are more prices than participants.');
         }
         $lang = 'wcf.contest.interaction.tickets.solution';
         $message = WCF::getLanguage()->getDynamicVariable($lang, array('tickets' => $owner->c));
         // create pseudo solution
         $solution = ContestSolutionEditor::create($this->contest->contestID, $owner->participantID, $message, $state = 'accepted');
         foreach ($ratingoptionIDs as $ratingOptionID) {
             // create pseudo rating
             $rating = ContestSolutionRatingEditor::create($solution->solutionID, $ratingOptionID, $score, $userID);
         }
         // decrease score
         $score--;
     }
     // close contest state
     $this->contest->getEditor()->updateState('closed');
 }
コード例 #6
0
 /**
  * 
  */
 public function testCreate()
 {
     require_once WCF_DIR . 'lib/data/contest/crew/ContestCrew.class.php';
     // create group
     $this->deleteArray[] = $group = $this->createGroup(array(array('optionID' => ContestCrew::getOptionID(), 'optionValue' => true)));
     $this->deleteArray[] = $user = $this->createUser($group->groupID);
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $contest = ContestEditor::create($userID = $user->userID, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array(), $state = 'applied');
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = 0, $userID = $user->userID, $groupID = 0, $state = 'private');
 }
コード例 #7
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save jury
     $inserts = '';
     foreach ($this->jurys as $jury) {
         $userID = $groupID = 0;
         switch ($jury['type']) {
             case 'user':
                 $userID = intval($jury['id']);
                 break;
             case 'group':
                 $groupID = intval($jury['id']);
                 break;
         }
         ContestJuryEditor::create($this->contest->contestID, $userID, $groupID, 'invited');
     }
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestJury&contestID=' . $this->contest->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
コード例 #8
0
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save jury
     $jury = ContestJuryEditor::create($this->contest->contestID, WCF::getUser()->userID, $this->groupID, $this->state);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestJury&contestID=' . $this->contest->contestID . '&juryID=' . $jury->juryID . SID_ARG_2ND_NOT_ENCODED . '#jury' . $jury->juryID);
     exit;
 }
コード例 #9
0
 public function testReflectionAPI()
 {
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = 0, $userID = 0, $groupID = 0, $state = 'invited');
     $this->callAllMethodsWithoutRequiredParameters($jury);
 }
コード例 #10
0
 /**
  * Saves jurys.
  */
 public function setJurys($jurys = array())
 {
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     foreach ($jurys as $jury) {
         ContestJuryEditor::create($this->contestID, $jury['type'] == 'user' ? intval($jury['id']) : 0, $jury['type'] == 'group' ? intval($jury['id']) : 0, 'invited');
     }
 }