创建作品之后再调用编程作业接口,参数传递增加作品的ID

This commit is contained in:
sw 2015-07-10 17:20:04 +08:00
parent aeb0d23289
commit aa5255c430
2 changed files with 20 additions and 11 deletions

View File

@ -80,17 +80,17 @@ class StudentWorkController < ApplicationController
end
render_attachment_warning_if_needed(stundet_work)
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 = {
src:stundet_work.description,
language:1
}
Net::HTTP.post_form(uri, solutions)
end
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
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

View File

@ -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