dev_local
cxt 6 years ago
commit 3bc33a2e0e

@ -62,14 +62,9 @@ module Mobile
end
def memo_authenticate!
pass = (request.path.match(/memos\/\d+/).present? && !request.path.include?("reply")) ||
request.path.include?("get_memos_list") ||
request.path.include?("memos?page=") || request.path.match(/memos$/).present?
unless pass
error!('401 Unauthorized', 401) unless current_user
if LocalSetting.first.try(:exam) && !current_user.admin?
redirect '/'
end
end
def discusses_authenticate!

@ -32,6 +32,10 @@ class CategoriesController < ApplicationController
private
def render_react
render "/common/index", :layout => false
if LocalSetting.first.try(:exam) && !current_user.admin?
render_403
else
render "/common/index", :layout => false
end
end
end

@ -28,7 +28,11 @@ class ForumsController < ApplicationController
private
def render_react
render "/common/index", :layout => false
if LocalSetting.first.try(:exam) && !current_user.admin?
render_403
else
render "/common/index", :layout => false
end
end
end

@ -29,6 +29,7 @@ class ProjectsController < ApplicationController
# menu_item :share, :only => :share
skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
skip_before_filter :check_if_login_required, :only => [:training_task_status]
before_filter :local_exam
before_filter :check_authentication
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,
:view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status]
@ -37,6 +38,7 @@ class ProjectsController < ApplicationController
before_filter :require_admin, :only => [ :copy, :unarchive, :calendar]
before_filter :require_admin_or_manager, :only => [ :destroy]
before_filter :file
before_filter :local_exam
# 除非项目内人员,不可查看成员, TODO: 完了写报表里去
@ -738,6 +740,12 @@ class ProjectsController < ApplicationController
def file
end
def local_exam
if LocalSetting.first.try(:exam) && !User.current.admin?
render_403
end
end
def statistics
end

@ -315,7 +315,7 @@ class UsersController < ApplicationController
end
def message_detail
if User.current == @user || User.current.admin?
if (User.current == @user && !LocalSetting.first.try(:exam)) || User.current.admin?
@target_user = User.where(:id => params[:user_id]).includes(:user_extensions).first
if @target_user.present?
@message_list = @user.private_messages.where(:target_id => params[:user_id], :status => [0, 1]).order("send_time asc")

@ -73,7 +73,8 @@ class GamesService
:challenge => game_challenge.try(:attributes), :game => game.try(:attributes), :shixun => shixun.try(:attributes),
:record => record, :grade => grade, :prev_game => prev_game, :next_game => next_game, :username => username,
:image_url => image_url, :user_url => user_url, :praise_count => praise_count, :user_praise => user_praise, :time_limit => time_limit,
:tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager}
:tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager,
:local_exam => LocalSetting.first.try(:exam)}
# 区分选择题和编程题st0编程题
if st == 0

@ -37,65 +37,132 @@
<% end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="answer_Temp">
<div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">实训题</div>
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<ul class="fl" id="ul">
<li id="0">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:
<input id="minute0" class="borderFF8121"/> 分/题
<div class="colorFF8121sum none" id="scoregreater0">*大于等于0且不能大于100</div>
<div class="colorFF8121sum none" id="scorenull0">*不能为空</div>
<div class="colorFF8121sum none" id="scorezero0">*必须大于等于0</div>
<div class="colorFF8121sum none" id="scoreone0">*不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input id="topic0" class="borderFF8121"/> 题
<div class="colorFF8121 none" id="topicnull0">*不能为空</div>
<div class="colorFF8121 none" id="topicinteger0">*必须为正整数</div>
<div class="colorFF8121 none" id="topicreater0">*不能大于可用题数</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:<input class="borderFF8121"/> 分/题
<div class="colorFF8121sum">*大于等于0且不能大于100</div>
<div class="colorFF8121sum">*不能为空</div>
<div class="colorFF8121sum">*必须大于等于0</div>
<div class="colorFF8121sum">*不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input class="borderFF8121"/> 题
<div class="colorFF8121">*不能为空</div>
<div class="colorFF8121">*必须为正整数</div>
<div class="colorFF8121">*不能大于可用题数</div>
</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
<div class="fl mb10 shixunsbox" id="shixunsbox0">
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,0)"></i>
</span>
</div>
<div class="fl mb10 shixunsbox">
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,1)"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,2)"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
</div>
</li>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
</div>
<li id="1">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">中级题</span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:
<input id="minute1" class="borderFF8121"/> 分/题
<div class="colorFF8121sum none" id="scoregreater1">*大于等于0且不能大于100</div>
<div class="colorFF8121sum none" id="scorenull1">*不能为空</div>
<div class="colorFF8121sum none" id="scorezero1">*必须大于等于0</div>
<div class="colorFF8121sum none" id="scoreone1">*不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input id="topic1" class="borderFF8121"/> 题
<div class="colorFF8121 none" id="topicnull1">*不能为空</div>
<div class="colorFF8121 none" id="topicinteger1">*必须为正整数</div>
<div class="colorFF8121 none" id="topicreater1">*不能大于可用题数</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
</div>
<div class="fl mb10 shixunsbox">
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
</div>
</li>
</ul>
<div class="fl mb10 shixunsboxs">
<div class="newshixunbox">
<div class="newshixunboxfont">新增实训题</div>
<div class="newshixunboxfont" onclick="newshixuns()">新增实训题</div>
</div>
</div>
@ -111,3 +178,65 @@
</div>
<script type="text/javascript">
$(function(){
//保存
$("#add_new_question").one('click', function(){
// add_ex_question($(this),5);
var Uarry=$("#ul li");//获取ul中所有的li元素
var arr = [] //数组存放值
for(var i = 0; i < Uarry.length; i++){
var first = parseInt($("#minute"+i).val())
var last = parseInt($("#topic"+i).val())
console.log(first) //分数
console.log(last) //题数
if(first<0){
$("#scorezero"+i).show()
}else if(isNaN(first)){
$("#scorenull"+i).show()
}else if(first>100){
$("#scoreone"+i).show()
}
if(last<0){
$("#topicnull"+i).show()
}else if(isNaN(last)){
$("#topicinteger"+i).show()
}else if(last>100){
$("#topicreater"+i).show()
}
}
console.log(arr)
});
});
function shixunboxdelete(num,key){
var div=$("#shixunsbox"+num+" div");//获取所有子元素
$("#shixunsbox"+num+" div")[key].remove();
console.log(div)
}
function newshixuns(){
var oDiv = document.getElementById('li');
}
</script>

