pre_develop
jingquan huang 6 years ago
commit b3ffa73ed1

@ -78,5 +78,7 @@ class Managements::SchoolsController < Managements::BaseController
@active_course_total = Course.where(is_end: false).count @active_course_total = Course.where(is_end: false).count
@shixun_homework_total = HomeworkCommon.where(homework_type: 4).count @shixun_homework_total = HomeworkCommon.where(homework_type: 4).count
@other_homework_total = HomeworkCommon.where(homework_type: [1, 3]).count @other_homework_total = HomeworkCommon.where(homework_type: [1, 3]).count
@shixun_total = Shixun.count
@shixun_evaluate_total = Game.sum(:evaluate_count)
end end
end end

@ -528,11 +528,12 @@ class GamesService
# 三类实训只取基础部分数据 # 三类实训只取基础部分数据
game = Game.select([:myshixun_id, :status, :challenge_id, :id, :evaluate_count]).find_by_identifier(params[:identifier]) game = Game.select([:myshixun_id, :status, :challenge_id, :id, :evaluate_count]).find_by_identifier(params[:identifier])
myshixun = Myshixun.select([:updated_at, :gpid, :id, :shixun_id]).find(game.myshixun_id) myshixun = Myshixun.select([:updated_at, :gpid, :id, :shixun_id]).find(game.myshixun_id)
shixun = Shixun.select([:id, :evaluate_script, :webssh, :exec_time, :sigle_training, :identifier, :status]).find(myshixun.shixun_id) shixun = Shixun.select([:id, :evaluate_script, :webssh, :exec_time, :sigle_training, :identifier, :status, :evaluate_count]).find(myshixun.shixun_id)
game_challenge = Challenge.select([:id, :position, :picture_path]).find(game.challenge_id) game_challenge = Challenge.select([:id, :position, :picture_path]).find(game.challenge_id)
# 更新评测次数 # 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
shixun.increment!(:evaluate_count)
# 清空代码评测信息 # 清空代码评测信息
msg = game.run_code_message msg = game.run_code_message
msg.update_attributes(:status => 0, :message => nil) if msg.present? msg.update_attributes(:status => 0, :message => nil) if msg.present?
@ -693,6 +694,7 @@ class GamesService
:evaluate_count]).find_by_identifier(params[:identifier]) :evaluate_count]).find_by_identifier(params[:identifier])
# 更新评测次数 # 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1)) game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
game.challenge.shixun.increment!(:evaluate_count)
# 选择题如果通关了,则不让再评测 # 选择题如果通关了,则不让再评测
if game.status == 2 if game.status == 2

@ -4,7 +4,7 @@ class Management::SchoolReportService
attr_reader :params attr_reader :params
sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count, sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count,
:course_count, :active_course_count, :nearly_course_time, :course_count, :active_course_count, :nearly_course_time, :shixun_count, :shixun_evaluate_count,
default_by: :teacher_count, default_direction: :desc default_by: :teacher_count, default_direction: :desc
def initialize(params) def initialize(params)
@ -47,6 +47,11 @@ class Management::SchoolReportService
nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at') nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at')
active_course_map = courses.where(is_end: false).count active_course_map = courses.where(is_end: false).count
shixun_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids })
.group('school_id').count
evaluate_count_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids })
.group('school_id').sum(:evaluate_count)
schools.map do |school| schools.map do |school|
{ {
id: school.id, id: school.id,
@ -58,6 +63,8 @@ class Management::SchoolReportService
course_count: course_map[school.id], course_count: course_map[school.id],
nearly_course_time: nearly_course_time_map[school.id], nearly_course_time: nearly_course_time_map[school.id],
active_course_count: active_course_map[school.id], active_course_count: active_course_map[school.id],
shixun_count: shixun_map.fetch(school.id, 0),
shixun_evaluate_count: evaluate_count_map.fetch(school.id, 0)
} }
end end
end end
@ -78,6 +85,12 @@ class Management::SchoolReportService
when 'course_count' then when 'course_count' then
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
.select("#{base_query_column}, COUNT(*) course_count") .select("#{base_query_column}, COUNT(*) course_count")
when 'shixun_count' then
schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id')
.select("#{base_query_column}, COUNT(*) shixun_count")
when 'shixun_evaluate_count' then
schools.joins(teacher_extensions: :user).joins('INNER JOIN shixuns sx ON sx.user_id = users.id')
.select("#{base_query_column}, SUM(sx.evaluate_count) shixun_evaluate_count")
when 'nearly_course_time' then when 'nearly_course_time' then
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0') schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
.joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id') .joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id')

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.e1b0d6a5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.1d0aa33a.js"></script></body></html> <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.e1b0d6a5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.f14d00a5.js"></script></body></html>

