Merge branch 'develop' of http://git.trustie.net/jacknudt/trustieforge into develop

Conflicts:
	db/schema.rb

解决冲突
This commit is contained in:
huang 2015-12-16 10:02:08 +08:00
commit 41bb37d6d4
6 changed files with 89 additions and 72 deletions

View File

@ -1,8 +1,10 @@
class ExerciseController < ApplicationController
layout "base_courses"
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, :commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,:show_student_result]
before_filter :find_course, :only => [:index,:new,:create,:student_exercise_list]
before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy,
:commit_exercise, :commit_answer,:publish_exercise,:republish_exercise,
:show_student_result,:student_exercise_list]
before_filter :find_course, :only => [:index,:new,:create]
include ExerciseHelper
def index
@ -354,8 +356,20 @@ class ExerciseController < ApplicationController
end
def student_exercise_list
=begin
if @exercise.end_time <= Time.now
@course.student.each do |student|
if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,@exercise.id).empty?
ExerciseUser.create(:user_id => student.student_id, :exercise_id => @exercise.id, :start_at => @exercise.end_time, :status => true,:score=>0)
end
s_score = calculate_student_score(@exercise, student.student)
exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", student.student_id, @exercise.id).first
exercise_user.update_attributes(:score => s_score)
end
end
=end
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
@exercise = Exercise.find params[:id]
@all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc")
@exercise_count = @exercise.exercise_users.where('score is not NULL').count
if @is_teacher || (!@exercise.exercise_users.where(:user_id => User.current.id).empty? && @exercise.end_time <= Time.now)
@ -543,11 +557,11 @@ class ExerciseController < ApplicationController
def show_student_result
@user = User.find params[:user_id]
@can_edit_excercise = false
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
@exercise_questions = @exercise.exercise_questions
score = calculate_student_score(@exercise, @user)
eu = get_exercise_user(@exercise.id, @user.id)
eu.update_attributes(:score => score)
@exercise_user = ExerciseUser.where("user_id =? and exercise_id=?", @user.id, @exercise.id).first
respond_to do |format|
format.html {render :layout => 'base_courses'}
end
@ -565,15 +579,15 @@ class ExerciseController < ApplicationController
standard_answer = get_user_standard_answer(question, user)
unless answer.empty?
# 问答题有多个答案
if question.question_type == 3
if question.question_type == 3 && !standard_answer.empty?
if standard_answer.include?(answer.first.answer_text)
score1 = score1+ question.question_score unless question.question_score.nil?
end
elsif question.question_type == 1
elsif question.question_type == 1 && !standard_answer.nil?
if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id
score2 = score2 + question.question_score unless question.question_score.nil?
end
else
elsif question.question_type == 2 && !standard_answer.nil?
arr = get_mulscore(question, user)
if arr.to_i == standard_answer.exercise_choice_id
score3 = score3 + question.question_score unless question.question_score.nil?

View File

@ -1,22 +1,18 @@
<style type="text/css">
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;}
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
/*.ke-container{height: 80px !important;}*/
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
/*.ke-container{height: 80px !important;}*/
</style>
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<% end %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %>
<script >
init_KindEditor_data('',80);
</script>
@ -24,11 +20,11 @@
<h4><%= l(:label_leave_message) %></h4>
<% if !User.current.logged?%>
<div style="font-size: 14px;margin:20px;">
<%= l(:label_user_login_tips) %>
<%= link_to l(:label_user_login_new), signin_path %>
<hr/>
</div>
<div style="font-size: 14px;margin:20px;">
<%= l(:label_user_login_tips) %>
<%= link_to l(:label_user_login_new), signin_path %>
<hr/>
</div>
<% else %>
<div nhname='new_message_' style="display:none;">
<%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_course_message'}, :html=>{:id => "course_feedback_new"},:method => "post") do |f|%>
@ -59,37 +55,37 @@
$("#submit_feedback_course").one('click',function() {
$("#course_feedback_new").submit();
});
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
var params = {};
params.kindutil = K;
params.container = $(this).parent('div').parent('div');
params.div_form = $(">.respond-form",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55;
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
}
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea);
setTimeout(function(){
if(!params.div_form.is(':hidden')){
params.textarea.show();
params.textarea.focus();
params.textarea.hide();
}
},300);
params.textarea.data('init',1);
});
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
var params = {};
params.kindutil = K;
params.container = $(this).parent('div').parent('div');
params.div_form = $(">.respond-form",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
params.height = 55;
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
}
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea);
setTimeout(function(){
if(!params.div_form.is(':hidden')){
params.textarea.show();
params.textarea.focus();
params.textarea.hide();
}
},300);
params.textarea.data('init',1);
});
});
});
});
</script>

View File

@ -32,7 +32,7 @@
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
</div>
<div class="cl"></div>
<div class="ur_inputs">
@ -64,7 +64,7 @@
<div>
<div class="testEditTitle"> 第<%= list_index+1%>题:<%= exercise_question.question_title %>&nbsp;&nbsp;(<%= exercise_question.question_score %>分)
<br />
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %>
标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first%>
</div>
<div class="cl"></div>
<div class="ur_inputs">

View File

@ -35,17 +35,19 @@
});
$(function(){
<% if Time.parse(h(@exercise.end_time)).strftime("%Y-%m-%d-%H-%M-%S") <= Time.now.strftime("%Y-%m-%d-%H-%M-%S") %>
$("#show_student_result_div").on('click',show_result);
$("#show_student_result_div_<%= exercise.id%>").on('click',function() {
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user_id) %>';
});
<% else %>
$("#show_student_result_div").attr("title","截止日期未到,暂不能查看学生答题结果");
$("#show_student_result_div_<%= exercise.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() {
window.location.href = '<%=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
}
/*function show_result(id) {
window.location.href = '<%#=show_student_result_exercise_path(@exercise,:user_id => exercise.user.id) %>';
}*/
</script>
<ul class="hworkListRow" id="student_work_<%= exercise.id%>">
<li class="hworkList340 width530">
@ -53,7 +55,7 @@
<li class="hworkPortrait mt15 mr10">
<%= link_to(image_tag(url_to_avatar(exercise.user),:width =>"40",:height => "40"),user_activities_path(exercise.user)) %>
</li>
<div id="show_student_result_div" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
<div id="show_student_result_div_<%= exercise.id%>" style="cursor: pointer;" class="student_work_<%= exercise.id%>">
<li>
<ul class="mt10 fl">
<li class="hworkStName mr15 mt16" title="姓名" id="student_name_<%= exercise.id%>">

View File

@ -1,8 +1,4 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'blog' %>
<% end %>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %>
<script>
$(function() {
init_activity_KindEditor_data(<%= @document.id%>,null,"85%");

View File

@ -0,0 +1,9 @@
class DeleteExerciseUser < ActiveRecord::Migration
def up
eus=ExerciseUser.where("score is null and status=?",0)
eus.delete_all
end
def down
end
end