', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
- ).appendTo('#attachments_fields');
+ ).appendTo(attachments_frame);
if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
@@ -58,7 +59,42 @@ function addFile(inputEl, file, eagerUpload) {
}
return null;
}
+function addFile(inputEl, file, eagerUpload) {
+
+ var attachments_frame = '#attachments_fields';
+ if ($(attachments_frame).children().length < 30) {
+ deleteallfiles = $(inputEl).data('deleteAllFiles');
+ var attachmentId = addFile.nextAttachmentId++;
+
+ var fileSpan = $('
', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
+
+ fileSpan.append(
+ $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
+ $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload),
+ $(''+$(inputEl).data('fieldIsPublic')+':').attr({ 'class': 'ispublic-label' }) ,
+ $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload),
+ $(' ').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){
+ if(confirm($(inputEl).data('areYouSure'))){
+ removeFile();
+ if(!eagerUpload){
+ (function(e){
+ reload(e);
+ })(fileSpan);
+ }
+ }
+ }).toggle(!eagerUpload),
+ $('', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
+ ).appendTo('#attachments_fields');
+
+ if(eagerUpload) {
+ ajaxUpload(file, attachmentId, fileSpan, inputEl);
+
+ }
+ return attachmentId;
+ }
+ return null;
+}
addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
@@ -202,7 +238,26 @@ function addInputFiles(inputEl) {
//clearedFileInput.insertAfter('#attachments_fields');
}
+function addInputFiles_board(inputEl, id) {
+ // var clearedFileInput = $(inputEl).clone().val('');
+
+ if (inputEl.files) {
+ // upload files using ajax
+ uploadAndAttachFiles_board(inputEl.files, inputEl, id);
+ // $(inputEl).remove();
+ } else {
+ // browser not supporting the file API, upload on form submission
+ var attachmentId;
+ var aFilename = inputEl.value.split(/\/|\\/);
+ attachmentId = addFile_board(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false, id);
+ if (attachmentId) {
+ $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide();
+ $('#upload_file_count').html(""+count+""+$(inputEl).data('fileCount'));
+ }
+ }
+ //clearedFileInput.insertAfter('#attachments_fields');
+}
function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size');
@@ -218,7 +273,21 @@ function uploadAndAttachFiles(files, inputEl) {
$.each(files, function() {addFile(inputEl, this, true);});
}
}
+function uploadAndAttachFiles_board(files, inputEl, id) {
+ var maxFileSize = $(inputEl).data('max-file-size');
+ var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
+
+ var sizeExceeded = false;
+ $.each(files, function() {
+ if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
+ });
+ if (sizeExceeded) {
+ window.alert(maxFileSizeExceeded);
+ } else {
+ $.each(files, function() {addFile_board(inputEl, this, true, id);});
+ }
+}
function handleFileDropEvent(e) {
$(this).removeClass('fileover');
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index f49ef22f1..132cddadc 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -83,8 +83,8 @@ a:hover.talk_edit{ color:#ff5722;}
.talkpage_text{ border:1px solid #64bdd9; width:600px; color:#7d7d7d; padding:5px; margin:10px 0 10px 50px; background:#fff;}
/****新建讨论***/
.talk_new{ color:#4c4c4c;}
-.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;}
-.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
+.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;}
+.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
.talk_new ul li{ }
.sb{width:70px; height:26px; color:#606060; cursor:pointer;}
a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;}
@@ -364,6 +364,23 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;}
.reply_btn:hover{ background:#999; color:#fff; }
#attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+
+.attachments_fields input.description {margin-left:4px; width:100px; }
+.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
+.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+a.remove-upload:hover {text-decoration:none !important;}
+.attachments_fields input.is_public_checkbox {width:20px;}
+
+
+.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
+a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}
+.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;}
+span.add_attachment {font-size: 80%;line-height: 2.5em;}
+.attachments_fields span {display: block;white-space: nowrap;}
+.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);}
+.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
+.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;}
+
.ui-widget {
font-family: Verdana, sans-serif;
font-size: 1.1em;
diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css
index 98194b73c..14a7a9a34 100644
--- a/public/stylesheets/project.css
+++ b/public/stylesheets/project.css
@@ -123,8 +123,8 @@ a:hover.talk_edit{ color:#ff5722;}
.recall_con{ float:left;color:#777777; width:520px; margin-left:10px; }
/****新建讨论***/
.talk_new{ color:#4c4c4c;}
-.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;}
-.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
+.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;}
+.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
.talk_new ul li{ }
.sb{width:70px; height:26px; color:#606060; cursor:pointer;}
/*a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;}*/
@@ -254,7 +254,21 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;}
.reply_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #ccc; color:#999; border-radius:3px; padding:2px 10px; margin-bottom:10px;display: block;margin-left: 470px;}
.reply_btn:hover{ background:#999; color:#fff; }
+.attachments_fields input.description {margin-left:4px; width:100px; }
+.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
+.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+a.remove-upload:hover {text-decoration:none !important;}
+.attachments_fields input.is_public_checkbox {width:20px;}
+
+.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
+a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}
+.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;}
+span.add_attachment {font-size: 80%;line-height: 2.5em;}
+.attachments_fields span {display: block;white-space: nowrap;}
+.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);}
+.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
+.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;}
.ui-widget {
font-family: Verdana, sans-serif;
From 3fae37fa90911663b2bd1497ce4e114a0e85bb3c Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Wed, 13 May 2015 09:56:34 +0800
Subject: [PATCH 8/8] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=AD=A6=E7=94=9F?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=8B=E5=95=A6=E5=88=B7=E6=96=B0=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=EF=BC=8C=E6=9F=A5=E7=9C=8B=E5=8E=86=E6=AC=A1=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A=E6=88=90=E7=BB=A9=E7=9A=84=E4=B8=8B=E5=95=A6=E5=88=B7?=
=?UTF-8?q?=E6=96=B0=E6=98=BE=E7=A4=BAapi=E6=94=B9=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/api/mobile/apis/courses.rb | 20 ++++++++++++++++++++
app/api/mobile/apis/users.rb | 1 +
app/api/mobile/entities/homework_attach.rb | 1 -
app/api/mobile/entities/homeworkscore.rb | 18 ++++++++++++++++++
app/api/mobile/entities/member.rb | 1 +
app/services/courses_service.rb | 17 +++++++++++++++++
app/services/users_service.rb | 12 ++++++++----
db/schema.rb | 10 ++++++++++
8 files changed, 75 insertions(+), 5 deletions(-)
create mode 100644 app/api/mobile/entities/homeworkscore.rb
diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb
index 0d0c4651f..b2a2532bc 100644
--- a/app/api/mobile/apis/courses.rb
+++ b/app/api/mobile/apis/courses.rb
@@ -168,6 +168,14 @@ module Mobile
present :status, 0
end
+ desc "设置教辅"
+ params do
+
+ end
+ post 'set_user_as_assitant' do
+
+ end
+
desc "返回单个课程"
params do
requires :id, type: Integer
@@ -254,6 +262,18 @@ module Mobile
present :status, 0
end
+ desc '查看用户历次作业成绩'
+ params do
+ requires :token,type:String
+ requires :member_id,type:Integer,desc:'课程member_id'
+ optional :homeworkName,type:String,desc:'作业名称以及作业名称可能包含的字符'
+ end
+ get '/show_member_score/:member_id' do
+ cs = CoursesService.new
+ homeworkscore = cs.show_member_score params
+ present :data,homeworkscore,with: Mobile::Entities::Homeworkscore
+ present :status,0
+ end
end
end
end
diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb
index 063cfafae..3ef2c3237 100644
--- a/app/api/mobile/apis/users.rb
+++ b/app/api/mobile/apis/users.rb
@@ -83,6 +83,7 @@ module Mobile
params do
requires :name, type: String, desc: '用户名关键字'
requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱,3 昵称和姓名'
+ optional :is_search_assitant,type:Integer,desc:'是否搜索注册用户来作为助教'
end
get 'search/search_user' do
us = UsersService.new
diff --git a/app/api/mobile/entities/homework_attach.rb b/app/api/mobile/entities/homework_attach.rb
index 690ec8e94..2ad11fe36 100644
--- a/app/api/mobile/entities/homework_attach.rb
+++ b/app/api/mobile/entities/homework_attach.rb
@@ -37,7 +37,6 @@ module Mobile
f.send(:attachments)
end
end
- #homework_attach_expose :user
end
end
end
\ No newline at end of file
diff --git a/app/api/mobile/entities/homeworkscore.rb b/app/api/mobile/entities/homeworkscore.rb
new file mode 100644
index 000000000..e0c501c58
--- /dev/null
+++ b/app/api/mobile/entities/homeworkscore.rb
@@ -0,0 +1,18 @@
+module Mobile
+ module Entities
+ class Homeworkscore < Grape::Entity
+ include Redmine::I18n
+ include ApplicationHelper
+ def self.homeworkscore_expose(field)
+ expose field do |f,opt|
+ if f.is_a?(Hash) && f.key?(field)
+ f[field]
+ end
+ end
+ end
+
+ homeworkscore_expose :name
+ homeworkscore_expose :score
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/api/mobile/entities/member.rb b/app/api/mobile/entities/member.rb
index 837ec788a..f9dd1e849 100644
--- a/app/api/mobile/entities/member.rb
+++ b/app/api/mobile/entities/member.rb
@@ -28,6 +28,7 @@ module Mobile
end
member_expose :student_id
member_expose :score
+ member_expose :id
end
end
end
\ No newline at end of file
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 22249b953..fd7ec55fb 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -458,6 +458,21 @@ class CoursesService
@all_members = searchmember_by_name(student_homework_score(0,params[:course_id], 10,"desc"),params[:name])
end
+ def show_member_score params
+ @member_score = Member.find(params[:member_id]) if params[:member_id]
+ atta = @member_score.student_homework_score[0]
+ result = []
+ atta.each do |t|
+ if !params[:homeworkName].nil? && params[:homeworkName] != ""
+ result << {:name=>t[:name],:score=>t[:score]} if t[:name].include?(params[:homeworkName])
+ else
+ result << {:name=>t[:name],:score=>t[:score]}
+ end
+
+ end
+ result
+ end
+
private
def searchmember_by_name members, name
#searchPeopleByRoles(project, StudentRoles)
@@ -559,4 +574,6 @@ class CoursesService
end
+
+
end
\ No newline at end of file
diff --git a/app/services/users_service.rb b/app/services/users_service.rb
index 3a92bf8f1..17557872b 100644
--- a/app/services/users_service.rb
+++ b/app/services/users_service.rb
@@ -205,10 +205,14 @@ class UsersService
"show_changesets" => true
}
scope = User.logged.status(status)
- watcher = User.watched_by(params[:user_id])
- watcher.push(params[:user_id])
- search_by = params[:search_by] ? params[:search_by] : "0"
- scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present?
+ if params[:is_search_assitant].nil?
+ watcher = User.watched_by(params[:user_id])
+ watcher.push(params[:user_id])
+ search_by = params[:search_by] ? params[:search_by] : "0"
+ scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present?
+ else
+ scope = scope.like(params[:name],search_by) if params[:name].present?
+ end
scope
end
diff --git a/db/schema.rb b/db/schema.rb
index e798dba1c..94210e8f2 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -659,6 +659,16 @@ ActiveRecord::Schema.define(:version => 20150505025537) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
+ create_table "journal_details_copy", :force => true do |t|
+ t.integer "journal_id", :default => 0, :null => false
+ t.string "property", :limit => 30, :default => "", :null => false
+ t.string "prop_key", :limit => 30, :default => "", :null => false
+ t.text "old_value"
+ t.text "value"
+ end
+
+ add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
+
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"