GithubHelp home page GithubHelp logo

judgegirl / judgenode Goto Github PK

View Code? Open in Web Editor NEW
56.0 8.0 16.0 55.76 MB

Small Online Judge frontend, based on Nodejs, Express4, MySQL

Home Page: http://judgegirl.csie.ntu.edu.tw/

License: GNU General Public License v3.0

JavaScript 67.86% CSS 8.84% HTML 23.19% Python 0.07% Makefile 0.01% CoffeeScript 0.02% Shell 0.02%

judgenode's Introduction

Judge Node

安裝

  1. 安裝 Nodejs & MySQL apt-get install nodejs mysql-server
  2. 下載這一份 repository git clone https://github.com/JudgeGirl/JudgeNode
  3. 複製設定檔案,並且產生 https 需要的相關文件
$ cp _DEFAULTconfig.yml _config.yml
$ openssl genrsa -out privatekey.pem 1024
$ openssl req -new -key privatekey.pem -out certrequest.csr
$ openssl x509 -req -in certrequest.csr -signkey privatekey.pem -out certificate.pem
  1. 確定 Judge 的目錄如下所示:
root@ubuntu:/home/judgesister# tree -L 1
.
├── JudgeNode (可以放置別處)
├── Judge-sender (一定要與 source, submission, testdata 位置相當)
├── Judge-template (提供範例,可不用下載)
├── source
├── submission
└── testdata
  1. 如果不手動建立,可以參考以下的做法建立
