dev_local
cxt 6 years ago
commit 8ba0fe6b07

@ -1163,6 +1163,9 @@ class ShixunsController < ApplicationController
end end
def get_script_contents def get_script_contents
if params[:script_id].to_i == -1
render :json => {contents: "", description: ""}
else
mirrir_script = MirrorScript.find(params[:script_id]) mirrir_script = MirrorScript.find(params[:script_id])
script = mirrir_script.try(:script) script = mirrir_script.try(:script)
description = mirrir_script.try(:description) description = mirrir_script.try(:description)
@ -1170,6 +1173,8 @@ class ShixunsController < ApplicationController
render :json => {contents: script, description: description} render :json => {contents: script, description: description}
end end
end
def get_common_script def get_common_script
shixun_script = PlatformSample.where(:samples_type => "script").first.try(:contents) shixun_script = PlatformSample.where(:samples_type => "script").first.try(:contents)
compile = params[:compile] compile = params[:compile]

@ -125,9 +125,21 @@ class ShixunsService
praise_count = d.praise_tread.where(:praise_or_tread => 1).count praise_count = d.praise_tread.where(:praise_or_tread => 1).count
user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
# 实训TPM的管理员可以看到隐藏的评论 # 实训TPM的管理员可以看到隐藏的评论
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position, :user_id => d.user.try(:id), :reward => d.reward, manager = current_user.manager_of_shixun?(dis, current_user)
:image_url => url_to_avatar(d.user), :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden, game_url =
:manager => current_user.manager_of_shixun?(dis, current_user), :praise_count => praise_count, :user_praise => user_praise, :admin => current_user.admin?} if manager
challenge_id = dis.challenges.where(position: d.position).pluck(:id).first
game_identifier = Game.where(user_id: current_user,
challenge_id: challenge_id).pluck(:identifier).first
"/tasks/#{game_identifier}"
else
""
end
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position,
:user_id => d.user.try(:id), :reward => d.reward, :image_url => url_to_avatar(d.user),
:username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
:manager => manager, :praise_count => praise_count, game_url: game_url,
:user_praise => user_praise, :admin => current_user.admin?}
# 现在没有二级回复所以查询的时候直接从root_id取 # 现在没有二级回复所以查询的时候直接从root_id取
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc") children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")

@ -85,8 +85,9 @@
<div class="clearfix"> <div class="clearfix">
<div class="with15 pr fl" <%= @power ? "select-for" : "" %>> <div class="with15 pr fl" <%= @power ? "select-for" : "" %>>
<input type="hidden" name="mirror_script" id="shixun_scenario" value="<%= @shixun.script_tag.try(:id) %>"> <input type="hidden" name="mirror_script" id="shixun_scenario" value="<%= @shixun.script_tag.try(:id) %>">
<input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) %>"/> <input type="text" id="shixun_scenario_name" class="task-height-40 task-form-100 panel-box-sizing pr20 color-grey3 font-14" readonly placeholder="请选择脚本" value="<%= @shixun.script_tag.try(:script_type) ? @shixun.script_tag.try(:script_type) : "无" %>"/>
<div class="down-select bor-grey-e user_bg_shadow" id="shixun_scenario_option"> <div class="down-select bor-grey-e user_bg_shadow" id="shixun_scenario_option">
<p data-shixun-value="-1" title="无">无</p>
<% @shixun.standrad_script.each do |script| %> <% @shixun.standrad_script.each do |script| %>
<p data-shixun-value="<%= script.id %>" title="<%= script.script_type %>"><%= script.script_type %></p> <p data-shixun-value="<%= script.id %>" title="<%= script.script_type %>"><%= script.script_type %></p>
<% end %> <% end %>

Loading…
Cancel
Save