Merge branch 'dev_cs' into dev_cxt

This commit is contained in:
cxt 2017-07-26 15:23:23 +08:00
commit 2bf31a635d
14 changed files with 181 additions and 39 deletions

View File

@ -48,6 +48,8 @@ class MyshixunsController < ApplicationController
jenkins_shixuns = Redmine::Configuration['jenkins_shixuns']
uri = URI("#{jenkins_shixuns}/jenkins-exec/webssh/deleteSSH")
user_id = User.current.id
logger.info("#############################")
logger.info("game_id:" + @_params[:id])
params = {gameID:@_params[:id]} # @_params[:id] 是webssh传过来的gameId
res = uri_exec uri, params
if res && res['code'].to_i != 0

View File

@ -88,7 +88,6 @@ class SubjectsController < ApplicationController
end
def publish
@subject.update_attributes(:status => 1)
apply = ApplyAction.where(:container_type => "ApplySubject", :container_id => @subject.id).order("created_at desc").first
if apply && apply.status == 0
@status = 0
@ -96,6 +95,7 @@ class SubjectsController < ApplicationController
if Shixun.where(:id => @subject.stage_shixuns.map(&:shixun_id), :status => [0, 1]).count > 0
@status = 2
else
@subject.update_attributes(:status => 1)
ApplyAction.create(:container_type => "ApplySubject", :container_id => @subject.id, :user_id => User.current.id, :status => 0)
notes = User.current.show_name.to_s + " 申请发布课程实训:<a href='#{subject_path(@subject)}'>#{@subject.name}</a>"
JournalsForMessage.create(:jour_id => 1, :jour_type => 'Principal', :user_id => User.current.id, :notes => notes, :private => 1, :reply_id => 0)

View File

@ -164,7 +164,7 @@ module ApplicationHelper
# 实训语言的种类
def shixun_language
["Java", "C", "C++", "Python", "MySQL/Java"]
["Java", "C", "C++", "Python", "MySQL/Java","JFinal","Docker","Ethoernet","Dynamips"]
end
# 实训试用专业

View File

@ -60,7 +60,8 @@ class Myshixun < ActiveRecord::Base
games = self.games
current_game = games.select{|game| game.status == 1 || game.status == 0}.first
if current_game.blank?
passed_games = games.select{|game| game.status == 2}
game_id = '(' + games.map(&:id).join(',') + ')'
passed_games = games.find_by_sql("SELECT *, (SELECT c.position from `challenges` c where g.challenge_id = c.id) as pos FROM `games` g where g.status = 2 and g.id in #{game_id} ORDER BY pos desc")
current_game = passed_games.first
end
return current_game

View File

@ -5,10 +5,10 @@
<span class="btn-cir btn-cir-grey ml10 mt12 fl"><%= @challenges.count %></span>
<% end %>
<% if User.current.manager_of_shixun?(@shixun) && @shixun.status == 0 %>
<!--<a href="<%#= new_shixun_challenge_path(@shixun, :st => 2) %>" class="shixun-task-btn task-btn-green fr mr5" style="margin: 5px 0;">单选任务</a>-->
<!--<a href="<%#= new_shixun_challenge_path(@shixun, :st => 1) %>" class="shixun-task-btn task-btn-green fr mr5" style="margin: 5px 0;">多选任务</a>-->
<!--<a href="<%#= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr mr5" style="margin: 5px 0;">编程任务</a>-->
<a href="<%= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr mr5" style="margin: 5px 0;">新建阶段</a>
<a href="<%#= new_shixun_challenge_path(@shixun, :st => 2) %>" class="shixun-task-btn task-btn-green fr mt5">+单选任务</a>
<a href="<%#= new_shixun_challenge_path(@shixun, :st => 1) %>" class="shixun-task-btn task-btn-green fr mr10 mt5">+多选任务</a>
<a href="<%#= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr mr10 mt5">+编程任务</a>
<!--<a href="<%= new_shixun_challenge_path(@shixun, :st => 0) %>" class="shixun-task-btn task-btn-green fr mr5" style="margin: 5px 0;">新建阶段</a>-->
<% end %> </div>
<div class="panel-list shixun-panel-list">
<% @challenges.each_with_index do |challenge, index| -%>

View File

