cphelper

A API which will return Course of specific Dept. and also Course which you can enroll at that time.


Keywords
coursepickinghelper, timetable, campass, api, django, pymongo
License
GPL-3.0
Install
pip install cphelper==2.1

Documentation

課程資料查詢API (API of Course code of Dept. and Time of Course)

此API可以直接查詢系所的課程代碼課程的上課時間

API usage and Results

API使用方式(下面所寫的是api的URL pattern)
(Usage of API (pattern written below is URL pattern)):

  1. /cphelper/get/CourseOfDept/?dept=<>&school=<>&grade=<Optional>
    取得系所的課程代碼
    (Get Course code of Dept Name.):

Grade參數用來指定年級,如果不加則是回傳所有年級的必選修:

  • 全年級:/cphelper/get/CourseOfDept/?dept=多媒&school=NSYSU

    • Result:
    {
      "obligatory": {
        "一1": [
          "D16149",
          "D16150",
          "D16148",
          "D16152",
          "D16151",
          "D16143",
          "D18798",
          "D16146",
          "D16147",
          "D16142",
          "D16144",
          "D16145"
        ],
        "四1": [
          "D16182",
          "D16180",
          "D16181"
        ]
      },
      "optional": {
        "二1": [
          "D16154",
          "D16155",
          "D16156",
          "D16158"
        ]
      }
    }
    
  • 指定年級:/cphelper/get/CourseOfDept/?dept=多媒&school=NSYSU&grade=三1

    • result:
    {
      "obligatory": {
        "三1": [
          "D16176",
          "D16173",
          "D16174",
          "D16175"
        ]
      },
      "optional": {
        "三1": [
          "D16164",
          "D16166",
          "D16169",
          "D16170",
          "D16168"
        ]
      }
    }
    
  1. /cphelper/get/CourseOfTime/?day=<星期幾>&time=<第幾節課>&school=<學校名稱>&dept=<系所,可以是複數>
    查詢該時段有什麼課可以上:
  • 範例 (Example):cphelper/get/CourseOfTime/?day=1&time=5&school=NSYSU&dept=通識類+多媒
    代表是要查詢通識類和多媒該時段的課程

  • dept :如果要使用複數的時候,請記得用 + 把參數隔開

  • result:

    ["1159", "2217", "3432", "3434", "3445", "3447", "3448", "3449", "3450", "3451", "3452", "3453", "3456", "3457", "3458", "3459", "3460", "3461"]
    
  1. /cphelper/get/Genra/?school=<學校名稱>
    該學校所有的系所和年級:
  • 範例 (Example):/cphelper/get/Genra/?school=NSYSU

  • result:

    {
      "其他類": {
        "語言": [
          "一1",
          "二1",
          "二2"
        ]
      },
      "通識類": {
        "通識": [
          "二2",
          "二1",
          "二5",
          "二3",
          "二4",
          "三B"
        ]
      },
      "體育類": {
        "體育": [
          "二2",
          "二1",
          "二3",
          "二4",
          "三A",
          "三1",
          "四丁",
          "四丙",
          "四己"
        ]
      },
      "大學部": {
        "應中": [
          "一1",
          "二1",
          "三1",
          "四1"
        ],
        "休閒": [
          "一1",
          "二1",
          "三1",
          "四1"
        ],
        "美容系技優班": [
          "一1"
        ],
        "資應菁英班": [
          "一甲",
          "二甲",
          "三A",
          "三甲",
          "四A",
          "四甲",
          "五甲"
        ]
        ...
        ...
        ...
      }
    }
    

Running & Testing

Run

  1. 插入mongodb以及django資料庫的範例指令:
    • 首先需要執行課程的爬蟲:CampassCrawler
    • python manage.py buildCourse 學校genra.json 學校course.json 學校 第幾學年度
    • 以中山大學為範例:python manage.py buildCourse NSYSU.json NSYSU 1061
  2. Execute : python manage.py runserver.

test

需要注意,一定要先執行才能夠通過test,因為測試的資料要用才能匯入 test cmd:python manage.py test cphelper