Merge branch 'cxt_course' into szzh

This commit is contained in:
cxt 2015-12-15 16:03:15 +08:00
commit eb3e562e9a
16 changed files with 77 additions and 87 deletions

View File

@ -27,7 +27,7 @@ class ExerciseController < ApplicationController
if @is_teacher || User.current.admin?
exercises = @course.exercises.order("created_at asc")
else
exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc")
exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc")
end
@exercises = paginateHelper exercises,20 #分页
respond_to do |format|
@ -54,41 +54,26 @@ class ExerciseController < ApplicationController
end
@exercise = Exercise.find params[:id]
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
if @exercise.exercise_status != 2 && (!(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?))
render_403
return
end
exercise_end = @exercise.end_time > Time.now
if @exercise.time == -1
@can_edit_excercise = exercise_end
else
@can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin?
@can_edit_excercise = !has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end
end
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
# 学生点击的时候即创建关联,自动保存
#eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
# 已提交问卷的用户不能再访问该界面
=begin
if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?)
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
else
=end
if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id)
unless @is_teacher
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
if @exercise_user.nil?
eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
end
# @percent = get_percent(@exercise,User.current)
exercise_questions = @exercise.exercise_questions
@exercise_questions = paginateHelper exercise_questions,5 #分页
score = calculate_student_score(@exercise, User.current)
eu = get_exercise_user(@exercise.id, User.current.id)
eu.update_attributes(:score => score)
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
@exercise_user.update_attributes(:score => score)
end
# @percent = get_percent(@exercise,User.current)
@exercise_questions = @exercise.exercise_questions
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
#end
end
@ -537,12 +522,9 @@ class ExerciseController < ApplicationController
# @score = 100
if @uncomplete_question.count < 1
# 查看是否有已提交记录
eu = get_exercise_user(@exercise.id, User.current.id)
eu.user_id = User.current.id
eu.exercise_id = @exercise.id
eu.score = @score
if eu.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
cur_exercise_user.score = @score
if cur_exercise_user.save
#redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
else
@status = 2 #未知错误
@ -550,6 +532,7 @@ class ExerciseController < ApplicationController
else
@status = 1 #有未做得必答题
end
@save = params[:save].to_i if params[:save]
respond_to do |format|
format.js
end

View File

@ -1,12 +1,15 @@
<div id="popbox" style="text-align: center;margin-top: 25px">
<% if status == 0 && exercise.time != -1%>
<% if @save == 1 %>
<h3 style="font-weight: normal;color: green">保存成功,测验日期截止前您还可以继续答题。</h3>
<%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 0 && exercise.time != -1%>
<h3 style="font-weight: normal;color: green">提交成功!您的分数是:<%=@score %>分。</h3>
<%= link_to "确定", exercise_path(),:class => 'commit'%>
<% elsif status == 0 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S") %>
<h3 style="font-weight: normal;color: green">提交成功!</h3>
<h3 style="font-weight: normal;color: green">提交成功,测验日期截止前您还可以修改,祝您考高分。</h3>
<%= link_to "确定", exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") > Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
<h3 style="font-weight: normal;color: red">保存成功!</h3>
<h3 style="font-weight: normal;color: red">提交成功,您还有未完成的题目,测验日期截止前您还可以继续答题,祝您考高分。</h3>
<%= link_to "确定",exercise_index_path(:course_id => @course.id),:class => 'commit'%>
<% elsif status == 1 && Time.parse(format_time(exercise.end_time)).strftime("%Y-%m-%d %H:%M:%S") <= Time.now.strftime("%Y-%m-%d %H:%M:%S")%>
<h3 style="font-weight: normal;color: red">时间已到!</h3>

View File