@ -38,7 +38,6 @@
<!-- </div>-->
<% end %>
<div class="user_bg_shadow bor-grey-e mb20 answer_Temp edu-back-white practicalTemp" id="shixun_question_block">
<div class="fl mt15 font-16 mb10 padding10 practicalTitlefont">实训题</div>
@ -103,9 +102,125 @@
</div>
<% end %>
<ul class="fl" id="ul">
<li id="0">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">初级题</span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:
<input id="minute0" class="borderFF8121"/> 分/题
<div class="colorFF8121sum none" id="scoregreater0">*大于等于0且不能大于100</div>
<div class="colorFF8121sum none" id="scorenull0">*不能为空</div>
<div class="colorFF8121sum none" id="scorezero0">*必须大于等于0</div>
<div class="colorFF8121sum none" id="scoreone0">*不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input id="topic0" class="borderFF8121"/> 题
<div class="colorFF8121 none" id="topicnull0">*不能为空</div>
<div class="colorFF8121 none" id="topicinteger0">*必须为正整数</div>
<div class="colorFF8121 none" id="topicreater0">*不能大于可用题数</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
</div>
<div class="fl mb10 shixunsbox" id="shixunsbox0">
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,0)"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,1)"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf" onclick="shixunboxdelete(0,2)"></i>
</span>
</div>
</div>
</li>
<li id="1">
<div class="fl font-16 mb10 practicalTitle">
<span class="Titlefont">中级题</span>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>分值:
<input id="minute1" class="borderFF8121"/> 分/题
<div class="colorFF8121sum none" id="scoregreater1">*大于等于0且不能大于100</div>
<div class="colorFF8121sum none" id="scorenull1">*不能为空</div>
<div class="colorFF8121sum none" id="scorezero1">*必须大于等于0</div>
<div class="colorFF8121sum none" id="scoreone1">*不能大于100</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-red mr5 shixun-title-font">*</span>
随机出题量:<input id="topic1" class="borderFF8121"/> 题
<div class="colorFF8121 none" id="topicnull1">*不能为空</div>
<div class="colorFF8121 none" id="topicinteger1">*必须为正整数</div>
<div class="colorFF8121 none" id="topicreater1">*不能大于可用题数</div>
</div>
<div class="fr mr40 shixun-title-font">
<span class="color-orange mr5 shixun-title-font">3</span>
题可用
</div>
</div>
<div class="fl mb10 shixunsbox">
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
<div>
<a class="shixunsboxfont">命令加密ZPI压缩文件解压</a>
<span class="shixundelect">
<i data-tip-down="删除" class="fa fa-times-circle mr10 color-afafaf"></i>
</span>
</div>
</div>
</li>
</ul>
<div class="fl mb10 shixunsboxs">
<div class="newshixunbox">
<div class="newshixunboxfont">新增实训题</div>
<div class="newshixunboxfont" onclick="newshixuns()">新增实训题</div>
</div>
</div>
@ -128,8 +243,60 @@
<% end %>
<script type="text/javascript">
$(function(){
//保存
$("#add_new_question").one('click', function(){
add_ex_question($(this),5);
// add_ex_question($(this),5);
var Uarry=$("#ul li");//获取ul中所有的li元素
var arr = [] //数组存放值
for(var i = 0; i < Uarry.length; i++){
var first = parseInt($("#minute"+i).val())
var last = parseInt($("#topic"+i).val())
console.log(first) //分数
console.log(last) //题数
if(first<0){
$("#scorezero"+i).show()
}else if(isNaN(first)){
$("#scorenull"+i).show()
}else if(first>100){
$("#scoreone"+i).show()
}
if(last<0){
$("#topicnull"+i).show()
}else if(isNaN(last)){
$("#topicinteger"+i).show()
}else if(last>100){
$("#topicreater"+i).show()
}
}
console.log(arr)
});
});
function shixunboxdelete(num,key){
var div=$("#shixunsbox"+num+" div");//获取所有子元素
$("#shixunsbox"+num+" div")[key].remove();
console.log(div)
}
function newshixuns(){
var oDiv = document.getElementById('li');
}
</script>

Loading…
Cancel
Save