Merge branch 'develop' of https://bdgit.trustie.net/hushasha/bigdata into develop

This commit is contained in:
cxt 2017-06-30 16:28:35 +08:00
commit 47ff17fbbb
15 changed files with 80 additions and 58 deletions

View File

@ -42,21 +42,15 @@ class CoursesController < ApplicationController
#
def index
@user = User.current
sy_courses = @user.courses.visible.not_deleted
syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
syllabus_members = SyllabusMember.where("user_id = #{@user.id}")
syllabus_member_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|syl_mem| syl_mem.syllabus_id}.join(',') + ")"
@search = params[:search].nil? ? '' : params[:search]
@select = params[:select].nil? ? '' : params[:select]
# 我发布的课程
create_syllabuses = Syllabus.where("user_id = #{@user.id} and title like '%#{@search}%'").order("created_at desc")
# 我参与的课程
join_syllabuses = Syllabus.where("(id in #{syllabus_ids} or id in #{syllabus_member_ids}) and user_id != #{@user.id} and title like '%#{@search}%'").order("created_at desc")
# 我的所有课程
all_syllabuses = Syllabus.where("title like '%#{@search}%'").order("created_at desc")
@syllabus_count = Syllabus.all.count
# 全部课堂
all_syllabuses = Course.where("is_end = 0 and name like '%#{@search}%'").order("created_at desc")
# 我参与的课堂
join_syllabuses = @user.courses.where("tea_id != #{@user.id} and name like '%#{@search}%'").order("created_at desc")
# 我创建的课堂
create_syllabuses = Course.where(:tea_id => @user.id).where("is_end = 0 and name like '%#{@search}%'").order("created_at desc")
@syllabus_count = all_syllabuses.count
@join_syllabuses_count = join_syllabuses.count
@create_syllabuses_count = create_syllabuses.count
# 页面筛选的课程

View File