$ mkdir /home/judgesister/source
$ mkdir /home/judgesister/submission
$ mkdir /home/judgesister/testdata
$ cp -r /home/judgesister/Judge-template/default/source/* /home/judgesister/source/
  1. 安裝 JudgeNode 相關套件
$ cd JudgeNode
$ npm install
$ bower install
$ gulp build
  1. 測試用的啟動模式 npm start / 公開用的啟動模式 ./start

關於設定檔

_config.yml 中,預設檔案配置如下:

# order is important, don't change or alternate, otherwise please change all testdata/xxx/judge
# lang: ['*', 'C', 'C++', 'C# 3.0', 'Python 3', 'Scala 2']
# compiler: [, 'g++ -std=c++98 -O2', 'mcs -langversion:3', 'python3', 'scalac -optimise'],
# WT: 0, CE: 1, OLE: 2, MLE: 3, RE: 4, TLE: 5, WA: 6, AC: 7, SAVING: 8, PE: -1,
JUDGE:
    path: 'c:/Users/morris821028/Desktop/github/'
    lang: ['*', 'C']
    compiler_arg: ['none', 'gcc -std=c99 -O2']
    result_message: ['Waiting', 'Compilation Error', 'Output Limit Exceeded', 'Memory Limit Exceeded', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted', 'Uploading...', 'Presentation Error']

# JUDGE_PATH/submission /testdata /source
# JUDGE_PATH: /home/c2014/judgesister/

# MODE: limits user open previous source code & submit problem which not in contest.
CONTEST:
    MODE: false
    SUBMIT_LIMIT: 15
    VALID_IP: ["::ffff:140.112.16.155", "::ffff:140.112.16.156", "::ffff:140.112.16.158", "::1", "::ffff:127.0.0.1"]

# DATABASE Setting, MySQL
DATABASE:
    host: '140.112.xxx.xxx'
    user: 'xxxxxxxxxxxxxxx'
    password: 'xxxxxxxxxxx'
    port: '3306'
    database: 'xxxxxxxxxxxxx'

# WEBSITE API HOST
HOST:
    TITLE: 'Judge Girl'
    IP: 'localhost'
    testdata: 'https://github.com/JudgeGirl/JG-testdata/blob/master/practice/'
    social:
        youtube: 'https://www.youtube.com/playlist?list=PLOvZ8aEg7xDkpKHk3hAwQxLAlpZ1Q3wKH'
        github: 'https://github.com/pangfengliu/programmingtasks/issues'
        facebook: 'https://www.facebook.com/%E6%89%B9%E6%94%B9%E5%A8%98%E7%B2%89%E7%B5%B2%E5%9C%98-257246016760/timeline/'
        googlesite: 'https://sites.google.com/site/ntucsiec2015/announcement'
    footer:
        text: 'TA 曹又霖、顏志軒、林蔚城、陳威甯'
        license: 'Instructor <a title="劉邦鋒" href="/">Pangfeng Liu</a>, Web designer <a title="許祐程" href="/">Akira</a>, <a title="王盛平" href="/">Peer4321</a>, <a title="曹又霖" href="https://github.com/sinmaplewing">Maplewing</a>, <a title="楊翔雲" href="https://github.com/morris821028">Morris</a>'
# Disqus
Disqus:
    shortname: 'ntucsiecprogramming'

公開用的啟動模式

網站可能會因為某些 Bug 而掛掉,若需要不斷地重新開啟,執行目錄下的 ./start 可以每隔 10 秒嘗試重新啟動,如果要強制關閉,請按 CTRL + C 終止網站啟動。在這種模式下,Debug 工作會變得非常困難。

$ ./start
  • 如果 CTRL + C 沒有反應,按照下面步驟。
$ root@ubuntu:/home/judgesister/JudgeNode# ps aux | grep start
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      5671  0.0  0.0   4448   780 pts/3    S+   Feb20   0:00 /bin/sh ./start <<<<Judge-sender
root     19296  0.0  0.0  27236  8028 pts/4    S+   12:04   0:00 python3 ./start <<<<JudgeNode
$ kill -9 <JudgeNode-PID>

judgenode's People

Contributors

jaidtw avatar morris821028 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

judgenode's Issues

考試規則客製化

對於每一場考試說明,提供預設內容和可以更改的 markdown 類型,有如 problem description 得更動頁面。

Submission widget

由於加入重測按鈕,總共有三個地方會顯示 submission,problem/status, problem/mystatus, user/status,為了往後更改,需要加入統一的模組參數。

Submission number

List the number of times the student has submitted a solution to a task.

AC code made public to other ACer.

One can see other's AC code when he gets AC. I think a better implementation is to give the student the following option. If he allows other ACer to see his AC code, the he can see others' AC code when he gets AC.

預設上傳檔案個數限制

router.post('/submit', 
    upload.fields([{name: 'code0', maxCount: 1}, {name: 'code1', maxCount: 1},
                   {name: 'code2', maxCount: 1}, {name: 'code3', maxCount: 1},
                   {name: 'code4', maxCount: 1}, {name: 'code5', maxCount: 1},
                   {name: 'code6', maxCount: 1}, {name: 'code7', maxCount: 1}]), 

回報訊息:不知道是不是上傳的source檔案數量有限制,剛剛有個題目 10 個 source 一上傳就 JudgeNode 就 crash

目標在下一次工作日研究一下 multer 給的 API,並完成檔案傳輸個數與大小上傳限制的測試。

yaml setting & .gitignore

建造 _config.yml 檔案,使用 YAML format 方便處理預設內容,而不直接去更動 source code。

# JUDGE_PATH/submission /testdata /source
# JUDGE_PATH: c:/Users/morris821028/Desktop/github/
JUDGE_PATH: /home/c2014/judgesister/

# MODE: limits user open previous source code & submit problem which not in contest.
CONTEST:
    MODE: true
    SUBMIT_LIMIT: 15

# DATABASE Setting, MySQL
DATABASE:
    host: '140.112.xxx.xxxx'
    user: 'c2015'
    password: 'xxxxxxxxxx'
    port: '3306'
    dbname: 'c2015'

加入 .gitignore 把 log 檔案移除。

Use https and mulitdomain with letsencrypt

https://github.com/letsencrypt/letsencrypt

./letsencrypt-auto certonly --standalone --email [email protected] -d judgegirl.csie.org
./letsencrypt-auto certonly --standalone --email [email protected] -d judgegirl.csie.ntu.edu.tw

change ./bin/www

/*
  https
*/
var crypto = require('crypto');
var https = require('https'),
    fs = require("fs");

function getSecureContext(domain) {
    return crypto.createCredentials({
        key:  fs.readFileSync('/etc/letsencrypt/live/'+ domain + '/privkey.pem'),
        cert:  fs.readFileSync('/etc/letsencrypt/live/' + domain + '/cert.pem')
      }).context;
}

var secureContext = {
    'judgegirl.csie.org': getSecureContext('judgegirl.csie.org'),
    'judgegirl.csie.ntu.edu.tw': getSecureContext('judgegirl.csie.ntu.edu.tw')
};

var options = {
    SNICallback: function(domain) {
        return secureContext[domain];
    },
    port: 443,
    path: '/140.112.31.208',
    method: 'GET',
    key: fs.readFileSync('/etc/letsencrypt/live/judgegirl.csie.org/privkey.pem'),
    cert: fs.readFileSync('/etc/letsencrypt/live/judgegirl.csie.org/cert.pem')
};

