Created
September 16, 2019 06:06
-
-
Save ynishi2014/ddc010207265ec1f3833c6bd8a8f53cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script | |
src="https://code.jquery.com/jquery-3.2.1.slim.min.js" | |
integrity="sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=" | |
crossorigin="anonymous"></script> | |
</head> | |
<body> | |
<h1>情報セキュリティマネジメント試験 平成29年秋</h1> | |
<p>問題文は別途配布します。</p> | |
<div id="container"> | |
<div id="template"> | |
<div style="width:50px;float:left">問{i}</div> | |
<div style="width:200px;float:left"> | |
<label><input type="radio" name="q{iii}" value="ア">ア</label> | |
<label><input type="radio" name="q{iii}" value="イ">イ</label> | |
<label><input type="radio" name="q{iii}" value="ウ">ウ</label> | |
<label><input type="radio" name="q{iii}" value="エ">エ</label> | |
<input type="hidden" name="q{iii}_result"> | |
</div> | |
<br clear=all> | |
</div> | |
</div> | |
<input type="hidden" id="scoreInput" name="__score__" value="0"> | |
<input type="hidden" id="lessonStatus" name="__lesson_status__" value="incomplete"> | |
<input type="button" value="提出" style="width:200px" onclick="submit()" id="submit"> | |
</body> | |
<script> | |
data = | |
"ウイアウエエウエイウ" + | |
"アアアイイイアウウエ" + | |
"アイエウイウエウエエ" + | |
"ウエエエアアイウウア" + | |
"イウウウエエエウイア" | |
function submit(){ | |
var correctCount = 0; | |
for(i = 0; i < data.length; i++){ | |
if($("[name=q"+i2iii(i+1)+"]:checked").val() == data[i]){ | |
correctCount++; | |
$("[name=q"+i2iii(i+1)+"_result]").val("correct") | |
}else{ | |
$("[name=q"+i2iii(i+1)+"_result]").val("wrong") | |
} | |
} | |
var score = Math.round(100 * correctCount / data.length); | |
if(score >= 60){ | |
$("#lessonStatus").val('passed') | |
}else{ | |
$("#lessonStatus").val('failed') | |
} | |
$("#scoreInput").val(String(score)); | |
} | |
function i2iii(i){ | |
if(i > 99){ | |
return "" + i; | |
}else if(i > 9){ | |
return "0" + i; | |
}else{ | |
return "00" + i; | |
} | |
} | |
var template = $("#template").prop("outerHTML"), i; | |
$("#template").remove(); | |
for(i = 0; i < data.length; i++){ | |
var templateCopy = template | |
templateCopy = templateCopy.replace(/{iii}/g, i2iii(i + 1)) | |
templateCopy = templateCopy.replace(/{i}/g, i + 1) | |
templateCopy = templateCopy.replace(/{answer}/g, data[i]) | |
$("#container").append(templateCopy); | |
} | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment