22 lines
560 B
Ruby
22 lines
560 B
Ruby
require 'base64'
|
|
|
|
class Api::SolutionsController < ApplicationController
|
|
protect_from_forgery :except => :create
|
|
respond_to :json
|
|
|
|
def create
|
|
args = [:student_work_id, :src, :language]
|
|
@solution = Question.find(params[:question_id]).solutions.build(params.slice(*args))
|
|
@solution.status = 7
|
|
|
|
if @solution.save
|
|
@solution.work
|
|
render :json => {status: 0, id: @solution.id}
|
|
else
|
|
render :json => {status: 7, message: @solution.errors.full_messages}
|
|
logger.error @solution.errors.full_messages
|
|
end
|
|
end
|
|
|
|
end
|