commit
177b211edd
@ -0,0 +1,54 @@
|
|||||||
|
class ActivityNotifysController < ApplicationController
|
||||||
|
# layout 'base_projects'#by young
|
||||||
|
# default_search_scope :messages
|
||||||
|
before_filter :find_project_by_project_id#, :find_board_if_available
|
||||||
|
# before_filter :authorize, :except => [:new, :show, :create, :index]
|
||||||
|
# accept_rss_auth :index, :show
|
||||||
|
|
||||||
|
helper :activities
|
||||||
|
def index
|
||||||
|
query = nil
|
||||||
|
if @course
|
||||||
|
query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=?',@course.id,'Course',User.current.id);
|
||||||
|
else
|
||||||
|
@events_by_day = []
|
||||||
|
end
|
||||||
|
|
||||||
|
if( query != nil )
|
||||||
|
logger.info('xxoo')
|
||||||
|
limit = 10;
|
||||||
|
@obj_count = query.count();
|
||||||
|
@obj_pages = Paginator.new @obj_count,limit,params['page']
|
||||||
|
list = query.order('id desc').limit(limit).offset(@obj_pages.offset).all();
|
||||||
|
events=[];
|
||||||
|
for item in list
|
||||||
|
event = item.activity;
|
||||||
|
event.set_notify_id(item.id)
|
||||||
|
event.set_notify_is_read(item.is_read)
|
||||||
|
events << event
|
||||||
|
end
|
||||||
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||||
|
@controller_name = 'ActivityNotifys'
|
||||||
|
logger.info('aavv')
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {render :template => 'courses/show', :layout => 'base_courses'}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def chang_read_flag
|
||||||
|
if @course
|
||||||
|
if(params[:an_id] != nil )
|
||||||
|
query = ActivityNotify.where('id=? and notify_to=?',params[:an_id],User.current.id)
|
||||||
|
else
|
||||||
|
query = ActivityNotify.where('activity_container_id=? and activity_container_type=? and notify_to=? and is_read=0',@course.id,'Course',User.current.id)
|
||||||
|
end
|
||||||
|
@result = query.update_all('is_read=1');
|
||||||
|
else
|
||||||
|
@result = false;
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{render :layout => nil}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,3 @@
|
|||||||
|
class ActivityNotify < ActiveRecord::Base
|
||||||
|
belongs_to :activity, polymorphic: true
|
||||||
|
end
|
@ -0,0 +1,12 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
#
|
||||||
|
class OfficeConverTask
|
||||||
|
def conver(source_file, saved_file)
|
||||||
|
office = Trustie::Utils::Office.new(source_file)
|
||||||
|
if office.conver(saved_file)
|
||||||
|
Rails.logger.info "process ok: #{saved_file} "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
handle_asynchronously :conver,:queue => 'office_conver'
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1 @@
|
|||||||
|
<%= @result == false ? 'false' : 'true' %>
|
@ -1,26 +1,30 @@
|
|||||||
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
|
<% if @is_destroy%>
|
||||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
$("#attachment_<%= @attachment.id%>").remove();
|
||||||
var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
|
<%else%>
|
||||||
if(containerid==undefined){
|
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
|
||||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
||||||
var count=$('#attachments_fields>span').length;
|
var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
|
||||||
if(count<=0){
|
if(containerid==undefined){
|
||||||
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||||
$(".remove_all").remove();
|
var count=$('#attachments_fields>span').length;
|
||||||
|
if(count<=0){
|
||||||
|
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
|
||||||
|
$(".remove_all").remove();
|
||||||
|
}else{
|
||||||
|
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||||
|
var count=$('#attachments_fields'+containerid+'>span').length;
|
||||||
|
if(count<=0){
|
||||||
|
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
|
||||||
|
var remove_all_html_obj = $(".remove_all").filter(function(index){
|
||||||
|
return $(this).data('containerid')==containerid;
|
||||||
|
});
|
||||||
|
remove_all_html_obj.remove();
|
||||||
|
}else{
|
||||||
|
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
||||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
<% end%>
|
||||||
var count=$('#attachments_fields'+containerid+'>span').length;
|
|
||||||
if(count<=0){
|
|
||||||
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
|
|
||||||
var remove_all_html_obj = $(".remove_all").filter(function(index){
|
|
||||||
return $(this).data('containerid')==containerid;
|
|
||||||
});
|
|
||||||
remove_all_html_obj.remove();
|
|
||||||
}else{
|
|
||||||
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
@ -1,32 +1,32 @@
|
|||||||
<li class="w70 ">
|
<li class="hwork_num ">
|
||||||
<span href="javascript:void(0);" class="c_dark f14 fb fl ">学号</span>
|
<a href="javascript:void(0);" class=" f14 f_b c_dark fl" >学号</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="w70">
|
<li class=" hwork_name f14 fb c_dark">
|
||||||
<span class="c_dark f14 fb fl ">学生姓名</span>
|
学生姓名
|
||||||
</li>
|
</li>
|
||||||
<li class="hwork_tit">
|
<li class="hwork_tit">
|
||||||
<span class="c_dark f14 fb fl">作品名称</span>
|
<span class="c_dark f14 fb fl">作品名称</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="w70 mr5" >
|
<li class="mr5 w70">
|
||||||
<%= link_to "教师评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
<%= link_to "教师评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teacher_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl hwork_code"%>
|
||||||
<% if @show_all && @order == "teacher_score"%>
|
<% if @show_all && @order == "teacher_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w70 mr5">
|
<li class="mr5 w70">
|
||||||
<%= link_to "教辅评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
<%= link_to "教辅评分",@show_all ? student_work_index_path(:homework => @homework.id,:order => "teaching_asistant_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl hwork_code"%>
|
||||||
<% if @show_all && @order == "teaching_asistant_score"%>
|
<% if @show_all && @order == "teaching_asistant_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w60 mr5 ml10">
|
<li class="mr5 ml15 w40">
|
||||||
<%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
<%= link_to "匿评",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
|
||||||
<% if @show_all && @order == "student_score"%>
|
<% if @show_all && @order == "student_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
</li>
|
</li>
|
||||||
<li class="w40 ml10" id="final_sort">
|
<li class="ml30">
|
||||||
<%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "c_dark f14 fb fl"%>
|
<%= link_to "成绩",@show_all ? student_work_index_path(:homework => @homework.id,:order => "final_score", :sort => @score, :name => @name) : "javascript:void(0)",:class => "f14 f_b c_dark fl"%>
|
||||||
<% if @show_all && @order == "final_score"%>
|
<% if @show_all && @order == "final_score"%>
|
||||||
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
<a href="javascript:void(0);" class="<%= @score == 'desc' ? 'st_up' : 'st_down'%>" ></a>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<% for attachment in attachments %>
|
<% attachments.each_with_index do |attachment,i| %>
|
||||||
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%>
|
<div id="attachment_<%= attachment.id%>">
|
||||||
<span class="ml5">(<%= number_to_human_size attachment.filesize %>)</span>
|
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%>
|
||||||
<div class="cl"></div>
|
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :title => '删除', :class => 'remove-upload', :confirm => l(:text_are_you_sure)) if attachment.id && User.current == attachment.author %>
|
||||||
|
<span class="ml5">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
class CreateActivityNotifies < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :activity_notifies do |t|
|
||||||
|
t.integer :activity_container_id
|
||||||
|
t.string :activity_container_type
|
||||||
|
t.integer :activity_id
|
||||||
|
t.string :activity_type
|
||||||
|
t.integer :notify_to
|
||||||
|
t.datetime :created_on
|
||||||
|
t.integer :is_read
|
||||||
|
|
||||||
|
end
|
||||||
|
add_index "activity_notifies", ["notify_to"], :name => "index_an_notify_to"
|
||||||
|
add_index "activity_notifies", ["created_on"], :name => "index_an_created_on"
|
||||||
|
add_index "activity_notifies", ["activity_container_id","activity_container_type"], :name => "index_an_activity_container_id"
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,42 @@
|
|||||||
|
module Trustie
|
||||||
|
module Utils
|
||||||
|
class Office
|
||||||
|
|
||||||
|
def initialize(file)
|
||||||
|
@file = file
|
||||||
|
end
|
||||||
|
|
||||||
|
def office?
|
||||||
|
%w(doc docx ppt pptx xls xlsx pdf).any?{|word| @file.downcase.end_with?(word)}
|
||||||
|
end
|
||||||
|
|
||||||
|
def conver(saved_file, force=false)
|
||||||
|
if force || !File.exist?(saved_file)
|
||||||
|
if File.exist? @file
|
||||||
|
if office?
|
||||||
|
begin
|
||||||
|
resource = RestClient::Resource.new(
|
||||||
|
'http://192.168.80.107/Any2HtmlHandler.ashx',
|
||||||
|
:timeout => -1,
|
||||||
|
:open_timeout => -1
|
||||||
|
)
|
||||||
|
req = resource.post :txtDes => File.new(@file, 'rb')
|
||||||
|
File.open(saved_file, "wb+") do |f|
|
||||||
|
f.write(req.body)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
rescue =>e
|
||||||
|
puts e.message
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
puts "can't find file #{@file}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,170 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* KindEditor - WYSIWYG HTML Editor for Internet
|
||||||
|
* Copyright (C) 2006-2011 kindsoft.net
|
||||||
|
*
|
||||||
|
* @author Roddy <luolonghao@gmail.com>
|
||||||
|
* @site http://www.kindsoft.net/
|
||||||
|
* @licence http://www.kindsoft.net/license.php
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
KindEditor.plugin('media', function(K) {
|
||||||
|
var self = this, name = 'media', lang = self.lang(name + '.'),
|
||||||
|
allowMediaUpload = K.undef(self.allowMediaUpload, true),
|
||||||
|
allowFileManager = K.undef(self.allowFileManager, false),
|
||||||
|
formatUploadUrl = K.undef(self.formatUploadUrl, true),
|
||||||
|
extraParams = K.undef(self.extraFileUploadParams, {}),
|
||||||
|
filePostName = K.undef(self.filePostName, 'imgFile'),
|
||||||
|
uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php');
|
||||||
|
self.plugin.media = {
|
||||||
|
edit : function() {
|
||||||
|
var html = [
|
||||||
|
'<div style="padding:20px;">',
|
||||||
|
//url
|
||||||
|
'<div class="ke-dialog-row">',
|
||||||
|
'<label for="keUrl" style="width:60px;">' + lang.url + '</label>',
|
||||||
|
'<input class="ke-input-text" type="text" id="keUrl" name="url" value="" style="width:160px;" /> ',
|
||||||
|
'<input type="button" class="ke-upload-button" value="' + lang.upload + '" /> ',
|
||||||
|
'<span class="ke-button-common ke-button-outer">',
|
||||||
|
'<input type="button" class="ke-button-common ke-button" name="viewServer" value="' + lang.viewServer + '" />',
|
||||||
|
'</span>',
|
||||||
|
'</div>',
|
||||||
|
//width
|
||||||
|
'<div class="ke-dialog-row">',
|
||||||
|
'<label for="keWidth" style="width:60px;">' + lang.width + '</label>',
|
||||||
|
'<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="550" maxlength="4" />',
|
||||||
|
'</div>',
|
||||||
|
//height
|
||||||
|
'<div class="ke-dialog-row">',
|
||||||
|
'<label for="keHeight" style="width:60px;">' + lang.height + '</label>',
|
||||||
|
'<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="400" maxlength="4" />',
|
||||||
|
'</div>',
|
||||||
|
//autostart
|
||||||
|
'<div class="ke-dialog-row">',
|
||||||
|
'<label for="keAutostart">' + lang.autostart + '</label>',
|
||||||
|
'<input type="checkbox" id="keAutostart" name="autostart" value="" /> ',
|
||||||
|
'</div>',
|
||||||
|
'</div>'
|
||||||
|
].join('');
|
||||||
|
var dialog = self.createDialog({
|
||||||
|
name : name,
|
||||||
|
width : 450,
|
||||||
|
height : 230,
|
||||||
|
title : self.lang(name),
|
||||||
|
body : html,
|
||||||
|
yesBtn : {
|
||||||
|
name : self.lang('yes'),
|
||||||
|
click : function(e) {
|
||||||
|
var url = K.trim(urlBox.val()),
|
||||||
|
width = widthBox.val(),
|
||||||
|
height = heightBox.val();
|
||||||
|
if (url == 'http://' || K.invalidUrl(url)) {
|
||||||
|
alert(self.lang('invalidUrl'));
|
||||||
|
urlBox[0].focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/^\d*$/.test(width)) {
|
||||||
|
alert(self.lang('invalidWidth'));
|
||||||
|
widthBox[0].focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!/^\d*$/.test(height)) {
|
||||||
|
alert(self.lang('invalidHeight'));
|
||||||
|
heightBox[0].focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var html = K.mediaImg(self.themesPath + 'common/blank.gif', {
|
||||||
|
src : url,
|
||||||
|
type : K.mediaType(url),
|
||||||
|
width : width,
|
||||||
|
height : height,
|
||||||
|
autostart : autostartBox[0].checked ? 'true' : 'false',
|
||||||
|
loop : 'true'
|
||||||
|
});
|
||||||
|
self.insertHtml(html).hideDialog().focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
div = dialog.div,
|
||||||
|
urlBox = K('[name="url"]', div),
|
||||||
|
viewServerBtn = K('[name="viewServer"]', div),
|
||||||
|
widthBox = K('[name="width"]', div),
|
||||||
|
heightBox = K('[name="height"]', div),
|
||||||
|
autostartBox = K('[name="autostart"]', div);
|
||||||
|
urlBox.val('http://');
|
||||||
|
|
||||||
|
if (allowMediaUpload) {
|
||||||
|
var uploadbutton = K.uploadbutton({
|
||||||
|
button : K('.ke-upload-button', div)[0],
|
||||||
|
fieldName : filePostName,
|
||||||
|
extraParams : extraParams,
|
||||||
|
url : K.addParam(uploadJson, 'dir=media'),
|
||||||
|
afterUpload : function(data) {
|
||||||
|
dialog.hideLoading();
|
||||||
|
if (data.error === 0) {
|
||||||
|
var url = data.url;
|
||||||
|
if (formatUploadUrl) {
|
||||||
|
url = K.formatUrl(url, 'absolute');
|
||||||
|
}
|
||||||
|
urlBox.val(url);
|
||||||
|
if (self.afterUpload) {
|
||||||
|
self.afterUpload.call(self, url, data, name);
|
||||||
|
}
|
||||||
|
alert(self.lang('uploadSuccess'));
|
||||||
|
} else {
|
||||||
|
alert(data.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
afterError : function(html) {
|
||||||
|
dialog.hideLoading();
|
||||||
|
self.errorDialog(html);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
uploadbutton.fileBox.change(function(e) {
|
||||||
|
dialog.showLoading(self.lang('uploadLoading'));
|
||||||
|
uploadbutton.submit();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
K('.ke-upload-button', div).hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allowFileManager) {
|
||||||
|
viewServerBtn.click(function(e) {
|
||||||
|
self.loadPlugin('filemanager', function() {
|
||||||
|
self.plugin.filemanagerDialog({
|
||||||
|
viewType : 'LIST',
|
||||||
|
dirName : 'media',
|
||||||
|
clickFn : function(url, title) {
|
||||||
|
if (self.dialogs.length > 1) {
|
||||||
|
K('[name="url"]', div).val(url);
|
||||||
|
if (self.afterSelectFile) {
|
||||||
|
self.afterSelectFile.call(self, url);
|
||||||
|
}
|
||||||
|
self.hideDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
viewServerBtn.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
var img = self.plugin.getSelectedMedia();
|
||||||
|
if (img) {
|
||||||
|
var attrs = K.mediaAttrs(img.attr('data-ke-tag'));
|
||||||
|
urlBox.val(attrs.src);
|
||||||
|
widthBox.val(K.removeUnit(img.css('width')) || attrs.width || 0);
|
||||||
|
heightBox.val(K.removeUnit(img.css('height')) || attrs.height || 0);
|
||||||
|
autostartBox[0].checked = (attrs.autostart === 'true');
|
||||||
|
}
|
||||||
|
urlBox[0].focus();
|
||||||
|
urlBox[0].select();
|
||||||
|
},
|
||||||
|
'delete' : function() {
|
||||||
|
self.plugin.getSelectedMedia().remove();
|
||||||
|
// [IE] 删除图片后立即点击图片按钮出错
|
||||||
|
self.addBookmark();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
self.clickToolbar(name, self.plugin.media.edit);
|
||||||
|
});
|
After Width: | Height: | Size: 4.1 KiB |
Loading…
Reference in new issue