This commit is contained in:
BoHung Chiu 2020-09-20 17:21:07 +08:00
parent 08e062e0ab
commit 77fed1ef13
3 changed files with 28 additions and 21 deletions

View File

@ -2,7 +2,7 @@ class StudentAssignment
include Mongoid::Document
include Mongoid::Timestamps
include Slug
field :assignment_content, as: :slug_title, type: String, localize: true, default: ""
field :assignment_content, as: :slug_title, type: String, default: ""
has_many :student_assignment_files, :dependent => :destroy, :autosave => true
accepts_nested_attributes_for :student_assignment_files, :allow_destroy => true
belongs_to :course_assignment
@ -14,6 +14,10 @@ class StudentAssignment
self.updated_at.strftime("%Y-%m-%d %H:%M")
end
def display_student_assignment_files
self.student_assignment_files.map{|f| "<a href=\"#{f.file.url}\" title=\"#{f.title}\">#{f.title}</a>"}.join("<br>").html_safe
self.student_assignment_files.map{ |f|
next if f.file.file.nil?
title = (f.title.blank? ? f.file.file.original_filename : f.title)
"<a href=\"#{f.file.url}\" title=\"#{title}\">#{title}</a>"
}.join("<br>").html_safe
end
end

View File

@ -20,6 +20,9 @@
<% if @student_assignment.new_record? %>
<%= f.hidden_field :course_assignment_id,:value=>@course_assignment.id.to_s %>
<% end %>
<% if params[:type] == "view" %>
<% @closed = true %>
<% end %>
<fieldset>
<legend><%= @course_assignment.course.title rescue "" %>-<%= @course_assignment.name rescue "" %></legend>
<!-- Name -->
@ -71,6 +74,7 @@
<div class="input-area">
<!-- Language Tabs -->
<!--
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
@ -85,28 +89,16 @@
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_selected_course.assignment_content") %></label>
<div class="controls">
<% if !@closed %>
<%= f.fields_for :assignment_content_translations do |f| %>
<%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t("personal_selected_course.assignment_content"), value: (@student_assignment.assignment_content_translations[locale] rescue nil) %>
<% end %>
<% else %>
<%= @student_assignment.assignment_content_translations[locale] rescue nil %>
<% end %>
</div>
</div>
</div>
<% end %>
</div>
</div> -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
@ -126,6 +118,17 @@
<% if @member_profile.present? %>
<%= f.hidden_field :member_profile_id, :value=>@member_profile.id %>
<% end %>
<div class="control-group input-title" style="width: 90%;">
<label class="control-label muted"><%= t("personal_selected_course.assignment_content") %></label>
<div class="controls">
<% if !@closed %>
<%= f.text_area :assignment_content, class: "input-block-level ckeditor", placeholder: t("personal_selected_course.assignment_content"), value: (@student_assignment.assignment_content rescue nil) %>
<% else %>
<%= @student_assignment.assignment_content rescue nil %>
<% end %>
</div>
</div>
<div style="clear: both;"></div>
<!-- Attachment -->
<%
files_hash = {}
@ -160,7 +163,7 @@
<a class="add_file trigger btn btn-small btn-primary" for="<%= file %>"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
<% else %>
<%= @student_assignment.send("display_"+file.pluralize) rescue "" %>
<%= @student_assignment.send("display_"+file.pluralize) %>
<% end %>
</div>
</div>

View File

@ -51,18 +51,18 @@
<% if !closed %>
<ul class="nav nav-pills hide">
<% if student_assignment.nil? %>
<li><%= link_to t('new_'), new_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page]) %></li>
<li><%= link_to t('new_'), new_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:member_profile_name=>@member_profile.name, :member_profile_uid=>@member_profile.uid) %></li>
<% else %>
<li><%= link_to t('edit'), edit_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:id=>student_assignment.id) %></li>
<li><%= link_to t('edit'), edit_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:id=>student_assignment.id,:member_profile_name=>@member_profile.name, :member_profile_uid=>@member_profile.uid) %></li>
<% end %>
</ul>
<% else %>
<span style="color: red;"><%=t('personal_selected_course.closed')%></span>
<ul class="nav nav-pills hide">
<% if student_assignment.nil? %>
<li><%= link_to t('personal_selected_course.view'), new_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page]) %></li>
<li><%= link_to t('personal_selected_course.view'), new_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:member_profile_name=>@member_profile.name, :member_profile_uid=>@member_profile.uid) %></li>
<% else %>
<li><%= link_to t('personal_selected_course.view'), edit_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:id=>student_assignment.id) %></li>
<li><%= link_to t('personal_selected_course.view'), edit_assignment_admin_selected_courses_path(:uid=>course_assignment.uid,:name=>course_assignment.name,:page => params[:page],:id=>student_assignment.id,:member_profile_name=>@member_profile.name, :member_profile_uid=>@member_profile.uid) %></li>
<% end %>
</ul>
<% end %>