我的资源里面显示来源 和大小 并可以下载课件

This commit is contained in:
yuanke 2016-07-12 10:25:18 +08:00
parent 14b7b04e4d
commit d4681eea00
5 changed files with 26 additions and 5 deletions

View File

@ -29,6 +29,8 @@ module Mobile
attachment_expose :quotes
attachment_expose :created_on
attachment_expose :file_dir
attachment_expose :attafile_size
attachment_expose :coursename #所属班级名
end
end
end

View File

@ -3,6 +3,7 @@ module Mobile
class Exercise < Grape::Entity
expose :exercise_name
expose :exercise_description
expose :coursename #所属班级名
end
end
end

View File

@ -94,6 +94,8 @@ module Mobile
homework_expose :homework_anony_type #是否是匿评作业
homework_expose :coursename #所属班级名
end
end
end

View File

@ -1,7 +1,7 @@
#coding=utf-8
class ResourcesService
include ActionView::Helpers::NumberHelper
#发送资源到课程
def send_resource_to_course user,params
send_id = params[:send_id]
@ -59,6 +59,12 @@ class ResourcesService
attchments = Attachment.where("(author_id = #{user.id} and is_publish = 1 and container_id in #{courses_ids} and container_type = 'Course') or (container_type = 'Course' and is_publish = 1 and container_id in #{courses_ids})" ).order("created_on desc")
attchments.each do |v|
course = Course.where("id=?",v.container_id).first
v[:coursename] = course.nil? ? "未知" : course.name
v[:attafile_size] = (number_to_human_size(v[:filesize])).gsub("ytes", "").to_s
end
attchments
end
@ -71,6 +77,11 @@ class ResourcesService
homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc")
homeworks.each do |v|
course = Course.where("id=?",v.course_id).first
v[:coursename] = course.nil? ? "未知" : course.name
end
homeworks
end
@ -83,6 +94,11 @@ class ResourcesService
exercises = Exercise.where("exercise_status <> 1 and course_id in #{courses_ids}").order("created_at desc")
exercises.each do |v|
course = Course.where("id=?",v.course_id).first
v[:coursename] = course.nil? ? "未知" : course.name
end
exercises
end

View File

@ -12,22 +12,22 @@
<div ng-class="{'undis': currentTab!=1}">
<div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]">
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4">课件来源:</span><span class="f12 ml10 mt5 c-grey4">大小:</span>
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <a ng-href="/attachments/download/{{r.id}}/{{r.filename}}" target="_blank" class="fl ml10 resource-width">{{r.filename}}</a><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4">大小:{{r.attafile_size}}</span>
</div>
<p ng-show="resources && resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站,在PC浏览器中上传课件。</p>
</div>
<div ng-class="{'undis': currentTab!=2}">
<div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4">作业来源:</span>
<span class="f12 mt5 ml35 c-grey4">作业来源:{{r.coursename}}</span>
</div>
<p ng-show="homeworks && homeworks.length<=0" class="class-test-tip">暂无作业,<br />
请登录Trustie网站,在PC浏览器中创建作业。</p>
</div>
<div ng-class="{'undis': currentTab!=3}">
<div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-click="sendFile(r)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4">题目来源:</span>
<span class="f12 mt5 ml35 c-grey4">题目来源:{{r.coursename}}</span>
</div>
<p ng-show="exercise && exercise.length<=0" class="class-test-tip">暂无测验,<br />
请登录Trustie网站,在PC浏览器中创建测验。</p>