@ -31,11 +31,41 @@
<% end %>
</ul>
<% end %>
<ul id="select_more">
<li class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">A.</span></label>
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
<input type="checkbox" name="select_more[]" value="" id="select_more_0" class="ml-3 mr5 magic-checkbox">
<label for="select_more_0" style="top:0px">网络层</label>
</div>
</li>
<li class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">B.</span></label>
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
<input type="checkbox" name="select_more[]" value="" id="select_more_1" class="ml-3 mr5 magic-checkbox">
<label for="select_more_1" style="top:0px">网络层</label>
</div>
</li>
</ul>
<ul id="select_single">
<li class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">A.</span></label>
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
<input name="select_single[]" value="" type="radio" id="select_single_0" class="ml-3 mr5 magic-radio">
<label for="select_single_0" style="top:0px">网络层</label>
</div>
</li>
<li class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">B.</span></label>
<div class="fl task-bg-grey panel-box-sizing panel-form-width-690">
<input name="select_single[]" value="" type="radio" id="select_single_1" class="ml-3 mr5 magic-radio">
<label for="select_single_1" style="top:0px">网络层</label>
</div>
</li>
</ul>
</div>
<%# if @challenge.st == 1 %>
<!--需要添加新代码的地方-->
<%# end %>
<script>
$(document).ready(function() {

View File

@ -11,7 +11,13 @@
position: relative;
}
</style>
<script id="t:set-option-list" type="text/html">
<li class="clearfix pr">
<label class="panel-form-label fl"><span class="option-item fr mr10 color-grey select-choice" onclick="selectchoice(this);" name="option_span">A</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" name="option_inputs_label" placeholder="请输入选项内容"></textarea>
<a title="移除" class="position-delete option_icon_remove"><i class="fa fa-times-circle color-orange font-16 fl"></i></a>
</li>
</script>
<div id="shixun_form">
<li class="clearfix">
<label class="panel-form-label fl"><span class="c_red mr5">*</span>名称:</label>
@ -25,11 +31,14 @@
</div>
<span style="display: none" class="c_red ml95" id="new_shixun_pass">过关任务不能为空</span>
</li>
<!--<li>-->
<!--/*****-->
<!--需要写选项的地方-->
<!--*****/-->
<!--</li>-->
<ul>
<li class="clearfix mb10" >
<label class="panel-form-label fl"><span class="add-option-item fr mr10 color-grey" name="option_span">A</span></label>
<div class="fl panel-box-sizing add-option-input"><a title="新增" class="option_icon_add">新增选项</a></div>
</li>
<li class="clearfix" ><label class="fl" style="margin-left: 46px">温馨提示:点击选项,可以直接设置答案</label><label class="fr">标准答案:<span id="current-option" class="color-orange">请点击正确选项</span></label></li>
</ul>
<li class="clearfix">
<a href="javascript:void(0);" class="task-btn task-btn-green fr" onclick="challenge_update()">保存</a>
<% if params[:action] == "new" %>
@ -68,7 +77,62 @@
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL : "<%= upload_with_markdown_path(:container_id => @shixun.id, :container_type => @shixun.class) %>"//url
});
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
$("#shixun_form").on('click', 'a.option_icon_add', function () {
var html = bt('t:set-option-list', null);
$(this).parent().parent('.clearfix').before(html);
var inputs = document.getElementsByName("option_inputs_label");
var inputs_spans = document.getElementsByName("option_span");
for (var j = 0; j < inputs_spans.length; j++) {
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
for (var i = 0; i < inputs.length; i++) {
autoTextarea(inputs[i], 0, 140);
}
$(inputs[inputs.length - 1]).focus();
});
$("#shixun_form").on('click', 'a.option_icon_remove', function () {
$(this).parent('.clearfix').remove();
var inputs_spans = document.getElementsByName("option_span");
for (var j = 0; j < inputs_spans.length; j++) {
if(j >= 0 && j <= 26){
if(j >= 0 && j <= 26){
$(inputs_spans[j]).html(String.fromCharCode(65 + j));
}
}
}
});
});
//设置选项答案
function selectchoice(item){
//判断是否选中,如果选中,再次点击的时候取消选中
if($(item).hasClass('check-option-bg')){
$(item).removeClass('check-option-bg');
}else{
if(true){
//单选
$(".select-choice").removeClass('check-option-bg');
$(item).addClass('check-option-bg');
}else{
//多选
$(item).addClass('check-option-bg');
}
}
$("#current-option").html("");
if($(".check-option-bg").length>0){
for(var i=0;i<$(".check-option-bg").length;i++){
$("#current-option").html($("#current-option").html()+$(".check-option-bg").eq(i).html());
}
}else{
$("#current-option").html("请点击正确选项");
}
}
window.onload = function(){
$("#challenge_task_pass [type=\"latex\"]").bind("click", function(){
taskpass_editormd.cm.replaceSelection("```latex");

View File

@ -133,20 +133,25 @@ $(function(){
}
);
doc.bind('mousemove',function(e){
$(".-brother").show();// 代码行的遮罩显示
if(dragging) {
clickX = e.pageX;
if(clickX > leftOffset + 300&&clickX<leftOffset+1500) {
if(clickX > leftOffset+300&&clickX<leftOffset+1600) {
//console.log(1);
lab.css('left', clickX - 7 - leftOffset + 'px');
lab.prev().width( clickX-leftOffset + 'px');
nextW2 = clickX-leftOffset;
lab.next().width( wrapWidth - nextW2 + 'px');
//console.log(lab.next().width());
} else {
lab.css('left', '0px');
}
}
if(flag){
clickY = e.pageY;
if(clickY > topOffset) {
if(clickY > topOffset+100) {
cen.css('top', clickY - 7 - topOffset + 'px');
cen.prev().height( clickY-topOffset + 'px');
nextW1 = clickY-topOffset;
@ -156,10 +161,12 @@ $(function(){
}
}
});
doc.mouseup(function(e) {
flag = false;
dragging = false;
e.cancelBubble = true;
$(".-brother").hide(); // 代码行的遮罩隐藏
});
})
/*-----------------------------------------------------------------------------------*/

View File

@ -8,7 +8,7 @@
</li>
<% end %>
<div class="fr mt5 -horizontal">
<% if @path == @game.challenge.path.strip %>
<% if @path == @game.challenge.path.try(:strip) %>
<a href="javascript:void(0);" onclick="delete_confirm_box('<%= reset_original_code_myshixun_game_path(@game, :myshixun_id => @myshixun, :path => @path) %>', '你在本文件中修改的内容将丢失<br />是否确定重新加载初始代码');" title="恢复初始代码"><i class="fa fa-rotate-left font-18 mr5"></i></a>
<% end %>
<a href="javascript:void(0);" onclick="repository_extend_and_zoom();" id="extend_and_zoom"><i class="fa fa-arrows-alt font-16"></i></a>
@ -46,7 +46,7 @@
</div>
</div>
</div>
<div id="codotab_con_2" class="undis">
<div id="codotab_con_2" class="undis -relative">
<div class="-flex -relative">
<div class="fit">
<div class="-layout-v -fit loading-center undis" id="coding_ajax_loading">
@ -61,6 +61,7 @@
</div>
</div>
</div>
</div>
<script>
function g_l(o){return document.getElementById(o);}
@ -68,10 +69,15 @@
for(var i=1;i<=2;i++){
g_l('codetab_nav_'+i).className='blacktab_nomal';
g_l('codotab_con_'+i).className='undis';
}
g_l('codotab_con_'+n).className='dis';
n == 2 ? $("#games_repository_contents").removeClass("-bg-black").addClass("-bg-weightblack")
: $("#games_repository_contents").removeClass("-bg-weightblack").addClass("-bg-black");
g_l('codotab_con_'+n).className='dis -relative';
g_l('codetab_nav_'+n).className='blacktab_hover';
};
$('#codetab_nav_2').on("click", function(){
$.ajax({
url: "<%= open_webssh_myshixun_path(@myshixun) %>",
@ -80,17 +86,15 @@
return;
}else{
// 测试版
var html = "<iframe src='<%= Redmine::Configuration['webssh'] %>/?Host=" + data.host + "&Port=" + data.port + "&Username=" + data.username + "&Password=" + data.password + "&Gameid=" + data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe>";
var html = "<iframe src='<%= Redmine::Configuration['webssh'] %>/?Host=" + data.host + "&Port=" + data.port + "&Username=" + data.username + "&Password=" + data.password + "&Gameid=" + data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
// 本地版
var html_local ="<iframe src='http://127.0.0.1:9527?Host=106.75.96.108&Port=40054&Username=root&Password=123123&Gameid=" +data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe>";
console.log(html);
var html_local ="<iframe src='http://127.0.0.1:9527?Host=106.75.96.108&Port=40054&Username=root&Password=123123&Gameid=" +data.game_id + "'" + " style='width:100%;border:0;' scrolling='no' id='game_webssh'></iframe><div class='-brother undis'></div>";
$("#codotab_con_2").html(html);
var h = $("#games_repository_contents").height() - $("#top_repository").height() - 10;
$("#game_webssh").css("min-height", h);
HoverLi_new(2);
}
}
HoverLi_new(2);
}
}
})
});
</script>

