public function on_course_modules_end() {

        foreach ($this->converter->get_stash('modnameslist') as $modname) {
            $modinfo = $this->converter->get_stash('modinfo_'.$modname);
            foreach ($modinfo['instances'] as $modinstanceid => $modinstance) {
                $cminfo    = $this->converter->get_stash('cminfo_'.$modname, $modinstanceid);
                $directory = 'activities/'.$modname.'_'.$cminfo['id'];

                // write module.xml
                $this->open_xml_writer($directory.'/module.xml');
                $this->write_xml('module', $cminfo, array('/module/id', '/module/version'));
                $this->close_xml_writer();

                // write grades.xml
                $this->open_xml_writer($directory.'/grades.xml');
                $this->xmlwriter->begin_tag('activity_gradebook');
                $gradeitems = $this->converter->get_stash_or_default('gradebook_modgradeitem_'.$modname, $modinstanceid, array());
                if (!empty($gradeitems)) {
                    $this->xmlwriter->begin_tag('grade_items');
                    foreach ($gradeitems as $gradeitem) {
                        $this->write_xml('grade_item', $gradeitem, array('/grade_item/id'));
                    }
                    $this->xmlwriter->end_tag('grade_items');
                }
                $this->write_xml('grade_letters', array()); // no grade_letters in module context in Moodle 1.9
                $this->xmlwriter->end_tag('activity_gradebook');
                $this->close_xml_writer();

                // todo: write proper roles.xml, for now we just make sure the file is present
                $this->make_sure_xml_exists($directory.'/roles.xml', 'roles');
            }
        }
    }