SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>试卷生成器</title>
    <script>
        function addQuestion() {
            let question = prompt("请输入题目:");
            if (!question) return;

            let options = [];
            for (let i = 0; i < 3; i++) {
                let option = prompt(`请输入选项 ${String.fromCharCode(66 + i)}:`);
                options.push(option ? option : "");
            }

            let storedQuestions = JSON.parse(localStorage.getItem("questions")) || [];
            storedQuestions.push({ question, options });
            localStorage.setItem("questions", JSON.stringify(storedQuestions));

            alert("题目已添加!");
        }

function generateExam() {
    let storedQuestions = JSON.parse(localStorage.getItem("questions")) || [];
    if (storedQuestions.length < 10) {
        alert("题目不足 10 道,请先添加更多题目!");
        return;
    }

    let examContent = `
        <html>
        <head>
            <title>试卷</title>
            <style>
                @media print {
                    #printButton {
                        display: none;
                    }
                }
            </style>
        </head>
        <body>
            <h2>试卷</h2>
            <ol>
    `;

    for (let i = 0; i < 10; i++) {
        let q = storedQuestions[i];
        examContent += `<li>${q.question}<br>B. ${q.options[0]}<br>C. ${q.options[1]}<br>D. ${q.options[2]}</li>`;
    }

    examContent += `
            </ol>
            <button id="printButton" onclick="window.print()">打印试卷</button>
        </body>
        </html>
    `;

    let examWindow = window.open("", "_blank");
    examWindow.document.write(examContent);
    examWindow.document.close();
}

    </script>
</head>
<body>
    <h1>试卷生成器</h1>
    <button onclick="addQuestion()">输入题目</button>
    <button onclick="generateExam()">生成试卷</button>
</body>
<style>
    @media print {
        button {
            display: none;
        }
    }
</style>
</html>