View File

@ -13,9 +13,9 @@
<% end %>
<% if !User.current.manager_of_subject?(@subject) || @subject.status > 1 %>
<ul class="last-all-count fr">
<li><i class="fa fa-tasks mr5 color_white" title="实训"></i><span class="ml5 color_white"><%= @subject.stage_shixuns.count %></span></li>
<li><i class="fa fa-users mr5 color_white" title="实训阶段"></i><span class="ml5 color_white"><%= @subject.subject_challenges %></span></li>
<li><i class="fa fa-viacoin mr5 color_white" title="实训总积分"></i><span class="ml5 color_white"><%= @subject.subject_score %></span></li>
<li class="fl mr30"><i class="fa fa-tasks color_white" title="实训"></i><span class="ml5 color_white"><%= @subject.stage_shixuns.count %></span></li>
<li class="fl mr30"><i class="fa fa-users color_white" title="实训阶段"></i><span class="ml5 color_white"><%= @subject.subject_challenges %></span></li>
<li class="fl mr30"><i class="fa fa-viacoin color_white" title="实训总积分"></i><span class="ml5 color_white"><%= @subject.subject_score %></span></li>
</ul>
<% elsif @subject.status == 0 && @subject.stages.count > 0 && User.current.manager_of_subject?(@subject) %>
<%= link_to '申请发布', publish_subject_path(@subject), :class => "course-btn fr", :remote => true %>
@ -31,6 +31,7 @@
$(".edit_subject_name").on("click",function(){
$(".subject-main-name").attr("contenteditable","true");
$(".subject-main-name").focus();
getC($(".subject-main-name"));
});
$(".subject-main-name").on("keydown",function(ev){
if(ev.keyCode==13 || ev.keyCode==108){
@ -46,4 +47,15 @@
}
);
})
function getC(that){
if(document.all){
that.range=document.selection.createRange();
that.range.select();
that.range.moveStart("character",-1);
}else{
that.range=window.getSelection().getRangeAt(0);
that.range.setStart(that.range.startContainer,that.html().length);
}
}
</script>

