added index page for external course migrations
closes #4230 Change-Id: Ibc550f1fc2b5fb5a0498982d676e98848530cab2 Reviewed-on: https://gerrit.instructure.com/3013 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
parent
6fdea80b52
commit
5ee8313865
|
@ -70,6 +70,7 @@ class ContentImportsController < ApplicationController
|
|||
else
|
||||
@plugins = Canvas::Plugin.all_for_tag(:export_system)
|
||||
@select_options = @plugins.map{|p|[p.settings[:select_text], p.id]}
|
||||
@pending_migrations = ContentMigration.find_all_by_context_id(@context.id).any?
|
||||
render
|
||||
end
|
||||
end
|
||||
|
@ -184,4 +185,13 @@ class ContentImportsController < ApplicationController
|
|||
@quizzes = @context.quizzes.active
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
if authorized_action(@context, @current_user, :update)
|
||||
@successful = ContentMigration.successful.find_all_by_context_id(@context.id)
|
||||
@running = ContentMigration.running.find_all_by_context_id(@context.id)
|
||||
@waiting = ContentMigration.waiting.find_all_by_context_id(@context.id)
|
||||
@failed = ContentMigration.failed.find_all_by_context_id(@context.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -145,6 +145,14 @@ class ContentMigration < ActiveRecord::Base
|
|||
self.context.root_account rescue nil
|
||||
end
|
||||
|
||||
def plugin_type
|
||||
if plugin = Canvas::Plugin.find(migration_settings['migration_type'])
|
||||
plugin.settings['select_text'] || plugin.name
|
||||
else
|
||||
migration_settings['migration_type'].titleize
|
||||
end
|
||||
end
|
||||
|
||||
def export_content
|
||||
plugin = Canvas::Plugin.find(migration_settings['migration_type'])
|
||||
if plugin
|
||||
|
@ -216,6 +224,11 @@ class ContentMigration < ActiveRecord::Base
|
|||
{:conditions => {:context_id => context.id, :context_type => context.class.to_s} }
|
||||
}
|
||||
|
||||
named_scope :successful, :conditions=>"workflow_state = 'imported'"
|
||||
named_scope :running, :conditions=>"workflow_state IN ('exporting', 'importing')"
|
||||
named_scope :waiting, :conditions=>"workflow_state IN ('exported')"
|
||||
named_scope :failed, :conditions=>"workflow_state IN ('failed', 'pre_process_error')"
|
||||
|
||||
def download_exported_data
|
||||
raise "No exported data to import" unless self.exported_attachment
|
||||
config = Setting.from_config('external_migration')
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<% add_crumb "Migrations" %>
|
||||
|
||||
<% content_for :page_title do %>Active Migrations
|
||||
<% end %>
|
||||
|
||||
<% content_for :page_header do %>
|
||||
<h1>Active Migrations</h1>
|
||||
<% end %>
|
||||
|
||||
<% if @waiting.length > 0 %>
|
||||
<h2>Migrations Needing Action</h2>
|
||||
<% @waiting.each do |mig| %>
|
||||
<%
|
||||
url = "/#{@context.class.to_s.downcase.pluralize}/#{@context.id}/imports/migrate/#{mig.id}"
|
||||
%>
|
||||
<p>
|
||||
<%= mig.plugin_type %> migration -
|
||||
<a href="<%= url %>">
|
||||
Click here to choose the content to import.
|
||||
</a>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @successful.length > 0 %>
|
||||
<h2>Successful Migrations</h2>
|
||||
<% @successful.each do |mig| %>
|
||||
<p><%= mig.plugin_type %> migration - This migration was successfully imported.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @running.length > 0 %>
|
||||
<h2>Migrations Being Processed</h2>
|
||||
<% @running.each do |mig| %>
|
||||
<p><%= mig.plugin_type %> migration - This migration is being processed.</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @failed.length > 0 %>
|
||||
<h2>Failed Migrations</h2>
|
||||
<% @failed.each do |mig| %>
|
||||
<p><%= mig.plugin_type %> migration - There was an error with this migration. Please give
|
||||
your administrator this migration identifier: <%= "ContentMigration:#{mig.id}" %></p>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -10,6 +10,12 @@
|
|||
from your course, and you can then specify which parts you'd
|
||||
like to have added to your new course.
|
||||
</p>
|
||||
|
||||
<% if @pending_migrations %>
|
||||
<p>There are previous migrations for this course: <%= link_to "View Migrations", course_import_list_path(@context) %></p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% form_tag context_url(@context, :context_import_migrate_url), :method => :post, :class=> 'file_upload', :id => "migration_form", :multipart => true do %>
|
||||
<input type="hidden" name="export_file_enabled" value="0" id="export_file_enabled"/>
|
||||
<input type="hidden" name="content_migration_id" id="content_migration_id"/>
|
||||
|
|
|
@ -95,6 +95,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
course.import_migrate_choose 'imports/migrate/:id', :controller => 'content_imports', :action => 'migrate_content_choose'
|
||||
course.import_migrate_execute 'imports/migrate/:id/execute', :controller => 'content_imports', :action => 'migrate_content_execute'
|
||||
course.import_review 'imports/review', :controller => 'content_imports', :action => 'review'
|
||||
course.import_list 'imports/list', :controller => 'content_imports', :action => 'index'
|
||||
course.resource :gradebook_upload
|
||||
course.resources :notifications, :only => [:index, :destroy, :update], :collection => {:clear => :post}
|
||||
course.grades "grades", :controller => 'gradebooks', :action => 'grade_summary', :id => nil
|
||||
|
|
|
@ -4,12 +4,12 @@ Rails.configuration.to_prepare do
|
|||
|
||||
Canvas::Plugin.register :qti_exporter, nil, {
|
||||
:name =>'QTI Exporter',
|
||||
:author => 'Bracken Mosbacker',
|
||||
:author => 'Instructure',
|
||||
:description => 'This enables exporting QTI .zip files to Canvas quiz json.',
|
||||
:version => '1.0.0',
|
||||
:settings_partial => 'plugins/qti_exporter_settings',
|
||||
:settings => {
|
||||
:enabled=>python_converter_found, :worker=>'QtiWorker'},
|
||||
:enabled=>python_converter_found, :worker=>'QtiWorker', :select_text=>'QTI .zip file'},
|
||||
:validator => 'QtiPluginValidator'
|
||||
}
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ module Canvas
|
|||
raise "Can't export QTI without the python converter tool installed."
|
||||
end
|
||||
cm = ContentMigration.find migration_id
|
||||
settings = cm.migration_settings
|
||||
settings = cm.migration_settings.clone
|
||||
settings[:content_migration_id] = migration_id
|
||||
settings[:user_id] = cm.user_id
|
||||
settings[:attachment_id] = cm.attachment.id rescue nil
|
||||
|
|
Loading…
Reference in New Issue