fix bugs in version 1
This commit is contained in:
parent
c73e76a2e7
commit
d242ef087e
|
@ -114,6 +114,10 @@ $(document).ready(function(){
|
|||
$('.fieldset_block input[type="submit"]').click(function(){
|
||||
$el = $('.fieldset_block li.required');
|
||||
for(var i = 0; i< $el.length ; i++){
|
||||
if($el.eq(i).attr('for') == "StudentFile"){
|
||||
if($el.eq(i).siblings('.col_r').find('img').length != 0){
|
||||
continue;
|
||||
}};
|
||||
if($el.eq(i).siblings('.col_r').find('.required').val() == ""){
|
||||
$el.eq(i).addClass('errFld');
|
||||
if($el.eq(i).siblings('.col_r').find('.errMsg').length == 0)
|
||||
|
|
|
@ -206,6 +206,11 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:school_code=> row[@row_index_hash["school_code"]],:sign_up_setting_id=>@sign_up_setting.id).first
|
||||
@olympia_school_data_field = OlympiaSchoolDataFields.new() if @olympia_school_data_field.nil?
|
||||
@update_attributes = @row_index_hash.map{|key,index| [key,row[index]]}.to_h
|
||||
if !@update_attributes["class_number"].nil?
|
||||
class_number = @update_attributes["class_number"].to_i
|
||||
enrollment_limited = (ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= class_number && class_setting_field.class_number_range[1] >= class_number}.first.enrollment_available.to_s rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_s)
|
||||
@update_attributes.merge!({:enrollment_limited=>enrollment_limited})
|
||||
end
|
||||
@olympia_school_data_field.update_attributes(@update_attributes)
|
||||
end
|
||||
end
|
||||
|
@ -426,13 +431,15 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
if @id_error_msg.length != 0
|
||||
@error_msg << @id_error_msg
|
||||
end
|
||||
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||
if @student_params['StudentIdentity'] == '1' && (@student_params['olympia_student_images']['0']['StudentFile'].nil? rescue true)
|
||||
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
||||
if @olympia_student_data.olympia_student_images.empty? || !@olympia_student_data.olympia_student_images.first.student_file.file.present?
|
||||
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
||||
end
|
||||
end
|
||||
@olympia_school_data_field = OlympiaSchoolDataFields.find(params[:school_id]) rescue nil
|
||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? (ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_i) : @olympia_school_data_field.enrollment_limited.to_i)
|
||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:school_id],:sign_up_setting_id=>@sign_up_setting_id)
|
||||
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||
extra_num = 0
|
||||
extra_num = 1 if(@olympia_student_data.nil? && @student_params['StudentIdentity'] != '1')
|
||||
if (@student_fields.length + extra_num) > @enrollment_limited
|
||||
|
|
|
@ -678,10 +678,12 @@ class OlympiamanagementsController < ApplicationController
|
|||
@error_msg << I18n.t('olympiamanagement.id_number_error')
|
||||
end
|
||||
if @student_params['StudentIdentity'] == '1' && (@student_params['olympia_student_images']['0']['student_file'].nil? rescue true)
|
||||
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
||||
if @olympia_student_data.olympia_student_images.empty? || !@olympia_student_data.olympia_student_images.first.student_file.file.present?
|
||||
@error_msg << I18n.t('olympiamanagement.StudentFile')
|
||||
end
|
||||
end
|
||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id],:sign_up_setting_id=>@sign_up_setting.id,:approved=>true).first
|
||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
|
||||
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? (ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_i) : @olympia_school_data_field.enrollment_limited.to_i)
|
||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_field.id,:sign_up_setting_id=>@sign_up_setting.id,:StudentIdentity=>'0')
|
||||
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||
extra_num = 0
|
||||
|
|
|
@ -23,10 +23,9 @@ class OlympiaSchoolDataFields
|
|||
after_destroy do |record|
|
||||
OlympiaStudentDataField.where(:olympia_school_data_fields_id => record.id).destroy_all
|
||||
end
|
||||
after_save do |record|
|
||||
before_save do |record|
|
||||
if record.account_number.blank? && !record.school_code.blank?
|
||||
record.account_number = record.school_code
|
||||
record.save
|
||||
end
|
||||
end
|
||||
after_initialize do
|
||||
|
|
|
@ -6,7 +6,7 @@ class StudentDataField
|
|||
# encoding: utf-8
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
field :student_data_fields , type: Array , default: [{'StudentIdentity'=>{'type'=>'select_string','hint'=>{'zh_tw'=>'','en'=>''},'values'=>{'zh_tw'=>['一般身分','科展得獎者'],'en'=>['General identity','Science Fair Winner']},'required'=>"true"}},
|
||||
field :student_data_fields , type: Array , default: [{'StudentIdentity'=>{'type'=>'select_string','hint'=>{'zh_tw'=>'','en'=>''},'values'=>{'zh_tw'=>['一般身分','科展得獎或科學班'],'en'=>['General identity','Science Fair Winner']},'required'=>"true"}},
|
||||
{'StudentName'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||
{'StudentSex'=>{'type'=>'radio','size'=>'20','choices'=>['M','F'],'values'=>{'zh_tw'=>['男','女'],'en'=>['Male','Female']},'hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||
{'StudentIDNO'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
|
||||
|
|
|
@ -63,6 +63,10 @@
|
|||
<% end %>
|
||||
<div style="clear:both;"></div>
|
||||
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% if @olympia_student_data.new_record? %>
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% else %>
|
||||
<input type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
|
@ -33,7 +33,7 @@
|
|||
<%=t('olympiamanagement.a_d_')%>
|
||||
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
|
||||
<select name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
|
||||
<% for @num in (Time.now.year.to_i-10) .. (Time.now.year.to_i+10) %>
|
||||
<% for @num in (Time.now.year.to_i-15) .. (Time.now.year.to_i+10) %>
|
||||
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + (field.values[0][:unit][I18n.locale.to_s] rescue "") + '</option>').html_safe %>
|
||||
<% end %>
|
||||
</select>
|
||||
|
@ -63,6 +63,10 @@
|
|||
<% end %>
|
||||
<div style="clear:both;"></div>
|
||||
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% if @olympia_student_data.new_record? %>
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% else %>
|
||||
<input type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
|
@ -32,7 +32,7 @@
|
|||
<%=t('olympiamanagement.a_d_')%>
|
||||
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
|
||||
<select name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
|
||||
<% for @num in (Time.now.year.to_i-10) .. (Time.now.year.to_i+10) %>
|
||||
<% for @num in (Time.now.year.to_i-15) .. (Time.now.year.to_i+10) %>
|
||||
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + (field.values[0][:unit][I18n.locale.to_s] rescue "") + '</option>').html_safe %>
|
||||
<% end %>
|
||||
</select>
|
||||
|
@ -66,6 +66,10 @@
|
|||
<% end %>
|
||||
<div style="clear:both;"></div>
|
||||
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% if @olympia_student_data.new_record? %>
|
||||
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% else %>
|
||||
<input type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
|
||||
<% end %>
|
||||
<% end %>
|
||||
</fieldset>
|
|
@ -11,7 +11,7 @@
|
|||
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
|
||||
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li><li class="col_r">
|
||||
<% if field.values[0]["type"] != 'select' %>
|
||||
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
|
||||
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? (ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_s) : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
|
||||
<% else%>
|
||||
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
|
||||
<select name="<%="[add_school_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_school_data_field[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
|
||||
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li><li class="col_r">
|
||||
<% if field.values[0]["type"] != 'select' %>
|
||||
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
|
||||
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? (ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s rescue ClassSettingFields.all.desc(:enrollment_available).first.enrollment_available.to_s) : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
|
||||
<% else%>
|
||||
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
|
||||
<select name="<%="[add_school_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_school_data_field[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
|
||||
|
|
|
@ -45,7 +45,7 @@ zh_tw:
|
|||
StudentCode: 郵遞區號
|
||||
StudentAddress: 地址
|
||||
StudentArea: 考區
|
||||
StudentFile: 上傳獎狀掃描檔(僅科展得獎者需要上傳)
|
||||
StudentFile: 上傳獎狀掃描檔或科學班錄取證明(一般身分無須上傳)
|
||||
class_number: 全校班級數
|
||||
spacing: 間距
|
||||
enrollment_available: 可報名人數
|
||||
|
|
Loading…
Reference in New Issue