View File

@ -18,6 +18,7 @@
$(".subject-produce").html("");
};
$("#subject-produce").focus();
getC($("#subject-produce"));
});
$(".subject-produce").on("keydown",function(ev){
if(ev.keyCode==13 || ev.keyCode==108){
@ -38,6 +39,16 @@
$("#subject-produce").removeClass("color-light-grey");
}
})
function getC(that){
if(document.all){
that.range=document.selection.createRange();
that.range.select();
that.range.moveStart("character",-1);
}else{
that.range=window.getSelection().getRangeAt(0);
that.range.setStart(that.range.startContainer,that.html().length);
}
}
</script>
<!--新版阶段列表-->
<div class="lesson-saved-list mb20">

View File

@ -70,8 +70,7 @@ li.li-width10{width: 10%;text-align: left}
.allback{background-color:#FFFFFF}
.last-all-count{width: 20%;text-align: right;}
.last-all-count li{float: left;width: 33.3%;}
.last-all-count{text-align: right;}
.course-option{width: 570px;padding: 10px;background-color: #FFFFFF;}
.magic-radio + label:before, .magic-checkbox + label:before{top: 11px;left: 5px;}

View File

@ -102,7 +102,7 @@
.-task-con-int .passageway .hascon .expand{display:block;;height:70px;line-height:70px;text-align:center;color:#5faee3;}
.-task-con-int .passageway .hascon .expand:hover{ color:#5faee3;}
.bg_shadow{-webkit-box-shadow: 0 0 10px #ccc;-moz-box-shadow: 0 0 10px #ccc;box-shadow: 0 0 10px #ccc;}
.new_expand{display:block;;height:70px;line-height:70px;text-align:center;color:#5faee3; background: #fafbfb}
.new_expand{display:block;;height:70px;line-height:70px;text-align:center;color:#5faee3; background: #FFFFFF}
.new_expand:hover{ color:#5faee3;}
/*--------------------------------------箭头动画效果-----------------------------------*/
.-task-con-int .passageway .hint .zhuan{

View File

@ -12,7 +12,7 @@ html,body{ font-size:14px; line-height:2.0; height:100%;}
a.user-info-img{ display: block; width: 50px; height: 50px; margin:0 auto; }
a.user-info-img img{border-radius:100px;border:2px solid #666;}
a.user-info-img img:hover{border:2px solid #888;}
a.user-info-name{ display: block; font-size: 16px; color: #fff; max-width:100px; margin: 10px auto; text-align: center;}
a.user-info-name{ display: block; font-size: 16px; color: #fff; max-width:100px; margin: 10px auto; text-align: center; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
.leftnav-box{ width: 80px; height: 60px; background:#292b3a; padding:10px 0; margin-bottom:2px;}
a.leftnav-box-inner{ display: block; width:77px; border-left:3px solid #292b3a; background:#292b3a; text-align: center; padding:10px 0; color:#575f6c;}
a:hover.leftnav-box-inner,a.leftnav-active{border-left:3px solid #3498db;color: #fff!important;}
@ -98,6 +98,7 @@ input.panel-form-width-100{ padding:5px;width:100%; height:40px; min-width:700px
textarea.panel-form-width-100{ padding:5px;width:100%; height:150px; min-width:700px;}
textarea.panel-form-width-40{ padding:5px;width:100%; height: 40px; min-width:700px;}
textarea.panel-form-width-690{ padding:5px;width:90%; height:150px; min-width:700px;}
textarea.panel-form-width2-690{ padding:5px;width:90%; height:40px; min-width:700px;}
.panel-form-width-670{ width: 670px; padding:5px;}
.panel-form-height-150{ height: 150px;}
.panel-form-height-30{height: 30px;}
@ -145,12 +146,14 @@ input.knowledge_frame{height:30px;line-height:30px;border:none;background:#f3f5f
.-scroll{ overflow:auto;}
.-flex-basic0{flex-basis: 0%!important; display: none}
/*王昌------------拖拽增加样式---------------修改*/
.-flex-basic40{flex-basis: auto;}
.-flex-basic50{flex-basis: auto;}
.b-label{width:2px;cursor:e-resize;}
.h-center{height:2px;cursor:n-resize;background:#2b2b2b;z-index:9999;}
.-flex-basic40{flex-basis:auto;}
.-flex-basic50{flex-basis:auto;}
.b-label{width:4px;cursor:ew-resize;background:#2b2b2b;}
.h-center{height:4px;cursor:ns-resize;background:#33485F;z-index:9999;}
.-brother{width:100%;height:100%;position:absolute;left:0;top:0;z-index:999;}
.-bg-weightblack{background:#000;}
/*---------------------------------------------*/
.-flex-basic60{flex-basis: 70%;}
.-flex-basic60{flex:4 9 auto;}
.-flex-basic100{flex-basis: 100%!important;}
.-header-title{ max-width:500px; font-weight: normal;}
.-header-right{ background:#333;border-radius:25px; padding:5px 15px; height: 30px; position: absolute; right:10px;line-height: 30px;}
@ -329,3 +332,12 @@ a.shixun-task-ban-btn{background-color: #c2c4c6;display: inline-block;font-weigh
.comment-input{width: 90%;padding: 0px 10px;}
.comment-input textarea{border: none !important;width:86%; outline: none;height: 30px;border-radius: 4px;margin-right: 10px;padding-left: 5px;float:left}
.comment_position{ position: absolute;bottom: 8px;}
/*-------新建阶段添加选项部分----------*/
.option-item{border:1px solid #e2e2e2;}
.add-option-item{border:1px dashed #e2e2e2;}
.option-item,.add-option-item{display: block;width: 38px;height: 38px;text-align: center;line-height: 38px;border-radius: 4px}
.check-option-bg{background: #ee4a1f;color: #ffffff!important;border: 1px solid #ee4a1f}
.add-option-input{padding: 5px;width: 90%;height: 40px;min-width: 700px;border: 1px dashed #e2e2e2;}
.add-option-input a{display: block;width: 100%;height: 100%;cursor: pointer}
.position-delete{position: absolute;right: -17px;top: 12px;cursor: pointer}