MDL-49490 assign: can't export to portfolio on non-submission
authorDan Poltawski <dan@moodle.com>
Wed, 4 Nov 2015 14:10:40 +0000 (14:10 +0000)
committerDan Poltawski <dan@moodle.com>
Wed, 18 Nov 2015 09:10:20 +0000 (09:10 +0000)
mod/assign/renderable.php

index ecd4d1a..ec10f34 100644 (file)
@@ -788,7 +788,7 @@ class assign_files implements renderable {
 
         if (!empty($CFG->enableportfolios)) {
             require_once($CFG->libdir . '/portfoliolib.php');
-            if (count($files) >= 1 &&
+            if (count($files) >= 1 && !empty($sid) &&
                     has_capability('mod/assign:exportownsubmission', $this->context)) {
                 $button = new portfolio_add_button();
                 $callbackparams = array('cmid' => $this->cm->id,
@@ -823,6 +823,7 @@ class assign_files implements renderable {
         foreach ($dir['files'] as $file) {
             $file->portfoliobutton = '';
             if (!empty($CFG->enableportfolios)) {
+                require_once($CFG->libdir . '/portfoliolib.php');
                 $button = new portfolio_add_button();
                 if (has_capability('mod/assign:exportownsubmission', $this->context)) {
                     $portfolioparams = array('cmid' => $this->cm->id, 'fileid' => $file->get_id());