This commit is contained in:
cxt 2015-09-16 15:40:24 +08:00
commit 3bdab22aca
59 changed files with 188 additions and 69 deletions

View File

@ -218,11 +218,11 @@ class HomeworkCommonController < ApplicationController
#关闭匿评
def stop_anonymous_comment
@homework_detail_manual.update_column('comment_status', 3)
#计算缺评扣分---->计算缺评数量
work_ids = "(" + @homework.student_works.map(&:id).join(",") + ")"
@homework.student_works.each do |student_work|
absence_penalty_count = student_work.user.student_works_evaluation_distributions.where("student_work_id IN #{work_ids}").count - student_work.user.student_works_scores.where("student_work_id IN #{work_ids}").count
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count * @homework_detail_manual.absence_penalty : 0
student_work.absence_penalty = absence_penalty_count > 0 ? absence_penalty_count : 0
student_work.save
end

View File

@ -216,6 +216,7 @@ class ProjectsController < ApplicationController
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
format.js
end
else
respond_to do |format|

View File

@ -180,15 +180,15 @@ class StudentWorkController < ApplicationController
student_work.homework_common_id = @homework.id
student_work.user_id = User.current.id
student_work.save_attachments(params[:attachments])
render_attachment_warning_if_needed(student_work)
#提交作品时,计算是否迟交
if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = @homework.late_penalty
student_work.late_penalty = 1
else
student_work.late_penalty = 0
end
render_attachment_warning_if_needed(student_work)
if student_work.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)

View File

@ -419,6 +419,14 @@ class UsersController < ApplicationController
homework = HomeworkCommon.find(params[:homework])
student_work = StudentWork.where(homework_common_id: homework.id, user_id: User.current.id).first
if student_work
#提交作品时,计算是否迟交
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
student_work.late_penalty = 1
else
student_work.late_penalty = 0
end
student_work.save
flash[:notice] = l(:notice_successful_create)
redirect_to student_work_index_url(:homework => params[:homework])

View File

@ -2304,20 +2304,19 @@ module ApplicationHelper
# else
# link = "<span class='fr mr10 pr_join_span ' title='未开启匿评作业不可以启动匿评'>启动匿评</span>".html_safe
# end
if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
link = "<span class='fr mr10 pr_join_span ' title='作业截止日期之前不可以启动匿评'>启动匿评</span>".html_safe
link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.count >= 2 #作业份数大于2
case homework.homework_detail_manual.comment_status
when 1
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'fr mr10 work_edit'
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
when 2
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'fr mr10 work_edit'
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
when 3
link = "<span class='fr pr_join_span mr10' title='匿评结束'>匿评结束</span>".html_safe
link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end
else
link = "<span class='fr mr10 pr_join_span ' title='学生提交作业数大于2时才可以启动匿评'>启动匿评</span>".html_safe
link = link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "学生提交作业数大于2时才可以启动匿评"
end
link
end

View File

@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
include AvatarHelper
include StudentWorkHelper
module ProjectsHelper
def link_to_version(version, options = {})
return '' unless version && version.is_a?(Version)

View File

@ -2,17 +2,16 @@
include UserScoreHelper
module StudentWorkHelper
#获取当前用户的项目列表
def user_projects_option
cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1"
memberships = User.current.memberships.all(:conditions => cond)
projects = memberships.map(&:project)
projects = User.current.projects.visible
not_have_project = []
not_have_project << Setting.please_chose
not_have_project << "没有可选项目,请直接为本作品创建一个项目"
not_have_project << 0
type = []
type << not_have_project
projects.each do |project|
if project != nil
if project
option = []
option << project.name
option << project.id

View File

@ -3,5 +3,4 @@ showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","").css("left","");
$('#ajax-modal').parent().addClass("anonymos");
$('#ajax-modal').parent().css("top","30%").css("left","30%");

View File

@ -1,6 +1,6 @@
<% if @statue == 1%>
alert('启动成功');
$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "fr mr10 work_edit")%>');
$("#<%= @homework.id %>_start_anonymous_comment").replaceWith('<%= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');
<% elsif @statue == 2 %>
alert('启动失败\n作业总数大于等于2份时才能启动匿评');
<% elsif @statue == 3%>

View File

@ -33,36 +33,6 @@
</div>
<div class="cl"></div>
<div id="Container">
<div id="TopBar">
<div class="topbar_info02 fl">
<h2>
<a href="http://<%= Setting.host_course%>" target="_blank" class="c_blue">
<%= l(:label_courses_community)%>
</a>
</h2>
<p class="hiddent">
<%= l(:label_user_location) %> :
<%= link_to l(:field_homepage), home_path %>
>
<a href="http://<%= Setting.host_course%>">
<%=l(:label_courses_management_platform)%>
</a>
>
<%= link_to @course.name, course_path(@course) %>
</p>
</div>
<!--<div class="search fl">-->
<!--<%#= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get, :class => "search_form") do %>-->
<!--<input class="search_text fl" id="name" name="name" onkeyup="regexName('搜索条件不能为空');" placeholder="课程名称" type="text">-->
<!--<a href="javascript:void(0)" onclick="submitSerch('<%#= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >-->
<!--<%#= l(:label_search)%>-->
<!--</a>-->
<!--<div class="cl"></div>-->
<!--<span id="project_name_span" style="float: left"></span>-->
<!--<%# end %>-->
<!--</div>-->
</div><!--TopBar end-->
<div class="cl"></div>
<div id="content">
<div id="LSide" class="fl">
<div class="project_info">