Nginx: build JudgeNode (virtual host)

/etc/nginx/sites-available 下建立 judgegirl 的資訊,目前將 Nodejs 開在 port 4000。host domain name 為 apponline.tw,預期使用 judgegirl.apponline.tw 連入。

root@tts:/etc/nginx/sites-available# cat judgegirl
upstream nodejs {
        server 127.0.0.1:4000 max_fails=0;
}

server {
        listen 80;
        server_name judgegirl.apponline.tw;


      location / {
        proxy_pass  http://127.0.0.1:4000;
      }
   }

複製一份連結到 /etc/nginx/sites-available 目錄下

$ cd /etc/nginx/sites-enabled
$ ln -s /etc/nginx/sites-available/judgegirl .

測試 nginx 設定檔案是否可行

$ sudo nginx -t

如果測試成功,直接重開 nginx 服務

$ service nginx restart

之後再測試 https port 443 的情況。

批改考卷設計 - 選擇題提交

由鑒於 NTU 系統目前沒提供選擇題考卷,下學期平行程式設計的小考考卷批改!

若在電腦教室上課,目標加入電腦閱卷功能。

第一班 第二班

Could we use 週一班,週二班? It will be much easier to understand.

為何在題目下方的留言會自動加上="">?

為何在題目下方的留言會自動加上="">?我在題目留言之後發現留言後方被自動加上了="">這串符號
如圖
送出前
image
送出後
image
想請問會這樣設計的原因是什麼?是不是為了要防止SQL injection ?

Distributed Judge configuration

需要更好的 Judge 排程,區分成 rejudge 和 livejudge,

  • livejudge 最新上傳應該按照時間優先測試。
  • rejudge 針對題目重新測試,應在 idle 下進行重測,並不影響 livejudge。

SSL Certificate - Failed to load resource: net::ERR_INSECURE_RESPONSE

主要原因為 Chrome 只為某個 domain name 進行合法憑證,假設現在對 judgegirl.csie.org 網站進行信任,在尚未對實際主機 IP 140.112.31.208 進行信任,在 judgegirl.csie.org 中使用 ajax 訪問 https://140.112.31.208 則會發生錯誤。

修改方式預計在 express 中介層,加入設定參數 req.hostname,針對不同使用者從不同 domain name 進入網站而做不同渲染工作。
http://expressjs.com/en/api.html#req.hostname

User 介面的最近上傳連結錯誤

http://xxx.xxx.xxx.xxx/user/1,點選上傳紀錄會跳轉到 http://xxx.xxx.xxx.xxx/user/1/detail/xxxxx,正確顯示應為 http://xxx.xxx.xxx.xxx/detail/xxxxx

Ubuntu 16.04 Update Problems: MySQL, Redis Server

Redis Server

You may got the error message when you start with redis server. Please check the port 6379 usage first, and then check redis setting in host OS.

https://bugs.launchpad.net/ubuntu/+source/redis/+bug/1663911

    $ sudo su
    $ mkdir /etc/systemd/system/redis-server.service.d/
    $ cd /etc/systemd/system/redis-server.service.d/
    $ echo '[Service]' > redis.override.conf
    $ echo 'PrivateDevices=no' >> redis.override.conf

MySQL grouping

Please degrade your MySQL version into 5.6. There are some SQL query sentences written by me as web beginner. If you don't want to change MySQL server, remove group feature from MySQL configuration.

https://stackoverflow.com/questions/23921117/disable-only-full-group-by

https://blog.csdn.net/helloxiaozhe/article/details/78570016

https://blog.csdn.net/u283056051/article/details/52463948

建議修改

$ chmod +x deploy_mySQL.sh
$ ./deploy_mysql.sh
大小寫

$ python distribute_setup.py
未更新

root $ cd Judge-receiver/scripts
沒s

$ bower install
$ gulp build
以上皆須先NPM INSTALL BOWER,GULP

$ ./start
先安裝colorama by pip3
pip3 install colorama

$ node adduser.js nodejs judgegirl notpassword 0 [email protected]
參數有錯 nodejs adduser.js $1 $2 $3 $4
motto nname ename 沒有default值
須自行加入adduser.js

root $ cd Judge-receiver/scripts
root $ ./mount
./mount,每一次主機重新開啟 (例如斷電重開職主機後),要重新執行這條指令

URL 網址前綴設計

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://judgegirl.github.io/
root: /

用來與其他網站伺服器架構結合,提供轉跳用途。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.