@ -24,11 +24,11 @@
<!--<li><%#= link_to "导出", export_exercise_exercise_path(exercise.id,:format => "xls"), :class => "polls_de fr ml5"%></li>-->
<%# end%>
<% if exercise.exercise_status == 1 %>
<li><a href="javascript:" class="pollsbtn btn_pu fr mr5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li>
<li><a href="javascript:" class="pollsbtn btn_pu fr mr10 ml5" onclick="exercise_submit(<%= exercise.id%>,<%= exercise.exercise_name.length %>,<%=index.to_i %>);">发布试卷</a></li>
<% elsif exercise.exercise_status == 2%>
<li><a href="javascript:" class="pollsbtn btn_de fr mr5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li>
<li><a href="javascript:" class="pollsbtn btn_de fr mr10 ml5" onclick="republish_exercise(<%= exercise.id%>,<%=index.to_i %>);">取消发布</a></li>
<% else%>
<li class="pollsbtn fr mr10 pollsbtn_grey" style="margin-left: 5px;" >发布试卷</li>
<li class="pollsbtn fr mr10 pollsbtn_grey ml5">发布试卷</li>
<% end%>
<% if exercise.exercise_status == 1%>
@ -42,18 +42,24 @@
<% if exercise.exercise_status == 1 %>
<li><%= link_to l(:button_edit), edit_exercise_path(exercise.id), :class => "polls_de fr ml10"%></li>
<li class="polls_date fr"><%=exercise.publish_time.nil? ? "未发布" : "将于"+format_time(exercise.publish_time.to_s)+"发布"%></li>
<% else%>
<% elsif exercise.exercise_status == 2 %>
<li class="polls_de_grey fr ml10" title="未发布的试卷才能进行编辑">编辑</li>
<li class="polls_date fr">已发布</li>
<% else %>
<li class="polls_de_grey fr ml10" title="未发布的试卷才能进行编辑">编辑</li>
<li class="polls_date fr">已截止</li>
<% end%>
<% else%>
<% if exercise.exercise_status == 2%>
<% if exercise.exercise_status != 1%>
<%# if has_commit%>
<!--li><%#= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_st fl c_dblue" %></li>
<li class="pollsbtn_tip fl ml5">已答</li-->
<%#else%>
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%>
<%= link_to (index.to_i+1).to_s+". "+exercise_name, exercise_path(exercise.id), :class => "polls_title polls_title_st fl c_dblue"%>
<% if exercise.end_time <= Time.now && has_commit_exercise?(exercise.id, User.current.id) %>
<li class="pollsbtn_tip fl ml5">已答</li>
<% end %>
<%#end%>
<% end%>
<li class="polls_date fr mr10">截止时间:<%= format_time(exercise.end_time.to_s)%></li>

View File

