2014-12-03 7 views
0
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; 
charset=iso-8859-1"> 
    <meta name="GENERATOR" content="Mozilla/4.51 (Macintosh; I; PPC) 
[Netscape]"> 
    <title>Correcting cloze exercise</title> 
<script LANGUAGE="javascript"> 
function Gradeit() 
{ 

function getvalues(){ 

return document.quiz.q1.value 
return document.quiz.q2.value 
return document.quiz.q3.value 
return document.quiz.q4.value 
return document.quiz.q5.value 
return document.quiz.q6.value 
return document.quiz.q7.value 
return document.quiz.q8.value 
return document.quiz.q9.value 
return document.quiz.q10.value 
} 




var Answers=new Array(10) 
Answers[0]="Rawls" 
Answers[1]="Utilitarianism" 
Answers[2]="Deontological" 
Answers[3]="Socialist" 
Answers[4]="Contractual" 
Answers[5]="Veil of Ignorance" 
Answers[6]="Stage 2" 
Answers[7]="Intent based Utilitarianism" 
Answers[8]="Libertarian Justice" 
Answers[9]="Kant" 


var UserAnswers = new Array(10) 
UserAnswers[0] = document.quiz.q1.value 
UserAnswers[1] = document.quiz.q2.value 
UserAnswers[2] = document.quiz.q3.value 
UserAnswers[3] = document.quiz.q4.value 
UserAnswers[4] = document.quiz.q5.value 
UserAnswers[5] = document.quiz.q6.value 
UserAnswers[6] = document.quiz.q7.value 
UserAnswers[7] = document.quiz.q8.value 
UserAnswers[8] = document.quiz.q9.value 
UserAnswers[9] = document.quiz.q10.value 


var count0 = 0 
document.quiz.number_correct.value = 0 


if (Answers[0] == UserAnswers[0]) 
{count0 = count0 + 1, document.quiz.ebox1.value=""} 
else 
{count0 = count0, document.quiz.ebox1.value="X"} 

if (Answers[1] == UserAnswers[1]) 
{count0 = count0 + 1, document.quiz.ebox2.value=" "} 
else 
{count0 = count0, document.quiz.ebox2.value="X"} 

if (Answers[2] == UserAnswers[2]) 
{count0 = count0 + 1, document.quiz.ebox3.value=" "} 
else 
{count0 = count0, document.quiz.ebox3.value="X"} 

if (Answers[3] == UserAnswers[3]) 
{count0 = count0 + 1, document.quiz.ebox4.value=" "} 
else 
{count0 = count0, document.quiz.ebox4.value="X"} 

if (Answers[4] == UserAnswers[4]) 
{count0 = count0 + 1, document.quiz.ebox5.value=" "} 
else 
{count0 = count0, document.quiz.ebox5.value="X"} 

if (Answers[5] == UserAnswers[5]) 
{count0 = count0 + 1, document.quiz.ebox6.value=" "} 
else 
{count0 = count0, document.quiz.ebox6.value="X"} 

if (Answers[6] == UserAnswers[6]) 
{count0 = count0 + 1, document.quiz.ebox7.value=" "} 
else 
{count0 = count0, document.quiz.ebox7.value="X"} 

if (Answers[7] == UserAnswers[7]) 
{count0 = count0 + 1, document.quiz.ebox8.value=" "} 
else 
{count0 = count0, document.quiz.ebox8.value="X"} 

if (Answers[8] == UserAnswers[8]) 
{count0 = count0 + 1, document.quiz.ebox9.value=" "} 
else 
{count0 = count0, document.quiz.ebox9.value="X"} 

if (Answers[9] == UserAnswers[9]) 
{count0 = count0 + 1, document.quiz.ebox10.value=" "} 
else 
{count0 = count0, document.quiz.ebox10.value="X"} 

document.quiz.number_correct.value = count0 


} 

</script> 
</head> 
<body> 

<h1> 
Self-Correcting and Grading Fill-ins</h1> 

<p>Directions.&nbsp; Fill in the blanks in the sentences below with the 
appropriate vocabulary words from the box below.&nbsp; Note there are 
five 
extra words.&nbsp; After filling it in, click the "Grade it" button. The button "Get answer key" opens a new 
window, 
where all the answers are listed. 
<br>&nbsp; 
<center><table COLS=3 WIDTH="75%" > 
<tr> 
<td>Principle of Equal Liberty Rights</td> 

<td>Intent based Utilitarianism</td> 

<td>Capitalist</td> 
</tr> 

<tr> 
<td>Stage 2</td> 

<td>Contractual</td> 

<td>Rawls</td> 
</tr> 

<tr> 
<td>Deontological</td> 

<td>Legal</td> 

<td>Universalizable</td> 
</tr> 

<tr> 
<td>Veil of Ignorance</td> 

<td>Utilitarianism</td> 

<td>Libertarian Justice</td> 
</tr> 

<tr> 
<td>Stage 3</td> 

<td>Kant</td> 

<td>Socialist</td> </tr> 


<td>&nbsp;</td> 
</tr> 
</table></center> 

<p><form NAME="quiz"><input name="ebox1" type="text" size="1"><b>#1: Which writer was a major proponent of the theory of Justice as Fairness?</b><input name="q1" type="text" size="25"> 

<p><input name="ebox2" type="text" size="1"><b>#2: A decision focused on outcome or consequences that emphasizes the greatest good for the greatest number&nbsp;</b><input name="q2" type="text" size="25"> 

