Commit 69c34a65 by Chris Dodge

switch the notification to be a prompt and allow for the user to go to the edit…

switch the notification to be a prompt and allow for the user to go to the edit unit page which contains the module in error. Otherwise, present the raw exception message and allow user to go to the course outline page.
parent fcaf3e63
......@@ -346,24 +346,42 @@ def generate_export_course(request, org, course, name):
try:
export_to_xml(modulestore('direct'), contentstore(), loc, root_dir, name, modulestore())
except SerializationError, e:
failed_item = modulestore().get_item(e.location)
parent_locs = modulestore().get_parent_locations(failed_item.location, None)
failed_item = modulestore().get_instance(course_module.location.course_id, e.location)
parent_locs = modulestore().get_parent_locations(failed_item.location, course_module.location.course_id)
unit = None
if len(parent_locs) > 0:
parent = modulestore().get_item(parent_locs[0])
parent_info = "Parent Display Name: {0}<br />Parent Identifier: {1}".format(parent.display_name, parent.location.name)
else:
parent_info = ''
if parent.location.category == 'vertical':
unit = parent
return render_to_response('export.html', {
'context_course': course_module,
'successful_import_redirect_url': '',
'err_msg': "A courseware module has failed to convert to XML. Details: <br />Module Type: {0}<br />Display Name: {1}<br />Identifier: {2}<br />{3}".
format(failed_item.location.category, failed_item.display_name, failed_item.location.name, parent_info)
'in_err': True,
'raw_err_msg': str(e),
'failed_module': failed_item,
'unit': unit,
'edit_unit_url': reverse('edit_unit', kwargs={
'location': parent.location
}),
'course_home_url': reverse('course_index', kwargs={
'org': org,
'course': course,
'name': name
})
})
except Exception, e:
return render_to_response('export.html', {
'context_course': course_module,
'successful_import_redirect_url': '',
'err_msg': str(e)
'in_err': True,
'unit': None,
'raw_err_msg': str(e),
'course_home_url': reverse('course_index', kwargs={
'org': org,
'course': course,
'name': name
})
})
logging.debug('tar file being generated at {0}'.format(export_file.name))
......
......@@ -7,17 +7,55 @@
<%block name="bodyclass">is-signedin course tools export</%block>
<%block name="jsextra">
% if err_msg:
% if in_err:
<script type='text/javascript'>
$(document).ready(function() {
var defaultTitle = gettext('There has been an error with your export.');
var msg = "${err_msg}";
dialog = new CMS.Views.Alert.Confirmation({
title: defaultTitle,
message: msg,
intent: "error",
closeIcon: false
});
%if unit:
dialog = new CMS.Views.Prompt({
title: gettext('There has been an error with your export.'),
message: gettext("There has been a failure to export to XML at least one component. It is recommended that you go to the edit page and repair the error before attempting another export. Please check that all components on the page are valid and do not display any error messages."),
intent: "error",
actions: {
primary: {
text: gettext('Yes, allow me to fix the failed component'),
click: function(view) {
view.hide();
document.location = "${edit_unit_url}"
}
},
secondary: {
text: gettext('cancel'),
click: function(view) {
view.hide();
}
}
}
});
% else:
var msg = gettext("<p>There has been a failure to export your course to XML. Unfortunately, we do not have specific enough information to assist you in identifying the failed component. It is recommended that you inspect your courseware to identify any components in error and try again.</p><p>The raw error message is:</p>");
msg = msg + "${raw_err_msg}";
dialog = new CMS.Views.Prompt({
title: gettext('There has been an error with your export.'),
message: msg,
intent: "error",
actions: {
primary: {
text: gettext('Yes, take me to the main course page'),
click: function(view) {
view.hide();
document.location = "${course_home_url}"
}
},
secondary: {
text: gettext('cancel'),
click: function(view) {
view.hide();
}
}
}
});
%endif
dialog.show();
})
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment