Пример #1
0
/*echo html_writer::start_tag('div', array('class' => 'clearer'));
echo html_writer::end_tag('div');
$mform->display();
*/
if (!$iid) {
    // If the import form has been submitted.
    if ($mform->is_cancelled()) {
        redirect($url);
    } else {
        if ($formdata = $mform->get_data()) {
            // Large files are likely to take their time and memory. Let PHP know
            // that we'll take longer, and that the process should be recycled soon
            // to free up memory.
            @set_time_limit(0);
            raise_memory_limit(MEMORY_EXTRA);
            $text = $mform->get_file_content('userfile');
            $iid = csv_import_reader::get_new_iid('rooms');
            $csvimport = new csv_import_reader($iid, 'rooms');
            $csvimport->load_csv_content($text, $formdata->encoding, $separator);
            // --- get header (field names) ---
            $header = $csvimport->get_columns();
            // Print a preview of the data.
            $numlines = 0;
            // 0 lines previewed so far.
            echo $OUTPUT->heading(get_string('importpreview', 'grades'));
            foreach ($header as $i => $h) {
                $h = trim($h);
                // Remove whitespace.
                $h = clean_param($h, PARAM_RAW);
                // Clean the header.
                $header[$i] = $h;
Пример #2
0
        $data = json_decode($data);
        $xml = base64_decode($data->content);
    } else {
        print_error('errorimporting');
    }
    if (cr_import_xml($xml, $course)) {
        redirect("$CFG->wwwroot/blocks/cobalt_reports/managereport.php?courseid={$course->id}", get_string('reportcreated', 'block_cobalt_reports'));
    } else {
        print_error('errorimporting');
    }
}

$mform = new import_form(null, $course->id);

if ($data = $mform->get_data()) {
    if ($xml = $mform->get_file_content('userfile')) {
        if (cr_import_xml($xml, $course)) {
            redirect("$CFG->wwwroot/blocks/cobalt_reports/managereport.php?courseid={$course->id}", get_string('reportcreated', 'block_cobalt_reports'));
        } else {
            print_error('errorimporting');
        }
    }
}

$reports = cr_get_my_reports($course->id, $USER->id);

$title = get_string('reports', 'block_cobalt_reports');

//$courseurl =  new moodle_url($CFG->wwwroot.'/course/view.php',array('id'=>$report->courseid));
//$PAGE->navbar->add($COURSE->shortname, $courseurl);
//$managereporturl =  new moodle_url($CFG->wwwroot.'/blocks/cobalt_reports/managereport.php',array('courseid'=>$courseid));