├── .vscode ├── settings.json └── launch.json ├── templates ├── load.gif ├── search-tk.html ├── search.html ├── error.html ├── managecenter.html ├── home.html ├── changepwd.html ├── result.html ├── style.css ├── tkedit.html ├── query.html ├── managetool.html └── testedit.html ├── tkcreate.py ├── .gitignore ├── userinsert.py ├── README.md ├── clangcalc.py ├── LICENSE └── app.py /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.linting.pylintEnabled": true 3 | } -------------------------------------------------------------------------------- /templates/load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CrystalRays/Project-OTS/HEAD/templates/load.gif -------------------------------------------------------------------------------- /templates/search-tk.html: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /tkcreate.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, session,redirect,url_for 2 | from datetime import datetime , date,time,timedelta 3 | import sqlite3 4 | from Crypto.Cipher import AES 5 | from binascii import b2a_hex,a2b_hex 6 | import random 7 | import traceback 8 | import importlib 9 | def encrypt(text,key): 10 | key=key+'\0'*(16-len(key)%16) 11 | cryptor=AES.new(key.encode('utf-8'),AES.MODE_CBC,key.encode('utf-8')) 12 | text=text+'\0'*(16-len(text.encode("utf-8"))%16) 13 | try:return b2a_hex(cryptor.encrypt(text.encode('utf-8'))).decode('utf-8') 14 | except: 15 | traceback.print_exc() 16 | return "ERROR" 17 | def decrypt(text,key): 18 | key=key+'\0'*(16-len(key)%16) 19 | cryptor=AES.new(key.encode('utf-8'),AES.MODE_CBC,key.encode('utf-8')) 20 | try:return cryptor.decrypt(a2b_hex(text.encode('utf-8'))).decode('utf-8').rstrip('\0') 21 | except:return "ERROR" 22 | 23 | base=input("请输入数据库文件名:") 24 | conn=sqlite3.connect(base) 25 | cursor=conn.cursor() 26 | tk=input("请输入题库文件名") 27 | sheet=input("请输入表名") 28 | with open(tk,'r',encoding='gbk') as tkf: 29 | text=tkf.read() 30 | for each in text.split("|||||"): 31 | print(each.find("["),each.find("]")) 32 | a=each[each.find("["):each.find("]")+1] 33 | print(a[a.find("(")+1:a.find(")")]) 34 | print(each.replace(a,"( )")) 35 | try:cursor.execute("insert into "+sheet+" (question,answer,scorecalc) values ('"+each.replace(a,"( )")+"','"+encrypt(a[a.find("(")+1:a.find(")")],"qddedtling")+"','standard')") 36 | except:pass 37 | cursor.execute("commit") 38 | cursor.close() 39 | conn.close() 40 | 41 | 42 | -------------------------------------------------------------------------------- /templates/search.html: -------------------------------------------------------------------------------- 1 | {% for each in data_list %} 2 | 23 | {% endfor %} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # OTS-settings & database 107 | *.db 108 | key 109 | *.txt 110 | *.dv 111 | .vscode 112 | _pycache_ 113 | -------------------------------------------------------------------------------- /userinsert.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, request, render_template, session,redirect,url_for 2 | from datetime import datetime , date,time,timedelta 3 | import sqlite3 4 | from Crypto.Cipher import AES 5 | from binascii import b2a_hex,a2b_hex 6 | import random 7 | import traceback 8 | import importlib 9 | def encrypt(text,key): 10 | key=key+'\0'*(16-len(key)%16) 11 | cryptor=AES.new(key.encode('utf-8'),AES.MODE_CBC,key.encode('utf-8')) 12 | text=text+'\0'*(16-len(text.encode("utf-8"))%16) 13 | try:return b2a_hex(cryptor.encrypt(text.encode('utf-8'))).decode('utf-8') 14 | except: 15 | traceback.print_exc() 16 | return "ERROR" 17 | def decrypt(text,key): 18 | key=key+'\0'*(16-len(key)%16) 19 | cryptor=AES.new(key.encode('utf-8'),AES.MODE_CBC,key.encode('utf-8')) 20 | try:return cryptor.decrypt(a2b_hex(text.encode('utf-8'))).decode('utf-8').rstrip('\0') 21 | except:return "ERROR" 22 | 23 | base=input("请输入数据库文件名:") 24 | conn=sqlite3.connect(base) 25 | cursor=conn.cursor() 26 | tk=input("请输入题库文件名") 27 | sheet=input("请输入表名") 28 | with open(tk,'r',encoding='gbk') as tkf: 29 | text=tkf.read() 30 | for each in text.split("\n"): 31 | print(each) 32 | a=each[0:each.find(" ")] 33 | print("insert into "+sheet+" (username,password,usertype) values ('"+a+"','"+each[each.find(" ")+1:]+"',0)") 34 | try:cursor.execute("insert into "+sheet+" (username,password,usertype) values ('"+a+"','"+encrypt(each[each.find(" ")+1:],"qdded")+"',0)") 35 | except:traceback.print_exc() 36 | try:cursor.execute("select id from userdata where username='"+a+"'") 37 | except:traceback.print_exc() 38 | id=cursor.fetchall() 39 | print("create table user"+str(id[0])+" (id integer primary key,testname text unique,answertime text,submit integer,grade integer)") 40 | try:cursor.execute("create table user"+str(id[0][0])+" (id integer primary key,testname text unique,answertime text,submit integer,grade integer)") 41 | except:traceback.print_exc() 42 | cursor.execute("commit") 43 | cursor.close() 44 | conn.close() 45 | 46 | 47 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File (Integrated Terminal)", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal" 13 | }, 14 | { 15 | "name": "Python: Remote Attach", 16 | "type": "python", 17 | "request": "attach", 18 | "port": 5678, 19 | "host": "localhost", 20 | "pathMappings": [ 21 | { 22 | "localRoot": "${workspaceFolder}", 23 | "remoteRoot": "." 24 | } 25 | ] 26 | }, 27 | { 28 | "name": "Python: Module", 29 | "type": "python", 30 | "request": "launch", 31 | "module": "enter-your-module-name-here", 32 | "console": "integratedTerminal" 33 | }, 34 | { 35 | "name": "Python: Django", 36 | "type": "python", 37 | "request": "launch", 38 | "program": "${workspaceFolder}/manage.py", 39 | "console": "integratedTerminal", 40 | "args": [ 41 | "runserver", 42 | "--noreload", 43 | "--nothreading" 44 | ], 45 | "django": true 46 | }, 47 | { 48 | "name": "Python: Flask", 49 | "type": "python", 50 | "request": "launch", 51 | "module": "flask", 52 | "env": { 53 | "FLASK_APP": "app.py" 54 | }, 55 | "args": [ 56 | "run", 57 | "--no-debugger", 58 | "--no-reload" 59 | ], 60 | "jinja": true 61 | }, 62 | { 63 | "name": "Python: Current File (External Terminal)", 64 | "type": "python", 65 | "request": "launch", 66 | "program": "${file}", 67 | "console": "externalTerminal" 68 | } 69 | ] 70 | } -------------------------------------------------------------------------------- /templates/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
Online Exam System written on Python 3. Your can first try it on ots.icystal.top.
基于Python 3的在线考试系统。你可以先在这里体验这个考试系统。