@ -12,7 +12,7 @@
<div class="grow-date-container" style="width: 450px;display: <%= params[:data_type] == 'grow' ? 'block' : 'none' %>"> <div class="grow-date-container" style="width: 450px;display: <%= params[:data_type] == 'grow' ? 'block' : 'none' %>">
<%= text_field_tag :grow_date_input, params[:grow_date_input], <%= text_field_tag :grow_date_input, params[:grow_date_input],
class: 'grow-date-input winput-220-30', placeholder: '请选择时间段', class: 'grow-date-input winput-220-30', placeholder: '请选择时间段具体从当日5:00开始计算',
style: 'width: 400px;' %> style: 'width: 400px;' %>
</div> </div>
<div class="contrast-date-container" style="width: 450px;display: <%= params[:data_type] == 'contrast' ? 'block' : 'none' %>"> <div class="contrast-date-container" style="width: 450px;display: <%= params[:data_type] == 'contrast' ? 'block' : 'none' %>">

@ -9,6 +9,8 @@
<th width="10%"><%= sort_tag('学生总人数', name: 'student_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('学生总人数', name: 'student_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('创建实训数', name: 'shixun_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('评测次数', name: 'shixun_evaluate_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: school_report_managements_path) %></th> <th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: school_report_managements_path) %></th>
<th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: school_report_managements_path) %></th> <th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: school_report_managements_path) %></th>
@ -24,6 +26,8 @@
<td><%= school[:student_count].to_i %></td> <td><%= school[:student_count].to_i %></td>
<td><%= school[:course_count].to_i %></td> <td><%= school[:course_count].to_i %></td>
<td><%= school[:active_course_count].to_i %></td> <td><%= school[:active_course_count].to_i %></td>
<td><%= school[:shixun_count].to_i %></td>
<td><%= school[:shixun_evaluate_count].to_i %></td>
<td><%= school[:homework_count].to_i %></td> <td><%= school[:homework_count].to_i %></td>
<td><%= school[:other_homework_count].to_i %></td> <td><%= school[:other_homework_count].to_i %></td>
<td><%= format_time school[:nearly_course_time] %></td> <td><%= format_time school[:nearly_course_time] %></td>

@ -21,6 +21,8 @@
学生总人数<span class="color-red"><%= @student_total %></span>人, 学生总人数<span class="color-red"><%= @student_total %></span>人,
课堂总数<span class="color-red"><%= @course_total %></span>个, 课堂总数<span class="color-red"><%= @course_total %></span>个,
正在进行课堂总数<span class="color-red"><%= @active_course_total %></span>个, 正在进行课堂总数<span class="color-red"><%= @active_course_total %></span>个,
创建实训数<span class="color-red"><%= @shixun_total %></span>个,
评测次数<span class="color-red"><%= @shixun_evaluate_total %></span>个,
实训作业总数<span class="color-red"><%= @shixun_homework_total %></span>个, 实训作业总数<span class="color-red"><%= @shixun_homework_total %></span>个,
其它作业总数<span class="color-red"><%= @other_homework_total %></span>个, 其它作业总数<span class="color-red"><%= @other_homework_total %></span>个,
</div> </div>

@ -0,0 +1,24 @@
class AddEvaluateCountToShixuns < ActiveRecord::Migration
def up
add_column :shixuns, :evaluate_count, :integer, default: 0
limit = 100
total = Shixun.count
((total / 100) + 1).times do |index|
shixun_ids = Shixun.order(:id).limit(limit).offset(index * limit).pluck(:id)
return if shixun_ids.blank?
count_map = Game.joins(:challenge).where(challenges: { shixun_id: shixun_ids }).group('shixun_id').sum(:evaluate_count)
id_str = count_map.keys.join(',')
str = count_map.map { |shixun_id, count| "WHEN #{shixun_id} THEN #{count}" }.join(' ')
execute "UPDATE shixuns SET evaluate_count = CASE id #{str} END WHERE id IN (#{id_str})"
end
end
def down
remove_column :shixuns, :evaluate_count
end
end

