id
int32
0
241k
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
40,100
claroline/Distribution
plugin/blog/Controller/API/BlogController.php
BlogController.updateOptionsAction
public function updateOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $this->blogManager->updateOptions($blog, $this->blogOptionsSerializer->deserialize($data), $data['infos']); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions())); }
php
public function updateOptionsAction(Request $request, Blog $blog) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $this->blogManager->updateOptions($blog, $this->blogOptionsSerializer->deserialize($data), $data['infos']); return new JsonResponse($this->blogOptionsSerializer->serialize($blog, $blog->getOptions())); }
[ "public", "function", "updateOptionsAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ...
Update blog options. @EXT\Route("options/update", name="apiv2_blog_options_update") @EXT\Method("PUT") @param Blog $blog @return array
[ "Update", "blog", "options", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/BlogController.php#L100-L107
40,101
claroline/Distribution
plugin/blog/Controller/API/BlogController.php
BlogController.getTagsAction
public function getTagsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters['limit'] = -1; $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, true); $postsData = []; if (!empty($posts)) { $postsData = $posts['data']; } return new JsonResponse($this->blogManager->getTags($blog, $postsData)); }
php
public function getTagsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters['limit'] = -1; $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, true); $postsData = []; if (!empty($posts)) { $postsData = $posts['data']; } return new JsonResponse($this->blogManager->getTags($blog, $postsData)); }
[ "public", "function", "getTagsAction", "(", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";", "$", "parameters", "[", "'limit'"...
Get tag cloud, tags used in blog posts. @EXT\Route("tags", name="apiv2_blog_tags") @EXT\Method("GET")
[ "Get", "tag", "cloud", "tags", "used", "in", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/BlogController.php#L115-L136
40,102
claroline/Distribution
plugin/tag/Serializer/TagSerializer.php
TagSerializer.serialize
public function serialize(Tag $tag, array $options = []): array { $serialized = [ 'id' => $tag->getUuid(), 'name' => $tag->getName(), 'color' => $tag->getColor(), ]; if (!in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'meta' => [ 'description' => $tag->getDescription(), 'creator' => $tag->getUser() ? $this->userSerializer->serialize($tag->getUser(), [Options::SERIALIZE_MINIMAL]) : null, ], 'elements' => $this->taggedObjectRepo->countByTag($tag), ]); } return $serialized; }
php
public function serialize(Tag $tag, array $options = []): array { $serialized = [ 'id' => $tag->getUuid(), 'name' => $tag->getName(), 'color' => $tag->getColor(), ]; if (!in_array(Options::SERIALIZE_MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'meta' => [ 'description' => $tag->getDescription(), 'creator' => $tag->getUser() ? $this->userSerializer->serialize($tag->getUser(), [Options::SERIALIZE_MINIMAL]) : null, ], 'elements' => $this->taggedObjectRepo->countByTag($tag), ]); } return $serialized; }
[ "public", "function", "serialize", "(", "Tag", "$", "tag", ",", "array", "$", "options", "=", "[", "]", ")", ":", "array", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "tag", "->", "getUuid", "(", ")", ",", "'name'", "=>", "$", "tag", "->...
Serializes a Tag entity into a serializable array. @param Tag $tag @param array $options @return array
[ "Serializes", "a", "Tag", "entity", "into", "a", "serializable", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Serializer/TagSerializer.php#L66-L87
40,103
claroline/Distribution
plugin/tag/Serializer/TagSerializer.php
TagSerializer.deserialize
public function deserialize(array $data, Tag $tag): Tag { $this->sipe('name', 'setName', $data, $tag); $this->sipe('color', 'setColor', $data, $tag); $this->sipe('meta.description', 'setDescription', $data, $tag); if (isset($data['meta']) && isset($data['meta']['creator'])) { $user = $this->om->getRepository(User::class)->findBy(['uuid' => $data['meta']['creator']['id']]); if ($user) { $tag->setUser($user); } } return $tag; }
php
public function deserialize(array $data, Tag $tag): Tag { $this->sipe('name', 'setName', $data, $tag); $this->sipe('color', 'setColor', $data, $tag); $this->sipe('meta.description', 'setDescription', $data, $tag); if (isset($data['meta']) && isset($data['meta']['creator'])) { $user = $this->om->getRepository(User::class)->findBy(['uuid' => $data['meta']['creator']['id']]); if ($user) { $tag->setUser($user); } } return $tag; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Tag", "$", "tag", ")", ":", "Tag", "{", "$", "this", "->", "sipe", "(", "'name'", ",", "'setName'", ",", "$", "data", ",", "$", "tag", ")", ";", "$", "this", "->", "sipe", "(",...
Deserializes tag data into an Entity. @param array $data @param Tag $tag @return Tag
[ "Deserializes", "tag", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Serializer/TagSerializer.php#L97-L111
40,104
claroline/Distribution
plugin/collecticiel/Entity/GradingCriteria.php
GradingCriteria.addChoiceCriteria
public function addChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias[] = $choiceCriteria; return $this; }
php
public function addChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias[] = $choiceCriteria; return $this; }
[ "public", "function", "addChoiceCriteria", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ChoiceCriteria", "$", "choiceCriteria", ")", "{", "$", "this", "->", "choiceCriterias", "[", "]", "=", "$", "choiceCriteria", ";", "return", "$", ...
Add choiceCriteria. @param \Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria @return GradingCriteria
[ "Add", "choiceCriteria", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/GradingCriteria.php#L131-L136
40,105
claroline/Distribution
plugin/collecticiel/Entity/GradingCriteria.php
GradingCriteria.removeChoiceCriteria
public function removeChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias->removeElement($choiceCriteria); }
php
public function removeChoiceCriteria(\Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria) { $this->choiceCriterias->removeElement($choiceCriteria); }
[ "public", "function", "removeChoiceCriteria", "(", "\\", "Innova", "\\", "CollecticielBundle", "\\", "Entity", "\\", "ChoiceCriteria", "$", "choiceCriteria", ")", "{", "$", "this", "->", "choiceCriterias", "->", "removeElement", "(", "$", "choiceCriteria", ")", ";...
Remove choiceCriteria. @param \Innova\CollecticielBundle\Entity\ChoiceCriteria $choiceCriteria
[ "Remove", "choiceCriteria", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/collecticiel/Entity/GradingCriteria.php#L143-L146
40,106
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var Path $path */ $path = $event->getResource(); $event->setData([ 'path' => $this->serializer->serialize($path), 'userEvaluation' => $this->serializer->serialize( $this->userProgressionManager->getUpdatedResourceUserEvaluation($path) ), ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var Path $path */ $path = $event->getResource(); $event->setData([ 'path' => $this->serializer->serialize($path), 'userEvaluation' => $this->serializer->serialize( $this->userProgressionManager->getUpdatedResourceUserEvaluation($path) ), ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Path $path */", "$", "path", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "event", "->", "setData", "(", "[", "'path'", "=>", "$", "this", "->", "s...
Loads the Path resource. @DI\Observe("resource.innova_path.load") @param LoadResourceEvent $event
[ "Loads", "the", "Path", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L96-L108
40,107
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.onCopy
public function onCopy(CopyResourceEvent $event) { // Start the transaction. We'll copy every resource in one go that way. $this->om->startFlushSuite(); /** @var Path $path */ $path = $event->getCopy(); $pathNode = $path->getResourceNode(); if ($path->hasResources()) { // create a directory to store copied resources $resourcesDirectory = $this->createResourcesCopyDirectory($pathNode->getParent(), $pathNode->getName()); // A forced flush is required for rights propagation on the copied resources $this->om->forceFlush(); // copy resources for all steps $copiedResources = []; foreach ($path->getSteps() as $step) { if ($step->hasResources()) { $copiedResources = $this->copyStepResources($step, $resourcesDirectory->getResourceNode(), $copiedResources); } } } $this->om->persist($path); // End the transaction $this->om->endFlushSuite(); $event->setCopy($path); $event->stopPropagation(); }
php
public function onCopy(CopyResourceEvent $event) { // Start the transaction. We'll copy every resource in one go that way. $this->om->startFlushSuite(); /** @var Path $path */ $path = $event->getCopy(); $pathNode = $path->getResourceNode(); if ($path->hasResources()) { // create a directory to store copied resources $resourcesDirectory = $this->createResourcesCopyDirectory($pathNode->getParent(), $pathNode->getName()); // A forced flush is required for rights propagation on the copied resources $this->om->forceFlush(); // copy resources for all steps $copiedResources = []; foreach ($path->getSteps() as $step) { if ($step->hasResources()) { $copiedResources = $this->copyStepResources($step, $resourcesDirectory->getResourceNode(), $copiedResources); } } } $this->om->persist($path); // End the transaction $this->om->endFlushSuite(); $event->setCopy($path); $event->stopPropagation(); }
[ "public", "function", "onCopy", "(", "CopyResourceEvent", "$", "event", ")", "{", "// Start the transaction. We'll copy every resource in one go that way.", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "/** @var Path $path */", "$", "path", "=", "$",...
Fired when a ResourceNode of type Path is duplicated. @DI\Observe("resource.innova_path.copy") @param CopyResourceEvent $event @throws \Exception
[ "Fired", "when", "a", "ResourceNode", "of", "type", "Path", "is", "duplicated", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L131-L162
40,108
claroline/Distribution
plugin/path/Listener/Resource/PathListener.php
PathListener.createResourcesCopyDirectory
private function createResourcesCopyDirectory(ResourceNode $destination, $pathName) { // Get current User $user = $this->tokenStorage->getToken()->getUser(); $resourcesDir = $this->resourceManager->createResource( Directory::class, $pathName.' ('.$this->translator->trans('resources', [], 'platform').')' ); return $this->resourceManager->create( $resourcesDir, $destination->getResourceType(), $user, $destination->getWorkspace(), $destination ); }
php
private function createResourcesCopyDirectory(ResourceNode $destination, $pathName) { // Get current User $user = $this->tokenStorage->getToken()->getUser(); $resourcesDir = $this->resourceManager->createResource( Directory::class, $pathName.' ('.$this->translator->trans('resources', [], 'platform').')' ); return $this->resourceManager->create( $resourcesDir, $destination->getResourceType(), $user, $destination->getWorkspace(), $destination ); }
[ "private", "function", "createResourcesCopyDirectory", "(", "ResourceNode", "$", "destination", ",", "$", "pathName", ")", "{", "// Get current User", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", "...
Create directory to store copies of resources. @param ResourceNode $destination @param string $pathName @return AbstractResource
[ "Create", "directory", "to", "store", "copies", "of", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Listener/Resource/PathListener.php#L172-L189
40,109
claroline/Distribution
main/core/Manager/WorkspaceUserQueueManager.php
WorkspaceUserQueueManager.validateRegistration
public function validateRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->roleManager->associateRolesToSubjects( [$workspaceRegistration->getUser()], [$workspaceRegistration->getRole()], true ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
php
public function validateRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->roleManager->associateRolesToSubjects( [$workspaceRegistration->getUser()], [$workspaceRegistration->getRole()], true ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
[ "public", "function", "validateRegistration", "(", "WorkspaceRegistrationQueue", "$", "workspaceRegistration", ")", "{", "$", "this", "->", "roleManager", "->", "associateRolesToSubjects", "(", "[", "$", "workspaceRegistration", "->", "getUser", "(", ")", "]", ",", ...
Validates a pending workspace registration. @param WorkspaceRegistrationQueue $workspaceRegistration
[ "Validates", "a", "pending", "workspace", "registration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WorkspaceUserQueueManager.php#L59-L69
40,110
claroline/Distribution
main/core/Manager/WorkspaceUserQueueManager.php
WorkspaceUserQueueManager.removeRegistration
public function removeRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->dispatcher->dispatch( 'log', 'Log\LogWorkspaceRegistrationDecline', [$workspaceRegistration] ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
php
public function removeRegistration(WorkspaceRegistrationQueue $workspaceRegistration) { $this->dispatcher->dispatch( 'log', 'Log\LogWorkspaceRegistrationDecline', [$workspaceRegistration] ); $this->om->remove($workspaceRegistration); $this->om->flush(); }
[ "public", "function", "removeRegistration", "(", "WorkspaceRegistrationQueue", "$", "workspaceRegistration", ")", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "'log'", ",", "'Log\\LogWorkspaceRegistrationDecline'", ",", "[", "$", "workspaceRegistration", ...
Removes a pending workspace registration. @param WorkspaceRegistrationQueue $workspaceRegistration
[ "Removes", "a", "pending", "workspace", "registration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WorkspaceUserQueueManager.php#L76-L86
40,111
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.getQuestion
public function getQuestion($questionUuid) { $question = null; if (empty($this->decodedStructure)) { $this->decodeStructure(); } foreach ($this->decodedStructure['steps'] as $step) { foreach ($step['items'] as $item) { if ($item['id'] === $questionUuid) { $question = $item; break 2; } } } return $question; }
php
public function getQuestion($questionUuid) { $question = null; if (empty($this->decodedStructure)) { $this->decodeStructure(); } foreach ($this->decodedStructure['steps'] as $step) { foreach ($step['items'] as $item) { if ($item['id'] === $questionUuid) { $question = $item; break 2; } } } return $question; }
[ "public", "function", "getQuestion", "(", "$", "questionUuid", ")", "{", "$", "question", "=", "null", ";", "if", "(", "empty", "(", "$", "this", "->", "decodedStructure", ")", ")", "{", "$", "this", "->", "decodeStructure", "(", ")", ";", "}", "foreac...
Gets a question in the paper structure. @param $questionUuid @return array
[ "Gets", "a", "question", "in", "the", "paper", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L332-L350
40,112
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.getAnswer
public function getAnswer($questionUuid) { $found = null; foreach ($this->answers as $answer) { if ($answer->getQuestionId() === $questionUuid) { $found = $answer; break; } } return $found; }
php
public function getAnswer($questionUuid) { $found = null; foreach ($this->answers as $answer) { if ($answer->getQuestionId() === $questionUuid) { $found = $answer; break; } } return $found; }
[ "public", "function", "getAnswer", "(", "$", "questionUuid", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "answers", "as", "$", "answer", ")", "{", "if", "(", "$", "answer", "->", "getQuestionId", "(", ")", "===", "$",...
Gets the answer to a question if any exist. @param string $questionUuid @return Answer
[ "Gets", "the", "answer", "to", "a", "question", "if", "any", "exist", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L359-L370
40,113
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.addAnswer
public function addAnswer(Answer $answer) { if (!$this->answers->contains($answer)) { $this->answers->add($answer); $answer->setPaper($this); } }
php
public function addAnswer(Answer $answer) { if (!$this->answers->contains($answer)) { $this->answers->add($answer); $answer->setPaper($this); } }
[ "public", "function", "addAnswer", "(", "Answer", "$", "answer", ")", "{", "if", "(", "!", "$", "this", "->", "answers", "->", "contains", "(", "$", "answer", ")", ")", "{", "$", "this", "->", "answers", "->", "add", "(", "$", "answer", ")", ";", ...
Adds an answer. @param Answer $answer
[ "Adds", "an", "answer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L377-L383
40,114
claroline/Distribution
plugin/exo/Entity/Attempt/Paper.php
Paper.removeAnswer
public function removeAnswer(Answer $answer) { if ($this->answers->contains($answer)) { $this->answers->removeElement($answer); } }
php
public function removeAnswer(Answer $answer) { if ($this->answers->contains($answer)) { $this->answers->removeElement($answer); } }
[ "public", "function", "removeAnswer", "(", "Answer", "$", "answer", ")", "{", "if", "(", "$", "this", "->", "answers", "->", "contains", "(", "$", "answer", ")", ")", "{", "$", "this", "->", "answers", "->", "removeElement", "(", "$", "answer", ")", ...
Removes an answer. @param Answer $answer
[ "Removes", "an", "answer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Attempt/Paper.php#L390-L395
40,115
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serialize
public function serialize(Item $question, array $options = []) { // Serialize specific data for the item type $serialized = $this->serializeQuestionType($question, $options); if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) { $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ? $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) : false; // Adds minimal information $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'autoId' => $question->getId(), 'type' => $question->getMimeType(), 'content' => $question->getContent(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), 'score' => json_decode($question->getScoreRule(), true), 'rights' => ['edit' => $canEdit], ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'hints' => $this->serializeHints($question, $options), 'objects' => $this->serializeObjects($question), 'resources' => $this->serializeResources($question), 'tags' => $this->serializeTags($question), ]); // Adds item feedback if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['feedback'] = $question->getFeedback(); } } } else { $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'type' => $question->getMimeType(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'tags' => $this->serializeTags($question), ]); } } return $serialized; }
php
public function serialize(Item $question, array $options = []) { // Serialize specific data for the item type $serialized = $this->serializeQuestionType($question, $options); if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) { $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ? $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) : false; // Adds minimal information $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'autoId' => $question->getId(), 'type' => $question->getMimeType(), 'content' => $question->getContent(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), 'score' => json_decode($question->getScoreRule(), true), 'rights' => ['edit' => $canEdit], ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'hints' => $this->serializeHints($question, $options), 'objects' => $this->serializeObjects($question), 'resources' => $this->serializeResources($question), 'tags' => $this->serializeTags($question), ]); // Adds item feedback if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['feedback'] = $question->getFeedback(); } } } else { $serialized = array_merge($serialized, [ 'id' => $question->getUuid(), 'type' => $question->getMimeType(), 'title' => $question->getTitle(), 'meta' => $this->serializeMetadata($question, $options), ]); // Adds full definition of the item if (!in_array(Transfer::MINIMAL, $options)) { $serialized = array_merge($serialized, [ 'description' => $question->getDescription(), 'tags' => $this->serializeTags($question), ]); } } return $serialized; }
[ "public", "function", "serialize", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Serialize specific data for the item type", "$", "serialized", "=", "$", "this", "->", "serializeQuestionType", "(", "$", "question", ",",...
Converts a Item into a JSON-encodable structure. @param Item $question @param array $options @return array
[ "Converts", "a", "Item", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L120-L174
40,116
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeQuestionType
private function serializeQuestionType(Item $question, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); return $definition->serializeQuestion($question->getInteraction(), $options); }
php
private function serializeQuestionType(Item $question, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); return $definition->serializeQuestion($question->getInteraction(), $options); }
[ "private", "function", "serializeQuestionType", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "itemDefinitions", "->", "getConvertedType", "(", "$", "question", "->", "getMimeType", ...
Serializes Item data specific to its type. Forwards the serialization to the correct handler. @param Item $question @param array $options @return array
[ "Serializes", "Item", "data", "specific", "to", "its", "type", ".", "Forwards", "the", "serialization", "to", "the", "correct", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L259-L265
40,117
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeQuestionType
private function deserializeQuestionType(Item $question, array $data, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); // Deserialize item type data $type = $definition->deserializeQuestion($data, $question->getInteraction(), $options); $type->setQuestion($question); if (in_array(Transfer::REFRESH_UUID, $options)) { $definition->refreshIdentifiers($question->getInteraction()); } }
php
private function deserializeQuestionType(Item $question, array $data, array $options = []) { $type = $this->itemDefinitions->getConvertedType($question->getMimeType()); $definition = $this->itemDefinitions->get($type); // Deserialize item type data $type = $definition->deserializeQuestion($data, $question->getInteraction(), $options); $type->setQuestion($question); if (in_array(Transfer::REFRESH_UUID, $options)) { $definition->refreshIdentifiers($question->getInteraction()); } }
[ "private", "function", "deserializeQuestionType", "(", "Item", "$", "question", ",", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "type", "=", "$", "this", "->", "itemDefinitions", "->", "getConvertedType", "(", "$", ...
Deserializes Item data specific to its type. Forwards the serialization to the correct handler. @param Item $question @param array $data @param array $options
[ "Deserializes", "Item", "data", "specific", "to", "its", "type", ".", "Forwards", "the", "serialization", "to", "the", "correct", "handler", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L275-L286
40,118
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeMetadata
private function serializeMetadata(Item $question, array $options = []) { $metadata = ['protectQuestion' => $question->getProtectUpdate()]; $creator = $question->getCreator(); if (!empty($creator)) { $metadata['creator'] = $this->userSerializer->serialize($creator, $options); // TODO : remove me. for retro compatibility with old schema $metadata['authors'] = [$this->userSerializer->serialize($creator, $options)]; } if ($question->getDateCreate()) { $metadata['created'] = DateNormalizer::normalize($question->getDateCreate()); } if ($question->getDateModify()) { $metadata['updated'] = DateNormalizer::normalize($question->getDateModify()); } if (in_array(Transfer::INCLUDE_ADMIN_META, $options)) { /** @var ExerciseRepository $exerciseRepo */ $exerciseRepo = $this->om->getRepository(Exercise::class); // Gets exercises that use this item $exercises = $exerciseRepo->findByQuestion($question); $metadata['usedBy'] = array_map(function (Exercise $exercise) { return $exercise->getUuid(); }, $exercises); // Gets users who have access to this item $users = $this->om->getRepository(Shared::class)->findBy(['question' => $question]); $metadata['sharedWith'] = array_map(function (Shared $sharedQuestion) use ($options) { $shared = [ 'adminRights' => $sharedQuestion->hasAdminRights(), 'user' => $this->userSerializer->serialize($sharedQuestion->getUser(), $options), ]; return $shared; }, $users); } return $metadata; }
php
private function serializeMetadata(Item $question, array $options = []) { $metadata = ['protectQuestion' => $question->getProtectUpdate()]; $creator = $question->getCreator(); if (!empty($creator)) { $metadata['creator'] = $this->userSerializer->serialize($creator, $options); // TODO : remove me. for retro compatibility with old schema $metadata['authors'] = [$this->userSerializer->serialize($creator, $options)]; } if ($question->getDateCreate()) { $metadata['created'] = DateNormalizer::normalize($question->getDateCreate()); } if ($question->getDateModify()) { $metadata['updated'] = DateNormalizer::normalize($question->getDateModify()); } if (in_array(Transfer::INCLUDE_ADMIN_META, $options)) { /** @var ExerciseRepository $exerciseRepo */ $exerciseRepo = $this->om->getRepository(Exercise::class); // Gets exercises that use this item $exercises = $exerciseRepo->findByQuestion($question); $metadata['usedBy'] = array_map(function (Exercise $exercise) { return $exercise->getUuid(); }, $exercises); // Gets users who have access to this item $users = $this->om->getRepository(Shared::class)->findBy(['question' => $question]); $metadata['sharedWith'] = array_map(function (Shared $sharedQuestion) use ($options) { $shared = [ 'adminRights' => $sharedQuestion->hasAdminRights(), 'user' => $this->userSerializer->serialize($sharedQuestion->getUser(), $options), ]; return $shared; }, $users); } return $metadata; }
[ "private", "function", "serializeMetadata", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "metadata", "=", "[", "'protectQuestion'", "=>", "$", "question", "->", "getProtectUpdate", "(", ")", "]", ";", "$", "cr...
Serializes Item metadata. @param Item $question @param array $options @return array
[ "Serializes", "Item", "metadata", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L296-L339
40,119
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeHints
private function serializeHints(Item $question, array $options = []) { return array_map(function (Hint $hint) use ($options) { return $this->hintSerializer->serialize($hint, $options); }, $question->getHints()->toArray()); }
php
private function serializeHints(Item $question, array $options = []) { return array_map(function (Hint $hint) use ($options) { return $this->hintSerializer->serialize($hint, $options); }, $question->getHints()->toArray()); }
[ "private", "function", "serializeHints", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "Hint", "$", "hint", ")", "use", "(", "$", "options", ")", "{", "return", "$", ...
Serializes Item hints. Forwards the hint serialization to HintSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "hints", ".", "Forwards", "the", "hint", "serialization", "to", "HintSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L361-L366
40,120
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeHints
private function deserializeHints(Item $question, array $hints = [], array $options = []) { $hintEntities = $question->getHints()->toArray(); foreach ($hints as $hintData) { $existingHint = null; // Searches for an existing hint entity. foreach ($hintEntities as $entityIndex => $entityHint) { /** @var Hint $entityHint */ if ($entityHint->getUuid() === $hintData['id']) { $existingHint = $entityHint; unset($hintEntities[$entityIndex]); break; } } $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options); if (empty($existingHint)) { // Creation of a new hint (we need to link it to the question) $question->addHint($entity); } } // Remaining hints are no longer in the Exercise if (0 < count($hintEntities)) { foreach ($hintEntities as $hintToRemove) { $question->removeHint($hintToRemove); } } }
php
private function deserializeHints(Item $question, array $hints = [], array $options = []) { $hintEntities = $question->getHints()->toArray(); foreach ($hints as $hintData) { $existingHint = null; // Searches for an existing hint entity. foreach ($hintEntities as $entityIndex => $entityHint) { /** @var Hint $entityHint */ if ($entityHint->getUuid() === $hintData['id']) { $existingHint = $entityHint; unset($hintEntities[$entityIndex]); break; } } $entity = $this->hintSerializer->deserialize($hintData, $existingHint, $options); if (empty($existingHint)) { // Creation of a new hint (we need to link it to the question) $question->addHint($entity); } } // Remaining hints are no longer in the Exercise if (0 < count($hintEntities)) { foreach ($hintEntities as $hintToRemove) { $question->removeHint($hintToRemove); } } }
[ "private", "function", "deserializeHints", "(", "Item", "$", "question", ",", "array", "$", "hints", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "hintEntities", "=", "$", "question", "->", "getHints", "(", ")", "->", "t...
Deserializes Item hints. Forwards the hint deserialization to HintSerializer. @param Item $question @param array $hints @param array $options
[ "Deserializes", "Item", "hints", ".", "Forwards", "the", "hint", "deserialization", "to", "HintSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L376-L407
40,121
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeObjects
private function serializeObjects(Item $question, array $options = []) { return array_values(array_map(function (ItemObject $object) use ($options) { return $this->itemObjectSerializer->serialize($object, $options); }, $question->getObjects()->toArray())); }
php
private function serializeObjects(Item $question, array $options = []) { return array_values(array_map(function (ItemObject $object) use ($options) { return $this->itemObjectSerializer->serialize($object, $options); }, $question->getObjects()->toArray())); }
[ "private", "function", "serializeObjects", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_values", "(", "array_map", "(", "function", "(", "ItemObject", "$", "object", ")", "use", "(", "$", "options", ...
Serializes Item objects. Forwards the object serialization to ItemObjectSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "objects", ".", "Forwards", "the", "object", "serialization", "to", "ItemObjectSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L418-L423
40,122
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeObjects
private function deserializeObjects(Item $question, array $objects = [], array $options = []) { $objectEntities = $question->getObjects()->toArray(); $question->emptyObjects(); foreach ($objects as $index => $objectData) { $existingObject = null; // Searches for an existing object entity. foreach ($objectEntities as $entityIndex => $entityObject) { /** @var ItemObject $entityObject */ if ($entityObject->getUuid() === $objectData['id']) { $existingObject = $entityObject; unset($objectEntities[$entityIndex]); break; } } $itemObject = $this->itemObjectSerializer->deserialize($objectData, $existingObject, $options); $itemObject->setOrder($index); $question->addObject($itemObject); } // Remaining objects are no longer in the Item if (0 < count($objectEntities)) { foreach ($objectEntities as $objectToRemove) { $this->om->remove($objectToRemove); } } }
php
private function deserializeObjects(Item $question, array $objects = [], array $options = []) { $objectEntities = $question->getObjects()->toArray(); $question->emptyObjects(); foreach ($objects as $index => $objectData) { $existingObject = null; // Searches for an existing object entity. foreach ($objectEntities as $entityIndex => $entityObject) { /** @var ItemObject $entityObject */ if ($entityObject->getUuid() === $objectData['id']) { $existingObject = $entityObject; unset($objectEntities[$entityIndex]); break; } } $itemObject = $this->itemObjectSerializer->deserialize($objectData, $existingObject, $options); $itemObject->setOrder($index); $question->addObject($itemObject); } // Remaining objects are no longer in the Item if (0 < count($objectEntities)) { foreach ($objectEntities as $objectToRemove) { $this->om->remove($objectToRemove); } } }
[ "private", "function", "deserializeObjects", "(", "Item", "$", "question", ",", "array", "$", "objects", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "objectEntities", "=", "$", "question", "->", "getObjects", "(", ")", "-...
Deserializes Item objects. @param Item $question @param array $objects @param array $options
[ "Deserializes", "Item", "objects", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L432-L460
40,123
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.serializeResources
private function serializeResources(Item $question, array $options = []) { return array_map(function (ItemResource $resource) use ($options) { return $this->resourceContentSerializer->serialize($resource->getResourceNode(), $options); }, $question->getResources()->toArray()); }
php
private function serializeResources(Item $question, array $options = []) { return array_map(function (ItemResource $resource) use ($options) { return $this->resourceContentSerializer->serialize($resource->getResourceNode(), $options); }, $question->getResources()->toArray()); }
[ "private", "function", "serializeResources", "(", "Item", "$", "question", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "array_map", "(", "function", "(", "ItemResource", "$", "resource", ")", "use", "(", "$", "options", ")", "{", "re...
Serializes Item resources. Forwards the resource serialization to ResourceContentSerializer. @param Item $question @param array $options @return array
[ "Serializes", "Item", "resources", ".", "Forwards", "the", "resource", "serialization", "to", "ResourceContentSerializer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L471-L476
40,124
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.deserializeResources
private function deserializeResources(Item $question, array $resources = [], array $options = []) { $resourceEntities = $question->getResources()->toArray(); foreach ($resources as $resourceData) { $existingResource = null; // Searches for an existing resource entity. foreach ($resourceEntities as $entityIndex => $entityResource) { /** @var ItemResource $entityResource */ if ((string) $entityResource->getId() === $resourceData['id']) { $existingResource = $entityResource; unset($resourceEntities[$entityIndex]); break; } } // Link resource to item if (empty($existingResource)) { $obj = $this->resourceContentSerializer->deserialize($resourceData, $existingResource, $options); if ($obj) { if ($obj instanceof ResourceNode) { $itemResource = new ItemResource(); $itemResource->setResourceNode($obj); $itemResource->setQuestion($question); $obj = $itemResource; } $question->addResource($obj); } } } // Remaining resources are no longer in the Item if (0 < count($resourceEntities)) { foreach ($resourceEntities as $resourceToRemove) { $question->removeResource($resourceToRemove); } } }
php
private function deserializeResources(Item $question, array $resources = [], array $options = []) { $resourceEntities = $question->getResources()->toArray(); foreach ($resources as $resourceData) { $existingResource = null; // Searches for an existing resource entity. foreach ($resourceEntities as $entityIndex => $entityResource) { /** @var ItemResource $entityResource */ if ((string) $entityResource->getId() === $resourceData['id']) { $existingResource = $entityResource; unset($resourceEntities[$entityIndex]); break; } } // Link resource to item if (empty($existingResource)) { $obj = $this->resourceContentSerializer->deserialize($resourceData, $existingResource, $options); if ($obj) { if ($obj instanceof ResourceNode) { $itemResource = new ItemResource(); $itemResource->setResourceNode($obj); $itemResource->setQuestion($question); $obj = $itemResource; } $question->addResource($obj); } } } // Remaining resources are no longer in the Item if (0 < count($resourceEntities)) { foreach ($resourceEntities as $resourceToRemove) { $question->removeResource($resourceToRemove); } } }
[ "private", "function", "deserializeResources", "(", "Item", "$", "question", ",", "array", "$", "resources", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "resourceEntities", "=", "$", "question", "->", "getResources", "(", "...
Deserializes Item resources. @param Item $question @param array $resources @param array $options
[ "Deserializes", "Item", "resources", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L485-L523
40,125
claroline/Distribution
plugin/exo/Serializer/Item/ItemSerializer.php
ItemSerializer.sanitizeScore
private function sanitizeScore($score) { $sanitized = ['type' => $score['type']]; switch ($score['type']) { case 'fixed': $sanitized['success'] = $score['success']; $sanitized['failure'] = $score['failure']; break; case 'manual': $sanitized['max'] = $score['max']; break; case 'rules': $sanitized['noWrongChoice'] = isset($score['noWrongChoice']) ? $score['noWrongChoice'] : false; $sanitized['rules'] = $score['rules']; break; } return $sanitized; }
php
private function sanitizeScore($score) { $sanitized = ['type' => $score['type']]; switch ($score['type']) { case 'fixed': $sanitized['success'] = $score['success']; $sanitized['failure'] = $score['failure']; break; case 'manual': $sanitized['max'] = $score['max']; break; case 'rules': $sanitized['noWrongChoice'] = isset($score['noWrongChoice']) ? $score['noWrongChoice'] : false; $sanitized['rules'] = $score['rules']; break; } return $sanitized; }
[ "private", "function", "sanitizeScore", "(", "$", "score", ")", "{", "$", "sanitized", "=", "[", "'type'", "=>", "$", "score", "[", "'type'", "]", "]", ";", "switch", "(", "$", "score", "[", "'type'", "]", ")", "{", "case", "'fixed'", ":", "$", "sa...
The client may send dirty data, we need to clean them before storing it in DB. @param $score @return array
[ "The", "client", "may", "send", "dirty", "data", "we", "need", "to", "clean", "them", "before", "storing", "it", "in", "DB", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemSerializer.php#L532-L553
40,126
claroline/Distribution
main/core/Listener/Tool/HomeListener.php
HomeListener.onDisplayDesktop
public function onDisplayDesktop(DisplayToolEvent $event) { $currentUser = $this->tokenStorage->getToken()->getUser(); $allTabs = $this->finder->search(HomeTab::class, [ 'filters' => ['user' => $currentUser->getUuid()], ]); // Order tabs. We want : // - Administration tabs to be at first // - Tabs to be ordered by position // For this, we separate administration tabs and user ones, order them by position // and then concat all tabs with admin in first (I don't have a easier solution to achieve this) $adminTabs = []; $userTabs = []; foreach ($allTabs['data'] as $tab) { if (!empty($tab)) { // we use the define position for array keys for easier sort if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) { $adminTabs[$tab['position']] = $tab; } else { $userTabs[$tab['position']] = $tab; } } } // order tabs by position ksort($adminTabs); ksort($userTabs); // generate the final list of tabs $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs)); // we rewrite tab position because an admin and a user tab may have the same position foreach ($orderedTabs as $index => &$tab) { $tab['position'] = $index; } $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'editable' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, ], 'tabs' => $orderedTabs, ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayDesktop(DisplayToolEvent $event) { $currentUser = $this->tokenStorage->getToken()->getUser(); $allTabs = $this->finder->search(HomeTab::class, [ 'filters' => ['user' => $currentUser->getUuid()], ]); // Order tabs. We want : // - Administration tabs to be at first // - Tabs to be ordered by position // For this, we separate administration tabs and user ones, order them by position // and then concat all tabs with admin in first (I don't have a easier solution to achieve this) $adminTabs = []; $userTabs = []; foreach ($allTabs['data'] as $tab) { if (!empty($tab)) { // we use the define position for array keys for easier sort if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) { $adminTabs[$tab['position']] = $tab; } else { $userTabs[$tab['position']] = $tab; } } } // order tabs by position ksort($adminTabs); ksort($userTabs); // generate the final list of tabs $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs)); // we rewrite tab position because an admin and a user tab may have the same position foreach ($orderedTabs as $index => &$tab) { $tab['position'] = $index; } $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'editable' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, ], 'tabs' => $orderedTabs, ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayDesktop", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "currentUser", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "$", "allTabs", "=", "$", "this", "->", "fi...
Displays home on Desktop. @DI\Observe("open_tool_desktop_home") @param DisplayToolEvent $event
[ "Displays", "home", "on", "Desktop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/HomeListener.php#L81-L132
40,127
claroline/Distribution
main/core/Listener/Tool/HomeListener.php
HomeListener.onDisplayWorkspace
public function onDisplayWorkspace(DisplayToolEvent $event) { $orderedTabs = []; $workspace = $event->getWorkspace(); $tabs = $this->finder->search(HomeTab::class, [ 'filters' => ['workspace' => $workspace->getUuid()], ]); // but why ? finder should never give you an empty row $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'workspace' => $workspace, 'editable' => $this->authorization->isGranted(['home', 'edit'], $workspace), 'context' => [ 'type' => Widget::CONTEXT_WORKSPACE, 'data' => $this->serializer->serialize($workspace), ], 'tabs' => array_values($orderedTabs), ] ); $event->setContent($content); $event->stopPropagation(); }
php
public function onDisplayWorkspace(DisplayToolEvent $event) { $orderedTabs = []; $workspace = $event->getWorkspace(); $tabs = $this->finder->search(HomeTab::class, [ 'filters' => ['workspace' => $workspace->getUuid()], ]); // but why ? finder should never give you an empty row $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $content = $this->templating->render( 'ClarolineCoreBundle:tool:home.html.twig', [ 'workspace' => $workspace, 'editable' => $this->authorization->isGranted(['home', 'edit'], $workspace), 'context' => [ 'type' => Widget::CONTEXT_WORKSPACE, 'data' => $this->serializer->serialize($workspace), ], 'tabs' => array_values($orderedTabs), ] ); $event->setContent($content); $event->stopPropagation(); }
[ "public", "function", "onDisplayWorkspace", "(", "DisplayToolEvent", "$", "event", ")", "{", "$", "orderedTabs", "=", "[", "]", ";", "$", "workspace", "=", "$", "event", "->", "getWorkspace", "(", ")", ";", "$", "tabs", "=", "$", "this", "->", "finder", ...
Displays home on Workspace. @DI\Observe("open_tool_workspace_home") @param DisplayToolEvent $event
[ "Displays", "home", "on", "Workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/HomeListener.php#L141-L174
40,128
claroline/Distribution
main/core/Controller/APINew/User/OrganizationController.php
OrganizationController.addManagersAction
public function addManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_ADD, $users); return new JsonResponse($this->serializer->serialize($organization)); }
php
public function addManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_ADD, $users); return new JsonResponse($this->serializer->serialize($organization)); }
[ "public", "function", "addManagersAction", "(", "Organization", "$", "organization", ",", "Request", "$", "request", ")", "{", "$", "users", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'Claroline\\CoreBundle\\Entity\\User'", ")", ";", "...
Adds managers to the collection. @Route("/{id}/manager", name="apiv2_organization_add_managers") @Method("PATCH") @ParamConverter("organization", options={"mapping": {"id": "uuid"}}) @param Organization $organization @param Request $request @return JsonResponse
[ "Adds", "managers", "to", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/User/OrganizationController.php#L96-L102
40,129
claroline/Distribution
main/core/Controller/APINew/User/OrganizationController.php
OrganizationController.removeManagersAction
public function removeManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_REMOVE, $users); return new JsonResponse($this->serializer->serialize($organization)); }
php
public function removeManagersAction(Organization $organization, Request $request) { $users = $this->decodeIdsString($request, 'Claroline\CoreBundle\Entity\User'); $this->crud->patch($organization, 'administrator', Crud::COLLECTION_REMOVE, $users); return new JsonResponse($this->serializer->serialize($organization)); }
[ "public", "function", "removeManagersAction", "(", "Organization", "$", "organization", ",", "Request", "$", "request", ")", "{", "$", "users", "=", "$", "this", "->", "decodeIdsString", "(", "$", "request", ",", "'Claroline\\CoreBundle\\Entity\\User'", ")", ";", ...
Removes managers from the collection. @Route("/{id}/manager", name="apiv2_organization_remove_managers") @Method("DELETE") @ParamConverter("organization", options={"mapping": {"id": "uuid"}}) @param Organization $organization @param Request $request @return JsonResponse
[ "Removes", "managers", "from", "the", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/User/OrganizationController.php#L116-L122
40,130
claroline/Distribution
main/app/API/Crud.php
Crud.create
public function create($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options); if (count($errors) > 0) { return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent } } // gets entity from raw data. $object = new $class(); $object = $this->serializer->deserialize($data, $object, $options); // creates the entity if allowed $this->checkPermission('CREATE', $object, [], true); if ($this->dispatch('create', 'pre', [$object, $options])) { $this->om->save($object); if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) { $this->dispatch('create', 'post', [$object, $options]); } } return $object; }
php
public function create($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::CREATE, $options); if (count($errors) > 0) { return $errors; // todo : it should throw an Exception otherwise it makes return inconsistent } } // gets entity from raw data. $object = new $class(); $object = $this->serializer->deserialize($data, $object, $options); // creates the entity if allowed $this->checkPermission('CREATE', $object, [], true); if ($this->dispatch('create', 'pre', [$object, $options])) { $this->om->save($object); if (!in_array(Options::IGNORE_CRUD_POST_EVENT, $options)) { $this->dispatch('create', 'post', [$object, $options]); } } return $object; }
[ "public", "function", "create", "(", "$", "class", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// validates submitted data.", "if", "(", "!", "in_array", "(", "self", "::", "NO_VALIDATE", ",", "$", "options", ")", ")", "{"...
Creates a new entry for `class` and populates it with `data`. @param string $class - the class of the entity to create @param mixed $data - the serialized data of the object to create @param array $options - additional creation options @return object
[ "Creates", "a", "new", "entry", "for", "class", "and", "populates", "it", "with", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L77-L103
40,131
claroline/Distribution
main/app/API/Crud.php
Crud.update
public function update($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::UPDATE); if (count($errors) > 0) { return $errors; } } $oldObject = $this->om->getObject($data, $class) ?? new $class(); $this->checkPermission('EDIT', $oldObject, [], true); $oldData = $this->serializer->serialize($oldObject); if (!$oldData) { $oldData = []; } $object = $this->serializer->deserialize($data, $oldObject, $options); if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) { $this->om->save($object); $this->dispatch('update', 'post', [$object, $options, $oldData]); } return $object; }
php
public function update($class, $data, array $options = []) { // validates submitted data. if (!in_array(self::NO_VALIDATE, $options)) { $errors = $this->validate($class, $data, ValidatorProvider::UPDATE); if (count($errors) > 0) { return $errors; } } $oldObject = $this->om->getObject($data, $class) ?? new $class(); $this->checkPermission('EDIT', $oldObject, [], true); $oldData = $this->serializer->serialize($oldObject); if (!$oldData) { $oldData = []; } $object = $this->serializer->deserialize($data, $oldObject, $options); if ($this->dispatch('update', 'pre', [$object, $options, $oldData])) { $this->om->save($object); $this->dispatch('update', 'post', [$object, $options, $oldData]); } return $object; }
[ "public", "function", "update", "(", "$", "class", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// validates submitted data.", "if", "(", "!", "in_array", "(", "self", "::", "NO_VALIDATE", ",", "$", "options", ")", ")", "{"...
Updates an entry of `class` with `data`. @param string $class - the class of the entity to updates @param mixed $data - the serialized data of the object to create @param array $options - additional update options @return object
[ "Updates", "an", "entry", "of", "class", "with", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L114-L141
40,132
claroline/Distribution
main/app/API/Crud.php
Crud.delete
public function delete($object, array $options = []) { $this->checkPermission('DELETE', $object, [], true); if ($this->dispatch('delete', 'pre', [$object, $options])) { if (!in_array(Options::SOFT_DELETE, $options)) { $this->om->remove($object); $this->om->flush(); } $this->dispatch('delete', 'post', [$object, $options]); } }
php
public function delete($object, array $options = []) { $this->checkPermission('DELETE', $object, [], true); if ($this->dispatch('delete', 'pre', [$object, $options])) { if (!in_array(Options::SOFT_DELETE, $options)) { $this->om->remove($object); $this->om->flush(); } $this->dispatch('delete', 'post', [$object, $options]); } }
[ "public", "function", "delete", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "checkPermission", "(", "'DELETE'", ",", "$", "object", ",", "[", "]", ",", "true", ")", ";", "if", "(", "$", "this", "-...
Deletes an entry `object`. @param object $object - the entity to delete @param array $options - additional delete options
[ "Deletes", "an", "entry", "object", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L149-L160
40,133
claroline/Distribution
main/app/API/Crud.php
Crud.deleteBulk
public function deleteBulk(array $data, array $options = []) { $this->om->startFlushSuite(); foreach ($data as $el) { //get the element $this->delete($el, $options); } $this->om->endFlushSuite(); }
php
public function deleteBulk(array $data, array $options = []) { $this->om->startFlushSuite(); foreach ($data as $el) { //get the element $this->delete($el, $options); } $this->om->endFlushSuite(); }
[ "public", "function", "deleteBulk", "(", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "el", ")", "{", "//get th...
Deletes a list of entries of `class`. @param array $data - the list of entries to delete @param array $options - additional delete options
[ "Deletes", "a", "list", "of", "entries", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L168-L178
40,134
claroline/Distribution
main/app/API/Crud.php
Crud.copy
public function copy($object, array $options = []) { $this->checkPermission('COPY', $object, [], true); $class = get_class($object); $new = new $class(); $this->serializer->deserialize( $this->serializer->serialize($object), $new ); $this->om->persist($new); //first event is the pre one if ($this->dispatch('copy', 'pre', [$object, $options, $new])) { //second event is the post one //we could use only one event afaik $this->dispatch('copy', 'post', [$object, $options, $new]); } $this->om->flush(); return $new; }
php
public function copy($object, array $options = []) { $this->checkPermission('COPY', $object, [], true); $class = get_class($object); $new = new $class(); $this->serializer->deserialize( $this->serializer->serialize($object), $new ); $this->om->persist($new); //first event is the pre one if ($this->dispatch('copy', 'pre', [$object, $options, $new])) { //second event is the post one //we could use only one event afaik $this->dispatch('copy', 'post', [$object, $options, $new]); } $this->om->flush(); return $new; }
[ "public", "function", "copy", "(", "$", "object", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "checkPermission", "(", "'COPY'", ",", "$", "object", ",", "[", "]", ",", "true", ")", ";", "$", "class", "=", "get_class", ...
Copy an entry `object` of `class`. @param object $object - the entity to copy @param array $options - additional copy options
[ "Copy", "an", "entry", "object", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L186-L209
40,135
claroline/Distribution
main/app/API/Crud.php
Crud.copyBulk
public function copyBulk($class, array $data, array $options = []) { $this->om->startFlushSuite(); $copies = []; foreach ($data as $el) { //get the element $copies[] = $this->copy($el, $options); } $this->om->endFlushSuite(); return $copies; }
php
public function copyBulk($class, array $data, array $options = []) { $this->om->startFlushSuite(); $copies = []; foreach ($data as $el) { //get the element $copies[] = $this->copy($el, $options); } $this->om->endFlushSuite(); return $copies; }
[ "public", "function", "copyBulk", "(", "$", "class", ",", "array", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "copies", "=", "[", "]", ";", "foreach", ...
Copy a list of entries of `class`. @param string $class - the class of the entries to copy @param array $data - the list of entries to copy @param array $options - additional copy options
[ "Copy", "a", "list", "of", "entries", "of", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L218-L231
40,136
claroline/Distribution
main/app/API/Crud.php
Crud.replace
public function replace($object, $property, $data, array $options = []) { $methodName = 'set'.ucfirst($property); if (!method_exists($object, $methodName)) { throw new \LogicException( sprintf('You have requested a non implemented action \'set\' on %s (looked for %s)', get_class($object), $methodName) ); } //add the options to pass on here $this->checkPermission('PATCH', $object, [], true); //we'll need to pass the $action and $data here aswell later if ($this->dispatch('patch', 'pre', [$object, $options, $property, $data, self::PROPERTY_SET])) { $object->$methodName($data); $this->om->save($object); $this->dispatch('patch', 'post', [$object, $options, $property, $data, self::PROPERTY_SET]); } }
php
public function replace($object, $property, $data, array $options = []) { $methodName = 'set'.ucfirst($property); if (!method_exists($object, $methodName)) { throw new \LogicException( sprintf('You have requested a non implemented action \'set\' on %s (looked for %s)', get_class($object), $methodName) ); } //add the options to pass on here $this->checkPermission('PATCH', $object, [], true); //we'll need to pass the $action and $data here aswell later if ($this->dispatch('patch', 'pre', [$object, $options, $property, $data, self::PROPERTY_SET])) { $object->$methodName($data); $this->om->save($object); $this->dispatch('patch', 'post', [$object, $options, $property, $data, self::PROPERTY_SET]); } }
[ "public", "function", "replace", "(", "$", "object", ",", "$", "property", ",", "$", "data", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "methodName", "=", "'set'", ".", "ucfirst", "(", "$", "property", ")", ";", "if", "(", "!", "...
Patches a property in `object`. @param object $object - the entity to update @param string $property - the property to update @param mixed $data - the data that must be set @param array $options - an array of options
[ "Patches", "a", "property", "in", "object", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L274-L293
40,137
claroline/Distribution
main/app/API/Crud.php
Crud.validate
public function validate($class, $data, $mode, array $options = []) { return $this->validator->validate($class, $data, $mode, true, $options); }
php
public function validate($class, $data, $mode, array $options = []) { return $this->validator->validate($class, $data, $mode, true, $options); }
[ "public", "function", "validate", "(", "$", "class", ",", "$", "data", ",", "$", "mode", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "validator", "->", "validate", "(", "$", "class", ",", "$", "data", ",", ...
Validates `data` with the available validator for `class`. @param string $class - the class of the entity used for validation @param mixed $data - the serialized data to validate @param string $mode - the validation mode
[ "Validates", "data", "with", "the", "available", "validator", "for", "class", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Crud.php#L302-L305
40,138
claroline/Distribution
main/core/Controller/APINew/DataSourceController.php
DataSourceController.listAction
public function listAction($context = null) { $widgets = $this->manager->getAvailable($context); return new JsonResponse(array_map(function (DataSource $dataSource) { return $this->serializer->serialize($dataSource); }, $widgets)); }
php
public function listAction($context = null) { $widgets = $this->manager->getAvailable($context); return new JsonResponse(array_map(function (DataSource $dataSource) { return $this->serializer->serialize($dataSource); }, $widgets)); }
[ "public", "function", "listAction", "(", "$", "context", "=", "null", ")", "{", "$", "widgets", "=", "$", "this", "->", "manager", "->", "getAvailable", "(", "$", "context", ")", ";", "return", "new", "JsonResponse", "(", "array_map", "(", "function", "(...
Lists available data sources for a given context. @EXT\Route("/{context}", name="apiv2_data_source_list", defaults={"context"=null}) @EXT\Method("GET") @param string $context @return JsonResponse
[ "Lists", "available", "data", "sources", "for", "a", "given", "context", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/DataSourceController.php#L63-L70
40,139
claroline/Distribution
main/core/Controller/APINew/DataSourceController.php
DataSourceController.loadAction
public function loadAction(Request $request, $type, $context, $contextId = null) { if (!$this->manager->check($type, $context)) { return new JsonResponse('Unknown data source.', 404); } return new JsonResponse( $this->manager->load($type, $context, $contextId, $request->query->all()) ); }
php
public function loadAction(Request $request, $type, $context, $contextId = null) { if (!$this->manager->check($type, $context)) { return new JsonResponse('Unknown data source.', 404); } return new JsonResponse( $this->manager->load($type, $context, $contextId, $request->query->all()) ); }
[ "public", "function", "loadAction", "(", "Request", "$", "request", ",", "$", "type", ",", "$", "context", ",", "$", "contextId", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "manager", "->", "check", "(", "$", "type", ",", "$", "conte...
Gets data from a data source. @EXT\Route("/{type}/{context}/{contextId}", name="apiv2_data_source", defaults={"contextId"=null}) @EXT\Method("GET") @param Request $request @param string $type @param string $context @param string $contextId @return JsonResponse
[ "Gets", "data", "from", "a", "data", "source", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/DataSourceController.php#L85-L94
40,140
claroline/Distribution
main/core/Entity/Facet/FieldFacet.php
FieldFacet.getRootFieldFacetChoices
public function getRootFieldFacetChoices() { $roots = []; if (!empty($this->fieldFacetChoices)) { foreach ($this->fieldFacetChoices as $choice) { if (empty($choice->getParent())) { $roots[] = $choice; } } } return $roots; }
php
public function getRootFieldFacetChoices() { $roots = []; if (!empty($this->fieldFacetChoices)) { foreach ($this->fieldFacetChoices as $choice) { if (empty($choice->getParent())) { $roots[] = $choice; } } } return $roots; }
[ "public", "function", "getRootFieldFacetChoices", "(", ")", "{", "$", "roots", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "fieldFacetChoices", ")", ")", "{", "foreach", "(", "$", "this", "->", "fieldFacetChoices", "as", "$", "...
Get root choices. @return FieldFacetChoice[]
[ "Get", "root", "choices", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Facet/FieldFacet.php#L352-L365
40,141
claroline/Distribution
plugin/exo/Listener/Resource/ExerciseListener.php
ExerciseListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $currentUser = $this->tokenStorage->getToken()->getUser(); $canEdit = $this->authorization->isGranted('EDIT', new ResourceCollection([$exercise->getResourceNode()])); $options = []; if ($canEdit || $exercise->hasStatistics()) { $options[] = Transfer::INCLUDE_SOLUTIONS; } // fetch additional user data $nbUserPapers = 0; $nbUserPapersDayCount = 0; $userEvaluation = null; if ($currentUser instanceof User) { $nbUserPapers = (int) $this->paperManager->countUserFinishedPapers($exercise, $currentUser); $nbUserPapersDayCount = (int) $this->paperManager->countUserFinishedDayPapers($exercise, $currentUser); $userEvaluation = $this->serializer->serialize( $this->resourceEvalManager->getResourceUserEvaluation($exercise->getResourceNode(), $currentUser) ); } $event->setData([ 'quiz' => $this->serializer->serialize($exercise, $options), 'paperCount' => (int) $this->paperManager->countExercisePapers($exercise), // user data 'userPaperCount' => $nbUserPapers, 'userPaperDayCount' => $nbUserPapersDayCount, 'userEvaluation' => $userEvaluation, ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $currentUser = $this->tokenStorage->getToken()->getUser(); $canEdit = $this->authorization->isGranted('EDIT', new ResourceCollection([$exercise->getResourceNode()])); $options = []; if ($canEdit || $exercise->hasStatistics()) { $options[] = Transfer::INCLUDE_SOLUTIONS; } // fetch additional user data $nbUserPapers = 0; $nbUserPapersDayCount = 0; $userEvaluation = null; if ($currentUser instanceof User) { $nbUserPapers = (int) $this->paperManager->countUserFinishedPapers($exercise, $currentUser); $nbUserPapersDayCount = (int) $this->paperManager->countUserFinishedDayPapers($exercise, $currentUser); $userEvaluation = $this->serializer->serialize( $this->resourceEvalManager->getResourceUserEvaluation($exercise->getResourceNode(), $currentUser) ); } $event->setData([ 'quiz' => $this->serializer->serialize($exercise, $options), 'paperCount' => (int) $this->paperManager->countExercisePapers($exercise), // user data 'userPaperCount' => $nbUserPapers, 'userPaperDayCount' => $nbUserPapersDayCount, 'userEvaluation' => $userEvaluation, ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Exercise $exercise */", "$", "exercise", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "currentUser", "=", "$", "this", "->", "tokenStorage", "->", "getTo...
Loads the Exercise resource. @DI\Observe("resource.ujm_exercise.load") @param LoadResourceEvent $event
[ "Loads", "the", "Exercise", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Listener/Resource/ExerciseListener.php#L112-L147
40,142
claroline/Distribution
plugin/exo/Listener/Resource/ExerciseListener.php
ExerciseListener.onDelete
public function onDelete(DeleteResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $deletable = $this->exerciseManager->isDeletable($exercise); if (!$deletable) { // If papers, the Exercise is not completely removed $event->enableSoftDelete(); } $event->stopPropagation(); }
php
public function onDelete(DeleteResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $deletable = $this->exerciseManager->isDeletable($exercise); if (!$deletable) { // If papers, the Exercise is not completely removed $event->enableSoftDelete(); } $event->stopPropagation(); }
[ "public", "function", "onDelete", "(", "DeleteResourceEvent", "$", "event", ")", "{", "/** @var Exercise $exercise */", "$", "exercise", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "deletable", "=", "$", "this", "->", "exerciseManager", "->", "...
Deletes an Exercise resource. @DI\Observe("delete_ujm_exercise") @param DeleteResourceEvent $event
[ "Deletes", "an", "Exercise", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Listener/Resource/ExerciseListener.php#L156-L168
40,143
claroline/Distribution
main/core/Listener/Administration/LogsListener.php
LogsListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:logs.html.twig', [ 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_ADMIN), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:logs.html.twig', [ 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_ADMIN), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:administration:logs.html.twig'", ",", "[", "'actions'", "=>", "$", "th...
Displays logs administration tool. @DI\Observe("administration_tool_platform_logs") @param OpenAdministrationToolEvent $event
[ "Displays", "logs", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/LogsListener.php#L49-L59
40,144
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.selectAsEntity
public function selectAsEntity($joinSingleRelatives = false, $class = null) { $this->init(); $eol = PHP_EOL; if ($class) { $this->selectClause = 'SELECT resource'.PHP_EOL; $this->fromClause = "FROM {$class} resource{$eol} JOIN resource.resourceNode node{$eol}"; } else { $this->selectClause = 'SELECT node'.PHP_EOL; } $this->joinSingleRelatives = $joinSingleRelatives; return $this; }
php
public function selectAsEntity($joinSingleRelatives = false, $class = null) { $this->init(); $eol = PHP_EOL; if ($class) { $this->selectClause = 'SELECT resource'.PHP_EOL; $this->fromClause = "FROM {$class} resource{$eol} JOIN resource.resourceNode node{$eol}"; } else { $this->selectClause = 'SELECT node'.PHP_EOL; } $this->joinSingleRelatives = $joinSingleRelatives; return $this; }
[ "public", "function", "selectAsEntity", "(", "$", "joinSingleRelatives", "=", "false", ",", "$", "class", "=", "null", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "eol", "=", "PHP_EOL", ";", "if", "(", "$", "class", ")", "{", "$", "thi...
Selects nodes as entities. @param bool $joinSingleRelatives Whether the creator, type and icon must be joined to the query @param string $class @return ResourceQueryBuilder
[ "Selects", "nodes", "as", "entities", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L81-L96
40,145
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.selectAsArray
public function selectAsArray($withMaxPermissions = false, $withLastOpenDate = false) { $this->init(); $this->resultAsArray = true; $this->joinSingleRelatives = true; $eol = PHP_EOL; $this->selectClause = "SELECT DISTINCT{$eol}". " node.id as id,{$eol}". " node.uuid as uuid,{$eol}". " node.name as name,{$eol}". " node.path as path,{$eol}". " IDENTITY(node.parent) as parent_id,{$eol}". " creator.username as creator_username,{$eol}". " creator.id as creator_id,{$eol}". " resourceType.name as type,{$eol}". " icon.relativeUrl as large_icon,{$eol}". " node.mimeType as mime_type,{$eol}". " node.index as index_dir,{$eol}". " node.creationDate as creation_date,{$eol}". " node.modificationDate as modification_date,{$eol}". " node.published as published,{$eol}". " node.accessibleFrom as accessible_from,{$eol}". " node.accessibleUntil as accessible_until,{$eol}". " node.deletable as deletable{$eol}"; if ($withMaxPermissions) { $this->leftJoinRights = true; $this->selectClause .= ",{$eol}rights.mask"; } if ($withLastOpenDate) { $this->leftJoinLogs = true; $this->selectClause .= ",{$eol}log.dateLog as last_opened"; } $this->selectClause .= $eol; return $this; }
php
public function selectAsArray($withMaxPermissions = false, $withLastOpenDate = false) { $this->init(); $this->resultAsArray = true; $this->joinSingleRelatives = true; $eol = PHP_EOL; $this->selectClause = "SELECT DISTINCT{$eol}". " node.id as id,{$eol}". " node.uuid as uuid,{$eol}". " node.name as name,{$eol}". " node.path as path,{$eol}". " IDENTITY(node.parent) as parent_id,{$eol}". " creator.username as creator_username,{$eol}". " creator.id as creator_id,{$eol}". " resourceType.name as type,{$eol}". " icon.relativeUrl as large_icon,{$eol}". " node.mimeType as mime_type,{$eol}". " node.index as index_dir,{$eol}". " node.creationDate as creation_date,{$eol}". " node.modificationDate as modification_date,{$eol}". " node.published as published,{$eol}". " node.accessibleFrom as accessible_from,{$eol}". " node.accessibleUntil as accessible_until,{$eol}". " node.deletable as deletable{$eol}"; if ($withMaxPermissions) { $this->leftJoinRights = true; $this->selectClause .= ",{$eol}rights.mask"; } if ($withLastOpenDate) { $this->leftJoinLogs = true; $this->selectClause .= ",{$eol}log.dateLog as last_opened"; } $this->selectClause .= $eol; return $this; }
[ "public", "function", "selectAsArray", "(", "$", "withMaxPermissions", "=", "false", ",", "$", "withLastOpenDate", "=", "false", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "this", "->", "resultAsArray", "=", "true", ";", "$", "this", "->", ...
Selects nodes as arrays. Resource type, creator and icon are always added to the query. @param bool $withMaxPermissions Whether maximum permissions must be calculated and added to the result @param bool $withLastOpenDate @return ResourceQueryBuilder
[ "Selects", "nodes", "as", "arrays", ".", "Resource", "type", "creator", "and", "icon", "are", "always", "added", "to", "the", "query", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L106-L145
40,146
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereInWorkspace
public function whereInWorkspace(Workspace $workspace) { $this->addWhereClause('node.workspace = :workspace_id'); $this->parameters[':workspace_id'] = $workspace->getId(); return $this; }
php
public function whereInWorkspace(Workspace $workspace) { $this->addWhereClause('node.workspace = :workspace_id'); $this->parameters[':workspace_id'] = $workspace->getId(); return $this; }
[ "public", "function", "whereInWorkspace", "(", "Workspace", "$", "workspace", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.workspace = :workspace_id'", ")", ";", "$", "this", "->", "parameters", "[", "':workspace_id'", "]", "=", "$", "workspace", "...
Filters nodes belonging to a given workspace. @param Workspace $workspace @return ResourceQueryBuilder
[ "Filters", "nodes", "belonging", "to", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L154-L160
40,147
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereParentIs
public function whereParentIs(ResourceNode $parent) { $this->addWhereClause('node.parent = :ar_parentId'); $this->parameters[':ar_parentId'] = $parent->getId(); return $this; }
php
public function whereParentIs(ResourceNode $parent) { $this->addWhereClause('node.parent = :ar_parentId'); $this->parameters[':ar_parentId'] = $parent->getId(); return $this; }
[ "public", "function", "whereParentIs", "(", "ResourceNode", "$", "parent", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.parent = :ar_parentId'", ")", ";", "$", "this", "->", "parameters", "[", "':ar_parentId'", "]", "=", "$", "parent", "->", "get...
Filters nodes that are the immediate children of a given node. @param ResourceNode $parent @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "are", "the", "immediate", "children", "of", "a", "given", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L178-L184
40,148
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.wherePathLike
public function wherePathLike($path, $includeGivenPath = true) { $this->addWhereClause('node.path LIKE :pathlike'); $this->parameters[':pathlike'] = $path.'%'; if (!$includeGivenPath) { $this->addWhereClause('node.path <> :path'); $this->parameters[':path'] = $path; } return $this; }
php
public function wherePathLike($path, $includeGivenPath = true) { $this->addWhereClause('node.path LIKE :pathlike'); $this->parameters[':pathlike'] = $path.'%'; if (!$includeGivenPath) { $this->addWhereClause('node.path <> :path'); $this->parameters[':path'] = $path; } return $this; }
[ "public", "function", "wherePathLike", "(", "$", "path", ",", "$", "includeGivenPath", "=", "true", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.path LIKE :pathlike'", ")", ";", "$", "this", "->", "parameters", "[", "':pathlike'", "]", "=", "$"...
Filters nodes whose path begins with a given path. @param string $path @param bool $includeGivenPath @return ResourceQueryBuilder
[ "Filters", "nodes", "whose", "path", "begins", "with", "a", "given", "path", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L194-L205
40,149
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereIsExportable
public function whereIsExportable($isExportable) { $this->joinSingleRelatives = true; $this->addWhereClause('resourceType.isExportable = :isExportable'); $this->parameters[':isExportable'] = $isExportable; return $this; }
php
public function whereIsExportable($isExportable) { $this->joinSingleRelatives = true; $this->addWhereClause('resourceType.isExportable = :isExportable'); $this->parameters[':isExportable'] = $isExportable; return $this; }
[ "public", "function", "whereIsExportable", "(", "$", "isExportable", ")", "{", "$", "this", "->", "joinSingleRelatives", "=", "true", ";", "$", "this", "->", "addWhereClause", "(", "'resourceType.isExportable = :isExportable'", ")", ";", "$", "this", "->", "parame...
Filters nodes that can or cannot be exported. @param bool $isExportable @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "can", "or", "cannot", "be", "exported", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L375-L382
40,150
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.getDql
public function getDql() { if (null === $this->selectClause) { throw new MissingSelectClauseException('Select clause is missing'); } $eol = PHP_EOL; $joinRelatives = $this->joinSingleRelatives ? $this->joinRelativesClause : ''; if ($this->leftJoinPlugins) { $joinRelatives .= " LEFT JOIN node.resourceType rtp{$eol} LEFT JOIN rtp.plugin p{$eol}"; } $joinRoles = $this->leftJoinRoles ? "LEFT JOIN node.workspace workspace{$eol}". "LEFT JOIN workspace.roles role{$eol}" : ''; $joinRights = $this->leftJoinRights ? "LEFT JOIN node.rights rights{$eol}". "JOIN rights.role rightRole{$eol}" : ''; $joinLogs = $this->leftJoinLogs ? "JOIN node.logs log{$eol}". "JOIN log.resourceNode log_node{$eol}" : ''; $dql = $this->selectClause. $this->fromClause. $joinRelatives. $joinRoles. $joinRights. $joinLogs. $this->joinClause. $this->whereClause. $this->groupByClause. $this->orderClause; return $dql; }
php
public function getDql() { if (null === $this->selectClause) { throw new MissingSelectClauseException('Select clause is missing'); } $eol = PHP_EOL; $joinRelatives = $this->joinSingleRelatives ? $this->joinRelativesClause : ''; if ($this->leftJoinPlugins) { $joinRelatives .= " LEFT JOIN node.resourceType rtp{$eol} LEFT JOIN rtp.plugin p{$eol}"; } $joinRoles = $this->leftJoinRoles ? "LEFT JOIN node.workspace workspace{$eol}". "LEFT JOIN workspace.roles role{$eol}" : ''; $joinRights = $this->leftJoinRights ? "LEFT JOIN node.rights rights{$eol}". "JOIN rights.role rightRole{$eol}" : ''; $joinLogs = $this->leftJoinLogs ? "JOIN node.logs log{$eol}". "JOIN log.resourceNode log_node{$eol}" : ''; $dql = $this->selectClause. $this->fromClause. $joinRelatives. $joinRoles. $joinRights. $joinLogs. $this->joinClause. $this->whereClause. $this->groupByClause. $this->orderClause; return $dql; }
[ "public", "function", "getDql", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "selectClause", ")", "{", "throw", "new", "MissingSelectClauseException", "(", "'Select clause is missing'", ")", ";", "}", "$", "eol", "=", "PHP_EOL", ";", "$", "j...
Returns the dql query string. @return string @throws MissingSelectClauseException if no select method was previously called
[ "Returns", "the", "dql", "query", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L499-L536
40,151
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.addWhereClause
public function addWhereClause($clause) { if (null === $this->whereClause) { $this->whereClause = "WHERE {$clause}".PHP_EOL; } else { $this->whereClause = $this->whereClause."AND {$clause}".PHP_EOL; } }
php
public function addWhereClause($clause) { if (null === $this->whereClause) { $this->whereClause = "WHERE {$clause}".PHP_EOL; } else { $this->whereClause = $this->whereClause."AND {$clause}".PHP_EOL; } }
[ "public", "function", "addWhereClause", "(", "$", "clause", ")", "{", "if", "(", "null", "===", "$", "this", "->", "whereClause", ")", "{", "$", "this", "->", "whereClause", "=", "\"WHERE {$clause}\"", ".", "PHP_EOL", ";", "}", "else", "{", "$", "this", ...
Adds a statement to the query "WHERE" clause. @param string $clause
[ "Adds", "a", "statement", "to", "the", "query", "WHERE", "clause", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L553-L560
40,152
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.create
public function create(array $data) { if ($this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured')) { return $this->update($data, new ScheduledTask()); } return null; }
php
public function create(array $data) { if ($this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured')) { return $this->update($data, new ScheduledTask()); } return null; }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "$", "this", "->", "configHandler", "->", "hasParameter", "(", "'is_cron_configured'", ")", "&&", "$", "this", "->", "configHandler", "->", "getParameter", "(", "'is_cron_configure...
Creates a new ScheduledTask. @param array $data @return ScheduledTask
[ "Creates", "a", "new", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L82-L90
40,153
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.update
public function update(array $data, ScheduledTask $scheduledTask) { $errors = $this->validate($data); if (count($errors) > 0) { throw new InvalidDataException('Scheduled task is not valid', $errors); } $scheduledTask = $this->om->getObject($data, ScheduledTask::class); $this->serializer->deserialize($data, $scheduledTask); $this->om->persist($scheduledTask); $this->om->flush(); return $scheduledTask; }
php
public function update(array $data, ScheduledTask $scheduledTask) { $errors = $this->validate($data); if (count($errors) > 0) { throw new InvalidDataException('Scheduled task is not valid', $errors); } $scheduledTask = $this->om->getObject($data, ScheduledTask::class); $this->serializer->deserialize($data, $scheduledTask); $this->om->persist($scheduledTask); $this->om->flush(); return $scheduledTask; }
[ "public", "function", "update", "(", "array", "$", "data", ",", "ScheduledTask", "$", "scheduledTask", ")", "{", "$", "errors", "=", "$", "this", "->", "validate", "(", "$", "data", ")", ";", "if", "(", "count", "(", "$", "errors", ")", ">", "0", "...
Updates a ScheduledTask. @param array $data @param ScheduledTask $scheduledTask @return ScheduledTask @throws InvalidDataException
[ "Updates", "a", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L102-L116
40,154
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.delete
public function delete(ScheduledTask $scheduledTask) { $this->om->remove($scheduledTask); $this->om->flush(); }
php
public function delete(ScheduledTask $scheduledTask) { $this->om->remove($scheduledTask); $this->om->flush(); }
[ "public", "function", "delete", "(", "ScheduledTask", "$", "scheduledTask", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "scheduledTask", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a ScheduledTask. @param ScheduledTask $scheduledTask
[ "Deletes", "a", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L147-L151
40,155
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.deleteBulk
public function deleteBulk(array $scheduledTasks) { $this->om->startFlushSuite(); foreach ($scheduledTasks as $scheduledTask) { $this->delete($scheduledTask); } $this->om->endFlushSuite(); }
php
public function deleteBulk(array $scheduledTasks) { $this->om->startFlushSuite(); foreach ($scheduledTasks as $scheduledTask) { $this->delete($scheduledTask); } $this->om->endFlushSuite(); }
[ "public", "function", "deleteBulk", "(", "array", "$", "scheduledTasks", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "scheduledTasks", "as", "$", "scheduledTask", ")", "{", "$", "this", "->", "delete", ...
Deletes a list of ScheduledTasks. @param ScheduledTask[] $scheduledTasks
[ "Deletes", "a", "list", "of", "ScheduledTasks", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L158-L165
40,156
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.markAsExecuted
public function markAsExecuted(ScheduledTask $task, \DateTime $executionDate = null) { if (empty($executionDate)) { $executionDate = new \DateTime(); } $task->setExecutionDate($executionDate); $this->om->persist($task); $this->om->flush(); }
php
public function markAsExecuted(ScheduledTask $task, \DateTime $executionDate = null) { if (empty($executionDate)) { $executionDate = new \DateTime(); } $task->setExecutionDate($executionDate); $this->om->persist($task); $this->om->flush(); }
[ "public", "function", "markAsExecuted", "(", "ScheduledTask", "$", "task", ",", "\\", "DateTime", "$", "executionDate", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "executionDate", ")", ")", "{", "$", "executionDate", "=", "new", "\\", "DateTime",...
Flags a ScheduledTask as executed. @param ScheduledTask $task @param \DateTime $executionDate
[ "Flags", "a", "ScheduledTask", "as", "executed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L173-L183
40,157
claroline/Distribution
plugin/claco-form/Listener/Resource/ClacoFormListener.php
ClacoFormListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var ClacoForm $clacoForm */ $clacoForm = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isAnon = 'anon.' === $user; $myEntries = $isAnon ? [] : $this->clacoFormManager->getUserEntries($clacoForm, $user); $canGeneratePdf = !$isAnon && $this->platformConfigHandler->hasParameter('knp_pdf_binary_path') && file_exists($this->platformConfigHandler->getParameter('knp_pdf_binary_path')); $cascadeLevelMax = $this->platformConfigHandler->hasParameter('claco_form_cascade_select_level_max') ? $this->platformConfigHandler->getParameter('claco_form_cascade_select_level_max') : 2; $roles = []; $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $roleAnonymous = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); $workspaceRoles = $this->roleManager->getWorkspaceRoles($clacoForm->getResourceNode()->getWorkspace()); $roles[] = $this->serializer->serialize($roleUser, [Options::SERIALIZE_MINIMAL]); $roles[] = $this->serializer->serialize($roleAnonymous, [Options::SERIALIZE_MINIMAL]); foreach ($workspaceRoles as $workspaceRole) { $roles[] = $this->serializer->serialize($workspaceRole, [Options::SERIALIZE_MINIMAL]); } $myRoles = $isAnon ? [$roleAnonymous->getName()] : $user->getRoles(); $event->setData([ 'clacoForm' => $this->serializer->serialize($clacoForm), 'canGeneratePdf' => $canGeneratePdf, 'cascadeLevelMax' => $cascadeLevelMax, 'myEntriesCount' => count($myEntries), 'roles' => $roles, 'myRoles' => $myRoles, ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var ClacoForm $clacoForm */ $clacoForm = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isAnon = 'anon.' === $user; $myEntries = $isAnon ? [] : $this->clacoFormManager->getUserEntries($clacoForm, $user); $canGeneratePdf = !$isAnon && $this->platformConfigHandler->hasParameter('knp_pdf_binary_path') && file_exists($this->platformConfigHandler->getParameter('knp_pdf_binary_path')); $cascadeLevelMax = $this->platformConfigHandler->hasParameter('claco_form_cascade_select_level_max') ? $this->platformConfigHandler->getParameter('claco_form_cascade_select_level_max') : 2; $roles = []; $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $roleAnonymous = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); $workspaceRoles = $this->roleManager->getWorkspaceRoles($clacoForm->getResourceNode()->getWorkspace()); $roles[] = $this->serializer->serialize($roleUser, [Options::SERIALIZE_MINIMAL]); $roles[] = $this->serializer->serialize($roleAnonymous, [Options::SERIALIZE_MINIMAL]); foreach ($workspaceRoles as $workspaceRole) { $roles[] = $this->serializer->serialize($workspaceRole, [Options::SERIALIZE_MINIMAL]); } $myRoles = $isAnon ? [$roleAnonymous->getName()] : $user->getRoles(); $event->setData([ 'clacoForm' => $this->serializer->serialize($clacoForm), 'canGeneratePdf' => $canGeneratePdf, 'cascadeLevelMax' => $cascadeLevelMax, 'myEntriesCount' => count($myEntries), 'roles' => $roles, 'myRoles' => $myRoles, ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var ClacoForm $clacoForm */", "$", "clacoForm", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken"...
Loads the ClacoForm resource. @DI\Observe("resource.claroline_claco_form.load") @param LoadResourceEvent $event
[ "Loads", "the", "ClacoForm", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Listener/Resource/ClacoFormListener.php#L91-L125
40,158
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.getUserOptions
public function getUserOptions(User $user) { $options = $this->optionsRepo->findOneBy(['user' => $user]); if (is_null($options)) { $options = new Options(); $options->setUser($user); $defaultValues = [ 'show_all_my_contacts' => true, 'show_all_visible_users' => true, 'show_username' => true, 'show_mail' => false, 'show_phone' => false, 'show_picture' => true, ]; $options->setOptions($defaultValues); $this->om->persist($options); $this->om->flush(); } return $options; }
php
public function getUserOptions(User $user) { $options = $this->optionsRepo->findOneBy(['user' => $user]); if (is_null($options)) { $options = new Options(); $options->setUser($user); $defaultValues = [ 'show_all_my_contacts' => true, 'show_all_visible_users' => true, 'show_username' => true, 'show_mail' => false, 'show_phone' => false, 'show_picture' => true, ]; $options->setOptions($defaultValues); $this->om->persist($options); $this->om->flush(); } return $options; }
[ "public", "function", "getUserOptions", "(", "User", "$", "user", ")", "{", "$", "options", "=", "$", "this", "->", "optionsRepo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", "]", ")", ";", "if", "(", "is_null", "(", "$", "options", ")"...
Fetches user options. @param User $user @return Options
[ "Fetches", "user", "options", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L56-L77
40,159
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.createContacts
public function createContacts(User $currentUser, array $users) { $this->om->startFlushSuite(); $createdContacts = []; foreach ($users as $user) { $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]); if (is_null($contact)) { $contact = new Contact(); $contact->setUser($currentUser); $contact->setContact($user); $this->om->persist($contact); $createdContacts[] = $contact; } } $this->om->endFlushSuite(); return $createdContacts; }
php
public function createContacts(User $currentUser, array $users) { $this->om->startFlushSuite(); $createdContacts = []; foreach ($users as $user) { $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]); if (is_null($contact)) { $contact = new Contact(); $contact->setUser($currentUser); $contact->setContact($user); $this->om->persist($contact); $createdContacts[] = $contact; } } $this->om->endFlushSuite(); return $createdContacts; }
[ "public", "function", "createContacts", "(", "User", "$", "currentUser", ",", "array", "$", "users", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "createdContacts", "=", "[", "]", ";", "foreach", "(", "$", "users", "a...
Creates contacts from a list of user. @param User $currentUser @param User[] $users @return Contact[]
[ "Creates", "contacts", "from", "a", "list", "of", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L87-L106
40,160
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.deleteContact
public function deleteContact(Contact $contact) { $this->om->remove($contact); $this->om->flush(); }
php
public function deleteContact(Contact $contact) { $this->om->remove($contact); $this->om->flush(); }
[ "public", "function", "deleteContact", "(", "Contact", "$", "contact", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "contact", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Removes a contact. @param Contact $contact
[ "Removes", "a", "contact", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L113-L117
40,161
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.update
public function update(Dropzone $dropzone, array $data) { $this->crud->update('Claroline\DropZoneBundle\Entity\Dropzone', $data); $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($dropzone); $this->eventDispatcher->dispatch('log', new LogDropzoneConfigureEvent($dropzone, $changeSet)); return $dropzone; }
php
public function update(Dropzone $dropzone, array $data) { $this->crud->update('Claroline\DropZoneBundle\Entity\Dropzone', $data); $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($dropzone); $this->eventDispatcher->dispatch('log', new LogDropzoneConfigureEvent($dropzone, $changeSet)); return $dropzone; }
[ "public", "function", "update", "(", "Dropzone", "$", "dropzone", ",", "array", "$", "data", ")", "{", "$", "this", "->", "crud", "->", "update", "(", "'Claroline\\DropZoneBundle\\Entity\\Dropzone'", ",", "$", "data", ")", ";", "$", "uow", "=", "$", "this"...
Updates a Dropzone. @param Dropzone $dropzone @param array $data @return Dropzone
[ "Updates", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L222-L233
40,162
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.delete
public function delete(Dropzone $dropzone) { $this->om->startFlushSuite(); $uuid = $dropzone->getUuid(); $ds = DIRECTORY_SEPARATOR; $dropzoneDir = $this->filesDir.$ds.'dropzone'.$ds.$uuid; if ($this->fileSystem->exists($dropzoneDir)) { $this->fileSystem->remove($dropzoneDir); } $this->crud->delete($dropzone); $this->om->endFlushSuite(); }
php
public function delete(Dropzone $dropzone) { $this->om->startFlushSuite(); $uuid = $dropzone->getUuid(); $ds = DIRECTORY_SEPARATOR; $dropzoneDir = $this->filesDir.$ds.'dropzone'.$ds.$uuid; if ($this->fileSystem->exists($dropzoneDir)) { $this->fileSystem->remove($dropzoneDir); } $this->crud->delete($dropzone); $this->om->endFlushSuite(); }
[ "public", "function", "delete", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "uuid", "=", "$", "dropzone", "->", "getUuid", "(", ")", ";", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", ...
Deletes a Dropzone. @param Dropzone $dropzone
[ "Deletes", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L240-L252
40,163
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.setDefaultDropType
public function setDefaultDropType(Dropzone $dropzone) { $dropzone->setDropType(Dropzone::DROP_TYPE_USER); $this->om->persist($dropzone); $this->om->flush(); }
php
public function setDefaultDropType(Dropzone $dropzone) { $dropzone->setDropType(Dropzone::DROP_TYPE_USER); $this->om->persist($dropzone); $this->om->flush(); }
[ "public", "function", "setDefaultDropType", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "dropzone", "->", "setDropType", "(", "Dropzone", "::", "DROP_TYPE_USER", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "dropzone", ")", ";", "$", ...
Sets Dropzone drop type to default. @param Dropzone $dropzone
[ "Sets", "Dropzone", "drop", "type", "to", "default", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L259-L264
40,164
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUserDrop
public function getUserDrop(Dropzone $dropzone, User $user, $withCreation = false) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null]); $drop = count($drops) > 0 ? $drops[0] : null; if (empty($drop) && $withCreation) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $this->om->persist($drop); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } return $drop; }
php
public function getUserDrop(Dropzone $dropzone, User $user, $withCreation = false) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null]); $drop = count($drops) > 0 ? $drops[0] : null; if (empty($drop) && $withCreation) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $this->om->persist($drop); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } return $drop; }
[ "public", "function", "getUserDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ",", "$", "withCreation", "=", "false", ")", "{", "$", "drops", "=", "$", "this", "->", "dropRepo", "->", "findBy", "(", "[", "'dropzone'", "=>", "$", "dro...
Gets user drop or creates one. @param Dropzone $dropzone @param User $user @param bool $withCreation @return Drop
[ "Gets", "user", "drop", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L287-L311
40,165
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getTeamDrop
public function getTeamDrop(Dropzone $dropzone, Team $team, User $user, $withCreation = false) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $team->getUuid()]); if ($withCreation) { if (empty($drop)) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $drop->setTeamId($team->getId()); $drop->setTeamUuid($team->getUuid()); $drop->setTeamName($team->getName()); foreach ($team->getRole()->getUsers() as $teamUser) { $drop->addUser($teamUser); /* TODO: checks that a valid status is not overwritten */ $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $teamUser, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); } $this->om->persist($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } elseif (!$drop->hasUser($user)) { $this->om->startFlushSuite(); $drop->addUser($user); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->persist($drop); $this->om->endFlushSuite(); } } return $drop; }
php
public function getTeamDrop(Dropzone $dropzone, Team $team, User $user, $withCreation = false) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $team->getUuid()]); if ($withCreation) { if (empty($drop)) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $drop->setTeamId($team->getId()); $drop->setTeamUuid($team->getUuid()); $drop->setTeamName($team->getName()); foreach ($team->getRole()->getUsers() as $teamUser) { $drop->addUser($teamUser); /* TODO: checks that a valid status is not overwritten */ $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $teamUser, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); } $this->om->persist($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } elseif (!$drop->hasUser($user)) { $this->om->startFlushSuite(); $drop->addUser($user); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->persist($drop); $this->om->endFlushSuite(); } } return $drop; }
[ "public", "function", "getTeamDrop", "(", "Dropzone", "$", "dropzone", ",", "Team", "$", "team", ",", "User", "$", "user", ",", "$", "withCreation", "=", "false", ")", "{", "$", "drop", "=", "$", "this", "->", "dropRepo", "->", "findOneBy", "(", "[", ...
Gets team drop or creates one. @param Dropzone $dropzone @param Team $team @param User $user @param bool $withCreation @return Drop
[ "Gets", "team", "drop", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L323-L366
40,166
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getTeamDrops
public function getTeamDrops(Dropzone $dropzone, User $user) { $drops = $this->dropRepo->findTeamDrops($dropzone, $user); return $drops; }
php
public function getTeamDrops(Dropzone $dropzone, User $user) { $drops = $this->dropRepo->findTeamDrops($dropzone, $user); return $drops; }
[ "public", "function", "getTeamDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "drops", "=", "$", "this", "->", "dropRepo", "->", "findTeamDrops", "(", "$", "dropzone", ",", "$", "user", ")", ";", "return", "$", "drops...
Gets Team drops or create one. @param Dropzone $dropzone @param User $user @return array
[ "Gets", "Team", "drops", "or", "create", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L376-L381
40,167
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteDrop
public function deleteDrop(Drop $drop) { $this->om->startFlushSuite(); $documents = $drop->getDocuments(); foreach ($documents as $document) { $this->deleteDocument($document); } $this->om->remove($drop); $this->om->endFlushSuite(); }
php
public function deleteDrop(Drop $drop) { $this->om->startFlushSuite(); $documents = $drop->getDocuments(); foreach ($documents as $document) { $this->deleteDocument($document); } $this->om->remove($drop); $this->om->endFlushSuite(); }
[ "public", "function", "deleteDrop", "(", "Drop", "$", "drop", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "documents", "=", "$", "drop", "->", "getDocuments", "(", ")", ";", "foreach", "(", "$", "documents", "as", ...
Deletes a Drop. @param Drop $drop
[ "Deletes", "a", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L388-L398
40,168
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUserTeamId
public function getUserTeamId(Dropzone $dropzone, User $user) { $teamId = null; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $teamId = $teamDrops[0]->getTeamUuid(); } } return $teamId; }
php
public function getUserTeamId(Dropzone $dropzone, User $user) { $teamId = null; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $teamId = $teamDrops[0]->getTeamUuid(); } } return $teamId; }
[ "public", "function", "getUserTeamId", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "teamId", "=", "null", ";", "if", "(", "Dropzone", "::", "DROP_TYPE_TEAM", "===", "$", "dropzone", "->", "getDropType", "(", ")", ")", "{", ...
Retrieves teamId of user. @param Dropzone $dropzone @param User $user @return string|null
[ "Retrieves", "teamId", "of", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L408-L421
40,169
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createDocument
public function createDocument(Drop $drop, User $user, $documentType, $documentData) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate(new \DateTime()); $document->setType($documentType); if (Document::DOCUMENT_TYPE_RESOURCE === $document->getType()) { $resourceNode = $this->resourceNodeRepo->findOneBy(['uuid' => $documentData]); $document->setData($resourceNode); } else { $document->setData($documentData); } $this->om->persist($document); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $document)); return $document; }
php
public function createDocument(Drop $drop, User $user, $documentType, $documentData) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate(new \DateTime()); $document->setType($documentType); if (Document::DOCUMENT_TYPE_RESOURCE === $document->getType()) { $resourceNode = $this->resourceNodeRepo->findOneBy(['uuid' => $documentData]); $document->setData($resourceNode); } else { $document->setData($documentData); } $this->om->persist($document); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $document)); return $document; }
[ "public", "function", "createDocument", "(", "Drop", "$", "drop", ",", "User", "$", "user", ",", "$", "documentType", ",", "$", "documentData", ")", "{", "$", "document", "=", "new", "Document", "(", ")", ";", "$", "document", "->", "setDrop", "(", "$"...
Creates a Document. @param Drop $drop @param User $user @param int $documentType @param mixed $documentData @return Document
[ "Creates", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L440-L460
40,170
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createFilesDocuments
public function createFilesDocuments(Drop $drop, User $user, array $files) { $documents = []; $documentEntities = []; $currentDate = new \DateTime(); $dropzone = $drop->getDropzone(); $this->om->startFlushSuite(); foreach ($files as $file) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate($currentDate); $document->setType(Document::DOCUMENT_TYPE_FILE); $data = $this->registerUplodadedFile($dropzone, $file); $document->setFile($data); $this->om->persist($document); $documentEntities[] = $document; $documents[] = $this->serializeDocument($document); } $this->om->endFlushSuite(); //tracking for each document, after flush foreach ($documentEntities as $entity) { $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $entity)); } return $documents; }
php
public function createFilesDocuments(Drop $drop, User $user, array $files) { $documents = []; $documentEntities = []; $currentDate = new \DateTime(); $dropzone = $drop->getDropzone(); $this->om->startFlushSuite(); foreach ($files as $file) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate($currentDate); $document->setType(Document::DOCUMENT_TYPE_FILE); $data = $this->registerUplodadedFile($dropzone, $file); $document->setFile($data); $this->om->persist($document); $documentEntities[] = $document; $documents[] = $this->serializeDocument($document); } $this->om->endFlushSuite(); //tracking for each document, after flush foreach ($documentEntities as $entity) { $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $entity)); } return $documents; }
[ "public", "function", "createFilesDocuments", "(", "Drop", "$", "drop", ",", "User", "$", "user", ",", "array", "$", "files", ")", "{", "$", "documents", "=", "[", "]", ";", "$", "documentEntities", "=", "[", "]", ";", "$", "currentDate", "=", "new", ...
Creates Files Documents. @param Drop $drop @param User $user @param array $files @return array
[ "Creates", "Files", "Documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L471-L499
40,171
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.submitDrop
public function submitDrop(Drop $drop, User $user) { $this->om->startFlushSuite(); $drop->setFinished(true); $drop->setDropDate(new \DateTime()); if ($drop->getTeamUuid()) { $drop->setUser($user); } $users = $drop->getTeamUuid() ? $drop->getUsers() : [$drop->getUser()]; $this->om->persist($drop); $this->checkCompletion($drop->getDropzone(), $users, $drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropEndEvent($drop->getDropzone(), $drop, $this->roleManager)); }
php
public function submitDrop(Drop $drop, User $user) { $this->om->startFlushSuite(); $drop->setFinished(true); $drop->setDropDate(new \DateTime()); if ($drop->getTeamUuid()) { $drop->setUser($user); } $users = $drop->getTeamUuid() ? $drop->getUsers() : [$drop->getUser()]; $this->om->persist($drop); $this->checkCompletion($drop->getDropzone(), $users, $drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropEndEvent($drop->getDropzone(), $drop, $this->roleManager)); }
[ "public", "function", "submitDrop", "(", "Drop", "$", "drop", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "drop", "->", "setFinished", "(", "true", ")", ";", "$", "drop", "->", "setDropDat...
Terminates a drop. @param Drop $drop @param User $user
[ "Terminates", "a", "drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L527-L544
40,172
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.computeDropScore
public function computeDropScore(Drop $drop) { $corrections = $drop->getCorrections(); $score = 0; $nbValidCorrection = 0; foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { $score += $correction->getScore(); ++$nbValidCorrection; } } $score = $nbValidCorrection > 0 ? round($score / $nbValidCorrection, 2) : null; $drop->setScore($score); $this->om->persist($drop); $this->om->flush(); return $drop; }
php
public function computeDropScore(Drop $drop) { $corrections = $drop->getCorrections(); $score = 0; $nbValidCorrection = 0; foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { $score += $correction->getScore(); ++$nbValidCorrection; } } $score = $nbValidCorrection > 0 ? round($score / $nbValidCorrection, 2) : null; $drop->setScore($score); $this->om->persist($drop); $this->om->flush(); return $drop; }
[ "public", "function", "computeDropScore", "(", "Drop", "$", "drop", ")", "{", "$", "corrections", "=", "$", "drop", "->", "getCorrections", "(", ")", ";", "$", "score", "=", "0", ";", "$", "nbValidCorrection", "=", "0", ";", "foreach", "(", "$", "corre...
Computes Drop score from submitted Corrections. @param Drop $drop @return Drop
[ "Computes", "Drop", "score", "from", "submitted", "Corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L553-L571
40,173
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.closeAllUnfinishedDrops
public function closeAllUnfinishedDrops(Dropzone $dropzone) { $this->om->startFlushSuite(); $currentDate = new \DateTime(); $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'finished' => false]); /** @var Drop $drop */ foreach ($drops as $drop) { $drop->setFinished(true); $drop->setDropDate($currentDate); $drop->setAutoClosedDrop(true); $this->om->persist($drop); } $dropzone->setDropClosed(true); $this->om->persist($dropzone); $this->om->endFlushSuite(); }
php
public function closeAllUnfinishedDrops(Dropzone $dropzone) { $this->om->startFlushSuite(); $currentDate = new \DateTime(); $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'finished' => false]); /** @var Drop $drop */ foreach ($drops as $drop) { $drop->setFinished(true); $drop->setDropDate($currentDate); $drop->setAutoClosedDrop(true); $this->om->persist($drop); } $dropzone->setDropClosed(true); $this->om->persist($dropzone); $this->om->endFlushSuite(); }
[ "public", "function", "closeAllUnfinishedDrops", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "currentDate", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "drops", "=", "$", "this",...
Closes all unfinished drops. @param Dropzone $dropzone
[ "Closes", "all", "unfinished", "drops", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L647-L665
40,174
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.saveCorrection
public function saveCorrection(array $data, User $user) { $this->om->startFlushSuite(); $existingCorrection = $this->correctionRepo->findOneBy(['uuid' => $data['id']]); $isNew = empty($existingCorrection); $correction = $this->serializer->get(Correction::class)->deserialize($data); $correction->setUser($user); $dropzone = $correction->getDrop()->getDropzone(); if (!$isNew) { $correction->setLastEditionDate(new \DateTime()); } $correction = $this->computeCorrectionScore($correction); $this->om->persist($correction); $this->om->endFlushSuite(); if ($isNew) { $this->eventDispatcher->dispatch('log', new LogCorrectionStartEvent($dropzone, $correction->getDrop(), $correction)); } else { $this->eventDispatcher->dispatch('log', new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction)); } return $correction; }
php
public function saveCorrection(array $data, User $user) { $this->om->startFlushSuite(); $existingCorrection = $this->correctionRepo->findOneBy(['uuid' => $data['id']]); $isNew = empty($existingCorrection); $correction = $this->serializer->get(Correction::class)->deserialize($data); $correction->setUser($user); $dropzone = $correction->getDrop()->getDropzone(); if (!$isNew) { $correction->setLastEditionDate(new \DateTime()); } $correction = $this->computeCorrectionScore($correction); $this->om->persist($correction); $this->om->endFlushSuite(); if ($isNew) { $this->eventDispatcher->dispatch('log', new LogCorrectionStartEvent($dropzone, $correction->getDrop(), $correction)); } else { $this->eventDispatcher->dispatch('log', new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction)); } return $correction; }
[ "public", "function", "saveCorrection", "(", "array", "$", "data", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "existingCorrection", "=", "$", "this", "->", "correctionRepo", "->", "findOneBy", ...
Updates a Correction. @param array $data @param User $user @return Correction
[ "Updates", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L675-L698
40,175
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.submitCorrection
public function submitCorrection(Correction $correction, User $user) { $this->om->startFlushSuite(); $correction->setFinished(true); $correction->setEndDate(new \DateTime()); $correction->setUser($user); $this->om->persist($correction); $this->om->forceFlush(); $drop = $this->computeDropScore($correction->getDrop()); $dropzone = $drop->getDropzone(); $userDrop = null; $users = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: $users = [$user]; $userDrop = $this->getUserDrop($dropzone, $user); break; case Dropzone::DROP_TYPE_TEAM: $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $users = $teamDrops[0]->getUsers(); $userDrop = $teamDrops[0]; } break; } $this->eventDispatcher->dispatch('log', new LogCorrectionEndEvent($dropzone, $correction->getDrop(), $correction)); $this->om->forceFlush(); $this->checkSuccess($drop); $this->checkCompletion($dropzone, $users, $userDrop); $this->om->endFlushSuite(); return $correction; }
php
public function submitCorrection(Correction $correction, User $user) { $this->om->startFlushSuite(); $correction->setFinished(true); $correction->setEndDate(new \DateTime()); $correction->setUser($user); $this->om->persist($correction); $this->om->forceFlush(); $drop = $this->computeDropScore($correction->getDrop()); $dropzone = $drop->getDropzone(); $userDrop = null; $users = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: $users = [$user]; $userDrop = $this->getUserDrop($dropzone, $user); break; case Dropzone::DROP_TYPE_TEAM: $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $users = $teamDrops[0]->getUsers(); $userDrop = $teamDrops[0]; } break; } $this->eventDispatcher->dispatch('log', new LogCorrectionEndEvent($dropzone, $correction->getDrop(), $correction)); $this->om->forceFlush(); $this->checkSuccess($drop); $this->checkCompletion($dropzone, $users, $userDrop); $this->om->endFlushSuite(); return $correction; }
[ "public", "function", "submitCorrection", "(", "Correction", "$", "correction", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "correction", "->", "setFinished", "(", "true", ")", ";", "$", "corr...
Submits a Correction. @param Correction $correction @param User $user @return Correction
[ "Submits", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L708-L745
40,176
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.switchCorrectionValidation
public function switchCorrectionValidation(Correction $correction) { $this->om->startFlushSuite(); $correction->setValid(!$correction->isValid()); $this->om->persist($correction); $drop = $this->computeDropScore($correction->getDrop()); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionValidationChangeEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction)); return $correction; }
php
public function switchCorrectionValidation(Correction $correction) { $this->om->startFlushSuite(); $correction->setValid(!$correction->isValid()); $this->om->persist($correction); $drop = $this->computeDropScore($correction->getDrop()); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionValidationChangeEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction)); return $correction; }
[ "public", "function", "switchCorrectionValidation", "(", "Correction", "$", "correction", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "correction", "->", "setValid", "(", "!", "$", "correction", "->", "isValid", "(", ")", ...
Switch Correction validation. @param Correction $correction @return Correction
[ "Switch", "Correction", "validation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L754-L768
40,177
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteCorrection
public function deleteCorrection(Correction $correction) { $this->om->startFlushSuite(); $drop = $correction->getDrop(); $drop->removeCorrection($correction); $this->om->remove($correction); $drop = $this->computeDropScore($drop); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionDeleteEvent($correction->getDrop()->getDropzone(), $drop, $correction)); }
php
public function deleteCorrection(Correction $correction) { $this->om->startFlushSuite(); $drop = $correction->getDrop(); $drop->removeCorrection($correction); $this->om->remove($correction); $drop = $this->computeDropScore($drop); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionDeleteEvent($correction->getDrop()->getDropzone(), $drop, $correction)); }
[ "public", "function", "deleteCorrection", "(", "Correction", "$", "correction", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "drop", "=", "$", "correction", "->", "getDrop", "(", ")", ";", "$", "drop", "->", "removeCorr...
Deletes a Correction. @param Correction $correction
[ "Deletes", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L775-L788
40,178
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.denyCorrection
public function denyCorrection(Correction $correction, $comment = null) { $correction->setCorrectionDenied(true); $correction->setCorrectionDeniedComment($comment); $this->om->persist($correction); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogCorrectionReportEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction, $this->roleManager)); return $correction; }
php
public function denyCorrection(Correction $correction, $comment = null) { $correction->setCorrectionDenied(true); $correction->setCorrectionDeniedComment($comment); $this->om->persist($correction); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogCorrectionReportEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction, $this->roleManager)); return $correction; }
[ "public", "function", "denyCorrection", "(", "Correction", "$", "correction", ",", "$", "comment", "=", "null", ")", "{", "$", "correction", "->", "setCorrectionDenied", "(", "true", ")", ";", "$", "correction", "->", "setCorrectionDeniedComment", "(", "$", "c...
Denies a Correction. @param Correction $correction @param string $comment @return Correction
[ "Denies", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L798-L808
40,179
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.computeCorrectionScore
public function computeCorrectionScore(Correction $correction) { $drop = $correction->getDrop(); $dropzone = $drop->getDropzone(); $criteria = $dropzone->getCriteria(); if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) { $score = 0; $criteriaIds = []; $scoreMax = $dropzone->getScoreMax(); $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria); $grades = $correction->getGrades(); foreach ($criteria as $criterion) { $criteriaIds[] = $criterion->getUuid(); } foreach ($grades as $grade) { $gradeCriterion = $grade->getCriterion(); if (in_array($gradeCriterion->getUuid(), $criteriaIds)) { $score += $grade->getValue(); } } $score = round(($score / $total) * $scoreMax, 2); $correction->setScore($score); } $this->om->persist($correction); $this->om->flush(); return $correction; }
php
public function computeCorrectionScore(Correction $correction) { $drop = $correction->getDrop(); $dropzone = $drop->getDropzone(); $criteria = $dropzone->getCriteria(); if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) { $score = 0; $criteriaIds = []; $scoreMax = $dropzone->getScoreMax(); $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria); $grades = $correction->getGrades(); foreach ($criteria as $criterion) { $criteriaIds[] = $criterion->getUuid(); } foreach ($grades as $grade) { $gradeCriterion = $grade->getCriterion(); if (in_array($gradeCriterion->getUuid(), $criteriaIds)) { $score += $grade->getValue(); } } $score = round(($score / $total) * $scoreMax, 2); $correction->setScore($score); } $this->om->persist($correction); $this->om->flush(); return $correction; }
[ "public", "function", "computeCorrectionScore", "(", "Correction", "$", "correction", ")", "{", "$", "drop", "=", "$", "correction", "->", "getDrop", "(", ")", ";", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "criteria", "...
Computes Correction score from criteria grades. @param Correction $correction @return Correction
[ "Computes", "Correction", "score", "from", "criteria", "grades", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L817-L847
40,180
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.saveTool
public function saveTool(array $data) { $tool = $this->serializer->get(DropzoneTool::class)->deserialize($data); $this->om->persist($tool); $this->om->flush(); return $tool; }
php
public function saveTool(array $data) { $tool = $this->serializer->get(DropzoneTool::class)->deserialize($data); $this->om->persist($tool); $this->om->flush(); return $tool; }
[ "public", "function", "saveTool", "(", "array", "$", "data", ")", "{", "$", "tool", "=", "$", "this", "->", "serializer", "->", "get", "(", "DropzoneTool", "::", "class", ")", "->", "deserialize", "(", "$", "data", ")", ";", "$", "this", "->", "om", ...
Updates a Tool. @param array $data @return Tool
[ "Updates", "a", "Tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L868-L875
40,181
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteTool
public function deleteTool(DropzoneTool $tool) { $this->om->remove($tool); $this->om->flush(); }
php
public function deleteTool(DropzoneTool $tool) { $this->om->remove($tool); $this->om->flush(); }
[ "public", "function", "deleteTool", "(", "DropzoneTool", "$", "tool", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "tool", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a Tool. @param DropzoneTool $tool
[ "Deletes", "a", "Tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L882-L886
40,182
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getFinishedUserDrop
public function getFinishedUserDrop(Dropzone $dropzone, User $user = null, $teamId = null) { $drop = null; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drop = $this->dropRepo->findOneBy([ 'dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null, 'finished' => true, ]); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $teamId, 'finished' => true]); } break; } return $drop; }
php
public function getFinishedUserDrop(Dropzone $dropzone, User $user = null, $teamId = null) { $drop = null; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drop = $this->dropRepo->findOneBy([ 'dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null, 'finished' => true, ]); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $teamId, 'finished' => true]); } break; } return $drop; }
[ "public", "function", "getFinishedUserDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drop", "=", "null", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "(", ")...
Gets user|team drop if it is finished. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "user|team", "drop", "if", "it", "is", "finished", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L910-L933
40,183
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getFinishedPeerDrops
public function getFinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserFinishedPeerDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamFinishedPeerDrops($dropzone, $teamId); } break; } return $drops; }
php
public function getFinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserFinishedPeerDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamFinishedPeerDrops($dropzone, $teamId); } break; } return $drops; }
[ "public", "function", "getFinishedPeerDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drops", "=", "[", "]", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "("...
Gets drops corrected by user|team. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "drops", "corrected", "by", "user|team", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L944-L962
40,184
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUnfinishedPeerDrops
public function getUnfinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserUnfinishedPeerDrop($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamUnfinishedPeerDrop($dropzone, $teamId); } break; } return $drops; }
php
public function getUnfinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserUnfinishedPeerDrop($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamUnfinishedPeerDrop($dropzone, $teamId); } break; } return $drops; }
[ "public", "function", "getUnfinishedPeerDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drops", "=", "[", "]", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "...
Gets drops corrected by user|team but that are not finished. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "drops", "corrected", "by", "user|team", "but", "that", "are", "not", "finished", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L973-L991
40,185
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getPeerDrop
public function getPeerDrop(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null, $withCreation = true) { $peerDrop = null; /* Gets user|team drop to check if it is finished before allowing peer review */ $userDrop = $this->getFinishedUserDrop($dropzone, $user, $teamId); /* user|team drop is finished */ if (!empty($userDrop)) { /* Gets drops where user|team has an unfinished correction */ $unfinishedDrops = $this->getUnfinishedPeerDrops($dropzone, $user, $teamId); if (count($unfinishedDrops) > 0) { /* Returns the first drop with an unfinished correction */ $peerDrop = $unfinishedDrops[0]; } else { /* Gets drops where user|team has a finished correction */ $finishedDrops = $this->getFinishedPeerDrops($dropzone, $user, $teamId); $nbCorrections = count($finishedDrops); /* Fetches a drop for peer correction if user|team has not made the expected number of corrections */ if ($withCreation && $dropzone->isReviewEnabled() && $nbCorrections < $dropzone->getExpectedCorrectionTotal()) { $peerDrop = $this->getAvailableDropForPeer($dropzone, $user, $teamId, $teamName); } } } return $peerDrop; }
php
public function getPeerDrop(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null, $withCreation = true) { $peerDrop = null; /* Gets user|team drop to check if it is finished before allowing peer review */ $userDrop = $this->getFinishedUserDrop($dropzone, $user, $teamId); /* user|team drop is finished */ if (!empty($userDrop)) { /* Gets drops where user|team has an unfinished correction */ $unfinishedDrops = $this->getUnfinishedPeerDrops($dropzone, $user, $teamId); if (count($unfinishedDrops) > 0) { /* Returns the first drop with an unfinished correction */ $peerDrop = $unfinishedDrops[0]; } else { /* Gets drops where user|team has a finished correction */ $finishedDrops = $this->getFinishedPeerDrops($dropzone, $user, $teamId); $nbCorrections = count($finishedDrops); /* Fetches a drop for peer correction if user|team has not made the expected number of corrections */ if ($withCreation && $dropzone->isReviewEnabled() && $nbCorrections < $dropzone->getExpectedCorrectionTotal()) { $peerDrop = $this->getAvailableDropForPeer($dropzone, $user, $teamId, $teamName); } } } return $peerDrop; }
[ "public", "function", "getPeerDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ",", "$", "teamName", "=", "null", ",", "$", "withCreation", "=", "true", ")", "{", "$", "peerDrop", "=", "...
Gets a drop for peer evaluation. @param Dropzone $dropzone @param User $user @param string $teamId @param string $teamName @param bool $withCreation @return Drop | null
[ "Gets", "a", "drop", "for", "peer", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1004-L1032
40,186
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getAvailableDropForPeer
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null) { $peerDrop = null; $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId); } break; } $validDrops = []; foreach ($drops as $drop) { $corrections = $drop->getCorrections(); if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) { $validDrops[] = $drop; } } if (count($validDrops) > 0) { /* Selects the drop with the least corrections */ $peerDrop = $this->getDropWithTheLeastCorrections($validDrops); /* Creates empty correction */ $correction = new Correction(); $correction->setDrop($peerDrop); $correction->setUser($user); $correction->setTeamUuid($teamId); $correction->setTeamName($teamName); $currentDate = new \DateTime(); $correction->setStartDate($currentDate); $correction->setLastEditionDate($currentDate); $peerDrop->addCorrection($correction); $this->om->persist($correction); $this->om->flush(); } return $peerDrop; }
php
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null) { $peerDrop = null; $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId); } break; } $validDrops = []; foreach ($drops as $drop) { $corrections = $drop->getCorrections(); if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) { $validDrops[] = $drop; } } if (count($validDrops) > 0) { /* Selects the drop with the least corrections */ $peerDrop = $this->getDropWithTheLeastCorrections($validDrops); /* Creates empty correction */ $correction = new Correction(); $correction->setDrop($peerDrop); $correction->setUser($user); $correction->setTeamUuid($teamId); $correction->setTeamName($teamName); $currentDate = new \DateTime(); $correction->setStartDate($currentDate); $correction->setLastEditionDate($currentDate); $peerDrop->addCorrection($correction); $this->om->persist($correction); $this->om->flush(); } return $peerDrop; }
[ "public", "function", "getAvailableDropForPeer", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ",", "$", "teamName", "=", "null", ")", "{", "$", "peerDrop", "=", "null", ";", "$", "drops", "="...
Gets available drop for peer evaluation. @param Dropzone $dropzone @param User $user @param string $teamId @param string $teamName @return Drop | null
[ "Gets", "available", "drop", "for", "peer", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1044-L1089
40,187
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.executeTool
public function executeTool(DropzoneTool $tool, Document $document) { if (DropzoneTool::COMPILATIO === $tool->getType() && Document::DOCUMENT_TYPE_FILE === $document->getType()) { $toolDocument = $this->dropzoneToolDocumentRepo->findOneBy(['tool' => $tool, 'document' => $document]); $toolData = $tool->getData(); $compilatio = new \SoapClient($toolData['url']); if (empty($toolDocument)) { $documentData = $document->getFile(); $params = []; $params[] = $toolData['key']; $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['mimeType']); $params[] = base64_encode(file_get_contents($this->filesDir.DIRECTORY_SEPARATOR.$documentData['url'])); $idDocument = $compilatio->__call('addDocumentBase64', $params); $analysisParams = []; $analysisParams[] = $toolData['key']; $analysisParams[] = $idDocument; $compilatio->__call('startDocumentAnalyse', $analysisParams); $reportUrl = $compilatio->__call('getDocumentReportUrl', $analysisParams); if ($idDocument && $reportUrl) { $this->createToolDocument($tool, $document, $idDocument, $reportUrl); } } } return $document; }
php
public function executeTool(DropzoneTool $tool, Document $document) { if (DropzoneTool::COMPILATIO === $tool->getType() && Document::DOCUMENT_TYPE_FILE === $document->getType()) { $toolDocument = $this->dropzoneToolDocumentRepo->findOneBy(['tool' => $tool, 'document' => $document]); $toolData = $tool->getData(); $compilatio = new \SoapClient($toolData['url']); if (empty($toolDocument)) { $documentData = $document->getFile(); $params = []; $params[] = $toolData['key']; $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['mimeType']); $params[] = base64_encode(file_get_contents($this->filesDir.DIRECTORY_SEPARATOR.$documentData['url'])); $idDocument = $compilatio->__call('addDocumentBase64', $params); $analysisParams = []; $analysisParams[] = $toolData['key']; $analysisParams[] = $idDocument; $compilatio->__call('startDocumentAnalyse', $analysisParams); $reportUrl = $compilatio->__call('getDocumentReportUrl', $analysisParams); if ($idDocument && $reportUrl) { $this->createToolDocument($tool, $document, $idDocument, $reportUrl); } } } return $document; }
[ "public", "function", "executeTool", "(", "DropzoneTool", "$", "tool", ",", "Document", "$", "document", ")", "{", "if", "(", "DropzoneTool", "::", "COMPILATIO", "===", "$", "tool", "->", "getType", "(", ")", "&&", "Document", "::", "DOCUMENT_TYPE_FILE", "==...
Executes a Tool on a Document. @param DropzoneTool $tool @param Document $document @return Document
[ "Executes", "a", "Tool", "on", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1099-L1129
40,188
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createToolDocument
public function createToolDocument(DropzoneTool $tool, Document $document, $idDocument = null, $reportUrl = null) { $toolDocument = new DropzoneToolDocument(); $toolDocument->setTool($tool); $toolDocument->setDocument($document); $data = ['idDocument' => $idDocument, 'reportUrl' => $reportUrl]; $toolDocument->setData($data); $this->om->persist($toolDocument); $this->om->flush(); }
php
public function createToolDocument(DropzoneTool $tool, Document $document, $idDocument = null, $reportUrl = null) { $toolDocument = new DropzoneToolDocument(); $toolDocument->setTool($tool); $toolDocument->setDocument($document); $data = ['idDocument' => $idDocument, 'reportUrl' => $reportUrl]; $toolDocument->setData($data); $this->om->persist($toolDocument); $this->om->flush(); }
[ "public", "function", "createToolDocument", "(", "DropzoneTool", "$", "tool", ",", "Document", "$", "document", ",", "$", "idDocument", "=", "null", ",", "$", "reportUrl", "=", "null", ")", "{", "$", "toolDocument", "=", "new", "DropzoneToolDocument", "(", "...
Associates data generated by a Tool to a Document. @param DropzoneTool $tool @param Document $document @param string $idDocument @param string $reportUrl
[ "Associates", "data", "generated", "by", "a", "Tool", "to", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1139-L1148
40,189
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.checkCompletion
public function checkCompletion(Dropzone $dropzone, array $users, Drop $drop = null) { $fixedStatusList = [ AbstractResourceEvaluation::STATUS_COMPLETED, AbstractResourceEvaluation::STATUS_PASSED, AbstractResourceEvaluation::STATUS_FAILED, ]; $teamId = !empty($drop) ? $drop->getTeamUuid() : null; $this->om->startFlushSuite(); /* By default drop is complete if teacher review is enabled or drop is unlocked for user */ $isComplete = !empty($drop) ? $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedUser()) : false; /* If drop is not complete by default, checks for the number of finished corrections done by user */ if (!$isComplete) { $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $finishedPeerDrops = $this->getFinishedPeerDrops($dropzone, $users[0], $teamId); $isComplete = count($finishedPeerDrops) >= $expectedCorrectionTotal; } if ($isComplete) { foreach ($users as $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (!empty($userEval) && !in_array($userEval->getStatus(), $fixedStatusList)) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_COMPLETED, 'progression' => 100] ); } elseif (!empty($drop)) { $this->updateDropProgression($dropzone, $drop, 100); } //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } } $this->om->endFlushSuite(); }
php
public function checkCompletion(Dropzone $dropzone, array $users, Drop $drop = null) { $fixedStatusList = [ AbstractResourceEvaluation::STATUS_COMPLETED, AbstractResourceEvaluation::STATUS_PASSED, AbstractResourceEvaluation::STATUS_FAILED, ]; $teamId = !empty($drop) ? $drop->getTeamUuid() : null; $this->om->startFlushSuite(); /* By default drop is complete if teacher review is enabled or drop is unlocked for user */ $isComplete = !empty($drop) ? $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedUser()) : false; /* If drop is not complete by default, checks for the number of finished corrections done by user */ if (!$isComplete) { $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $finishedPeerDrops = $this->getFinishedPeerDrops($dropzone, $users[0], $teamId); $isComplete = count($finishedPeerDrops) >= $expectedCorrectionTotal; } if ($isComplete) { foreach ($users as $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (!empty($userEval) && !in_array($userEval->getStatus(), $fixedStatusList)) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_COMPLETED, 'progression' => 100] ); } elseif (!empty($drop)) { $this->updateDropProgression($dropzone, $drop, 100); } //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } } $this->om->endFlushSuite(); }
[ "public", "function", "checkCompletion", "(", "Dropzone", "$", "dropzone", ",", "array", "$", "users", ",", "Drop", "$", "drop", "=", "null", ")", "{", "$", "fixedStatusList", "=", "[", "AbstractResourceEvaluation", "::", "STATUS_COMPLETED", ",", "AbstractResour...
Computes Complete status for a user. @param Dropzone $dropzone @param array $users @param Drop $drop
[ "Computes", "Complete", "status", "for", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1157-L1196
40,190
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.checkSuccess
public function checkSuccess(Drop $drop) { $this->om->startFlushSuite(); $dropzone = $drop->getDropzone(); $users = [$drop->getUser()]; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $users = $drop->getUsers(); } $computeStatus = $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedDrop()); if (!$computeStatus) { $nbValidCorrections = 0; $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $corrections = $drop->getCorrections(); foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { ++$nbValidCorrections; } } $computeStatus = $nbValidCorrections >= $expectedCorrectionTotal; } if ($computeStatus) { $score = $drop->getScore(); $scoreToPass = $dropzone->getScoreToPass(); $scoreMax = $dropzone->getScoreMax(); $status = !empty($scoreMax) && (($score / $scoreMax) * 100) >= $scoreToPass ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; foreach ($users as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $scoreMax, 'data' => $this->serializeDrop($drop), ], ['status' => true, 'score' => true] ); } $this->eventDispatcher->dispatch('log', new LogDropEvaluateEvent($dropzone, $drop, $drop->getScore())); //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } $this->om->endFlushSuite(); }
php
public function checkSuccess(Drop $drop) { $this->om->startFlushSuite(); $dropzone = $drop->getDropzone(); $users = [$drop->getUser()]; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $users = $drop->getUsers(); } $computeStatus = $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedDrop()); if (!$computeStatus) { $nbValidCorrections = 0; $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $corrections = $drop->getCorrections(); foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { ++$nbValidCorrections; } } $computeStatus = $nbValidCorrections >= $expectedCorrectionTotal; } if ($computeStatus) { $score = $drop->getScore(); $scoreToPass = $dropzone->getScoreToPass(); $scoreMax = $dropzone->getScoreMax(); $status = !empty($scoreMax) && (($score / $scoreMax) * 100) >= $scoreToPass ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; foreach ($users as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $scoreMax, 'data' => $this->serializeDrop($drop), ], ['status' => true, 'score' => true] ); } $this->eventDispatcher->dispatch('log', new LogDropEvaluateEvent($dropzone, $drop, $drop->getScore())); //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } $this->om->endFlushSuite(); }
[ "public", "function", "checkSuccess", "(", "Drop", "$", "drop", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "users", "=", "[", "$", "drop", "...
Computes Success status for a Drop. @param Drop $drop
[ "Computes", "Success", "status", "for", "a", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1203-L1256
40,191
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.generateResourceUserEvaluation
public function generateResourceUserEvaluation(Dropzone $dropzone, User $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (empty($userEval)) { $userEval = $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_NOT_ATTEMPTED] ); } return $userEval; }
php
public function generateResourceUserEvaluation(Dropzone $dropzone, User $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (empty($userEval)) { $userEval = $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_NOT_ATTEMPTED] ); } return $userEval; }
[ "public", "function", "generateResourceUserEvaluation", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "userEval", "=", "$", "this", "->", "resourceEvalManager", "->", "getResourceUserEvaluation", "(", "$", "dropzone", "->", "getResourc...
Retrieves ResourceUserEvaluation for a Dropzone and an user or creates one. @param Dropzone $dropzone @param User $user @return ResourceUserEvaluation
[ "Retrieves", "ResourceUserEvaluation", "for", "a", "Dropzone", "and", "an", "user", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1266-L1280
40,192
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.updateDropProgression
public function updateDropProgression(Dropzone $dropzone, Drop $drop, $progression) { $this->om->startFlushSuite(); if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { foreach ($drop->getUsers() as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } } else { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $drop->getUser(), null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } $this->om->endFlushSuite(); }
php
public function updateDropProgression(Dropzone $dropzone, Drop $drop, $progression) { $this->om->startFlushSuite(); if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { foreach ($drop->getUsers() as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } } else { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $drop->getUser(), null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } $this->om->endFlushSuite(); }
[ "public", "function", "updateDropProgression", "(", "Dropzone", "$", "dropzone", ",", "Drop", "$", "drop", ",", "$", "progression", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "if", "(", "Dropzone", "::", "DROP_TYPE_TEAM", "=...
Updates progression of ResourceEvaluation for drop. @param Dropzone $dropzone @param Drop $drop @param int $progression @return ResourceUserEvaluation
[ "Updates", "progression", "of", "ResourceEvaluation", "for", "drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1291-L1315
40,193
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getAllCorrectionsData
public function getAllCorrectionsData(Dropzone $dropzone) { $data = []; $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); foreach ($corrections as $correction) { $teamId = $correction->getTeamUuid(); $key = empty($teamId) ? 'user_'.$correction->getUser()->getUuid() : 'team_'.$teamId; if (!isset($data[$key])) { $data[$key] = []; } $data[$key][] = $this->serializeCorrection($correction); } return $data; }
php
public function getAllCorrectionsData(Dropzone $dropzone) { $data = []; $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); foreach ($corrections as $correction) { $teamId = $correction->getTeamUuid(); $key = empty($teamId) ? 'user_'.$correction->getUser()->getUuid() : 'team_'.$teamId; if (!isset($data[$key])) { $data[$key] = []; } $data[$key][] = $this->serializeCorrection($correction); } return $data; }
[ "public", "function", "getAllCorrectionsData", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "data", "=", "[", "]", ";", "$", "corrections", "=", "$", "this", "->", "correctionRepo", "->", "findAllCorrectionsByDropzone", "(", "$", "dropzone", ")", ";", "f...
Retrieves all corrections made for a Dropzone. @param Dropzone $dropzone @return array
[ "Retrieves", "all", "corrections", "made", "for", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1324-L1340
40,194
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.copyDropzone
public function copyDropzone(Dropzone $dropzone, DropZone $newDropzone) { foreach ($dropzone->getCriteria() as $criterion) { $newCriterion = new Criterion(); $newCriterion->setDropzone($newDropzone); $newCriterion->setInstruction($criterion->getInstruction()); $this->om->persist($newCriterion); } return $newDropzone; }
php
public function copyDropzone(Dropzone $dropzone, DropZone $newDropzone) { foreach ($dropzone->getCriteria() as $criterion) { $newCriterion = new Criterion(); $newCriterion->setDropzone($newDropzone); $newCriterion->setInstruction($criterion->getInstruction()); $this->om->persist($newCriterion); } return $newDropzone; }
[ "public", "function", "copyDropzone", "(", "Dropzone", "$", "dropzone", ",", "DropZone", "$", "newDropzone", ")", "{", "foreach", "(", "$", "dropzone", "->", "getCriteria", "(", ")", "as", "$", "criterion", ")", "{", "$", "newCriterion", "=", "new", "Crite...
Copy a Dropzone resource. @param Dropzone $dropzone @return Dropzone
[ "Copy", "a", "Dropzone", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1410-L1420
40,195
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.updateScoreByScoreMax
public function updateScoreByScoreMax(Dropzone $dropzone, $oldScoreMax, $newScoreMax) { $ratio = !empty($oldScoreMax) && !empty($newScoreMax) ? $newScoreMax / $oldScoreMax : 0; if ($ratio) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone]); $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); $i = 0; $this->om->startFlushSuite(); foreach ($drops as $drop) { $score = $drop->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $drop->setScore($newScore); $this->om->persist($drop); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } foreach ($corrections as $correction) { $score = $correction->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $correction->setScore($newScore); $this->om->persist($correction); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } $this->om->endFlushSuite(); } }
php
public function updateScoreByScoreMax(Dropzone $dropzone, $oldScoreMax, $newScoreMax) { $ratio = !empty($oldScoreMax) && !empty($newScoreMax) ? $newScoreMax / $oldScoreMax : 0; if ($ratio) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone]); $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); $i = 0; $this->om->startFlushSuite(); foreach ($drops as $drop) { $score = $drop->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $drop->setScore($newScore); $this->om->persist($drop); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } foreach ($corrections as $correction) { $score = $correction->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $correction->setScore($newScore); $this->om->persist($correction); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } $this->om->endFlushSuite(); } }
[ "public", "function", "updateScoreByScoreMax", "(", "Dropzone", "$", "dropzone", ",", "$", "oldScoreMax", ",", "$", "newScoreMax", ")", "{", "$", "ratio", "=", "!", "empty", "(", "$", "oldScoreMax", ")", "&&", "!", "empty", "(", "$", "newScoreMax", ")", ...
Fetches all drops and corrections and updates their score depending on new score max. @param Dropzone $dropzone @param float $oldScoreMax @param float $newScoreMax
[ "Fetches", "all", "drops", "and", "corrections", "and", "updates", "their", "score", "depending", "on", "new", "score", "max", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1531-L1572
40,196
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.listUnpublishedAction
public function listUnpublishedAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); if ($this->checkPermission('MODERATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode())) { $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, PostManager::GET_UNPUBLISHED_POSTS, true); return new JsonResponse($posts); } else { throw new AccessDeniedException(); } }
php
public function listUnpublishedAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); if ($this->checkPermission('MODERATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode())) { $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, PostManager::GET_UNPUBLISHED_POSTS, true); return new JsonResponse($posts); } else { throw new AccessDeniedException(); } }
[ "public", "function", "listUnpublishedAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ...
Get unpublished blog posts. @EXT\Route("/moderation", name="apiv2_blog_post_list_unpublished") @EXT\Method("GET") @param Blog $blog @return array
[ "Get", "unpublished", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L80-L98
40,197
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.listAction
public function listAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, !$blog->getOptions()->getDisplayFullPosts()); return new JsonResponse($posts); }
php
public function listAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, !$blog->getOptions()->getDisplayFullPosts()); return new JsonResponse($posts); }
[ "public", "function", "listAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";", "$...
Get blog posts. @EXT\Route("", name="apiv2_blog_post_list") @EXT\Method("GET") @param Blog $blog @return array
[ "Get", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L110-L128
40,198
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.getAction
public function getAction(Request $request, Blog $blog, $postId) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $post = $this->postManager->getPostByIdOrSlug($blog, $postId); if (is_null($post)) { throw new NotFoundHttpException('Post not found'); } $this->trackingManager->dispatchPostReadEvent($post); $session = $request->getSession(); $sessionViewCounterKey = 'blog_post_view_counter_'.$post->getId(); $now = time(); if ($now >= ($session->get($sessionViewCounterKey) + $this->logThreshold)) { $session->set($sessionViewCounterKey, $now); $this->postManager->updatePostViewCount($post); } return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function getAction(Request $request, Blog $blog, $postId) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $post = $this->postManager->getPostByIdOrSlug($blog, $postId); if (is_null($post)) { throw new NotFoundHttpException('Post not found'); } $this->trackingManager->dispatchPostReadEvent($post); $session = $request->getSession(); $sessionViewCounterKey = 'blog_post_view_counter_'.$post->getId(); $now = time(); if ($now >= ($session->get($sessionViewCounterKey) + $this->logThreshold)) { $session->set($sessionViewCounterKey, $now); $this->postManager->updatePostViewCount($post); } return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "$", "postId", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "...
Get blog post. @EXT\Route("/{postId}", name="apiv2_blog_post_get") @EXT\Method("GET") @EXT\ParamConverter("blog", options={"mapping": {"blogId": "uuid"}}) @param Blog $blog @param Post $post @return array
[ "Get", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L142-L163
40,199
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.createPostAction
public function createPostAction(Request $request, Blog $blog, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('POST', $blog->getResourceNode())) { $data = json_decode($request->getContent(), true); $post = $this->postManager->createPost($blog, $this->postSerializer->deserialize($data), $user); } else { throw new AccessDeniedException(); } return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function createPostAction(Request $request, Blog $blog, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('POST', $blog->getResourceNode())) { $data = json_decode($request->getContent(), true); $post = $this->postManager->createPost($blog, $this->postSerializer->deserialize($data), $user); } else { throw new AccessDeniedException(); } return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "createPostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ...
Create blog post. @EXT\Route("/new", name="apiv2_blog_post_new") @EXT\Method({"POST", "PUT"}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param User $user @return array
[ "Create", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L177-L188