new module exam_archive

This commit is contained in:
JiangRu 2015-04-08 10:52:35 +08:00
parent 736db91cb5
commit 5486b7612f
82 changed files with 2579 additions and 22 deletions

View File

@ -1,6 +1,6 @@
source "https://rubygems.org" source "https://rubygems.org"
# Declare your gem's dependencies in archive.gemspec. # Declare your gem's dependencies in archive_exam.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and # Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group. # development dependencies will be added by default to the :development group.
gemspec gemspec

View File

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
archive (0.0.1) archive_exam (0.0.1)
mongoid (= 4.0.0.beta1) mongoid (= 4.0.0.beta1)
rails (~> 4.1.0.rc2) rails (~> 4.1.0.rc2)
@ -101,4 +101,4 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
archive! archive_exam!

View File

@ -1,3 +1,3 @@
= Archive = ArchiveExam
This project rocks and uses MIT-LICENSE. This project rocks and uses MIT-LICENSE.

View File

@ -8,7 +8,7 @@ require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc| RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc' rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Archive' rdoc.title = 'ArchiveExam'
rdoc.options << '--line-numbers' rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb')

View File

View File

@ -0,0 +1,29 @@
$(function() {
$('a[data-toggle="tab"]').click(function (e) {
e.preventDefault();
$(this).tab('show');
});
$.pageslide.closeCallback(function(pageslide, item) {
$('.filter-item').removeClass("active");
});
$.pageslide.loadComplete(function(pageslide, item) {
$('.filter-item').removeClass("active");
item.closest('li').addClass('active');
if(item.data('id') == 'new') {
resetForm();
pageslide.find('form:eq(0)').attr('action', window.location.pathname);
pageslide.find('form:eq(0)').attr('method', 'post');
}else {
setForm(item.data('form'));
pageslide.find('form:eq(0)').attr('action', window.location.pathname + '/' + item.data('id'));
pageslide.find('form:eq(0)').attr('method', 'put');
}
});
})

View File

