王皓
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# API Docs ## README > 本文档用于AICoach前后端沟通API接口,具体格式在下方已经有示例。Markdown中\#数量表示标题等级。统一规定二级标题为**API所属大类**,三级标题为**API名称**,四级标题为**API的描述项**。 > > - 三级标题的API Name为建议名,非特殊情况不要修改方便他人使用。需要修改请注明 > - Parameters为前端向后端发起请求时的参数,如果表格内表述不清楚可以另起一个4级标题描述 > - Method为http请求类型 > - URL为接口的URL形式 > > **注意事项:请大家按照统一格式增加和修改,方便通过目录直接索引到具体的API。如果参与了某个API的工作请把自己添加到designer中方便沟通交流。同时文档提供了评论功能、可以直接在评论里讨论(view mode)。比如README这一段的右边就有一条评论** > ### 暂时开一个debug版的测试地址:**http://GCRAZCDL006:8000** [TOC] ## User Information ### getUserInfo | Parameters | Method | URL | |:------------:|:------:|:----------------:| | NULL | GET | /user/info | #### parameters http request #### returns if fail: ```json= { "msg": 'error message', "status": 503, "data": null } ``` if success: ```json= { "login_status": 'is_login'/'not_login', "user_name": 'monica', "user_id": 3, } ``` #### designer - Xin Kang ### getUserById | Parameters | Method | URL | |:------------:|:------:|:----------------:| | user_id(int) | GET | /user/\<int:id\> | #### Name 没有特殊情况可以不写这一项 #### parameters 如果需要,可以添加更详细的说明 #### returns ```json= { "name":"Bob", "age":21, "ability": { "label": ['属性1', '属性2', '属性3'], # 属性数目固定,可不为3 "score": [55, 40, 80] }, # 能力值 "score": { "x_data": ['2019-11-10', '2019-11-11', '2019-11-12', '2019-11-13', '2019-11-14', '2019-11-15', '2019-11-16'], # 时间戳 "y_data": [20, 30, 25, 40, 41, 45, 45] # 分数 }, # 用来画积分曲线 "nextProblemId":1 # 自动推荐下一个题目的ID } ``` #### designer - Hao Wang - Hanyue Tu - Zhikai Chen ### getScore | Parameters | Method | URL | |:------------:|:------:|:----------------:| | user_id(int) | GET | /user/\<int:id\>/score | #### parameters http request and user_id #### returns ```json= { "user_id":1, "score":99, "msg": 'success' } ``` #### designer - Zhikai Chen ### getAbility | Parameters | Method | URL | |:------------:|:------:|:----------------:| | user_id(int) | GET | /user/\<int:id\>/ability | #### parameters http request and user_id #### returns ```json= { "user_id":1 , "ability": [51,34,65,97,84], # ability1, ability2, ability3, ability4, ability5 "msg": 'success' } ``` #### designer - Zhikai Chen ## Login/Logout/Register ### login | Parameters | Method | URL | |:------------:|:------:|:----------------:| | NULL | POST | user/login | #### parameters http request with body ```json= { "username": 'Joey' , "password": '123456' } ``` #### returns if fail: ```json= { "msg": 'error message', "status": 503, "data": null } ``` if success: ```json= { "msg": 'success', "status": 200, "data": {"user_name": 'Joey', "user_id": 1} } ``` #### designer - Xin Kang ### logout | Parameters | Method | URL | |:------------:|:------:|:----------------:| | NULL | NULL | user/logout | #### parameters http request #### returns ```json= { "msg": 'success', "status": 200 } ``` #### designer - Xin Kang ### register | Parameters | Method | URL | |:------------:|:------:|:----------------:| | NULL | POST | user/register | #### parameters http request with body ```json= { "username": 'Joey' , "password1": '123456', "password2": '123456', "email": 'test@exampe.com', } ``` #### returns if fail: ```json= { "msg": 'error message', "status": 503, "data": null } ``` if success: ```json= { "msg": 'success', "status": 200, "data": {"user_name": 'Joey', "user_id": 1} } ``` #### designer - Xin Kang ## Questionnaire Infomation ### getQuestionnaire | Parameters | Method | URL | |:------------:|:------:|:----------------:| | NULL | GET | user/\<int:id\>/questionnaire | #### Name 没有特殊情况可以不写这一项 #### parameters 如果需要,可以添加更详细的说明 #### returns ```json= { "items": [ { "question_id": 1, "type" : "single", # 单选或多选等,如只有单选可忽略这一项 "question": "问题1", "options": ["问题1的选项1", "问题1的选项2", "问题1的选项3", "问题1的选项4"] }, { "question_id": 2 "type": "single", # 单选或多选等,如只有单选可忽略这一项 "question": "问题2", "options": ["问题2的选项1", "问题2的选项2", "问题2的选项3"] } ] "msg": "success" # 获取成功的标志,若失败则会返回错误信息 } ``` #### designer - Hanyue Tu - Zhikai Chen ### postSurvey | Parameters | Method | url | |:------------:|:------:|:----------------:| |Json Data| POST|/user/\<int:id\>/questionnaire/submit/ #### Name 没有特殊情况可以不写这一项 #### json data ```json= { "user_id":1, "items": [ { "questionnaire_id" : 1, "submission": [1,2] # 如多选选择了选项1和2 }, { "questionnaire_id" : 2, "submission": [1] # 如单选选择了选项1 } ] } ``` #### returns #### designer - Hanyue Tu - Zhikai Chen ## Submission History Information ### getSubmissionById | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getSubmissionById | submission_id(int) | GET | /user/\<int:user_id\>/submissionid/?submission_id=\<id\> | ```json= { "msg": "success", "submission_id": 1, "challenge_id": 1001, "data":{ "code": `def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] # Driver code to test above arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print ("Sorted array is:") for i in range(len(arr)): print ("%d" %arr[i]),` "editableLines": [ [ 2, 2 ], # start_line and end_line [ 15, 17] ] #可编辑的行 "status": "pass", "stdin": "", "stdout": "", "sdterr": "", "comment": "this is hard" } } ``` ### getSubmissionList | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getSubmissionList | user_id(int) | GET | /user/\<int:user_id\>/submission/?challenge_id=1001 | ```json= { "msg": "success", "data":[ { "submission_id": 1, "status": "pass", "comment": "this is hard" }, { "submission_id": 2, "status": "fail", "comment": null # 没有评论就为 null } ] } ``` ### postComment | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | commentSubmission | user_id(int) | POST | /user/\<int:user_id\>/comment/ | #### Input ```json= { "submission_id": 1, "data": "This is hard" } ``` #### Output ## Challenge Information ### rateChallenge | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | rateChallenge | user_id(int) | POST | /user/\<int:user_id\>/rate/ | #### Input ```json= { "user_id":1, "challenge_id":1001 "data": 9.5 /*0~10/* } ``` #### Output ### getChallengeById | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getChallengeById | challenge_id(int) | GET | /user/\<int:user_id\>/challenge/?challenge_id=1001 | ```json= { "msg": "success" "challenge_id":1001, "data":{ "rate": Number or null, "title":"Challenge 1", "description":"The description of this challenge", ## "level": 1, # 难度值、比如1,2,3对应easy、normal、hard 模型组不提供暂此标签 "code": `def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] # Driver code to test above arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print ("Sorted array is:") for i in range(len(arr)): print ("%d" %arr[i]),` #返回整个题目就行(空行或换行为换行符即可) "editableLines": [ (2, 2, "str1"), # start_line, end_line and guide (15, 17, "str2") ] #可编辑的行 "tags": ["tag1", "tag2"] #标签 } } ``` #### Name 没有特殊情况可以不写这一项 #### parameters challenge_id通过传统request.GET.get方式获取,需要在请求的query params中设置好 user_id设置为1就行,目前数据库只有一个用户 #### designer - Hao Wang - Zhikai Chen - Jingwei Yi ### submitChallenge | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | submitChallenge | user_id,challege_id | POST | /user/\<int:uid\>/submit/ | #### Input ```json= { "challenge_id": 12, "code": "..." } ``` #### Output ```json= { "msg": "success", "code": 200, /*状态码 200,201,404,500*/ "data": { "submission_id": 1, "status": "pass", "stdin": [ "1 2\n3 4", /* 第一组输入 */ "5 6\n7 8" /* 第二组输入 */ ], "userout": [ "3\n7", /* 第一组输出; */ "except Exception as e:\n^"/* 第二组输出 */ ], "stdout": [ "3\n7", /* 第一组输出; */ "11\n15" ], "hints": [ {...}, {...} ] } } ``` <!-- ### getRuntimeRslt | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getRuntimeRslt | user_id,challege_id | POST | /user/\<int:uid\>/challenge/\<int:cid\>/rslt | #### Description 此 API 用于返回题目运行结果。 #### parameters ```json= { "id": #题目id "code": `def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] # Driver code to test above arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print ("Sorted array is:") for i in range(len(arr)): print ("%d" %arr[i]),` #用户已填写好的code } ``` ### postSubmit | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | postChallengeSubmission | user_id,challege_id | POST | /user/\<int:uid\>/challenge/\<int:cid\>/submit | #### Description 此 API 用于存储用户提交的代码空,但是模型组暂时还没有用到这个数据,也可以暂不提供。 #### parameters ```json= { "id": #题目id "code": `def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traverse the array from 0 to n-i-1 # Swap if the element found is greater # than the next element if arr[j] > arr[j+1] : arr[j], arr[j+1] = arr[j+1], arr[j] # Driver code to test above arr = [64, 34, 25, 12, 22, 11, 90] bubbleSort(arr) print ("Sorted array is:") for i in range(len(arr)): print ("%d" %arr[i]),` #用户已填写好的code } ``` --> ## Recommendation System ### getRecomendation | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getRecomendation | user_id(int) | GET | /user/\<int:id\>/recommend | ```json= { "msg":"success", "data":[challenge_id1,challenge_id2,challenge_id3...] # 推荐的题号 } ``` #### Name 没有特殊情况可以不写这一项 #### parameters 推荐系统返回推荐的题号,前端可以显示给用户,比如以题目列表高亮等形式,用户选择题目之后要重新调用getChallengeById接口获取推荐的题目内容 #### designer - Zhikai Chen <!-- ## Hint System ### getHints | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | getHints | user_id(int) | GET | /user/\<int:uid\>/challenge/\<int:cid\>/hint | ```json= { "msg":"success", "data": { "Hints":[ { "line":10, "col":4, "hint":"The <code>sqrt()</code> accepts only positive numbers\n see <link>" }, { "line":10, "col":4, "hint":"The <code>sqrt()</code> accepts only positive numbers\n see <link>" } ] } } ``` #### Name 没有特殊情况可以不写这一项 #### parameters #### designer - Zhikai Chen --> ## Action Record ### postClick | API Name | Parameters | Method | URL | |:-----------:|:------------:|:------:|:--------:| | postUserEvent | user_id(int),challenge_id(int) | POST | /user/\<int:id\>/click/ | ```json= { "user_id":1, "challenge_id":1001, "event": "click", # 必须是click字符 } ``` #### return #### description 此接口记录用户的每个预定义动作,用户进行这五种动作时一定要post这个请求给后端记录下来。click表示用户点击了这道题,rate表示用户对这道题进行了评分(data中存分数),pass和fail代表用户这道题run后的结果(data中也可以存用户评论) #### designer - Zhikai Chen

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully