- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为客户将静态 HTML 站点转换为 WordPress。在他们现有的网站上,他们有这个测验 http://www.virginiauranium.com/quiz .我已将所有内容从他们的原始站点复制到 WordPress 安装,但是正如您在回答问题时所看到的那样,在问题 2 之后它会让您回到第一个问题 http://www.virginiauranium.com/wp/quiz/
我完全被这个难住了,希望这里有人能给我一些指导。我将包括所有相关代码。
模板:
<?php
require_once( ABSPATH . 'wp-content/themes/virginiauranium/includes/quiz.questions.php');
$question = $questions[$currQuestion-1];
?>
<div id="body" class="quiz">
<h1>Uranium 101 <em>Would you pass? Take the quiz!</em></h1>
<hr />
<div class="quiz_header">
<?php if($currQuestion == sizeof($questions)) { ?>
<h4>Final Score: <?=$numCorrect?> out of <?=sizeof($questions)-1?></h4>
<?php } else { ?>
<h4>Question <?=$currQuestion?> of <?=sizeof($questions)-1?></h4>
<a href="http://www.virginiauranium.com/wp/quiz" class="quiz_next">Next</a>
<?php } ?>
</div>
<div class="quiz_body">
<?php if($question['image'] != "") { ?>
<p class="alignright<?=(($currQuestion == 7) ? " nomargin" : "")?>">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/quiz/<?=$question['image']?>" alt="" /><br />
<span class="caption"><?=$question['caption']?></span>
</p>
<?php } ?>
<div class="question"><?=$question['question']?></div>
<?php if($currQuestion < sizeof($questions)) { ?>
<div class="quiz_buttons">
<a href="javascript:void(0);" class="quiz_button_true">True</a>
<a href="javascript:void(0);" class="quiz_button_false">False</a>
</div>
<div class="answer">
<p><strong><?=ucfirst($question['shortanswer'])?>.</strong></p>
<p><?=$question['answer']?></p>
<span class="hide"><?=$question['shortanswer']?></span>
</div>
<?php } ?>
</div>
<input type="hidden" name="currentQuestion" value="<?=$currQuestion?>">
</div>
</div><!-- #main .wrapper -->
<footer id="colophon" role="contentinfo">
<div class="site-info">
<p>Virginia Uranium, Inc., P.O. Box 399, 231 Woodlawn Heights, Chatham, VA 24531 USA. Tel: 434.432.1065 Copyright © <?php echo the_date('Y'); ?> Virginia Uranium, Inc. All rights reserved.</p>
</div><!-- .site-info -->
</footer><!-- #colophon -->
</div><!-- #page -->
<?php wp_reset_query(); ?>
<?php wp_footer(); ?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery.cycle.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/sitenew.js"></script>
</body>
</html>
测验问题.php
<?php
$questions = array(
array(
"question" => "Uranium is a common element which occurs in the soil of most backyards, most rocks, and seawater.",
"answer" => "Uranium is found nearly everywhere in small concentrations. Although used primarily as fuel for nuclear power plants, uranium is also used for weights in airplanes, military armor, and various advanced medical procedures and treatments.",
"shortanswer" => "true",
"image" => "Q1---core-samples.jpg",
"caption" => "Ore samples from Coles Hill"
), array(
"question" => "It is standard practice to install waste-water treatment plants at uranium mines and mills today.",
"answer" => "If Virginia Uranium’s enterprise moves forward, the company will build a wastewater treatment plant at the mine/mill site. Water used in the mill process will be recycled and re-used in the mill process. Any water used or collected on site will be cleaned to standards set by the Environmental Protection Agency before it is released on site. The treatment plant will be capable of cleaning water to E.P.A. drinking-water standards.",
"shortanswer" => "true",
"image" => "Q2---Ranger2005.jpg",
"caption" => "Key Lake uranium facility, Canada"
), array(
"question" => "Tailings are a radioactive waste product from mining.",
"answer" => 'Actually, "tailings" is the term for the crushed rock that remains once the uranium has been removed from the ore in the milling process. The uranium is separated out by a heated sodium bicarbonate leach (basically soda water). The ore at Coles Hill is unique from other uranium ores from the Western U.S or Canada in that it does NOT contain significant quantities of heavy metals or sulfides, which could be of environmental concern. Yes, there is some radioactivity, but is it important to note that the tailings are less radioactive than the naturally occurring rock in the ore deposit. Industry best practices recommend the addition of a binding agent to the tailings so that they will harden back into solid rock once they are placed into a below-grade tailings containment structure. The addition of a binding agent and the placement below grade remove any risk that the tailings could be swept away in a flood or hurricane and affect water quality.',
"shortanswer" => "true",
"image" => "Q3---tailings-pic.jpg",
"caption" => "Tailings management facilities at JEB mine, Canada"
), array(
"question" => "A mining operation at Coles Hill would pollute the air for miles.",
"answer" => "Water is used in the mining and milling process to keep down the dispersion of dust. Moreover, Virginia Uranium’s plan to build an underground mine would eliminate dust emissions outside of the Coles Hill property, and tailings, the crushed rock from which the uranium is removed, are stored as a heavy liquid slurry under water. They are not susceptible to wind dispersion. While radon gas is associated with uranium, improved ventilation practices have minimized worker exposure to radon gas over the past forty years. In fact, according to Canadian regulators, many uranium miners in Saskatchewan, Canada, receive more radon exposure in their homes than in the mines.",
"shortanswer" => "false",
"image" => "Q4---air-quality.jpg",
"caption" => ""
), array(
"question" => "Radiation from uranium mines and mills has not increased the cancer rates of communities living near mines and mills.",
"answer" => "Highly-respected studies confirm that cancer rates of communities living in the vicinity of uranium mining operations are no higher than those of the general population. Dr. John Boice, an epidemiologist from Vanderbilt University’s School of Medicine, studied four populations who lived near uranium mines in the western United States for decades and found no increased rates of cancer.",
"shortanswer" => "true",
"image" => "Q4---Gartempe-River-2.jpg",
"caption" => ""
), array(
"question" => "The drastic changes in the spot-market price of uranium will subject Virginia Uranium to boom-and-bust cycles.",
"answer" => "Most uranium is sold under long-term price contracts between mining companies and utilities such as Dominion Power. Contracts lasting up to twenty years are conceivable. Only about 25% of global uranium mine production is sold on the spot market, because it is in the best interest of utilities to ensure a stable supply of uranium to power their reactors. Long-term supply contracts benefit uranium mining companies by ensuring a stable uranium selling price for long periods of time.",
"shortanswer" => "false",
"image" => "Q6---surry-reactors.jpg",
"caption" => "Nuclear reactors at Surry Power Station, Virginia"
), array(
"question" => "Virginia Uranium could draw all the water it would need to operate a uranium mine and mill at Coles Hill from its site.",
"answer" => "Virginia Uranium would require approximately 300,000 gallons of water per day, all of which would come from the 3,500-acre Coles Hill site. That sounds like a lot of water, but it is slightly less than the Town of Chatham, a nearby town of 1,200 residents, uses. It is far less than other industrial operations in the area have used; for example, Dan River Mills’ textile plant in Danville used 8.2 million gallons of water per day.",
"shortanswer" => "true",
"image" => "Q7---water-graphic.jpg",
"caption" => ""
), array(
"question" => "Yellowcake, the commodity a mining company like Virginia Uranium would produce, is dangerous in the hands of terrorists.",
"answer" => "Yellowcake is harmless in the hands of terrorists. This natural uranium produced at uranium mines and mills must go through the three major processing steps of conversion, enrichment, and fuel rod fabrication before it can even be used in the nuclear reactors that power our world. Commercial-grade uranium fuel for reactors is usually enriched up to 3.5-5% uranium-235.",
"shortanswer" => "false",
"image" => "Q8---yellowcake.jpg",
"caption" => "Barrel of yellowcake"
), array(
"question" => "The uranium that mining companies produce is a very hazardous and explosive material.",
"answer" => "Yellowcake, the form of natural uranium produced in the mining and milling process, is not flammable and cannot explode. It is far safer to transport than common fuels like gas and propane. Like lead, it is only harmful if ingested in significant quantities.",
"shortanswer" => "false",
"image" => "Q9---gas-truck.jpg",
"caption" => "Gas is explosive. Uranium is far safer for transport"
), array(
"question" => "If Virginia’s legislature lifts the moratorium on uranium mining, mines will open up all over the state.",
"answer" => "Uranium, a common element, exists in virtually any rock and in seawater in very small concentrations, but companies do not extract uranium from seawater. The process required to do so is far more expensive than the price of uranium, which means that it is not currently possible to profit from such means of uranium production. Likewise, uranium occurs in Virginia outside of Coles Hill, but, as the National Academy of Sciences has written, it is not worth mining at prevailing prices.",
"shortanswer" => "false",
"image" => "Q10---state-capitol.jpg",
"caption" => ""
), array(
"question" => "Strict federal regulations govern the disposals of tailings, the byproduct of uranium mining. Under federal regulations, tailings management facilities must be designed to last for 1,000 years and withstand severe weather events, including hurricanes and floods.",
"answer" => "The Nuclear Regulatory Commission, the federal agency regulating uranium mills and tailings disposal, has designated below-grade disposal as the prime option for tailings disposal. Tailings disposal cells must have impermeable liners. They cannot be located in areas at all prone to flooding. In fact, current industry best practices recommend that tailings be returned to the same geologic structure which held the uranium ore for millions of years prior to mining.",
"shortanswer" => "true",
"image" => "Q11---Puy-de-L'Ages,-Now-a-Trout-Fishing-Lake,-June-2009.jpg",
"caption" => "Former open pit mine at Puy de L’Ages, France, now a trout fishing pond"
), array(
"question" => "Pittsylvania County and Virginia taxpayers will be expected to pay for mine reclamation and monitoring when the mine closes.",
"answer" => "The Nuclear Regulatory Commission requires uranium mill operators to post surety bonds to cover reclamation and long-term monitoring costs. Operations cannot begin before these bonds are posted, and the amount of the bonds is determined by the NRC during the permitting process and reviewed annually. For example, Pinion Ridge Mill in Colorado is required to post $11 million in bonds and Homestake Grants in New Mexico $33 million.",
"shortanswer" => "false",
"image" => "Q12---elliotlakepic.jpg",
"caption" => "Elliot Lake, Canada, the former “Uranium Capital of the World.”"
), array(
"question" => "<p>So, would you have passed Uranium 101? If not, don’t fear. You may find plenty of general information about uranium and the mining industry in our <a href='http://www.virginiauranium.com/reference-library/'>Reference Library</a>, and you’ll be able to learn more about Virginia Uranium and our plans <a href='http://www.virginiauranium.com/who-we-are/'>here</a>.</p>
<p><a href='http://www.virginiauranium.com/contact/'>Click here</a> to tell us a little about yourself and send us any questions you may have about Virginia Uranium and our plans.</p>"
)
);
function isNumeric($num="") {
if(is_numeric($num) && $num = round($num) && $num >= 0)
return true;
return false;
}
/* sets default question and score, then checks the session to see if one is already set */
$currQuestion = 1;
$numCorrect = 0;
if(isset($_SESSION['uQuiz_Question']) && isNumeric($_SESSION['uQuiz_Question']) && $_SESSION['uQuiz_Question'] > 0 && $_SESSION['uQuiz_Question'] <= sizeof($questions))
$currQuestion = intval($_SESSION['uQuiz_Question']);
if(isset($_SESSION['uQuiz_Score']) && isNumeric($_SESSION['uQuiz_Score']) && $_SESSION['uQuiz_Score'] >= 0 && $_SESSION['uQuiz_Score'] < sizeof($questions))
$numCorrect = intval($_SESSION['uQuiz_Score']);
/* if user has answered, test answer and alter score, go to next question */
if(isset($_GET['val']) && isNumeric($_GET['val'])) {
$testVal = "";
if(intval(($currQuestion."tru"), 36) == $_GET['val'])
$testVal = "true";
else if(intval(($currQuestion."fal"), 36) == $_GET['val'])
$testVal = "false";
if($testVal != "") {
if($questions[$currQuestion]['shortanswer'] == $testVal)
$numCorrect++;
$currQuestion++;
}
}
/*
if on last page of quiz, delete the session so the next visit will start the quiz again
otherwise just store the updated info in the session
*/
if($currQuestion == sizeof($questions)) {
unset($_SESSION['uQuiz_Question']);
unset($_SESSION['uQuiz_Score']);
} else {
$_SESSION['uQuiz_Question'] = $currQuestion;
$_SESSION['uQuiz_Score'] = $numCorrect;
}
?>
网站新.js
jQuery(document).ready(function() {
jQuery(".quiz_button_true,.quiz_button_false")
.click(function() {
var $sibling = jQuery(this).siblings();
var $answer = jQuery(this).parent().siblings(".answer");
var correct = false;
if(!jQuery(this).hasClass("active") && !$sibling.hasClass("active")) {
jQuery(this).addClass("active");
$sibling
.addClass("inactive")
.animate({ "opacity": .4 }, 300)
.end();
if(($answer.find(".hide").html() == "true" && jQuery(this).hasClass("quiz_button_true")) || ($answer.find(".hide").html() == "false" && jQuery(this).hasClass("quiz_button_false")))
correct = true;
$answer.each(function() {
if(!correct)
jQuery(this).find("strong").css("color", "#af0000");
jQuery(this)
.css({ "opacity": 0, "display": "block" })
.animate({ "opacity": 1 }, 300)
.end();
});
var currQ = jQuery("#body").find("input[name='currentQuestion']").val();
jQuery(".quiz_next")
.attr("href", ("?val=" + intval(currQ + ((jQuery(this).hasClass("quiz_button_true")) ? "tru" : "fal"), 36)))
.addClass("active")
.end();
}
})
.end();
jQuery(".quiz_next")
.click(function(e) {
if(jQuery(this).hasClass("active"))
window.location.href = jQuery(this).attr("href");
return false;
e.preventDefault();
})
.end();
});
function intval(mixed_var, base) {
var tmp;
var type = typeof(mixed_var);
if(type === 'boolean')
return +mixed_var;
else if(type === 'string') {
tmp = parseInt(mixed_var, base || 10);
return (isNaN(tmp) || !isFinite(tmp)) ? 0 : tmp;
} else if(type === 'number' && isFinite(mixed_var))
return mixed_var | 0;
return 0;
}
我真的希望这里有人能够帮助我度过难关。我不想编写一个全新的测验。
最佳答案
声明 session_start()! :)
xxo
关于php - 让 Javascript True/False 测验在 WordPress 网站上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13424576/
我有这个网站,这个特定页面是安全的,但是当它回发时,它回发到一个不安全的页面。如何解决? 我正在使用 ASP.NET 向导。我有这个页面 - checkout.aspx,页面包含这个控件 checko
我有 2 个 azure 网站 - 两个独立的项目 我现在有 2 个网址: myazurewebsite.azurewebsites.net myazureblog.azurewebsites.net
我有 2 个 azure 网站 - 两个独立的项目 我现在有 2 个网址: myazurewebsite.azurewebsites.net myazureblog.azurewebsites.net
环境: 旧网站: React 托管在 Heroku URL( http://sameurl.com ) 新网站: Java 托管在 Heroku URL ( http://sameurl.com )
我已在 Windows Azure 上注册了一个测试帐户来对其进行测试。我构建了一个 Hello world ASP.NET Web 应用程序 + 数据库只是为了测试。 我安装了 Visual Stu
我有一个可以收集和显示各种测量值的产品(不会详细介绍)。正如人们所期望的那样,显示部分是一个数据库+建立在其之上的网站(使用 Symfony)。 但是,我们可能还会创建一个 API 来向第三方公开数据
这个问题在这里已经有了答案: Software keyboard resizes background image on Android (16 个答案) 关闭 8 年前。 我有一个类似的问题:So
这个问题似乎很常见,但我真的无法根据现有答案解决问题。 我有一个简单的 maven 项目,没有任何复杂的部署配置等,并且想在点击“mvn site”时生成一个 Maven CheckStyle 报告。
有没有人看过有关何时进行横向扩展与纵向扩展的最佳选择的任何分析或信息。什么时候一个比另一个更有意义。 目前,在标准模式和基本模式下,2 个小型实例的费用与 1 个中型实例的费用相同。 拥有 2 个小型
有没有办法找到 azure 网站何时停止? (我通过门户网站停止了网站,但我不记得是什么时候......) 我正在寻找一些日志,但没有找到任何有用的内容。 谢谢。 最佳答案 您拥有的最接近的是 azu
我目前在 Azure VM 的 IIS 中拥有一个网站。我已将该站点复制到 2 个可用区域中的 2 个虚拟机上。 这可以保护网站免遭停机。 我需要为高负载时刻实现一些可扩展性。这似乎就是创建音阶集的目
我有一个托管在 Azure 上的网站 ( http://mike-ward.azurewebsites.net/ )。我从 Azure 门户设置了一个指向(引用?)我的网站的 Azure CDN。根据
我有一个 Azure 网站(不是 Web 角色),有 2 个槽:生产和暂存。 我只想为生产插槽启用 CDN,而不是为登台启用,问题是我找不到识别主机插槽的方法。 RoleEnvironment 不可用
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提出有关书籍、工具、软件库等建议的问题。您可以编辑问题,以便可以用事实和引用来回答它。 4年前关
我们正在考虑将一些网站从 Azure 云服务迁移到 Azure 网站(事情似乎就是这样进行的)。显然,我们被明确告知云服务不会保留文件系统状态,因为它们会在机器故障时重新部署。 我假设网站是基于 Bl
我有一个 Azure 网站,需要使用在 VM 上运行的 Elasticsearch 服务。 虽然我需要能够锁定对 Elasticsearch 的访问,以便只有 Azure 网站可以访问它,但我似乎无法
我有一个 azure 网站,位于 yis3.azurewebsites.net - 我已将其提升为“共享”网站,以便我可以使用自定义域。我拥有从 123-reg.co.uk 购买的域名 yorkshi
我正在使用 abcPDF 动态创建 PDF。 我想保存这些 PDF,以便客户随时检索。最简单的方法(也是我现在在当前服务器上所做的方法)是将完成的 PDF 保存到文件系统。 看来我一直坚持使用 blo
我们正在尝试了解 Windows Azure 管理 API 为 Azure 网站(而非 Webroles)返回的监控数据的复杂性 例如,下图描述了为 CPUTime 检索的数据点。它似乎表明,在晚上
看起来真的很愚蠢,因为我找不到它: 门户网站似乎不太直观,我如何为一个“网站”付费并在其中运行最多 500 个网站?我想当我通过单击左下角的加号添加“网站”时,我添加了整个虚拟机而不是子站点。如何仅添
我是一名优秀的程序员,十分优秀!