🏠 Home 

TikN学习通教师模式试卷导出工具

将学习通教师模式试卷导出为TikN可识别的格式。


安装此脚本?
  1. // ==UserScript==
  2. // @name TikN学习通教师模式试卷导出工具
  3. // @namespace http://blmm.top/
  4. // @version 0.1.0
  5. // @description 将学习通教师模式试卷导出为TikN可识别的格式。
  6. // @author Fairytale_Store
  7. // @match https://mooc2-ans.chaoxing.com/mooc2-ans/exam/lookpaper*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11. (function() {
  12. 'use strict';
  13. // 定义一个函数来导出题目
  14. function exportQuestions() {
  15. var questions = $('.stem_con');
  16. var output = '';
  17. questions.each(function(index) {
  18. var questionText = $(this).find('p').text().trim();
  19. var options = $(this).next('.stem_answer').find('.num_option, .answer_p');
  20. // 寻找紧接在当前题目的下一个.answerDiv作为答案部分
  21. var nextAnswerDiv = $(this).nextUntil('.stem_con').filter('.answerDiv');
  22. var answer = nextAnswerDiv.find('.answer_tit p').text().trim();
  23. output += (index + 1) + '. ' + questionText + '\r\n';
  24. options.each(function(optionIndex) {
  25. if (optionIndex % 2 === 0) { // 选项字母
  26. var letter = $(this).text().trim();
  27. output += letter + ' ';
  28. } else { // 选项文本
  29. output += $(this).text().trim() + '\r\n';
  30. }
  31. });
  32. output += '#' + answer + '#\r\n';
  33. });
  34. saveStringToFile("<TikS><本试卷使用TikN学习通导出工具V1.0自动生成>" + output,"导出习题.tik")
  35. }
  36. function saveStringToFile(str, filename) {
  37. var blob = new Blob([str], {type: "text/plain;charset=utf-8"});
  38. var link = document.createElement('a');
  39. link.href = window.URL.createObjectURL(blob);
  40. link.download = filename;
  41. link.click();
  42. }
  43. // 当页面加载完成时执行导出函数
  44. $(document).ready(exportQuestions);
  45. })();