@ -182,6 +182,8 @@ class Index extends Component {
myshixun={context.myshixun} myshixun={context.myshixun}
shixun={context.shixun} shixun={context.shixun}
vnc_url={context.vnc_url} vnc_url={context.vnc_url}
zip_path={context.zip_path}
loading={context.loading} loading={context.loading}
discusses_count={context.discusses_count} discusses_count={context.discusses_count}

@ -68,7 +68,7 @@ class MainContent extends Component {
id="game_right_contents" style={{width: '996px'}}> id="game_right_contents" style={{width: '996px'}}>
{/* {/*
iframe模式下可以使用样式控制不接收鼠标事件 iframe模式下可以使用样式控制不接收鼠标事件
注意 page--body 不能设置index 7999 弹出框的index才1300
.page--body { z-index: ${showIframeContent ? '7999': '1'} ; } .page--body { z-index: ${showIframeContent ? '7999': '1'} ; }
.b-label>.resize-helper { top: ${showIframeContent ? '10px': '50%'} } .b-label>.resize-helper { top: ${showIframeContent ? '10px': '50%'} }
@ -78,8 +78,6 @@ class MainContent extends Component {
height: 100%; height: 100%;
background: #fff; background: #fff;
} }
.page--body { z-index: 9999; }
.resize-helper { top: 10px }
`}</style> `}</style>
{ showIframeContent ? <iframe src={vnc_url ||"http://106.75.27.125:42288/vnc.html"} id="contentIframe" ></iframe> : { showIframeContent ? <iframe src={vnc_url ||"http://106.75.27.125:42288/vnc.html"} id="contentIframe" ></iframe> :
<React.Fragment> <React.Fragment>

@ -296,7 +296,7 @@ class CodeRepositoryView extends Component {
const { repositoryCode, onRepositoryCodeUpdate, showFilesDrawer, drawerOpen, loadingFirstRepoFiles const { repositoryCode, onRepositoryCodeUpdate, showFilesDrawer, drawerOpen, loadingFirstRepoFiles
, challenge, evaluateViewExpanded, onRepositoryViewExpand, codeStatus , , challenge, evaluateViewExpanded, onRepositoryViewExpand, codeStatus ,
showResetCodeDialog, showResetPassedCodeDialog, tabIndex, tabIndexChange, game, shixun, isEditablePath, currentPath showResetCodeDialog, showResetPassedCodeDialog, tabIndex, tabIndexChange, game, shixun, isEditablePath, currentPath
, showSettingDrawer, hide_code, myshixun_manager } = this.props; , showSettingDrawer, hide_code, myshixun_manager, zip_path } = this.props;
// onRequestChange={(drawerOpen) => showFilesDrawer(drawerOpen)} // onRequestChange={(drawerOpen) => showFilesDrawer(drawerOpen)}
/* /*
@ -410,9 +410,9 @@ class CodeRepositoryView extends Component {
</a> </a>
</Tooltip> } </Tooltip> }
{/* onClick={showFilesDrawer.bind(this, true)} */} {/* onClick={showFilesDrawer.bind(this, true)} target='_blank'*/}
{ myshixun_manager == true && <Tooltip title={ "下载代码"} disableFocusListener={true}> { myshixun_manager == true && <Tooltip title={ "下载代码"} disableFocusListener={true}>
<a href={shixun.zip_path || `/myshixuns/${myshixun.identifier}/archive`} className="iconButton" target='_blank'> <a href={zip_path || `/myshixuns/${myshixun.identifier}/archive`} className="iconButton" >
<i className="iconfont icon-xiazai1 font-18 "></i> <i className="iconfont icon-xiazai1 font-18 "></i>
</a> </a>
</Tooltip> } </Tooltip> }

Loading…
Cancel
Save