@@ -21,7 +21,7 @@ public function index_action()
2121 Navigation::activateItem ('/course/mooc_courseware/index ' );
2222 }
2323
24- $ this ->canMigrate = $ perm ->have_studip_perm ('dozent ' , \Context::getId (), $ user ->id );
24+ $ this ->canMigrate = $ perm ->have_studip_perm ('dozent ' , \Context::getId (), $ user ->id ) && Config:: get ()-> COURSEWARE_MANUAL_MIGRATION ;
2525
2626 $ this ->status = \Mooc \DB \MigrationStatus::findOneBySQL ('seminar_id = ? ' , array ($ this ->container ['cid ' ]));
2727 $ this ->CoursewareLink = URLHelper::getLink ('dispatch.php/course/courseware/ ' , ['cid ' => $ this ->container ['cid ' ]]);
@@ -43,14 +43,28 @@ public function migrate_action()
4343 {
4444 global $ user , $ perm ;
4545
46- if (!$ perm ->have_studip_perm ('dozent ' , \Context::getId (), $ user ->id )) {
46+ $ cid = \Context::getId ();
47+
48+ if (!$ perm ->have_studip_perm ('dozent ' , $ cid , $ user ->id )) {
4749 return $ this ->redirect ('courseware ' );
4850 }
4951
50- $ status = $ this ->migrateCourseware (\Context::getId ());
52+ $ actionStatus = $ this ->migrateCourseware ($ cid );
53+
54+ if ($ actionStatus ['code ' ] === 200 ) {
55+ $ MigrationStatus = \Mooc \DB \MigrationStatus::findOneBySQL ('seminar_id = ? ' , array ($ cid ));
56+ if ($ MigrationStatus !== null ) {
57+ $ MigrationStatus ->delete ();
58+ }
59+ $ MigrationStatus = \Mooc \DB \MigrationStatus::build ([
60+ 'seminar_id ' => $ cid ,
61+ 'mkdate ' => time ()
62+ ]);
63+ $ MigrationStatus ->store ();
64+ }
5165
5266 $ this ->response ->add_header ('Content-Type ' , 'application/json ' );
53- $ this ->render_text (json_encode ($ status ));
67+ $ this ->render_text (json_encode ($ actionStatus ));
5468 }
5569
5670 private function migrateCourseware ($ cid )
0 commit comments