
Related
Read Next
September 20, 2023
คนที่น่าอิจฉาที่สุด คือคนที่ไม่อิจฉาใครเลย
September 4, 2022
เราเป็นคนใจแคบหรือใจกว้าง
April 13, 2022
ภาพไม่มีวันนี้ไม่ได้สร้างภาพ
January 16, 2022
ครูคือเรือจ้าง
December 23, 2021
ชีวิตไม่ได้สร้างมาพอดีเหมือนจิ๊กซอว์
December 17, 2021
ไม่ต้องรวยก็มีความสุข ไม่จำเป็นต้องผูกความสุขไว้กับความรวย
December 5, 2021
ทักษะความรู้สามารถถ่ายทอดให้แก่กัน แต่จินตนาการเป็นเรื่องของแต่ละบุคคล
December 5, 2021
ผู้มีปัญญาจะไม่เย่อหยิ่ง ของจริงนั้นเป็นใบ้
April 17, 2021
อย่าไปสนใจว่าเดินมาถึงไหนแล้ว
จงสนใจว่าเดินไปในทิศทางขึ้นหรือทิศทางลง
มีแต่ความเ…
March 17, 2021
ความรู้และความรัก ความรู้ไม่จำเป็นต้องแสดงว่ามีมาก
Back to top button
const wpLabels = {
num: ["①", "②", "③", "④", "⑤"],
eng: ["A", "B", "C", "D", "E"],
thai: ["ก", "ข", "ค", "ง", "จ"]
};
function wpRenderKeys() {
const totalQEl = document.getElementById('wp-total-q');
const choiceTypeEl = document.getElementById('wp-choice-type');
const numChoicesEl = document.getElementById('wp-num-choices');
const answerKeyContainer = document.getElementById('wp-answer-key-inputs');
if (!totalQEl || !answerKeyContainer) return;
const totalQ = parseInt(totalQEl.value);
const choiceType = choiceTypeEl.value;
const numChoices = parseInt(numChoicesEl.value);
const labels = wpLabels[choiceType];
let html = "";
for (let i = 1; i <= totalQ; i++) {
html += `ข้อ ${i}:
`;
}
answerKeyContainer.innerHTML = html;
}
function wpRenderGrids() {
const gridContainer = document.getElementById('wp-grids');
if (!gridContainer) return;
let makeGrid = (title, cols) => {
let h = `${title}
`;
for(let col=1; col<=cols; col++) {
h += `
0`;
for(let d=0; d<=9; d++) {
h += `${d}`;
}
h += `
`;
}
return h + `
`;
};
gridContainer.innerHTML = makeGrid('เลขที่', 2) + makeGrid('รหัส 5 หลัก', 5) + makeGrid('รหัสวิชา', 3);
}
function wpGenerate(type) {
const school = document.getElementById('wp-school').value || "โรงเรียน Authain Academy";
const teacher = document.getElementById('wp-teacher').value || "-";
const subject = document.getElementById('wp-subject').value || "-";
const className = document.getElementById('wp-class').value || "-";
const term = document.getElementById('wp-term').value;
const year = document.getElementById('wp-year').value || "2569";
const totalQ = parseInt(document.getElementById('wp-total-q').value);
const choiceType = document.getElementById('wp-choice-type').value;
const numChoices = parseInt(document.getElementById('wp-num-choices').value);
const labels = wpLabels[choiceType];
document.getElementById('wp-prev-title').innerText = type === 'key' ? "🔑 กระดาษเฉลยคำตอบ (Answer Key)" : "📄 กระดาษคำตอบนักเรียน";
document.getElementById('wp-prev-info').innerHTML = `โรงเรียน: ${school} | วิชา: ${subject} | ชั้น: ${className} | ภาคเรียนที่ ${term}/${year} | ครูผู้สอน: ${teacher}`;
let html = "";
for (let i = 1; i <= totalQ; i++) {
let correctAns = 0;
if (type === 'key') {
const el = document.getElementById(`wp-k-${i}`);
if (el) correctAns = parseInt(el.value);
}
html += `
ข้อ ${i}
`;
for (let c = 1; c <= numChoices; c++) {
let isSelected = (type === 'key' && correctAns === c);
let bgColor = isSelected ? '#000000' : '#ffffff';
let textColor = isSelected ? '#ffffff' : '#444444';
let displayText = isSelected ? '●' : labels[c-1];
html += `${displayText}`;
}
html += `
`;
}
document.getElementById('wp-bubbles').innerHTML = html;
const area = document.querySelector('.print-area');
area.style.display = "block";
window.scrollTo({ top: area.offsetTop, behavior: 'smooth' });
}
// โหลดข้อมูลเริ่มต้นเมื่อเปิดหน้าเว็บ
window.addEventListener('DOMContentLoaded', () => {
wpRenderKeys();
wpRenderGrids();
});