项目经历-手写调查文档生成代码(小功能)

手写调查文档生成代码项目经历
/**
 * ClassName:ExamHtmlGenerator
 * Description:
 *
 * @Author:独酌
 * @Create:2025/3/30 10:40
 */
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ExamHtmlGenerator {

    // 选择题类
    static class ChoiceQuestion {
        String question;
        Integer score;
        List<String> options;

        private ChoiceQuestion(String question, List<String> options ,Integer score) {
            this.question = question;
            this.options = options;
            this.score = score;
        }
    }

    // 填空题类
    static class FillQuestion {
        String question;
        Integer score;

        private FillQuestion(String question ,Integer score) {
            this.question = question;
            this.score = score;
        }
    }

    // 简答题类
    static class ShortQuestion {
        String question;
        Integer score;

        private ShortQuestion(String question ,Integer score) {
            this.question = question;
            this.score = score;
        }
    }

    // 编程题类
    static class programmingQuestion {
        String question;
        Integer score;

        private programmingQuestion(String question ,Integer score) {
            this.question = question;
            this.score = score;
        }
    }

    public static String generateExamHtml(List<ChoiceQuestion> choiceQuestions, List<FillQuestion> fillQuestions, List<ShortQuestion> shortQuestions, List<programmingQuestion> programmingQuestions) {
        StringBuilder html = new StringBuilder();
        html.append("<!DOCTYPE html>\n");
        html.append("<html lang=\"zh-CN\">\n");
        html.append("<head>\n");
        html.append("    <meta charset=\"UTF-8\">\n");
        html.append("    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n");
        html.append("    <title>考核答题</title>\n");
        html.append("    <!-- 引入 MathJax 库 -->\n");
        html.append("    <script id=\"MathJax-script\" async src=\"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js\"></script>\n");
        html.append("    <style>\n");
        html.append("        body {\n" +
                "            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;\n" +
                "            background-color: #f4f4f9;\n" +
                "            display: flex;\n" +
                "            justify-content: center;\n" +
                "            align-items: center;\n" +
                "            min-height: 100vh;\n" +
                "            margin: 0;\n" +
                "        }\n" +
                "\n" +
                "        .exam-container {\n" +
                "            background-color: #fff;\n" +
                "            border-radius: 10px;\n" +
                "            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);\n" +
                "            padding: 40px;\n" +
                "            width: 90%;\n" +
                "            max-width: 800px;\n" +
                "        }\n" +
                "\n" +
                "        h1 {\n" +
                "            text-align: center;\n" +
                "            color: #333;\n" +
                "            margin-bottom: 30px;\n" +
                "        }\n" +
                "\n" +
                "        h2 {\n" +
                "            color: #555;\n" +
                "            margin-top: 30px;\n" +
                "            margin-bottom: 15px;\n" +
                "        }\n" +
                "\n" +
                "        .question {\n" +
                "            margin-bottom: 20px;\n" +
                "            border-bottom: 1px solid #eee;\n" +
                "            padding-bottom: 20px;\n" +
                "        }\n" +
                "\n" +
                "        .question p {\n" +
                "            font-weight: bold;\n" +
                "            color: #444;\n" +
                "        }\n" +
                "\n" +
                "        input[type=\"radio\"],\n" +
                "        input[type=\"text\"],\n" +
                "        textarea {\n" +
                "            margin-top: 5px;\n" +
                "            margin-
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值