moodle/course/import/activities/mod.html
moodler f8b3c0f484 New plugin structure for code that imports stuff into a course
Old import.php is now import/activities and we've added a new plugin
for importing groups from an external file
2005-11-05 08:06:36 +00:00

80 lines
3 KiB
HTML

<?php // $Id$
require_once($CFG->dirroot.'/course/lib.php');
require_once($CFG->dirroot.'/backup/restorelib.php');
// if we're not a course creator , we can only import from our own courses.
if (iscreator()) {
$creator = true;
}
$strimport = get_string("importdata");
$taught_courses = get_my_courses($USER->id,"visible DESC,sortorder ASC",0,1);
if (!empty($creator)) {
$cat_courses = get_courses($course->category);
} else {
$cat_courses = array();
}
print_heading(get_string("importactivities"));
$options = array();
foreach ($taught_courses as $tcourse) {
if ($tcourse->id != $course->id && $tcourse->id != SITEID){
$options[$tcourse->id] = $tcourse->fullname;
}
}
$fm = '<form method="post" action="'.$CFG->wwwroot.'/course/import/activities/index.php"><input type="hidden" name="id" value="'.$course->id.'" />';
$submit = '<input type="submit" value="'.get_string('usethiscourse').'" /></form>';
if (count($options) > 0) {
$table->data[] = array($fm.'<b>'.get_string('coursestaught').'</b>',
choose_from_menu($options,"fromcourse","","choose","","0",true),
$submit);
}
unset($options);
$options = array();
foreach ($cat_courses as $ccourse) {
if ($ccourse->id != $course->id && $ccourse->id != SITEID) {
$options[$ccourse->id] = $ccourse->fullname;
}
}
$cat = get_record("course_categories","id",$course->category);
if (count($options) > 0) {
$table->data[] = array($fm.'<b>'.get_string('coursescategory').' ('.$cat->name .')</b>',
choose_from_menu($options,"fromcourse","","choose","","0",true),
$submit);
}
if (!empty($creator)) {
$table->data[] = array($fm.'<b>'.get_string('searchcourses').'</b>',
'<input type="text" name="fromcoursesearch" />',
'<input type="submit" value="'.get_string('searchcourses').'" /></form>');
}
if (!empty($fromcoursesearch) && !empty($creator)) {
$totalcount = 0;
$courses = get_courses_search(explode(" ",$fromcoursesearch),"fullname ASC",$page,50,$totalcount);
if (is_array($courses) and count($courses) > 0) {
$table->data[] = array('<b>'.get_string('searchresults').'</b>','','');
foreach ($courses as $scourse) {
if ($course->id != $scourse->id) {
$table->data[] = array('',$scourse->fullname,
'<a href="'.$CFG->wwwroot.'/course/import/activities/index.php?id='.$course->id.'&fromcourse='.$scourse->id.'">'
.get_string('usethiscourse'));
}
}
}
else {
$table->data[] = array('',get_string('noresults'),'');
}
}
print_table($table);
?>