当前位置: 首页>>代码示例>>PHP>>正文


PHP WC_Challenge::getMaxScore方法代码示例

本文整理汇总了PHP中WC_Challenge::getMaxScore方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Challenge::getMaxScore方法的具体用法?PHP WC_Challenge::getMaxScore怎么用?PHP WC_Challenge::getMaxScore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WC_Challenge的用法示例。


在下文中一共展示了WC_Challenge::getMaxScore方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onEdit

 private function onEdit(WC_Challenge $chall)
 {
     $form = $this->getForm($chall);
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     $msgs = '';
     $wc = WC_Site::getWeChall();
     # Solution
     $is_case_i = isset($_POST['case_i']);
     if ('' !== ($solution = Common::getPostString('solution', ''))) {
         if (false === $chall->saveVar('chall_solution', $chall->hashSolution($solution, $is_case_i))) {
             $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     # CASE_I
     $case_i = WC_Challenge::CHALL_CASE_I;
     if ($chall->isOptionEnabled($case_i) !== $is_case_i) {
         if (false === $chall->saveOption($case_i, $is_case_i)) {
             $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     # Save score
     $new_score = $form->getVar('score');
     $old_score = $chall->getVar('chall_score');
     if ($new_score !== $old_score) {
         if (!WC_Challenge::isValidScore($new_score)) {
             $msgs .= $this->module->error('err_chall_score', array($new_score, WC_Challenge::MIN_SCORE, WC_Challenge::MAX_SCORE));
         }
         if (false === $chall->saveVar('chall_score', $new_score)) {
             $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if (false === $wc->saveVar('site_maxscore', WC_Challenge::getMaxScore())) {
             $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         $wc->recalcSite();
     }
     # URL+Title (dangerous)
     if (false === $chall->saveVars(array('chall_url' => $form->getVar('url'), 'chall_title' => $form->getVar('title')))) {
         $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # Creator:
     if (false === $chall->updateCreators($form->getVar('creators'))) {
         $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # Tags:
     if (false === $chall->saveVar('chall_tags', trim($form->getVar('tags'), ' ,'))) {
         $msgs .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     Module_WeChall::instance()->cacheChallTags();
     # Done
     return $msgs . $this->module->message('msg_chall_edited');
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:53,代码来源:ChallEdit.php

示例2: outputScore

 private function outputScore($username)
 {
     if (false === ($user = GWF_User::getByName($username))) {
         die('Unknown User');
     }
     if (false === ($site = WC_Site::getWeChall())) {
         die('Unknown Site');
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_RegAt.php';
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $score = WC_Challenge::getScoreForUser($user);
     $maxscore = WC_Challenge::getMaxScore();
     $challs_solved = WC_ChallSolved::getChallsSolvedForUser($user);
     $challcount = WC_Challenge::getChallCount();
     $usercount = GDO::table('GWF_User')->countRows();
     $rank = WC_RegAt::calcExactRank($user);
     die(sprintf('%d:%s:%s:%s:%s:%s', $rank, $score, $maxscore, $challs_solved, $challcount, $usercount));
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:18,代码来源:CrossSite.php

示例3: wechallChalls

 /**
  * Wechall internally bot response.
  * The advantage over the other method is accurate challcount.
  * @param string $input
  * @return string
  */
 public function wechallChalls($input)
 {
     if ($input === '') {
         return sprintf('Try wechallchalls.php?userame=blub');
     }
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     $wechall = WC_Site::getWeChall();
     $siteid = $wechall->getID();
     if (false !== ($user = GWF_User::getByName($input))) {
         if ($user->isOptionEnabled(0x10000000)) {
             die('This user is not ranked!');
         }
         $rank = WC_RegAt::calcExactSiteRank($user, $siteid);
     } elseif (false !== ($user = WC_RegAt::getUserBySiteRank($siteid, $input))) {
         $rank = intval($input);
     } else {
         return sprintf('The user does not exist.');
     }
     //		if (false !== ($error = $this->module->isExcludedFromAPI($user))) {
     //			return $error;
     //		}
     $userid = $user->getID();
     $username = $user->displayUsername();
     $solvedCount = WC_ChallSolved::getSolvedCount($userid);
     $score = WC_Challenge::getScoreForUser($user);
     $challcount = WC_Challenge::getChallCount();
     $maxScore = WC_Challenge::getMaxScore();
     $percent = $score / $maxScore * 100;
     $out = sprintf('%s solved %d of %d Challenges with %d of %d possible points (%.02f%%).', $username, $solvedCount, $challcount, $score, $maxScore, $percent);
     if ($rank !== false) {
         $out .= sprintf(' Rank for the site WeChall: %d', $rank);
     }
     return $out;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:40,代码来源:API_Bot.php


注:本文中的WC_Challenge::getMaxScore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。