repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
claroline/Distribution
plugin/exo/Serializer/Misc/CellChoiceSerializer.php
CellChoiceSerializer.serialize
public function serialize(CellChoice $choice, array $options = []) { $serialized = [ 'text' => $choice->getText(), 'caseSensitive' => $choice->isCaseSensitive(), 'score' => $choice->getScore(), 'expected' => $choice->isExpected(), ]; if ($choice->getFeedback()) { $serialized['feedback'] = $choice->getFeedback(); } return $serialized; }
php
public function serialize(CellChoice $choice, array $options = []) { $serialized = [ 'text' => $choice->getText(), 'caseSensitive' => $choice->isCaseSensitive(), 'score' => $choice->getScore(), 'expected' => $choice->isExpected(), ]; if ($choice->getFeedback()) { $serialized['feedback'] = $choice->getFeedback(); } return $serialized; }
[ "public", "function", "serialize", "(", "CellChoice", "$", "choice", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'text'", "=>", "$", "choice", "->", "getText", "(", ")", ",", "'caseSensitive'", "=>", "$", "choic...
Converts a CellChoice into a JSON-encodable structure. @param CellChoice $choice @param array $options @return array
[ "Converts", "a", "CellChoice", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Misc/CellChoiceSerializer.php#L27-L41
train
claroline/Distribution
main/core/Repository/GroupRepository.php
GroupRepository.findGroupsByWorkspacesAndSearch
public function findGroupsByWorkspacesAndSearch(array $workspaces, $search) { $upperSearch = strtoupper(trim($search)); $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g LEFT JOIN g.roles wr WITH wr IN ( SELECT pr FROM Claroline\CoreBundle\Entity\Role pr WHERE pr.type = :type ) LEFT JOIN wr.workspace w WHERE w IN (:workspaces) AND UPPER(g.name) LIKE :search ORDER BY g.name '; $query = $this->_em->createQuery($dql); $query->setParameter('workspaces', $workspaces); $query->setParameter('search', "%{$upperSearch}%"); $query->setParameter('type', Role::WS_ROLE); return $query->getResult(); }
php
public function findGroupsByWorkspacesAndSearch(array $workspaces, $search) { $upperSearch = strtoupper(trim($search)); $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g LEFT JOIN g.roles wr WITH wr IN ( SELECT pr FROM Claroline\CoreBundle\Entity\Role pr WHERE pr.type = :type ) LEFT JOIN wr.workspace w WHERE w IN (:workspaces) AND UPPER(g.name) LIKE :search ORDER BY g.name '; $query = $this->_em->createQuery($dql); $query->setParameter('workspaces', $workspaces); $query->setParameter('search', "%{$upperSearch}%"); $query->setParameter('type', Role::WS_ROLE); return $query->getResult(); }
[ "public", "function", "findGroupsByWorkspacesAndSearch", "(", "array", "$", "workspaces", ",", "$", "search", ")", "{", "$", "upperSearch", "=", "strtoupper", "(", "trim", "(", "$", "search", ")", ")", ";", "$", "dql", "=", "'\n SELECT g\n ...
Returns the groups which are member of a workspace and whose name corresponds the search. @param array $workspace @param string $search @return array[Group]
[ "Returns", "the", "groups", "which", "are", "member", "of", "a", "workspace", "and", "whose", "name", "corresponds", "the", "search", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L84-L106
train
claroline/Distribution
main/core/Repository/GroupRepository.php
GroupRepository.findGroupsByNames
public function findGroupsByNames(array $names) { $nameCount = count($names); $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g WHERE g.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); if (($groupCount = count($result)) !== $nameCount) { throw new MissingObjectException("{$groupCount} out of {$nameCount} groups were found"); } return $result; }
php
public function findGroupsByNames(array $names) { $nameCount = count($names); $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g WHERE g.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); if (($groupCount = count($result)) !== $nameCount) { throw new MissingObjectException("{$groupCount} out of {$nameCount} groups were found"); } return $result; }
[ "public", "function", "findGroupsByNames", "(", "array", "$", "names", ")", "{", "$", "nameCount", "=", "count", "(", "$", "names", ")", ";", "$", "dql", "=", "'\n SELECT g FROM Claroline\\CoreBundle\\Entity\\Group g\n WHERE g.name IN (:names)\n ...
Returns groups by their names. @param array $names @return array[Group] @throws MissingObjectException if one or more groups cannot be found
[ "Returns", "groups", "by", "their", "names", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L269-L287
train
claroline/Distribution
main/core/Repository/GroupRepository.php
GroupRepository.findGroupByName
public function findGroupByName($name, $executeQuery = true) { $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g WHERE g.name = :name '; $query = $this->_em->createQuery($dql); $query->setParameter('name', $name); return $executeQuery ? $query->getOneOrNullResult() : $query; }
php
public function findGroupByName($name, $executeQuery = true) { $dql = ' SELECT g FROM Claroline\CoreBundle\Entity\Group g WHERE g.name = :name '; $query = $this->_em->createQuery($dql); $query->setParameter('name', $name); return $executeQuery ? $query->getOneOrNullResult() : $query; }
[ "public", "function", "findGroupByName", "(", "$", "name", ",", "$", "executeQuery", "=", "true", ")", "{", "$", "dql", "=", "'\n SELECT g\n FROM Claroline\\CoreBundle\\Entity\\Group g\n WHERE g.name = :name\n '", ";", "$", "query", "="...
Returns a group by its name. @param string $name @param bool $executeQuery @return Group|null
[ "Returns", "a", "group", "by", "its", "name", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L305-L317
train
claroline/Distribution
plugin/scorm/Listener/ScormListener.php
ScormListener.copySco
private function copySco(Sco $sco, Scorm $resource, Sco $scoParent = null) { $scoCopy = new Sco(); $scoCopy->setScorm($resource); $scoCopy->setScoParent($scoParent); $scoCopy->setEntryUrl($sco->getEntryUrl()); $scoCopy->setIdentifier($sco->getIdentifier()); $scoCopy->setTitle($sco->getTitle()); $scoCopy->setVisible($sco->isVisible()); $scoCopy->setParameters($sco->getParameters()); $scoCopy->setLaunchData($sco->getLaunchData()); $scoCopy->setMaxTimeAllowed($sco->getMaxTimeAllowed()); $scoCopy->setTimeLimitAction($sco->getTimeLimitAction()); $scoCopy->setBlock($sco->isBlock()); $scoCopy->setScoreToPassInt($sco->getScoreToPassInt()); $scoCopy->setScoreToPassDecimal($sco->getScoreToPassDecimal()); $scoCopy->setCompletionThreshold($sco->getCompletionThreshold()); $scoCopy->setPrerequisites($sco->getPrerequisites()); $this->om->persist($scoCopy); foreach ($sco->getScoChildren() as $scoChild) { $this->copySco($scoChild, $resource, $scoCopy); } }
php
private function copySco(Sco $sco, Scorm $resource, Sco $scoParent = null) { $scoCopy = new Sco(); $scoCopy->setScorm($resource); $scoCopy->setScoParent($scoParent); $scoCopy->setEntryUrl($sco->getEntryUrl()); $scoCopy->setIdentifier($sco->getIdentifier()); $scoCopy->setTitle($sco->getTitle()); $scoCopy->setVisible($sco->isVisible()); $scoCopy->setParameters($sco->getParameters()); $scoCopy->setLaunchData($sco->getLaunchData()); $scoCopy->setMaxTimeAllowed($sco->getMaxTimeAllowed()); $scoCopy->setTimeLimitAction($sco->getTimeLimitAction()); $scoCopy->setBlock($sco->isBlock()); $scoCopy->setScoreToPassInt($sco->getScoreToPassInt()); $scoCopy->setScoreToPassDecimal($sco->getScoreToPassDecimal()); $scoCopy->setCompletionThreshold($sco->getCompletionThreshold()); $scoCopy->setPrerequisites($sco->getPrerequisites()); $this->om->persist($scoCopy); foreach ($sco->getScoChildren() as $scoChild) { $this->copySco($scoChild, $resource, $scoCopy); } }
[ "private", "function", "copySco", "(", "Sco", "$", "sco", ",", "Scorm", "$", "resource", ",", "Sco", "$", "scoParent", "=", "null", ")", "{", "$", "scoCopy", "=", "new", "Sco", "(", ")", ";", "$", "scoCopy", "->", "setScorm", "(", "$", "resource", ...
Copy given sco and its children. @param Sco $sco @param Scorm $resource @param Sco $scoParent
[ "Copy", "given", "sco", "and", "its", "children", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Listener/ScormListener.php#L308-L332
train
claroline/Distribution
main/core/Manager/WidgetManager.php
WidgetManager.getAvailable
public function getAvailable($context = null) { $enabledPlugins = $this->pluginManager->getEnabled(true); return $this->widgetRepository->findAllAvailable($enabledPlugins, $context); }
php
public function getAvailable($context = null) { $enabledPlugins = $this->pluginManager->getEnabled(true); return $this->widgetRepository->findAllAvailable($enabledPlugins, $context); }
[ "public", "function", "getAvailable", "(", "$", "context", "=", "null", ")", "{", "$", "enabledPlugins", "=", "$", "this", "->", "pluginManager", "->", "getEnabled", "(", "true", ")", ";", "return", "$", "this", "->", "widgetRepository", "->", "findAllAvaila...
Get the list of available widgets in the platform. @param string $context @return array
[ "Get", "the", "list", "of", "available", "widgets", "in", "the", "platform", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WidgetManager.php#L65-L70
train
claroline/Distribution
plugin/drop-zone/Controller/API/DropzoneController.php
DropzoneController.updateAction
public function updateAction(Dropzone $dropzone, Request $request) { $this->checkPermission('EDIT', $dropzone->getResourceNode(), [], true); try { $this->manager->update($dropzone, json_decode($request->getContent(), true)); $closedDropStates = [ Dropzone::STATE_FINISHED, Dropzone::STATE_PEER_REVIEW, Dropzone::STATE_WAITING_FOR_PEER_REVIEW, ]; if (!$dropzone->getDropClosed() && $dropzone->getManualPlanning() && in_array($dropzone->getManualState(), $closedDropStates)) { $this->manager->closeAllUnfinishedDrops($dropzone); } return new JsonResponse($this->manager->serialize($dropzone)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
php
public function updateAction(Dropzone $dropzone, Request $request) { $this->checkPermission('EDIT', $dropzone->getResourceNode(), [], true); try { $this->manager->update($dropzone, json_decode($request->getContent(), true)); $closedDropStates = [ Dropzone::STATE_FINISHED, Dropzone::STATE_PEER_REVIEW, Dropzone::STATE_WAITING_FOR_PEER_REVIEW, ]; if (!$dropzone->getDropClosed() && $dropzone->getManualPlanning() && in_array($dropzone->getManualState(), $closedDropStates)) { $this->manager->closeAllUnfinishedDrops($dropzone); } return new JsonResponse($this->manager->serialize($dropzone)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
[ "public", "function", "updateAction", "(", "Dropzone", "$", "dropzone", ",", "Request", "$", "request", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "dropzone", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")...
Updates a Dropzone resource. @EXT\Route("/{id}", name="claro_dropzone_update") @EXT\Method("PUT") @EXT\ParamConverter( "dropzone", class="ClarolineDropZoneBundle:Dropzone", options={"mapping": {"id": "uuid"}} ) @param Dropzone $dropzone @param Request $request @return JsonResponse
[ "Updates", "a", "Dropzone", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropzoneController.php#L91-L112
train
claroline/Distribution
plugin/drop-zone/Controller/API/DropzoneController.php
DropzoneController.downloadAction
public function downloadAction(Document $document) { $this->checkDocumentAccess($document); $data = $document->getData(); $response = new StreamedResponse(); $path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url']; $response->setCallBack( function () use ($path) { readfile($path); } ); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']); $response->headers->set('Content-Type', $data['mimeType']); $response->headers->set('Connection', 'close'); $this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document)); return $response->send(); }
php
public function downloadAction(Document $document) { $this->checkDocumentAccess($document); $data = $document->getData(); $response = new StreamedResponse(); $path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url']; $response->setCallBack( function () use ($path) { readfile($path); } ); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']); $response->headers->set('Content-Type', $data['mimeType']); $response->headers->set('Connection', 'close'); $this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document)); return $response->send(); }
[ "public", "function", "downloadAction", "(", "Document", "$", "document", ")", "{", "$", "this", "->", "checkDocumentAccess", "(", "$", "document", ")", ";", "$", "data", "=", "$", "document", "->", "getData", "(", ")", ";", "$", "response", "=", "new", ...
Downloads a document. @EXT\Route("/{document}/download", name="claro_dropzone_document_download") @EXT\Method("GET") @EXT\ParamConverter( "document", class="ClarolineDropZoneBundle:Document", options={"mapping": {"document": "uuid"}} ) @param Document $document @return StreamedResponse
[ "Downloads", "a", "document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropzoneController.php#L407-L428
train
claroline/Distribution
main/core/Listener/Tool/ContactsListener.php
ContactsListener.onDisplayDesktopContactTool
public function onDisplayDesktopContactTool(DisplayToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:tool:contacts.html.twig', [ 'options' => $this->contactManager->getUserOptions( $this->tokenStorage->getToken()->getUser() ), ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayDesktopContactTool(DisplayToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:tool:contacts.html.twig', [ 'options' => $this->contactManager->getUserOptions( $this->tokenStorage->getToken()->getUser() ), ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayDesktopContactTool", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:tool:contacts.html.twig'", ",", "[", "'options'", "=>", "$", "this"...
Displays contacts on Desktop. @DI\Observe("open_tool_desktop_my_contacts") @param DisplayToolEvent $event
[ "Displays", "contacts", "on", "Desktop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/ContactsListener.php#L66-L78
train
claroline/Distribution
plugin/drop-zone/Controller/API/DropController.php
DropController.createAction
public function createAction(Dropzone $dropzone, User $user, Team $team = null) { $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); if (!empty($team)) { $this->checkTeamUser($team, $user); } try { if (empty($team)) { // creates a User drop $myDrop = $this->manager->getUserDrop($dropzone, $user, true); } else { // creates a Team drop $myDrop = $this->manager->getTeamDrop($dropzone, $team, $user, true); } return new JsonResponse($this->manager->serializeDrop($myDrop)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
php
public function createAction(Dropzone $dropzone, User $user, Team $team = null) { $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); if (!empty($team)) { $this->checkTeamUser($team, $user); } try { if (empty($team)) { // creates a User drop $myDrop = $this->manager->getUserDrop($dropzone, $user, true); } else { // creates a Team drop $myDrop = $this->manager->getTeamDrop($dropzone, $team, $user, true); } return new JsonResponse($this->manager->serializeDrop($myDrop)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
[ "public", "function", "createAction", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ",", "Team", "$", "team", "=", "null", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "dropzone", "->", "getResourceNode", "(", ")...
Initializes a Drop for the current User or Team. @EXT\Route("/{id}/drops/{teamId}", name="claro_dropzone_drop_create", defaults={"teamId"=null}) @EXT\ParamConverter("dropzone", class="ClarolineDropZoneBundle:Dropzone", options={"mapping": {"id": "uuid"}}) @EXT\ParamConverter("team", class="ClarolineTeamBundle:Team", options={"mapping": {"teamId": "uuid"}}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @EXT\Method("POST") @param Dropzone $dropzone @param Team $team @param User $user @return JsonResponse
[ "Initializes", "a", "Drop", "for", "the", "current", "User", "or", "Team", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L140-L160
train
claroline/Distribution
plugin/drop-zone/Controller/API/DropController.php
DropController.submitAction
public function submitAction(Drop $drop, User $user) { $dropzone = $drop->getDropzone(); $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); $this->checkDropEdition($drop, $user); try { $this->manager->submitDrop($drop, $user); $progression = $dropzone->isPeerReview() ? 50 : 100; $this->manager->updateDropProgression($dropzone, $drop, $progression); return new JsonResponse($this->manager->serializeDrop($drop)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
php
public function submitAction(Drop $drop, User $user) { $dropzone = $drop->getDropzone(); $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); $this->checkDropEdition($drop, $user); try { $this->manager->submitDrop($drop, $user); $progression = $dropzone->isPeerReview() ? 50 : 100; $this->manager->updateDropProgression($dropzone, $drop, $progression); return new JsonResponse($this->manager->serializeDrop($drop)); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
[ "public", "function", "submitAction", "(", "Drop", "$", "drop", ",", "User", "$", "user", ")", "{", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "dropzone", "->", ...
Submits Drop. @EXT\Route("/drop/{id}/submit", name="claro_dropzone_drop_submit") @EXT\Method("PUT") @EXT\ParamConverter( "drop", class="ClarolineDropZoneBundle:Drop", options={"mapping": {"id": "uuid"}} ) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Drop $drop @param User $user @return JsonResponse
[ "Submits", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L179-L194
train
claroline/Distribution
plugin/drop-zone/Controller/API/DropController.php
DropController.addDocumentAction
public function addDocumentAction(Drop $drop, $type, User $user, Request $request) { $dropzone = $drop->getDropzone(); $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); $this->checkDropEdition($drop, $user); $documents = []; try { if (!$drop->isFinished()) { switch ($type) { case Document::DOCUMENT_TYPE_FILE: $files = $request->files->all(); $documents = $this->manager->createFilesDocuments($drop, $user, $files); break; case Document::DOCUMENT_TYPE_TEXT: case Document::DOCUMENT_TYPE_URL: case Document::DOCUMENT_TYPE_RESOURCE: $uuid = $request->request->get('dropData', false); $document = $this->manager->createDocument($drop, $user, $type, $uuid); $documents[] = $this->manager->serializeDocument($document); break; } $progression = $dropzone->isPeerReview() ? 0 : 50; $this->manager->updateDropProgression($dropzone, $drop, $progression); } return new JsonResponse($documents); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
php
public function addDocumentAction(Drop $drop, $type, User $user, Request $request) { $dropzone = $drop->getDropzone(); $this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true); $this->checkDropEdition($drop, $user); $documents = []; try { if (!$drop->isFinished()) { switch ($type) { case Document::DOCUMENT_TYPE_FILE: $files = $request->files->all(); $documents = $this->manager->createFilesDocuments($drop, $user, $files); break; case Document::DOCUMENT_TYPE_TEXT: case Document::DOCUMENT_TYPE_URL: case Document::DOCUMENT_TYPE_RESOURCE: $uuid = $request->request->get('dropData', false); $document = $this->manager->createDocument($drop, $user, $type, $uuid); $documents[] = $this->manager->serializeDocument($document); break; } $progression = $dropzone->isPeerReview() ? 0 : 50; $this->manager->updateDropProgression($dropzone, $drop, $progression); } return new JsonResponse($documents); } catch (\Exception $e) { return new JsonResponse($e->getMessage(), 422); } }
[ "public", "function", "addDocumentAction", "(", "Drop", "$", "drop", ",", "$", "type", ",", "User", "$", "user", ",", "Request", "$", "request", ")", "{", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "this", "->", "chec...
Adds a Document to a Drop. @EXT\Route("/drop/{id}/type/{type}", name="claro_dropzone_documents_add") @EXT\Method("POST") @EXT\ParamConverter( "drop", class="ClarolineDropZoneBundle:Drop", options={"mapping": {"id": "uuid"}} ) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Drop $drop @param int $type @param User $user @param Request $request @return JsonResponse
[ "Adds", "a", "Document", "to", "a", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L245-L275
train
claroline/Distribution
plugin/reservation/Manager/ReservationManager.php
ReservationManager.completeJsonEventWithReservation
public function completeJsonEventWithReservation(Reservation $reservation) { $color = $reservation->getResource()->getColor(); return array_merge( $reservation->getEvent()->jsonSerialize(), [ 'color' => !empty($color) ? $color : '#3a87ad', 'comment' => $reservation->getComment(), 'resourceTypeId' => $reservation->getResource()->getResourceType()->getId(), 'resourceTypeName' => $reservation->getResource()->getResourceType()->getName(), 'resourceId' => $reservation->getResource()->getId(), 'reservationId' => $reservation->getId(), 'editable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK), 'durationEditable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK), ] ); }
php
public function completeJsonEventWithReservation(Reservation $reservation) { $color = $reservation->getResource()->getColor(); return array_merge( $reservation->getEvent()->jsonSerialize(), [ 'color' => !empty($color) ? $color : '#3a87ad', 'comment' => $reservation->getComment(), 'resourceTypeId' => $reservation->getResource()->getResourceType()->getId(), 'resourceTypeName' => $reservation->getResource()->getResourceType()->getName(), 'resourceId' => $reservation->getResource()->getId(), 'reservationId' => $reservation->getId(), 'editable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK), 'durationEditable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK), ] ); }
[ "public", "function", "completeJsonEventWithReservation", "(", "Reservation", "$", "reservation", ")", "{", "$", "color", "=", "$", "reservation", "->", "getResource", "(", ")", "->", "getColor", "(", ")", ";", "return", "array_merge", "(", "$", "reservation", ...
Add to the jsonSerialize, some reservations fields
[ "Add", "to", "the", "jsonSerialize", "some", "reservations", "fields" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Manager/ReservationManager.php#L79-L96
train
claroline/Distribution
main/core/API/Serializer/Resource/Types/FileSerializer.php
FileSerializer.serialize
public function serialize(File $file) { $options = [ 'id' => $file->getId(), 'size' => $file->getSize(), 'autoDownload' => $file->getAutoDownload(), 'commentsActivated' => $file->getResourceNode()->isCommentsActivated(), 'hashName' => $file->getHashName(), // We generate URL here because the stream API endpoint uses ResourceNode ID, // but the new api only contains the ResourceNode UUID. // NB : This will no longer be required when the stream API will use UUIDs 'url' => $this->router->generate('claro_file_get_media', [ 'node' => $file->getResourceNode()->getId(), ]), ]; return $options; }
php
public function serialize(File $file) { $options = [ 'id' => $file->getId(), 'size' => $file->getSize(), 'autoDownload' => $file->getAutoDownload(), 'commentsActivated' => $file->getResourceNode()->isCommentsActivated(), 'hashName' => $file->getHashName(), // We generate URL here because the stream API endpoint uses ResourceNode ID, // but the new api only contains the ResourceNode UUID. // NB : This will no longer be required when the stream API will use UUIDs 'url' => $this->router->generate('claro_file_get_media', [ 'node' => $file->getResourceNode()->getId(), ]), ]; return $options; }
[ "public", "function", "serialize", "(", "File", "$", "file", ")", "{", "$", "options", "=", "[", "'id'", "=>", "$", "file", "->", "getId", "(", ")", ",", "'size'", "=>", "$", "file", "->", "getSize", "(", ")", ",", "'autoDownload'", "=>", "$", "fil...
Serializes a File resource entity for the JSON api. @param File $file - the file to serialize @return array - the serialized representation of the file
[ "Serializes", "a", "File", "resource", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/FileSerializer.php#L47-L66
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php
OrderingQuestionSerializer.serialize
public function serialize(OrderingQuestion $question, array $options = []) { $serialized = [ 'mode' => $question->getMode(), 'direction' => $question->getDirection(), 'penalty' => $question->getPenalty(), ]; // Serializes items $items = $this->serializeItems($question, $options); // shuffle items only in player if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($items); } $serialized['items'] = $items; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($question); } return $serialized; }
php
public function serialize(OrderingQuestion $question, array $options = []) { $serialized = [ 'mode' => $question->getMode(), 'direction' => $question->getDirection(), 'penalty' => $question->getPenalty(), ]; // Serializes items $items = $this->serializeItems($question, $options); // shuffle items only in player if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($items); } $serialized['items'] = $items; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($question); } return $serialized; }
[ "public", "function", "serialize", "(", "OrderingQuestion", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'mode'", "=>", "$", "question", "->", "getMode", "(", ")", ",", "'direction'", "=>", "$", ...
Converts an Ordering question into a JSON-encodable structure. @param OrderingQuestion $question @param array $options @return array
[ "Converts", "an", "Ordering", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L47-L69
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php
OrderingQuestionSerializer.serializeItems
private function serializeItems(OrderingQuestion $question, array $options = []) { return array_map(function (OrderingItem $item) use ($options) { $itemData = $this->contentSerializer->serialize($item, $options); $itemData['id'] = $item->getUuid(); return $itemData; }, $question->getItems()->toArray()); }
php
private function serializeItems(OrderingQuestion $question, array $options = []) { return array_map(function (OrderingItem $item) use ($options) { $itemData = $this->contentSerializer->serialize($item, $options); $itemData['id'] = $item->getUuid(); return $itemData; }, $question->getItems()->toArray()); }
[ "private", "function", "serializeItems", "(", "OrderingQuestion", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "OrderingItem", "$", "item", ")", "use", "(", "$", "options", ")", "{", ...
Serializes the question items. @param OrderingQuestion $question @param array $options @return array
[ "Serializes", "the", "question", "items", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L79-L87
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php
OrderingQuestionSerializer.deserialize
public function deserialize($data, OrderingQuestion $question = null, array $options = []) { if (empty($question)) { $question = new OrderingQuestion(); } if (!empty($data['penalty']) || 0 === $data['penalty']) { $question->setPenalty($data['penalty']); } $this->sipe('direction', 'setDirection', $data, $question); $this->sipe('mode', 'setMode', $data, $question); $this->deserializeItems($question, $data['items'], $data['solutions'], $options); return $question; }
php
public function deserialize($data, OrderingQuestion $question = null, array $options = []) { if (empty($question)) { $question = new OrderingQuestion(); } if (!empty($data['penalty']) || 0 === $data['penalty']) { $question->setPenalty($data['penalty']); } $this->sipe('direction', 'setDirection', $data, $question); $this->sipe('mode', 'setMode', $data, $question); $this->deserializeItems($question, $data['items'], $data['solutions'], $options); return $question; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "OrderingQuestion", "$", "question", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "question", ")", ")", "{", "$", "question", "=", "new",...
Converts raw data into an Ordering question entity. @param array $data @param OrderingQuestion $question @param array $options @return OrderingQuestion
[ "Converts", "raw", "data", "into", "an", "Ordering", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L125-L141
train
claroline/Distribution
plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php
OrderingQuestionSerializer.deserializeItems
private function deserializeItems(OrderingQuestion $question, array $items, array $solutions, array $options = []) { $itemEntities = $question->getItems()->toArray(); foreach ($items as $itemData) { $item = null; // Searches for an existing item entity. foreach ($itemEntities as $entityIndex => $entityItem) { /** @var OrderingItem $entityItem */ if ($entityItem->getUuid() === $itemData['id']) { $item = $entityItem; unset($itemEntities[$entityIndex]); break; } } $item = $item ?: new OrderingItem(); $item->setUuid($itemData['id']); // Deserialize item content $item = $this->contentSerializer->deserialize($itemData, $item, $options); // Set item score feedback and order foreach ($solutions as $solution) { if ($solution['itemId'] === $itemData['id']) { $item->setScore($solution['score']); if (isset($solution['feedback'])) { $item->setFeedback($solution['feedback']); } if (isset($solution['position'])) { $item->setPosition($solution['position']); } break; } } $question->addItem($item); } // Remaining items are no longer in the Question foreach ($itemEntities as $itemToRemove) { $question->removeItem($itemToRemove); } }
php
private function deserializeItems(OrderingQuestion $question, array $items, array $solutions, array $options = []) { $itemEntities = $question->getItems()->toArray(); foreach ($items as $itemData) { $item = null; // Searches for an existing item entity. foreach ($itemEntities as $entityIndex => $entityItem) { /** @var OrderingItem $entityItem */ if ($entityItem->getUuid() === $itemData['id']) { $item = $entityItem; unset($itemEntities[$entityIndex]); break; } } $item = $item ?: new OrderingItem(); $item->setUuid($itemData['id']); // Deserialize item content $item = $this->contentSerializer->deserialize($itemData, $item, $options); // Set item score feedback and order foreach ($solutions as $solution) { if ($solution['itemId'] === $itemData['id']) { $item->setScore($solution['score']); if (isset($solution['feedback'])) { $item->setFeedback($solution['feedback']); } if (isset($solution['position'])) { $item->setPosition($solution['position']); } break; } } $question->addItem($item); } // Remaining items are no longer in the Question foreach ($itemEntities as $itemToRemove) { $question->removeItem($itemToRemove); } }
[ "private", "function", "deserializeItems", "(", "OrderingQuestion", "$", "question", ",", "array", "$", "items", ",", "array", "$", "solutions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "itemEntities", "=", "$", "question", "->", "getIte...
Deserializes Question items. @param OrderingQuestion $question @param array $items @param array $solutions @param array $options
[ "Deserializes", "Question", "items", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L151-L197
train
claroline/Distribution
plugin/exo/Library/Item/Definition/ContentItemDefinition.php
ContentItemDefinition.deserializeQuestion
public function deserializeQuestion(array $itemData, AbstractItem $item = null, array $options = []) { return $this->getItemSerializer()->deserialize($itemData, $item, $options); }
php
public function deserializeQuestion(array $itemData, AbstractItem $item = null, array $options = []) { return $this->getItemSerializer()->deserialize($itemData, $item, $options); }
[ "public", "function", "deserializeQuestion", "(", "array", "$", "itemData", ",", "AbstractItem", "$", "item", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getItemSerializer", "(", ")", "->", "deserialize...
Deserializes content item data. @param array $itemData @param AbstractItem $item @param array $options @return AbstractItem
[ "Deserializes", "content", "item", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/ContentItemDefinition.php#L121-L124
train
claroline/Distribution
main/migration/Manager/Manager.php
Manager.generateBundleMigration
public function generateBundleMigration(Bundle $bundle, $output = null) { $platforms = $this->getAvailablePlatforms(); $version = date('YmdHis'); $this->log("Generating migrations classes for '{$bundle->getName()}'..."); if (!$output) { $output = $bundle; } foreach ($platforms as $driverName => $platform) { $queries = $this->generator->generateMigrationQueries($bundle, $platform); if (count($queries[Generator::QUERIES_UP]) > 0 || count($queries[Generator::QUERIES_DOWN]) > 0) { $this->log(" - Generating migration class for {$driverName} driver..."); $this->writer->writeMigrationClass($output, $driverName, $version, $queries); } else { $this->log('Nothing to generate: database and mapping are synced'); break; } } }
php
public function generateBundleMigration(Bundle $bundle, $output = null) { $platforms = $this->getAvailablePlatforms(); $version = date('YmdHis'); $this->log("Generating migrations classes for '{$bundle->getName()}'..."); if (!$output) { $output = $bundle; } foreach ($platforms as $driverName => $platform) { $queries = $this->generator->generateMigrationQueries($bundle, $platform); if (count($queries[Generator::QUERIES_UP]) > 0 || count($queries[Generator::QUERIES_DOWN]) > 0) { $this->log(" - Generating migration class for {$driverName} driver..."); $this->writer->writeMigrationClass($output, $driverName, $version, $queries); } else { $this->log('Nothing to generate: database and mapping are synced'); break; } } }
[ "public", "function", "generateBundleMigration", "(", "Bundle", "$", "bundle", ",", "$", "output", "=", "null", ")", "{", "$", "platforms", "=", "$", "this", "->", "getAvailablePlatforms", "(", ")", ";", "$", "version", "=", "date", "(", "'YmdHis'", ")", ...
Generates bundle migrations classes for all the available driver platforms. @param \Symfony\Component\HttpKernel\Bundle\Bundle $bundle @param \Symfony\Component\HttpKernel\Bundle\Bundle $output
[ "Generates", "bundle", "migrations", "classes", "for", "all", "the", "available", "driver", "platforms", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/migration/Manager/Manager.php#L55-L75
train
claroline/Distribution
plugin/exo/Manager/ExerciseManager.php
ExerciseManager.update
public function update(Exercise $exercise, array $data) { // Validate received data $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]); if (count($errors) > 0) { throw new InvalidDataException('Exercise is not valid', $errors); } // Start flush suite to avoid persisting and flushing tags before quiz $this->om->startFlushSuite(); // Update Exercise with new data $this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]); // Save to DB $this->om->persist($exercise); $this->om->endFlushSuite(); // Invalidate unfinished papers $this->repository->invalidatePapers($exercise); // Log exercise update $event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise)); $this->eventDispatcher->dispatch('log', $event); return $exercise; }
php
public function update(Exercise $exercise, array $data) { // Validate received data $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]); if (count($errors) > 0) { throw new InvalidDataException('Exercise is not valid', $errors); } // Start flush suite to avoid persisting and flushing tags before quiz $this->om->startFlushSuite(); // Update Exercise with new data $this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]); // Save to DB $this->om->persist($exercise); $this->om->endFlushSuite(); // Invalidate unfinished papers $this->repository->invalidatePapers($exercise); // Log exercise update $event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise)); $this->eventDispatcher->dispatch('log', $event); return $exercise; }
[ "public", "function", "update", "(", "Exercise", "$", "exercise", ",", "array", "$", "data", ")", "{", "// Validate received data", "$", "errors", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", "data", ",", "[", "Validation", "::", "REQUI...
Validates and updates an Exercise entity with raw data. @param Exercise $exercise @param array $data @return Exercise @throws InvalidDataException
[ "Validates", "and", "updates", "an", "Exercise", "entity", "with", "raw", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L132-L157
train
claroline/Distribution
plugin/exo/Manager/ExerciseManager.php
ExerciseManager.copy
public function copy(Exercise $exercise) { // Serialize quiz entities $exerciseData = $this->serializer->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS]); // Populate new entities with original data $newExercise = $this->createCopy($exerciseData, null); // Save copy to db $this->om->flush(); return $newExercise; }
php
public function copy(Exercise $exercise) { // Serialize quiz entities $exerciseData = $this->serializer->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS]); // Populate new entities with original data $newExercise = $this->createCopy($exerciseData, null); // Save copy to db $this->om->flush(); return $newExercise; }
[ "public", "function", "copy", "(", "Exercise", "$", "exercise", ")", "{", "// Serialize quiz entities", "$", "exerciseData", "=", "$", "this", "->", "serializer", "->", "serialize", "(", "$", "exercise", ",", "[", "Transfer", "::", "INCLUDE_SOLUTIONS", "]", ")...
Copies an Exercise resource. @param Exercise $exercise @return Exercise
[ "Copies", "an", "Exercise", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L179-L191
train
claroline/Distribution
plugin/exo/Manager/ExerciseManager.php
ExerciseManager.isDeletable
public function isDeletable(Exercise $exercise) { return !$exercise->getResourceNode()->isPublished() || 0 === $this->paperManager->countExercisePapers($exercise); }
php
public function isDeletable(Exercise $exercise) { return !$exercise->getResourceNode()->isPublished() || 0 === $this->paperManager->countExercisePapers($exercise); }
[ "public", "function", "isDeletable", "(", "Exercise", "$", "exercise", ")", "{", "return", "!", "$", "exercise", "->", "getResourceNode", "(", ")", "->", "isPublished", "(", ")", "||", "0", "===", "$", "this", "->", "paperManager", "->", "countExercisePapers...
Checks if an Exercise can be deleted. The exercise needs to be unpublished or have no paper to be safely removed. @param Exercise $exercise @return bool
[ "Checks", "if", "an", "Exercise", "can", "be", "deleted", ".", "The", "exercise", "needs", "to", "be", "unpublished", "or", "have", "no", "paper", "to", "be", "safely", "removed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L201-L204
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.update
public function update(Item $question, array $data) { // Validate received data $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]); if (count($errors) > 0) { throw new InvalidDataException('Question is not valid', $errors); } // Update Item with new data $this->serializer->deserialize($data, $question, [Transfer::PERSIST_TAG]); // Save to DB $this->om->persist($question); $this->om->flush(); return $question; }
php
public function update(Item $question, array $data) { // Validate received data $errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]); if (count($errors) > 0) { throw new InvalidDataException('Question is not valid', $errors); } // Update Item with new data $this->serializer->deserialize($data, $question, [Transfer::PERSIST_TAG]); // Save to DB $this->om->persist($question); $this->om->flush(); return $question; }
[ "public", "function", "update", "(", "Item", "$", "question", ",", "array", "$", "data", ")", "{", "// Validate received data", "$", "errors", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", "data", ",", "[", "Validation", "::", "REQUIRE_S...
Validates and updates a Item entity with raw data. @param Item $question @param array $data @return Item @throws InvalidDataException
[ "Validates", "and", "updates", "a", "Item", "entity", "with", "raw", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L148-L164
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.deserialize
public function deserialize(array $data, Item $item = null, array $options = []) { return $this->serializer->deserialize($data, $item, $options); }
php
public function deserialize(array $data, Item $item = null, array $options = []) { return $this->serializer->deserialize($data, $item, $options); }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Item", "$", "item", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "data", ",", "$", ...
Deserializes a question. @param array $data @param Item $item @param array $options @return Item
[ "Deserializes", "a", "question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L188-L191
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.delete
public function delete(Item $item, $user, $skipErrors = false) { if (!$this->canEdit($item, $user)) { if (!$skipErrors) { throw new \Exception('You can not delete this item.'); } else { return; } } $this->om->remove($item); $this->om->flush(); }
php
public function delete(Item $item, $user, $skipErrors = false) { if (!$this->canEdit($item, $user)) { if (!$skipErrors) { throw new \Exception('You can not delete this item.'); } else { return; } } $this->om->remove($item); $this->om->flush(); }
[ "public", "function", "delete", "(", "Item", "$", "item", ",", "$", "user", ",", "$", "skipErrors", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "canEdit", "(", "$", "item", ",", "$", "user", ")", ")", "{", "if", "(", "!", "$", ...
Deletes an Item. It's only possible if the Item is not used in an Exercise. @param Item $item @param $user @param bool $skipErrors @throws \Exception
[ "Deletes", "an", "Item", ".", "It", "s", "only", "possible", "if", "the", "Item", "is", "not", "used", "in", "an", "Exercise", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L203-L215
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.calculateScore
public function calculateScore(Item $question, Answer $answer) { // Let the question correct the answer $definition = $this->itemDefinitions->get($question->getMimeType()); /** @var AnswerableItemDefinitionInterface $definition */ $corrected = $definition->correctAnswer($question->getInteraction(), json_decode($answer->getData(), true)); if (!$corrected instanceof CorrectedAnswer) { $corrected = new CorrectedAnswer(); } // Add hints foreach ($answer->getUsedHints() as $hintId) { // Get hint definition from question data $hint = null; foreach ($question->getHints() as $questionHint) { if ($hintId === $questionHint->getUuid()) { $hint = $questionHint; break; } } if ($hint) { $corrected->addPenalty($hint); } } return $this->scoreManager->calculate(json_decode($question->getScoreRule(), true), $corrected); }
php
public function calculateScore(Item $question, Answer $answer) { // Let the question correct the answer $definition = $this->itemDefinitions->get($question->getMimeType()); /** @var AnswerableItemDefinitionInterface $definition */ $corrected = $definition->correctAnswer($question->getInteraction(), json_decode($answer->getData(), true)); if (!$corrected instanceof CorrectedAnswer) { $corrected = new CorrectedAnswer(); } // Add hints foreach ($answer->getUsedHints() as $hintId) { // Get hint definition from question data $hint = null; foreach ($question->getHints() as $questionHint) { if ($hintId === $questionHint->getUuid()) { $hint = $questionHint; break; } } if ($hint) { $corrected->addPenalty($hint); } } return $this->scoreManager->calculate(json_decode($question->getScoreRule(), true), $corrected); }
[ "public", "function", "calculateScore", "(", "Item", "$", "question", ",", "Answer", "$", "answer", ")", "{", "// Let the question correct the answer", "$", "definition", "=", "$", "this", "->", "itemDefinitions", "->", "get", "(", "$", "question", "->", "getMim...
Calculates the score of an answer to a question. @param Item $question @param Answer $answer @return float
[ "Calculates", "the", "score", "of", "an", "answer", "to", "a", "question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L243-L269
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.getItemScores
public function getItemScores(Exercise $exercise, Item $question) { $definition = $this->itemDefinitions->get($question->getMimeType()); if ($definition instanceof AnswerableItemDefinitionInterface) { return array_map(function ($answer) use ($question, $definition) { $score = $this->calculateScore($question, $answer); // get total available for the question $expected = $definition->expectAnswer($question->getInteraction()); $total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction()); // report the score on 100 $score = $total > 0 ? (100 * $score) / $total : 0; return $score; }, $this->answerRepository->findByQuestion($question, $exercise)); } return []; }
php
public function getItemScores(Exercise $exercise, Item $question) { $definition = $this->itemDefinitions->get($question->getMimeType()); if ($definition instanceof AnswerableItemDefinitionInterface) { return array_map(function ($answer) use ($question, $definition) { $score = $this->calculateScore($question, $answer); // get total available for the question $expected = $definition->expectAnswer($question->getInteraction()); $total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction()); // report the score on 100 $score = $total > 0 ? (100 * $score) / $total : 0; return $score; }, $this->answerRepository->findByQuestion($question, $exercise)); } return []; }
[ "public", "function", "getItemScores", "(", "Exercise", "$", "exercise", ",", "Item", "$", "question", ")", "{", "$", "definition", "=", "$", "this", "->", "itemDefinitions", "->", "get", "(", "$", "question", "->", "getMimeType", "(", ")", ")", ";", "if...
Get all scores for an Answerable Item. @param Exercise $exercise @param Item $question @return array
[ "Get", "all", "scores", "for", "an", "Answerable", "Item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L279-L297
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.calculateTotal
public function calculateTotal(array $questionData) { // Get entities for score calculation $question = $this->serializer->deserialize($questionData, new Item()); /** @var AnswerableItemDefinitionInterface $definition */ $definition = $this->itemDefinitions->get($question->getMimeType()); // Get the expected answer for the question $expected = $definition->expectAnswer($question->getInteraction()); return $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction()); }
php
public function calculateTotal(array $questionData) { // Get entities for score calculation $question = $this->serializer->deserialize($questionData, new Item()); /** @var AnswerableItemDefinitionInterface $definition */ $definition = $this->itemDefinitions->get($question->getMimeType()); // Get the expected answer for the question $expected = $definition->expectAnswer($question->getInteraction()); return $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction()); }
[ "public", "function", "calculateTotal", "(", "array", "$", "questionData", ")", "{", "// Get entities for score calculation", "$", "question", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "$", "questionData", ",", "new", "Item", "(", ")", ")",...
Calculates the total score of a question. @param array $questionData @return float
[ "Calculates", "the", "total", "score", "of", "a", "question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L306-L318
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.getStatistics
public function getStatistics(Item $question, Exercise $exercise = null, $finishedPapersOnly = false) { $questionStats = []; // We load all the answers for the question (we need to get the entities as the response in DB are not processable as is) $answers = $this->answerRepository->findByQuestion($question, $exercise, $finishedPapersOnly); // Number of Users that have seen the question $questionStats['seen'] = count($answers); // Grab answer data to pass it decoded to the question type // it doesn't need to know the whole Answer object $answersData = []; // get corrected answers for the Item in order to compute question success percentage $correctedAnswers = []; // Number of Users that have answered the question (no blank answer) $questionStats['answered'] = 0; if (!empty($answers)) { // Let the handler of the question type parse and compile the data $definition = $this->itemDefinitions->get($question->getMimeType()); for ($i = 0; $i < $questionStats['seen']; ++$i) { $answer = $answers[$i]; if (!empty($answer->getData())) { ++$questionStats['answered']; $answersData[] = json_decode($answer->getData(), true); } // for each answer get corresponding correction if ($definition instanceof AnswerableItemDefinitionInterface && isset($answersData[$i])) { $corrected = $definition->correctAnswer($question->getInteraction(), $answersData[$i]); $correctedAnswers[] = $corrected; } } // Let the handler of the question type parse and compile the data if ($definition instanceof AnswerableItemDefinitionInterface) { $questionStats['solutions'] = $definition->getStatistics($question->getInteraction(), $answersData, $questionStats['seen']); } } // get the number of good answers among all $nbGoodAnswers = 0; foreach ($correctedAnswers as $corrected) { if ($corrected instanceof CorrectedAnswer && 0 === count($corrected->getMissing()) && 0 === count($corrected->getUnexpected())) { ++$nbGoodAnswers; } } // compute question success percentage $questionStats['successPercent'] = $questionStats['answered'] > 0 ? (100 * $nbGoodAnswers) / $questionStats['answered'] : 0; return $questionStats; }
php
public function getStatistics(Item $question, Exercise $exercise = null, $finishedPapersOnly = false) { $questionStats = []; // We load all the answers for the question (we need to get the entities as the response in DB are not processable as is) $answers = $this->answerRepository->findByQuestion($question, $exercise, $finishedPapersOnly); // Number of Users that have seen the question $questionStats['seen'] = count($answers); // Grab answer data to pass it decoded to the question type // it doesn't need to know the whole Answer object $answersData = []; // get corrected answers for the Item in order to compute question success percentage $correctedAnswers = []; // Number of Users that have answered the question (no blank answer) $questionStats['answered'] = 0; if (!empty($answers)) { // Let the handler of the question type parse and compile the data $definition = $this->itemDefinitions->get($question->getMimeType()); for ($i = 0; $i < $questionStats['seen']; ++$i) { $answer = $answers[$i]; if (!empty($answer->getData())) { ++$questionStats['answered']; $answersData[] = json_decode($answer->getData(), true); } // for each answer get corresponding correction if ($definition instanceof AnswerableItemDefinitionInterface && isset($answersData[$i])) { $corrected = $definition->correctAnswer($question->getInteraction(), $answersData[$i]); $correctedAnswers[] = $corrected; } } // Let the handler of the question type parse and compile the data if ($definition instanceof AnswerableItemDefinitionInterface) { $questionStats['solutions'] = $definition->getStatistics($question->getInteraction(), $answersData, $questionStats['seen']); } } // get the number of good answers among all $nbGoodAnswers = 0; foreach ($correctedAnswers as $corrected) { if ($corrected instanceof CorrectedAnswer && 0 === count($corrected->getMissing()) && 0 === count($corrected->getUnexpected())) { ++$nbGoodAnswers; } } // compute question success percentage $questionStats['successPercent'] = $questionStats['answered'] > 0 ? (100 * $nbGoodAnswers) / $questionStats['answered'] : 0; return $questionStats; }
[ "public", "function", "getStatistics", "(", "Item", "$", "question", ",", "Exercise", "$", "exercise", "=", "null", ",", "$", "finishedPapersOnly", "=", "false", ")", "{", "$", "questionStats", "=", "[", "]", ";", "// We load all the answers for the question (we n...
Get question statistics inside an Exercise. @param Item $question @param Exercise $exercise @param bool $finishedPapersOnly @return array
[ "Get", "question", "statistics", "inside", "an", "Exercise", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L329-L385
train
claroline/Distribution
plugin/exo/Manager/Item/ItemManager.php
ItemManager.refreshIdentifiers
public function refreshIdentifiers(Item $item) { // refresh self id $item->refreshUuid(); // refresh objects ids foreach ($item->getObjects() as $object) { $object->refreshUuid(); } // refresh hints ids foreach ($item->getHints() as $hint) { $hint->refreshUuid(); } if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item->getMimeType())) { // it's a question $definition = $this->itemDefinitions->get($item->getMimeType()); } else { // it's a content $definition = $this->itemDefinitions->get(ItemType::CONTENT); } $definition->refreshIdentifiers($item->getInteraction()); }
php
public function refreshIdentifiers(Item $item) { // refresh self id $item->refreshUuid(); // refresh objects ids foreach ($item->getObjects() as $object) { $object->refreshUuid(); } // refresh hints ids foreach ($item->getHints() as $hint) { $hint->refreshUuid(); } if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item->getMimeType())) { // it's a question $definition = $this->itemDefinitions->get($item->getMimeType()); } else { // it's a content $definition = $this->itemDefinitions->get(ItemType::CONTENT); } $definition->refreshIdentifiers($item->getInteraction()); }
[ "public", "function", "refreshIdentifiers", "(", "Item", "$", "item", ")", "{", "// refresh self id", "$", "item", "->", "refreshUuid", "(", ")", ";", "// refresh objects ids", "foreach", "(", "$", "item", "->", "getObjects", "(", ")", "as", "$", "object", "...
Generates new UUIDs for the entities of an item. @param Item $item
[ "Generates", "new", "UUIDs", "for", "the", "entities", "of", "an", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L392-L416
train
claroline/Distribution
plugin/path/Manager/PathManager.php
PathManager.import
public function import($structure, array $data, array $resourcesCreated = []) { // Create a new Path object which will be populated with exported data $path = new Path(); $pathData = $data['data']['path']; // Populate Path properties $path->setDescription($pathData['description']); $path->setOpenSummary($pathData['summaryDisplayed']); $path->setManualProgressionAllowed($pathData['manualProgressionAllowed']); // Create steps $stepData = $data['data']['steps']; if (!empty($stepData)) { $createdSteps = []; foreach ($stepData as $step) { $createdSteps = $this->importStep($path, $step, $resourcesCreated, $createdSteps); } } // Inject empty structure into path (will be replaced by a version with updated IDs later in the import process) $path->setStructure($structure); return $path; }
php
public function import($structure, array $data, array $resourcesCreated = []) { // Create a new Path object which will be populated with exported data $path = new Path(); $pathData = $data['data']['path']; // Populate Path properties $path->setDescription($pathData['description']); $path->setOpenSummary($pathData['summaryDisplayed']); $path->setManualProgressionAllowed($pathData['manualProgressionAllowed']); // Create steps $stepData = $data['data']['steps']; if (!empty($stepData)) { $createdSteps = []; foreach ($stepData as $step) { $createdSteps = $this->importStep($path, $step, $resourcesCreated, $createdSteps); } } // Inject empty structure into path (will be replaced by a version with updated IDs later in the import process) $path->setStructure($structure); return $path; }
[ "public", "function", "import", "(", "$", "structure", ",", "array", "$", "data", ",", "array", "$", "resourcesCreated", "=", "[", "]", ")", "{", "// Create a new Path object which will be populated with exported data", "$", "path", "=", "new", "Path", "(", ")", ...
Import a Path into the Platform. @param string $structure @param array $data @param array $resourcesCreated @return Path
[ "Import", "a", "Path", "into", "the", "Platform", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L84-L109
train
claroline/Distribution
plugin/path/Manager/PathManager.php
PathManager.exportStep
public function exportStep(Step $step) { $parent = $step->getParent(); $activity = $step->getActivity(); $data = [ 'uid' => $step->getId(), 'parent' => !empty($parent) ? $parent->getId() : null, 'activityId' => !empty($activity) ? $activity->getId() : null, 'activityNodeId' => !empty($activity) ? $activity->getResourceNode()->getId() : null, 'order' => $step->getOrder(), ]; return $data; }
php
public function exportStep(Step $step) { $parent = $step->getParent(); $activity = $step->getActivity(); $data = [ 'uid' => $step->getId(), 'parent' => !empty($parent) ? $parent->getId() : null, 'activityId' => !empty($activity) ? $activity->getId() : null, 'activityNodeId' => !empty($activity) ? $activity->getResourceNode()->getId() : null, 'order' => $step->getOrder(), ]; return $data; }
[ "public", "function", "exportStep", "(", "Step", "$", "step", ")", "{", "$", "parent", "=", "$", "step", "->", "getParent", "(", ")", ";", "$", "activity", "=", "$", "step", "->", "getActivity", "(", ")", ";", "$", "data", "=", "[", "'uid'", "=>", ...
Transform Step data to export it. @param Step $step @return array
[ "Transform", "Step", "data", "to", "export", "it", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L118-L132
train
claroline/Distribution
plugin/path/Manager/PathManager.php
PathManager.importStep
public function importStep(Path $path, array $data, array $createdResources = [], array $createdSteps = []) { $step = new Step(); $step->setPath($path); if (!empty($data['parent'])) { $step->setParent($createdSteps[$data['parent']]); } $step->setOrder($data['order']); $step->setActivityHeight(0); // Link Step to its Activity if (!empty($data['activityNodeId']) && !empty($createdResources[$data['activityNodeId']])) { // Step has an Activity $step->setActivity($createdResources[$data['activityNodeId']]); } $createdSteps[$data['uid']] = $step; $this->om->persist($step); return $createdSteps; }
php
public function importStep(Path $path, array $data, array $createdResources = [], array $createdSteps = []) { $step = new Step(); $step->setPath($path); if (!empty($data['parent'])) { $step->setParent($createdSteps[$data['parent']]); } $step->setOrder($data['order']); $step->setActivityHeight(0); // Link Step to its Activity if (!empty($data['activityNodeId']) && !empty($createdResources[$data['activityNodeId']])) { // Step has an Activity $step->setActivity($createdResources[$data['activityNodeId']]); } $createdSteps[$data['uid']] = $step; $this->om->persist($step); return $createdSteps; }
[ "public", "function", "importStep", "(", "Path", "$", "path", ",", "array", "$", "data", ",", "array", "$", "createdResources", "=", "[", "]", ",", "array", "$", "createdSteps", "=", "[", "]", ")", "{", "$", "step", "=", "new", "Step", "(", ")", ";...
Import a Step. @param Path $path @param array $data @param array $createdResources @param array $createdSteps @return array
[ "Import", "a", "Step", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L144-L167
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.create
public function create(Result $result) { $this->om->persist($result); $this->om->flush(); return $result; }
php
public function create(Result $result) { $this->om->persist($result); $this->om->flush(); return $result; }
[ "public", "function", "create", "(", "Result", "$", "result", ")", "{", "$", "this", "->", "om", "->", "persist", "(", "$", "result", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "return", "$", "result", ";", "}" ]
Creates a result resource. @param Result $result @return Result
[ "Creates", "a", "result", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L78-L84
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.delete
public function delete(Result $result) { $this->om->remove($result); $this->om->flush(); }
php
public function delete(Result $result) { $this->om->remove($result); $this->om->flush(); }
[ "public", "function", "delete", "(", "Result", "$", "result", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "result", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a result resource. @param Result $result
[ "Deletes", "a", "result", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L91-L95
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.getMarks
public function getMarks(Result $result, User $user, $canEdit) { $repo = $this->om->getRepository('ClarolineResultBundle:Mark'); return $canEdit ? $repo->findByResult($result) : $repo->findByResultAndUser($result, $user); }
php
public function getMarks(Result $result, User $user, $canEdit) { $repo = $this->om->getRepository('ClarolineResultBundle:Mark'); return $canEdit ? $repo->findByResult($result) : $repo->findByResultAndUser($result, $user); }
[ "public", "function", "getMarks", "(", "Result", "$", "result", ",", "User", "$", "user", ",", "$", "canEdit", ")", "{", "$", "repo", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'ClarolineResultBundle:Mark'", ")", ";", "return", "$", "canE...
Returns an array representation of the marks associated with a result. If the user passed in has the permission to edit the result, all the marks are returned, otherwise only his mark is returned. @param Result $result @param User $user @param bool $canEdit @return array
[ "Returns", "an", "array", "representation", "of", "the", "marks", "associated", "with", "a", "result", ".", "If", "the", "user", "passed", "in", "has", "the", "permission", "to", "edit", "the", "result", "all", "the", "marks", "are", "returned", "otherwise",...
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L149-L156
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.getUsers
public function getUsers(Result $result, $canEdit) { if (!$canEdit) { return []; } $repo = $this->om->getRepository('ClarolineCoreBundle:User'); $roles = $result->getResourceNode()->getWorkspace()->getRoles()->toArray(); $users = $repo->findUsersByRolesIncludingGroups($roles); return array_map(function ($user) { return [ 'id' => $user->getId(), 'name' => "{$user->getFirstName()} {$user->getLastName()}", ]; }, $users); }
php
public function getUsers(Result $result, $canEdit) { if (!$canEdit) { return []; } $repo = $this->om->getRepository('ClarolineCoreBundle:User'); $roles = $result->getResourceNode()->getWorkspace()->getRoles()->toArray(); $users = $repo->findUsersByRolesIncludingGroups($roles); return array_map(function ($user) { return [ 'id' => $user->getId(), 'name' => "{$user->getFirstName()} {$user->getLastName()}", ]; }, $users); }
[ "public", "function", "getUsers", "(", "Result", "$", "result", ",", "$", "canEdit", ")", "{", "if", "(", "!", "$", "canEdit", ")", "{", "return", "[", "]", ";", "}", "$", "repo", "=", "$", "this", "->", "om", "->", "getRepository", "(", "'Clarolin...
Returns an array representation of the members of the workspace in which the given result lives. If the edit flag is set to false, an empty array is returned. @param Result $result @param bool $canEdit @return array
[ "Returns", "an", "array", "representation", "of", "the", "members", "of", "the", "workspace", "in", "which", "the", "given", "result", "lives", ".", "If", "the", "edit", "flag", "is", "set", "to", "false", "an", "empty", "array", "is", "returned", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L168-L184
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.isValidMark
public function isValidMark(Result $result, $mark) { // normalize french decimal marks $mark = str_replace(',', '.', $mark); return is_numeric($mark) && (float) $mark <= $result->getTotal(); }
php
public function isValidMark(Result $result, $mark) { // normalize french decimal marks $mark = str_replace(',', '.', $mark); return is_numeric($mark) && (float) $mark <= $result->getTotal(); }
[ "public", "function", "isValidMark", "(", "Result", "$", "result", ",", "$", "mark", ")", "{", "// normalize french decimal marks", "$", "mark", "=", "str_replace", "(", "','", ",", "'.'", ",", "$", "mark", ")", ";", "return", "is_numeric", "(", "$", "mark...
Returns whether a mark is valid. @param Result $result @param mixed $mark @return bool
[ "Returns", "whether", "a", "mark", "is", "valid", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L194-L200
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.createMark
public function createMark(Result $result, User $user, $mark) { $mark = new Mark($result, $user, $mark); $this->om->persist($mark); $this->om->flush(); $newMarkEvent = new LogResultsNewMarkEvent($mark); $this->dispatcher->dispatch('log', $newMarkEvent); return $mark; }
php
public function createMark(Result $result, User $user, $mark) { $mark = new Mark($result, $user, $mark); $this->om->persist($mark); $this->om->flush(); $newMarkEvent = new LogResultsNewMarkEvent($mark); $this->dispatcher->dispatch('log', $newMarkEvent); return $mark; }
[ "public", "function", "createMark", "(", "Result", "$", "result", ",", "User", "$", "user", ",", "$", "mark", ")", "{", "$", "mark", "=", "new", "Mark", "(", "$", "result", ",", "$", "user", ",", "$", "mark", ")", ";", "$", "this", "->", "om", ...
Creates a new mark. @param Result $result @param User $user @param string $mark @return mark
[ "Creates", "a", "new", "mark", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L211-L221
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.deleteMark
public function deleteMark(Mark $mark) { $this->om->remove($mark); $this->om->flush(); // First of all update older mark events so as result would be 0 $this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), 0); // Then delete mark $deleteMarkEvent = new LogResultsDeleteMarkEvent($mark); $this->dispatcher->dispatch('log', $deleteMarkEvent); }
php
public function deleteMark(Mark $mark) { $this->om->remove($mark); $this->om->flush(); // First of all update older mark events so as result would be 0 $this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), 0); // Then delete mark $deleteMarkEvent = new LogResultsDeleteMarkEvent($mark); $this->dispatcher->dispatch('log', $deleteMarkEvent); }
[ "public", "function", "deleteMark", "(", "Mark", "$", "mark", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "mark", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "// First of all update older mark events so as result would b...
Deletes a mark. @param Mark $mark
[ "Deletes", "a", "mark", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L228-L237
train
claroline/Distribution
plugin/result/Manager/ResultManager.php
ResultManager.updateMark
public function updateMark(Mark $mark, $value) { $oldMark = $mark->getValue(); $mark->setValue($value); $this->om->flush(); // First of all update older mark events so as result would be new value $this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), $value); // Then create new mark event to log update $newMarkEvent = new LogResultsNewMarkEvent($mark, $oldMark); $this->dispatcher->dispatch('log', $newMarkEvent); }
php
public function updateMark(Mark $mark, $value) { $oldMark = $mark->getValue(); $mark->setValue($value); $this->om->flush(); // First of all update older mark events so as result would be new value $this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), $value); // Then create new mark event to log update $newMarkEvent = new LogResultsNewMarkEvent($mark, $oldMark); $this->dispatcher->dispatch('log', $newMarkEvent); }
[ "public", "function", "updateMark", "(", "Mark", "$", "mark", ",", "$", "value", ")", "{", "$", "oldMark", "=", "$", "mark", "->", "getValue", "(", ")", ";", "$", "mark", "->", "setValue", "(", "$", "value", ")", ";", "$", "this", "->", "om", "->...
Updates a mark. @param Mark $mark @param string $value
[ "Updates", "a", "mark", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L245-L255
train
claroline/Distribution
main/core/Security/Voter/FacetVoter.php
FacetVoter.vote
public function vote(TokenInterface $token, $object, array $attributes) { if ($object instanceof FieldFacetCollection) { //fields right management is done at the Panel level return $this->fieldFacetVote($object, $token, strtolower($attributes[0])); } if ($object instanceof PanelFacet) { return $this->panelFacetVote($object, $token, strtolower($attributes[0])); } elseif ($object instanceof Facet) { //no implementation yet } return VoterInterface::ACCESS_ABSTAIN; }
php
public function vote(TokenInterface $token, $object, array $attributes) { if ($object instanceof FieldFacetCollection) { //fields right management is done at the Panel level return $this->fieldFacetVote($object, $token, strtolower($attributes[0])); } if ($object instanceof PanelFacet) { return $this->panelFacetVote($object, $token, strtolower($attributes[0])); } elseif ($object instanceof Facet) { //no implementation yet } return VoterInterface::ACCESS_ABSTAIN; }
[ "public", "function", "vote", "(", "TokenInterface", "$", "token", ",", "$", "object", ",", "array", "$", "attributes", ")", "{", "if", "(", "$", "object", "instanceof", "FieldFacetCollection", ")", "{", "//fields right management is done at the Panel level", "retur...
Attributes can either be "open" or "edit". @param TokenInterface $token @param $object @param array $attributes
[ "Attributes", "can", "either", "be", "open", "or", "edit", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Security/Voter/FacetVoter.php#L55-L69
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.homeAction
public function homeAction($type) { $typeEntity = $this->manager->getType($type); $homeType = $this->config->getParameter('home_redirection_type'); switch ($homeType) { case 'url': $url = $this->config->getParameter('home_redirection_url'); if ($url) { return new RedirectResponse($url); } break; case 'login': return new RedirectResponse($this->router->generate('claro_security_login')); case 'new': return new RedirectResponse($this->router->generate('apiv2_home')); } if (is_null($typeEntity)) { throw new NotFoundHttpException('Page not found'); } else { $typeTemplate = $typeEntity->getTemplate(); $template = is_null($typeTemplate) ? 'ClarolineCoreBundle:home:home.html.twig' : 'ClarolineCoreBundle:home\templates\custom:'.$typeTemplate; $response = $this->render( $template, [ 'type' => $type, 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->typeAction($type)->getContent(), ] ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; } }
php
public function homeAction($type) { $typeEntity = $this->manager->getType($type); $homeType = $this->config->getParameter('home_redirection_type'); switch ($homeType) { case 'url': $url = $this->config->getParameter('home_redirection_url'); if ($url) { return new RedirectResponse($url); } break; case 'login': return new RedirectResponse($this->router->generate('claro_security_login')); case 'new': return new RedirectResponse($this->router->generate('apiv2_home')); } if (is_null($typeEntity)) { throw new NotFoundHttpException('Page not found'); } else { $typeTemplate = $typeEntity->getTemplate(); $template = is_null($typeTemplate) ? 'ClarolineCoreBundle:home:home.html.twig' : 'ClarolineCoreBundle:home\templates\custom:'.$typeTemplate; $response = $this->render( $template, [ 'type' => $type, 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->typeAction($type)->getContent(), ] ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; } }
[ "public", "function", "homeAction", "(", "$", "type", ")", "{", "$", "typeEntity", "=", "$", "this", "->", "manager", "->", "getType", "(", "$", "type", ")", ";", "$", "homeType", "=", "$", "this", "->", "config", "->", "getParameter", "(", "'home_redi...
Render the home page of the platform. @Route("/type/{type}", name="claro_get_content_by_type", options = {"expose" = true}) @Route("/", name="claro_index", defaults={"type" = "home"}, options = {"expose" = true}) @return Response
[ "Render", "the", "home", "page", "of", "the", "platform", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L130-L173
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.typeAction
public function typeAction($type, $father = null, $region = null) { $layout = $this->manager->contentLayout($type, $father, $region, $this->canEdit()); if ($layout) { return $this->render('ClarolineCoreBundle:home:layout.html.twig', $this->renderContent($layout)); } return $this->render('ClarolineCoreBundle:home:error.html.twig', ['path' => $type]); }
php
public function typeAction($type, $father = null, $region = null) { $layout = $this->manager->contentLayout($type, $father, $region, $this->canEdit()); if ($layout) { return $this->render('ClarolineCoreBundle:home:layout.html.twig', $this->renderContent($layout)); } return $this->render('ClarolineCoreBundle:home:error.html.twig', ['path' => $type]); }
[ "public", "function", "typeAction", "(", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ")", "{", "$", "layout", "=", "$", "this", "->", "manager", "->", "contentLayout", "(", "$", "type", ",", "$", "father", ",", "$...
Render the layout of contents by type. @return Response
[ "Render", "the", "layout", "of", "contents", "by", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L180-L189
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.typesAction
public function typesAction() { $types = $this->manager->getTypes(); $response = $this->render( 'ClarolineCoreBundle:home:home.html.twig', [ 'type' => '_pages', 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->render( 'ClarolineCoreBundle:home:types.html.twig', ['types' => $types, 'hasCustomTemplates' => $this->homeService->hasCustomTemplates()] )->getContent(), ] ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; }
php
public function typesAction() { $types = $this->manager->getTypes(); $response = $this->render( 'ClarolineCoreBundle:home:home.html.twig', [ 'type' => '_pages', 'region' => $this->renderRegions($this->manager->getRegionContents()), 'content' => $this->render( 'ClarolineCoreBundle:home:types.html.twig', ['types' => $types, 'hasCustomTemplates' => $this->homeService->hasCustomTemplates()] )->getContent(), ] ); $response->headers->addCacheControlDirective('no-cache', true); $response->headers->addCacheControlDirective('max-age', 0); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('no-store', true); $response->headers->addCacheControlDirective('expires', '-1'); return $response; }
[ "public", "function", "typesAction", "(", ")", "{", "$", "types", "=", "$", "this", "->", "manager", "->", "getTypes", "(", ")", ";", "$", "response", "=", "$", "this", "->", "render", "(", "'ClarolineCoreBundle:home:home.html.twig'", ",", "[", "'type'", "...
Render the page of types administration. @Route("/types", name="claroline_types_manager") @Secure(roles="ROLE_HOME_MANAGER") @return Response
[ "Render", "the", "page", "of", "types", "administration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L199-L221
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.renameContentAction
public function renameContentAction(Type $type, $name) { try { $this->manager->renameType($type, $name); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
php
public function renameContentAction(Type $type, $name) { try { $this->manager->renameType($type, $name); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
[ "public", "function", "renameContentAction", "(", "Type", "$", "type", ",", "$", "name", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "renameType", "(", "$", "type", ",", "$", "name", ")", ";", "return", "new", "Response", "(", "'true'", ...
Rename a content form. @Route("/rename/type/{type}/{name}", name="claro_content_rename_type", options = {"expose" = true}) @Secure(roles="ROLE_HOME_MANAGER") @ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping" : {"type": "name"}}) @param Type $type @param string $name @return Response
[ "Rename", "a", "content", "form", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L266-L275
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.changeTemplateFormAction
public function changeTemplateFormAction(Type $type) { $form = $this->formFactory->create( HomeTemplateType::class, $type, ['dir' => $this->homeService->getTemplatesDirectory()] ); return ['form' => $form->createView(), 'type' => $type]; }
php
public function changeTemplateFormAction(Type $type) { $form = $this->formFactory->create( HomeTemplateType::class, $type, ['dir' => $this->homeService->getTemplatesDirectory()] ); return ['form' => $form->createView(), 'type' => $type]; }
[ "public", "function", "changeTemplateFormAction", "(", "Type", "$", "type", ")", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", "HomeTemplateType", "::", "class", ",", "$", "type", ",", "[", "'dir'", "=>", "$", "this", "->"...
Edit template form. @Route( "/type/{type}/change/template/form", name="claro_content_change_template_form", options = {"expose" = true} ) @Secure(roles="ROLE_HOME_MANAGER") @Template("ClarolineCoreBundle:home:change_template_modal_form.html.twig") @param Type $type @return array
[ "Edit", "template", "form", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L292-L301
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.changeTemplateAction
public function changeTemplateAction(Type $type, Request $request) { $form = $this->formFactory->create( HomeTemplateType::class, $type, ['dir' => $this->homeService->getTemplatesDirectory()] ); $form->handleRequest($request); if ($form->isValid()) { $this->manager->persistType($type); return new JsonResponse('success', 200); } else { return ['form' => $form->createView(), 'type' => $type]; } }
php
public function changeTemplateAction(Type $type, Request $request) { $form = $this->formFactory->create( HomeTemplateType::class, $type, ['dir' => $this->homeService->getTemplatesDirectory()] ); $form->handleRequest($request); if ($form->isValid()) { $this->manager->persistType($type); return new JsonResponse('success', 200); } else { return ['form' => $form->createView(), 'type' => $type]; } }
[ "public", "function", "changeTemplateAction", "(", "Type", "$", "type", ",", "Request", "$", "request", ")", "{", "$", "form", "=", "$", "this", "->", "formFactory", "->", "create", "(", "HomeTemplateType", "::", "class", ",", "$", "type", ",", "[", "'di...
Edit template. @Route( "/type/{type}/change/template", name="claro_content_change_template", options = {"expose" = true} ) @Secure(roles="ROLE_HOME_MANAGER") @Template("ClarolineCoreBundle:home:change_template_modal_form.html.twig") @param Type $type @param Request $request @return Response|array
[ "Edit", "template", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L319-L335
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.moveContentAction
public function moveContentAction($content, $type, $page) { try { $this->manager->moveContent($content, $type, $page); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
php
public function moveContentAction($content, $type, $page) { try { $this->manager->moveContent($content, $type, $page); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
[ "public", "function", "moveContentAction", "(", "$", "content", ",", "$", "type", ",", "$", "page", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "moveContent", "(", "$", "content", ",", "$", "type", ",", "$", "page", ")", ";", "return", ...
Render the "move a content" form. @Route("/move/content/{content}/{type}/{page}", name="claroline_move_content", options = {"expose" = true}) @Secure(roles="ROLE_HOME_MANAGER") @Template("ClarolineCoreBundle:home:move.html.twig") @ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"}) @ParamConverter("type", class = "ClarolineCoreBundle:home\Type", options = {"mapping" : {"type": "name"}}) @ParamConverter("page", class = "ClarolineCoreBundle:home\Type", options = {"mapping" : {"page": "name"}}) @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "move", "a", "content", "form", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L367-L376
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.creatorAction
public function creatorAction($type, $id = null, $content = null, $father = null) { //cant use @Secure(roles="ROLE_ADMIN") annotation beacause this method is called in anonymous mode if ($this->canEdit()) { return $this->render( 'ClarolineCoreBundle:home/types:'.$type.'.creator.twig', $this->manager->getCreator($type, $id, $content, $father), true ); } return new Response(); //return void and not an exeption }
php
public function creatorAction($type, $id = null, $content = null, $father = null) { //cant use @Secure(roles="ROLE_ADMIN") annotation beacause this method is called in anonymous mode if ($this->canEdit()) { return $this->render( 'ClarolineCoreBundle:home/types:'.$type.'.creator.twig', $this->manager->getCreator($type, $id, $content, $father), true ); } return new Response(); //return void and not an exeption }
[ "public", "function", "creatorAction", "(", "$", "type", ",", "$", "id", "=", "null", ",", "$", "content", "=", "null", ",", "$", "father", "=", "null", ")", "{", "//cant use @Secure(roles=\"ROLE_ADMIN\") annotation beacause this method is called in anonymous mode", "...
Render the page of the creator box. @Route("/content/creator/{type}/{id}/{father}", name="claroline_content_creator", defaults={"father" = null}) @param string $type The type of the content to create @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "page", "of", "the", "creator", "box", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L387-L399
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.menuAction
public function menuAction($id, $size, $type, $father = null, $region = null, $collapse = null) { return $this->manager->getMenu($id, $size, $type, $father, $region, $collapse); }
php
public function menuAction($id, $size, $type, $father = null, $region = null, $collapse = null) { return $this->manager->getMenu($id, $size, $type, $father, $region, $collapse); }
[ "public", "function", "menuAction", "(", "$", "id", ",", "$", "size", ",", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ",", "$", "collapse", "=", "null", ")", "{", "return", "$", "this", "->", "manager", "->", "...
Render the page of the menu. @param string $id The id of the content @param string $size The size (content-12) of the content @param string $type The type of the content @Template("ClarolineCoreBundle:home:menu.html.twig") @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "page", "of", "the", "menu", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L412-L415
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.graphAction
public function graphAction(Request $request) { $graph = $this->manager->getGraph($request->get('generated_content_url')); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig', ['content' => $graph], true ); } return new Response('false'); }
php
public function graphAction(Request $request) { $graph = $this->manager->getGraph($request->get('generated_content_url')); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig', ['content' => $graph], true ); } return new Response('false'); }
[ "public", "function", "graphAction", "(", "Request", "$", "request", ")", "{", "$", "graph", "=", "$", "this", "->", "manager", "->", "getGraph", "(", "$", "request", "->", "get", "(", "'generated_content_url'", ")", ")", ";", "if", "(", "isset", "(", ...
Render the HTML of a content generated by an external url with Open Grap meta tags. @Route("/content/graph", name="claroline_content_graph") @return \Symfony\Component\HttpFoundation\Response
[ "Render", "the", "HTML", "of", "a", "content", "generated", "by", "an", "external", "url", "with", "Open", "Grap", "meta", "tags", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L442-L455
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.createAction
public function createAction($type = null, $father = null, Request $request) { if ($id = $this->manager->createContent($request->get('home_content'), $type, $father)) { return new Response($id); } return new Response('false'); //useful in ajax }
php
public function createAction($type = null, $father = null, Request $request) { if ($id = $this->manager->createContent($request->get('home_content'), $type, $father)) { return new Response($id); } return new Response('false'); //useful in ajax }
[ "public", "function", "createAction", "(", "$", "type", "=", "null", ",", "$", "father", "=", "null", ",", "Request", "$", "request", ")", "{", "if", "(", "$", "id", "=", "$", "this", "->", "manager", "->", "createContent", "(", "$", "request", "->",...
Create new content by POST method. This is used by ajax. The response is the id of the new content in success, otherwise the response is the false word in a string. @Route( "/content/create/{type}/{father}", name="claroline_content_create", defaults={"type" = "home", "father" = null} ) @Secure(roles="ROLE_HOME_MANAGER") @return \Symfony\Component\HttpFoundation\Response
[ "Create", "new", "content", "by", "POST", "method", ".", "This", "is", "used", "by", "ajax", ".", "The", "response", "is", "the", "id", "of", "the", "new", "content", "in", "success", "otherwise", "the", "response", "is", "the", "false", "word", "in", ...
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L489-L496
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.reorderAction
public function reorderAction($type, $a, Content $b = null, Content $father = null) { try { $this->manager->reorderContent($type, $a, $b, $father); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
php
public function reorderAction($type, $a, Content $b = null, Content $father = null) { try { $this->manager->reorderContent($type, $a, $b, $father); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
[ "public", "function", "reorderAction", "(", "$", "type", ",", "$", "a", ",", "Content", "$", "b", "=", "null", ",", "Content", "$", "father", "=", "null", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "reorderContent", "(", "$", "type", ...
Reorder contents in types. This method is used by ajax. The response is the word true in a string in success, otherwise false. @param string $type The type of the content @param string $a The id of the content 1 @param string $b The id of the content 2 @param string $father The father content @Route("/content/reorder/{type}/{a}/{b}/{father}", requirements={"a" = "\d+"}, name="claroline_content_reorder") @Secure(roles="ROLE_HOME_MANAGER") @ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping": {"type": "name"}}) @ParamConverter("a", class = "ClarolineCoreBundle:Content", options = {"id" = "a"}) @ParamConverter("b", class = "ClarolineCoreBundle:Content", options = {"id" = "b"}) @ParamConverter("father", class = "ClarolineCoreBundle:Content", options = {"id" = "father"}) @return \Symfony\Component\HttpFoundation\Response
[ "Reorder", "contents", "in", "types", ".", "This", "method", "is", "used", "by", "ajax", ".", "The", "response", "is", "the", "word", "true", "in", "a", "string", "in", "success", "otherwise", "false", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L545-L554
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.contentToRegionAction
public function contentToRegionAction($region, $content) { try { $this->manager->contentToRegion($region, $content); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
php
public function contentToRegionAction($region, $content) { try { $this->manager->contentToRegion($region, $content); return new Response('true'); } catch (\Exception $e) { return new Response('false'); //useful in ajax } }
[ "public", "function", "contentToRegionAction", "(", "$", "region", ",", "$", "content", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "contentToRegion", "(", "$", "region", ",", "$", "content", ")", ";", "return", "new", "Response", "(", "'tr...
Put a content into a region in front page as left, right, footer. This is useful for menus. @Route("/region/{region}/{content}", requirements={"content" = "\d+"}, name="claroline_content_to_region") @ParamConverter("region", class = "ClarolineCoreBundle:Home\Region", options = {"mapping": {"region": "name"}}) @ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"}) @Secure(roles="ROLE_HOME_MANAGER") @return \Symfony\Component\HttpFoundation\Response
[ "Put", "a", "content", "into", "a", "region", "in", "front", "page", "as", "left", "right", "footer", ".", "This", "is", "useful", "for", "menus", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L648-L657
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.canGenerateContentAction
public function canGenerateContentAction(Request $request) { $content = $this->decodeRequest($request); if ($content && $content['url'] && $this->manager->isValidUrl($content['url'])) { $graph = $this->manager->getGraph($content['url']); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig', ['content' => $graph], true ); } } return new Response('false'); //in case is not valid URL }
php
public function canGenerateContentAction(Request $request) { $content = $this->decodeRequest($request); if ($content && $content['url'] && $this->manager->isValidUrl($content['url'])) { $graph = $this->manager->getGraph($content['url']); if (isset($graph['type'])) { return $this->render( 'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig', ['content' => $graph], true ); } } return new Response('false'); //in case is not valid URL }
[ "public", "function", "canGenerateContentAction", "(", "Request", "$", "request", ")", "{", "$", "content", "=", "$", "this", "->", "decodeRequest", "(", "$", "request", ")", ";", "if", "(", "$", "content", "&&", "$", "content", "[", "'url'", "]", "&&", ...
Check if a string is a valid URL. @Route("/cangeneratecontent", name="claroline_can_generate_content", options={"expose" = true}) @Method("POST") @param Request $request @return Response
[ "Check", "if", "a", "string", "is", "a", "valid", "URL", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L696-L712
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.saveMenuSettingsAction
public function saveMenuSettingsAction($menu, $login, $workspaces, $locale) { try { $this->manager->saveHomeParameters($menu, $login, $workspaces, $locale); return new Response('true'); } catch (\Exception $e) { return new Response('false'); } }
php
public function saveMenuSettingsAction($menu, $login, $workspaces, $locale) { try { $this->manager->saveHomeParameters($menu, $login, $workspaces, $locale); return new Response('true'); } catch (\Exception $e) { return new Response('false'); } }
[ "public", "function", "saveMenuSettingsAction", "(", "$", "menu", ",", "$", "login", ",", "$", "workspaces", ",", "$", "locale", ")", "{", "try", "{", "$", "this", "->", "manager", "->", "saveHomeParameters", "(", "$", "menu", ",", "$", "login", ",", "...
Save the menu settings. @Route( "/content/menu/save/settings/{menu}/{login}/{workspaces}/{locale}", name="claroline_content_menu_save_settings", options = {"expose" = true} ) @param int $menu The id of the menu @param bool $login A Boolean that determine if there is the login button in the footer @param bool $workspaces A Boolean that determine if there is the workspace button in the footer @param bool $locale A boolean that determine if there is a locale button in the header @Secure(roles="ROLE_HOME_MANAGER") @return Response
[ "Save", "the", "menu", "settings", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L751-L760
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.renderContent
public function renderContent($layout) { $tmp = ' '; // void in case of not yet content if (isset($layout['content']) && isset($layout['type']) && is_array($layout['content'])) { foreach ($layout['content'] as $content) { $tmp .= $this->render( 'ClarolineCoreBundle:home/types:'.$content['type'].'.html.twig', $content, true )->getContent(); } } $layout['content'] = $tmp; return $layout; }
php
public function renderContent($layout) { $tmp = ' '; // void in case of not yet content if (isset($layout['content']) && isset($layout['type']) && is_array($layout['content'])) { foreach ($layout['content'] as $content) { $tmp .= $this->render( 'ClarolineCoreBundle:home/types:'.$content['type'].'.html.twig', $content, true )->getContent(); } } $layout['content'] = $tmp; return $layout; }
[ "public", "function", "renderContent", "(", "$", "layout", ")", "{", "$", "tmp", "=", "' '", ";", "// void in case of not yet content", "if", "(", "isset", "(", "$", "layout", "[", "'content'", "]", ")", "&&", "isset", "(", "$", "layout", "[", "'type'", ...
Render the HTML of the content. @param string $layout @return array
[ "Render", "the", "HTML", "of", "the", "content", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L769-L784
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.renderRegions
public function renderRegions($regions) { $tmp = []; foreach ($regions as $name => $region) { $tmp[$name] = ''; foreach ($region as $variables) { $tmp[$name] .= $this->render( 'ClarolineCoreBundle:home/types:'.$variables['type'].'.html.twig', $variables, true )->getContent(); } } return $tmp; }
php
public function renderRegions($regions) { $tmp = []; foreach ($regions as $name => $region) { $tmp[$name] = ''; foreach ($region as $variables) { $tmp[$name] .= $this->render( 'ClarolineCoreBundle:home/types:'.$variables['type'].'.html.twig', $variables, true )->getContent(); } } return $tmp; }
[ "public", "function", "renderRegions", "(", "$", "regions", ")", "{", "$", "tmp", "=", "[", "]", ";", "foreach", "(", "$", "regions", "as", "$", "name", "=>", "$", "region", ")", "{", "$", "tmp", "[", "$", "name", "]", "=", "''", ";", "foreach", ...
Render the HTML of the regions. @param array $regions @return string
[ "Render", "the", "HTML", "of", "the", "regions", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L793-L808
train
claroline/Distribution
main/core/Controller/HomeController.php
HomeController.render
public function render($template, $variables, $default = false) { if ($default) { $template = $this->homeService->defaultTemplate($template); } return new Response($this->templating->render($template, $variables)); }
php
public function render($template, $variables, $default = false) { if ($default) { $template = $this->homeService->defaultTemplate($template); } return new Response($this->templating->render($template, $variables)); }
[ "public", "function", "render", "(", "$", "template", ",", "$", "variables", ",", "$", "default", "=", "false", ")", "{", "if", "(", "$", "default", ")", "{", "$", "template", "=", "$", "this", "->", "homeService", "->", "defaultTemplate", "(", "$", ...
Extends templating render. @param string $template @param array $variables @param bool $default @return Response
[ "Extends", "templating", "render", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L819-L826
train
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.serialize
public function serialize(Paper $paper, array $options = []) { $serialized = [ 'id' => $paper->getUuid(), 'number' => $paper->getNumber(), 'finished' => !$paper->isInterrupted(), 'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null, 'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null, 'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null, 'structure' => json_decode($paper->getStructure(), true), ]; // Adds detail information if (!in_array(Transfer::MINIMAL, $options)) { $serialized['answers'] = $this->serializeAnswers($paper, $options); } // Adds user score if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) { $serialized['score'] = $paper->getScore(); } return $serialized; }
php
public function serialize(Paper $paper, array $options = []) { $serialized = [ 'id' => $paper->getUuid(), 'number' => $paper->getNumber(), 'finished' => !$paper->isInterrupted(), 'user' => $paper->getUser() && !$paper->isAnonymized() ? $this->userSerializer->serialize($paper->getUser(), $options) : null, 'startDate' => $paper->getStart() ? DateNormalizer::normalize($paper->getStart()) : null, 'endDate' => $paper->getEnd() ? DateNormalizer::normalize($paper->getEnd()) : null, 'structure' => json_decode($paper->getStructure(), true), ]; // Adds detail information if (!in_array(Transfer::MINIMAL, $options)) { $serialized['answers'] = $this->serializeAnswers($paper, $options); } // Adds user score if (!in_array(Transfer::INCLUDE_USER_SCORE, $options)) { $serialized['score'] = $paper->getScore(); } return $serialized; }
[ "public", "function", "serialize", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "paper", "->", "getUuid", "(", ")", ",", "'number'", "=>", "$", "paper", "->", "ge...
Converts a Paper into a JSON-encodable structure. @param Paper $paper @param array $options @return array
[ "Converts", "a", "Paper", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L58-L81
train
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.deserialize
public function deserialize($data, Paper $paper = null, array $options = []) { $paper = $paper ?: new Paper(); $this->sipe('id', 'setUuid', $data, $paper); $this->sipe('number', 'setNumber', $data, $paper); $this->sipe('score', 'setScore', $data, $paper); if (isset($data['startDate'])) { $startDate = DateNormalizer::denormalize($data['startDate']); $paper->setStart($startDate); } if (isset($data['endDate'])) { $endDate = DateNormalizer::denormalize($data['endDate']); $paper->setEnd($endDate); } if (isset($data['structure'])) { $paper->setStructure(json_encode($data['structure'])); } if (isset($data['finished'])) { $paper->setInterrupted(!$data['finished']); } if (isset($data['answers'])) { $this->deserializeAnswers($paper, $data['answers'], $options); } return $paper; }
php
public function deserialize($data, Paper $paper = null, array $options = []) { $paper = $paper ?: new Paper(); $this->sipe('id', 'setUuid', $data, $paper); $this->sipe('number', 'setNumber', $data, $paper); $this->sipe('score', 'setScore', $data, $paper); if (isset($data['startDate'])) { $startDate = DateNormalizer::denormalize($data['startDate']); $paper->setStart($startDate); } if (isset($data['endDate'])) { $endDate = DateNormalizer::denormalize($data['endDate']); $paper->setEnd($endDate); } if (isset($data['structure'])) { $paper->setStructure(json_encode($data['structure'])); } if (isset($data['finished'])) { $paper->setInterrupted(!$data['finished']); } if (isset($data['answers'])) { $this->deserializeAnswers($paper, $data['answers'], $options); } return $paper; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Paper", "$", "paper", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "paper", "=", "$", "paper", "?", ":", "new", "Paper", "(", ")", ";", "$", "this", "->", ...
Converts raw data into a Paper entity. @param array $data @param Paper $paper @param array $options @return Paper
[ "Converts", "raw", "data", "into", "a", "Paper", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L92-L119
train
claroline/Distribution
plugin/exo/Serializer/Attempt/PaperSerializer.php
PaperSerializer.serializeAnswers
private function serializeAnswers(Paper $paper, array $options = []) { // We need to inject the hints available in the structure $options['hints'] = []; $decoded = json_decode($paper->getStructure(), true); foreach ($decoded['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { foreach ($item['hints'] as $hint) { $options['hints'][$hint['id']] = $hint; } } } } return array_map(function (Answer $answer) use ($options) { return $this->answerSerializer->serialize($answer, $options); }, $paper->getAnswers()->toArray()); }
php
private function serializeAnswers(Paper $paper, array $options = []) { // We need to inject the hints available in the structure $options['hints'] = []; $decoded = json_decode($paper->getStructure(), true); foreach ($decoded['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { foreach ($item['hints'] as $hint) { $options['hints'][$hint['id']] = $hint; } } } } return array_map(function (Answer $answer) use ($options) { return $this->answerSerializer->serialize($answer, $options); }, $paper->getAnswers()->toArray()); }
[ "private", "function", "serializeAnswers", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// We need to inject the hints available in the structure", "$", "options", "[", "'hints'", "]", "=", "[", "]", ";", "$", "decoded", ...
Serializes paper answers. @param Paper $paper @param array $options @return array
[ "Serializes", "paper", "answers", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Attempt/PaperSerializer.php#L129-L148
train
claroline/Distribution
main/core/Entity/Content.php
Content.setModified
public function setModified($modified = null) { if ($modified) { $this->modified = $modified; } else { $this->modified = new \Datetime(); } return $this; }
php
public function setModified($modified = null) { if ($modified) { $this->modified = $modified; } else { $this->modified = new \Datetime(); } return $this; }
[ "public", "function", "setModified", "(", "$", "modified", "=", "null", ")", "{", "if", "(", "$", "modified", ")", "{", "$", "this", "->", "modified", "=", "$", "modified", ";", "}", "else", "{", "$", "this", "->", "modified", "=", "new", "\\", "Da...
Set modified. @param \DateTime $modified @return Content
[ "Set", "modified", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Content.php#L209-L218
train
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.getDesktopToolsConfigurationArray
public function getDesktopToolsConfigurationArray(User $user, $type = 0) { $orderedToolList = []; $desktopTools = $this->orderedToolRepo->findDisplayableDesktopOrderedToolsByUser( $user, $type ); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByUser($user, $type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopTools( $user, $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
php
public function getDesktopToolsConfigurationArray(User $user, $type = 0) { $orderedToolList = []; $desktopTools = $this->orderedToolRepo->findDisplayableDesktopOrderedToolsByUser( $user, $type ); foreach ($desktopTools as $desktopTool) { //this field isn't mapped $desktopTool->getTool()->setVisible($desktopTool->isVisibleInDesktop()); $orderedToolList[$desktopTool->getOrder()] = $desktopTool->getTool(); } $undisplayedTools = $this->toolRepo->findDesktopUndisplayedToolsByUser($user, $type); foreach ($undisplayedTools as $tool) { //this field isn't mapped $tool->setVisible(false); } $this->addMissingDesktopTools( $user, $undisplayedTools, count($desktopTools) + 1, $type ); return $this->utilities->arrayFill($orderedToolList, $undisplayedTools); }
[ "public", "function", "getDesktopToolsConfigurationArray", "(", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "orderedToolList", "=", "[", "]", ";", "$", "desktopTools", "=", "$", "this", "->", "orderedToolRepo", "->", "findDisplayableDesktop...
Returns the sorted list of OrderedTools for a user. @param \Claroline\CoreBundle\Entity\User $user @return \Claroline\CoreBundle\Entity\Tool\OrderedTool
[ "Returns", "the", "sorted", "list", "of", "OrderedTools", "for", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L235-L264
train
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.setToolPosition
public function setToolPosition( Tool $tool, $position, User $user = null, Workspace $workspace = null, $type = 0 ) { $movingTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'workspace' => $workspace, 'type' => $type] ); $movingTool->setOrder($position); $this->om->persist($movingTool); $this->om->flush(); }
php
public function setToolPosition( Tool $tool, $position, User $user = null, Workspace $workspace = null, $type = 0 ) { $movingTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'workspace' => $workspace, 'type' => $type] ); $movingTool->setOrder($position); $this->om->persist($movingTool); $this->om->flush(); }
[ "public", "function", "setToolPosition", "(", "Tool", "$", "tool", ",", "$", "position", ",", "User", "$", "user", "=", "null", ",", "Workspace", "$", "workspace", "=", "null", ",", "$", "type", "=", "0", ")", "{", "$", "movingTool", "=", "$", "this"...
Sets a tool position. @param Tool $tool @param $position @param User $user @param Workspace $workspace
[ "Sets", "a", "tool", "position", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L550-L563
train
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.resetToolsVisiblity
public function resetToolsVisiblity( User $user = null, Workspace $workspace = null, $type = 0 ) { $orderedTools = $this->orderedToolRepo->findBy( ['user' => $user, 'workspace' => $workspace, 'type' => $type] ); foreach ($orderedTools as $orderedTool) { if ($user) { $orderedTool->setVisibleInDesktop(false); } $this->om->persist($orderedTool); } $this->om->flush(); }
php
public function resetToolsVisiblity( User $user = null, Workspace $workspace = null, $type = 0 ) { $orderedTools = $this->orderedToolRepo->findBy( ['user' => $user, 'workspace' => $workspace, 'type' => $type] ); foreach ($orderedTools as $orderedTool) { if ($user) { $orderedTool->setVisibleInDesktop(false); } $this->om->persist($orderedTool); } $this->om->flush(); }
[ "public", "function", "resetToolsVisiblity", "(", "User", "$", "user", "=", "null", ",", "Workspace", "$", "workspace", "=", "null", ",", "$", "type", "=", "0", ")", "{", "$", "orderedTools", "=", "$", "this", "->", "orderedToolRepo", "->", "findBy", "("...
Resets the tool visibility. @param User $user @param Workspace $workspace
[ "Resets", "the", "tool", "visibility", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L571-L589
train
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.setDesktopToolVisible
public function setDesktopToolVisible(Tool $tool, User $user, $type = 0) { $orderedTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'type' => $type] ); $orderedTool->setVisibleInDesktop(true); $this->om->persist($orderedTool); $this->om->flush(); }
php
public function setDesktopToolVisible(Tool $tool, User $user, $type = 0) { $orderedTool = $this->orderedToolRepo->findOneBy( ['user' => $user, 'tool' => $tool, 'type' => $type] ); $orderedTool->setVisibleInDesktop(true); $this->om->persist($orderedTool); $this->om->flush(); }
[ "public", "function", "setDesktopToolVisible", "(", "Tool", "$", "tool", ",", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "orderedTool", "=", "$", "this", "->", "orderedToolRepo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "u...
Sets a tool visible for a user in the desktop. @param Tool $tool @param User $user
[ "Sets", "a", "tool", "visible", "for", "a", "user", "in", "the", "desktop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L636-L644
train
claroline/Distribution
main/core/Manager/ToolManager.php
ToolManager.addRequiredToolsToUser
public function addRequiredToolsToUser(User $user, $type = 0) { $requiredTools = []; $adminOrderedTools = $this->getConfigurableDesktopOrderedToolsByTypeForAdmin($type); foreach ($adminOrderedTools as $orderedTool) { if ($orderedTool->isVisibleInDesktop()) { $requiredTools[] = $orderedTool->getTool(); } } $position = 1; $this->om->startFlushSuite(); foreach ($requiredTools as $requiredTool) { $this->addDesktopTool( $requiredTool, $user, $position, $requiredTool->getName(), $type ); ++$position; } $this->om->persist($user); $this->om->endFlushSuite($user); }
php
public function addRequiredToolsToUser(User $user, $type = 0) { $requiredTools = []; $adminOrderedTools = $this->getConfigurableDesktopOrderedToolsByTypeForAdmin($type); foreach ($adminOrderedTools as $orderedTool) { if ($orderedTool->isVisibleInDesktop()) { $requiredTools[] = $orderedTool->getTool(); } } $position = 1; $this->om->startFlushSuite(); foreach ($requiredTools as $requiredTool) { $this->addDesktopTool( $requiredTool, $user, $position, $requiredTool->getName(), $type ); ++$position; } $this->om->persist($user); $this->om->endFlushSuite($user); }
[ "public", "function", "addRequiredToolsToUser", "(", "User", "$", "user", ",", "$", "type", "=", "0", ")", "{", "$", "requiredTools", "=", "[", "]", ";", "$", "adminOrderedTools", "=", "$", "this", "->", "getConfigurableDesktopOrderedToolsByTypeForAdmin", "(", ...
Adds the mandatory tools at the user creation. @param \Claroline\CoreBundle\Entity\User $user
[ "Adds", "the", "mandatory", "tools", "at", "the", "user", "creation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ToolManager.php#L651-L678
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.contentLayout
public function contentLayout($type, $father = null, $region = null, $admin = null) { $type = $this->getType($type); $content = $this->getContentByType($type->getName(), $father, $region); $array = null; if ($content && ($type->isPublish() || $admin)) { $array = []; $array['content'] = $content; $array['type'] = $type->getName(); $array['publish'] = $type->isPublish(); $array = $this->homeService->isDefinedPush($array, 'father', $father); $array = $this->homeService->isDefinedPush($array, 'region', $region); } return $array; }
php
public function contentLayout($type, $father = null, $region = null, $admin = null) { $type = $this->getType($type); $content = $this->getContentByType($type->getName(), $father, $region); $array = null; if ($content && ($type->isPublish() || $admin)) { $array = []; $array['content'] = $content; $array['type'] = $type->getName(); $array['publish'] = $type->isPublish(); $array = $this->homeService->isDefinedPush($array, 'father', $father); $array = $this->homeService->isDefinedPush($array, 'region', $region); } return $array; }
[ "public", "function", "contentLayout", "(", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ",", "$", "admin", "=", "null", ")", "{", "$", "type", "=", "$", "this", "->", "getType", "(", "$", "type", ")", ";", "$", ...
Return the layout of contents by his type. @return array
[ "Return", "the", "layout", "of", "contents", "by", "his", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L104-L120
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getContentByType
public function getContentByType($type, $father = null, $region = null) { $array = []; $type = $this->type->findOneBy(['name' => $type]); if ($type) { if ($father) { $father = $this->content->find($father); $first = $this->subContent->findOneBy( ['back' => null, 'father' => $father] ); } else { $first = $this->contentType->findOneBy( ['back' => null, 'type' => $type] ); } if ($first) { for ($i = 0; $i < $type->getMaxContentPage() && null !== $first; ++$i) { $variables = []; $variables['content'] = $first->getContent(); $variables['size'] = $first->getSize(); $variables['type'] = $type->getName(); if (!$father) { $variables['collapse'] = $first->isCollapse(); } $variables = $this->homeService->isDefinedPush($variables, 'father', $father, 'getId'); $variables = $this->homeService->isDefinedPush($variables, 'region', $region); $array[] = $variables; $first = $first->getNext(); } } else { $array[] = ['content' => '', 'type' => $type->getName()]; // in case of not yet content } } return $array; }
php
public function getContentByType($type, $father = null, $region = null) { $array = []; $type = $this->type->findOneBy(['name' => $type]); if ($type) { if ($father) { $father = $this->content->find($father); $first = $this->subContent->findOneBy( ['back' => null, 'father' => $father] ); } else { $first = $this->contentType->findOneBy( ['back' => null, 'type' => $type] ); } if ($first) { for ($i = 0; $i < $type->getMaxContentPage() && null !== $first; ++$i) { $variables = []; $variables['content'] = $first->getContent(); $variables['size'] = $first->getSize(); $variables['type'] = $type->getName(); if (!$father) { $variables['collapse'] = $first->isCollapse(); } $variables = $this->homeService->isDefinedPush($variables, 'father', $father, 'getId'); $variables = $this->homeService->isDefinedPush($variables, 'region', $region); $array[] = $variables; $first = $first->getNext(); } } else { $array[] = ['content' => '', 'type' => $type->getName()]; // in case of not yet content } } return $array; }
[ "public", "function", "getContentByType", "(", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ")", "{", "$", "array", "=", "[", "]", ";", "$", "type", "=", "$", "this", "->", "type", "->", "findOneBy", "(", "[", "'...
Get Content by type. This method return a string with the content on success or null if the type does not exist. @return array
[ "Get", "Content", "by", "type", ".", "This", "method", "return", "a", "string", "with", "the", "content", "on", "success", "or", "null", "if", "the", "type", "does", "not", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L138-L175
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.reorderContent
public function reorderContent($type, $a, $b = null, $father = null) { $a = $this->getNode($type, $a, $father); $a->detach(); if ($b) { $b = $this->getNode($type, $b, $father); $a->setBack($b->getBack()); $a->setNext($b); if ($b->getBack()) { $b->getBack()->setNext($a); } $b->setBack($a); } else { $b = $this->getnode($type, null, $father); $a->setNext($b->getNext()); $a->setBack($b); $b->setNext($a); } $this->manager->persist($a); $this->manager->persist($b); $this->manager->flush(); }
php
public function reorderContent($type, $a, $b = null, $father = null) { $a = $this->getNode($type, $a, $father); $a->detach(); if ($b) { $b = $this->getNode($type, $b, $father); $a->setBack($b->getBack()); $a->setNext($b); if ($b->getBack()) { $b->getBack()->setNext($a); } $b->setBack($a); } else { $b = $this->getnode($type, null, $father); $a->setNext($b->getNext()); $a->setBack($b); $b->setNext($a); } $this->manager->persist($a); $this->manager->persist($b); $this->manager->flush(); }
[ "public", "function", "reorderContent", "(", "$", "type", ",", "$", "a", ",", "$", "b", "=", "null", ",", "$", "father", "=", "null", ")", "{", "$", "a", "=", "$", "this", "->", "getNode", "(", "$", "type", ",", "$", "a", ",", "$", "father", ...
Reorder Contents.
[ "Reorder", "Contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L306-L331
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.createType
public function createType($name) { $type = new Type($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
php
public function createType($name) { $type = new Type($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
[ "public", "function", "createType", "(", "$", "name", ")", "{", "$", "type", "=", "new", "Type", "(", "$", "name", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "->", "flush", "...
Create a type. @param string $name @return Type
[ "Create", "a", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L399-L406
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.renameType
public function renameType($type, $name) { $type->setName($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
php
public function renameType($type, $name) { $type->setName($name); $this->manager->persist($type); $this->manager->flush(); return $type; }
[ "public", "function", "renameType", "(", "$", "type", ",", "$", "name", ")", "{", "$", "type", "->", "setName", "(", "$", "name", ")", ";", "$", "this", "->", "manager", "->", "persist", "(", "$", "type", ")", ";", "$", "this", "->", "manager", "...
Rename a type. @param Type $type @param string $name @return Type
[ "Rename", "a", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L416-L423
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.typeExist
public function typeExist($name) { $type = $this->type->findOneBy(['name' => $name]); if (is_object($type)) { return true; } return false; }
php
public function typeExist($name) { $type = $this->type->findOneBy(['name' => $name]); if (is_object($type)) { return true; } return false; }
[ "public", "function", "typeExist", "(", "$", "name", ")", "{", "$", "type", "=", "$", "this", "->", "type", "->", "findOneBy", "(", "[", "'name'", "=>", "$", "name", "]", ")", ";", "if", "(", "is_object", "(", "$", "type", ")", ")", "{", "return"...
Verify if a type exist. @param string $name @return bool
[ "Verify", "if", "a", "type", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L441-L450
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.deleNodeEntity
public function deleNodeEntity($entity, $search, $function = null) { $entities = $entity->findBy($search); foreach ($entities as $entity) { $entity->detach(); if ($function) { $function($entity); } $this->manager->remove($entity); $this->manager->flush(); } }
php
public function deleNodeEntity($entity, $search, $function = null) { $entities = $entity->findBy($search); foreach ($entities as $entity) { $entity->detach(); if ($function) { $function($entity); } $this->manager->remove($entity); $this->manager->flush(); } }
[ "public", "function", "deleNodeEntity", "(", "$", "entity", ",", "$", "search", ",", "$", "function", "=", "null", ")", "{", "$", "entities", "=", "$", "entity", "->", "findBy", "(", "$", "search", ")", ";", "foreach", "(", "$", "entities", "as", "$"...
Delete a node entity and link together the next and back entities. @return string The word "true" useful in ajax
[ "Delete", "a", "node", "entity", "and", "link", "together", "the", "next", "and", "back", "entities", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L498-L512
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.deleteRegions
public function deleteRegions($content, $regions) { foreach ($regions as $region) { $region->detach(); $this->manager->remove($region); $this->manager->flush(); } }
php
public function deleteRegions($content, $regions) { foreach ($regions as $region) { $region->detach(); $this->manager->remove($region); $this->manager->flush(); } }
[ "public", "function", "deleteRegions", "(", "$", "content", ",", "$", "regions", ")", "{", "foreach", "(", "$", "regions", "as", "$", "region", ")", "{", "$", "region", "->", "detach", "(", ")", ";", "$", "this", "->", "manager", "->", "remove", "(",...
Delete a content from every region.
[ "Delete", "a", "content", "from", "every", "region", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L540-L547
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getCreator
public function getCreator($type, $id = null, $content = null, $father = null) { $variables = ['type' => $type]; if ($id && !$content) { $content = $this->content->find($id); $variables['content'] = $content; } $variables['form'] = $this->formFactory->create( HomeContentType::class, $content, ['id' => $id, 'type' => $type, 'father' => $father] )->createView(); return $this->homeService->isDefinedPush($variables, 'father', $father); }
php
public function getCreator($type, $id = null, $content = null, $father = null) { $variables = ['type' => $type]; if ($id && !$content) { $content = $this->content->find($id); $variables['content'] = $content; } $variables['form'] = $this->formFactory->create( HomeContentType::class, $content, ['id' => $id, 'type' => $type, 'father' => $father] )->createView(); return $this->homeService->isDefinedPush($variables, 'father', $father); }
[ "public", "function", "getCreator", "(", "$", "type", ",", "$", "id", "=", "null", ",", "$", "content", "=", "null", ",", "$", "father", "=", "null", ")", "{", "$", "variables", "=", "[", "'type'", "=>", "$", "type", "]", ";", "if", "(", "$", "...
Get the creator of contents. @return array
[ "Get", "the", "creator", "of", "contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L554-L570
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getMenu
public function getMenu($id, $size, $type, $father = null, $region = null, $collapse = false) { $variables = ['id' => $id, 'size' => $size, 'type' => $type, 'region' => $region, 'collapse' => $collapse]; return $this->homeService->isDefinedPush($variables, 'father', $father); }
php
public function getMenu($id, $size, $type, $father = null, $region = null, $collapse = false) { $variables = ['id' => $id, 'size' => $size, 'type' => $type, 'region' => $region, 'collapse' => $collapse]; return $this->homeService->isDefinedPush($variables, 'father', $father); }
[ "public", "function", "getMenu", "(", "$", "id", ",", "$", "size", ",", "$", "type", ",", "$", "father", "=", "null", ",", "$", "region", "=", "null", ",", "$", "collapse", "=", "false", ")", "{", "$", "variables", "=", "[", "'id'", "=>", "$", ...
Get the variables of the menu. @param string $id The id of the content @param string $size The size (content-8) of the content @param string $type The type of the content @return array
[ "Get", "the", "variables", "of", "the", "menu", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L581-L586
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.getHomeParameters
public function getHomeParameters() { return [ 'homeMenu' => $this->configHandler->getParameter('home_menu'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), ]; }
php
public function getHomeParameters() { return [ 'homeMenu' => $this->configHandler->getParameter('home_menu'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), ]; }
[ "public", "function", "getHomeParameters", "(", ")", "{", "return", "[", "'homeMenu'", "=>", "$", "this", "->", "configHandler", "->", "getParameter", "(", "'home_menu'", ")", ",", "'footerLogin'", "=>", "$", "this", "->", "configHandler", "->", "getParameter", ...
Get the home parameters.
[ "Get", "the", "home", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L603-L611
train
claroline/Distribution
main/core/Manager/HomeManager.php
HomeManager.saveHomeParameters
public function saveHomeParameters($homeMenu, $footerLogin, $footerWorkspaces, $headerLocale) { $this->configHandler->setParameters( [ 'home_menu' => is_numeric($homeMenu) ? intval($homeMenu) : null, 'footer_login' => ('true' === $footerLogin), 'footer_workspaces' => ('true' === $footerWorkspaces), 'header_locale' => ('true' === $headerLocale), ] ); }
php
public function saveHomeParameters($homeMenu, $footerLogin, $footerWorkspaces, $headerLocale) { $this->configHandler->setParameters( [ 'home_menu' => is_numeric($homeMenu) ? intval($homeMenu) : null, 'footer_login' => ('true' === $footerLogin), 'footer_workspaces' => ('true' === $footerWorkspaces), 'header_locale' => ('true' === $headerLocale), ] ); }
[ "public", "function", "saveHomeParameters", "(", "$", "homeMenu", ",", "$", "footerLogin", ",", "$", "footerWorkspaces", ",", "$", "headerLocale", ")", "{", "$", "this", "->", "configHandler", "->", "setParameters", "(", "[", "'home_menu'", "=>", "is_numeric", ...
Save the home parameters.
[ "Save", "the", "home", "parameters", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/HomeManager.php#L616-L626
train
claroline/Distribution
main/core/Controller/WorkspaceController.php
WorkspaceController.renderToolbarAction
public function renderToolbarAction(Workspace $workspace, Request $request) { $orderedTools = []; $hasManagerAccess = $this->workspaceManager->isManager($workspace, $this->tokenStorage->getToken()); $hideToolsMenu = $this->workspaceManager->isToolsMenuHidden($workspace); $this->toolManager->addMissingWorkspaceTools($workspace); if ($hasManagerAccess || !$hideToolsMenu) { // load tool list if ($hasManagerAccess) { // gets all available tools $orderedTools = $this->toolManager->getOrderedToolsByWorkspace($workspace); // always display tools to managers $hideToolsMenu = false; } else { // gets accessible tools by user $currentRoles = $this->utils->getRoles($this->tokenStorage->getToken()); $orderedTools = $this->toolManager->getOrderedToolsByWorkspaceAndRoles($workspace, $currentRoles); } } $current = null; if ('claro_workspace_open_tool' === $request->get('_route')) { $params = $request->get('_route_params'); if (!empty($params['toolName'])) { $current = $params['toolName']; } } // mega hack to make the resource manager active when inside a resource if (in_array($request->get('_route'), ['claro_resource_show', 'claro_resource_show_short'])) { $current = 'resource_manager'; } return [ 'current' => $current, 'tools' => array_values(array_map(function (OrderedTool $orderedTool) use ($workspace) { // todo : create a serializer return [ 'icon' => $orderedTool->getTool()->getClass(), 'name' => $orderedTool->getTool()->getName(), 'open' => ['claro_workspace_open_tool', ['workspaceId' => $workspace->getId(), 'toolName' => $orderedTool->getTool()->getName()]], ]; }, $orderedTools)), 'workspace' => $workspace, 'hideToolsMenu' => $hideToolsMenu, ]; }
php
public function renderToolbarAction(Workspace $workspace, Request $request) { $orderedTools = []; $hasManagerAccess = $this->workspaceManager->isManager($workspace, $this->tokenStorage->getToken()); $hideToolsMenu = $this->workspaceManager->isToolsMenuHidden($workspace); $this->toolManager->addMissingWorkspaceTools($workspace); if ($hasManagerAccess || !$hideToolsMenu) { // load tool list if ($hasManagerAccess) { // gets all available tools $orderedTools = $this->toolManager->getOrderedToolsByWorkspace($workspace); // always display tools to managers $hideToolsMenu = false; } else { // gets accessible tools by user $currentRoles = $this->utils->getRoles($this->tokenStorage->getToken()); $orderedTools = $this->toolManager->getOrderedToolsByWorkspaceAndRoles($workspace, $currentRoles); } } $current = null; if ('claro_workspace_open_tool' === $request->get('_route')) { $params = $request->get('_route_params'); if (!empty($params['toolName'])) { $current = $params['toolName']; } } // mega hack to make the resource manager active when inside a resource if (in_array($request->get('_route'), ['claro_resource_show', 'claro_resource_show_short'])) { $current = 'resource_manager'; } return [ 'current' => $current, 'tools' => array_values(array_map(function (OrderedTool $orderedTool) use ($workspace) { // todo : create a serializer return [ 'icon' => $orderedTool->getTool()->getClass(), 'name' => $orderedTool->getTool()->getName(), 'open' => ['claro_workspace_open_tool', ['workspaceId' => $workspace->getId(), 'toolName' => $orderedTool->getTool()->getName()]], ]; }, $orderedTools)), 'workspace' => $workspace, 'hideToolsMenu' => $hideToolsMenu, ]; }
[ "public", "function", "renderToolbarAction", "(", "Workspace", "$", "workspace", ",", "Request", "$", "request", ")", "{", "$", "orderedTools", "=", "[", "]", ";", "$", "hasManagerAccess", "=", "$", "this", "->", "workspaceManager", "->", "isManager", "(", "...
Renders the left tool bar. Not routed. @EXT\Template("ClarolineCoreBundle:workspace:toolbar.html.twig") @param Workspace $workspace @param Request $request @return array
[ "Renders", "the", "left", "tool", "bar", ".", "Not", "routed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/WorkspaceController.php#L170-L217
train
claroline/Distribution
main/core/API/Serializer/ParametersSerializer.php
ParametersSerializer.deserialize
public function deserialize(array $data) { $original = $data; $this->deserializeTos($data); $data = $this->getJavascriptsData($data); $data = $this->getLogoData($data); unset($data['tos']['text']); //maybe move this somewhere else unset($data['archives']); $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data); ksort($data); $data = json_encode($data, JSON_PRETTY_PRINT); file_put_contents($this->filePath, $data); return $original; }
php
public function deserialize(array $data) { $original = $data; $this->deserializeTos($data); $data = $this->getJavascriptsData($data); $data = $this->getLogoData($data); unset($data['tos']['text']); //maybe move this somewhere else unset($data['archives']); $data = array_merge($this->serialize([Options::SERIALIZE_MINIMAL]), $data); ksort($data); $data = json_encode($data, JSON_PRETTY_PRINT); file_put_contents($this->filePath, $data); return $original; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ")", "{", "$", "original", "=", "$", "data", ";", "$", "this", "->", "deserializeTos", "(", "$", "data", ")", ";", "$", "data", "=", "$", "this", "->", "getJavascriptsData", "(", "$", "d...
Deserializes the parameters list. @param array $data - the data to deserialize @return array
[ "Deserializes", "the", "parameters", "list", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/ParametersSerializer.php#L97-L114
train
claroline/Distribution
main/app/API/ValidatorProvider.php
ValidatorProvider.validate
public function validate($class, $data, $mode, $throwException = false, array $options = []) { $schema = $this->serializer->getSchema($class); //schema isn't always there yet if ($schema) { $validator = Validator::buildDefault(); $errors = $validator->validate($this->toObject($data), $schema, '', [$mode]); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } if (count($errors) > 0) { return $errors; } } //validate uniques try { $validator = $this->get($class); } catch (\Exception $e) { //no custom validator $uniqueFields = []; $identifiers = $this->serializer->getIdentifiers($class); foreach ($identifiers as $identifier) { $uniqueFields[$identifier] = $identifier; } return $this->validateUnique($uniqueFields, $data, $mode, $class); } //can be deduced from the mapping, but we won't know //wich field is related to wich data prop in that case $uniqueFields = $validator->getUniqueFields(); $errors = $this->validateUnique($uniqueFields, $data, $mode, $class); //custom validation $errors = array_merge($errors, $validator->validate($data, $mode, $options)); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } return $errors; }
php
public function validate($class, $data, $mode, $throwException = false, array $options = []) { $schema = $this->serializer->getSchema($class); //schema isn't always there yet if ($schema) { $validator = Validator::buildDefault(); $errors = $validator->validate($this->toObject($data), $schema, '', [$mode]); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } if (count($errors) > 0) { return $errors; } } //validate uniques try { $validator = $this->get($class); } catch (\Exception $e) { //no custom validator $uniqueFields = []; $identifiers = $this->serializer->getIdentifiers($class); foreach ($identifiers as $identifier) { $uniqueFields[$identifier] = $identifier; } return $this->validateUnique($uniqueFields, $data, $mode, $class); } //can be deduced from the mapping, but we won't know //wich field is related to wich data prop in that case $uniqueFields = $validator->getUniqueFields(); $errors = $this->validateUnique($uniqueFields, $data, $mode, $class); //custom validation $errors = array_merge($errors, $validator->validate($data, $mode, $options)); if (!empty($errors) && $throwException) { throw new InvalidDataException( sprintf('Invalid data for "%s".', $class), $errors ); } return $errors; }
[ "public", "function", "validate", "(", "$", "class", ",", "$", "data", ",", "$", "mode", ",", "$", "throwException", "=", "false", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "schema", "=", "$", "this", "->", "serializer", "->", "ge...
Validates `data` using the `class` validator. @param string $class - the class of the validator to use @param mixed $data - the data to validate @param string $mode - 'create', 'update' @param bool $throwException - if true an InvalidDataException is thrown instead of returning the errors @return array - the list of validation errors @throws InvalidDataException
[ "Validates", "data", "using", "the", "class", "validator", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/ValidatorProvider.php#L102-L154
train
claroline/Distribution
main/app/API/ValidatorProvider.php
ValidatorProvider.validateUnique
private function validateUnique(array $uniqueFields, array $data, $mode, $class) { $errors = []; foreach ($uniqueFields as $dataProp => $entityProp) { if (isset($data[$dataProp])) { $qb = $this->om->createQueryBuilder(); $qb->select('DISTINCT o') ->from($class, 'o') ->where("o.{$entityProp} LIKE :{$entityProp}") ->setParameter($entityProp, $data[$dataProp]); if (self::UPDATE === $mode && isset($data['id'])) { $parameter = is_numeric($data['id']) ? 'id' : 'uuid'; $value = is_numeric($data['id']) ? (int) $data['id'] : $data['id']; $qb->setParameter($parameter, $value)->andWhere("o.{$parameter} != :{$parameter}"); } $objects = $qb->getQuery()->getResult(); if ((self::UPDATE === $mode && isset($data['id'])) || self::CREATE === $mode) { if (count($objects) > 0) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } else { if (count($objects) > 1) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } } } return $errors; }
php
private function validateUnique(array $uniqueFields, array $data, $mode, $class) { $errors = []; foreach ($uniqueFields as $dataProp => $entityProp) { if (isset($data[$dataProp])) { $qb = $this->om->createQueryBuilder(); $qb->select('DISTINCT o') ->from($class, 'o') ->where("o.{$entityProp} LIKE :{$entityProp}") ->setParameter($entityProp, $data[$dataProp]); if (self::UPDATE === $mode && isset($data['id'])) { $parameter = is_numeric($data['id']) ? 'id' : 'uuid'; $value = is_numeric($data['id']) ? (int) $data['id'] : $data['id']; $qb->setParameter($parameter, $value)->andWhere("o.{$parameter} != :{$parameter}"); } $objects = $qb->getQuery()->getResult(); if ((self::UPDATE === $mode && isset($data['id'])) || self::CREATE === $mode) { if (count($objects) > 0) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } else { if (count($objects) > 1) { $errors[] = ['path' => $dataProp, 'message' => "{$entityProp} already exists and should be unique"]; } } } } return $errors; }
[ "private", "function", "validateUnique", "(", "array", "$", "uniqueFields", ",", "array", "$", "data", ",", "$", "mode", ",", "$", "class", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "uniqueFields", "as", "$", "dataProp", "=>", ...
only if uniqueFields in data
[ "only", "if", "uniqueFields", "in", "data" ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/ValidatorProvider.php#L173-L207
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.export
public function export(ResourceNode $node, $locale = 'en', $scormVersion = '2004') { if ('2004' !== $scormVersion && '1.2' !== $scormVersion) { // Invalid Scorm version throw new \Exception('SCORM export : Invalid SCORM version.'); } $resource = $this->resourceManager->getResourceFromNode($node); if (!$resource) { throw new ResourceNotFoundException('SCORM export : The resource '.$node->getName().' was not found'); } // Export the Resource and all it's sub-resources $exportedResources = $this->exportResource($resource, $locale); // Create the manifest for the Scorm package if ('1.2' === $scormVersion) { $manifest = new Scorm12Manifest($node, $exportedResources); } else { $manifest = new Scorm2004Manifest($node, $exportedResources); } $package = $this->createPackage($node, $locale, $manifest, $exportedResources); return $package; }
php
public function export(ResourceNode $node, $locale = 'en', $scormVersion = '2004') { if ('2004' !== $scormVersion && '1.2' !== $scormVersion) { // Invalid Scorm version throw new \Exception('SCORM export : Invalid SCORM version.'); } $resource = $this->resourceManager->getResourceFromNode($node); if (!$resource) { throw new ResourceNotFoundException('SCORM export : The resource '.$node->getName().' was not found'); } // Export the Resource and all it's sub-resources $exportedResources = $this->exportResource($resource, $locale); // Create the manifest for the Scorm package if ('1.2' === $scormVersion) { $manifest = new Scorm12Manifest($node, $exportedResources); } else { $manifest = new Scorm2004Manifest($node, $exportedResources); } $package = $this->createPackage($node, $locale, $manifest, $exportedResources); return $package; }
[ "public", "function", "export", "(", "ResourceNode", "$", "node", ",", "$", "locale", "=", "'en'", ",", "$", "scormVersion", "=", "'2004'", ")", "{", "if", "(", "'2004'", "!==", "$", "scormVersion", "&&", "'1.2'", "!==", "$", "scormVersion", ")", "{", ...
Create a Scorm archive for a ResourceNode. @param ResourceNode $node @param string $locale @param string $scormVersion @return \ZipArchive @throws ResourceNotFoundException @throws \Exception
[ "Create", "a", "Scorm", "archive", "for", "a", "ResourceNode", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L117-L142
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.exportResource
private function exportResource(AbstractResource $resource, $locale) { $resources = []; $event = $this->dispatchEvent($resource, $locale); $embedResources = $event->getEmbedResources(); // Grab data from event $resources[$resource->getResourceNode()->getId()] = [ 'node' => $resource->getResourceNode(), 'template' => $event->getTemplate(), 'assets' => $event->getAssets(), 'files' => $event->getFiles(), 'translation_domains' => $event->getTranslationDomains(), 'resources' => array_keys($embedResources), // We only need IDs ]; if (!empty($embedResources)) { foreach ($embedResources as $embedResource) { if (empty($resources[$embedResource->getResourceNode()->getId()])) { // Current resource has not been exported yet $exported = $this->exportResource($embedResource, $locale); $resources = array_merge($resources, $exported); } } } return $resources; }
php
private function exportResource(AbstractResource $resource, $locale) { $resources = []; $event = $this->dispatchEvent($resource, $locale); $embedResources = $event->getEmbedResources(); // Grab data from event $resources[$resource->getResourceNode()->getId()] = [ 'node' => $resource->getResourceNode(), 'template' => $event->getTemplate(), 'assets' => $event->getAssets(), 'files' => $event->getFiles(), 'translation_domains' => $event->getTranslationDomains(), 'resources' => array_keys($embedResources), // We only need IDs ]; if (!empty($embedResources)) { foreach ($embedResources as $embedResource) { if (empty($resources[$embedResource->getResourceNode()->getId()])) { // Current resource has not been exported yet $exported = $this->exportResource($embedResource, $locale); $resources = array_merge($resources, $exported); } } } return $resources; }
[ "private", "function", "exportResource", "(", "AbstractResource", "$", "resource", ",", "$", "locale", ")", "{", "$", "resources", "=", "[", "]", ";", "$", "event", "=", "$", "this", "->", "dispatchEvent", "(", "$", "resource", ",", "$", "locale", ")", ...
Export a Claroline Resource and all it's embed Resources. @param AbstractResource $resource @param string $locale @return array - The list of exported resource
[ "Export", "a", "Claroline", "Resource", "and", "all", "it", "s", "embed", "Resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L152-L180
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.dispatchEvent
private function dispatchEvent(AbstractResource $resource, $locale) { return $this->dispatcher->dispatch( 'export_scorm_'.$resource->getResourceNode()->getResourceType()->getName(), 'Claroline\\ScormBundle\\Event\\ExportScormResourceEvent', [$resource, $locale] ); }
php
private function dispatchEvent(AbstractResource $resource, $locale) { return $this->dispatcher->dispatch( 'export_scorm_'.$resource->getResourceNode()->getResourceType()->getName(), 'Claroline\\ScormBundle\\Event\\ExportScormResourceEvent', [$resource, $locale] ); }
[ "private", "function", "dispatchEvent", "(", "AbstractResource", "$", "resource", ",", "$", "locale", ")", "{", "return", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'export_scorm_'", ".", "$", "resource", "->", "getResourceNode", "(", ")", "->", ...
Dispatch export event for the Resource. @param AbstractResource $resource @param string $locale @return ExportScormResourceEvent
[ "Dispatch", "export", "event", "for", "the", "Resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L190-L197
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.createPackage
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = []) { $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis'); // Create and open scorm archive if (!is_dir($this->tmpPath)) { mkdir($this->tmpPath); } $archive = new \ZipArchive(); $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE); // Add manifest $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump()); // Add common files $this->addCommons($archive, $locale); // Add resources files foreach ($scos as $sco) { // Dump template into file $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']); // Dump additional resource assets if (!empty($sco['assets'])) { foreach ($sco['assets'] as $filename => $originalFile) { $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } } // Add uploaded files if (!empty($sco['files'])) { // $this->container->getParameter('claroline.param.files_directory') foreach ($sco['files'] as $filename => $originalFile) { $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']); $this->copyToPackage($archive, 'files/'.$filename, $filePath); } } // Add translations if (!empty($sco['translation_domains'])) { foreach ($sco['translation_domains'] as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } } } $archive->close(); return $archive; }
php
public function createPackage(ResourceNode $node, $locale, AbstractScormManifest $manifest, array $scos = []) { $scormId = 'scorm-'.$node->getId().'-'.date('YmdHis'); // Create and open scorm archive if (!is_dir($this->tmpPath)) { mkdir($this->tmpPath); } $archive = new \ZipArchive(); $archive->open($this->tmpPath.DIRECTORY_SEPARATOR.$scormId.'.zip', \ZipArchive::CREATE); // Add manifest $this->saveToPackage($archive, 'imsmanifest.xml', $manifest->dump()); // Add common files $this->addCommons($archive, $locale); // Add resources files foreach ($scos as $sco) { // Dump template into file $this->saveToPackage($archive, 'scos/resource_'.$sco['node']->getId().'.html', $sco['template']); // Dump additional resource assets if (!empty($sco['assets'])) { foreach ($sco['assets'] as $filename => $originalFile) { $this->copyToPackage($archive, 'assets/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } } // Add uploaded files if (!empty($sco['files'])) { // $this->container->getParameter('claroline.param.files_directory') foreach ($sco['files'] as $filename => $originalFile) { $filePath = $originalFile['absolute'] ? $originalFile['path'] : $this->getFilePath($this->uploadPath, $originalFile['path']); $this->copyToPackage($archive, 'files/'.$filename, $filePath); } } // Add translations if (!empty($sco['translation_domains'])) { foreach ($sco['translation_domains'] as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } } } $archive->close(); return $archive; }
[ "public", "function", "createPackage", "(", "ResourceNode", "$", "node", ",", "$", "locale", ",", "AbstractScormManifest", "$", "manifest", ",", "array", "$", "scos", "=", "[", "]", ")", "{", "$", "scormId", "=", "'scorm-'", ".", "$", "node", "->", "getI...
Create SCORM package. @param ResourceNode $node - The exported ResourceNode @param string $locale - THe locale to use for export @param AbstractScormManifest $manifest - The manifest of the SCORM package @param array $scos - The list of resources to include into the package @return \ZipArchive
[ "Create", "SCORM", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L209-L260
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.addCommons
private function addCommons(\ZipArchive $archive, $locale) { $assets = [ 'bootstrap.css' => 'themes/claroline/bootstrap.css', 'fontawesome' => 'packages/@fortawesome/fontawesome-free/css/fontawesome.css', 'v4-shims' => 'packages/@fortawesome/fontawesome-free/css/v4-shims.css', 'solid' => 'packages/@fortawesome/fontawesome-free/css/solid.css', 'regular' => 'packages/@fortawesome/fontawesome-free/css/regular.css', 'brands' => 'packages/@fortawesome/fontawesome-free/css/brands.css', 'claroline-reset.css' => 'vendor/clarolinescorm/claroline-reset.css', 'jquery.min.js' => 'packages/jquery/dist/jquery.min.js', 'jquery-ui.min.js' => 'packages/jquery-ui-dist/jquery-ui.min.js', 'bootstrap.min.js' => 'packages/bootstrap/dist/js/bootstrap.min.js', 'translator.js' => 'bundles/bazingajstranslation/js/translator.min.js', 'router.js' => 'bundles/fosjsrouting/js/router.js', 'video.min.js' => 'packages/video.js/dist/video.min.js', 'video-js.min.css' => 'packages/video.js/dist/video-js.min.css', 'video-js.swf' => 'packages/video.js/dist/video-js.swf', ]; $webpackAssets = [ 'commons.js' => 'dist/commons.js', 'claroline-distribution-plugin-video-player-watcher.js' => 'dist/claroline-distribution-plugin-video-player-watcher.js', ]; $translationDomains = [ 'resource', 'home', 'platform', 'error', 'validators', ]; foreach ($assets as $filename => $originalFile) { $this->copyToPackage($archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } // Add webpack assets foreach ($webpackAssets as $filename => $originalFile) { $this->copyToPackage( $archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $this->webpack->hotAsset($originalFile, true)) ); } // Add FontAwesome font files $fontDir = $this->webPath.DIRECTORY_SEPARATOR.'packages/@fortawesome/fontawesome-free/webfonts'; $files = scandir($fontDir); foreach ($files as $file) { $filePath = $fontDir.DIRECTORY_SEPARATOR.$file; if (is_file($filePath)) { $this->copyToPackage($archive, 'fonts/'.$file, $this->getFilePath($fontDir, $file)); } } // Generate JS routes with FOSJSRoutingBundle $request = new Request([ 'callback' => 'fos.Router.setData', ]); $jsRoutes = $this->jsRouterCtrl->indexAction($request, 'js'); $this->saveToPackage($archive, 'commons/routes.js', $jsRoutes->getContent()); // Add common translations foreach ($translationDomains as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } }
php
private function addCommons(\ZipArchive $archive, $locale) { $assets = [ 'bootstrap.css' => 'themes/claroline/bootstrap.css', 'fontawesome' => 'packages/@fortawesome/fontawesome-free/css/fontawesome.css', 'v4-shims' => 'packages/@fortawesome/fontawesome-free/css/v4-shims.css', 'solid' => 'packages/@fortawesome/fontawesome-free/css/solid.css', 'regular' => 'packages/@fortawesome/fontawesome-free/css/regular.css', 'brands' => 'packages/@fortawesome/fontawesome-free/css/brands.css', 'claroline-reset.css' => 'vendor/clarolinescorm/claroline-reset.css', 'jquery.min.js' => 'packages/jquery/dist/jquery.min.js', 'jquery-ui.min.js' => 'packages/jquery-ui-dist/jquery-ui.min.js', 'bootstrap.min.js' => 'packages/bootstrap/dist/js/bootstrap.min.js', 'translator.js' => 'bundles/bazingajstranslation/js/translator.min.js', 'router.js' => 'bundles/fosjsrouting/js/router.js', 'video.min.js' => 'packages/video.js/dist/video.min.js', 'video-js.min.css' => 'packages/video.js/dist/video-js.min.css', 'video-js.swf' => 'packages/video.js/dist/video-js.swf', ]; $webpackAssets = [ 'commons.js' => 'dist/commons.js', 'claroline-distribution-plugin-video-player-watcher.js' => 'dist/claroline-distribution-plugin-video-player-watcher.js', ]; $translationDomains = [ 'resource', 'home', 'platform', 'error', 'validators', ]; foreach ($assets as $filename => $originalFile) { $this->copyToPackage($archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $originalFile)); } // Add webpack assets foreach ($webpackAssets as $filename => $originalFile) { $this->copyToPackage( $archive, 'commons/'.$filename, $this->getFilePath($this->webPath, $this->webpack->hotAsset($originalFile, true)) ); } // Add FontAwesome font files $fontDir = $this->webPath.DIRECTORY_SEPARATOR.'packages/@fortawesome/fontawesome-free/webfonts'; $files = scandir($fontDir); foreach ($files as $file) { $filePath = $fontDir.DIRECTORY_SEPARATOR.$file; if (is_file($filePath)) { $this->copyToPackage($archive, 'fonts/'.$file, $this->getFilePath($fontDir, $file)); } } // Generate JS routes with FOSJSRoutingBundle $request = new Request([ 'callback' => 'fos.Router.setData', ]); $jsRoutes = $this->jsRouterCtrl->indexAction($request, 'js'); $this->saveToPackage($archive, 'commons/routes.js', $jsRoutes->getContent()); // Add common translations foreach ($translationDomains as $domain) { $translationFile = 'js/translations/'.$domain.'/'.$locale.'.js'; $this->copyToPackage($archive, 'translations/'.$domain.'.js', $this->getFilePath($this->webPath, $translationFile)); } }
[ "private", "function", "addCommons", "(", "\\", "ZipArchive", "$", "archive", ",", "$", "locale", ")", "{", "$", "assets", "=", "[", "'bootstrap.css'", "=>", "'themes/claroline/bootstrap.css'", ",", "'fontawesome'", "=>", "'packages/@fortawesome/fontawesome-free/css/fon...
Adds the claroline common assets and translations into the package. @param \ZipArchive $archive @param string $locale
[ "Adds", "the", "claroline", "common", "assets", "and", "translations", "into", "the", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L268-L336
train
claroline/Distribution
plugin/scorm/Manager/ExportManager.php
ExportManager.copyToPackage
private function copyToPackage(\ZipArchive $archive, $pathInArchive, $path) { if (file_exists($path)) { if (is_dir($path)) { /** @var \SplFileInfo[] $files */ $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $file) { // Skip directories if (!$file->isDir()) { // Get real and relative path for current file // Add current file to archive $archive->addFile( $path.DIRECTORY_SEPARATOR.$file->getFilename(), $pathInArchive.DIRECTORY_SEPARATOR.$file->getFilename()); } } } else { $archive->addFile($path, $pathInArchive); } } else { throw new FileNotFoundException(sprintf('File "%s" could not be found.', $path)); } }
php
private function copyToPackage(\ZipArchive $archive, $pathInArchive, $path) { if (file_exists($path)) { if (is_dir($path)) { /** @var \SplFileInfo[] $files */ $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $file) { // Skip directories if (!$file->isDir()) { // Get real and relative path for current file // Add current file to archive $archive->addFile( $path.DIRECTORY_SEPARATOR.$file->getFilename(), $pathInArchive.DIRECTORY_SEPARATOR.$file->getFilename()); } } } else { $archive->addFile($path, $pathInArchive); } } else { throw new FileNotFoundException(sprintf('File "%s" could not be found.', $path)); } }
[ "private", "function", "copyToPackage", "(", "\\", "ZipArchive", "$", "archive", ",", "$", "pathInArchive", ",", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "if", "(", "is_dir", "(", "$", "path", ")", ")", "{", ...
Copy file into the SCORM package. @param \ZipArchive $archive @param string $pathInArchive @param string $path
[ "Copy", "file", "into", "the", "SCORM", "package", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ExportManager.php#L345-L370
train
claroline/Distribution
main/core/Repository/ResourceTypeRepository.php
ResourceTypeRepository.findAll
public function findAll($filterEnabled = true) { if (!$filterEnabled) { return parent::findAll(); } $dql = ' SELECT rt FROM Claroline\CoreBundle\Entity\Resource\ResourceType rt LEFT JOIN rt.plugin p WHERE (CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR rt.plugin is NULL) AND rt.isEnabled = true'; $query = $this->_em->createQuery($dql); $query->setParameter('bundles', $this->bundles); return $query->getResult(); }
php
public function findAll($filterEnabled = true) { if (!$filterEnabled) { return parent::findAll(); } $dql = ' SELECT rt FROM Claroline\CoreBundle\Entity\Resource\ResourceType rt LEFT JOIN rt.plugin p WHERE (CONCAT(p.vendorName, p.bundleName) IN (:bundles) OR rt.plugin is NULL) AND rt.isEnabled = true'; $query = $this->_em->createQuery($dql); $query->setParameter('bundles', $this->bundles); return $query->getResult(); }
[ "public", "function", "findAll", "(", "$", "filterEnabled", "=", "true", ")", "{", "if", "(", "!", "$", "filterEnabled", ")", "{", "return", "parent", "::", "findAll", "(", ")", ";", "}", "$", "dql", "=", "'\n SELECT rt FROM Claroline\\CoreBundle\\Ent...
Returns all the resource types introduced by plugins. @param bool $filterEnabled - when true, it will only return resource types for enabled plugins @return ResourceType[]
[ "Returns", "all", "the", "resource", "types", "introduced", "by", "plugins", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceTypeRepository.php#L92-L109
train
claroline/Distribution
main/core/Repository/ResourceTypeRepository.php
ResourceTypeRepository.findEnabledResourceTypesByNames
public function findEnabledResourceTypesByNames(array $names) { if (count($names) > 0) { $dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Resource\ResourceType r WHERE r.isEnabled = true AND r.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); } else { $result = []; } return $result; }
php
public function findEnabledResourceTypesByNames(array $names) { if (count($names) > 0) { $dql = ' SELECT r FROM Claroline\CoreBundle\Entity\Resource\ResourceType r WHERE r.isEnabled = true AND r.name IN (:names) '; $query = $this->_em->createQuery($dql); $query->setParameter('names', $names); $result = $query->getResult(); } else { $result = []; } return $result; }
[ "public", "function", "findEnabledResourceTypesByNames", "(", "array", "$", "names", ")", "{", "if", "(", "count", "(", "$", "names", ")", ">", "0", ")", "{", "$", "dql", "=", "'\n SELECT r\n FROM Claroline\\CoreBundle\\Entity\\Resource\\Re...
Returns enabled resource types by their names. @param array $names @return ResourceType[]
[ "Returns", "enabled", "resource", "types", "by", "their", "names", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceTypeRepository.php#L144-L162
train
claroline/Distribution
main/core/Manager/Theme/ThemeBuilderManager.php
ThemeBuilderManager.rebuild
public function rebuild(array $themes, $cache = true) { $logs = []; foreach ($themes as $theme) { $logs[$theme->getNormalizedName()] = $this->rebuildTheme($theme, $cache); } return $logs; }
php
public function rebuild(array $themes, $cache = true) { $logs = []; foreach ($themes as $theme) { $logs[$theme->getNormalizedName()] = $this->rebuildTheme($theme, $cache); } return $logs; }
[ "public", "function", "rebuild", "(", "array", "$", "themes", ",", "$", "cache", "=", "true", ")", "{", "$", "logs", "=", "[", "]", ";", "foreach", "(", "$", "themes", "as", "$", "theme", ")", "{", "$", "logs", "[", "$", "theme", "->", "getNormal...
Rebuilds the list of themes passed as argument. @param Theme[] $themes @param bool $cache @return array
[ "Rebuilds", "the", "list", "of", "themes", "passed", "as", "argument", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Theme/ThemeBuilderManager.php#L86-L95
train
claroline/Distribution
main/core/Library/Utilities/ClaroUtilities.php
ClaroUtilities.getRealFileSize
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = ['KB', 'MB', 'GB', 'TB']; $value = str_replace(' ', '', $fileSize); $pattern = '/\d+/'; preg_match($pattern, $value, $match); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch ($unit) { case 'B': return $match[0] * pow(1024, 0); case 'KB': return $match[0] * pow(1024, 1); case 'MB': return $match[0] * pow(1024, 2); case 'GB': return $match[0] * pow(1024, 3); case 'TB': return $match[0] * pow(1024, 4); } } } return $fileSize; }
php
public function getRealFileSize($fileSize) { //B goes at the end because it's always matched otherwise $validUnits = ['KB', 'MB', 'GB', 'TB']; $value = str_replace(' ', '', $fileSize); $pattern = '/\d+/'; preg_match($pattern, $value, $match); foreach ($validUnits as $unit) { if (strpos($fileSize, $unit)) { switch ($unit) { case 'B': return $match[0] * pow(1024, 0); case 'KB': return $match[0] * pow(1024, 1); case 'MB': return $match[0] * pow(1024, 2); case 'GB': return $match[0] * pow(1024, 3); case 'TB': return $match[0] * pow(1024, 4); } } } return $fileSize; }
[ "public", "function", "getRealFileSize", "(", "$", "fileSize", ")", "{", "//B goes at the end because it's always matched otherwise", "$", "validUnits", "=", "[", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", "]", ";", "$", "value", "=", "str_replace", "(", "' ...
Take a formatted file size and returns the number of bytes. @deprecated. just let the client do it for you
[ "Take", "a", "formatted", "file", "size", "and", "returns", "the", "number", "of", "bytes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Library/Utilities/ClaroUtilities.php#L181-L208
train
claroline/Distribution
plugin/reservation/Controller/API/ResourceController.php
ResourceController.listOrganizationsAction
public function listOrganizationsAction($id, Request $request) { $resource = $this->resourceRepo->findOneBy(['uuid' => $id]); $organizations = !empty($resource) ? $resource->getOrganizations() : []; $organizationsUuids = array_map(function (Organization $organization) { return $organization->getUuid(); }, $organizations); return new JsonResponse( $this->finder->search('Claroline\CoreBundle\Entity\Organization\Organization', array_merge( $request->query->all(), ['hiddenFilters' => ['whitelist' => $organizationsUuids]] )) ); }
php
public function listOrganizationsAction($id, Request $request) { $resource = $this->resourceRepo->findOneBy(['uuid' => $id]); $organizations = !empty($resource) ? $resource->getOrganizations() : []; $organizationsUuids = array_map(function (Organization $organization) { return $organization->getUuid(); }, $organizations); return new JsonResponse( $this->finder->search('Claroline\CoreBundle\Entity\Organization\Organization', array_merge( $request->query->all(), ['hiddenFilters' => ['whitelist' => $organizationsUuids]] )) ); }
[ "public", "function", "listOrganizationsAction", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "resource", "=", "$", "this", "->", "resourceRepo", "->", "findOneBy", "(", "[", "'uuid'", "=>", "$", "id", "]", ")", ";", "$", "organizations...
List organizations of the collection. @Route("/{id}/organization") @Method("GET") @param string $id @param Request $request @return JsonResponse
[ "List", "organizations", "of", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Controller/API/ResourceController.php#L72-L86
train
claroline/Distribution
plugin/reservation/Controller/API/ResourceController.php
ResourceController.exportResourcesAction
public function exportResourcesAction(Request $request) { $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource'); $response = new StreamedResponse(function () use ($resources) { $file = fopen('php://output', 'w'); fputcsv($file, [ 'resourceType.name', 'id', 'name', 'maxTimeReservation', 'description', 'localization', 'quantity', 'color', ], ';', '"'); foreach ($resources as $resource) { if (!empty($resource)) { $resourceType = $resource->getResourceType(); $data = [ $resourceType->getName(), $resource->getUuid(), $resource->getName(), $resource->getMaxTimeReservation(), $resource->getDescription(), $resource->getLocalisation(), $resource->getQuantity(), $resource->getColor(), ]; fputcsv($file, $data, ';', '"'); } } fclose($file); }); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"'); $response->headers->set('Content-Type', 'application/csv; charset=utf-8'); $response->headers->set('Connection', 'close'); $response->send(); return $response; }
php
public function exportResourcesAction(Request $request) { $resources = $this->decodeIdsString($request, 'FormaLibre\ReservationBundle\Entity\Resource'); $response = new StreamedResponse(function () use ($resources) { $file = fopen('php://output', 'w'); fputcsv($file, [ 'resourceType.name', 'id', 'name', 'maxTimeReservation', 'description', 'localization', 'quantity', 'color', ], ';', '"'); foreach ($resources as $resource) { if (!empty($resource)) { $resourceType = $resource->getResourceType(); $data = [ $resourceType->getName(), $resource->getUuid(), $resource->getName(), $resource->getMaxTimeReservation(), $resource->getDescription(), $resource->getLocalisation(), $resource->getQuantity(), $resource->getColor(), ]; fputcsv($file, $data, ';', '"'); } } fclose($file); }); $response->headers->set('Content-Transfer-Encoding', 'octet-stream'); $response->headers->set('Content-Type', 'application/force-download'); $response->headers->set('Content-Disposition', 'attachment; filename="resources.csv"'); $response->headers->set('Content-Type', 'application/csv; charset=utf-8'); $response->headers->set('Connection', 'close'); $response->send(); return $response; }
[ "public", "function", "exportResourcesAction", "(", "Request", "$", "request", ")", "{", "$", "resources", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'FormaLibre\\ReservationBundle\\Entity\\Resource'", ")", ";", "$", "response", "=", "ne...
Exports resources. @Route( "/resources/export", name="apiv2_reservationresource_export" ) @Method("GET") @return StreamedResponse
[ "Exports", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Controller/API/ResourceController.php#L99-L142
train
claroline/Distribution
plugin/exo/Library/Item/Definition/AbstractDefinition.php
AbstractDefinition.validateAnswer
public function validateAnswer($answer, AbstractItem $question, array $options = []) { $options[Validation::QUESTION] = $question; return $this->getAnswerValidator()->validate($answer, $options); }
php
public function validateAnswer($answer, AbstractItem $question, array $options = []) { $options[Validation::QUESTION] = $question; return $this->getAnswerValidator()->validate($answer, $options); }
[ "public", "function", "validateAnswer", "(", "$", "answer", ",", "AbstractItem", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "Validation", "::", "QUESTION", "]", "=", "$", "question", ";", "return", "$", ...
Validates the answer data for a question. @param mixed $answer @param AbstractItem $question @param array $options @return array
[ "Validates", "the", "answer", "data", "for", "a", "question", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/AbstractDefinition.php#L57-L62
train
claroline/Distribution
plugin/exo/Library/Item/Definition/AbstractDefinition.php
AbstractDefinition.deserializeQuestion
public function deserializeQuestion(array $questionData, AbstractItem $question = null, array $options = []) { return $this->getQuestionSerializer()->deserialize($questionData, $question, $options); }
php
public function deserializeQuestion(array $questionData, AbstractItem $question = null, array $options = []) { return $this->getQuestionSerializer()->deserialize($questionData, $question, $options); }
[ "public", "function", "deserializeQuestion", "(", "array", "$", "questionData", ",", "AbstractItem", "$", "question", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getQuestionSerializer", "(", ")", "->", ...
Deserializes question data. @param array $questionData @param AbstractItem $question @param array $options @return AbstractItem
[ "Deserializes", "question", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/AbstractDefinition.php#L86-L89
train