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


PHP WC_Challenge::getID方法代码示例

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


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

示例1: onVote

 public function onVote(WC_Challenge $chall)
 {
     if ('0' === ($userid = GWF_Session::getUserID())) {
         return GWF_HTML::err('ERR_LOGIN_REQUIRED');
     }
     if (!WC_ChallSolved::hasSolved($userid, $chall->getID())) {
         return $this->module->error('err_chall_vote');
     }
     $form = $this->getFormVote($chall, false, $userid);
     if (false !== ($error = $form->validate($this->module))) {
         return $error;
     }
     if (false !== ($vs = $chall->getVotesDif())) {
         $vs->onUserVoteSafe($_POST['dif'], $userid);
     }
     if (false !== ($vs = $chall->getVotesEdu())) {
         $vs->onUserVoteSafe($_POST['edu'], $userid);
     }
     if (false !== ($vs = $chall->getVotesFun())) {
         $vs->onUserVoteSafe($_POST['fun'], $userid);
     }
     if (false === WC_ChallSolved::setVoted($userid, $chall->getID(), true)) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->onRecalcVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $this->module->message('msg_chall_voted');
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:29,代码来源:ChallVotes.php

示例2: math_pyramid_check

function math_pyramid_check(WC_Challenge $chall, $formula, $maxlen, $precision = 4)
{
    error_reporting(E_ERROR);
    GWF_Debug::setDieOnError(false);
    GWF_Debug::setMailOnError(false);
    $len = strlen($formula);
    $tests = array('0' => 0, '1' => 0.2357, '3.14' => 7.2971, '10' => 235.7023, '100' => 235702.2604);
    $eval = new EvalMath();
    $fa = "f(a) = {$formula}";
    if (false === $eval->evaluate($fa)) {
        echo GWF_HTML::error('Math Pyramid', $chall->lang('err_formula', array(htmlspecialchars($fa))));
        return false;
    }
    GWF_Debug::setDieOnError(true);
    GWF_Debug::setMailOnError(true);
    $back = GWF_HTML::message('Math Pyramid', $chall->lang('msg_formula', array(htmlspecialchars($fa))), false);
    $correct = 0;
    foreach ($tests as $a => $result) {
        $result2 = $eval->evaluate("f({$a})");
        $result = sprintf('%.0' . $precision . 'f', $result);
        $result2 = sprintf('%.0' . $precision . 'f', $result2);
        if ($result === $result2) {
            $back .= GWF_HTML::message('Math Pyramid', $chall->lang('msg_correct', array($a, $result2, $result)), false);
            $correct++;
        } else {
            $back .= GWF_HTML::error('Math Pyramid', $chall->lang('err_wrong', array($a, $result2, $result)), false);
        }
    }
    require_once GWF_CORE_PATH . 'module/WeChall/WC_MathChall.php';
    if ($chall->getID() > 0 && $correct === count($tests)) {
        if (false === WC_MathChall::insertSolution($chall->getID(), GWF_Session::getUserID(), $formula)) {
            $back .= GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
        } else {
            $back .= GWF_HTML::message('Math Pyramid', WC_HTML::lang('msg_wmc_sol_inserted', array($len, WC_MathChall::getLimitedHREF($chall, $len))), false);
        }
    }
    # Check Len
    if ($len > $maxlen) {
        $back .= GWF_HTML::error('Math Pyramid', $chall->lang('err_too_long', array($len, $maxlen)), false);
    }
    echo $back;
    if ($correct === count($tests) && $len <= $maxlen) {
        if ($len < $maxlen) {
            echo GWF_HTML::message('Math Pyramid', $chall->lang('msg_new_record', array($len, $maxlen)), false);
            GWF_Settings::setSetting('WC_MATH_PYRAMID', $len);
        }
        $chall->onChallengeSolved(GWF_Session::getUserID());
    }
}
开发者ID:sinfocol,项目名称:gwf3,代码行数:49,代码来源:index.php

示例3: templateSolutions

 private function templateSolutions(WC_Challenge $chall, GWF_User $user, $length, $token)
 {
     $tt = $this->module->lang('pt_wmc_sol', array($chall->display('chall_title'), $length));
     GWF_Website::setPageTitle($tt);
     $ipp = 50;
     $cid = $chall->getID();
     $length = (int) $length;
     $whitelist = array('user_name', 'wmc_date', 'wmc_length', 'wmc_solution');
     $by = GDO::getWhitelistedByS(Common::getGetString('by'), $whitelist, self::DEFAULT_BY);
     $dir = GDO::getWhitelistedDirS(Common::getGetString('dir'), self::DEFAULT_DIR);
     $wmc = GWF_TABLE_PREFIX . 'wc_math_chall';
     $users = GWF_TABLE_PREFIX . 'user';
     $where = "wmc_cid={$cid} AND wmc_length>={$length}";
     $db = gdo_db();
     $result = $db->queryFirst("SELECT COUNT(*) c FROM {$wmc} WHERE {$where}");
     $nRows = (int) $result['c'];
     $nPages = GWF_PageMenu::getPagecount($ipp, $nRows);
     $page = Common::clamp(Common::getGetInt('page', 1), 1, $nPages);
     $from = GWF_PageMenu::getFrom($page, $ipp);
     $limit = GDO::getLimit($ipp, $from);
     $query = "SELECT user_name, wmc_date, wmc_length, wmc_solution FROM {$wmc} LEFT JOIN {$users} ON user_id=wmc_uid WHERE {$where} ORDER BY {$by} {$dir} {$limit}";
     $tVars = array('sort_url' => GWF_WEB_ROOT . "index.php?mo=WeChall&me=MathSolutions&cid={$cid}&length={$length}&token={$token}&by=%BY%&dir=%DIR%", 'data' => $db->queryAll($query), 'page_menu' => GWF_PageMenu::display($page, $nPages, GWF_WEB_ROOT . sprintf('index.php?mo=WeChall&me=MathSolutions&cid=%d&length=%d&token=%s&by=%s&dir=%s&page=%%PAGE%%', $cid, $length, $token, urlencode($by), urlencode($dir))), 'table_title' => $tt, 'chall' => $chall);
     return $this->module->templatePHP('math_solutions.php', $tVars);
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:24,代码来源:MathSolutions.php

示例4: onReset

 private function onReset(WC_Challenge $chall)
 {
     require_once GWF_CORE_PATH . 'module/WeChall/WC_ChallSolved.php';
     # Remove solved
     $cid = $chall->getID();
     $solved = GDO::table('WC_ChallSolved');
     if (false === $solved->update("csolve_date='', csolve_options=0", "csolve_cid={$cid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $solved->affectedRows();
     $back = GWF_HTML::message('WeChall', "Reset {$affected} players that have solved it.");
     # Remove from users from groups
     $gid = $chall->getGID();
     $usergroup = GDO::table('GWF_UserGroup');
     if (false === $usergroup->deleteWhere("ug_groupid={$gid}")) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $affected = $usergroup->affectedRows();
     $back .= GWF_HTML::message('WeChall', "Removed {$affected} players from the challenge group.");
     # Reset votes
     Module_WeChall::includeVotes();
     if (false === $chall->getVotesDif()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesEdu()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->getVotesFun()->resetVotesSameSettings()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     if (false === $chall->onRecalcVotes()) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     # reset solve count and various vars
     if (false === $chall->saveVars(array('chall_solvecount' => 0, 'chall_views' => 0, 'chall_date' => GWF_Time::getDate(GWF_Date::LEN_SECOND)))) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     return $back;
 }
开发者ID:sinfocol,项目名称:gwf3,代码行数:39,代码来源:ChallEdit.php


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