<p><input name="ebox3" type="text" size="1"><b>#3: An approach that focuses on “universal ethical principles” 

&nbsp;<input name="q3" type="text" size="25"></b> 

<p><input name="ebox4" type="text" size="1"><b>#4: Which justice is criticised for providing a disincentive to contribute, since we’ll all get the same benefits no matter what (free rider problem)? 
&nbsp;<input 
name="q4" type="text" size="25"></b> 

<p><input name="ebox5" type="text" size="1"><b>#5 Limited rights and duties that arise when individuals enter into agreements with one another. 
<input 
name="q5" type="text" size="25"></b> 

<p><input name="ebox6" type="text" size="1"><b>#6 The point of this is to remove personal bias from the choice of principles. 
    &nbsp;<input name="q6" type="text" size="25"></b> 

<p><input name="ebox7" type="text" size="1"><b>#7 Reason for doing the right thing is to gain rewards (i.e., right actions are “instruments” for satisfying one’s own needs) is which stage of the Moral Cognitive Development Model? 
<input 
name="q7" type="text" size="25"></b> 

<p><input name="ebox8" type="text" size="1"><b>#8 If you genuinely tried your best to maximize utility, you’ve done the right thing, even if it turns out in the end that utility wasn’t maximized is 
&nbsp;<input name="q8" type="text" size="25"></b> 

<p><input name="ebox9" type="text" size="1"><b>#9:The people who have them, earn them, or are freely given them describes which justice? 
<input 
name="q9" type="text" size="25"></b> 

<p><input name="ebox10" type="text" size="1"><b>#10: Reversible, universalizable 
and treating stakeholders as an end unto themselves and does not use them only as a means to an end is part of which theory? 
<input name="q10" type="text" size="25"></b> 

<p><input TYPE="button" VALUE="Grade Me" onClick="Gradeit()"><input 
type="reset" Value="Clear All Answers"><br> 

<b>You got&nbsp;<input name="number_correct" type="text" 
size="4">correct out of 10. Try questions marked with the "X" again, and click the button to have your answers checked again.</b> 
</form> 
</body> enter code here 
</html> 

사용자가 대소 문자를 구분하지 않고 답변하는 것 외에 사용자가 정답 일 때 녹색 눈금 표시를 붙이는 방법에 대한 아이디어가 있습니까? 사용자가 옳은 경우 현재 비어 있습니다. 그래서 나는 올바른 답을 나타내는 녹색 눈금 표시와 잘못된 답을 나타내는 적색 십자가를 나타내는 것을 필요로합니다. 이 방법은 문자가 될 것입니다 때문에 훨씬 쉽게 비교 할 수 있습니다대문자/소문자가 아닌 질문에 사용자가 어떻게 대답하게합니까?

variable.toLowerCase() 

:

답변

1

나는 자바 스크립트 당신은

"string".toLowerCase() 

로 또는 변수의 경우 소문자로 문자열을 변환 할 수 있습니다 모두 소문자. 그게 네가 묻고있는 것이기를 바란다. 문서 개체 모델에서 콘텐츠 추가/제거에 대한 해결 방법을 알고 싶을 때 녹색 체크 표시가 나타납니다. 한 가지 방법은 이미지를 표시 한 다음 이미지의 소스를 대답에 따라 체크 또는 "x"표시로 변경하는 것입니다. 예를 들면 다음과 같습니다.

if(true) { //if the answer is correct 
    document.getElementById('image').src = 'check.png'; 
} else { 
    document.getElementById('image').src = 'wrong.png'; 
} 
+0

어떻게 이것을 내 코드에 통합합니까? – Jason

0

Gwiddle의 답변을 통합하려면 원하는대로 어디에서나 각 대답 옆에 이미지가 있어야합니다. 그러나 처음에 그것을 더 소스를 제공하지 않으며, 그것을 "markbox0"또는 이와 유사한의 ID를 제공해야합니다

<img src="" id="markbox0" alt="mark"> 

사용하여 Gwiddle 같이 이제 코드에서 이미지 laster의 소스를 변경할 수 있습니다 당신이 항목의 긴 목록에 대한 코드의 유사한 세트를 수행하는 경우

document.getElementById('markbox').src = 'check.png'; 

또한, 일반적인 코딩 팁으로, 모든 하나 하나를 작성하는 대신 루프를 사용하는 것이 훨씬 쉽습니다. 이 기능은 페이지에 질문을 추가하고자 할 때 특히 유용합니다. 간단한 'for'루프는 많은 공간과 글을 저장합니다. 여기서 루프 코드가 실행될 때마다 카운트 업하는 변수를 사용하여 긴 목록을 단계별로 실행할 수 있습니다. 이 루프는 'i'를 답 목록에 항목이 횟수를 들면, 수가와 코드를 실행

for (var i = 0; i <= Answers.length; i = i + 1){ 
    if (Answers[i] == UserAnswers[i]) 
     {count0 = count0 + 1; 
     document.getElementById('markbox' + String(i)).src = 'check.png';} 
    else 
     {count0 = count0; 
     document.getElementById('markbox' + String(i)).src = 'cross.png';} 
} 

예를 들어, 코드를 확인 당신의 대답은 달성 할 수있다. i의 값은 0에서 시작하고 루프가 실행될 때마다 1 씩 증가합니다. 처음에는 Answers [0]과 UserAnswers [0]을 비교하고 ID가 'markbox0'인 이미지 소스를 확인한 다음 다시 1 등으로 결정합니다. 당신을 도와줍니다

희망.