@ -3,10 +3,6 @@
$("#RSide").removeAttr("id");
$("#homework_page_right").css("min-height",$("#LSide").height()-30);
$("#Container").css("width","1000px");
<%uncomplete_question =get_uncomplete_question(exercise, User.current) %>;
<% if (uncomplete_question.count < 1) %>
$("#exercise_submit_btn").html("提交");
<% end %>
var end_time = <%=exercise.end_time.to_i%>;
getTime(end_time);
/*start_time = new Date();
@ -104,11 +100,6 @@
{
obj.checked = false;
}
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
}
@ -163,11 +154,6 @@
{
obj.checked = false;
}
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
}
@ -210,11 +196,6 @@
success: function (data) {
var dataObj = eval(data);
obj.value = dataObj.text;
if(dataObj.complete == 1) {
$("#exercise_submit_btn").html("提交");
} else {
$("#exercise_submit_btn").html("保存");
}
}
});
@ -228,7 +209,8 @@
<% end %>
</div>
<div class="ur_buttons">
<%= link_to "保存",commit_exercise_exercise_path(exercise),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:80px;",:format => 'js',:remote=>true %>
<%= link_to "保存",commit_exercise_exercise_path(exercise,:save => 1),:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:format => 'js',:remote=>true %>
<%= link_to "提交",commit_exercise_exercise_path(exercise), :data => {:confirm => "您确定要提交吗?"},:id=>"exercise_submit_btn", :method => :post,:class => "ur_button_submit",:style => "margin-left:20px;",:format => 'js',:remote=>true %>
</div>
<div class="cl"></div>
<!--contentbox end-->

View File

@ -78,7 +78,7 @@
<% else %>
×
<% end %></span><br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
标准答案:<%= convert_to_char(standard_answer.first.exercise_choice_id.to_s) if !standard_answer.empty? %>
</div>
<div class="cl"></div>
<div class="ur_inputs">

View File

@ -38,9 +38,9 @@
$("#show_student_result_div").on('click',show_result);
<% else %>
$("#show_student_result_div").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_name_id").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_id_id").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_class_id").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_name_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_id_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#student_class_<%= exercise.id%>").attr("title","截止日期未到,暂不能查看学生答题结果");
<% end %>
});
function show_result() {
@ -56,13 +56,13 @@
<div id="show_student_result_div" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
<li>
<ul class="mt10 fl">
<li class="hworkStName mr15 mt16" title="姓名" id="student_name_id">
<li class="hworkStName mr15 mt16" title="姓名" id="student_name_<%= exercise.id%>">
<%=exercise.user.show_name %>
</li>
<li class="hworkStID mr10 mt16" title="学号" id="student_id_id">
<li class="hworkStID mr10 mt16" title="学号" id="student_id_<%= exercise.id%>">
<%= exercise.user.user_extensions.nil? ? "--" : exercise.user.user_extensions.student_id%>
</li>
<li class="hworkStID mt16" title="班级" id="student_class_id">
<li class="hworkStID mt16" title="班级" id="student_class_<%= exercise.id%>">
--
</li>
</ul>

View File

@ -1,6 +1,5 @@
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'commit_alert',:locals => {:status => @status,:exercise =>@exercise}) %>');
showModal('ajax-modal', '270px');
$('#ajax-modal').css('height','110px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<span style='float: right;cursor:pointer;'>" +
"<a href='javascript:' onclick='hidden_atert_form();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");

View File

@ -1 +1,9 @@
<%= render :partial => 'exercise_form'%>
<%= render :partial => 'exercise_form'%>
<script type="text/javascript">
$(function() {
<% if @exercise.exercise_name != "" && @exercise.end_time != "" %>
$("#polls_head_show").show();
$("#polls_head_edit").hide();
<% end %>
});
</script>

View File

@ -188,10 +188,10 @@
<%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
</div>
<% end %>
<% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count) %>
<% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count) %>
<div class="subNav">
<%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%>
<%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status=2").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
<%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
<%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
</div>
<% end %>

View File

@ -2,7 +2,11 @@
<div class="ni_con_work">
<p>
当前作业
<span class="c_pink">已开启匿评</span>
<% if @homework.homework_detail_manual.comment_status == 2 %>
<span class="c_pink">已开启匿评</span>
<% elsif @homework.homework_detail_manual.comment_status == 3 %>
<span class="c_pink">已关闭匿评</span>
<% end %>
您提交作品后将
<span class="c_pink">不会收到任何匿评作品</span>,
您的作品也

View File

@ -46,7 +46,12 @@
<% if @homework.homework_detail_group.base_on_project == 1 %>
<li>
<span class="tit_fb"> 关联项目:</span>
<%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
<% if work.project.is_public || User.current.member_of?(work.project) || User.current.admin? %>
<%= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
<% else %>
<span title ="该项目是私有的"><%=work.project.name %></span>
<% end %>
<%#= link_to( work.project.name, project_path(work.project.id), :class => "linkBlue" )%>
<span class="ml5">(综合评分:<font class="c_red"><%=work.project.project_score.score.to_i %></font>)</span>
</li>
<% end %>

View File

@ -51,7 +51,7 @@
<span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
<% end %>
<div class="homepagePostSubmitContainer">
<% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 %>
<% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(activity.course)%>
<% projects = cur_user_projects_for_homework activity %>
<% works = cur_user_works_for_homework activity %>
<% if works.nil? && projects.nil? %>
@ -105,8 +105,8 @@
</div>
<% activity.student_work_projects.where("is_leader = 1").each do |pro| %>
<div class="mr10 mb10 fl">
<% project = Project.find pro.project_id || User.current.member_of?(project) || User.current.admin? %>
<% if project.is_public || project.user_id == User.current.id %>
<% project = Project.find pro.project_id %>
<% if project.is_public || User.current.member_of?(project) || User.current.admin?%>
<%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %>
<% else %>
<%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %>

View File

@ -49,7 +49,7 @@
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
<% end %>
<div class="homepagePostSubmitContainer">
<% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1%>
<% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(homework_common.course) %>
<% projects = cur_user_projects_for_homework homework_common %>
<% works = cur_user_works_for_homework homework_common %>
<% if works.nil? && projects.nil? %>
@ -108,8 +108,8 @@
<% homework_common.student_work_projects.where("is_leader = 1").each do |pro| %>
<div class="mr10 mb10 fl">
<% project = Project.find pro.project_id %>
<% if project.is_public == 1 || User.current.member_of?(project) || User.current.admin? %>
<%=link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name) %>
<% if project.is_public || User.current.member_of?(project) || User.current.admin? %>
<%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %>
<% else %>
<%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %>
<% end %>

View File

@ -598,11 +598,11 @@ function regex_evaluation_end(){
}
var evaluation_start_time = new Date(evaluation_start);
var evaluation_end_time = new Date(evaluation_end);
if(evaluation_end_time > evaluation_start_time){
if(evaluation_end_time >= evaluation_start_time){
$("#homework_evaluation_end_time").text("");
return true;
}else{
$("#homework_evaluation_end_time").text("关闭匿评日期必须大于开启匿评日期");
$("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
return false;
}
}
@ -1387,4 +1387,4 @@ function submit_course_feedback() {
$("#course_feedback_new").submit();
var flag = true
}
}
}

View File

@ -213,11 +213,11 @@ function regex_evaluation_end(){
}
var evaluation_start_time = new Date(evaluation_start);
var evaluation_end_time = new Date(evaluation_end);
if(evaluation_end_time > evaluation_start_time){
if(evaluation_end_time >= evaluation_start_time){
$("#homework_evaluation_end_time").text("");
return true;
}else{
$("#homework_evaluation_end_time").text("关闭匿评日期必须大于开启匿评日期");
$("#homework_evaluation_end_time").text("关闭匿评日期不能小于开启匿评日期");
return false;
}
}

View File

@ -145,7 +145,7 @@ a:hover.btn_pu{ background:#3cb761;}
/*问卷提交时弹出框*/
.alert_box{width:250px;height:180px;position:fixed !important;z-index:100;left:60%;top:65%;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;}
.commit{height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 60px;margin-top: 4px;margin-right: 10px;}
.commit{font-size: 1.2em;height: 28px;display: block;width: 80px;color: #fff !important;background: #15bccf;text-align: center;padding-top: 4px;margin-left: 70px;margin-top: 4px;margin-right: 10px;}
/******确定弹框***********/
.poll_alert_form{width:140px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-100px 0 0 -150px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.polls_alert_btn_box{width: 100%;margin: 0 auto;padding-left: 45px;}