- 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/
好的,所以我想从批处理文件运行我的整个工作环境... 我想要实现什么...... 打开新的 powershell,打开我的 API 文件夹并从该文件夹运行 VS Code 编辑器(cd c:\xy;
我正在查看 Cocoa Controls 上的示例并下载了一些演示。我遇到的问题是一些例子,比如 BCTabBarController ,不会在我的设备上构建或启动。当我打开项目时,它看起来很正常,没
我刚刚开始学习 C 语言(擅长 Java 和 Python)。 当编写 C 程序(例如 hello world)时,我在 ubuntu cmd 行上使用 gcc hello.c -o hello 编译
我在 php 脚本从 cron 开始运行到超时后注意到了这个问题,但是当它从命令行手动运行时这不是问题。 (对于 CLI,PHP 默认的 max_execution_time 是 0) 所以我尝试运行
我可以使用命令行运行测试 > ./node_modules/.bin/wdio wdio.conf.js 但是如果我尝试从 IntelliJ 的运行/调试配置运行它,我会遇到各种不同的错误。 Fea
Error occurred during initialization of VM. Could not reserve enough space for object heap. Error: C
将 Anaconda 安装到 C:\ 后,我无法打开 jupyter 笔记本。无论是在带有 jupyter notebook 的 Anaconda Prompt 中还是在导航器中。我就是无法让它工作。
我遇到一个问题,如果我双击我的脚本 (.py),或者使用 IDLE 打开它,它将正确编译并运行。但是,如果我尝试在 Windows 命令行中运行脚本,请使用 C:\> "C:\Software_Dev
情况 我正在使用 mysql 数据库。查询从 phpmyadmin 和 postman 运行 但是当我从 android 发送请求时(它返回零行) 我已经记录了从 android 发送的电子邮件是正确
所以这个有点奇怪 - 为什么从 Java 运行 .exe 文件会给出不同的输出而不是直接运行 .exe。 当 java 在下面的行执行时,它会调用我构建的可与 3CX 电话系统配合使用的 .exe 文
这行代码 Environment.Is64BitProcess 当我的应用单独运行时评估为真。 但是当它在我的 Visual Studio 单元测试中运行时,相同的表达式的计算结果为 false。 我
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我写了一个使用 libpq 连接到 PostgreSQL 数据库的演示。 我尝试通过包含将 C 文件连接到 PostgreSQL #include 在我将路径添加到系统变量 I:\Program F
如何从 Jenkins 运行 Android 模拟器来运行我的测试?当我在 Execiute Windows bath 命令中写入时,运行模拟器的命令: emulator -avd Tester 然后
我已经配置好东西,这样我就可以使用 ssl 登录和访问在 nginx 上运行的 errbit 我的问题是我不知道如何设置我的 Rails 应用程序的 errbit.rb 以便我可以运行测试 nginx
我编写了 flutter 应用程序,我通过 xcode 打开了 ios 部分并且应用程序正在运行,但是当我通过 flutter build ios 通过 vscode 运行应用程序时,我得到了这个错误
我有一个简短的 python 脚本,它使用日志记录模块和 configparser 模块。我在Win7下使用PyCharm 2.7.1和Python 3.3。 当我使用 PyCharm 运行我的脚本时
我在这里遇到了一些难题。 我的开发箱是 64 位的,windows 7。我所有的项目都编译为“任何 CPU”。该项目引用了 64 位版本的第 3 方软件 当我运行不使用任何 Web 引用的单元测试时,
当我注意到以下问题时,我正在做一些 C++ 练习。给定的代码将不会在 Visual Studio 2013 或 Qt Creator 5.4.1 中运行/编译 报错: invalid types 'd
假设我有一个 easteregg.py 文件: from airflow import DAG from dateutil import parser from datetime import tim
我是一名优秀的程序员,十分优秀!