@ -4870,6 +4870,27 @@ def sy_homeworks syllabus
homeworks
end
# 可以查看到资源库的资源
def visable_attachemnts_incourse course
return[] unless course
result = []
course.attachments.each do |attachment|
if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || User.current.allowed_to?(:as_teacher,course) || (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
result << attachment
end
end
result
end
def visable_course_homework course
if User.current.admin? || User.current.allowed_to?(:as_teacher,course)
homework_num = course.homework_commons.count
else
homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count
end
homework_num
end
#成绩计算
def set_final_score homework,student_work
if homework && homework.homework_detail_manual

View File

@ -14,14 +14,14 @@ module ChallengesHelper
def find_game_status challenge_id
game = Game.where(:challenge_id => challenge_id, :user_id => User.current.id).first
case game.status
case game.try(:status)
when 0
"<a title='待完成'><i class='fa fa-unlock-alt fr font-18 mt5 -text-danger w20_center'></i></a>".html_safe
when 1
"评测中"
when 2
"<a title='已解决'><i class='fa fa-unlock fr font-18 mt5 color-light-green w20_center' ></i></a>".html_safe
when 3
when 3,nil
"<a title='未解锁'><i class='fa fa-lock fr font-18 mt5 color-grey w20_center' ></i></a>".html_safe
end
end

View File

@ -833,26 +833,6 @@ module CoursesHelper
link.html_safe
end
# 可以查看到资源库的资源
def visable_attachemnts_incourse course
return[] unless course
result = []
course.attachments.each do |attachment|
if attachment.is_public? && attachment.is_publish == 1 || User.current == attachment.author || User.current.allowed_to?(:as_teacher,course) || (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
result << attachment
end
end
result
end
def visable_course_homework course
if User.current.admin? || User.current.allowed_to?(:as_teacher,course)
homework_num = course.homework_commons.count
else
homework_num = course.homework_commons.where("publish_time <= '#{Time.now}'").count
end
homework_num
end
def zh_course_role role
if role == "TeachingAsistant"

View File

@ -1,18 +1,18 @@
<% if @syllabuses.count > 0 %>
<% @syllabuses.each do | sy | %>
<% sy_author = User.find(sy.tea_id) %>
<div class="sub-con fl" style="cursor: default;">
<div class="task-index-list-box-top">
<a href="<%= syllabus_path(sy) %>" title="<%= sy.title %>" target="_blank">
<a href="<%= course_path(sy) %>" title="<%= sy.name %>" target="_blank">
<p class="font-14 task-index-list-title two_lines_show">
<%= sy.title %>
<%= sy.name %>
</p>
</a>
<div class="clearfix task-index-list-user">
<%= link_to image_tag(url_to_avatar(sy.user), :width => "60", :height => "60", :class => "panel-warp-img mr10 fl", :alt => "用户"), user_path(sy.user), :target => '_blank' %>
<%= link_to sy.user.show_name, user_path(sy.user), :class => 'task-index-name task-hide fl', :target => '_blank' %>
<%= link_to image_tag(url_to_avatar(sy_author), :width => "60", :height => "60", :class => "panel-warp-img mr10 fl", :alt => "用户"), user_path(sy_author), :target => '_blank' %>
<%= link_to sy_author.show_name, user_path(sy_author), :class => 'task-index-name task-hide fl', :target => '_blank' %>
</div>
<p class="color-grey">
<% sy_author = User.find(sy.user_id) %>
<% if !sy_author.user_extensions.school_id.blank? && sy_author.user_extensions.school %>
<%= sy_author.user_extensions.school.name %>
<% end %>
@ -25,10 +25,10 @@
</div>
<div class="bot" style="text-align: center;">
<p class="color-grey pl15 pr15 clearfix">
<% syResource = sy_resources sy %>
<% syHome = sy.homework_banks %>
<% syResource = visable_attachemnts_incourse(sy) %>
<% syHome = visable_course_homework(sy) %>
<span class="mr30"><i class="fa fa-cubes color-light-green pr10" aria-hidden="true" title="资源"></i><em><%= syResource.count %></em></span>
<span class=""><i class="fa fa-map color-light-green pr10" aria-hidden="true"title="题库"></i><em><%= syHome.count %></em></span>
<span class=""><i class="fa fa-map color-light-green pr10" aria-hidden="true"title="题库"></i><em><%= syHome %></em></span>
<!-- <span class="fr collect" onclick="add_cancel_to_favorites(this);">
<i class="fa fa-heart-o grey" aria-hidden="true"title="收藏课程"></i>
</span>-->

View File

@ -12,14 +12,18 @@
</ul>
</div>
<div class="clearfix mb15 fl">
<li class="edu-dropdown fl ml15 mr5" id="thirdly_select" style="width: 100px">
<a href="<%= courses_path(:select => "all", :search => @search) %>" class="course_filtrate fl course_filtrate_bg" data-tab="all" data-remote="true">全部课堂</a>
<a href="<%= courses_path(:select => "create", :search => @search) %>" class="course_filtrate fl" data-tab="create" data-remote="true">我管理的</a>
<a href="<%= courses_path(:select => "join", :search => @search) %>" class="course_filtrate fl" data-tab="join" data-remote="true">我参与的</a>
<!-- <li class="edu-dropdown fl ml15 mr5" id="thirdly_select" style="width: 100px">
<a href="javascript:void(0);" class="edu-dropdown-toggle" id="all_syllabuses" >所有课程<i class="fa fa-caret-down ml20"></i></a>
<ul class="edu-dropdown-menu" id="all_syllabuses_list">
<li onclick="change_language(this);"><a id="courses_index_syllabuses_1" href="<%= courses_path(:select => "all", :search => @search) %>" data-remote="true">所有课程</a></li>
<li onclick="change_language(this);"><a id="courses_index_syllabuses_2" href="<%= courses_path(:select => "create", :search => @search) %>" data-remote="true">我发布的课程</a></li>
<li onclick="change_language(this);"><a id="courses_index_syllabuses_3" href="<%= courses_path(:select => "join", :search => @search) %>" data-remote="true">我参与的课程</a></li>
<li onclick="change_language(this);"><a id="courses_index_syllabuses_1" href="<%#= courses_path(:select => "all", :search => @search) %>" data-remote="true">所有课程</a></li>
<li onclick="change_language(this);"><a id="courses_index_syllabuses_2" href="<%#= courses_path(:select => "create", :search => @search) %>" data-remote="true">我发布的课程</a></li>
<li onclick="change_language(this);"><a id="courses_index_syllabuses_3" href="<%#= courses_path(:select => "join", :search => @search) %>" data-remote="true">我参与的课程</a></li>
</ul>
</li>
</li>-->
<form action="<%= courses_path() %>" data-remote="true" onsubmit="submitFn(this, event);" class="fl ml15" id="search_syllabuses_name" >
<div class="search-wrapper">
@ -125,4 +129,13 @@
evt.preventDefault();
}
$(".course_filtrate").live("click", function(){
console.log($(this).attr("data-tab"));
if ($(this).hasClass("course_filtrate_bg")){
return;
}else{
$(".course_filtrate").removeClass("course_filtrate_bg");
$(this).addClass("course_filtrate_bg");
}
})
</script>

View File

@ -23,6 +23,12 @@
<% end %>
</div>
<script>
/* -------------- 点击加载上次通过的代码----------------*/
$("#task_popup_confirm").live("click", function(){
$("#coding_area").hide();
$("#coding_ajax_loading").css("display", "flex");
});
/* ------------------耗时------------------------- */
var cTime = 1; // 时间累加参数
var cm = setInterval(setTime, 1000);
@ -132,10 +138,10 @@
}
// 传递具体屏幕的宽高,实现不同浏览器与不同分辨率都能撑满屏幕
pop_box_new2(htmlvalue, window.innerWidth, window.innerHeight);
$("#reset_code_to_bengin").show(); // 显示加载上次通过的代码
}
var html = "<a href='javascript:void(0)' class='task-btn task-btn-blue mr15 mt8' onclick='training_task_submmit();'>评测</a>";
$("#code_test").html(html); // 恢复评测
$("#reset_code_to_bengin").show(); // 显示加载上次通过的代码
}
// 访问60次即120s后后台还未改变状态即执行
if(i == 60){

View File

@ -132,7 +132,7 @@
function error_correction_pop(){
var htmlvalue = "<%= escape_javascript(render :partial => 'games/send_error_pop') %>";
pop_box_new(htmlvalue,460,316);
$("#popupWrap").addClass("bg_shadow");
$("#popupWrap").addClass("user_bg_shadow");
};
// 点赞/取消点赞功能

View File

@ -12,7 +12,10 @@
</div>
<div class="-flex -relative">
<div class="fit">
<div class="-layout-v -fit">
<div class="-layout-v -fit loading-center undis" id="coding_ajax_loading">
<embed src='/images/bigdata/loading2.svg' />
</div>
<div class="-layout-v -fit" id="coding_area">
<div class="-flex">
<div class="content-editor-inner">
<% if !@content.nil? || params[:action] == "entry" %>

View File

@ -1,5 +1,7 @@
<% if @error_messages %>
notice_sure_box('<%= @error_messages %>');
notice_sure_box('<%= @error_messages %>');
<% else %>
$("#games_repository_contents").html('<%= escape_javascript(render :partial => 'games/repository') %>');
$("#games_repository_contents").html('<%= escape_javascript(render :partial => 'games/repository') %>');
<% end %>
$("#coding_area").show();
$("#coding_ajax_loading").css("display", "none");

View File

@ -14,7 +14,7 @@
<%#= link_to image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像"), "javascrip:void(0);" %>
<a href="javascript:void(0);"><%= image_tag(url_to_avatar(shixun.owner), :width =>"60", :height => "60", :class => "panel-warp-img mr10 fl", :alt=>"头像") %></a>
<%#= link_to shixun.owner.try(:show_name), "javascript:void(0);" , :class => "task-index-name task-hide fl", :target => "_blank" %>
<a href="javascript:void(0);" class="task-index-name task-hide fl"><%= shixun.owner.try(:show_name) %></a>
<span class="task-index-name task-hide fl"><%= shixun.owner.try(:show_name) %></span>
</div>
<div class="cl"></div>
<span class="mt10 mb10"><%= shixun.language == "JDBC" ? "Java/SQL" : shixun.language %></span>

View File

@ -25,14 +25,14 @@
<%= link_to "开始实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %>
<%#= link_to_shixun_exec myshixun, @shixun, '开始实战' %>
<% else %>
<%= link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :target => "_blank"%>
<%= link_to "继续实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %>
<% end %>
<% if User.current.manager_of_shixun?(@shixun) %>
<a href="javascript:void(0);" class="fr shixun-task-btn task-btn-grey-white mr15" id="challenge_begin" onclick="s_op_confirm_box('<%= close_shixun_path(@shixun) %>', '关闭后,用户不能再开始挑战了<br/>是否确认关闭')">永久关闭</a>
<% end %>
<% elsif @shixun.status == 3 %>
<% unless myshixun.blank? %>
<%= link_to "继续实战", myshixun_game_path(myshixun.current_task, :myshixun_id => myshixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :target => "_blank"%>
<%= link_to "继续实战", operation_shixun_path(@shixun, :myshixun_id => myshixun.try(:id)), :class => "fr shixun-task-btn task-btn-orange mr15", :remote => true %>
<% end %>
<a href="javascript:void(0);" class="fr shixun-task-btn task-btn-grey-white mr15">已关闭</a>
<% end %>

View File

@ -13,7 +13,7 @@
<div class="cl"></div>
<div style="text-align:center;" class="new_expand">
<div class="pages_right_min" style="width:auto; display:inline-block;margin: 18px 0;">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @shixuns_pages, @shixuns_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true %>
</ul>

View File

@ -209,7 +209,7 @@ function s_op_confirm_box(url, str){
function delete_confirm_box(url, str){
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
'<a href="'+ url +'" class="task-btn task-btn-blue fr pop_close" data-remote="true">确定</a></div></div>';
'<a href="'+ url +'" class="task-btn task-btn-blue fr pop_close" data-remote="true" id="task_popup_confirm">确定</a></div></div>';
pop_box_new(htmlvalue, 480, 140);
}

View File

@ -274,3 +274,6 @@ html>body #ajax-indicator { position: fixed; }
.white_bg {background: #fff}
.user_tab_type {background: #FF6610}
.course_filtrate{width: 70px;text-align: center;background: #fff;border-radius: 10px;margin-right: 10px}
.course_filtrate:hover{background: #FFDAC1; color: #FF6610;}
.course_filtrate_bg{background: #FFDAC1; color: #FF6610!important;}