diff --git a/Gemfile b/Gemfile index 8fc116f..823fc1f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ 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 # development dependencies will be added by default to the :development group. gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 148e653..115275a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - archive (0.0.1) + archive_exam (0.0.1) mongoid (= 4.0.0.beta1) rails (~> 4.1.0.rc2) @@ -101,4 +101,4 @@ PLATFORMS ruby DEPENDENCIES - archive! + archive_exam! diff --git a/README.rdoc b/README.rdoc index 2a19864..057b076 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,3 +1,3 @@ -= Archive += ArchiveExam This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile index 3d6998f..dd9c539 100644 --- a/Rakefile +++ b/Rakefile @@ -8,7 +8,7 @@ require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Archive' + rdoc.title = 'ArchiveExam' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.rdoc') rdoc.rdoc_files.include('lib/**/*.rb') diff --git a/app/assets/images/archive_exam/.keep b/app/assets/images/archive_exam/.keep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/javascripts/archive_exam_sets.js b/app/assets/javascripts/archive_exam_sets.js new file mode 100644 index 0000000..92be5b3 --- /dev/null +++ b/app/assets/javascripts/archive_exam_sets.js @@ -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'); + } + + }); +}) \ No newline at end of file diff --git a/app/assets/javascripts/check_archive_exam_set_colleges.js.erb b/app/assets/javascripts/check_archive_exam_set_colleges.js.erb new file mode 100644 index 0000000..51c254b --- /dev/null +++ b/app/assets/javascripts/check_archive_exam_set_colleges.js.erb @@ -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(); +}); diff --git a/app/assets/javascripts/check_archive_exam_set_departments.js.erb b/app/assets/javascripts/check_archive_exam_set_departments.js.erb new file mode 100644 index 0000000..4810868 --- /dev/null +++ b/app/assets/javascripts/check_archive_exam_set_departments.js.erb @@ -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(); +}); diff --git a/app/assets/javascripts/check_archive_exam_set_grades.js.erb b/app/assets/javascripts/check_archive_exam_set_grades.js.erb new file mode 100644 index 0000000..33b33f8 --- /dev/null +++ b/app/assets/javascripts/check_archive_exam_set_grades.js.erb @@ -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(); +}); diff --git a/app/assets/javascripts/check_archive_exam_set_subjects.js.erb b/app/assets/javascripts/check_archive_exam_set_subjects.js.erb new file mode 100644 index 0000000..b92da4a --- /dev/null +++ b/app/assets/javascripts/check_archive_exam_set_subjects.js.erb @@ -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(); +}); diff --git a/app/assets/javascripts/check_archive_exam_set_test_types.js.erb b/app/assets/javascripts/check_archive_exam_set_test_types.js.erb new file mode 100644 index 0000000..e418a3c --- /dev/null +++ b/app/assets/javascripts/check_archive_exam_set_test_types.js.erb @@ -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(); +}); diff --git a/app/assets/stylesheets/archive_exam_sets.css b/app/assets/stylesheets/archive_exam_sets.css new file mode 100644 index 0000000..16aacf9 --- /dev/null +++ b/app/assets/stylesheets/archive_exam_sets.css @@ -0,0 +1,3 @@ +/* + *= require lib/tags-groups +*/ \ No newline at end of file diff --git a/app/controllers/admin/archive_exam_colleges_controller.rb b/app/controllers/admin/archive_exam_colleges_controller.rb new file mode 100644 index 0000000..3ceb82a --- /dev/null +++ b/app/controllers/admin/archive_exam_colleges_controller.rb @@ -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 diff --git a/app/controllers/admin/archive_exam_departments_controller.rb b/app/controllers/admin/archive_exam_departments_controller.rb new file mode 100644 index 0000000..516f2da --- /dev/null +++ b/app/controllers/admin/archive_exam_departments_controller.rb @@ -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 diff --git a/app/controllers/admin/archive_exam_files_controller.rb b/app/controllers/admin/archive_exam_files_controller.rb new file mode 100644 index 0000000..be72849 --- /dev/null +++ b/app/controllers/admin/archive_exam_files_controller.rb @@ -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 diff --git a/app/controllers/admin/archive_exam_grades_controller.rb b/app/controllers/admin/archive_exam_grades_controller.rb new file mode 100644 index 0000000..94d5b44 --- /dev/null +++ b/app/controllers/admin/archive_exam_grades_controller.rb @@ -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 diff --git a/app/controllers/admin/archive_exam_subjects_controller.rb b/app/controllers/admin/archive_exam_subjects_controller.rb new file mode 100644 index 0000000..ef19e0c --- /dev/null +++ b/app/controllers/admin/archive_exam_subjects_controller.rb @@ -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 diff --git a/app/controllers/admin/archive_exam_test_types_controller.rb b/app/controllers/admin/archive_exam_test_types_controller.rb new file mode 100644 index 0000000..aac555f --- /dev/null +++ b/app/controllers/admin/archive_exam_test_types_controller.rb @@ -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 diff --git a/app/controllers/archive_exams_controller.rb b/app/controllers/archive_exams_controller.rb new file mode 100644 index 0000000..904687e --- /dev/null +++ b/app/controllers/archive_exams_controller.rb @@ -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 \ No newline at end of file diff --git a/app/helpers/admin/archive_exam_files_helper.rb b/app/helpers/admin/archive_exam_files_helper.rb new file mode 100644 index 0000000..aab5ad1 --- /dev/null +++ b/app/helpers/admin/archive_exam_files_helper.rb @@ -0,0 +1,2 @@ +module Admin::ArchiveExamFilesHelper +end diff --git a/app/models/archive_exam_college.rb b/app/models/archive_exam_college.rb new file mode 100644 index 0000000..2abd4ae --- /dev/null +++ b/app/models/archive_exam_college.rb @@ -0,0 +1,9 @@ +class ArchiveExamCollege + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :archive_exam_file + +end \ No newline at end of file diff --git a/app/models/archive_exam_department.rb b/app/models/archive_exam_department.rb new file mode 100644 index 0000000..6d744b6 --- /dev/null +++ b/app/models/archive_exam_department.rb @@ -0,0 +1,9 @@ +class ArchiveExamDepartment + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :archive_exam_file + +end \ No newline at end of file diff --git a/app/models/archive_exam_file.rb b/app/models/archive_exam_file.rb new file mode 100644 index 0000000..6afa1ba --- /dev/null +++ b/app/models/archive_exam_file.rb @@ -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 = "#{file_data.split('.')[-1]}".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 diff --git a/app/models/archive_exam_file_multiple.rb b/app/models/archive_exam_file_multiple.rb new file mode 100644 index 0000000..d611f26 --- /dev/null +++ b/app/models/archive_exam_file_multiple.rb @@ -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 diff --git a/app/models/archive_exam_grade.rb b/app/models/archive_exam_grade.rb new file mode 100644 index 0000000..25bd44e --- /dev/null +++ b/app/models/archive_exam_grade.rb @@ -0,0 +1,9 @@ +class ArchiveExamGrade + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :archive_exam_file + +end \ No newline at end of file diff --git a/app/models/archive_exam_subject.rb b/app/models/archive_exam_subject.rb new file mode 100644 index 0000000..2c2d0cb --- /dev/null +++ b/app/models/archive_exam_subject.rb @@ -0,0 +1,9 @@ +class ArchiveExamSubject + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :archive_exam_file + +end \ No newline at end of file diff --git a/app/models/archive_exam_test_type.rb b/app/models/archive_exam_test_type.rb new file mode 100644 index 0000000..ab4ed12 --- /dev/null +++ b/app/models/archive_exam_test_type.rb @@ -0,0 +1,9 @@ +class ArchiveExamTestType + include Mongoid::Document + include Mongoid::Timestamps + + field :title, localize: true + + belongs_to :archive_exam_file + +end \ No newline at end of file diff --git a/app/views/admin/archive_exam_colleges/_college.html.erb b/app/views/admin/archive_exam_colleges/_college.html.erb new file mode 100644 index 0000000..349c316 --- /dev/null +++ b/app/views/admin/archive_exam_colleges/_college.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= 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 %> +
  • \ No newline at end of file diff --git a/app/views/admin/archive_exam_colleges/_delete_modal.html.erb b/app/views/admin/archive_exam_colleges/_delete_modal.html.erb new file mode 100644 index 0000000..11b50b8 --- /dev/null +++ b/app/views/admin/archive_exam_colleges/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/archive_exam_colleges/_form.html.erb b/app/views/admin/archive_exam_colleges/_form.html.erb new file mode 100644 index 0000000..a5f01fa --- /dev/null +++ b/app/views/admin/archive_exam_colleges/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/archive_exam_colleges/_index.html.erb b/app/views/admin/archive_exam_colleges/_index.html.erb new file mode 100644 index 0000000..3405553 --- /dev/null +++ b/app/views/admin/archive_exam_colleges/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= 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'} %> +
    +
    + + + +
    +
    +

    <%= t('archive_exam_college.set_college') %>

    + <% if !@archive_exam_colleges.blank? %> + + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/archive_exam_colleges/index.html.erb b/app/views/admin/archive_exam_colleges/index.html.erb new file mode 100644 index 0000000..5dea00b --- /dev/null +++ b/app/views/admin/archive_exam_colleges/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :archive_exam_college, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% 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 %> + + + \ No newline at end of file diff --git a/app/views/admin/archive_exam_colleges/index.js.erb b/app/views/admin/archive_exam_colleges/index.js.erb new file mode 100644 index 0000000..0dcb95d --- /dev/null +++ b/app/views/admin/archive_exam_colleges/index.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/archive_exam_departments/_delete_modal.html.erb b/app/views/admin/archive_exam_departments/_delete_modal.html.erb new file mode 100644 index 0000000..688cb53 --- /dev/null +++ b/app/views/admin/archive_exam_departments/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/archive_exam_departments/_department.html.erb b/app/views/admin/archive_exam_departments/_department.html.erb new file mode 100644 index 0000000..bcdf9f9 --- /dev/null +++ b/app/views/admin/archive_exam_departments/_department.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= 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 %> +
  • \ No newline at end of file diff --git a/app/views/admin/archive_exam_departments/_form.html.erb b/app/views/admin/archive_exam_departments/_form.html.erb new file mode 100644 index 0000000..4f3cf95 --- /dev/null +++ b/app/views/admin/archive_exam_departments/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/archive_exam_departments/_index.html.erb b/app/views/admin/archive_exam_departments/_index.html.erb new file mode 100644 index 0000000..6d3df96 --- /dev/null +++ b/app/views/admin/archive_exam_departments/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= 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'} %> +
    +
    + + + +
    +
    +

    <%= t('archive_exam_department.set_department') %>

    + <% if !@archive_exam_departments.blank? %> + + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/archive_exam_departments/index.html.erb b/app/views/admin/archive_exam_departments/index.html.erb new file mode 100644 index 0000000..11f138d --- /dev/null +++ b/app/views/admin/archive_exam_departments/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :archive_exam_department, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% 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 %> + + + \ No newline at end of file diff --git a/app/views/admin/archive_exam_departments/index.js.erb b/app/views/admin/archive_exam_departments/index.js.erb new file mode 100644 index 0000000..a675546 --- /dev/null +++ b/app/views/admin/archive_exam_departments/index.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/archive_exam_files/_form.html.erb b/app/views/admin/archive_exam_files/_form.html.erb new file mode 100644 index 0000000..c60a393 --- /dev/null +++ b/app/views/admin/archive_exam_files/_form.html.erb @@ -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 %> + + +
    + + + + + + +
    + + +
    + + +
    + +
    + <%= select_category(f, @module_app) %> +
    +
    + + +
    + +
    + <%= 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"} ) %> +
    +
    + +
    + +
    + <% @archive_exam_test_types.collect { |t| %> + + <% } %> +
    +
    + +
    + +
    + <% @archive_exam_grades.collect { |t| %> + + <% } %> +
    +
    + +
    + +
    + <% @archive_exam_colleges.collect { |t| %> + + <% } %> +
    +
    + +
    + +
    + <% @archive_exam_departments.collect { |t| %> + + <% } %> +
    +
    + +
    + +
    + <% @archive_exam_subjects.collect { |t| %> + + <% } %> +
    +
    + + +
    + +
    + <%= f.text_field :sort_number %> +
    +
    + +
    + + +
    + + +
    + +
    + + + +
    +
    + +
    + + +
    + + +
    + + <%= select_tags(f, @module_app) %> +
    + +
    + +
    + + + + + + +
    + + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
    "> + + +
    + +
    + <%= 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 %> +
    +
    + +
    + + <% end %> + + +
    + +
    + + + <% if @archive_exam_file && !@archive_exam_file.archive_exam_file_multiples.blank? %> +
    + <% @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 %> +
    +
    + <% end %> + + +
    +
    +

    + <%= hidden_field_tag 'archive_exam_file_multiple_field_count', @archive_exam_file.archive_exam_file_multiples.count %> + <%= t(:add) %> +

    + +
    +
    +
    + +
    + + +
    + <%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + Cancel +
    + +<% content_for :page_specific_javascript do %> + +<% end %> diff --git a/app/views/admin/archive_exam_files/_form_file.html.erb b/app/views/admin/archive_exam_files/_form_file.html.erb new file mode 100644 index 0000000..f0e7032 --- /dev/null +++ b/app/views/admin/archive_exam_files/_form_file.html.erb @@ -0,0 +1,66 @@ +<% if form_file.new_record? %> +
    +<% else %> +
    + <% 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 %> +
    + + + + <% @site_in_use_locales.each_with_index do |locale, i| %> + <%= 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 %> + + <% end %> + + + + + <%= f.text_field :sort_number , :class => "input-mini" %> + + + + + + <%= hidden_field_tag 'archive_exam_file[archive_exam_file_multiples_attributes][0][choose_lang][]', '' %> + + + <% if form_file.new_record? %> + + + + <% else %> + + <%= f.hidden_field :id %> + + <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> + + <% end %> +
    +
    + diff --git a/app/views/admin/archive_exam_files/_index.html.erb b/app/views/admin/archive_exam_files/_index.html.erb new file mode 100644 index 0000000..140eadd --- /dev/null +++ b/app/views/admin/archive_exam_files/_index.html.erb @@ -0,0 +1,45 @@ + + + + + + <% @table_fields.each do |f| %> + <%= thead(f) %> + <% end %> + + + + <% @archive_exams.each do |archive_exam| %> + + + + + + + + <% end %> + +
    <%= archive_exam.status_for_table %> + <%= archive_exam.category.title rescue "" %> + <% if (archive_exam.category.disable rescue false) %> + <%= t(:disabled) %> + <% end %> + + <%= archive_exam.title %> +
    + +
    +
    <%= format_value archive_exam.updated_at rescue nil %><%= User.find(archive_exam.update_user_id).user_name rescue nil %>
    + +<%= + content_tag :div, class: "bottomnav clearfix" do + content_tag :div, paginate(@archive_exams), class: "pagination pagination-centered" + end +%> \ No newline at end of file diff --git a/app/views/admin/archive_exam_files/edit.html.erb b/app/views/admin/archive_exam_files/edit.html.erb new file mode 100644 index 0000000..6e9d3a5 --- /dev/null +++ b/app/views/admin/archive_exam_files/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @archive_exam_file, :url => {:action => "update"}, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
    + <%= render partial: 'form', locals: {f: f} %> +
    +<% end %> diff --git a/app/views/admin/archive_exam_files/index.html.erb b/app/views/admin/archive_exam_files/index.html.erb new file mode 100644 index 0000000..dba461b --- /dev/null +++ b/app/views/admin/archive_exam_files/index.html.erb @@ -0,0 +1,4 @@ +<%= render_filter @filter_fields, "index_table" %> +
    + <%= render 'index'%> +
    diff --git a/app/views/admin/archive_exam_files/new.html.erb b/app/views/admin/archive_exam_files/new.html.erb new file mode 100644 index 0000000..4c5ca75 --- /dev/null +++ b/app/views/admin/archive_exam_files/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @archive_exam_file, :url => {:action => "create"}, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
    + <%= render partial: 'form', locals: {f: f} %> +
    +<% end %> diff --git a/app/views/admin/archive_exam_grades/_delete_modal.html.erb b/app/views/admin/archive_exam_grades/_delete_modal.html.erb new file mode 100644 index 0000000..a409681 --- /dev/null +++ b/app/views/admin/archive_exam_grades/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/archive_exam_grades/_form.html.erb b/app/views/admin/archive_exam_grades/_form.html.erb new file mode 100644 index 0000000..1c8ea3f --- /dev/null +++ b/app/views/admin/archive_exam_grades/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/archive_exam_grades/_grade.html.erb b/app/views/admin/archive_exam_grades/_grade.html.erb new file mode 100644 index 0000000..e5def39 --- /dev/null +++ b/app/views/admin/archive_exam_grades/_grade.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= 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 %> +
  • \ No newline at end of file diff --git a/app/views/admin/archive_exam_grades/_index.html.erb b/app/views/admin/archive_exam_grades/_index.html.erb new file mode 100644 index 0000000..9edce4b --- /dev/null +++ b/app/views/admin/archive_exam_grades/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= 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'} %> +
    +
    + + + +
    +
    +

    <%= t('archive_exam_grade.set_grade') %>

    + <% if !@archive_exam_grades.blank? %> +
      + <%= render partial: "grade", collection: @archive_exam_grades, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/archive_exam_grades/index.html.erb b/app/views/admin/archive_exam_grades/index.html.erb new file mode 100644 index 0000000..45a1f46 --- /dev/null +++ b/app/views/admin/archive_exam_grades/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :archive_exam_grade, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% 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 %> + + + \ No newline at end of file diff --git a/app/views/admin/archive_exam_grades/index.js.erb b/app/views/admin/archive_exam_grades/index.js.erb new file mode 100644 index 0000000..1921eca --- /dev/null +++ b/app/views/admin/archive_exam_grades/index.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/archive_exam_subjects/_delete_modal.html.erb b/app/views/admin/archive_exam_subjects/_delete_modal.html.erb new file mode 100644 index 0000000..b0a0bf5 --- /dev/null +++ b/app/views/admin/archive_exam_subjects/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/archive_exam_subjects/_form.html.erb b/app/views/admin/archive_exam_subjects/_form.html.erb new file mode 100644 index 0000000..9bf701d --- /dev/null +++ b/app/views/admin/archive_exam_subjects/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/archive_exam_subjects/_index.html.erb b/app/views/admin/archive_exam_subjects/_index.html.erb new file mode 100644 index 0000000..c73e380 --- /dev/null +++ b/app/views/admin/archive_exam_subjects/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= 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'} %> +
    +
    + + + +
    +
    +

    <%= t('archive_exam_subject.set_subject') %>

    + <% if !@archive_exam_subjects.blank? %> +
      + <%= render partial: "subject", collection: @archive_exam_subjects, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/archive_exam_subjects/_subject.html.erb b/app/views/admin/archive_exam_subjects/_subject.html.erb new file mode 100644 index 0000000..7c6daab --- /dev/null +++ b/app/views/admin/archive_exam_subjects/_subject.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= 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 %> +
  • \ No newline at end of file diff --git a/app/views/admin/archive_exam_subjects/index.html.erb b/app/views/admin/archive_exam_subjects/index.html.erb new file mode 100644 index 0000000..5369ecd --- /dev/null +++ b/app/views/admin/archive_exam_subjects/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :archive_exam_subject, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% 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 %> + + + \ No newline at end of file diff --git a/app/views/admin/archive_exam_subjects/index.js.erb b/app/views/admin/archive_exam_subjects/index.js.erb new file mode 100644 index 0000000..a7a537b --- /dev/null +++ b/app/views/admin/archive_exam_subjects/index.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/admin/archive_exam_test_types/_delete_modal.html.erb b/app/views/admin/archive_exam_test_types/_delete_modal.html.erb new file mode 100644 index 0000000..1d31246 --- /dev/null +++ b/app/views/admin/archive_exam_test_types/_delete_modal.html.erb @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/app/views/admin/archive_exam_test_types/_form.html.erb b/app/views/admin/archive_exam_test_types/_form.html.erb new file mode 100644 index 0000000..84c778d --- /dev/null +++ b/app/views/admin/archive_exam_test_types/_form.html.erb @@ -0,0 +1,11 @@ +<%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
    + +
    + + <%= t('front_page.name_field_helper') %> +
    +
    + <% end %> +<% end %> diff --git a/app/views/admin/archive_exam_test_types/_index.html.erb b/app/views/admin/archive_exam_test_types/_index.html.erb new file mode 100644 index 0000000..ce14c2e --- /dev/null +++ b/app/views/admin/archive_exam_test_types/_index.html.erb @@ -0,0 +1,27 @@ + +
    +
    + + + <%= 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'} %> +
    +
    + + + +
    +
    +

    <%= t('archive_exam_test_type.set_test_type') %>

    + <% if !@archive_exam_test_types.blank? %> +
      + <%= render partial: "test_type", collection: @archive_exam_test_types, locals: {in_module: true} %> +
    + <% end %> +
    +
    + + + +<%= render 'delete_modal' %> + \ No newline at end of file diff --git a/app/views/admin/archive_exam_test_types/_test_type.html.erb b/app/views/admin/archive_exam_test_types/_test_type.html.erb new file mode 100644 index 0000000..3706bda --- /dev/null +++ b/app/views/admin/archive_exam_test_types/_test_type.html.erb @@ -0,0 +1,8 @@ +
  • +

    + +

    + <%= 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 %> +
  • \ No newline at end of file diff --git a/app/views/admin/archive_exam_test_types/index.html.erb b/app/views/admin/archive_exam_test_types/index.html.erb new file mode 100644 index 0000000..b925c21 --- /dev/null +++ b/app/views/admin/archive_exam_test_types/index.html.erb @@ -0,0 +1,81 @@ +
    + <%= render 'index' %> +
    + + +
    +
    + + + + +
    +
    +
    +
    +
    + +
    + +
    + <%= form_for :archive_exam_test_type, url: nil, remote: true do |f| %> +
    + <%= render :partial => "form", :locals => { :f => f } %> +
    + <%= t(:cancel) %> + <%= f.submit t(:submit), class: 'btn btn-primary btn-small', id: "tag_submit" %> +
    +
    + <% end %> +
    + +
    + +
    +
    +
    +
    +
    + +<% 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 %> + + + \ No newline at end of file diff --git a/app/views/admin/archive_exam_test_types/index.js.erb b/app/views/admin/archive_exam_test_types/index.js.erb new file mode 100644 index 0000000..590f8ba --- /dev/null +++ b/app/views/admin/archive_exam_test_types/index.js.erb @@ -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(); \ No newline at end of file diff --git a/app/views/archive_exams/index.html.erb b/app/views/archive_exams/index.html.erb new file mode 100644 index 0000000..669b0a3 --- /dev/null +++ b/app/views/archive_exams/index.html.erb @@ -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"] +%> + + + + + + +
    + +<% @categories.each_with_index do |category,i| %> +
    +

    +

    + <%= 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] }) %> +
    + + + +
    +

    +
    +<% end %> + +
    + + \ No newline at end of file diff --git a/app/views/archive_exams/result.html.erb b/app/views/archive_exams/result.html.erb new file mode 100644 index 0000000..c9a6ee4 --- /dev/null +++ b/app/views/archive_exams/result.html.erb @@ -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? %> + +

    <%= @category %>

    + + + +<% else %> + +

    +no data +

    + +<% end %> \ No newline at end of file diff --git a/archive_exam.gemspec b/archive_exam.gemspec new file mode 100644 index 0000000..df53b41 --- /dev/null +++ b/archive_exam.gemspec @@ -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 diff --git a/bin/rails b/bin/rails old mode 100755 new mode 100644 index 93e121d..9da5280 --- a/bin/rails +++ b/bin/rails @@ -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. 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. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/config/locales/en.yml b/config/locales/en.yml index 22252aa..2f04d82 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,16 +1,56 @@ en: - archive: - archive: Archive + archive_exam: + archive_exam: ArchiveExam all: All new: New show_lang: Language download: Download - archive: Archive + archive_exam: ArchiveExam Title: Title Files: Files 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: - archive: Archive Front-end + archive_exam: ArchiveExam Front-end widget: - index: Archive Widget \ No newline at end of file + 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: 刪除科目 + diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index d81d138..d99d581 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,17 +1,63 @@ zh_tw: - archive: + archive_exam: show_lang: 呈現語系 download: 檔案下載 - archive: 檔案室 + archive_exam: 考古題檔案室 Title: 標題 Files: 檔案 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: - archive: 檔案室前台 + archive_exam: 檔案室前台 widget: index: 檔案室Widget mongoid: attributes: - archive_file: + archive_exam_file: 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: 刪除科目 + diff --git a/config/routes.rb b/config/routes.rb index 72fe1a1..33a1b25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 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 diff --git a/lib/archive_exam.rb b/lib/archive_exam.rb new file mode 100644 index 0000000..110e694 --- /dev/null +++ b/lib/archive_exam.rb @@ -0,0 +1,4 @@ +require "archive_exam/engine" + +module ArchiveExam +end diff --git a/lib/archive_exam/engine.rb b/lib/archive_exam/engine.rb new file mode 100644 index 0000000..684aafe --- /dev/null +++ b/lib/archive_exam/engine.rb @@ -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 diff --git a/lib/archive_exam/version.rb b/lib/archive_exam/version.rb new file mode 100644 index 0000000..0adf128 --- /dev/null +++ b/lib/archive_exam/version.rb @@ -0,0 +1,3 @@ +module ArchiveExam + VERSION = "0.0.1" +end diff --git a/lib/tasks/archive_exam_tasks.rake b/lib/tasks/archive_exam_tasks.rake new file mode 100644 index 0000000..ee9c8f7 --- /dev/null +++ b/lib/tasks/archive_exam_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :archive_exam do +# # Task goes here +# end diff --git a/test/archive_test.rb b/test/archive_test.rb index 507b238..8b4fed4 100644 --- a/test/archive_test.rb +++ b/test/archive_test.rb @@ -1,7 +1,7 @@ require 'test_helper' -class ArchiveTest < ActiveSupport::TestCase +class ArchiveExamTest < ActiveSupport::TestCase test "truth" do - assert_kind_of Module, Archive + assert_kind_of Module, ArchiveExam end end diff --git a/test/controllers/admin/archive_files_controller_test.rb b/test/controllers/admin/archive_files_controller_test.rb index ff9b64d..a998a27 100644 --- a/test/controllers/admin/archive_files_controller_test.rb +++ b/test/controllers/admin/archive_files_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class Admin::ArchiveFilesControllerTest < ActionController::TestCase +class Admin::ArchiveExamFilesControllerTest < ActionController::TestCase test "should get index" do get :index assert_response :success diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle old mode 100755 new mode 100644 diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails old mode 100755 new mode 100644 diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake old mode 100755 new mode 100644 diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index fabb013..d728a91 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -9,7 +9,7 @@ require "sprockets/railtie" require "rails/test_unit/railtie" Bundler.require(*Rails.groups) -require "archive" +require "archive_exam" module Dummy class Application < Rails::Application diff --git a/test/helpers/admin/archive_files_helper_test.rb b/test/helpers/admin/archive_files_helper_test.rb index d29c88c..8d19e79 100644 --- a/test/helpers/admin/archive_files_helper_test.rb +++ b/test/helpers/admin/archive_files_helper_test.rb @@ -1,4 +1,4 @@ require 'test_helper' -class Admin::ArchiveFilesHelperTest < ActionView::TestCase +class Admin::ArchiveExamFilesHelperTest < ActionView::TestCase end diff --git a/test/models/archive_file_test.rb b/test/models/archive_file_test.rb index bf56de3..3e01e13 100644 --- a/test/models/archive_file_test.rb +++ b/test/models/archive_file_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class ArchiveFileTest < ActiveSupport::TestCase +class ArchiveExamFileTest < ActiveSupport::TestCase # test "the truth" do # assert true # end