创建作品之后再调用编程作业接口,参数传递增加作品的ID
This commit is contained in:
parent
aeb0d23289
commit
aa5255c430
|
@ -80,17 +80,17 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
render_attachment_warning_if_needed(stundet_work)
|
||||
|
||||
if stundet_work.save
|
||||
if @homework.homework_type == 2 && @homework.homework_detail_programing #编程作业,学生提交作品后计算系统得分
|
||||
url = "http://fast.forge.trustie.net/api/questions/#{@homework.homework_detail_programing.question_id}/solutions.json"
|
||||
uri = URI(url)
|
||||
solutions = {
|
||||
id:stundet_work.id,
|
||||
src:stundet_work.description,
|
||||
language:1
|
||||
}
|
||||
Net::HTTP.post_form(uri, solutions)
|
||||
end
|
||||
|
||||
if stundet_work.save
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
|
@ -321,6 +321,15 @@ class StudentWorkController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
#设置编程作业得分
|
||||
def set_program_score
|
||||
res = JSON.parse(response.body)
|
||||
stundet_work = StudentWork.find_by_id res["id"]
|
||||
if stundet_work
|
||||
stundet_work.update_column("student_score",res["status"])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#获取作业
|
||||
def find_homework
|
||||
|
|
|
@ -86,7 +86,6 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
collection do
|
||||
post 'next_step'
|
||||
post 'set_program_score'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -101,6 +100,7 @@ RedmineApp::Application.routes.draw do
|
|||
get 'student_work_absence_penalty'
|
||||
get 'absence_penalty_list'
|
||||
get 'evaluation_list'
|
||||
post 'set_program_score'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue