Gull Rock reading check: source, four questions and passage-based feedback

HTML for this example

Select the code and use your copy shortcut. Changes in this preview are temporary.

<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; script-src 'unsafe-inline'; form-action 'none'; base-uri 'none'"><title>Gull Rock reading check</title><style>*{box-sizing:border-box}body{margin:0;background:white;color:#263340;font:16px/1.5 Arial,sans-serif}main{max-width:950px;margin:auto;padding:22px}h1{font-size:26px;line-height:1.25;margin:7px 0 12px}h2{font-size:19px;margin:20px 0 10px}h3{font-size:17px;margin:12px 0 8px}p{margin:0 0 12px}ol,ul{padding-left:23px}li{margin:6px 0}.note{font-size:13px;color:#4d5c68}.controls{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0}button{font:inherit;color:#263340;background:white;border:1px solid #70818e;min-height:44px;padding:8px 12px;cursor:pointer}button[aria-pressed=true]{color:white;background:#344f71}button:disabled{opacity:.55;cursor:default}button:focus-visible,summary:focus-visible{outline:3px solid #a34b25;outline-offset:3px}pre{font:14px/1.5 Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere;min-width:0;background:#f0f3f6;padding:14px;margin:8px 0}table{border-collapse:collapse;width:100%;table-layout:fixed}caption{text-align:left;font-weight:bold;padding-bottom:8px}th,td{padding:9px 7px;border-bottom:1px solid #b7c1ca;text-align:left;vertical-align:top;overflow-wrap:anywhere}th{font-size:14px;background:#f0f3f6}td .label{display:none}footer{margin-top:22px;padding-top:13px;border-top:1px solid #b7c1ca}[hidden]{display:none!important}@media(max-width:560px){main{padding:16px}h1{font-size:24px}caption{display:block;width:100%}thead{display:none}table,tbody,tr,td{display:block;width:100%}tr{padding:10px 0;border-bottom:1px solid #b7c1ca}td{border:0;padding:3px 0}td .label{display:inline;font-weight:bold}}.source{border-left:3px solid #536977;background:#f3f6f8;padding:12px 14px}.source p{font-size:16px;margin:0 0 7px}.source p:last-child{margin:0}.line{font-weight:bold;font-size:12px;color:#536977}#question{margin:18px 0 10px}#options{display:grid;gap:8px}#options button{text-align:left;width:100%}#feedback{border-left:3px solid #a34b25;padding:10px 12px;background:#fff6ec;margin-top:14px}#progress{font-weight:bold;margin:12px 0}#options button[aria-pressed=true]{background:#344f71;color:white}</style></head><body><main><p class="note">Original fictional story · local practice · no AI service,student identity or saved answers</p><h1>Gull Rock: read and check</h1><div class="source" aria-label="Source passage"><p><span class="line">P1</span> Rae, the fictional Gull Rock keeper, checked the lantern every sunset. The supply boat normally arrived on Tuesday.</p><p><span class="line">P2</span> On Monday, a storm damaged the pier. Rae sent a note asking the boat to wait until Thursday.</p><p><span class="line">P3</span> The reserve oil would last until Friday. Rae used it for the lantern while carpenters repaired the pier.</p><p><span class="line">P4</span> On Thursday, the boat arrived with fresh oil. Rae stored the new supply and lit the lantern that evening.</p></div><p id="progress" role="status"></p><h2 id="question"></h2><div id="options" aria-labelledby="question"></div><p id="feedback" role="status"></p><div class="controls"><button id="previous">Previous question</button><button id="next">Next question</button><button id="reset">Try again</button></div><footer>Use the paragraph evidence to review an answer. Choices change only this open page; nothing is submitted.</footer></main><script>const questions=[{"text":"On which day did the boat normally arrive?","options":["Monday","Tuesday","Thursday","Friday"],"correct":1,"evidence":"P1 says the supply boat normally arrived on Tuesday. Thursday is the delayed arrival, not the normal schedule."},{"text":"Why did Rae ask the boat to wait?","options":["The fresh oil had already arrived.","The reserve oil was empty.","The lantern was no longer needed.","The storm damaged the pier."],"correct":3,"evidence":"P2 describes the damaged pier immediately before Rae asks the boat to wait."},{"text":"How did Rae keep the lantern supplied before Thursday?","options":["Used the reserve oil.","Borrowed oil from the boat on Tuesday.","Stopped lighting the lantern.","Waited for fresh oil on Friday."],"correct":0,"evidence":"P3 says Rae used the reserve oil while the pier was repaired."},{"text":"What does “reserve” mean in paragraph 3?","options":["Oil already delivered on Thursday.","Oil that cannot be used.","A supply kept for later use.","A different name for the pier."],"correct":2,"evidence":"P3 describes oil available while delivery is delayed, and P4 brings a fresh supply. Reserve means a supply kept for later use."}];let current=0;const chosen=Array(questions.length).fill(null),options=document.getElementById('options'),feedback=document.getElementById('feedback'),progress=document.getElementById('progress');function status(){const count=chosen.filter(x=>x!==null).length;progress.textContent=count+' of '+questions.length+' answered'+(count===questions.length?' · Score: '+chosen.reduce((s,x,i)=>s+Number(x===questions[i].correct),0)+' / '+questions.length:' · Final score appears after every question has an answer.');}function show(focus=false){document.getElementById('question').textContent=(current+1)+'. '+questions[current].text;options.replaceChildren();questions[current].options.forEach((text,i)=>{const b=document.createElement('button');b.type='button';b.dataset.choice=i;b.textContent=String.fromCharCode(65+i)+'. '+text;b.setAttribute('aria-pressed',String(chosen[current]===i));b.addEventListener('click',()=>{chosen[current]=i;options.querySelectorAll('button').forEach(x=>x.setAttribute('aria-pressed',String(Number(x.dataset.choice)===i)));feedback.textContent=(i===questions[current].correct?'Correct. ':'Not quite. ')+questions[current].evidence;status();});options.append(b);});feedback.textContent=chosen[current]===null?'Choose an answer to see passage evidence.':(chosen[current]===questions[current].correct?'Correct. ':'Not quite. ')+questions[current].evidence;document.getElementById('previous').disabled=current===0;document.getElementById('next').disabled=current===questions.length-1;status();if(focus)options.querySelector('button').focus();}document.getElementById('previous').addEventListener('click',()=>{if(current>0){current--;show(true);}});document.getElementById('next').addEventListener('click',()=>{if(current<questions.length-1){current++;show(true);}});document.getElementById('reset').addEventListener('click',()=>{chosen.fill(null);current=0;show(true);});show();</script></body></html>