@ -0,0 +1,78 @@
function checkTagsQuantity() {
var $tagLead = $('.tag-lead'),
$tagsGroups = $('.tags-groups');
$tagsGroups.each(function(i) {
var $children = $(this).children().length;
$tagLead.eq(i).children('.badge').text($children);
})
}
function checkedLength() {
var $tagsList = $('#tags-list'),
$defaultTags,
ids;
function reload_links() {
var _checked = 0;
ids = [];
$defaultTags = $('li.default input[type="checkbox"]');
$defaultTags.each(function(index, el) {
if($(el).prop('checked')) {
_checked ++;
ids.push($(el).val())
}
});
console.log(_checked,ids)
if(_checked > 0) {
$('#deselect').removeClass('hide');
$('#deselect').on('click', deselect);
$('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_colleges_admin_archive_exam_colleges_path %>" + "?ids=" + ids);
$('#deleteUnits').removeClass('hide');
} else {
$('#deselect').addClass('hide');
$('#deleteUnits').attr('rel', "");
$('#deleteUnits').addClass('hide');
$('#deselect').off('click', deselect);
};
}
$tagsList.on('click', '.card', function(event) {
reload_links();
});
$('#selectAllTags').on('click', function() {
$('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true);
$('.filter-item:not(".mark") .card').addClass('active');
reload_links();
});
$('#deleteUnits').on('click', function() {
$('#delete_archive_exam_colleges .tags-groups').empty();
$('#delete_archive_exam_colleges a.delete-tags').attr("href", $(this).attr("rel"));
if(ids.length) {
$('.filter-item').children('.card.active').each(function(i, e) {
console.log($(e))
$(e).parents('.filter-item').clone().appendTo('#delete_archive_exam_colleges .tags-groups');
$('#delete_archive_exam_colleges .tags-groups .filter-item').addClass('def');
});
}
$('#delete_archive_exam_colleges').modal('show', cleanTagInputs());
function cleanTagInputs(){
var $tagsDelete = $('#delete_archive_exam_colleges'),
$filterItem = $tagsDelete.find('.filter-item');
$filterItem.find('.card, .amount').remove();
$filterItem.find('a').removeAttr('class');
$filterItem.find('a').removeAttr('href');
}
});
function deselect() {
$('.tags input[type="checkbox"]').prop('checked', false);
$('.card').removeClass('active');
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
$('#deleteUnits').attr('rel', "");
}
}
$(function() {
checkedLength();
});

View File

@ -0,0 +1,78 @@
function checkTagsQuantity() {
var $tagLead = $('.tag-lead'),
$tagsGroups = $('.tags-groups');
$tagsGroups.each(function(i) {
var $children = $(this).children().length;
$tagLead.eq(i).children('.badge').text($children);
})
}
function checkedLength() {
var $tagsList = $('#tags-list'),
$defaultTags,
ids;
function reload_links() {
var _checked = 0;
ids = [];
$defaultTags = $('li.default input[type="checkbox"]');
$defaultTags.each(function(index, el) {
if($(el).prop('checked')) {
_checked ++;
ids.push($(el).val())
}
});
console.log(_checked,ids)
if(_checked > 0) {
$('#deselect').removeClass('hide');
$('#deselect').on('click', deselect);
$('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_departments_admin_archive_exam_departments_path %>" + "?ids=" + ids);
$('#deleteUnits').removeClass('hide');
} else {
$('#deselect').addClass('hide');
$('#deleteUnits').attr('rel', "");
$('#deleteUnits').addClass('hide');
$('#deselect').off('click', deselect);
};
}
$tagsList.on('click', '.card', function(event) {
reload_links();
});
$('#selectAllTags').on('click', function() {
$('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true);
$('.filter-item:not(".mark") .card').addClass('active');
reload_links();
});
$('#deleteUnits').on('click', function() {
$('#delete_archive_exam_departments .tags-groups').empty();
$('#delete_archive_exam_departments a.delete-tags').attr("href", $(this).attr("rel"));
if(ids.length) {
$('.filter-item').children('.card.active').each(function(i, e) {
console.log($(e))
$(e).parents('.filter-item').clone().appendTo('#delete_archive_exam_departments .tags-groups');
$('#delete_archive_exam_departments .tags-groups .filter-item').addClass('def');
});
}
$('#delete_archive_exam_departments').modal('show', cleanTagInputs());
function cleanTagInputs(){
var $tagsDelete = $('#delete_archive_exam_departments'),
$filterItem = $tagsDelete.find('.filter-item');
$filterItem.find('.card, .amount').remove();
$filterItem.find('a').removeAttr('class');
$filterItem.find('a').removeAttr('href');
}
});
function deselect() {
$('.tags input[type="checkbox"]').prop('checked', false);
$('.card').removeClass('active');
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
$('#deleteUnits').attr('rel', "");
}
}
$(function() {
checkedLength();
});

View File

@ -0,0 +1,78 @@
function checkTagsQuantity() {
var $tagLead = $('.tag-lead'),
$tagsGroups = $('.tags-groups');
$tagsGroups.each(function(i) {
var $children = $(this).children().length;
$tagLead.eq(i).children('.badge').text($children);
})
}
function checkedLength() {
var $tagsList = $('#tags-list'),
$defaultTags,
ids;
function reload_links() {
var _checked = 0;
ids = [];
$defaultTags = $('li.default input[type="checkbox"]');
$defaultTags.each(function(index, el) {
if($(el).prop('checked')) {
_checked ++;
ids.push($(el).val())
}
});
console.log(_checked,ids)
if(_checked > 0) {
$('#deselect').removeClass('hide');
$('#deselect').on('click', deselect);
$('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_grades_admin_archive_exam_grades_path %>" + "?ids=" + ids);
$('#deleteUnits').removeClass('hide');
} else {
$('#deselect').addClass('hide');
$('#deleteUnits').attr('rel', "");
$('#deleteUnits').addClass('hide');
$('#deselect').off('click', deselect);
};
}
$tagsList.on('click', '.card', function(event) {
reload_links();
});
$('#selectAllTags').on('click', function() {
$('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true);
$('.filter-item:not(".mark") .card').addClass('active');
reload_links();
});
$('#deleteUnits').on('click', function() {
$('#delete_archive_exam_grades .tags-groups').empty();
$('#delete_archive_exam_grades a.delete-tags').attr("href", $(this).attr("rel"));
if(ids.length) {
$('.filter-item').children('.card.active').each(function(i, e) {
console.log($(e))
$(e).parents('.filter-item').clone().appendTo('#delete_archive_exam_grades .tags-groups');
$('#delete_archive_exam_grades .tags-groups .filter-item').addClass('def');
});
}
$('#delete_archive_exam_grades').modal('show', cleanTagInputs());
function cleanTagInputs(){
var $tagsDelete = $('#delete_archive_exam_grades'),
$filterItem = $tagsDelete.find('.filter-item');
$filterItem.find('.card, .amount').remove();
$filterItem.find('a').removeAttr('class');
$filterItem.find('a').removeAttr('href');
}
});
function deselect() {
$('.tags input[type="checkbox"]').prop('checked', false);
$('.card').removeClass('active');
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
$('#deleteUnits').attr('rel', "");
}
}
$(function() {
checkedLength();
});

View File

@ -0,0 +1,78 @@
function checkTagsQuantity() {
var $tagLead = $('.tag-lead'),
$tagsGroups = $('.tags-groups');
$tagsGroups.each(function(i) {
var $children = $(this).children().length;
$tagLead.eq(i).children('.badge').text($children);
})
}
function checkedLength() {
var $tagsList = $('#tags-list'),
$defaultTags,
ids;
function reload_links() {
var _checked = 0;
ids = [];
$defaultTags = $('li.default input[type="checkbox"]');
$defaultTags.each(function(index, el) {
if($(el).prop('checked')) {
_checked ++;
ids.push($(el).val())
}
});
console.log(_checked,ids)
if(_checked > 0) {
$('#deselect').removeClass('hide');
$('#deselect').on('click', deselect);
$('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_subjects_admin_archive_exam_subjects_path %>" + "?ids=" + ids);
$('#deleteUnits').removeClass('hide');
} else {
$('#deselect').addClass('hide');
$('#deleteUnits').attr('rel', "");
$('#deleteUnits').addClass('hide');
$('#deselect').off('click', deselect);
};
}
$tagsList.on('click', '.card', function(event) {
reload_links();
});
$('#selectAllTags').on('click', function() {
$('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true);
$('.filter-item:not(".mark") .card').addClass('active');
reload_links();
});
$('#deleteUnits').on('click', function() {
$('#delete_archive_exam_subjects .tags-groups').empty();
$('#delete_archive_exam_subjects a.delete-tags').attr("href", $(this).attr("rel"));
if(ids.length) {
$('.filter-item').children('.card.active').each(function(i, e) {
console.log($(e))
$(e).parents('.filter-item').clone().appendTo('#delete_archive_exam_subjects .tags-groups');
$('#delete_archive_exam_subjects .tags-groups .filter-item').addClass('def');
});
}
$('#delete_archive_exam_subjects').modal('show', cleanTagInputs());
function cleanTagInputs(){
var $tagsDelete = $('#delete_archive_exam_subjects'),
$filterItem = $tagsDelete.find('.filter-item');
$filterItem.find('.card, .amount').remove();
$filterItem.find('a').removeAttr('class');
$filterItem.find('a').removeAttr('href');
}
});
function deselect() {
$('.tags input[type="checkbox"]').prop('checked', false);
$('.card').removeClass('active');
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
$('#deleteUnits').attr('rel', "");
}
}
$(function() {
checkedLength();
});

View File

@ -0,0 +1,78 @@
function checkTagsQuantity() {
var $tagLead = $('.tag-lead'),
$tagsGroups = $('.tags-groups');
$tagsGroups.each(function(i) {
var $children = $(this).children().length;
$tagLead.eq(i).children('.badge').text($children);
})
}
function checkedLength() {
var $tagsList = $('#tags-list'),
$defaultTags,
ids;
function reload_links() {
var _checked = 0;
ids = [];
$defaultTags = $('li.default input[type="checkbox"]');
$defaultTags.each(function(index, el) {
if($(el).prop('checked')) {
_checked ++;
ids.push($(el).val())
}
});
console.log(_checked,ids)
if(_checked > 0) {
$('#deselect').removeClass('hide');
$('#deselect').on('click', deselect);
$('#deleteUnits').attr('rel', "<%= Rails.application.routes.url_helpers.delete_test_types_admin_archive_exam_test_types_path %>" + "?ids=" + ids);
$('#deleteUnits').removeClass('hide');
} else {
$('#deselect').addClass('hide');
$('#deleteUnits').attr('rel', "");
$('#deleteUnits').addClass('hide');
$('#deselect').off('click', deselect);
};
}
$tagsList.on('click', '.card', function(event) {
reload_links();
});
$('#selectAllTags').on('click', function() {
$('.filter-item:not(".mark") input[type="checkbox"]').prop('checked', true);
$('.filter-item:not(".mark") .card').addClass('active');
reload_links();
});
$('#deleteUnits').on('click', function() {
$('#delete_archive_exam_test_types .tags-groups').empty();
$('#delete_archive_exam_test_types a.delete-tags').attr("href", $(this).attr("rel"));
if(ids.length) {
$('.filter-item').children('.card.active').each(function(i, e) {
console.log($(e))
$(e).parents('.filter-item').clone().appendTo('#delete_archive_exam_test_types .tags-groups');
$('#delete_archive_exam_test_types .tags-groups .filter-item').addClass('def');
});
}
$('#delete_archive_exam_test_types').modal('show', cleanTagInputs());
function cleanTagInputs(){
var $tagsDelete = $('#delete_archive_exam_test_types'),
$filterItem = $tagsDelete.find('.filter-item');
$filterItem.find('.card, .amount').remove();
$filterItem.find('a').removeAttr('class');
$filterItem.find('a').removeAttr('href');
}
});
function deselect() {
$('.tags input[type="checkbox"]').prop('checked', false);
$('.card').removeClass('active');
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
$('#deleteUnits').attr('rel', "");
}
}
$(function() {
checkedLength();
});

View File

@ -0,0 +1,3 @@
/*
*= require lib/tags-groups
*/

View File

@ -0,0 +1,51 @@
class Admin::ArchiveExamCollegesController < OrbitAdminController
def initialize
super
@app_title = 'archive_exam'
end
def index
@archive_exam_colleges = ArchiveExamCollege.all
@url = admin_archive_exam_college_path(@archive_exam_colleges)
end
def create
@archive_exam_college = ArchiveExamCollege.new(archive_exam_college_params)
@archive_exam_college.save
redirect_to request.referer, :status => 303
end
def create_in_form
@archive_exam_college = ArchiveExamCollege.new(archive_exam_college_params)
@archive_exam_college.save
render :json => {:id=>@archive_exam_college.id.to_s, :title=>@archive_exam_college.title}.to_json ,:layout => false
end
def update
@archive_exam_college = ArchiveExamCollege.find(params[:id])
@archive_exam_college.update_attributes(archive_exam_college_params)
redirect_to request.referer, :status => 303
end
def toggle
@archive_exam_college = ArchiveExamCollege.find(params[:id])
@archive_exam_college.save!
redirect_to request.referer, :status => 303
end
def delete_colleges
colleges = ArchiveExamCollege.find(params[:ids].split(',')) rescue nil
if colleges
colleges.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def archive_exam_college_params
params.require(:archive_exam_college).permit!
end
end

View File

@ -0,0 +1,51 @@
class Admin::ArchiveExamDepartmentsController < OrbitAdminController
def initialize
super
@app_title = 'archive_exam'
end
def index
@archive_exam_departments = ArchiveExamDepartment.all
@url = admin_archive_exam_department_path(@archive_exam_departments)
end
def create
@archive_exam_department = ArchiveExamDepartment.new(archive_exam_department_params)
@archive_exam_department.save
redirect_to request.referer, :status => 303
end
def create_in_form
@archive_exam_department = ArchiveExamDepartment.new(archive_exam_department_params)
@archive_exam_department.save
render :json => {:id=>@archive_exam_department.id.to_s, :title=>@archive_exam_department.title}.to_json ,:layout => false
end
def update
@archive_exam_department = ArchiveExamDepartment.find(params[:id])
@archive_exam_department.update_attributes(archive_exam_department_params)
redirect_to request.referer, :status => 303
end
def toggle
@archive_exam_department = ArchiveExamDepartment.find(params[:id])
@archive_exam_department.save!
redirect_to request.referer, :status => 303
end
def delete_departments
departments = ArchiveExamDepartment.find(params[:ids].split(',')) rescue nil
if departments
departments.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def archive_exam_department_params
params.require(:archive_exam_department).permit!
end
end

View File

@ -0,0 +1,127 @@
class Admin::ArchiveExamFilesController < OrbitAdminController
def index
@table_fields = [:status, :category, :title, :update_at,:last_modified]
@categories = @module_app.categories
@tags = @module_app.tags
@filter_fields = filter_fields(@categories, @tags)
@archive_exams = ArchiveExamFile.order_by(sort)
.with_categories(filters("category"))
.with_tags(filters("tag"))
.with_status(filters("status"))
@archive_exams = search_data(@archive_exams,[:title]).page(params[:page]).per(10)
render :partial => "index" if request.xhr?
end
def new
@archive_exam_file = ArchiveExamFile.new
@tags = @module_app.tags
@categories = @module_app.categories
@archive_exam_test_types = ArchiveExamTestType.all
@archive_exam_grades = ArchiveExamGrade.all
@archive_exam_colleges = ArchiveExamCollege.all
@archive_exam_departments = ArchiveExamDepartment.all
@archive_exam_subjects = ArchiveExamSubject.all
end
def edit
@archive_exam_test_types = ArchiveExamTestType.all
@archive_exam_grades = ArchiveExamGrade.all
@archive_exam_colleges = ArchiveExamCollege.all
@archive_exam_departments = ArchiveExamDepartment.all
@archive_exam_subjects = ArchiveExamSubject.all
@archive_exam_file = ArchiveExamFile.find(params[:id])
if can_edit_or_delete?(@archive_exam_file)
@tags = @module_app.tags
@categories = @module_app.categories
else
render_401
end
end
def create
@archive_exam_file = ArchiveExamFile.new(archive_exam_vars)
@archive_exam_file.create_user_id = current_user.id
@archive_exam_file.update_user_id = current_user.id
respond_to do |format|
if @archive_exam_file.save
format.html { redirect_to(admin_archive_exam_files_path) }
format.xml { render :xml => @archive_exam_file, :status => :created, :location => @archive_exam_file }
else
@tags = @module_app.tags
format.html { render :action => "new" }
format.xml { render :xml => @archive_exam_file.errors, :status => :unprocessable_entity }
end
end
end
# PUT /archive_exam_files/1
# PUT /archive_exam_files/1.xml
def update
params[:archive_exam_file][:archive_exam_test_type_id] = (params[:archive_exam_file][:archive_exam_test_type_id] ? params[:archive_exam_file][:archive_exam_test_type_id] : [])
params[:archive_exam_file][:archive_exam_grade_id] = (params[:archive_exam_file][:archive_exam_grade_id] ? params[:archive_exam_file][:archive_exam_grade_id] : [])
params[:archive_exam_file][:archive_exam_college_id] = (params[:archive_exam_file][:archive_exam_college_id] ? params[:archive_exam_file][:archive_exam_college_id] : [])
params[:archive_exam_file][:archive_exam_department_id] = (params[:archive_exam_file][:archive_exam_department_id] ? params[:archive_exam_file][:archive_exam_department_id] : [])
params[:archive_exam_file][:archive_exam_subject_id] = (params[:archive_exam_file][:archive_exam_subject_id] ? params[:archive_exam_file][:archive_exam_subject_id] : [])
@archive_exam_file = ArchiveExamFile.find(params[:id])
@archive_exam_file.update_user_id = current_user.id
respond_to do |format|
if @archive_exam_file.update_attributes(archive_exam_vars)
format.html { redirect_to(admin_archive_exam_files_path(:page => params[:page])) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @archive_exam_file.errors, :status => :unprocessable_entity }
end
end
end
def destroy
archive_exam_file = ArchiveExamFile.find(params[:id])
archive_exam_file.destroy
redirect_to admin_archive_exam_files_path
end
private
def archive_exam_vars
params[:archive_exam_file][:tags] ||=[]
params.require(:archive_exam_file).permit!
end
def setup_vars
@module_app = ModuleApp.where(:key => "archive_exam").first
end
def sort
unless params[:sort].blank?
case params[:sort]
when "status"
@sort = [[:is_top, params[:order]],
[:is_hot, params[:order]],
[:is_hidden,params[:order]]]
when "category"
@sort = {:category_id=>params[:order]}
when "title"
@sort = {:title=>params[:order]}
when "last_modified"
@sort = {:update_user_id=>params[:order]}
end
else
@sort = {:created_at=>'desc'}
end
@sort
end
end

View File

@ -0,0 +1,51 @@
class Admin::ArchiveExamGradesController < OrbitAdminController
def initialize
super
@app_title = 'archive_exam'
end
def index
@archive_exam_grades = ArchiveExamGrade.all
@url = admin_archive_exam_grade_path(@archive_exam_grades)
end
def create
@archive_exam_grade = ArchiveExamGrade.new(archive_exam_grade_params)
@archive_exam_grade.save
redirect_to request.referer, :status => 303
end
def create_in_form
@archive_exam_grade = ArchiveExamGrade.new(archive_exam_grade_params)
@archive_exam_grade.save
render :json => {:id=>@archive_exam_grade.id.to_s, :title=>@archive_exam_grade.title}.to_json ,:layout => false
end
def update
@archive_exam_grade = ArchiveExamGrade.find(params[:id])
@archive_exam_grade.update_attributes(archive_exam_grade_params)
redirect_to request.referer, :status => 303
end
def toggle
@archive_exam_grade = ArchiveExamGrade.find(params[:id])
@archive_exam_grade.save!
redirect_to request.referer, :status => 303
end
def delete_grades
grades = ArchiveExamGrade.find(params[:ids].split(',')) rescue nil
if grades
grades.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def archive_exam_grade_params
params.require(:archive_exam_grade).permit!
end
end

View File

@ -0,0 +1,51 @@
class Admin::ArchiveExamSubjectsController < OrbitAdminController
def initialize
super
@app_title = 'archive_exam'
end
def index
@archive_exam_subjects = ArchiveExamSubject.all
@url = admin_archive_exam_subject_path(@archive_exam_subjects)
end
def create
@archive_exam_subject = ArchiveExamSubject.new(archive_exam_subject_params)
@archive_exam_subject.save
redirect_to request.referer, :status => 303
end
def create_in_form
@archive_exam_subject = ArchiveExamSubject.new(archive_exam_subject_params)
@archive_exam_subject.save
render :json => {:id=>@archive_exam_subject.id.to_s, :title=>@archive_exam_subject.title}.to_json ,:layout => false
end
def update
@archive_exam_subject = ArchiveExamSubject.find(params[:id])
@archive_exam_subject.update_attributes(archive_exam_subject_params)
redirect_to request.referer, :status => 303
end
def toggle
@archive_exam_subject = ArchiveExamSubject.find(params[:id])
@archive_exam_subject.save!
redirect_to request.referer, :status => 303
end
def delete_subjects
subjects = ArchiveExamSubject.find(params[:ids].split(',')) rescue nil
if subjects
subjects.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def archive_exam_subject_params
params.require(:archive_exam_subject).permit!
end
end

View File

@ -0,0 +1,51 @@
class Admin::ArchiveExamTestTypesController < OrbitAdminController
def initialize
super
@app_title = 'archive_exam'
end
def index
@archive_exam_test_types = ArchiveExamTestType.all
@url = admin_archive_exam_test_type_path(@archive_exam_test_types)
end
def create
@archive_exam_test_type = ArchiveExamTestType.new(archive_exam_test_type_params)
@archive_exam_test_type.save
redirect_to request.referer, :status => 303
end
def create_in_form
@archive_exam_test_type = ArchiveExamTestType.new(archive_exam_test_type_params)
@archive_exam_test_type.save
render :json => {:id=>@archive_exam_test_type.id.to_s, :title=>@archive_exam_test_type.title}.to_json ,:layout => false
end
def update
@archive_exam_test_type = ArchiveExamTestType.find(params[:id])
@archive_exam_test_type.update_attributes(archive_exam_test_type_params)
redirect_to request.referer, :status => 303
end
def toggle
@archive_exam_test_type = ArchiveExamTestType.find(params[:id])
@archive_exam_test_type.save!
redirect_to request.referer, :status => 303
end
def delete_test_types
test_types = ArchiveExamTestType.find(params[:ids].split(',')) rescue nil
if test_types
test_types.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def archive_exam_test_type_params
params.require(:archive_exam_test_type).permit!
end
end

View File

@ -0,0 +1,85 @@
class ArchiveExamsController < ApplicationController
def index
categories = OrbitHelper.page_categories
@categories = []
if categories.first == "all"
module_app = OrbitHelper.this_module_app
@categories = module_app.categories
else
categories.each do |cat|
@categories << Category.find(cat)
end
end
archive_exam_test_types = ArchiveExamTestType.all
archive_exam_grades = ArchiveExamGrade.all
archive_exam_colleges = ArchiveExamCollege.all
archive_exam_departments = ArchiveExamDepartment.all
archive_exam_subjects = ArchiveExamSubject.all
{
'categories' => @categories,
'archive_exam_test_types' => archive_exam_test_types,
'archive_exam_grades' => archive_exam_grades,
'archive_exam_colleges' => archive_exam_colleges,
'archive_exam_departments' => archive_exam_departments,
'archive_exam_subjects' => archive_exam_subjects
}
end
def result
params = OrbitHelper.params
cagetoey = Category.find(params[:category]).title rescue ""
archive_exam_files = ArchiveExamFile.where(:category_id => params[:category], :is_hidden=> false).desc(:year)
if !params[:test_type].blank?
archive_exam_files = archive_exam_files.where(:archive_exam_test_type_id => params[:test_type])
test_type = ' * 考試類型: ' + ArchiveExamTestType.find(params[:test_type]).title rescue ""
end
if !params[:grade].blank?
archive_exam_files = archive_exam_files.where(:archive_exam_grade_id => params[:grade])
grade = ' * 年級: ' + ArchiveExamGrade.find(params[:grade]).title rescue ""
end
if !params[:year].blank?
archive_exam_files = archive_exam_files.where(:year => params[:year])
year = ' * 年度: ' + params[:year] rescue ""
end
if !params[:college].blank?
archive_exam_files = archive_exam_files.where(:archive_exam_college_id => params[:college])
college = ' * 學院: ' + ArchiveExamCollege.find(params[:college]).title rescue ""
end
if !params[:department].blank?
archive_exam_files = archive_exam_files.where(:archive_exam_department_id => params[:department])
department = ' * 系所: ' + ArchiveExamDepartment.find(params[:department]).title rescue ""
end
if !params[:subject].blank?
archive_exam_files = archive_exam_files.where(:archive_exam_subject_id => params[:subject])
subject = ' * 科目: ' + ArchiveExamSubject.find(params[:subject]).title rescue ""
end
archive_exam_files = archive_exam_files.where(:archive_exam_subject_id => params[:subject]) if !params[:subject].blank?
{
'cagetoey' => cagetoey,
'archive_exam_files' => archive_exam_files,
'test_type' => test_type,
'grade' => grade,
'year' => year,
'college' => college,
'department' => department,
'subject' => subject
}
end
end

View File

@ -0,0 +1,2 @@
module Admin::ArchiveExamFilesHelper
end

View File

@ -0,0 +1,9 @@
class ArchiveExamCollege
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
belongs_to :archive_exam_file
end

View File

@ -0,0 +1,9 @@
class ArchiveExamDepartment
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
belongs_to :archive_exam_file
end

View File

@ -0,0 +1,128 @@
# encoding: utf-8
class ArchiveExamFile
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCategory::Categorizable
include OrbitModel::Status
include OrbitTag::Taggable
include Slug
# include Tire::Model::Search
# include Tire::Model::Callbacks
# BelongsToCategory = :archive_exam_file_category
# PAYMENT_TYPES = @site_valid_locales
field :title, as: :slug_title, localize: true
field :year
field :create_user_id
field :update_user_id
field :postdate , :type => DateTime, :default => Time.now
field :deadline , :type => DateTime
field :uid, type: String
field :sort_number, type: Integer
field :rss2_sn
field :archive_exam_test_type_id , :type => Array
field :archive_exam_grade_id , :type => Array
field :archive_exam_college_id , :type => Array
field :archive_exam_department_id , :type => Array
field :archive_exam_subject_id , :type => Array
# scope :can_display,where(is_hidden: false)
scope :can_display, ->{where(is_hidden: false).order_by(:is_top=>-1, :sort_number=>1, :title=>1)}
# belongs_to :archive_exam_file_category
has_many :archive_exam_file_multiples, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :archive_exam_file_multiples, :allow_destroy => true
# belongs_to :archive_exam_test_type
# belongs_to :archive_exam_grade
# belongs_to :archive_exam_college
# belongs_to :archive_exam_department
# belongs_to :archive_exam_subject
# validates :title, :at_least_one => true
after_save :save_archive_exam_file_multiples
# def to_indexed_json
# self.to_json
# end
# search_in :title
# searchable do
# text :titles do
# title_translations.to_a.collect{|t| t[1]}
# end
# boolean :frontend_search do
# !is_hidden
# end
# end
# def self.search( category_id = nil )
# if category_id.to_s.size > 0
# find(:all, :conditions => {archive_exam_file_category_id: category_id}).desc( :is_top, :title )
# else
# find(:all).desc( :is_top, :title)
# end
# end
def self.get_test_types(category)
@archive_exams = ArchiveExamFile.where(:category_id => category).asc(:archive_exam_test_type_id)
test_types = []
@archive_exams.collect do |archvie|
if !archvie.archive_exam_test_type_id.blank?
@testtype = ArchiveExamTestType.find(archvie.archive_exam_test_type_id)
if @testtype
test_types << [@testtype.title,@testtype.id]
end
end
end
test_types.uniq
end
def self.find_by_param(input)
self.find_by(uid: input)
end
def self.widget_datas
where( :is_hidden => false ).desc(:is_top, :title)
end
def get_file_icon( file_data )
file_icon = "<span class=\"o-archive_exams-file-type\">#{file_data.split('.')[-1]}</span>".html_safe
end
def save_archive_exam_file_multiples
self.archive_exam_file_multiples.each do |t|
if t.should_destroy
t.destroy
end
end
end
end

View File

@ -0,0 +1,27 @@
class ArchiveExamFileMultiple
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :file_title, localize: true
# field :description
field :choose_lang, :type => Array, :default => nil
field :should_destroy, :type => Boolean
field :sort_number, :type => Integer
# default_scope asc(:sort_number)
def choose_lang_display(lang)
self.choose_lang.include?(lang)
end
belongs_to :archive_exam_file
# has_many :archive_exam_file_multiple_langs, :autosave => true, :dependent => :destroy
# accepts_nested_attributes_for :archive_exam_file_multiple_langs, :allow_destroy => true
end

View File

@ -0,0 +1,9 @@
class ArchiveExamGrade
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
belongs_to :archive_exam_file
end

View File

@ -0,0 +1,9 @@
class ArchiveExamSubject
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
belongs_to :archive_exam_file
end

View File

@ -0,0 +1,9 @@
class ArchiveExamTestType
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
belongs_to :archive_exam_file
end

View File

@ -0,0 +1,8 @@
<li class="filter-item default">
<p class="card pull-left">
<input type="checkbox" value="<%= college.id %>">
</p>
<%= link_to '#', class: "open-slide", data: {title: t('archive_exam_college.edit_college'), id: college.id.to_s, form: college.title_translations} do %>
<%= college.title_translations.values.join(" / ") %>
<% end %>
</li>

View File

@ -0,0 +1,16 @@
<div id="delete_archive_exam_colleges" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('archive_exam_college.del_college') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,11 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
<div class="controls">
<input class="input-large" id="<%=locale%>" name="archive_exam_college[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
<span class="help-inline hide"><%= t('front_page.name_field_helper') %></span>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,27 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
<%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('archive_exam_college.new_college'), id: 'new'} %>
</div>
</div>
<!-- footer:end -->
<!-- tags -->
<div class="tags">
<div id="tags-list">
<p class="tag-lead lead muted"><%= t('archive_exam_college.set_college') %></p>
<% if !@archive_exam_colleges.blank? %>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "college", collection: @archive_exam_colleges, locals: {in_module: true} %>
</ul>
<% end %>
</div>
</div>
<!-- tags:end -->
<!-- delete -->
<%= render 'delete_modal' %>
<!-- delete:end -->

View File

@ -0,0 +1,81 @@
<div id="archive_exam_colleges_index">
<%= render 'index' %>
</div>
<!-- pageslide -->
<div id="pageslide">
<div class="page-title clearfix">
<a class="pull-right" href="javascript:$.pageslide.close()">
<i class="icons-arrow-left-2"></i>
</a>
<span></span>
</div>
<div class="view-page">
<div class="nano">
<div class="content">
<div id="add-tags">
<div class="tab-content">
<div class="set_new tab-pane fade active in">
<%= form_for :archive_exam_college, url: nil, remote: true do |f| %>
<fieldset>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "archive_exam_sets" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "check_archive_exam_set_colleges.js" %>
<%= javascript_include_tag "archive_exam_sets.js" %>
<% end %>
<script type="text/javascript">
var validate = function(dom){
var valid = true;
if($(dom).val()==""){
valid=false;
$(dom).parent().parent().addClass('error');
$(dom).next().removeClass('hide');
}else{
$(dom).parent().parent().removeClass('error');
$(dom).next().addClass('hide');
}
return valid;
}
$(function(){
$.each($('.set_new form input:text'),function(){
$(this).blur(function(){
validate($(this));
});
$(this).keyup(function(){
validate($(this));
});
});
});
$("#tag_submit").click(function(){
var valid = true;
$.each($(".set_new form input:text"),function(){
if(!validate($(this))) valid=false;
});
if(!valid) return false;
});
</script>
<!-- pageslide:end -->

View File

@ -0,0 +1,8 @@
$("#delete_archive_exam_colleges").modal('hide');
$("#archive_exam_colleges_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();
$('.card').cardCheck({
item: $('.card input[type="checkbox"]'),
});
checkedLength();

View File

@ -0,0 +1,16 @@
<div id="delete_archive_exam_departments" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('archive_exam_department.del_department') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,8 @@
<li class="filter-item default">
<p class="card pull-left">
<input type="checkbox" value="<%= department.id %>">
</p>
<%= link_to '#', class: "open-slide", data: {title: t('archive_exam_department.edit_department'), id: department.id.to_s, form: department.title_translations} do %>
<%= department.title_translations.values.join(" / ") %>
<% end %>
</li>

View File

@ -0,0 +1,11 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
<div class="controls">
<input class="input-large" id="<%=locale%>" name="archive_exam_department[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
<span class="help-inline hide"><%= t('front_page.name_field_helper') %></span>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,27 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
<%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('archive_exam_department.new_department'), id: 'new'} %>
</div>
</div>
<!-- footer:end -->
<!-- tags -->
<div class="tags">
<div id="tags-list">
<p class="tag-lead lead muted"><%= t('archive_exam_department.set_department') %></p>
<% if !@archive_exam_departments.blank? %>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "department", collection: @archive_exam_departments, locals: {in_module: true} %>
</ul>
<% end %>
</div>
</div>
<!-- tags:end -->
<!-- delete -->
<%= render 'delete_modal' %>
<!-- delete:end -->

View File

@ -0,0 +1,81 @@
<div id="archive_exam_departments_index">
<%= render 'index' %>
</div>
<!-- pageslide -->
<div id="pageslide">
<div class="page-title clearfix">
<a class="pull-right" href="javascript:$.pageslide.close()">
<i class="icons-arrow-left-2"></i>
</a>
<span></span>
</div>
<div class="view-page">
<div class="nano">
<div class="content">
<div id="add-tags">
<div class="tab-content">
<div class="set_new tab-pane fade active in">
<%= form_for :archive_exam_department, url: nil, remote: true do |f| %>
<fieldset>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "archive_exam_sets" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "check_archive_exam_set_departments.js" %>
<%= javascript_include_tag "archive_exam_sets.js" %>
<% end %>
<script type="text/javascript">
var validate = function(dom){
var valid = true;
if($(dom).val()==""){
valid=false;
$(dom).parent().parent().addClass('error');
$(dom).next().removeClass('hide');
}else{
$(dom).parent().parent().removeClass('error');
$(dom).next().addClass('hide');
}
return valid;
}
$(function(){
$.each($('.set_new form input:text'),function(){
$(this).blur(function(){
validate($(this));
});
$(this).keyup(function(){
validate($(this));
});
});
});
$("#tag_submit").click(function(){
var valid = true;
$.each($(".set_new form input:text"),function(){
if(!validate($(this))) valid=false;
});
if(!valid) return false;
});
</script>
<!-- pageslide:end -->

View File

@ -0,0 +1,8 @@
$("#delete_archive_exam_departments").modal('hide');
$("#archive_exam_departments_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();
$('.card').cardCheck({
item: $('.card input[type="checkbox"]'),
});
checkedLength();

View File

@ -0,0 +1,250 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<%#= f.error_messages %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.year") %></label>
<div class="controls">
<%= select_year((@archive_exam_file.year ? @archive_exam_file.year.to_i : DateTime.now.year), {:start_year => (DateTime.now.year - 1911), :end_year => (1998 - 1911), prompt: 'Select'}, {:name => 'archive_exam_file[year]', :class => "span1"} ) %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.test_type") %></label>
<div class="controls">
<% @archive_exam_test_types.collect { |t| %>
<label class="checkbox inline">
<input type="checkbox" name="archive_exam_file[archive_exam_test_type_id][]" value="<%=t.id %>" <%=(!@archive_exam_file.archive_exam_test_type_id.blank? and @archive_exam_file.archive_exam_test_type_id.include?(t.id.to_s)) ? "checked" : "" %> ><%= t.title %>
</label>
<% } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.grade") %></label>
<div class="controls">
<% @archive_exam_grades.collect { |t| %>
<label class="checkbox inline">
<input type="checkbox" name="archive_exam_file[archive_exam_grade_id][]" value="<%=t.id %>" <%=(!@archive_exam_file.archive_exam_grade_id.blank? and @archive_exam_file.archive_exam_grade_id.include?(t.id.to_s)) ? "checked" : "" %> ><%= t.title %>
</label>
<% } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.college") %></label>
<div class="controls">
<% @archive_exam_colleges.collect { |t| %>
<label class="checkbox inline">
<input type="checkbox" name="archive_exam_file[archive_exam_college_id][]" value="<%=t.id %>" <%=(!@archive_exam_file.archive_exam_college_id.blank? and @archive_exam_file.archive_exam_college_id.include?(t.id.to_s)) ? "checked" : "" %> ><%= t.title %>
</label>
<% } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.department") %></label>
<div class="controls">
<% @archive_exam_departments.collect { |t| %>
<label class="checkbox inline">
<input type="checkbox" name="archive_exam_file[archive_exam_department_id][]" value="<%=t.id %>" <%=(!@archive_exam_file.archive_exam_department_id.blank? and @archive_exam_file.archive_exam_department_id.include?(t.id.to_s)) ? "checked" : "" %> ><%= t.title %>
</label>
<% } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("archive_exam.subject") %></label>
<div class="controls">
<% @archive_exam_subjects.collect { |t| %>
<label class="checkbox inline">
<input type="checkbox" name="archive_exam_file[archive_exam_subject_id][]" value="<%=t.id %>" <%=(!@archive_exam_file.archive_exam_subject_id.blank? and @archive_exam_file.archive_exam_subject_id.include?(t.id.to_s)) ? "checked" : "" %> ><%= t.title %>
</label>
<% } %>
</div>
</div>
<!-- Sort -->
<div class="control-group">
<label class="control-label muted"><%= t(:sort_number) %></label>
<div class="controls">
<%= f.text_field :sort_number %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @archive_exam_file.is_top? %>">
<%= f.check_box :is_top %> <%= t(:top) %>
</label>
<label class="checkbox inline btn <%= 'active' if @archive_exam_file.is_hot? %>">
<%= f.check_box :is_hot %> <%= t(:hot) %>
</label>
<label class="checkbox inline btn <%= 'active' if @archive_exam_file.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
<div class="control-group">
<label class="control-label muted"><%= t(:tags) %></label>
<%= select_tags(f, @module_app) %>
</div>
</div>
</div>
<!-- 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| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale.to_s) %></a>
</li>
<% 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" : '' %>">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@archive_exam_file.title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @archive_exam_file && !@archive_exam_file.archive_exam_file_multiples.blank? %>
<div class="exist">
<% @archive_exam_file.archive_exam_file_multiples.each_with_index do |archive_exam_file_multiple, i| %>
<%= f.fields_for :archive_exam_file_multiples, archive_exam_file_multiple do |f| %>
<%= render :partial => 'form_file', :object => archive_exam_file_multiple, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'archive_exam_file_multiple_field_count', @archive_exam_file.archive_exam_file_multiples.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<a href="/<%= I18n.locale.to_s %>/admin/archive_exam_files/" class="btn" >Cancel</a>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_archive_exam_file_multiples", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :archive_exam_file_multiples) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,66 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title="<%= t(:file_) %>">
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title="<%= t('file.name') %>"></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :file_title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t('file.name'), :value => (form_file.file_title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icon-list-ol" title="<%= t(:sort_number) %>"></span>
<span class="tab-content">
<%= f.text_field :sort_number , :class => "input-mini" %>
</span>
<span class="add-on btn-group btn" title="<%= t('archive_exam.show_lang') %>">
<i class="icons-earth"></i> <span class="caret"></span>
<ul class="dropdown-menu">
<% @site_in_use_locales.each do |locale| %>
<li>
<label class="checkbox">
<%= check_box_tag "archive_exam_file[archive_exam_file_multiples_attributes][#{( form_file.new_record? ? 'new_archive_exam_file_multiples' : "#{i}" )}][choose_lang][]", locale, (form_file.choose_lang.nil? ? true : form_file.choose_lang.include?(locale)) %>
<%= t(locale.to_s) %>
</label>
</li>
<% end %>
</ul>
<%= hidden_field_tag 'archive_exam_file[archive_exam_file_multiples_attributes][0][choose_lang][]', '' %>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class=" icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,45 @@
<script>
if(document.querySelectorAll("#orbit-bar").length==0) location.reload();
</script>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @archive_exams.each do |archive_exam| %>
<tr>
<td><%= archive_exam.status_for_table %></td>
<td>
<%= archive_exam.category.title rescue "" %>
<% if (archive_exam.category.disable rescue false) %>
<span class='label'><%= t(:disabled) %></span>
<% end %>
</td>
<td>
<a href="#" target="_blank"><%= archive_exam.title %></a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(archive_exam) %>
<li><a href="/<%= I18n.locale.to_s %>/admin/archive_exam_files/<%= archive_exam.id.to_s %>/edit"><%= t(:edit) %></a></li>
<li><a href="/admin/archive_exam_files/<%= archive_exam.id.to_s %>" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td><%= format_value archive_exam.updated_at rescue nil %></td>
<td><%= User.find(archive_exam.update_user_id).user_name rescue nil %></td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@archive_exams), class: "pagination pagination-centered"
end
%>

View File

@ -0,0 +1,5 @@
<%= form_for @archive_exam_file, :url => {:action => "update"}, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,4 @@
<%= render_filter @filter_fields, "index_table" %>
<div id="index_table">
<%= render 'index'%>
</div>

View File

@ -0,0 +1,5 @@
<%= form_for @archive_exam_file, :url => {:action => "create"}, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,16 @@
<div id="delete_archive_exam_grades" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('archive_exam_grade.del_grade') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,11 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
<div class="controls">
<input class="input-large" id="<%=locale%>" name="archive_exam_grade[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
<span class="help-inline hide"><%= t('front_page.name_field_helper') %></span>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,8 @@
<li class="filter-item default">
<p class="card pull-left">
<input type="checkbox" value="<%= grade.id %>">
</p>
<%= link_to '#', class: "open-slide", data: {title: t('archive_exam_grade.edit_grade'), id: grade.id.to_s, form: grade.title_translations} do %>
<%= grade.title_translations.values.join(" / ") %>
<% end %>
</li>

View File

@ -0,0 +1,27 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
<%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('archive_exam_grade.new_grade'), id: 'new'} %>
</div>
</div>
<!-- footer:end -->
<!-- tags -->
<div class="tags">
<div id="tags-list">
<p class="tag-lead lead muted"><%= t('archive_exam_grade.set_grade') %></p>
<% if !@archive_exam_grades.blank? %>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "grade", collection: @archive_exam_grades, locals: {in_module: true} %>
</ul>
<% end %>
</div>
</div>
<!-- tags:end -->
<!-- delete -->
<%= render 'delete_modal' %>
<!-- delete:end -->

View File

@ -0,0 +1,81 @@
<div id="archive_exam_grades_index">
<%= render 'index' %>
</div>
<!-- pageslide -->
<div id="pageslide">
<div class="page-title clearfix">
<a class="pull-right" href="javascript:$.pageslide.close()">
<i class="icons-arrow-left-2"></i>
</a>
<span></span>
</div>
<div class="view-page">
<div class="nano">
<div class="content">
<div id="add-tags">
<div class="tab-content">
<div class="set_new tab-pane fade active in">
<%= form_for :archive_exam_grade, url: nil, remote: true do |f| %>
<fieldset>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "archive_exam_sets" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "check_archive_exam_set_grades.js" %>
<%= javascript_include_tag "archive_exam_sets.js" %>
<% end %>
<script type="text/javascript">
var validate = function(dom){
var valid = true;
if($(dom).val()==""){
valid=false;
$(dom).parent().parent().addClass('error');
$(dom).next().removeClass('hide');
}else{
$(dom).parent().parent().removeClass('error');
$(dom).next().addClass('hide');
}
return valid;
}
$(function(){
$.each($('.set_new form input:text'),function(){
$(this).blur(function(){
validate($(this));
});
$(this).keyup(function(){
validate($(this));
});
});
});
$("#tag_submit").click(function(){
var valid = true;
$.each($(".set_new form input:text"),function(){
if(!validate($(this))) valid=false;
});
if(!valid) return false;
});
</script>
<!-- pageslide:end -->

View File

@ -0,0 +1,8 @@
$("#delete_archive_exam_grades").modal('hide');
$("#archive_exam_grades_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();
$('.card').cardCheck({
item: $('.card input[type="checkbox"]'),
});
checkedLength();

View File

@ -0,0 +1,16 @@
<div id="delete_archive_exam_subjects" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('archive_exam_subject.del_subject') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,11 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
<div class="controls">
<input class="input-large" id="<%=locale%>" name="archive_exam_subject[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
<span class="help-inline hide"><%= t('front_page.name_field_helper') %></span>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,27 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
<%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('archive_exam_subject.new_subject'), id: 'new'} %>
</div>
</div>
<!-- footer:end -->
<!-- tags -->
<div class="tags">
<div id="tags-list">
<p class="tag-lead lead muted"><%= t('archive_exam_subject.set_subject') %></p>
<% if !@archive_exam_subjects.blank? %>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "subject", collection: @archive_exam_subjects, locals: {in_module: true} %>
</ul>
<% end %>
</div>
</div>
<!-- tags:end -->
<!-- delete -->
<%= render 'delete_modal' %>
<!-- delete:end -->

View File

@ -0,0 +1,8 @@
<li class="filter-item default">
<p class="card pull-left">
<input type="checkbox" value="<%= subject.id %>">
</p>
<%= link_to '#', class: "open-slide", data: {title: t('archive_exam_subject.edit_subject'), id: subject.id.to_s, form: subject.title_translations} do %>
<%= subject.title_translations.values.join(" / ") %>
<% end %>
</li>

View File

@ -0,0 +1,81 @@
<div id="archive_exam_subjects_index">
<%= render 'index' %>
</div>
<!-- pageslide -->
<div id="pageslide">
<div class="page-title clearfix">
<a class="pull-right" href="javascript:$.pageslide.close()">
<i class="icons-arrow-left-2"></i>
</a>
<span></span>
</div>
<div class="view-page">
<div class="nano">
<div class="content">
<div id="add-tags">
<div class="tab-content">
<div class="set_new tab-pane fade active in">
<%= form_for :archive_exam_subject, url: nil, remote: true do |f| %>
<fieldset>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "archive_exam_sets" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "check_archive_exam_set_subjects.js" %>
<%= javascript_include_tag "archive_exam_sets.js" %>
<% end %>
<script type="text/javascript">
var validate = function(dom){
var valid = true;
if($(dom).val()==""){
valid=false;
$(dom).parent().parent().addClass('error');
$(dom).next().removeClass('hide');
}else{
$(dom).parent().parent().removeClass('error');
$(dom).next().addClass('hide');
}
return valid;
}
$(function(){
$.each($('.set_new form input:text'),function(){
$(this).blur(function(){
validate($(this));
});
$(this).keyup(function(){
validate($(this));
});
});
});
$("#tag_submit").click(function(){
var valid = true;
$.each($(".set_new form input:text"),function(){
if(!validate($(this))) valid=false;
});
if(!valid) return false;
});
</script>
<!-- pageslide:end -->

View File

@ -0,0 +1,8 @@
$("#delete_archive_exam_subjects").modal('hide');
$("#archive_exam_subjects_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();
$('.card').cardCheck({
item: $('.card input[type="checkbox"]'),
});
checkedLength();

View File

@ -0,0 +1,16 @@
<div id="delete_archive_exam_test_types" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t('archive_exam_test_type.del_test_type') %></h3>
</div>
<div class="modal-body tags">
<span class="text-warning text-center"><%= t('tag.warning.delete') %></span>
<hr>
<ul class="tags-groups checkbox-card">
</ul>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<%= link_to t(:delete_), nil, class: "delete-tags btn btn-danger", method: :post, remote: true %>
</div>
</div>

View File

@ -0,0 +1,11 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<label class="control-label"><%= "#{t(:name)} (#{t(locale)})" %></label>
<div class="controls">
<input class="input-large" id="<%=locale%>" name="archive_exam_test_type[title_translations][<%=locale%>]" placeholder="<%=t(:name)%>" type="text">
<span class="help-inline hide"><%= t('front_page.name_field_helper') %></span>
</div>
</div>
<% end %>
<% end %>

View File

@ -0,0 +1,27 @@
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<button id="selectAllTags" class="btn"><%= t(:select_all) %></button>
<button id="deselect" class="btn btn-inverse toggable hide"><%= t(:deselect_all) %></button>
<%= link_to t(:delete_), '#', id: "deleteUnits", class: "btn btn-danger toggable hide", rel: '' %>
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add), '#', class: "btn btn-primary open-slide", data: {title: t('archive_exam_test_type.new_test_type'), id: 'new'} %>
</div>
</div>
<!-- footer:end -->
<!-- tags -->
<div class="tags">
<div id="tags-list">
<p class="tag-lead lead muted"><%= t('archive_exam_test_type.set_test_type') %></p>
<% if !@archive_exam_test_types.blank? %>
<ul class="tags-groups checkbox-card module-tags">
<%= render partial: "test_type", collection: @archive_exam_test_types, locals: {in_module: true} %>
</ul>
<% end %>
</div>
</div>
<!-- tags:end -->
<!-- delete -->
<%= render 'delete_modal' %>
<!-- delete:end -->

View File

@ -0,0 +1,8 @@
<li class="filter-item default">
<p class="card pull-left">
<input type="checkbox" value="<%= test_type.id %>">
</p>
<%= link_to '#', class: "open-slide", data: {title: t('archive_exam_test_type.edit_test_type'), id: test_type.id.to_s, form: test_type.title_translations} do %>
<%= test_type.title_translations.values.join(" / ") %>
<% end %>
</li>

View File

@ -0,0 +1,81 @@
<div id="archive_exam_test_types_index">
<%= render 'index' %>
</div>
<!-- pageslide -->
<div id="pageslide">
<div class="page-title clearfix">
<a class="pull-right" href="javascript:$.pageslide.close()">
<i class="icons-arrow-left-2"></i>
</a>
<span></span>
</div>
<div class="view-page">
<div class="nano">
<div class="content">
<div id="add-tags">
<div class="tab-content">
<div class="set_new tab-pane fade active in">
<%= form_for :archive_exam_test_type, url: nil, remote: true do |f| %>
<fieldset>
<%= render :partial => "form", :locals => { :f => f } %>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %>
</div>
</fieldset>
<% end %>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "archive_exam_sets" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "check_archive_exam_set_test_types.js" %>
<%= javascript_include_tag "archive_exam_sets.js" %>
<% end %>
<script type="text/javascript">
var validate = function(dom){
var valid = true;
if($(dom).val()==""){
valid=false;
$(dom).parent().parent().addClass('error');
$(dom).next().removeClass('hide');
}else{
$(dom).parent().parent().removeClass('error');
$(dom).next().addClass('hide');
}
return valid;
}
$(function(){
$.each($('.set_new form input:text'),function(){
$(this).blur(function(){
validate($(this));
});
$(this).keyup(function(){
validate($(this));
});
});
});
$("#tag_submit").click(function(){
var valid = true;
$.each($(".set_new form input:text"),function(){
if(!validate($(this))) valid=false;
});
if(!valid) return false;
});
</script>
<!-- pageslide:end -->

View File

@ -0,0 +1,8 @@
$("#delete_archive_exam_test_types").modal('hide');
$("#archive_exam_test_types_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();
$('.card').cardCheck({
item: $('.card input[type="checkbox"]'),
});
checkedLength();

View File

@ -0,0 +1,54 @@
<% # encoding: utf-8 %>
<%
data = action_data
@categories = data["categories"]
@archive_exam_test_types = data["archive_exam_test_types"]
@archive_exam_grades = data["archive_exam_grades"]
@archive_exam_colleges = data["archive_exam_colleges"]
@archive_exam_departments = data["archive_exam_departments"]
@archive_exam_subjects = data["archive_exam_subjects"]
%>
<ul class="nav nav-tabs" role="tablist" id="myTab">
<% @categories.each_with_index do |category,i| %>
<li role="presentation" class="<% i == 0 ? 'active' : '' %>"><a href="#a<%= i %>" aria-controls="<%= category.title %>" role="tab" data-toggle="tab"><%= category.title %></a></li>
<% end %>
</ul>
<div class="tab-content">
<% @categories.each_with_index do |category,i| %>
<div role="tabpanel" class="tab-pane <% i == 0 ? 'active' : '' %>" id="a<%= i %>">
<p>
<form method='get' action="" target="_blank">
<%= t('archive_exam.test_type') %> <%= select_tag 'test_type', options_for_select(ArchiveExamFile.get_test_types(category)) %>
<% if category.title == '大學部' or category.title == 'University' %>
<%= t('archive_exam.grade') %> <%= select_tag 'grade', options_for_select(@archive_exam_grades.collect{ |u| [u.title, u.id] }) %>
<% end %>
<%= t('archive_exam.year') %> <%= select_year(DateTime.now.year, {:start_year => (DateTime.now.year - 1911), :end_year => (1998 - 1911), prompt: 'Select'}, {:name => 'year', :class => "span1"} ) %>
<%= t('archive_exam.college') %> <%= select_tag 'college', options_for_select(@archive_exam_colleges.collect{ |u| [u.title, u.id] }) %>
<%= t('archive_exam.department') %> <%= select_tag 'department', options_for_select(@archive_exam_departments.collect{ |u| [u.title, u.id] }) %>
<%= t('archive_exam.subject') %> <%= select_tag 'subject', options_for_select(@archive_exam_subjects.collect{ |u| [u.title, u.id] }) %>
<br />
<input type="hidden" name="category" value="<%= category.id%>">
<input type="hidden" name="method" value="result">
<input type="submit" value="<%= t('submit') %>">
</form>
</p>
</div>
<% end %>
</div>
<script>
$(function () {
$('#myTab a:first').tab('show')
})
</script>

View File

@ -0,0 +1,62 @@
<% # encoding: utf-8 %>
<%
data = action_data
@cagetoey = data["cagetoey"]
@archive_exam_files = data["archive_exam_files"]
@test_type = data["test_type"]
@grade = data["grade"]
@year = data["year"]
@college = data["college"]
@department = data["department"]
@subject = data["subject"]
%>
<%= @test_type %>
<%= @grade %>
<%= @year %>
<%= @college %>
<%= @department %>
<%= @subject %>
<% if !@archive_exam_files.blank? %>
<h4 class="i-archive_exam__category-title"><%= @category %></h4>
<ul>
<% @archive_exam_files.collect do |archive_exam| %>
<li>
<dl>
<div class="i-archive_exam__item-wrap">
<dt class="i-archive_exam__category-item">
<sapn class="i-archive_exam__archive_exam-title"><%= archive_exam.title %></span>
</dt>
<dl class="i-archive_exam__file-list">
<%
files = archive_exam.archive_exam_file_multiples.order_by(:sort_number=>'asc').collect do |file|
title = (file.file_title.blank? ? File.basename(file.file.path) : file.file_title) rescue ""
extension = file.file.file.extension.downcase rescue ""
url = file.file.url rescue ""
%>
<dd class="i-archive_exam__file-wrap">
<a class="i-archive_exam__file-name" href="<%= url %>" target="_blank"><%= title %></a>
<span class="i-archive_exam__file-type label label-primary"><%= extension %></span>
</dd>
<% end %>
</dl>
</div>
</dl>
</li>
<% end %>
</ul>
<% else %>
<p>
no data
</p>
<% end %>

19
archive_exam.gemspec Normal file
View File

@ -0,0 +1,19 @@
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "archive_exam/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "archive_exam"
s.version = ArchiveExam::VERSION
s.authors = ["Ruling Digital"]
s.email = ["orbit@rulingcom.com"]
s.homepage = "http://www.rulingcom.com"
s.summary = "ArchiveExam module for Orbit."
s.description = "ArchiveExam module for Orbit"
s.license = "MIT"
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
s.test_files = Dir["test/**/*"]
end

2
bin/rails Executable file → Normal file
View File

@ -2,7 +2,7 @@
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__) ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/archive/engine', __FILE__) ENGINE_PATH = File.expand_path('../../lib/archive_exam/engine', __FILE__)
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

View File

@ -1,16 +1,56 @@
en: en:
archive: archive_exam:
archive: Archive archive_exam: ArchiveExam
all: All all: All
new: New new: New
show_lang: Language show_lang: Language
download: Download download: Download
archive: Archive archive_exam: ArchiveExam
Title: Title Title: Title
Files: Files Files: Files
Category: Category Category: Category
year: 年度
set_archive_exam_test_types: 設定考試類型
set_archive_exam_grades: 設定年級
set_archive_exam_colleges: 設定學院
set_archive_exam_departments: 設定系所
set_archive_exam_subjects: 設定科目
frontend: frontend:
archive: Archive Frontend archive_exam: ArchiveExam Frontend
widget: widget:
index: Archive Widget index: ArchiveExam Widget
archive_exam_test_type:
new_test_type: 新增考試類型
edit_test_type: 編輯考試類型
set_test_type: 設定考試類型
del_test_type: 刪除考試類型
archive_exam_grade:
new_grade: 新增年級
edit_grade: 編輯年級
set_grade: 設定年級
del_grade: 刪除年級
archive_exam_college:
new_college: 新增學院
edit_college: 編輯學院
set_college: 設定學院
del_college: 刪除學院
archive_exam_department:
new_department: 新增系所
edit_department: 編輯系所
set_department: 設定系所
del_department: 刪除系所
archive_exam_subject:
new_subject: 新增科目
edit_subject: 編輯科目
set_subject: 設定科目
del_subject: 刪除科目

View File

@ -1,17 +1,63 @@
zh_tw: zh_tw:
archive: archive_exam:
show_lang: 呈現語系 show_lang: 呈現語系
download: 檔案下載 download: 檔案下載
archive: 檔案室 archive_exam: 考古題檔案室
Title: 標題 Title: 標題
Files: 檔案 Files: 檔案
Category: 類別 Category: 類別
year: 年度
test_type: 考試類型
grade: 年級
college: 學院
department: 系所
subject: 科目
set_archive_exam_test_types: 設定考試類型
set_archive_exam_grades: 設定年級
set_archive_exam_colleges: 設定學院
set_archive_exam_departments: 設定系所
set_archive_exam_subjects: 設定科目
frontend: frontend:
archive: 檔案室前台 archive_exam: 檔案室前台
widget: widget:
index: 檔案室Widget index: 檔案室Widget
mongoid: mongoid:
attributes: attributes:
archive_file: archive_exam_file:
sort_number: 排序數 sort_number: 排序數
archive_exam_test_type:
new_test_type: 新增考試類型
edit_test_type: 編輯考試類型
set_test_type: 設定考試類型
del_test_type: 刪除考試類型
archive_exam_grade:
new_grade: 新增年級
edit_grade: 編輯年級
set_grade: 設定年級
del_grade: 刪除年級
archive_exam_college:
new_college: 新增學院
edit_college: 編輯學院
set_college: 設定學院
del_college: 刪除學院
archive_exam_department:
new_department: 新增系所
edit_department: 編輯系所
set_department: 設定系所
del_department: 刪除系所
archive_exam_subject:
new_subject: 新增科目
edit_subject: 編輯科目
set_subject: 設定科目
del_subject: 刪除科目

View File

@ -4,7 +4,34 @@ locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_l
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
resources :archive_files resources :archive_exam_files
resources :archive_exam_test_types do
collection do
post 'delete_test_types'
end
end
resources :archive_exam_grades do
collection do
post 'delete_grades'
end
end
resources :archive_exam_colleges do
collection do
post 'delete_colleges'
end
end
resources :archive_exam_departments do
collection do
post 'delete_departments'
end
end
resources :archive_exam_subjects do
collection do
post 'delete_subjects'
end
end
end end
end end

4
lib/archive_exam.rb Normal file
View File

@ -0,0 +1,4 @@
require "archive_exam/engine"
module ArchiveExam
end

View File

@ -0,0 +1,77 @@
module ArchiveExam
class Engine < ::Rails::Engine
initializer "archive_exam" do
OrbitApp.registration "ArchiveExam", :type => "ModuleApp" do
module_label "archive_exam.archive_exam"
base_url File.expand_path File.dirname(__FILE__)
taggable "ArchiveExamFile"
categorizable
authorizable
frontend_enabled
side_bar do
head_label_i18n 'archive_exam.archive_exam', icon_class: "icon-building"
available_for "users"
active_for_controllers (['admin/archive_exam_files'])
head_link_path "admin_archive_exam_files_path"
context_link 'all',
:link_path=>"admin_archive_exam_files_path" ,
:priority=>1,
:active_for_action=>{'admin/archive_exam_files'=>"index"},
:available_for => 'users'
context_link 'new_',
:link_path=>"new_admin_archive_exam_file_path" ,
:priority=>2,
:active_for_action=>{'admin/archive_exam_files'=>"new"},
:available_for => 'sub_managers'
context_link 'categories',
:link_path=>"admin_module_app_categories_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'archive_exam').id}",
:priority=>3,
:active_for_action=>{'admin/archive_exam_files'=>'categories'},
:active_for_category => 'ArchiveExam',
:available_for => 'managers'
context_link 'archive_exam.set_archive_exam_test_types',
:link_path=>"admin_archive_exam_test_types_path" ,
:priority=>4,
:active_for_action=>{'admin/archive_exams'=>'archive_exam_test_types'},
:available_for => 'managers'
context_link 'archive_exam.set_archive_exam_grades',
:link_path=>"admin_archive_exam_grades_path" ,
:priority=>5,
:active_for_action=>{'admin/archive_exams'=>'archive_exam_grades'},
:available_for => 'managers'
context_link 'archive_exam.set_archive_exam_departments',
:link_path=>"admin_archive_exam_departments_path" ,
:priority=>6,
:active_for_action=>{'admin/archive_exams'=>'archive_exam_departments'},
:available_for => 'managers'
context_link 'archive_exam.set_archive_exam_colleges',
:link_path=>"admin_archive_exam_colleges_path" ,
:priority=>7,
:active_for_action=>{'admin/archive_exams'=>'archive_exam_colleges'},
:available_for => 'managers'
context_link 'archive_exam.set_archive_exam_subjects',
:link_path=>"admin_archive_exam_subjects_path" ,
:priority=>8,
:active_for_action=>{'admin/archive_exams'=>'archive_exam_subjects'},
:available_for => 'managers'
context_link 'tags',
:link_path=>"admin_module_app_tags_path" ,
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'archive_exam').id}",
:priority=>9,
:active_for_action=>{'admin/archive_exam_files'=>'tags'},
:active_for_tag => 'ArchiveExam',
:available_for => 'managers'
end
end
end
end
end

View File

@ -0,0 +1,3 @@
module ArchiveExam
VERSION = "0.0.1"
end

View File

@ -0,0 +1,4 @@
# desc "Explaining what the task does"
# task :archive_exam do
# # Task goes here
# end

View File

@ -1,7 +1,7 @@
require 'test_helper' require 'test_helper'
class ArchiveTest < ActiveSupport::TestCase class ArchiveExamTest < ActiveSupport::TestCase
test "truth" do test "truth" do
assert_kind_of Module, Archive assert_kind_of Module, ArchiveExam
end end
end end

View File

@ -1,6 +1,6 @@
require 'test_helper' require 'test_helper'
class Admin::ArchiveFilesControllerTest < ActionController::TestCase class Admin::ArchiveExamFilesControllerTest < ActionController::TestCase
test "should get index" do test "should get index" do
get :index get :index
assert_response :success assert_response :success

0
test/dummy/bin/bundle Executable file → Normal file
View File

0
test/dummy/bin/rails Executable file → Normal file
View File

0
test/dummy/bin/rake Executable file → Normal file
View File

View File

@ -9,7 +9,7 @@ require "sprockets/railtie"
require "rails/test_unit/railtie" require "rails/test_unit/railtie"
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
require "archive" require "archive_exam"
module Dummy module Dummy
class Application < Rails::Application class Application < Rails::Application

View File

@ -1,4 +1,4 @@
require 'test_helper' require 'test_helper'
class Admin::ArchiveFilesHelperTest < ActionView::TestCase class Admin::ArchiveExamFilesHelperTest < ActionView::TestCase
end end

View File

@ -1,6 +1,6 @@
require 'test_helper' require 'test_helper'
class ArchiveFileTest < ActiveSupport::TestCase class ArchiveExamFileTest < ActiveSupport::TestCase
# test "the truth" do # test "the truth" do
# assert true # assert true
# end # end