|
|
|
|
@ -4,10 +4,16 @@ |
|
|
|
|
|
|
|
|
|
namespace Chamilo\PluginBundle\XApi\ToolExperience\Statement; |
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Entity\PortfolioAttachment; |
|
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\Course as CourseActivity; |
|
|
|
|
use Chamilo\PluginBundle\XApi\ToolExperience\Activity\Site as SiteActivity; |
|
|
|
|
use Chamilo\UserBundle\Entity\User; |
|
|
|
|
use Xabbuh\XApi\Model\Attachment; |
|
|
|
|
use Xabbuh\XApi\Model\Context; |
|
|
|
|
use Xabbuh\XApi\Model\ContextActivities; |
|
|
|
|
use Xabbuh\XApi\Model\IRI; |
|
|
|
|
use Xabbuh\XApi\Model\IRL; |
|
|
|
|
use Xabbuh\XApi\Model\LanguageMap; |
|
|
|
|
use Xabbuh\XApi\Model\Statement; |
|
|
|
|
use Xabbuh\XApi\Model\StatementId; |
|
|
|
|
use Xabbuh\XApi\Model\Uuid; |
|
|
|
|
@ -50,4 +56,56 @@ abstract class BaseStatement |
|
|
|
|
new ContextActivities(null, $groupingActivities) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param array|PortfolioAttachment[] $portfolioAttachments |
|
|
|
|
* @param \Chamilo\UserBundle\Entity\User $user |
|
|
|
|
* |
|
|
|
|
* @return array|Attachment[] |
|
|
|
|
*/ |
|
|
|
|
protected function generateAttachments(array $portfolioAttachments, User $user): array |
|
|
|
|
{ |
|
|
|
|
if (empty($portfolioAttachments)) { |
|
|
|
|
return []; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$attachments = []; |
|
|
|
|
|
|
|
|
|
$userDirectory = \UserManager::getUserPathById($user->getId(), 'system'); |
|
|
|
|
$attachmentsDirectory = $userDirectory.'portfolio_attachments/'; |
|
|
|
|
|
|
|
|
|
$langIso = api_get_language_isocode(); |
|
|
|
|
|
|
|
|
|
$cidreq = api_get_cidreq(); |
|
|
|
|
$baseUrl = api_get_path(WEB_CODE_PATH).'portfolio/index.php?'.($cidreq ? $cidreq.'&' : ''); |
|
|
|
|
|
|
|
|
|
foreach ($portfolioAttachments as $portfolioAttachment) { |
|
|
|
|
$attachmentFilename = $attachmentsDirectory.$portfolioAttachment->getPath(); |
|
|
|
|
|
|
|
|
|
$display = LanguageMap::create( |
|
|
|
|
['und' => $portfolioAttachment->getFilename()] |
|
|
|
|
); |
|
|
|
|
$description = null; |
|
|
|
|
|
|
|
|
|
if ($portfolioAttachment->getComment()) { |
|
|
|
|
$description = LanguageMap::create( |
|
|
|
|
[$langIso => $portfolioAttachment->getComment()] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$attachments[] = new Attachment( |
|
|
|
|
IRI::fromString('http://id.tincanapi.com/attachment/supporting_media'), |
|
|
|
|
mime_content_type($attachmentFilename), |
|
|
|
|
$portfolioAttachment->getSize(), |
|
|
|
|
hash_file('sha256', $attachmentFilename), |
|
|
|
|
$display, |
|
|
|
|
$description, |
|
|
|
|
IRL::fromString( |
|
|
|
|
$baseUrl.http_build_query(['action' => 'download', 'file' => $portfolioAttachment->getPath()]) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $attachments; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|