View File

@ -109,9 +109,9 @@
<% end%>
<% end%>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses">
<ul>
<% courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%>
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" id="homepageLeftMenuCourses">
<ul>
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>
</ul>
</div>
@ -122,9 +122,9 @@
<%=link_to "", new_project_path, :class => "homepageMenuSetting fr", :title => "新建项目"%>
<% end%>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuForge">
<ul>
<% projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
<div class="homepageLeftMenuCourses <%= projects.empty? ? 'none' : ''%>" id="homepageLeftMenuForge">
<ul>
<%= render :partial => 'layouts/user_projects', :locals => {:projects => projects,:user => @user, :page => 0} %>
</ul>
</div>

View File

@ -0,0 +1,3 @@
$("#project_id").replaceWith("<%= escape_javascript(select_tag :project_id, options_for_select(user_projects_option), {:class => "InputBox W680 fl"})%>");
hideModal("#popbox02");
alert("创建成功");

View File

@ -0,0 +1,31 @@
<div class="BluePopupBox" id="popbox02">
<%= labelled_form_for(Project.new,:remote => "true") do |f| %>
<h2 class="BluePopuph2 fl">新建项目</h2>
<div class="cl"></div>
<div class="">
<div class="mt10 mb10">
<input type="text" class="none" />
<input class="InputBox W700" placeholder="项目名称" name="project[name]" id="project_name" onkeyup="regex_project_name();" />
<p id="project_name_error_msg" class="c_red"></p>
</div>
<div class="mb10">
<textarea class="InputBox W700" placeholder="项目描述" id="project_description" name="project[description]" onkeyup="regex_project_desc();"></textarea>
<p id="project_desc_error_msg" class="c_red"></p>
<script>
var text = document.getElementById("project_description");
autoTextarea(text);// 调用
</script>
</div>
<div class="fl">
<input type="checkbox" name="project[is_public]" class="mt5" checked value="1" /><label class=" ml5 ">公开</label>
</div>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_project();">确定</a>
<span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class=" fr mr10 mt3" onclick="clickCanel();">取消</a>
<div class="cl"></div>
</div>
<% end%>
<div class="cl"></div>
</div><!----BluePopupBox end-->

View File

@ -9,12 +9,18 @@
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","40%");
$('#ajax-modal').parent().addClass("anonymos_work");
// alert("当前作业已开启匿评,您提交作品后将不会收到任何匿评作品,您的作品也不会被其他用户匿评,如需获得最终成绩,请您联系主讲老师对您的作品单独进行评分");
});
<% end%>
//匿评弹框取消按钮
function clickCanel(){hideModal("#popbox02");}
//快速创建项目的弹框
function new_project(){
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'student_work/new_project') %>');
showModal('ajax-modal', '800px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed");
}
</script>
<div class="homepageRightBanner mb10">
@ -75,6 +81,18 @@
<%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %>
</div>
<div class="mt5 fl">
<a href="javascript:void(0);" class="RalationIcon fl mt3" onclick="show_project();">关联项目</a>
</div>
<div class="cl"></div>
<div class="mt10 none" id="about_project">
<%= select_tag :project_id, options_for_select(user_projects_option, @student_work.project_id), {:class => "InputBox W680 fl"} %>
<%#=link_to "", new_project_path, :class => "ml5 mt5 SetUpIcon fl", :title => "快速创建"%>
<a class=" ml5 mt5 SetUpIcon fl" href="javascript:void(0)" title="快速创建" onclick="new_project();"></a>
<div class="cl"></div>
</div>
<div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="new_student_work();">确定</a>
<span class="fr mr10 mt3">或</span>

View File

@ -48,7 +48,7 @@
<div class="mt5 fl">
<!-- , user_import_resource_user_path(User.current.id,:homework_id=>container.id) -->
<a href="javascript:void(0);" class="AnnexBtn fl mt3" onclick="$('#_file').click();">上传附件</a>
<%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mr15 mt3",:remote => true%>
<%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3",:remote => true%>
<% if defined?(has_program) && has_program %>
<a href="javascript:void(0);" class="ProBtn fl mt3">编程</a>
<span class="fl C_lgrey mt3 program_detail_info"></span>

View File

