commit
5ea68dcd7d
@ -0,0 +1,3 @@
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>");
|
||||
|
||||
init_KindEditor_data('<%= @user_activity_id%>');
|
@ -0,0 +1,74 @@
|
||||
<div class="homepageRight">
|
||||
<div class="HomeWork">
|
||||
<div class="RightBanner">
|
||||
<div class="NewsBannerName">发布作业</div>
|
||||
</div>
|
||||
<div class="HomeWorkCon">
|
||||
<div class="mt15">
|
||||
<textarea class="InputBox W700 " placeholder="请输入作业标题" name="homework_common[name]" id="homework_name" maxlength="255" onkeyup="regex_homework_name();" value="<%= homework.name%>"></textarea>
|
||||
</div>
|
||||
<div class=" mt10">
|
||||
<a href="javascript:void(0);" class="BlueCirBtn fl mr10">导入作业</a>
|
||||
<input type="text" name="homework_common[end_time]" id="homework_end_time" class="InputBox fl W120 date-input" readonly="readonly" value="<%= homework.end_time%>" placeholder="截止日期"></input>
|
||||
<div class="fl DateBorder mr10"><a href="javascript:void(0);" class="pic_date"></a></div>
|
||||
<input type="text" name="homework_common[publish_time]" id="homework_publish_time" class="InputBox fl W120 date-input" readonly="readonly" value="<%= homework.publish_time%>" placeholder="发布日期"></input>
|
||||
<div class="fl DateBorder"><a href="javascript:void(0);" class="pic_date"></a></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<% if edit_mode %>
|
||||
<%= f.kindeditor :description,:editor_id => 'homework_description_editor',:owner_id => homework.id,:owner_type =>OwnerTypeHelper::HOMEWORKCOMMON %>
|
||||
<% else %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
<%= f.kindeditor :description,:editor_id => 'homework_description_editor' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<textarea class="InputBox W700 SearchIcon" placeholder="发送到课程" style="margin-top: 0px; margin-bottom: 0px; height: 29px;"></textarea>
|
||||
</div>
|
||||
<div class="mt5">
|
||||
<a href="javascript:void(0);" class="AnnexBtn fl mt3">上传附件</a>
|
||||
<a href="javascript:void(0);" class="FilesBtn fl mr15 mt3">资源库</a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
||||
<div class="mt10">
|
||||
<a href="javascript:void(0);" class=" fl DropBtn">高级功能</a>
|
||||
<div class="DropLine"></div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="advanced_option" style="display:none;">
|
||||
<div class="mt10">
|
||||
<select class="InputBox W120" required="true">
|
||||
<option value="语言选择">语言选择</option>
|
||||
<option value="C语言">C语言</option>
|
||||
<option value="C++">C++</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mt10">
|
||||
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required></textarea>
|
||||
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<a href="javascript:void(0);" onClick="submit_homework('new_homework_common');" class="BlueCirBtnMini fr">发布</a>
|
||||
<span class="fr mr10 mt3">或</span><%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'fr mr10 mt3'%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!----HomeWork end-->
|
||||
|
||||
</div>
|
||||
|
||||
<script id="t:test-answer-list" type="text/html">
|
||||
<div class="mt10">
|
||||
<textarea class="InputBox W320 fl mr10" placeholder="测试输入" required></textarea><textarea class="InputBox W320 fl mr5" placeholder="测试输出" required></textarea>
|
||||
<a href="javascript:void(0);" class=" fl icon_add" title="增加测试组"></a>
|
||||
<a href="javascript:void(0);" class=" fl icon_remove" title="删除测试组"></a>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
</script>
|
||||
|
@ -1,17 +1,16 @@
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor" %>
|
||||
<% content_for :header_tags do %>
|
||||
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
|
||||
<%= javascript_include_tag 'homework','baiduTemplate' %>
|
||||
<% end %>
|
||||
|
||||
<%= error_messages_for 'homework_common' %>
|
||||
<div class="project_r_h">
|
||||
<h2 class="project_h2">
|
||||
<%= l(:label_course_homework_new)%>
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="hwork_new">
|
||||
<%= labelled_form_for @homework,:url => {:controller => 'homework_common',:action => 'create'} do |f| %>
|
||||
<%= hidden_field_tag "course",@course.id%>
|
||||
<%= render :partial => 'homework_common/homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
|
||||
<a href="javascript:void(0)" class="blue_btn fl mr10" onClick="submit_homework('new_homework_common');" >提交</a>
|
||||
<%#= link_to "上一步", new_homework_common_path(:course => @course.id), :class => "orange_btn_homework fl"%>
|
||||
<%= link_to '取消',homework_common_index_path(:course => @course.id),:class => 'grey_btn fl'%>
|
||||
<%= render :partial => 'homework_common/new_homework_detail_manual_form', :locals => { :homework => @homework,:f => f,:edit_mode => false } %>
|
||||
<% end%>
|
||||
</div><!--hwork_new end-->
|
||||
|
||||
|
||||
<div class="cl"></div>
|
||||
|
@ -0,0 +1,3 @@
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>");
|
||||
|
||||
init_KindEditor_data(<%= @user_activity_id%>);
|
@ -0,0 +1,6 @@
|
||||
<%if @project%>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
|
||||
<%elsif @course%>
|
||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>");
|
||||
<%end%>
|
||||
init_KindEditor_data(<%= @user_activity_id%>);
|
@ -1,26 +1,67 @@
|
||||
<div class="coursesChoosePopup" id="coursesChoosePopup">
|
||||
<script>
|
||||
// $(document).ready(function(){
|
||||
//// var popupHeight = $(".referenceResourcesPopup").outerHeight(true);
|
||||
//// $(".referenceResourcesPopup").css("marginTop",-popupHeight/2);
|
||||
//
|
||||
//
|
||||
// $(".resourcePopupClose").click(function(){
|
||||
// $(".referenceResourcesPopup").css("display","none");
|
||||
// });
|
||||
// });
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".referenceTypeBlock").click(function(){
|
||||
var activeBlock = $(".referenceResourceType").children(".referenceTypeActive");
|
||||
activeBlock.removeClass("referenceTypeActive");
|
||||
$(this).addClass("referenceTypeActive");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!--<div class="referenceResourcesPopup">-->
|
||||
<div>
|
||||
<div class="sendText">资源库</div>
|
||||
<div class="referenceText">引用资源库资源</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form class="coursesSearchBox">
|
||||
<input type="text" name="homework_name" placeholder="输入资源名称进行搜索" class="searchCoursesPopup" id="search_homework_name"/>
|
||||
<a href="javascript:void(0);" class="searchIconPopup" onclick="search_homework_by_name('<%= user_search_homeworks_user_path(User.current.id)%>');"></a>
|
||||
</form>
|
||||
<div class="referenceResourceType fl">
|
||||
<a href="<%= user_resource_type_user_path(user)%>" class="referenceTypeBlock referenceTypeActive" data-remote="true" >资源库</a>
|
||||
<a href="<%= user_resource_type_user_path(user,:type=>'2')%>" class="referenceTypeBlock" data-remote="true">课程资源</a>
|
||||
<a href="<%= user_resource_type_user_path(user,:type=>'3')%>" class="referenceTypeBlock" data-remote="true">项目资源</a>
|
||||
<a href="<%= user_resource_type_user_path(user,:type=>'5')%>" class="referenceTypeBlock" data-remote="true">用户资源</a>
|
||||
<a href="<%= user_resource_type_user_path(user,:type=>'4')%>" class="referenceTypeBlock" data-remote="true">附件</a> </div>
|
||||
<div class="fr">
|
||||
<!--<form class="referenceSearchBox">-->
|
||||
<%= form_tag(user_ref_resource_search_user_path(user),:method => 'get',:remote=>'true',:class=>'referenceSearchBox') do%>
|
||||
<input type="text" name="search" placeholder="输入资源关键词进行搜索" class="searchReferencePopup" />
|
||||
<a href="javascript:void(0);" onclick="$(this).parent().submit();" class="referenceSearchIcon"></a>
|
||||
<% end %>
|
||||
<!--</form>-->
|
||||
</div>
|
||||
<%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %>
|
||||
<div class="homeworkListForm mb10 " id="homework_list_form_show">
|
||||
<%= render :partial => 'users/show_user_homework_form', :locals => {:user_homeworks => @user_homeworks}%>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="courseSendSubmit">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="$('#select_homework_form').submit();">确定</a>
|
||||
<div class="resourcesListBanner">
|
||||
<ul class="resourcesListTab">
|
||||
<li class="resourcesListCheckbox fl"> </li>
|
||||
<li class="resourcesListName fl">资源名称</li>
|
||||
<li class="resourcesListSize fl">大小</li>
|
||||
<li class="resourcesListType fl">类别</li>
|
||||
<li class="resourcesListUploader fl">上传者</li>
|
||||
<li class="resourcesListTime fl">上传时间</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="courseSendCancel">
|
||||
<a href="javascript:void(0);" class="sendSourceText" onclick="hideModal('#coursesChoosePopup')">取消</a>
|
||||
<%= form_tag(import_resources_to_homework_user_path(user),:method => 'post',:remote=>'true') do %>
|
||||
<input type="hidden" name="homework_id" value="<%= homework_id%>"/>
|
||||
<div style="height: 300px" id="user_ref_resources">
|
||||
<%= render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments} %>
|
||||
</div>
|
||||
<div >
|
||||
<ul class="wlist" id="resource_ref_pages" style="margin-top: 5px;">
|
||||
<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
|
||||
</ul>
|
||||
</div>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
<div>
|
||||
<div class="courseSendSubmit"><a href="javascript:void(0);" onclick="$(this).parent().parent().parent().submit();" class="sendSourceText">确定</a></div>
|
||||
<div class="courseSendCancel"><a href="javascript:void(0);" onclick="hideModal();" class="sendSourceText">取消</a></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<% end %>
|
||||
<!--</div>-->
|
||||
|
@ -1,4 +1,9 @@
|
||||
<% if @flag == true%>
|
||||
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
|
||||
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
|
||||
$("#res_count").html(0);
|
||||
$("#checkboxAll").attr('checked',false);
|
||||
$("#res_all_count").html(<%= @atta_count%>);
|
||||
closePopUp();
|
||||
<% else%>
|
||||
<% end %>
|
@ -1,4 +1,9 @@
|
||||
<% if @flag == true%>
|
||||
$("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} ) %>');
|
||||
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
|
||||
$("#res_count").html(0);
|
||||
$("#checkboxAll").attr('checked',false);
|
||||
$("#res_all_count").html(<%= @atta_count%>);
|
||||
closePopUp();
|
||||
<% else%>
|
||||
<% end %>
|
@ -0,0 +1,16 @@
|
||||
<% unless @attachments.empty?%>
|
||||
<% @attachments.each_with_index do |attachment, i| %>
|
||||
$("#attachments_fields").append(
|
||||
'<span id="attachments_p<%= i %>">'+
|
||||
'<%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => "filename link_file", :readonly=>"readonly")%>'+
|
||||
'<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => "description", :style=>"display: inline-block;") %>'+
|
||||
'<span class="ispublic-label"><%= l(:field_is_public)%>:</span>'+
|
||||
'<%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => "is_public")%>'+
|
||||
'<%= link_to(" ".html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => "js"), :method => "delete", :remote => true, :class => "remove-upload") unless attachment.id.nil? %>'+
|
||||
'<%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>'+
|
||||
'</span>'+
|
||||
'<div class="cl"></div>')
|
||||
|
||||
<% end %>
|
||||
hideModal();
|
||||
<% end %>
|
@ -1,4 +1,2 @@
|
||||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page} )%>");
|
||||
<% if @user_activities.count < 10%>
|
||||
$(window).off("scroll", scrollHandler);
|
||||
<% end%>
|
||||
$("#show_more_activities").replaceWith("<%= escape_javascript( render :partial => 'users/user_activities',:locals => {:user_activities => @user_activities, :page => @page,:type => @type} )%>");
|
||||
|
||||
|
@ -1,4 +1,2 @@
|
||||
$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page} )%>");
|
||||
<% if @homework_commons.count < 10%>
|
||||
$(window).off("scroll", scrollHandler);
|
||||
<% end%>
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_homeworks') %>');
|
||||
showModal('ajax-modal', '580px');
|
||||
$('#ajax-modal').css('height','300px').css("width","580px");
|
||||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'users/show_user_resource',:locals => {:user => @user,:homework_id=>@homework_id}) %>');
|
||||
showModal('ajax-modal', '730px');
|
||||
$('#ajax-modal').css('height','500px').css("width","730px");
|
||||
$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
|
||||
"<a href='javascript:void(0)' onclick='hideModal();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
|
||||
$('#ajax-modal').parent().css("top","20%").css("left","25%").css("position","fixed");
|
||||
$('#ajax-modal').before("<div class='resourcePopupClose mt5 mr-5'>" +
|
||||
"<a href='javascript:void(0)' class='resourceClose' onclick='hideModal();'></a></div>");
|
||||
$('#ajax-modal').parent().css("top","").css("left","").css("position","fixed").css("padding-left","16px").css("padding-bottom","16px").css("padding-right","16px");
|
||||
$('#ajax-modal').parent().addClass("popbox").addClass("referenceResourcesPopup");
|
@ -0,0 +1,2 @@
|
||||
$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>');
|
||||
$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
@ -0,0 +1,2 @@
|
||||
$("#user_ref_resources").html('<%= escape_javascript(render :partial => 'resources_list',:locals=>{:attachments => @attachments})%>');
|
||||
$("#resource_ref_pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
|
@ -0,0 +1,13 @@
|
||||
class ChangeStudentWorkTests < ActiveRecord::Migration
|
||||
|
||||
def change
|
||||
change_table :student_work_tests do |t|
|
||||
t.remove :error_msg
|
||||
t.remove :result
|
||||
t.remove :homework_test_id
|
||||
t.integer :status, default: 9
|
||||
t.text :results
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddSrcToStudentWorkTests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :student_work_tests, :src, :text
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
class AboutMemoMessage < ActiveRecord::Migration
|
||||
def up
|
||||
Memo.all.each do |memo|
|
||||
transaction do
|
||||
# 贴吧帖子
|
||||
receivers = []
|
||||
u = User.find(6)
|
||||
receivers << u
|
||||
# 主贴
|
||||
if memo.parent_id.nil?
|
||||
if memo.author_id != memo.forum.creator_id # 发帖人不是吧主
|
||||
receivers << memo.forum.creator
|
||||
end
|
||||
else # 回帖
|
||||
# 添加吧主
|
||||
if memo.author_id != memo.forum.creator_id
|
||||
receivers << memo.forum.creator
|
||||
end
|
||||
# 添加发帖人
|
||||
unless memo.parent.nil?
|
||||
if memo.author_id != memo.parent.author_id
|
||||
receivers << memo.parent.author
|
||||
puts memo.id
|
||||
end
|
||||
end
|
||||
end
|
||||
receivers.each do |r|
|
||||
memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -0,0 +1,36 @@
|
||||
class AboutUserFeedbackMessage < ActiveRecord::Migration
|
||||
def up
|
||||
JournalsForMessage.all.each do |jour_for_message|
|
||||
transaction do
|
||||
# 主留言
|
||||
if jour_for_message.jour_type == 'Principal'
|
||||
receivers = []
|
||||
if jour_for_message.reply_id == 0
|
||||
if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息
|
||||
receivers << jour_for_message.jour
|
||||
end
|
||||
else # 留言回复
|
||||
reply_to = User.find(jour_for_message.reply_id)
|
||||
if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人
|
||||
receivers << reply_to
|
||||
end
|
||||
unless jour_for_message.parent.nil?
|
||||
if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发
|
||||
receivers << jour_for_message.parent.jour
|
||||
end
|
||||
end
|
||||
end
|
||||
unless receivers.blank?
|
||||
receivers.each do |r|
|
||||
puts jour_for_message.id
|
||||
jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
class UpdateMemoMessageTime < ActiveRecord::Migration
|
||||
def up
|
||||
memo_count = Memo.all.count / 30 + 1
|
||||
transaction do
|
||||
for i in 1 ... memo_count do i
|
||||
MemoMessage.page(i).per(30).each do |memo_message|
|
||||
if memo_message.memo
|
||||
if memo_message.memo.respond_to?("created_at")
|
||||
memo_message.created_at = memo_message.memo.created_at
|
||||
elsif memo_message.memo.respond_to?("created_on")
|
||||
memo_message.created_at = memo_message.memo.created_on
|
||||
end
|
||||
memo_message.save
|
||||
|
||||
memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first
|
||||
memo_messages.created_at = memo_message.created_at
|
||||
memo_messages.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -0,0 +1,27 @@
|
||||
class UpdateUserfeebackMessageTime < ActiveRecord::Migration
|
||||
def up
|
||||
user_feedback_count = UserFeedbackMessage.all.count / 30 + 1
|
||||
transaction do
|
||||
for i in 1 ... user_feedback_count do i
|
||||
UserFeedbackMessage.page(i).per(30).each do |ufm|
|
||||
if ufm.journals_for_message
|
||||
if ufm.journals_for_message.respond_to?("created_at")
|
||||
ufm.created_at = ufm.journals_for_message.created_at
|
||||
elsif ufm.journals_for_message.respond_to?("created_on")
|
||||
ufm.created_at = ufm.journals_for_message.created_on
|
||||
end
|
||||
puts ufm.id
|
||||
ufm.save
|
||||
|
||||
user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first
|
||||
user_feedback_messages.created_at = ufm.created_at
|
||||
user_feedback_messages.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,133 @@
|
||||
$(function(){
|
||||
//提交作业
|
||||
|
||||
var bt=baidu.template;
|
||||
bt.LEFT_DELIMITER='<!';
|
||||
bt.RIGHT_DELIMITER='!>';
|
||||
|
||||
var tested = false;
|
||||
var valid_form = function() {
|
||||
var src = $('#program-src').val();
|
||||
var title = $('#program-title').val();
|
||||
|
||||
if (!src) {
|
||||
alert('请输入正确的代码');
|
||||
return false;
|
||||
}
|
||||
if (!title) {
|
||||
alert('请输入标题');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
var test_program = function(cb){
|
||||
var homework_id = $('#test-program-btn').attr('data-homework-id');
|
||||
var student_work_id = $('#test-program-btn').attr('data-student-work-id');
|
||||
var src = $('#program-src').val();
|
||||
var title = $('#program-title').val();
|
||||
|
||||
if(!valid_form()){
|
||||
return;
|
||||
}
|
||||
|
||||
$.post(
|
||||
'/student_work/program_test',
|
||||
{homework: homework_id, student_work_id: student_work_id, src: src, title: title},
|
||||
function(data,status){
|
||||
tested = true;
|
||||
console.log(data);
|
||||
|
||||
if (typeof cb == 'function') {cb(); return;}
|
||||
|
||||
|
||||
var html=bt('t:result-list',data);
|
||||
$('.ProResult').prepend(html);
|
||||
|
||||
if (data.status==0) {
|
||||
var r=confirm("答题正确,是否立刻提交?");
|
||||
if (r) {
|
||||
$(".HomeWorkCon form").submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
$('#test-program-btn').on('click', test_program);
|
||||
|
||||
|
||||
$('#commit-program-work-btn').on('click', function(){
|
||||
if(!valid_form()){
|
||||
return;
|
||||
}
|
||||
if($('.ProResult .ProResultTop').length<=0){
|
||||
var r=confirm("测试后才能提交,是否立刻测试?");
|
||||
if (r) {
|
||||
test_program();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tested) {
|
||||
test_program(function(){
|
||||
$(".HomeWorkCon form").submit();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$(".HomeWorkCon form").submit();
|
||||
});
|
||||
|
||||
$('form.edit_student_work').on('keydown', '#program-src', function(){
|
||||
tested = false;
|
||||
});
|
||||
|
||||
|
||||
//发布作业
|
||||
var isProgramHomework = function(){
|
||||
return !$(".advanced_option").is(":hidden");
|
||||
}
|
||||
|
||||
var submit_comm_homework = function(id){
|
||||
var valid = true;
|
||||
if (isProgramHomework()) {
|
||||
$.each($('.advanced_option textarea.InputBox'), function(i, val){
|
||||
if ($(val).val().length<=0) {
|
||||
$(val).focus();
|
||||
valid = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (valid) {
|
||||
$('input[name=homework_type]').val(2);
|
||||
};
|
||||
}
|
||||
if (valid) {
|
||||
submit_homework(id);
|
||||
}
|
||||
}
|
||||
window.submit_comm_homework = submit_comm_homework;
|
||||
|
||||
var datepickerOptions={dateFormat:'yy-mm-dd',firstDay:0,showWeek:true,showOtherMonths:true,selectOtherMonths:true};
|
||||
|
||||
$('input.date-input').datepicker(datepickerOptions);
|
||||
|
||||
$('a.pic_date').on('click', function(){
|
||||
$(this).parent().prev().first().focus();
|
||||
})
|
||||
|
||||
|
||||
$('a.DropBtn').on('click', function(){
|
||||
$(".advanced_option").toggle();
|
||||
});
|
||||
|
||||
$(".HomeWork").on('click', 'a.icon_add', function(){
|
||||
var html = bt('t:test-answer-list', null);
|
||||
$(this).parent('.mt10').after(html);
|
||||
|
||||
});
|
||||
$(".HomeWork").on('click', 'a.icon_remove', function(){
|
||||
$(this).parent('.mt10').remove();
|
||||
});
|
||||
});
|
@ -0,0 +1,100 @@
|
||||
function init_editor(params){
|
||||
var editor = params.kindutil.create(params.textarea, {
|
||||
resizeType : 1,minWidth:"1px",width:"100%",height:"80px",
|
||||
items:['emoticons'],
|
||||
afterChange:function(){//按键事件
|
||||
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
||||
},
|
||||
afterCreate:function(){
|
||||
var toolbar = $("div[class='ke-toolbar']",params.div_form);
|
||||
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
|
||||
params.toolbar_container.append(toolbar);
|
||||
}
|
||||
}).loadPlugin('paste');
|
||||
return editor;
|
||||
}
|
||||
|
||||
function nh_check_field(params){
|
||||
var result=true;
|
||||
if(params.content!=undefined){
|
||||
if(params.content.isEmpty()){
|
||||
result=false;
|
||||
}
|
||||
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
||||
params.textarea.html(params.content.html());
|
||||
params.content.sync();
|
||||
if(params.content.isEmpty()){
|
||||
params.contentmsg.html('内容不能为空');
|
||||
params.contentmsg.css({color:'#ff0000'});
|
||||
}else{
|
||||
params.contentmsg.html('填写正确');
|
||||
params.contentmsg.css({color:'#008000'});
|
||||
}
|
||||
params.contentmsg.show();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function init_form(params){
|
||||
params.form.submit(function(){
|
||||
var flag = false;
|
||||
if(params.form.attr('data-remote') != undefined ){
|
||||
flag = true
|
||||
}
|
||||
var is_checked = nh_check_field({
|
||||
issubmit:true,
|
||||
content:params.editor,
|
||||
contentmsg:params.contentmsg,
|
||||
textarea:params.textarea
|
||||
});
|
||||
if(is_checked){
|
||||
if(flag){
|
||||
return true;
|
||||
}else{
|
||||
$(this)[0].submit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
function nh_reset_form(params){
|
||||
params.form[0].reset();
|
||||
params.textarea.empty();
|
||||
if(params.editor != undefined){
|
||||
params.editor.html(params.textarea.html());
|
||||
}
|
||||
params.contentmsg.hide();
|
||||
}
|
||||
|
||||
function init_KindEditor_data(id){
|
||||
KindEditor.ready(function (K) {
|
||||
$("div[nhname='new_message_" + id + "']").each(function () {
|
||||
var params = {};
|
||||
params.kindutil = K;
|
||||
params.div_form = $(this);
|
||||
params.form = $("form", params.div_form);
|
||||
if (params.form == undefined || params.form.length == 0) {
|
||||
return;
|
||||
}
|
||||
params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form);
|
||||
params.contentmsg = $("p[nhname='contentmsg_" + id + "']", params.div_form);
|
||||
params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
|
||||
params.cancel_btn = $("#new_message_cancel_btn_" + id);
|
||||
params.submit_btn = $("#new_message_submit_btn_" + id);
|
||||
|
||||
if (params.textarea.data('init') == undefined) {
|
||||
params.editor = init_editor(params);
|
||||
init_form(params);
|
||||
params.cancel_btn.click(function () {
|
||||
nh_reset_form(params);
|
||||
});
|
||||
params.submit_btn.click(function () {
|
||||
params.form.submit();
|
||||
});
|
||||
params.textarea.data('init', 1);
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue