Mp3、mp4类实训的问题

dev_daiao
daiao 5 years ago
parent 8deb23a919
commit 814aa13c21

@ -116,7 +116,7 @@ class GamesController < ApplicationController
@qrcode_str = Base64.encode64( qr.to_img.resize(400,400).to_s ) @qrcode_str = Base64.encode64( qr.to_img.resize(400,400).to_s )
else else
@type = "image" @type = ""
#conv = Iconv.new("GBK", "utf-8") #conv = Iconv.new("GBK", "utf-8")
@game_challenge = @game.challenge @game_challenge = @game.challenge
type = @game_challenge.show_type type = @game_challenge.show_type

@ -24,7 +24,7 @@ class MyshixunsController < ApplicationController
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin begin
@shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id) @shixun = Shixun.select(:id, :identifier).find(@myshixun.shixun_id)
@myshixun.destroy @myshixun.destroy!
StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0) StudentWork.where(:myshixun_id => @myshixun.id).update_all(:myshixun_id => 0, :work_status => 0)

@ -6,7 +6,7 @@ module GamesHelper
end end
# 获取目录下所有文件,返回一个文件名的数组 type是查看文件的类型image表示图片 # 获取目录下所有文件,返回一个文件名的数组 type是查看文件的类型image表示图片
# type [[1, "图片"], [2, "apk/exe"], [3, "txt"], [4, "html"]] # type [[1, "图片"], [2, "apk/exe"], [3, "txt"], [4, "html"], [5, "mp3"], [6, "mp4"]]
def get_dir_filename(path, type, game_id) def get_dir_filename(path, type, game_id)
answer_picture = [] answer_picture = []
return answer_picture unless File.directory?(path) return answer_picture unless File.directory?(path)
@ -39,6 +39,12 @@ module GamesHelper
end end
f.close f.close
@type = 'txt' @type = 'txt'
elsif extension == 'mp3' && type == 5
answer_picture << file
@type = 'mp3'
elsif extension == 'mp4' && type == 6
answer_picture << file
@type = 'mp4'
end end
end end

@ -1,5 +1,6 @@
class Challenge < ApplicationRecord class Challenge < ApplicationRecord
# difficulty: 关卡难度: 1.简单 2.中等 3.困难 # difficulty: 关卡难度: 1.简单 2.中等 3.困难
# show_type: 效果展示:-1.无效果 1.图片 2.apk/exe 3.txt 4.html 5.mp3 6.mp4
default_scope { order("challenges.position asc") } default_scope { order("challenges.position asc") }
belongs_to :shixun, :touch => true, counter_cache: true belongs_to :shixun, :touch => true, counter_cache: true

Loading…
Cancel
Save