@ -47,6 +47,9 @@
<li>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
</li>
<li>
<%= homework_anonymous_comment homework_common %>
</li>
</ul>
</li>
</ul>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 762 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -180,6 +180,12 @@ function regexStudentWorkDescription()
}
}
//学生作品
function show_project()
{
$("#about_project").slideToggle();
}
//textarea自适应高度 纯js写的 有浏览器判断
/**
* 文本框根据输入内容自适应高度
@ -250,3 +256,62 @@ var autoTextarea = function (elem, extra, maxHeight) {
addEvent('focus', change);
change();
};
/////////////////////////////////////////////////////////////////////////////////////创建项目
//验证项目名称是不是为空
function regex_project_name(){
var name = $.trim($("#project_name").val());
if(name=="")
{
$("#project_name_error_msg").text("项目名称不能为空");
return false;
}
else
{
$("#project_name_error_msg").text("");
return true;
}
}
//验证项目名称是否重复---项目名称可以重复。。。。
function regex_project_name_same(){
var name = $.trim($("#project_name").val());
return true;
}
//验证项目描述
function regex_project_desc(){
var desc = $.trim($("#project_description").val());
if(desc == "")
{
$("#project_desc_error_msg").text("项目名称不能为空");
return false;
}
else
{
$("#project_desc_error_msg").text("");
return true;
}
}
//提交
function submit_project(){
if(regex_project_name()&&regex_project_desc()){
$("#new_project").submit();
}
}
/////////////////////////////////////////////////////////////////////////////////////创建项目 end
//匿评弹框取消按钮
function clickCanel(){hideModal("#popbox02");}
//匿评弹框确定按钮
function clickOK(path)
{
clickCanel();
$.ajax({
type: "GET",
url: path,
data: 'text',
success: function (data) {
}
});
}
/////////////////////////////////////////////////////////////////////////////////////////

View File

@ -890,7 +890,7 @@ a.FilesBtn{ background: url(../images/homepage_icon.png) 0px -373px no-repeat;
a:hover.FilesBtn{background: url(../images/homepage_icon.png) -89px -372px no-repeat; color:#3598db;}
a.BlueCirBtnMini{ display:block;width:40px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
a:hover.BlueCirBtnMini{ background:#3598db; color:#fff;}
a.ProBtn{background: url(../images/homepage_icon.png) -86px -396px no-repeat; width:35px; height:20px; display:block; padding-left:20px; color:#888888;}
a.ProBtn{background: url(../images/homepage_icon.png) -86px -396px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.ProBtn{background: url(../images/homepage_icon.png) -86px -426px no-repeat; color:#3598db;}
a.DropBtn{background: url(../images/homepage_icon.png) -125px -339px no-repeat; width:85px; height:20px; display:block; color:#888888; font-size:14px;}
@ -938,7 +938,7 @@ a:hover.UsersApBtn{border:1px solid #888888; }
.C_Blue{ color:#3598db;}
a.C_Blue{ color:#3598db;}
a:hover.C_Blue{ color:#297fb8;}
.BluePopupBox{ border:3px solid #3598db; padding:20px; background:#fff; width:707px;}
.BluePopupBox{ padding:20px; background:#fff; width:707px;}
/*.BluePopupBox:hover{ border:3px solid #297fb8; }*/
a.CloseBtn{background:url(../images/CloseBtn.png) 0px 0px no-repeat; width:13px; height:13px; display:block; float:right;}
a:hover.CloseBtn{background:url(../images/CloseBtn.png) 0px -24px no-repeat; }
@ -1116,3 +1116,25 @@ a:hover.tijiao{ background:#0f99a9;}
#cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;}
#cboxNext{position:absolute; bottom:0px; left:63px; color:#444;}
#cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;}
/*20150906关联项目LB*/
a.RalationIcon{ background: url(../images/homepage_icon.png) -183px -396px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}
a:hover.RalationIcon{background: url(../images/homepage_icon.png) -183px -428px no-repeat; color:#3598db;}
a.SetUpIcon{background: url(../images/homepage_icon.png) 0px -453px no-repeat; width:20px; height:20px; display:block; color:#888888;}
a:hover.SetUpIcon{background: url(../images/homepage_icon.png) 0px -486px no-repeat; color:#3598db;}
.W680{ width:680px;}
.W710{ width:708px;}
/* 开启匿评弹框 */
.anonymos{width:480px;height:180px;position:fixed !important;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.anonymos_work {position:fixed !important;left:60%;top:60%;margin:-215px 0 0 -300px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.ni_con { width:425px; margin:25px 30px;}
.ni_con h2{ display:block; height:40px; width:425px; text-align:center; color:#3a3a3a;}
.ni_con p{ color:#808181; }
.ni_con a:hover{ text-decoration:none;}
.ni_btn{ width:190px; margin:15px auto; line-height:1.9;}
a.tijiao{ height:28px; display:block; width:80px; color:#fff; background:#15bccf; text-align:center; padding-top:4px; float:left; margin-right:15px;}
a:hover.tijiao{ background:#0f99a9;}
.c_pink{ color:#e65d5e;}
.ni_con_work { width:300px; margin:25px 20px;}
.ni_con_work p{ color:#808181; }