re-add selective course copy options
add the selective course copy back in and change it to use the updated format for what items are selected Test Plan: * Copy some courses and selectively choose items * Only the items you selected should copy refs #4645 Change-Id: Id5043b4e5e4a285b1f5cefd2ab16473052026484 Reviewed-on: https://gerrit.instructure.com/9763 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Simon Williams <simon@instructure.com>
This commit is contained in:
parent
a942ede9c6
commit
567eb8b068
|
@ -142,25 +142,14 @@ class ContentImportsController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def migrate_content_execute
|
||||
if authorized_action(@context, @current_user, :manage_content)
|
||||
migration_id = params[:id] || params[:copy] && params[:copy][:content_migration_id]
|
||||
@content_migration = ContentMigration.find_by_context_id_and_context_type_and_id(@context.id, @context.class.to_s, migration_id) if migration_id.present?
|
||||
@content_migration ||= ContentMigration.find_by_context_id_and_context_type(@context.id, @context.class.to_s, :order => "id DESC")
|
||||
if request.method == :post
|
||||
if params[:items_to_copy]
|
||||
params[:copy] ||= {}
|
||||
params[:items_to_copy].each_pair do |key, vals|
|
||||
params[:copy][key] ||= {}
|
||||
if vals && ! vals.empty?
|
||||
vals.each do |val|
|
||||
params[:copy][key][val] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
params.delete :items_to_copy
|
||||
end
|
||||
process_migration_params
|
||||
@content_migration.migration_settings[:migration_ids_to_import] = params
|
||||
@content_migration.save
|
||||
@content_migration.import_content
|
||||
|
@ -187,6 +176,17 @@ class ContentImportsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def copy_course_checklist
|
||||
if authorized_action(@context, @current_user, :manage_content)
|
||||
find_source_course
|
||||
if @source_course
|
||||
render :json => {:selection_list => render_to_string(:partial => 'copy_course_item_selection', :layout => false)}
|
||||
else
|
||||
render.html ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def copy_course_finish
|
||||
if authorized_action(@context, @current_user, :manage_content)
|
||||
cm = ContentMigration.find_by_context_id_and_id(@context.id, params[:content_migration_id])
|
||||
|
@ -277,6 +277,7 @@ class ContentImportsController < ApplicationController
|
|||
copy_params[:everything] = true
|
||||
end
|
||||
else
|
||||
process_migration_params
|
||||
@source_course = Course.find(params[:source_course])
|
||||
copy_params = params[:copy]
|
||||
end
|
||||
|
@ -347,6 +348,21 @@ class ContentImportsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def process_migration_params
|
||||
if params[:items_to_copy]
|
||||
params[:copy] ||= {}
|
||||
params[:items_to_copy].each_pair do |key, vals|
|
||||
params[:copy][key] ||= {}
|
||||
if vals && !vals.empty?
|
||||
vals.each do |val|
|
||||
params[:copy][key][val] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
params.delete :items_to_copy
|
||||
end
|
||||
end
|
||||
|
||||
SELECTION_CONVERSIONS = {
|
||||
"external_tools" => "context_external_tools",
|
||||
"files" => "attachments",
|
||||
|
|
|
@ -49,4 +49,8 @@ module ContentImportsHelper
|
|||
user_content(string)
|
||||
end
|
||||
end
|
||||
|
||||
def mig_id(obj)
|
||||
CC::CCHelper.create_key(obj)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -341,7 +341,7 @@ class ContentMigration < ActiveRecord::Base
|
|||
|
||||
def download_exported_data
|
||||
raise "No exported data to import" unless self.exported_attachment
|
||||
config = Setting.from_config('external_migration')
|
||||
config = Setting.from_config('external_migration') || {}
|
||||
@exported_data_zip = self.exported_attachment.open(
|
||||
:need_local_file => true,
|
||||
:temp_folder => config[:data_folder])
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
<h3><%= check_box :copy, :course_settings, :class => "copy_all", :checked => false %><%= label :copy, :course_settings, image_tag('file_multiple.png') + " " + t('labels.copy_settings', "Settings from %{course}", :course => @source_course.name) %></h3>
|
||||
|
||||
<% if @source_course.assignment_groups.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_assignments, :class => "copy_all", :checked => true %><%= label :copy, :all_assignments, image_tag('assignment.png') + " " + t('labels.assignment', "Assignments for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.assignment_groups.active.each do |group| %>
|
||||
<li>
|
||||
<h4><%= check_box "copy[assignment_groups]", mig_id(group), :class => "copy_all" %><%= label :copy, mig_id(group), group.name %></h4>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% group.assignments.active.each do |assignment| %>
|
||||
<li>
|
||||
<%= check_box "copy[assignments]", mig_id(assignment) %>
|
||||
<%= label "copy[assignments]", mig_id(assignment), assignment.title %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.context_modules.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_context_modules, :class => "copy_all", :checked => true %><%= label :copy, :all_context_modules, image_tag('ball.png') + " " + t('labels.modules', "Modules for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.context_modules.active.each do |mod| %>
|
||||
<li>
|
||||
<%= check_box "copy[context_modules]", mig_id(mod) %>
|
||||
<%= label "copy[context_modules]", mig_id(mod), mod.name %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.learning_outcomes.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_learning_outcomes, :class => "copy_all", :checked => true %><%= label :copy, :all_learning_outcomes, image_tag('flagged_question_dim.png') + " " + t('labels.learning_outcomes', "Learning Outcomes for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.learning_outcomes.active.each do |mod| %>
|
||||
<li>
|
||||
<%= check_box "copy[learning_outcomes]", mig_id(mod) %>
|
||||
<%= label "copy[learning_outcomes]", mig_id(mod), mod.short_description %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.quizzes.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_quizzes, :class => "copy_all", :checked => true %><%= label :copy, :all_quizzes, image_tag('quiz.png') + " " + t('labels.quizzes', "Quizzes for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.quizzes.active.each do |quiz| %>
|
||||
<li>
|
||||
<%= check_box "copy[quizzes]", mig_id(quiz) %>
|
||||
<%= label "copy[quizzes]", mig_id(quiz), quiz.title %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.assessment_question_banks.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_assessment_question_banks, :class => "copy_all", :checked => true %><%= label :copy, :all_assessment_question_banks, image_tag('quiz.png') + " " + t('labels.question_banks', "Question Banks for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.assessment_question_banks.active.each do |bank| %>
|
||||
<li>
|
||||
<%= check_box "copy[assessment_question_banks]", mig_id(bank) %>
|
||||
<%= label "copy[assessment_question_banks]", mig_id(bank), bank.title %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.folders.active.length > 0 && @source_course.attachments.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_attachments, :class => "copy_all", :checked => true %><%= label :copy, :all_attachments, image_tag('download.png') + " " + t('labels.files', "Files for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list root_asset_list">
|
||||
<% @source_course.folders.active.sort_by { |f| f.full_name }.each do |folder| %>
|
||||
<% if folder.attachments.length > 0 %>
|
||||
<li>
|
||||
<h4><%= check_box "copy[folders]", mig_id(folder), :class => "copy_all" %><%= label "copy[folders]", mig_id(folder), folder.full_name %></h4>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% folder.attachments.each do |file| %>
|
||||
<li><%= check_box "copy[attachments]", mig_id(file) %><%= label "copy[attachments]", mig_id(file), file.display_name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.wiki.wiki_pages.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_wiki_pages, :class => "copy_all", :checked => true %><%= label :copy, :all_wiki_pages, image_tag('course_content_icon.png') + " " + t('labels.wiki_ages', "Wiki Pages for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% @source_course.wiki.wiki_pages.active.each do |page| %>
|
||||
<li><%= check_box "copy[wiki_pages]", mig_id(page) %><%= label "copy[wiki_pages]", mig_id(page), page.title %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.discussion_topics.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_discussion_topics, :class => "copy_all" %><%= label :copy, :all_discussion_topics, image_tag('word_bubble.png') + " " + t('labels.discussions', "Discussions for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% @source_course.discussion_topics.active.each do |topic| %>
|
||||
<li><%= check_box "copy[discussion_topics]", mig_id(topic) %><%= label "copy[discussion_topics]", mig_id(topic), topic.title %>
|
||||
<div style="font-size: 0.8em; padding-left: 25px;">
|
||||
<%= check_box "copy[discussion_entries]", mig_id(topic), :class => "secondary_checkbox skip" %><%= label "copy[discussion_entries]", mig_id(topic), :copy, :en => "include entries from the old course" %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.calendar_events.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_calendar_events, :class => "copy_all", :checked => true %><%= label :copy, :all_calendar_events, image_tag('due_date_icon.png') + " " + t('labels.events', "Events for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% @source_course.calendar_events.active.each do |event| %>
|
||||
<li><%= check_box "copy[calendar_events]", mig_id(event) %><%= label "copy[calendar_events]", mig_id(event), event.title %>
|
||||
-
|
||||
<span style="font-size: 0.8em;"><%= datetime_string(event.start_at) %></span>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% if @source_course.context_external_tools.active.length > 0 %>
|
||||
<h3><%= check_box :copy, :all_context_external_tools, :class => "copy_all", :checked => true %><%= label :copy, :all_context_external_tools, t('labels.external_tools', "External Tools for %{course}", :course => @source_course.name) %></h3>
|
||||
<ul class="unstyled_list asset_list">
|
||||
<% @source_course.context_external_tools.active.each do |tool| %>
|
||||
<li><%= check_box "copy[context_external_tools]", mig_id(tool) %><%= label "copy[context_external_tools]", mig_id(tool), tool.name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
|
@ -2,7 +2,7 @@
|
|||
<h3><%= check_box :copy, :shift_dates, :class => "shift_dates_checkbox" %><%= label :copy, :shift_dates, :en => "Adjust events and due dates" %></h3>
|
||||
<div style="display: none; margin-left: 50px;" class="shift_dates_settings">
|
||||
<div>
|
||||
<div style="margin-bottom: 5px;"><%= t 'labels.dates_range', "%{course} dates range", :course => '<strong class="course_name">...</strong>'.html_safe %></div>
|
||||
<div style="margin-bottom: 5px;"><%= t 'labels.dates_range', "%{course} dates range", :course => %{<strong class="course_name">#{@source_course.name}</strong>}.html_safe %></div>
|
||||
<% ot 'from_to', "*from* %{start_date} **to** %{end_date}",
|
||||
:start_date => capture { %>
|
||||
<div style="float: left;"><%= text_field :copy, :old_start_date, :value => "", :class => "date_field", :style => "width: 120px;" %></div>
|
||||
|
|
|
@ -3,7 +3,10 @@
|
|||
<% add_crumb t('crumbs.choose_course', "Choose Course"), context_url(@context, :context_import_choose_course_url) %>
|
||||
<% add_crumb t('crumbs.choose_content', "Choose Content") %>
|
||||
|
||||
<% js_env :COPY_COURSE_FINISH_URL => context_url(@context, :context_import_copy_course_finish_url)%>
|
||||
<%
|
||||
js_env :COPY_COURSE_FINISH_URL => context_url(@context, :context_import_copy_course_finish_url)
|
||||
js_env :CONTENT_SELECT_URL => context_url(@context, :context_import_copy_course_checklist_url) + "?source_course=#{@source_course.id}"
|
||||
%>
|
||||
|
||||
<% content_for :stylesheets do %>
|
||||
<style>
|
||||
|
|
|
@ -194,6 +194,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
course.import_content 'imports/content', :controller => 'content_imports', :action => 'content'
|
||||
course.import_choose_course 'imports/choose_course', :controller => 'content_imports', :action => 'choose_course', :conditions => {:method => :get}
|
||||
course.import_choose_content 'imports/choose_content', :controller => 'content_imports', :action => 'choose_content', :conditions => {:method => :get}
|
||||
course.import_copy_course_checklist 'imports/copy_course_checklist', :controller => 'content_imports', :action => 'copy_course_checklist', :conditions => {:method => :get}
|
||||
course.import_copy_course_finish 'imports/copy_course_finish', :controller => 'content_imports', :action => 'copy_course_finish', :conditions => {:method => :get}
|
||||
course.import_migrate 'imports/migrate', :controller => 'content_imports', :action => 'migrate_content'
|
||||
course.import_upload 'imports/upload', :controller => 'content_imports', :action => 'migrate_content_upload'
|
||||
|
|
|
@ -79,6 +79,8 @@ module CC::Importer::Canvas
|
|||
def run_qti_converter(qti_folder)
|
||||
# convert to 2.1
|
||||
@dest_dir_2_1 = File.join(qti_folder, "qti_2_1")
|
||||
return unless File.exists?(qti_folder)
|
||||
|
||||
command = Qti.get_conversion_command(@dest_dir_2_1, qti_folder)
|
||||
logger.debug "Running migration command: #{command}"
|
||||
python_std_out = `#{command}`
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
define([
|
||||
'jquery' /* $ */,
|
||||
'i18n!content_imports',
|
||||
'compiled/util/processItemSelections',
|
||||
'compiled/util/processMigrationItemSelections',
|
||||
'jquery.ajaxJSON' /* ajaxJSON */,
|
||||
'jquery.instructure_date_and_time' /* date_field */,
|
||||
'jquery.instructure_forms' /* formSubmit */,
|
||||
|
@ -10,7 +10,7 @@ define([
|
|||
'jquery.rails_flash_notifications' /* flashError */,
|
||||
'jqueryui/autocomplete' /* /\.autocomplete/ */,
|
||||
'jqueryui/progressbar' /* /\.progressbar/ */
|
||||
], function($, I18n, processItemSelections){
|
||||
], function($, I18n, processMigrationItemSelections){
|
||||
|
||||
$(function () {
|
||||
var $frame = $("<iframe id='copy_course_target' name='copy_course_target' src='about:blank'/>");
|
||||
|
@ -42,7 +42,7 @@ define([
|
|||
};
|
||||
|
||||
$("#copy_context_form").formSubmit({
|
||||
//processData:processItemSelections,
|
||||
processData:processMigrationItemSelections,
|
||||
beforeSubmit:function (data) {
|
||||
$("#copy_context_form .submit_button").text(I18n.t('messages.copying', "Copying... this will take a few minutes")).attr('disabled', true);
|
||||
$(".progress_bar_holder").show();
|
||||
|
@ -53,8 +53,9 @@ define([
|
|||
}, 5000);
|
||||
}
|
||||
});
|
||||
|
||||
$("#copy_entries_dialog button").click(function () {
|
||||
var $checkbox = $("#copy_all_topics");
|
||||
var $checkbox = $("#copy_all_discussion_topics");
|
||||
var include_secondaries = $(this).hasClass('include');
|
||||
if (include_secondaries) {
|
||||
$checkbox.parent().next("ul").find(":checkbox:not(.secondary_checkbox)").prop('checked', $checkbox.prop('checked')).each(function () {
|
||||
|
@ -65,28 +66,40 @@ define([
|
|||
}
|
||||
$("#copy_entries_dialog").dialog('close');
|
||||
});
|
||||
$("#copy_context_form :checkbox").bind('change', function (event, force_secondaries) {
|
||||
|
||||
var checkEverything = function (checked) {
|
||||
$("#copy_context_form :checkbox:not(.secondary_checkbox):not(.copy_everything):not(.skip_on_everything):not(.shift_dates_checkbox)")
|
||||
.prop('checked', checked)
|
||||
.filter(":not(.copy_all)")
|
||||
.each(function () {
|
||||
$(this).triggerHandler('change');
|
||||
});
|
||||
};
|
||||
|
||||
var itemSelectionsFetchDfd;
|
||||
var $itemSelectionsDiv = $("#item_selections");
|
||||
|
||||
$("#copy_context_form").delegate(':checkbox', 'change', function (event, force_secondaries) {
|
||||
if (!$(this).attr('checked')) {
|
||||
force_secondaries = true;
|
||||
}
|
||||
if ($(this).hasClass('copy_all')) {
|
||||
if ($(this).is('#copy_all_topics') && $(this).attr('checked')) {
|
||||
$("#copy_entries_dialog").dialog('close').dialog({
|
||||
autoOpen:false,
|
||||
title:I18n.t('titles.copy_discussion_replies', "Copy Discussion Replies?"),
|
||||
width:370
|
||||
}).dialog('open');
|
||||
} else {
|
||||
$(this).parent().next("ul").find(":checkbox:not(.secondary_checkbox)").prop('checked', $(this).prop('checked')).each(function () {
|
||||
$(this).triggerHandler('change');
|
||||
});
|
||||
$('#copy_everything').attr('checked', false);
|
||||
}
|
||||
} else if ($(this).hasClass('copy_everything')) {
|
||||
$("#copy_context_form :checkbox:not(.secondary_checkbox):not(.copy_everything):not(.skip_on_everything):not(.shift_dates_checkbox)").prop('checked', $(this).prop('checked')).filter(":not(.copy_all)").each(function () {
|
||||
$(this).parent().next("ul").find(":checkbox:not(.secondary_checkbox)").prop('checked', $(this).prop('checked')).each(function () {
|
||||
$(this).triggerHandler('change');
|
||||
});
|
||||
$("#copy_all_topics").prop('checked', $(this).prop('checked')).triggerHandler('change');
|
||||
$('#copy_everything').attr('checked', false);
|
||||
} else if ($(this).hasClass('copy_everything')) {
|
||||
if ($(this).prop('checked')) {
|
||||
$itemSelectionsDiv.hide();
|
||||
} else {
|
||||
var url = ENV.CONTENT_SELECT_URL;
|
||||
itemSelectionsFetchDfd = itemSelectionsFetchDfd || $.ajaxJSON(url, 'GET', {}, function (data) {
|
||||
if (data) {
|
||||
$itemSelectionsDiv.find('.content_list').html(data.selection_list);
|
||||
}
|
||||
});
|
||||
$itemSelectionsDiv.show().disableWhileLoading(itemSelectionsFetchDfd);
|
||||
}
|
||||
} else {
|
||||
$(this).parent().find(":checkbox.secondary_checkbox" + (force_secondaries ? '' : ':not(.skip)')).attr('checked', $(this).attr('checked'));
|
||||
if ($(this).hasClass('secondary_checkbox') && $(this).attr('checked')) {
|
||||
|
@ -103,6 +116,16 @@ define([
|
|||
}
|
||||
});
|
||||
|
||||
$("#check_everything").click(function (event) {
|
||||
event.preventDefault();
|
||||
checkEverything(true);
|
||||
});
|
||||
|
||||
$("#uncheck_everything").click(function (event) {
|
||||
event.preventDefault();
|
||||
checkEverything(false);
|
||||
});
|
||||
|
||||
$(".shift_dates_checkbox").change(
|
||||
function () {
|
||||
$(".shift_dates_settings").showIf($(this).attr('checked'));
|
||||
|
|
|
@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/common')
|
|||
describe "courses" do
|
||||
it_should_behave_like "in-process server selenium tests"
|
||||
|
||||
context "course as a teacher" do
|
||||
context "as a teacher" do
|
||||
|
||||
before (:each) do
|
||||
account = Account.default
|
||||
|
@ -69,87 +69,117 @@ describe "courses" do
|
|||
url.should match(%r{/files/\d+/download\?verifier=})
|
||||
end
|
||||
|
||||
it "should copy course content" do
|
||||
course_with_teacher_logged_in
|
||||
@second_course = Course.create!(:name => 'second course')
|
||||
@second_course.offer!
|
||||
5.times do |i|
|
||||
@second_course.wiki.wiki_pages.create!(:title => "hi #{i}", :body => "Whatever #{i}")
|
||||
end
|
||||
#add teacher as a user
|
||||
e = @second_course.enroll_teacher(@user)
|
||||
e.workflow_state = 'active'
|
||||
e.accept
|
||||
e.save!
|
||||
@second_course.reload
|
||||
|
||||
new_term = Account.default.enrollment_terms.create(:name => 'Test Term')
|
||||
third_course = Course.create!(:name => 'third course', :enrollment_term => new_term)
|
||||
e = third_course.enroll_teacher(@user)
|
||||
e.workflow_state = 'active'
|
||||
e.accept
|
||||
e.save!
|
||||
|
||||
get "/courses/#{@course.id}/details"
|
||||
|
||||
wait_for_ajaximations
|
||||
driver.find_element(:link, I18n.t('links.import', 'Import Content into this Course')).click
|
||||
driver.find_element(:css, '#content a.button').click
|
||||
|
||||
select_box = driver.find_element(:id, 'copy_from_course')
|
||||
select_box.find_elements(:css, 'optgroup').length.should == 2
|
||||
second_group = select_box.find_elements(:css, 'optgroup').last
|
||||
second_group.find_elements(:css, 'option').length.should == 1
|
||||
second_group.attribute('label').should == 'Test Term'
|
||||
|
||||
click_option('#copy_from_course', 'second course')
|
||||
driver.find_element(:css, '#content form').submit
|
||||
|
||||
#driver.find_element(:id, 'copy_everything').click
|
||||
|
||||
#modify course dates
|
||||
driver.find_element(:id, 'copy_shift_dates').click
|
||||
#adjust start dates
|
||||
driver.find_element(:css, '#copy_old_start_date + img').click
|
||||
datepicker_prev
|
||||
#adjust end dates
|
||||
driver.find_element(:css, '#copy_old_end_date + img').click
|
||||
datepicker_next
|
||||
#adjust day substitutions
|
||||
driver.find_element(:css, '.shift_dates_settings .add_substitution_link').click
|
||||
driver.find_element(:css, '.substitutions > .substitution').should be_displayed
|
||||
|
||||
driver.find_element(:id, 'copy_context_form').submit
|
||||
wait_for_ajaximations
|
||||
|
||||
# since jobs aren't running
|
||||
ContentMigration.last.copy_course_without_send_later
|
||||
|
||||
keep_trying_until { driver.find_element(:css, '#copy_results > h2').should include_text('Copy Succeeded') }
|
||||
@course.reload
|
||||
@course.wiki.wiki_pages.count.should == 5
|
||||
end
|
||||
|
||||
it "should copy the course" do
|
||||
enable_cache do
|
||||
context "course copy" do
|
||||
def course_copy_helper
|
||||
course_with_teacher_logged_in
|
||||
@second_course = Course.create!(:name => 'second course')
|
||||
@second_course.offer!
|
||||
5.times do |i|
|
||||
@course.wiki.wiki_pages.create!(:title => "hi #{i}", :body => "Whatever #{i}")
|
||||
@second_course.wiki.wiki_pages.create!(:title => "hi #{i}", :body => "Whatever #{i}")
|
||||
end
|
||||
#add teacher as a user
|
||||
e = @second_course.enroll_teacher(@user)
|
||||
e.workflow_state = 'active'
|
||||
e.accept
|
||||
e.save!
|
||||
@second_course.reload
|
||||
|
||||
new_term = Account.default.enrollment_terms.create(:name => 'Test Term')
|
||||
third_course = Course.create!(:name => 'third course', :enrollment_term => new_term)
|
||||
e = third_course.enroll_teacher(@user)
|
||||
e.workflow_state = 'active'
|
||||
e.accept
|
||||
e.save!
|
||||
|
||||
get "/courses/#{@course.id}/details"
|
||||
|
||||
wait_for_ajaximations
|
||||
driver.find_element(:link, I18n.t('links.import', 'Import Content into this Course')).click
|
||||
driver.find_element(:css, '#content a.button').click
|
||||
|
||||
select_box = driver.find_element(:id, 'copy_from_course')
|
||||
select_box.find_elements(:css, 'optgroup').length.should == 2
|
||||
second_group = select_box.find_elements(:css, 'optgroup').last
|
||||
second_group.find_elements(:css, 'option').length.should == 1
|
||||
second_group.attribute('label').should == 'Test Term'
|
||||
|
||||
click_option('#copy_from_course', 'second course')
|
||||
driver.find_element(:css, '#content form').submit
|
||||
|
||||
yield driver if block_given?
|
||||
|
||||
#modify course dates
|
||||
driver.find_element(:id, 'copy_shift_dates').click
|
||||
#adjust start dates
|
||||
driver.find_element(:css, '#copy_old_start_date + img').click
|
||||
datepicker_prev
|
||||
#adjust end dates
|
||||
driver.find_element(:css, '#copy_old_end_date + img').click
|
||||
datepicker_next
|
||||
#adjust day substitutions
|
||||
driver.find_element(:css, '.shift_dates_settings .add_substitution_link').click
|
||||
driver.find_element(:css, '.substitutions > .substitution').should be_displayed
|
||||
|
||||
get "/courses/#{@course.id}/copy"
|
||||
expect_new_page_load { driver.find_element(:css, "div#content form").submit }
|
||||
driver.find_element(:id, 'copy_context_form').submit
|
||||
wait_for_ajaximations
|
||||
|
||||
# since jobs aren't running
|
||||
ContentMigration.last.copy_course_without_send_later
|
||||
|
||||
keep_trying_until { driver.find_element(:css, '#copy_results > h2').should include_text('Copy Succeeded') }
|
||||
@course.reload
|
||||
end
|
||||
|
||||
@new_course = Course.last(:order => :id)
|
||||
get "/courses/#{@new_course.id}"
|
||||
driver.find_element(:css, "#no_topics_message span.title").should include_text("No Recent Messages")
|
||||
@new_course.wiki.wiki_pages.count.should == 5
|
||||
it "should copy course content" do
|
||||
course_copy_helper
|
||||
@course.wiki.wiki_pages.count.should == 5
|
||||
end
|
||||
|
||||
it "should copy content if things are unselected in hidden boxes" do
|
||||
course_copy_helper do |driver|
|
||||
driver.find_element(:id, 'copy_everything').click
|
||||
wait_for_ajaximations
|
||||
driver.find_element(:id, 'uncheck_everything').click
|
||||
driver.find_element(:id, 'copy_everything').click
|
||||
end
|
||||
@course.wiki.wiki_pages.count.should == 5
|
||||
end
|
||||
|
||||
it "should selectively copy content" do
|
||||
course_copy_helper do |driver|
|
||||
driver.find_element(:id, 'copy_everything').click
|
||||
wait_for_ajaximations
|
||||
driver.find_element(:id, 'uncheck_everything').click
|
||||
@second_course.wiki.wiki_pages[0..2].each do |page|
|
||||
driver.find_element(:id, "copy_wiki_pages_#{CC::CCHelper.create_key(page)}").click
|
||||
end
|
||||
end
|
||||
@course.wiki.wiki_pages.count.should == 3
|
||||
end
|
||||
|
||||
it "should copy the course" do
|
||||
enable_cache do
|
||||
course_with_teacher_logged_in
|
||||
5.times do |i|
|
||||
@course.wiki.wiki_pages.create!(:title => "hi #{i}", :body => "Whatever #{i}")
|
||||
end
|
||||
|
||||
get "/courses/#{@course.id}/copy"
|
||||
expect_new_page_load { driver.find_element(:css, "div#content form").submit }
|
||||
driver.find_element(:id, 'copy_context_form').submit
|
||||
wait_for_ajaximations
|
||||
driver.find_element(:id, 'copy_everything').click
|
||||
wait_for_ajaximations
|
||||
|
||||
keep_trying_until { ContentMigration.last.copy_course_without_send_later }
|
||||
|
||||
keep_trying_until { driver.find_element(:css, '#copy_results > h2').should include_text('Copy Succeeded') }
|
||||
|
||||
@new_course = Course.last(:order => :id)
|
||||
get "/courses/#{@new_course.id}"
|
||||
driver.find_element(:css, "#no_topics_message span.title").should include_text("No Recent Messages")
|
||||
@new_course.wiki.wiki_pages.count.should == 5
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue