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,600
claroline/Distribution
main/core/Entity/Home/Content2Type.php
Content2Type.detach
public function detach() { if ($this->getBack()) { $this->getBack()->setNext($this->getNext()); } if ($this->getNext()) { $this->getNext()->setBack($this->getBack()); } }
php
public function detach() { if ($this->getBack()) { $this->getBack()->setNext($this->getNext()); } if ($this->getNext()) { $this->getNext()->setBack($this->getBack()); } }
[ "public", "function", "detach", "(", ")", "{", "if", "(", "$", "this", "->", "getBack", "(", ")", ")", "{", "$", "this", "->", "getBack", "(", ")", "->", "setNext", "(", "$", "this", "->", "getNext", "(", ")", ")", ";", "}", "if", "(", "$", "...
Detach a content from a type, this function can be used for reorder or delete contents.
[ "Detach", "a", "content", "from", "a", "type", "this", "function", "can", "be", "used", "for", "reorder", "or", "delete", "contents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Home/Content2Type.php#L239-L248
40,601
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.serialize
public function serialize(Paper $paper, array $options = []) { // Adds user score if available and the method options do not already request it if (!in_array(Transfer::INCLUDE_USER_SCORE, $options) && $this->isScoreAvailable($paper->getExercise(), $paper)) { $options[] = Transfer::INCLUDE_USER_SCORE; } return $this->serializer->serialize($paper, $options); }
php
public function serialize(Paper $paper, array $options = []) { // Adds user score if available and the method options do not already request it if (!in_array(Transfer::INCLUDE_USER_SCORE, $options) && $this->isScoreAvailable($paper->getExercise(), $paper)) { $options[] = Transfer::INCLUDE_USER_SCORE; } return $this->serializer->serialize($paper, $options); }
[ "public", "function", "serialize", "(", "Paper", "$", "paper", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// Adds user score if available and the method options do not already request it", "if", "(", "!", "in_array", "(", "Transfer", "::", "INCLUDE_USER_S...
Serializes a user paper. @param Paper $paper @param array $options @return array
[ "Serializes", "a", "user", "paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L92-L101
40,602
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.checkPaperEvaluated
public function checkPaperEvaluated(Paper $paper) { $fullyEvaluated = $this->repository->isFullyEvaluated($paper); if ($fullyEvaluated) { $event = new LogExerciseEvaluatedEvent($paper->getExercise(), [ 'result' => $paper->getScore(), 'resultMax' => $this->calculateTotal($paper), ]); $this->eventDispatcher->dispatch('log', $event); } return $fullyEvaluated; }
php
public function checkPaperEvaluated(Paper $paper) { $fullyEvaluated = $this->repository->isFullyEvaluated($paper); if ($fullyEvaluated) { $event = new LogExerciseEvaluatedEvent($paper->getExercise(), [ 'result' => $paper->getScore(), 'resultMax' => $this->calculateTotal($paper), ]); $this->eventDispatcher->dispatch('log', $event); } return $fullyEvaluated; }
[ "public", "function", "checkPaperEvaluated", "(", "Paper", "$", "paper", ")", "{", "$", "fullyEvaluated", "=", "$", "this", "->", "repository", "->", "isFullyEvaluated", "(", "$", "paper", ")", ";", "if", "(", "$", "fullyEvaluated", ")", "{", "$", "event",...
Check if a Paper is full evaluated and dispatch a Log event if yes. @param Paper $paper @return bool
[ "Check", "if", "a", "Paper", "is", "full", "evaluated", "and", "dispatch", "a", "Log", "event", "if", "yes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L110-L123
40,603
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.calculateScore
public function calculateScore(Paper $paper, $base = null) { $score = $this->repository->findScore($paper); if (!empty($base) && $base > 0) { $scoreTotal = $this->calculateTotal($paper); if ($scoreTotal && $scoreTotal !== $base) { $score = ($score / $scoreTotal) * $base; } } return $score; }
php
public function calculateScore(Paper $paper, $base = null) { $score = $this->repository->findScore($paper); if (!empty($base) && $base > 0) { $scoreTotal = $this->calculateTotal($paper); if ($scoreTotal && $scoreTotal !== $base) { $score = ($score / $scoreTotal) * $base; } } return $score; }
[ "public", "function", "calculateScore", "(", "Paper", "$", "paper", ",", "$", "base", "=", "null", ")", "{", "$", "score", "=", "$", "this", "->", "repository", "->", "findScore", "(", "$", "paper", ")", ";", "if", "(", "!", "empty", "(", "$", "bas...
Calculates the score of a Paper. @param Paper $paper @param float $base @return float
[ "Calculates", "the", "score", "of", "a", "Paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L133-L144
40,604
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.calculateTotal
public function calculateTotal(Paper $paper) { $total = 0; $structure = json_decode($paper->getStructure(), true); foreach ($structure['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { $total += $this->itemManager->calculateTotal($item); } } } return $total; }
php
public function calculateTotal(Paper $paper) { $total = 0; $structure = json_decode($paper->getStructure(), true); foreach ($structure['steps'] as $step) { foreach ($step['items'] as $item) { if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item['type'])) { $total += $this->itemManager->calculateTotal($item); } } } return $total; }
[ "public", "function", "calculateTotal", "(", "Paper", "$", "paper", ")", "{", "$", "total", "=", "0", ";", "$", "structure", "=", "json_decode", "(", "$", "paper", "->", "getStructure", "(", ")", ",", "true", ")", ";", "foreach", "(", "$", "structure",...
Calculates the total score of a Paper. @param Paper $paper @return float
[ "Calculates", "the", "total", "score", "of", "a", "Paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L153-L168
40,605
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.serializeExercisePapers
public function serializeExercisePapers(Exercise $exercise, User $user = null) { if (!empty($user)) { // Load papers for of a single user $papers = $this->repository->findBy([ 'exercise' => $exercise, 'user' => $user, ]); } else { // Load all papers submitted for the exercise $papers = $this->repository->findBy([ 'exercise' => $exercise, ]); } return array_map(function (Paper $paper) { return $this->serialize($paper); }, $papers); }
php
public function serializeExercisePapers(Exercise $exercise, User $user = null) { if (!empty($user)) { // Load papers for of a single user $papers = $this->repository->findBy([ 'exercise' => $exercise, 'user' => $user, ]); } else { // Load all papers submitted for the exercise $papers = $this->repository->findBy([ 'exercise' => $exercise, ]); } return array_map(function (Paper $paper) { return $this->serialize($paper); }, $papers); }
[ "public", "function", "serializeExercisePapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "user", ")", ")", "{", "// Load papers for of a single user", "$", "papers", "=", "$", "t...
Returns the papers for a given exercise, in a JSON format. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "papers", "for", "a", "given", "exercise", "in", "a", "JSON", "format", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L178-L196
40,606
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.delete
public function delete(Paper $paper) { $this->om->remove($paper); $this->om->flush(); }
php
public function delete(Paper $paper) { $this->om->remove($paper); $this->om->flush(); }
[ "public", "function", "delete", "(", "Paper", "$", "paper", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "paper", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a paper. @param Paper $paper
[ "Deletes", "a", "paper", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L221-L225
40,607
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.countUserFinishedPapers
public function countUserFinishedPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedPapers($exercise, $user); }
php
public function countUserFinishedPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedPapers($exercise, $user); }
[ "public", "function", "countUserFinishedPapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "repository", "->", "countUserFinishedPapers", "(", "$", "exercise", ",", "$", "user", ")", ";", "}" ]
Returns the number of finished papers already done by the user for a given exercise. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "number", "of", "finished", "papers", "already", "done", "by", "the", "user", "for", "a", "given", "exercise", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L235-L238
40,608
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.countUserFinishedDayPapers
public function countUserFinishedDayPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedDayPapers($exercise, $user); }
php
public function countUserFinishedDayPapers(Exercise $exercise, User $user) { return $this->repository->countUserFinishedDayPapers($exercise, $user); }
[ "public", "function", "countUserFinishedDayPapers", "(", "Exercise", "$", "exercise", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "repository", "->", "countUserFinishedDayPapers", "(", "$", "exercise", ",", "$", "user", ")", ";", "}" ]
Returns the number of finished papers already done by the user for a given exercise for the current day. @param Exercise $exercise @param User $user @return array
[ "Returns", "the", "number", "of", "finished", "papers", "already", "done", "by", "the", "user", "for", "a", "given", "exercise", "for", "the", "current", "day", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L248-L251
40,609
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.isSolutionAvailable
public function isSolutionAvailable(Exercise $exercise, Paper $paper) { $correctionMode = $exercise->getCorrectionMode(); switch ($correctionMode) { case ShowCorrectionAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowCorrectionAt::AFTER_LAST_ATTEMPT: $available = 0 === $exercise->getMaxAttempts() || $paper->getNumber() === $exercise->getMaxAttempts(); break; case ShowCorrectionAt::AFTER_DATE: $now = new \DateTime(); $available = empty($exercise->getDateCorrection()) || $now >= $exercise->getDateCorrection(); break; case ShowCorrectionAt::NEVER: default: $available = false; break; } return $available; }
php
public function isSolutionAvailable(Exercise $exercise, Paper $paper) { $correctionMode = $exercise->getCorrectionMode(); switch ($correctionMode) { case ShowCorrectionAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowCorrectionAt::AFTER_LAST_ATTEMPT: $available = 0 === $exercise->getMaxAttempts() || $paper->getNumber() === $exercise->getMaxAttempts(); break; case ShowCorrectionAt::AFTER_DATE: $now = new \DateTime(); $available = empty($exercise->getDateCorrection()) || $now >= $exercise->getDateCorrection(); break; case ShowCorrectionAt::NEVER: default: $available = false; break; } return $available; }
[ "public", "function", "isSolutionAvailable", "(", "Exercise", "$", "exercise", ",", "Paper", "$", "paper", ")", "{", "$", "correctionMode", "=", "$", "exercise", "->", "getCorrectionMode", "(", ")", ";", "switch", "(", "$", "correctionMode", ")", "{", "case"...
Check if the solution of the Paper is available to User. @param Exercise $exercise @param Paper $paper @return bool
[ "Check", "if", "the", "solution", "of", "the", "Paper", "is", "available", "to", "User", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L297-L321
40,610
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.isScoreAvailable
public function isScoreAvailable(Exercise $exercise, Paper $paper) { $markMode = $exercise->getMarkMode(); switch ($markMode) { case ShowScoreAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowScoreAt::NEVER: $available = false; break; case ShowScoreAt::WITH_CORRECTION: default: $available = $this->isSolutionAvailable($exercise, $paper); break; } return $available; }
php
public function isScoreAvailable(Exercise $exercise, Paper $paper) { $markMode = $exercise->getMarkMode(); switch ($markMode) { case ShowScoreAt::AFTER_END: $available = !empty($paper->getEnd()); break; case ShowScoreAt::NEVER: $available = false; break; case ShowScoreAt::WITH_CORRECTION: default: $available = $this->isSolutionAvailable($exercise, $paper); break; } return $available; }
[ "public", "function", "isScoreAvailable", "(", "Exercise", "$", "exercise", ",", "Paper", "$", "paper", ")", "{", "$", "markMode", "=", "$", "exercise", "->", "getMarkMode", "(", ")", ";", "switch", "(", "$", "markMode", ")", "{", "case", "ShowScoreAt", ...
Check if the score of the Paper is available to User. @param Exercise $exercise @param Paper $paper @return bool
[ "Check", "if", "the", "score", "of", "the", "Paper", "is", "available", "to", "User", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L331-L348
40,611
claroline/Distribution
plugin/exo/Manager/Attempt/PaperManager.php
PaperManager.generateResourceEvaluation
public function generateResourceEvaluation(Paper $paper, $finished) { $totalScoreOn = $paper->getExercise()->getTotalScoreOn(); $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper); $score = $this->calculateScore($paper, $total); $successScore = $paper->getExercise()->getSuccessScore(); $data = [ 'paper' => [ 'id' => $paper->getId(), 'uuid' => $paper->getUuid(), ], ]; if ($finished) { if (is_null($successScore)) { $status = AbstractResourceEvaluation::STATUS_COMPLETED; } else { $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100); $status = $percentScore >= $successScore ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; } } else { $status = AbstractResourceEvaluation::STATUS_INCOMPLETE; } $nbQuestions = 0; $structure = json_decode($paper->getStructure(), true); if (isset($structure['steps'])) { foreach ($structure['steps'] as $step) { $nbQuestions += count($step['items']); // TODO : remove content items } } $nbAnswers = 0; foreach ($paper->getAnswers() as $answer) { if (!is_null($answer->getData())) { ++$nbAnswers; } } return $this->resourceEvalManager->createResourceEvaluation( $paper->getExercise()->getResourceNode(), $paper->getUser(), null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $total, 'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null, 'data' => $data, ] ); }
php
public function generateResourceEvaluation(Paper $paper, $finished) { $totalScoreOn = $paper->getExercise()->getTotalScoreOn(); $total = $totalScoreOn ? $totalScoreOn : $this->calculateTotal($paper); $score = $this->calculateScore($paper, $total); $successScore = $paper->getExercise()->getSuccessScore(); $data = [ 'paper' => [ 'id' => $paper->getId(), 'uuid' => $paper->getUuid(), ], ]; if ($finished) { if (is_null($successScore)) { $status = AbstractResourceEvaluation::STATUS_COMPLETED; } else { $percentScore = 100 === $totalScoreOn ? $score : $this->calculateScore($paper, 100); $status = $percentScore >= $successScore ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; } } else { $status = AbstractResourceEvaluation::STATUS_INCOMPLETE; } $nbQuestions = 0; $structure = json_decode($paper->getStructure(), true); if (isset($structure['steps'])) { foreach ($structure['steps'] as $step) { $nbQuestions += count($step['items']); // TODO : remove content items } } $nbAnswers = 0; foreach ($paper->getAnswers() as $answer) { if (!is_null($answer->getData())) { ++$nbAnswers; } } return $this->resourceEvalManager->createResourceEvaluation( $paper->getExercise()->getResourceNode(), $paper->getUser(), null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $total, 'progression' => $nbQuestions > 0 ? floor(($nbAnswers / $nbQuestions) * 100) : null, 'data' => $data, ] ); }
[ "public", "function", "generateResourceEvaluation", "(", "Paper", "$", "paper", ",", "$", "finished", ")", "{", "$", "totalScoreOn", "=", "$", "paper", "->", "getExercise", "(", ")", "->", "getTotalScoreOn", "(", ")", ";", "$", "total", "=", "$", "totalSco...
Creates a ResourceEvaluation for the attempt. @param Paper $paper @param bool $finished @return ResourceEvaluation
[ "Creates", "a", "ResourceEvaluation", "for", "the", "attempt", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/PaperManager.php#L358-L411
40,612
claroline/Distribution
plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php
ChoiceQuestionSerializer.serialize
public function serialize(ChoiceQuestion $choiceQuestion, array $options = []) { $serialized = [ 'random' => $choiceQuestion->getShuffle(), 'multiple' => $choiceQuestion->isMultiple(), 'numbering' => $choiceQuestion->getNumbering(), 'direction' => $choiceQuestion->getDirection(), ]; // Serializes choices $choices = $this->serializeChoices($choiceQuestion, $options); if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($choices); } $serialized['choices'] = $choices; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($choiceQuestion); } return $serialized; }
php
public function serialize(ChoiceQuestion $choiceQuestion, array $options = []) { $serialized = [ 'random' => $choiceQuestion->getShuffle(), 'multiple' => $choiceQuestion->isMultiple(), 'numbering' => $choiceQuestion->getNumbering(), 'direction' => $choiceQuestion->getDirection(), ]; // Serializes choices $choices = $this->serializeChoices($choiceQuestion, $options); if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) { shuffle($choices); } $serialized['choices'] = $choices; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($choiceQuestion); } return $serialized; }
[ "public", "function", "serialize", "(", "ChoiceQuestion", "$", "choiceQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'random'", "=>", "$", "choiceQuestion", "->", "getShuffle", "(", ")", ",", "'multiple'", "...
Converts a Choice question into a JSON-encodable structure. @param ChoiceQuestion $choiceQuestion @param array $options @return array
[ "Converts", "a", "Choice", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php#L47-L70
40,613
claroline/Distribution
plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php
ChoiceQuestionSerializer.deserialize
public function deserialize($data, ChoiceQuestion $choiceQuestion = null, array $options = []) { if (empty($choiceQuestion)) { $choiceQuestion = new ChoiceQuestion(); } $this->sipe('multiple', 'setMultiple', $data, $choiceQuestion); $this->sipe('random', 'setShuffle', $data, $choiceQuestion); $this->sipe('numbering', 'setNumbering', $data, $choiceQuestion); $this->deserializeChoices($choiceQuestion, $data['choices'], $data['solutions'], $options); return $choiceQuestion; }
php
public function deserialize($data, ChoiceQuestion $choiceQuestion = null, array $options = []) { if (empty($choiceQuestion)) { $choiceQuestion = new ChoiceQuestion(); } $this->sipe('multiple', 'setMultiple', $data, $choiceQuestion); $this->sipe('random', 'setShuffle', $data, $choiceQuestion); $this->sipe('numbering', 'setNumbering', $data, $choiceQuestion); $this->deserializeChoices($choiceQuestion, $data['choices'], $data['solutions'], $options); return $choiceQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ChoiceQuestion", "$", "choiceQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "choiceQuestion", ")", ")", "{", "$", "choiceQuestion",...
Converts raw data into a Choice question entity. @param array $data @param ChoiceQuestion $choiceQuestion @param array $options @return ChoiceQuestion
[ "Converts", "raw", "data", "into", "a", "Choice", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ChoiceQuestionSerializer.php#L81-L94
40,614
claroline/Distribution
main/core/Repository/ResourceNodeRepository.php
ResourceNodeRepository.findDescendants
public function findDescendants( ResourceNode $resource, $includeStartNode = false, $filterResourceType = null ) { $this->builder->selectAsEntity(true) ->wherePathLike($resource->getPath(), $includeStartNode); if ($filterResourceType) { $this->builder->whereTypeIn([$filterResourceType]); } $query = $this->_em->createQuery($this->builder->getDql()); $query->setParameters($this->builder->getParameters()); return $this->executeQuery($query, null, null, false); }
php
public function findDescendants( ResourceNode $resource, $includeStartNode = false, $filterResourceType = null ) { $this->builder->selectAsEntity(true) ->wherePathLike($resource->getPath(), $includeStartNode); if ($filterResourceType) { $this->builder->whereTypeIn([$filterResourceType]); } $query = $this->_em->createQuery($this->builder->getDql()); $query->setParameters($this->builder->getParameters()); return $this->executeQuery($query, null, null, false); }
[ "public", "function", "findDescendants", "(", "ResourceNode", "$", "resource", ",", "$", "includeStartNode", "=", "false", ",", "$", "filterResourceType", "=", "null", ")", "{", "$", "this", "->", "builder", "->", "selectAsEntity", "(", "true", ")", "->", "w...
Returns the descendants of a resource. @param ResourceNode $resource The resource node to start with @param bool $includeStartNode Whether the given resource should be included in the result @param string $filterResourceType A resource type to filter the results @return array[ResourceNode]
[ "Returns", "the", "descendants", "of", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceNodeRepository.php#L89-L105
40,615
claroline/Distribution
main/core/Repository/ResourceNodeRepository.php
ResourceNodeRepository.executeQuery
private function executeQuery($query, $offset = null, $numrows = null, $asArray = true) { $query->setFirstResult($offset); $query->setMaxResults($numrows); if ($asArray) { $resources = $query->getArrayResult(); $return = $resources; // Add a field "pathfordisplay" in each entity (as array) of the given array. foreach ($resources as $key => $resource) { if (isset($resource['path'])) { $return[$key]['path_for_display'] = ResourceNode::convertPathForDisplay($resource['path']); } } return $return; } return $query->getResult(); }
php
private function executeQuery($query, $offset = null, $numrows = null, $asArray = true) { $query->setFirstResult($offset); $query->setMaxResults($numrows); if ($asArray) { $resources = $query->getArrayResult(); $return = $resources; // Add a field "pathfordisplay" in each entity (as array) of the given array. foreach ($resources as $key => $resource) { if (isset($resource['path'])) { $return[$key]['path_for_display'] = ResourceNode::convertPathForDisplay($resource['path']); } } return $return; } return $query->getResult(); }
[ "private", "function", "executeQuery", "(", "$", "query", ",", "$", "offset", "=", "null", ",", "$", "numrows", "=", "null", ",", "$", "asArray", "=", "true", ")", "{", "$", "query", "->", "setFirstResult", "(", "$", "offset", ")", ";", "$", "query",...
Executes a DQL query and returns resources as entities or arrays. If it returns arrays, it add a "pathfordisplay" field to each item. @param Query $query The query to execute @param int $offset First row to start with @param int $numrows Maximum number of rows to return @param bool $asArray Whether the resources must be returned as arrays or as objects @return array[AbstractResource|array]
[ "Executes", "a", "DQL", "query", "and", "returns", "resources", "as", "entities", "or", "arrays", ".", "If", "it", "returns", "arrays", "it", "add", "a", "pathfordisplay", "field", "to", "each", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceNodeRepository.php#L306-L325
40,616
claroline/Distribution
main/core/API/Serializer/Resource/Types/DirectorySerializer.php
DirectorySerializer.serialize
public function serialize(Directory $directory): array { return [ 'id' => $directory->getId(), 'uploadDestination' => $directory->isUploadDestination(), 'display' => [ 'showSummary' => $directory->getShowSummary(), 'openSummary' => $directory->getOpenSummary(), ], // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer 'list' => [ 'actions' => $directory->hasActions(), 'count' => $directory->hasCount(), // display feature 'display' => $directory->getDisplay(), 'availableDisplays' => $directory->getAvailableDisplays(), // sort feature 'sorting' => $directory->getSortBy(), 'availableSort' => $directory->getAvailableSort(), // filter feature 'searchMode' => $directory->getSearchMode(), 'filters' => $directory->getFilters(), 'availableFilters' => $directory->getAvailableFilters(), // pagination feature 'paginated' => $directory->isPaginated(), 'pageSize' => $directory->getPageSize(), 'availablePageSizes' => $directory->getAvailablePageSizes(), // table config 'columns' => $directory->getDisplayedColumns(), 'availableColumns' => $directory->getAvailableColumns(), // grid config 'card' => [ 'display' => $directory->getCard(), 'mapping' => [], // TODO ], ], ]; }
php
public function serialize(Directory $directory): array { return [ 'id' => $directory->getId(), 'uploadDestination' => $directory->isUploadDestination(), 'display' => [ 'showSummary' => $directory->getShowSummary(), 'openSummary' => $directory->getOpenSummary(), ], // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer 'list' => [ 'actions' => $directory->hasActions(), 'count' => $directory->hasCount(), // display feature 'display' => $directory->getDisplay(), 'availableDisplays' => $directory->getAvailableDisplays(), // sort feature 'sorting' => $directory->getSortBy(), 'availableSort' => $directory->getAvailableSort(), // filter feature 'searchMode' => $directory->getSearchMode(), 'filters' => $directory->getFilters(), 'availableFilters' => $directory->getAvailableFilters(), // pagination feature 'paginated' => $directory->isPaginated(), 'pageSize' => $directory->getPageSize(), 'availablePageSizes' => $directory->getAvailablePageSizes(), // table config 'columns' => $directory->getDisplayedColumns(), 'availableColumns' => $directory->getAvailableColumns(), // grid config 'card' => [ 'display' => $directory->getCard(), 'mapping' => [], // TODO ], ], ]; }
[ "public", "function", "serialize", "(", "Directory", "$", "directory", ")", ":", "array", "{", "return", "[", "'id'", "=>", "$", "directory", "->", "getId", "(", ")", ",", "'uploadDestination'", "=>", "$", "directory", "->", "isUploadDestination", "(", ")", ...
Serializes a Directory entity for the JSON api. @param Directory $directory @return array
[ "Serializes", "a", "Directory", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/DirectorySerializer.php#L24-L68
40,617
claroline/Distribution
main/core/API/Serializer/Resource/Types/DirectorySerializer.php
DirectorySerializer.deserialize
public function deserialize(array $data, Directory $directory): Directory { $this->sipe('uploadDestination', 'setUploadDestination', $data, $directory); $this->sipe('display.showSummary', 'setShowSummary', $data, $directory); $this->sipe('display.openSummary', 'setOpenSummary', $data, $directory); // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer $this->sipe('list.count', 'setCount', $data, $directory); $this->sipe('list.actions', 'setActions', $data, $directory); // display feature $this->sipe('list.display', 'setDisplay', $data, $directory); $this->sipe('list.availableDisplays', 'setAvailableDisplays', $data, $directory); // sort feature $this->sipe('list.sorting', 'setSortBy', $data, $directory); $this->sipe('list.availableSort', 'setAvailableSort', $data, $directory); // filter feature $this->sipe('list.searchMode', 'setSearchMode', $data, $directory); $this->sipe('list.filters', 'setFilters', $data, $directory); $this->sipe('list.availableFilters', 'setAvailableFilters', $data, $directory); // pagination feature $this->sipe('list.paginated', 'setPaginated', $data, $directory); $this->sipe('list.pageSize', 'setPageSize', $data, $directory); $this->sipe('list.availablePageSizes', 'setAvailablePageSizes', $data, $directory); // table config $this->sipe('list.columns', 'setDisplayedColumns', $data, $directory); $this->sipe('list.availableColumns', 'setAvailableColumns', $data, $directory); // grid config $this->sipe('list.card.display', 'setCard', $data, $directory); return $directory; }
php
public function deserialize(array $data, Directory $directory): Directory { $this->sipe('uploadDestination', 'setUploadDestination', $data, $directory); $this->sipe('display.showSummary', 'setShowSummary', $data, $directory); $this->sipe('display.openSummary', 'setOpenSummary', $data, $directory); // resource list config // todo : big c/c from Claroline\CoreBundle\API\Serializer\Widget\Type\ListWidgetSerializer $this->sipe('list.count', 'setCount', $data, $directory); $this->sipe('list.actions', 'setActions', $data, $directory); // display feature $this->sipe('list.display', 'setDisplay', $data, $directory); $this->sipe('list.availableDisplays', 'setAvailableDisplays', $data, $directory); // sort feature $this->sipe('list.sorting', 'setSortBy', $data, $directory); $this->sipe('list.availableSort', 'setAvailableSort', $data, $directory); // filter feature $this->sipe('list.searchMode', 'setSearchMode', $data, $directory); $this->sipe('list.filters', 'setFilters', $data, $directory); $this->sipe('list.availableFilters', 'setAvailableFilters', $data, $directory); // pagination feature $this->sipe('list.paginated', 'setPaginated', $data, $directory); $this->sipe('list.pageSize', 'setPageSize', $data, $directory); $this->sipe('list.availablePageSizes', 'setAvailablePageSizes', $data, $directory); // table config $this->sipe('list.columns', 'setDisplayedColumns', $data, $directory); $this->sipe('list.availableColumns', 'setAvailableColumns', $data, $directory); // grid config $this->sipe('list.card.display', 'setCard', $data, $directory); return $directory; }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Directory", "$", "directory", ")", ":", "Directory", "{", "$", "this", "->", "sipe", "(", "'uploadDestination'", ",", "'setUploadDestination'", ",", "$", "data", ",", "$", "directory", ")"...
Deserializes directory data into an Entity. @param array $data @param Directory $directory @return Directory
[ "Deserializes", "directory", "data", "into", "an", "Entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/DirectorySerializer.php#L78-L116
40,618
claroline/Distribution
main/core/Listener/PlatformListener.php
PlatformListener.setLocale
public function setLocale(GetResponseEvent $event) { if ($event->isMasterRequest()) { $request = $event->getRequest(); $locale = $this->localeManager->getUserLocale($request); $request->setLocale($locale); } }
php
public function setLocale(GetResponseEvent $event) { if ($event->isMasterRequest()) { $request = $event->getRequest(); $locale = $this->localeManager->getUserLocale($request); $request->setLocale($locale); } }
[ "public", "function", "setLocale", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "$", "locale", "=", "$", "...
Sets the platform language. @DI\Observe("kernel.request", priority = 17) @param GetResponseEvent $event
[ "Sets", "the", "platform", "language", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/PlatformListener.php#L95-L103
40,619
claroline/Distribution
main/core/Listener/PlatformListener.php
PlatformListener.checkAvailability
public function checkAvailability(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $isAdmin = false; $token = $this->tokenStorage->getToken(); if ($token) { foreach ($token->getRoles() as $role) { if ('ROLE_ADMIN' === $role->getRole()) { $isAdmin = true; break; } } } $now = time(); if (is_int($this->config->getParameter('platform_init_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_init_date')); } else { $minDate = new \DateTime($this->config->getParameter('platform_init_date')); } if (is_int($this->config->getParameter('platform_limit_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_limit_date')); } else { $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date')); } if (!$isAdmin && !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) && ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp()) ) { throw new HttpException(503, 'Platform is not available.'); } } }
php
public function checkAvailability(GetResponseEvent $event) { if ('prod' === $this->kernel->getEnvironment() && $event->isMasterRequest()) { $isAdmin = false; $token = $this->tokenStorage->getToken(); if ($token) { foreach ($token->getRoles() as $role) { if ('ROLE_ADMIN' === $role->getRole()) { $isAdmin = true; break; } } } $now = time(); if (is_int($this->config->getParameter('platform_init_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_init_date')); } else { $minDate = new \DateTime($this->config->getParameter('platform_init_date')); } if (is_int($this->config->getParameter('platform_limit_date'))) { $minDate = new \DateTime(); $minDate->setTimestamp($this->config->getParameter('platform_limit_date')); } else { $expirationDate = new \DateTime($this->config->getParameter('platform_limit_date')); } if (!$isAdmin && !in_array($event->getRequest()->get('_route'), static::PUBLIC_ROUTES) && ($minDate->getTimeStamp() > $now || $now > $expirationDate->getTimeStamp()) ) { throw new HttpException(503, 'Platform is not available.'); } } }
[ "public", "function", "checkAvailability", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "'prod'", "===", "$", "this", "->", "kernel", "->", "getEnvironment", "(", ")", "&&", "$", "event", "->", "isMasterRequest", "(", ")", ")", "{", "$", "...
Checks the app availability before displaying the platform. - Checks are enabled only on productions. - Administrators are always granted. - Public routes are still accessible. @DI\Observe("kernel.request") @param GetResponseEvent $event
[ "Checks", "the", "app", "availability", "before", "displaying", "the", "platform", ".", "-", "Checks", "are", "enabled", "only", "on", "productions", ".", "-", "Administrators", "are", "always", "granted", ".", "-", "Public", "routes", "are", "still", "accessi...
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/PlatformListener.php#L115-L152
40,620
claroline/Distribution
plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php
OpenQuestionSerializer.serialize
public function serialize(OpenQuestion $openQuestion, array $options = []) { $serialized = [ 'contentType' => 'text', 'maxLength' => $openQuestion->getAnswerMaxLength(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = []; } return $serialized; }
php
public function serialize(OpenQuestion $openQuestion, array $options = []) { $serialized = [ 'contentType' => 'text', 'maxLength' => $openQuestion->getAnswerMaxLength(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = []; } return $serialized; }
[ "public", "function", "serialize", "(", "OpenQuestion", "$", "openQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'contentType'", "=>", "'text'", ",", "'maxLength'", "=>", "$", "openQuestion", "->", "getAnswerM...
Converts a Open question into a JSON-encodable structure. @param OpenQuestion $openQuestion @param array $options @return array
[ "Converts", "a", "Open", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php#L26-L38
40,621
claroline/Distribution
plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php
OpenQuestionSerializer.deserialize
public function deserialize($data, OpenQuestion $openQuestion = null, array $options = []) { if (empty($openQuestion)) { $openQuestion = new OpenQuestion(); } $this->sipe('maxLength', 'setAnswerMaxLength', $data, $openQuestion); return $openQuestion; }
php
public function deserialize($data, OpenQuestion $openQuestion = null, array $options = []) { if (empty($openQuestion)) { $openQuestion = new OpenQuestion(); } $this->sipe('maxLength', 'setAnswerMaxLength', $data, $openQuestion); return $openQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "OpenQuestion", "$", "openQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "openQuestion", ")", ")", "{", "$", "openQuestion", "=", ...
Converts raw data into an Open question entity. @param array $data @param OpenQuestion $openQuestion @param array $options @return OpenQuestion
[ "Converts", "raw", "data", "into", "an", "Open", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OpenQuestionSerializer.php#L49-L57
40,622
claroline/Distribution
main/core/Listener/Administration/AppearanceListener.php
AppearanceListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $iconSets = $this->iconSetManager->listIconSetsByType(IconSetTypeEnum::RESOURCE_ICON_SET); // TODO : do it front side $iconSetChoices = []; foreach ($iconSets as $set) { $iconSetChoices[$set->getName()] = $set->getName(); } $content = $this->templating->render( 'ClarolineCoreBundle:administration:appearance.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'iconSetChoices' => $iconSetChoices, ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $iconSets = $this->iconSetManager->listIconSetsByType(IconSetTypeEnum::RESOURCE_ICON_SET); // TODO : do it front side $iconSetChoices = []; foreach ($iconSets as $set) { $iconSetChoices[$set->getName()] = $set->getName(); } $content = $this->templating->render( 'ClarolineCoreBundle:administration:appearance.html.twig', [ 'context' => [ 'type' => Tool::ADMINISTRATION, ], 'parameters' => $this->serializer->serialize(), 'iconSetChoices' => $iconSetChoices, ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "iconSets", "=", "$", "this", "->", "iconSetManager", "->", "listIconSetsByType", "(", "IconSetTypeEnum", "::", "RESOURCE_ICON_SET", ")", ";", "// TODO : do it fron...
Displays appearance administration tool. @DI\Observe("administration_tool_appearance_settings") @param OpenAdministrationToolEvent $event
[ "Displays", "appearance", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/AppearanceListener.php#L74-L96
40,623
claroline/Distribution
main/core/Event/User/DecorateUserEvent.php
DecorateUserEvent.add
public function add($key, $data) { $this->validate($key, $data); $this->injectedData[$key] = $data; }
php
public function add($key, $data) { $this->validate($key, $data); $this->injectedData[$key] = $data; }
[ "public", "function", "add", "(", "$", "key", ",", "$", "data", ")", "{", "$", "this", "->", "validate", "(", "$", "key", ",", "$", "data", ")", ";", "$", "this", "->", "injectedData", "[", "$", "key", "]", "=", "$", "data", ";", "}" ]
Adds custom data to the resource node. @param string $key @param mixed $data
[ "Adds", "custom", "data", "to", "the", "resource", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/User/DecorateUserEvent.php#L87-L92
40,624
claroline/Distribution
main/core/Event/User/DecorateUserEvent.php
DecorateUserEvent.validate
private function validate($key, $data) { // validates key if (in_array($key, $this->unauthorizedKeys)) { throw new \RuntimeException( 'Injected key `'.$key.'` is not authorized. (Unauthorized keys: '.implode(', ', $this->unauthorizedKeys).')' ); } if (in_array($key, array_keys($this->injectedData))) { throw new \RuntimeException( 'Injected key `'.$key.'` is already used.' ); } // validates data (must be serializable) if (false !== $data && false === json_encode($data)) { throw new \RuntimeException( 'Injected data is not serializable.' ); } }
php
private function validate($key, $data) { // validates key if (in_array($key, $this->unauthorizedKeys)) { throw new \RuntimeException( 'Injected key `'.$key.'` is not authorized. (Unauthorized keys: '.implode(', ', $this->unauthorizedKeys).')' ); } if (in_array($key, array_keys($this->injectedData))) { throw new \RuntimeException( 'Injected key `'.$key.'` is already used.' ); } // validates data (must be serializable) if (false !== $data && false === json_encode($data)) { throw new \RuntimeException( 'Injected data is not serializable.' ); } }
[ "private", "function", "validate", "(", "$", "key", ",", "$", "data", ")", "{", "// validates key", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "unauthorizedKeys", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Inject...
Validates injected data. @param string $key @param mixed $data
[ "Validates", "injected", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/User/DecorateUserEvent.php#L100-L121
40,625
claroline/Distribution
main/migration/Twig/SqlFormatterExtension.php
SqlFormatterExtension.formatSql
public function formatSql($sql, $tabOffset = 3) { $tab = Formatter::$tab; $indent = ''; for ($i = 0; $i < $tabOffset; ++$i) { $indent .= $tab; } $sql = explode("\n", Formatter::format($sql, false)); $indentedLines = array(); foreach ($sql as $line) { $indentedLines[] = $indent.str_replace('"', '\"', $line); } return implode("\n", $indentedLines); }
php
public function formatSql($sql, $tabOffset = 3) { $tab = Formatter::$tab; $indent = ''; for ($i = 0; $i < $tabOffset; ++$i) { $indent .= $tab; } $sql = explode("\n", Formatter::format($sql, false)); $indentedLines = array(); foreach ($sql as $line) { $indentedLines[] = $indent.str_replace('"', '\"', $line); } return implode("\n", $indentedLines); }
[ "public", "function", "formatSql", "(", "$", "sql", ",", "$", "tabOffset", "=", "3", ")", "{", "$", "tab", "=", "Formatter", "::", "$", "tab", ";", "$", "indent", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "tabOf...
Formats an SQL query using the SqlFormatter library. @param string $sql @param int $tabOffset @return string
[ "Formats", "an", "SQL", "query", "using", "the", "SqlFormatter", "library", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/migration/Twig/SqlFormatterExtension.php#L66-L83
40,626
claroline/Distribution
plugin/exo/Manager/Attempt/AnswerManager.php
AnswerManager.update
public function update(Item $question, Answer $answer, array $answerData, $noFlush = false) { $errors = $this->validator->validate($answerData, [Validation::QUESTION => $question->getInteraction()]); if (count($errors) > 0) { throw new InvalidDataException('Answer is not valid', $errors); } // Update Answer with new data $this->serializer->deserialize($answerData, $answer); // Save to DB $this->om->persist($answer); if (!$noFlush) { $this->om->flush(); } return $answer; }
php
public function update(Item $question, Answer $answer, array $answerData, $noFlush = false) { $errors = $this->validator->validate($answerData, [Validation::QUESTION => $question->getInteraction()]); if (count($errors) > 0) { throw new InvalidDataException('Answer is not valid', $errors); } // Update Answer with new data $this->serializer->deserialize($answerData, $answer); // Save to DB $this->om->persist($answer); if (!$noFlush) { $this->om->flush(); } return $answer; }
[ "public", "function", "update", "(", "Item", "$", "question", ",", "Answer", "$", "answer", ",", "array", "$", "answerData", ",", "$", "noFlush", "=", "false", ")", "{", "$", "errors", "=", "$", "this", "->", "validator", "->", "validate", "(", "$", ...
Validates and updates an Answer entity with raw data. @param Item $question @param Answer $answer @param array $answerData @param bool $noFlush @return Answer @throws InvalidDataException
[ "Validates", "and", "updates", "an", "Answer", "entity", "with", "raw", "data", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/AnswerManager.php#L86-L104
40,627
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findMaximumRights
public function findMaximumRights(array $roles, ResourceNode $resource) { //add the role anonymous for everyone ! if (!in_array('ROLE_ANONYMOUS', $roles)) { $roles[] = 'ROLE_ANONYMOUS'; } $dql = ' SELECT rrw.mask FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rrw JOIN rrw.role role JOIN rrw.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = {$resource->getId()} AND role.name = :role{$key}"; ++$index; } $query = $this->_em->createQuery($dql); foreach ($roles as $key => $role) { $query->setParameter("role{$key}", $role); } $results = $query->getResult(); $mask = 0; foreach ($results as $result) { $mask |= $result['mask']; } return $mask; }
php
public function findMaximumRights(array $roles, ResourceNode $resource) { //add the role anonymous for everyone ! if (!in_array('ROLE_ANONYMOUS', $roles)) { $roles[] = 'ROLE_ANONYMOUS'; } $dql = ' SELECT rrw.mask FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rrw JOIN rrw.role role JOIN rrw.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = {$resource->getId()} AND role.name = :role{$key}"; ++$index; } $query = $this->_em->createQuery($dql); foreach ($roles as $key => $role) { $query->setParameter("role{$key}", $role); } $results = $query->getResult(); $mask = 0; foreach ($results as $result) { $mask |= $result['mask']; } return $mask; }
[ "public", "function", "findMaximumRights", "(", "array", "$", "roles", ",", "ResourceNode", "$", "resource", ")", "{", "//add the role anonymous for everyone !", "if", "(", "!", "in_array", "(", "'ROLE_ANONYMOUS'", ",", "$", "roles", ")", ")", "{", "$", "roles",...
Returns the maximum rights on a given resource for a set of roles. Used by the ResourceVoter. @param array[string] $rights @param ResourceNode $resource @return array
[ "Returns", "the", "maximum", "rights", "on", "a", "given", "resource", "for", "a", "set", "of", "roles", ".", "Used", "by", "the", "ResourceVoter", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L30-L66
40,628
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findCreationRights
public function findCreationRights(array $roles, ResourceNode $node) { if (0 === count($roles)) { throw new \RuntimeException('Roles cannot be empty'); } $dql = ' SELECT DISTINCT rType.name FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType JOIN rType.rights right JOIN right.role role JOIN right.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = :nodeId AND role.name = :role_{$key}"; ++$index; } $query = $this->_em->createQuery($dql); $query->setParameter('nodeId', $node->getId()); foreach ($roles as $key => $role) { $query->setParameter('role_'.$key, $role); } return $query->getArrayResult(); }
php
public function findCreationRights(array $roles, ResourceNode $node) { if (0 === count($roles)) { throw new \RuntimeException('Roles cannot be empty'); } $dql = ' SELECT DISTINCT rType.name FROM Claroline\CoreBundle\Entity\Resource\ResourceType AS rType JOIN rType.rights right JOIN right.role role JOIN right.resourceNode resource WHERE '; $index = 0; foreach ($roles as $key => $role) { $dql .= 0 !== $index ? ' OR ' : ''; $dql .= "resource.id = :nodeId AND role.name = :role_{$key}"; ++$index; } $query = $this->_em->createQuery($dql); $query->setParameter('nodeId', $node->getId()); foreach ($roles as $key => $role) { $query->setParameter('role_'.$key, $role); } return $query->getArrayResult(); }
[ "public", "function", "findCreationRights", "(", "array", "$", "roles", ",", "ResourceNode", "$", "node", ")", "{", "if", "(", "0", "===", "count", "(", "$", "roles", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Roles cannot be empty'", ...
Returns the resource types a set of roles is allowed to create in a given directory. @param array $roles @param ResourceNode $node @return array
[ "Returns", "the", "resource", "types", "a", "set", "of", "roles", "is", "allowed", "to", "create", "in", "a", "given", "directory", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L77-L107
40,629
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findRecursiveByResource
public function findRecursiveByResource(ResourceNode $resource) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); return $query->getResult(); }
php
public function findRecursiveByResource(ResourceNode $resource) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); return $query->getResult(); }
[ "public", "function", "findRecursiveByResource", "(", "ResourceNode", "$", "resource", ")", "{", "$", "dql", "=", "\"\n SELECT rights, role, resource\n FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceRights rights\n JOIN rights.resourceNode resource\n ...
Returns all the resource rights of a resource and its descendants. @param ResourceNode $resource @return array[ResourceRights]
[ "Returns", "all", "the", "resource", "rights", "of", "a", "resource", "and", "its", "descendants", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L145-L159
40,630
claroline/Distribution
main/core/Repository/ResourceRightsRepository.php
ResourceRightsRepository.findRecursiveByResourceAndRole
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path AND role.name = :roleName "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); $query->setParameter('roleName', $role->getName()); return $query->getResult(); }
php
public function findRecursiveByResourceAndRole(ResourceNode $resource, Role $role) { $dql = " SELECT rights, role, resource FROM Claroline\CoreBundle\Entity\Resource\ResourceRights rights JOIN rights.resourceNode resource JOIN rights.role role WHERE resource.path LIKE :path AND role.name = :roleName "; $query = $this->_em->createQuery($dql); $query->setParameter('path', $resource->getPath().'%'); $query->setParameter('roleName', $role->getName()); return $query->getResult(); }
[ "public", "function", "findRecursiveByResourceAndRole", "(", "ResourceNode", "$", "resource", ",", "Role", "$", "role", ")", "{", "$", "dql", "=", "\"\n SELECT rights, role, resource\n FROM Claroline\\CoreBundle\\Entity\\Resource\\ResourceRights rights\n ...
Find ResourceRights for each descendant of a resource for a role. @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $resource @param \Claroline\CoreBundle\Entity\Role $role @return array
[ "Find", "ResourceRights", "for", "each", "descendant", "of", "a", "resource", "for", "a", "role", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceRightsRepository.php#L169-L184
40,631
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.addRow
public function addRow(GridRow $row) { if (!$this->rows->contains($row)) { $this->rows->add($row); $row->setQuestion($this); } }
php
public function addRow(GridRow $row) { if (!$this->rows->contains($row)) { $this->rows->add($row); $row->setQuestion($this); } }
[ "public", "function", "addRow", "(", "GridRow", "$", "row", ")", "{", "if", "(", "!", "$", "this", "->", "rows", "->", "contains", "(", "$", "row", ")", ")", "{", "$", "this", "->", "rows", "->", "add", "(", "$", "row", ")", ";", "$", "row", ...
Add row. @param GridRow $row
[ "Add", "row", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L145-L151
40,632
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.removeRow
public function removeRow(GridRow $row) { if ($this->rows->contains($row)) { $this->rows->removeElement($row); } }
php
public function removeRow(GridRow $row) { if ($this->rows->contains($row)) { $this->rows->removeElement($row); } }
[ "public", "function", "removeRow", "(", "GridRow", "$", "row", ")", "{", "if", "(", "$", "this", "->", "rows", "->", "contains", "(", "$", "row", ")", ")", "{", "$", "this", "->", "rows", "->", "removeElement", "(", "$", "row", ")", ";", "}", "}"...
Remove row. @param GridRow $row
[ "Remove", "row", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L158-L163
40,633
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.getOddItem
public function getOddItem($uuid) { $found = null; foreach ($this->oddItems as $oddItem) { if ($oddItem->getItem()->getUuid() === $uuid) { $found = $oddItem; break; } } return $found; }
php
public function getOddItem($uuid) { $found = null; foreach ($this->oddItems as $oddItem) { if ($oddItem->getItem()->getUuid() === $uuid) { $found = $oddItem; break; } } return $found; }
[ "public", "function", "getOddItem", "(", "$", "uuid", ")", "{", "$", "found", "=", "null", ";", "foreach", "(", "$", "this", "->", "oddItems", "as", "$", "oddItem", ")", "{", "if", "(", "$", "oddItem", "->", "getItem", "(", ")", "->", "getUuid", "(...
Get an odd item by its uuid. @param $uuid @return GridOdd|null
[ "Get", "an", "odd", "item", "by", "its", "uuid", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L182-L193
40,634
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.addOddItem
public function addOddItem(GridOdd $gridOdd) { if (!$this->oddItems->contains($gridOdd)) { $this->oddItems->add($gridOdd); $gridOdd->setQuestion($this); } }
php
public function addOddItem(GridOdd $gridOdd) { if (!$this->oddItems->contains($gridOdd)) { $this->oddItems->add($gridOdd); $gridOdd->setQuestion($this); } }
[ "public", "function", "addOddItem", "(", "GridOdd", "$", "gridOdd", ")", "{", "if", "(", "!", "$", "this", "->", "oddItems", "->", "contains", "(", "$", "gridOdd", ")", ")", "{", "$", "this", "->", "oddItems", "->", "add", "(", "$", "gridOdd", ")", ...
Add odd item. @param GridOdd $gridOdd
[ "Add", "odd", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L200-L206
40,635
claroline/Distribution
plugin/exo/Entity/ItemType/PairQuestion.php
PairQuestion.removeOddItem
public function removeOddItem(GridOdd $gridOdd) { if ($this->oddItems->contains($gridOdd)) { $this->oddItems->removeElement($gridOdd); } }
php
public function removeOddItem(GridOdd $gridOdd) { if ($this->oddItems->contains($gridOdd)) { $this->oddItems->removeElement($gridOdd); } }
[ "public", "function", "removeOddItem", "(", "GridOdd", "$", "gridOdd", ")", "{", "if", "(", "$", "this", "->", "oddItems", "->", "contains", "(", "$", "gridOdd", ")", ")", "{", "$", "this", "->", "oddItems", "->", "removeElement", "(", "$", "gridOdd", ...
Remove odd item. @param GridOdd $gridOdd
[ "Remove", "odd", "item", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/ItemType/PairQuestion.php#L213-L218
40,636
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.getAll
public function getAll(User $user) { return array_map(function ($dashboard) { return $this->exportDashboard($dashboard); }, $this->getRepository()->findBy(['creator' => $user])); }
php
public function getAll(User $user) { return array_map(function ($dashboard) { return $this->exportDashboard($dashboard); }, $this->getRepository()->findBy(['creator' => $user])); }
[ "public", "function", "getAll", "(", "User", "$", "user", ")", "{", "return", "array_map", "(", "function", "(", "$", "dashboard", ")", "{", "return", "$", "this", "->", "exportDashboard", "(", "$", "dashboard", ")", ";", "}", ",", "$", "this", "->", ...
get all dashboards for a given user.
[ "get", "all", "dashboards", "for", "a", "given", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L49-L54
40,637
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.create
public function create(User $user, $data) { $dashboard = new Dashboard(); $dashboard->setCreator($user); $dashboard->setName($data['name']); $wId = $data['workspace']['id']; $dashboard->setWorkspace($this->workspaceManager->getWorkspaceById($wId)); $this->em->persist($dashboard); $this->em->flush(); return $this->exportDashboard($dashboard); }
php
public function create(User $user, $data) { $dashboard = new Dashboard(); $dashboard->setCreator($user); $dashboard->setName($data['name']); $wId = $data['workspace']['id']; $dashboard->setWorkspace($this->workspaceManager->getWorkspaceById($wId)); $this->em->persist($dashboard); $this->em->flush(); return $this->exportDashboard($dashboard); }
[ "public", "function", "create", "(", "User", "$", "user", ",", "$", "data", ")", "{", "$", "dashboard", "=", "new", "Dashboard", "(", ")", ";", "$", "dashboard", "->", "setCreator", "(", "$", "user", ")", ";", "$", "dashboard", "->", "setName", "(", ...
create a dashboard.
[ "create", "a", "dashboard", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L59-L70
40,638
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.delete
public function delete(Dashboard $dashboard) { $this->em->remove($dashboard); $this->em->flush(); }
php
public function delete(Dashboard $dashboard) { $this->em->remove($dashboard); $this->em->flush(); }
[ "public", "function", "delete", "(", "Dashboard", "$", "dashboard", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "dashboard", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
delete a dashboard.
[ "delete", "a", "dashboard", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L86-L90
40,639
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.getDashboardWorkspaceSpentTimes
public function getDashboardWorkspaceSpentTimes(Workspace $workspace, User $user, $all = false) { $datas = []; // user(s) concerned by the query if ($all) { // get all users involved in the workspace $ids = $this->getWorkspaceUsersIds($workspace); } else { // only the current user $ids[] = $user->getId(); } // for each user (ie user ids) -> get first 'workspace-enter' event for the given workspace foreach ($ids as $uid) { $userSqlSelect = 'SELECT first_name, last_name FROM claro_user WHERE id = :uid'; $userSqlSelectStmt = $this->em->getConnection()->prepare($userSqlSelect); $userSqlSelectStmt->bindValue('uid', $uid); $userSqlSelectStmt->execute(); $userData = $userSqlSelectStmt->fetch(); // select first "workspace-enter" actions for the given user and workspace $selectEnterEventOnThisWorkspace = "SELECT DISTINCT date_log FROM claro_log WHERE workspace_id = :wid AND action = 'workspace-enter' AND doer_id = :uid ORDER BY date_log ASC LIMIT 1"; $selectEnterEventOnThisWorkspaceStmt = $this->em->getConnection()->prepare($selectEnterEventOnThisWorkspace); $selectEnterEventOnThisWorkspaceStmt->bindValue('uid', $uid); $selectEnterEventOnThisWorkspaceStmt->bindValue('wid', $workspace->getId()); $selectEnterEventOnThisWorkspaceStmt->execute(); $enterOnThisWorksapceDateResult = $selectEnterEventOnThisWorkspaceStmt->fetch(); $refDate = $enterOnThisWorksapceDateResult['date_log']; $total = 0; if ($refDate) { $total = $this->computeTimeForUserAndWorkspace($refDate, $uid, $workspace->getId(), 0); } $datas[] = [ 'user' => [ 'id' => $uid, 'firstName' => $userData['first_name'], 'lastName' => $userData['last_name'], ], 'time' => $total, ]; } return $datas; }
php
public function getDashboardWorkspaceSpentTimes(Workspace $workspace, User $user, $all = false) { $datas = []; // user(s) concerned by the query if ($all) { // get all users involved in the workspace $ids = $this->getWorkspaceUsersIds($workspace); } else { // only the current user $ids[] = $user->getId(); } // for each user (ie user ids) -> get first 'workspace-enter' event for the given workspace foreach ($ids as $uid) { $userSqlSelect = 'SELECT first_name, last_name FROM claro_user WHERE id = :uid'; $userSqlSelectStmt = $this->em->getConnection()->prepare($userSqlSelect); $userSqlSelectStmt->bindValue('uid', $uid); $userSqlSelectStmt->execute(); $userData = $userSqlSelectStmt->fetch(); // select first "workspace-enter" actions for the given user and workspace $selectEnterEventOnThisWorkspace = "SELECT DISTINCT date_log FROM claro_log WHERE workspace_id = :wid AND action = 'workspace-enter' AND doer_id = :uid ORDER BY date_log ASC LIMIT 1"; $selectEnterEventOnThisWorkspaceStmt = $this->em->getConnection()->prepare($selectEnterEventOnThisWorkspace); $selectEnterEventOnThisWorkspaceStmt->bindValue('uid', $uid); $selectEnterEventOnThisWorkspaceStmt->bindValue('wid', $workspace->getId()); $selectEnterEventOnThisWorkspaceStmt->execute(); $enterOnThisWorksapceDateResult = $selectEnterEventOnThisWorkspaceStmt->fetch(); $refDate = $enterOnThisWorksapceDateResult['date_log']; $total = 0; if ($refDate) { $total = $this->computeTimeForUserAndWorkspace($refDate, $uid, $workspace->getId(), 0); } $datas[] = [ 'user' => [ 'id' => $uid, 'firstName' => $userData['first_name'], 'lastName' => $userData['last_name'], ], 'time' => $total, ]; } return $datas; }
[ "public", "function", "getDashboardWorkspaceSpentTimes", "(", "Workspace", "$", "workspace", ",", "User", "$", "user", ",", "$", "all", "=", "false", ")", "{", "$", "datas", "=", "[", "]", ";", "// user(s) concerned by the query", "if", "(", "$", "all", ")",...
Compute spent time for each user in a given workspace.
[ "Compute", "spent", "time", "for", "each", "user", "in", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L95-L140
40,640
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.getWorkspaceUsersIds
private function getWorkspaceUsersIds(Workspace $workspace) { // Select all user(s) belonging to the target workspace (manager and collaborators)... $selectUsersIds = 'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr.id = cur.role_id WHERE cr.workspace_id = :wid'; $idStmt = $this->em->getConnection()->prepare($selectUsersIds); $idStmt->bindValue('wid', $workspace->getId()); $idStmt->execute(); $idResults = $idStmt->fetchAll(); foreach ($idResults as $result) { $ids[] = $result['user_id']; } return $ids; }
php
private function getWorkspaceUsersIds(Workspace $workspace) { // Select all user(s) belonging to the target workspace (manager and collaborators)... $selectUsersIds = 'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr.id = cur.role_id WHERE cr.workspace_id = :wid'; $idStmt = $this->em->getConnection()->prepare($selectUsersIds); $idStmt->bindValue('wid', $workspace->getId()); $idStmt->execute(); $idResults = $idStmt->fetchAll(); foreach ($idResults as $result) { $ids[] = $result['user_id']; } return $ids; }
[ "private", "function", "getWorkspaceUsersIds", "(", "Workspace", "$", "workspace", ")", "{", "// Select all user(s) belonging to the target workspace (manager and collaborators)...", "$", "selectUsersIds", "=", "'SELECT DISTINCT cur.user_id FROM claro_user_role cur JOIN claro_role cr ON cr...
Get all ids from users related to a given workspace.
[ "Get", "all", "ids", "from", "users", "related", "to", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L145-L158
40,641
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.computeTimeForUserAndWorkspace
private function computeTimeForUserAndWorkspace($startDate, $userId, $workspaceId, $time) { // select first "out of this workspace event" (ie "workspace enter" on another workspace) $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $startDate); $stmt->execute(); $action = $stmt->fetch(); // if there is an action we can compute time if ($action['date_log']) { $t1 = strtotime($startDate); $t2 = strtotime($action['date_log']); $seconds = $t2 - $t1; // add time only if bewteen 30s and 2 hours <= totally arbitrary ! if ($seconds > 5 && ($seconds / 60) <= 120) { $time += $seconds; } // get next "enter the requested workspace enter event" $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog AND workspace_id = :wid ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $action['date_log']); $stmt->bindValue('wid', $workspaceId); $stmt->execute(); $nextEnterEvent = $stmt->fetch(); // if there is an "enter-workspace" action after the current one recall the method if ($nextEnterEvent['date_log']) { return $this->computeTimeForUserAndWorkspace($nextEnterEvent['date_log'], $userId, $workspaceId, $time); } else { return $time; } } return $time; }
php
private function computeTimeForUserAndWorkspace($startDate, $userId, $workspaceId, $time) { // select first "out of this workspace event" (ie "workspace enter" on another workspace) $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $startDate); $stmt->execute(); $action = $stmt->fetch(); // if there is an action we can compute time if ($action['date_log']) { $t1 = strtotime($startDate); $t2 = strtotime($action['date_log']); $seconds = $t2 - $t1; // add time only if bewteen 30s and 2 hours <= totally arbitrary ! if ($seconds > 5 && ($seconds / 60) <= 120) { $time += $seconds; } // get next "enter the requested workspace enter event" $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog AND workspace_id = :wid ORDER BY date_log ASC LIMIT 1"; $stmt = $this->em->getConnection()->prepare($sql); $stmt->bindValue('uid', $userId); $stmt->bindValue('dateLog', $action['date_log']); $stmt->bindValue('wid', $workspaceId); $stmt->execute(); $nextEnterEvent = $stmt->fetch(); // if there is an "enter-workspace" action after the current one recall the method if ($nextEnterEvent['date_log']) { return $this->computeTimeForUserAndWorkspace($nextEnterEvent['date_log'], $userId, $workspaceId, $time); } else { return $time; } } return $time; }
[ "private", "function", "computeTimeForUserAndWorkspace", "(", "$", "startDate", ",", "$", "userId", ",", "$", "workspaceId", ",", "$", "time", ")", "{", "// select first \"out of this workspace event\" (ie \"workspace enter\" on another workspace)", "$", "sql", "=", "\"SELE...
Search for out and in events on a given wokspace, for a given user and relativly to a date.
[ "Search", "for", "out", "and", "in", "events", "on", "a", "given", "wokspace", "for", "a", "given", "user", "and", "relativly", "to", "a", "date", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L163-L200
40,642
claroline/Distribution
plugin/dashboard/Manager/DashboardManager.php
DashboardManager.exportDashboard
public function exportDashboard(Dashboard $dashboard) { return [ 'id' => $dashboard->getId(), 'creatorId' => $dashboard->getCreator()->getId(), 'name' => $dashboard->getName(), 'workspace' => $this->workspaceManager->exportWorkspace($dashboard->getWorkspace()), ]; }
php
public function exportDashboard(Dashboard $dashboard) { return [ 'id' => $dashboard->getId(), 'creatorId' => $dashboard->getCreator()->getId(), 'name' => $dashboard->getName(), 'workspace' => $this->workspaceManager->exportWorkspace($dashboard->getWorkspace()), ]; }
[ "public", "function", "exportDashboard", "(", "Dashboard", "$", "dashboard", ")", "{", "return", "[", "'id'", "=>", "$", "dashboard", "->", "getId", "(", ")", ",", "'creatorId'", "=>", "$", "dashboard", "->", "getCreator", "(", ")", "->", "getId", "(", "...
Export dashboard as array.
[ "Export", "dashboard", "as", "array", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dashboard/Manager/DashboardManager.php#L205-L213
40,643
claroline/Distribution
plugin/tag/Listener/TagListener.php
TagListener.onRetrieveUsedTagsByClassAndIds
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event) { $tags = []; $data = $event->getData(); if (is_array($data) && isset($data['class']) && !empty($data['ids'])) { /** @var TaggedObject[] $taggedObjects */ $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']); if (isset($data['frequency']) && $data['frequency']) { //array [tagName => frequency] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); if (!array_key_exists($tag->getName(), $tags)) { $tags[$tag->getName()] = 0; } ++$tags[$tag->getName()]; } } else { //array [tagName] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); $tags[$tag->getId()] = $taggedObject->getTag()->getName(); } $tags = array_values($tags); } } $event->setResponse($tags); }
php
public function onRetrieveUsedTagsByClassAndIds(GenericDataEvent $event) { $tags = []; $data = $event->getData(); if (is_array($data) && isset($data['class']) && !empty($data['ids'])) { /** @var TaggedObject[] $taggedObjects */ $taggedObjects = $this->manager->getTaggedObjects($data['class'], $data['ids']); if (isset($data['frequency']) && $data['frequency']) { //array [tagName => frequency] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); if (!array_key_exists($tag->getName(), $tags)) { $tags[$tag->getName()] = 0; } ++$tags[$tag->getName()]; } } else { //array [tagName] foreach ($taggedObjects as $taggedObject) { $tag = $taggedObject->getTag(); $tags[$tag->getId()] = $taggedObject->getTag()->getName(); } $tags = array_values($tags); } } $event->setResponse($tags); }
[ "public", "function", "onRetrieveUsedTagsByClassAndIds", "(", "GenericDataEvent", "$", "event", ")", "{", "$", "tags", "=", "[", "]", ";", "$", "data", "=", "$", "event", "->", "getData", "(", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", "&&...
Used by serializers to retrieves tags. @DI\Observe("claroline_retrieve_used_tags_by_class_and_ids") @param GenericDataEvent $event
[ "Used", "by", "serializers", "to", "retrieves", "tags", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/tag/Listener/TagListener.php#L155-L183
40,644
claroline/Distribution
main/app/JVal/Walker.php
Walker.parseSchema
public function parseSchema(\stdClass $schema, Context $context) { if ($this->isProcessed($schema, $this->parsedSchemas)) { return $schema; } $version = $this->getVersion($schema); $constraints = $this->registry->getConstraints($version); $constraints = $this->filterConstraintsForSchema($constraints, $schema); foreach ($constraints as $constraint) { $constraint->normalize($schema, $context, $this); } return $schema; }
php
public function parseSchema(\stdClass $schema, Context $context) { if ($this->isProcessed($schema, $this->parsedSchemas)) { return $schema; } $version = $this->getVersion($schema); $constraints = $this->registry->getConstraints($version); $constraints = $this->filterConstraintsForSchema($constraints, $schema); foreach ($constraints as $constraint) { $constraint->normalize($schema, $context, $this); } return $schema; }
[ "public", "function", "parseSchema", "(", "\\", "stdClass", "$", "schema", ",", "Context", "$", "context", ")", "{", "if", "(", "$", "this", "->", "isProcessed", "(", "$", "schema", ",", "$", "this", "->", "parsedSchemas", ")", ")", "{", "return", "$",...
Recursively normalizes a given schema and validates its syntax. @param stdClass $schema @param Context $context @return stdClass
[ "Recursively", "normalizes", "a", "given", "schema", "and", "validates", "its", "syntax", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Walker.php#L143-L158
40,645
claroline/Distribution
main/app/JVal/Walker.php
Walker.getVersion
private function getVersion(stdClass $schema) { return property_exists($schema, '$schema') && is_string($schema->{'$schema'}) ? $schema->{'$schema'} : Registry::VERSION_CURRENT; }
php
private function getVersion(stdClass $schema) { return property_exists($schema, '$schema') && is_string($schema->{'$schema'}) ? $schema->{'$schema'} : Registry::VERSION_CURRENT; }
[ "private", "function", "getVersion", "(", "stdClass", "$", "schema", ")", "{", "return", "property_exists", "(", "$", "schema", ",", "'$schema'", ")", "&&", "is_string", "(", "$", "schema", "->", "{", "'$schema'", "}", ")", "?", "$", "schema", "->", "{",...
Returns the version of a schema. @param stdClass $schema @return string
[ "Returns", "the", "version", "of", "a", "schema", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/JVal/Walker.php#L212-L217
40,646
claroline/Distribution
plugin/website/Controller/Controller.php
Controller.getLoggedUser
protected function getLoggedUser() { $user = $this->get('security.token_storage')->getToken()->getUser(); if (is_string($user)) { $user = null; } return $user; }
php
protected function getLoggedUser() { $user = $this->get('security.token_storage')->getToken()->getUser(); if (is_string($user)) { $user = null; } return $user; }
[ "protected", "function", "getLoggedUser", "(", ")", "{", "$", "user", "=", "$", "this", "->", "get", "(", "'security.token_storage'", ")", "->", "getToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "is_string", "(", "$", "user", ")", ")", ...
Retrieve logged user. If anonymous return null. @return user
[ "Retrieve", "logged", "user", ".", "If", "anonymous", "return", "null", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/website/Controller/Controller.php#L88-L96
40,647
claroline/Distribution
main/core/Listener/Administration/HomeListener.php
HomeListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $tabs = $this->finder->search( HomeTab::class, ['filters' => ['type' => HomeTab::TYPE_ADMIN_DESKTOP]] ); $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $roles = $this->finder->search('Claroline\CoreBundle\Entity\Role', ['filters' => ['type' => Role::PLATFORM_ROLE]] ); $content = $this->templating->render( 'ClarolineCoreBundle:administration:home.html.twig', [ 'editable' => true, 'administration' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, 'data' => [ 'roles' => $roles['data'], ], ], 'tabs' => array_values($orderedTabs), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $tabs = $this->finder->search( HomeTab::class, ['filters' => ['type' => HomeTab::TYPE_ADMIN_DESKTOP]] ); $tabs = array_filter($tabs['data'], function ($data) { return $data !== []; }); foreach ($tabs as $tab) { $orderedTabs[$tab['position']] = $tab; } ksort($orderedTabs); $roles = $this->finder->search('Claroline\CoreBundle\Entity\Role', ['filters' => ['type' => Role::PLATFORM_ROLE]] ); $content = $this->templating->render( 'ClarolineCoreBundle:administration:home.html.twig', [ 'editable' => true, 'administration' => true, 'context' => [ 'type' => Widget::CONTEXT_DESKTOP, 'data' => [ 'roles' => $roles['data'], ], ], 'tabs' => array_values($orderedTabs), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "tabs", "=", "$", "this", "->", "finder", "->", "search", "(", "HomeTab", "::", "class", ",", "[", "'filters'", "=>", "[", "'type'", "=>", "HomeTab", ":...
Displays analytics administration tool. @DI\Observe("administration_tool_desktop_and_home") @param OpenAdministrationToolEvent $event
[ "Displays", "analytics", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/HomeListener.php#L51-L86
40,648
claroline/Distribution
plugin/open-badge/Serializer/EvidenceSerializer.php
EvidenceSerializer.deserialize
public function deserialize(array $data, Evidence $evidence = null, array $options = []) { $this->sipe('narrative', 'setNarrative', $data, $evidence); $this->sipe('name', 'setName', $data, $evidence); if (isset($data['resources'])) { $resources = []; foreach ($data['resources'] as $resource) { $node = $this->_om->getObject($resource, ResourceNode::class); $resources[] = $this->resourceNodeSerializer->deserialize($resource, $node); } $evidence->setResourceEvidences($resources); } }
php
public function deserialize(array $data, Evidence $evidence = null, array $options = []) { $this->sipe('narrative', 'setNarrative', $data, $evidence); $this->sipe('name', 'setName', $data, $evidence); if (isset($data['resources'])) { $resources = []; foreach ($data['resources'] as $resource) { $node = $this->_om->getObject($resource, ResourceNode::class); $resources[] = $this->resourceNodeSerializer->deserialize($resource, $node); } $evidence->setResourceEvidences($resources); } }
[ "public", "function", "deserialize", "(", "array", "$", "data", ",", "Evidence", "$", "evidence", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "sipe", "(", "'narrative'", ",", "'setNarrative'", ",", "$", "data"...
Serializes a Evidence entity. @param array $data @param Evidence $evidence @param array $options @return array
[ "Serializes", "a", "Evidence", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/open-badge/Serializer/EvidenceSerializer.php#L72-L85
40,649
claroline/Distribution
plugin/exo/Entity/Misc/GridItem.php
GridItem.getCoords
public function getCoords() { return (is_int($this->coordsX) || is_int($this->coordsY)) ? [$this->coordsX, $this->coordsY] : null; }
php
public function getCoords() { return (is_int($this->coordsX) || is_int($this->coordsY)) ? [$this->coordsX, $this->coordsY] : null; }
[ "public", "function", "getCoords", "(", ")", "{", "return", "(", "is_int", "(", "$", "this", "->", "coordsX", ")", "||", "is_int", "(", "$", "this", "->", "coordsY", ")", ")", "?", "[", "$", "this", "->", "coordsX", ",", "$", "this", "->", "coordsY...
Get coordinates. @return array
[ "Get", "coordinates", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/GridItem.php#L113-L117
40,650
claroline/Distribution
plugin/scorm/Manager/ScormManager.php
ScormManager.retrieveIntervalFromSeconds
private function retrieveIntervalFromSeconds($seconds) { $result = ''; $remainingTime = (int) $seconds; if (empty($remainingTime)) { $result .= 'PT0S'; } else { $nbDays = (int) ($remainingTime / 86400); $remainingTime %= 86400; $nbHours = (int) ($remainingTime / 3600); $remainingTime %= 3600; $nbMinutes = (int) ($remainingTime / 60); $nbSeconds = $remainingTime % 60; $result .= 'P'.$nbDays.'DT'.$nbHours.'H'.$nbMinutes.'M'.$nbSeconds.'S'; } return $result; }
php
private function retrieveIntervalFromSeconds($seconds) { $result = ''; $remainingTime = (int) $seconds; if (empty($remainingTime)) { $result .= 'PT0S'; } else { $nbDays = (int) ($remainingTime / 86400); $remainingTime %= 86400; $nbHours = (int) ($remainingTime / 3600); $remainingTime %= 3600; $nbMinutes = (int) ($remainingTime / 60); $nbSeconds = $remainingTime % 60; $result .= 'P'.$nbDays.'DT'.$nbHours.'H'.$nbMinutes.'M'.$nbSeconds.'S'; } return $result; }
[ "private", "function", "retrieveIntervalFromSeconds", "(", "$", "seconds", ")", "{", "$", "result", "=", "''", ";", "$", "remainingTime", "=", "(", "int", ")", "$", "seconds", ";", "if", "(", "empty", "(", "$", "remainingTime", ")", ")", "{", "$", "res...
Converts a time in seconds to a DateInterval string. @param int $seconds @return string
[ "Converts", "a", "time", "in", "seconds", "to", "a", "DateInterval", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Manager/ScormManager.php#L992-L1010
40,651
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.serialize
public function serialize(User $user, array $options = []) { $serialized = [ 'id' => $user->getUuid(), 'name' => trim($user->getFirstName().' '.$user->getLastName()), 'picture' => $this->serializePicture($user), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'username' => $user->getUsername(), 'publicUrl' => $user->getPublicUrl(), ]; if (!in_array(Transfer::MINIMAL, $options)) { $serialized['email'] = $user->getEmail(); } return $serialized; }
php
public function serialize(User $user, array $options = []) { $serialized = [ 'id' => $user->getUuid(), 'name' => trim($user->getFirstName().' '.$user->getLastName()), 'picture' => $this->serializePicture($user), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'username' => $user->getUsername(), 'publicUrl' => $user->getPublicUrl(), ]; if (!in_array(Transfer::MINIMAL, $options)) { $serialized['email'] = $user->getEmail(); } return $serialized; }
[ "public", "function", "serialize", "(", "User", "$", "user", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "user", "->", "getUuid", "(", ")", ",", "'name'", "=>", "trim", "(", "$", "user", ...
Converts a User into a JSON-encodable structure. @param User $user @param array $options @return array
[ "Converts", "a", "User", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L56-L73
40,652
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.deserialize
public function deserialize($data, User $user = null, array $options = []) { if (empty($user)) { /** @var User $user */ $user = $this->om->getRepository(User::class)->findOneBy(['uuid' => $data['id']]); } return $user; }
php
public function deserialize($data, User $user = null, array $options = []) { if (empty($user)) { /** @var User $user */ $user = $this->om->getRepository(User::class)->findOneBy(['uuid' => $data['id']]); } return $user; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "User", "$", "user", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "user", ")", ")", "{", "/** @var User $user */", "$", "user", "=", "$...
Converts raw data into a User entity. Note : we don't allow to update users here, so this method only returns the untouched entity instance. @param \array $data @param User $user @param array $options @return User
[ "Converts", "raw", "data", "into", "a", "User", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L86-L94
40,653
claroline/Distribution
plugin/exo/Serializer/UserSerializer.php
UserSerializer.serializePicture
private function serializePicture(User $user) { if (!empty($user->getPicture())) { /** @var PublicFile $file */ $file = $this->om ->getRepository(PublicFile::class) ->findOneBy(['url' => $user->getPicture()]); if ($file) { return $this->fileSerializer->serialize($file); } } return null; }
php
private function serializePicture(User $user) { if (!empty($user->getPicture())) { /** @var PublicFile $file */ $file = $this->om ->getRepository(PublicFile::class) ->findOneBy(['url' => $user->getPicture()]); if ($file) { return $this->fileSerializer->serialize($file); } } return null; }
[ "private", "function", "serializePicture", "(", "User", "$", "user", ")", "{", "if", "(", "!", "empty", "(", "$", "user", "->", "getPicture", "(", ")", ")", ")", "{", "/** @var PublicFile $file */", "$", "file", "=", "$", "this", "->", "om", "->", "get...
Serialize the user picture. @param User $user @return array|null
[ "Serialize", "the", "user", "picture", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/UserSerializer.php#L103-L117
40,654
claroline/Distribution
main/core/Entity/Facet/Facet.php
Facet.resetPanelFacets
public function resetPanelFacets() { foreach ($this->panelFacets as $panelFacet) { $panelFacet->setFacet(null); } $this->panelFacets = new ArrayCollection(); }
php
public function resetPanelFacets() { foreach ($this->panelFacets as $panelFacet) { $panelFacet->setFacet(null); } $this->panelFacets = new ArrayCollection(); }
[ "public", "function", "resetPanelFacets", "(", ")", "{", "foreach", "(", "$", "this", "->", "panelFacets", "as", "$", "panelFacet", ")", "{", "$", "panelFacet", "->", "setFacet", "(", "null", ")", ";", "}", "$", "this", "->", "panelFacets", "=", "new", ...
Removes all PanelFacet.
[ "Removes", "all", "PanelFacet", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Facet/Facet.php#L132-L139
40,655
claroline/Distribution
main/core/Controller/FileController.php
FileController.uploadTinyMceAction
public function uploadTinyMceAction(Request $request, User $user) { // grab and validate user submission $content = $this->decodeRequest($request); if (empty($content) || empty($content['file']) || empty($content['parent'])) { $errors = []; if (empty($content['parent'])) { $errors[] = [ 'path' => 'parent', 'message' => 'This value should not be blank.', ]; } if (empty($content['file'])) { $errors[] = [ 'path' => 'file', 'message' => 'This value should not be blank.', ]; } throw new InvalidDataException('Invalid data.', $errors); } // check user rights $parent = $this->om->getRepository(ResourceNode::class)->findOneBy(['uuid' => $content['parent']]); $this->checkPermission('CREATE', new ResourceCollection([$parent], ['type' => 'file'])); // create the new file resource $file = new File(); $file->setSize($content['file']['size']); $file->setName($content['file']['filename']); $file->setHashName($content['file']['url']); $file->setMimeType($content['file']['mimeType']); $rights = []; if (!$parent->getWorkspace()) { $rights = [ 'ROLE_ANONYMOUS' => [ 'open' => true, 'export' => true, 'create' => [], 'role' => $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), ], ]; } $file = $this->resourceManager->create( $file, $this->resourceManager->getResourceTypeByName('file'), $user, $parent->getWorkspace(), $parent, null, $rights, true ); return new JsonResponse($this->serializer->serialize($file->getResourceNode(), [Options::SERIALIZE_MINIMAL]), 201); }
php
public function uploadTinyMceAction(Request $request, User $user) { // grab and validate user submission $content = $this->decodeRequest($request); if (empty($content) || empty($content['file']) || empty($content['parent'])) { $errors = []; if (empty($content['parent'])) { $errors[] = [ 'path' => 'parent', 'message' => 'This value should not be blank.', ]; } if (empty($content['file'])) { $errors[] = [ 'path' => 'file', 'message' => 'This value should not be blank.', ]; } throw new InvalidDataException('Invalid data.', $errors); } // check user rights $parent = $this->om->getRepository(ResourceNode::class)->findOneBy(['uuid' => $content['parent']]); $this->checkPermission('CREATE', new ResourceCollection([$parent], ['type' => 'file'])); // create the new file resource $file = new File(); $file->setSize($content['file']['size']); $file->setName($content['file']['filename']); $file->setHashName($content['file']['url']); $file->setMimeType($content['file']['mimeType']); $rights = []; if (!$parent->getWorkspace()) { $rights = [ 'ROLE_ANONYMOUS' => [ 'open' => true, 'export' => true, 'create' => [], 'role' => $this->roleManager->getRoleByName('ROLE_ANONYMOUS'), ], ]; } $file = $this->resourceManager->create( $file, $this->resourceManager->getResourceTypeByName('file'), $user, $parent->getWorkspace(), $parent, null, $rights, true ); return new JsonResponse($this->serializer->serialize($file->getResourceNode(), [Options::SERIALIZE_MINIMAL]), 201); }
[ "public", "function", "uploadTinyMceAction", "(", "Request", "$", "request", ",", "User", "$", "user", ")", "{", "// grab and validate user submission", "$", "content", "=", "$", "this", "->", "decodeRequest", "(", "$", "request", ")", ";", "if", "(", "empty",...
Creates a resource from uploaded file. @EXT\Route("/tinymce/upload", name="claro_tinymce_file_upload") @EXT\ParamConverter("user", options={"authenticatedUser" = true}) @EXT\Method("POST") @param Request $request @param User $user @throws \Exception @return Response
[ "Creates", "a", "resource", "from", "uploaded", "file", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/FileController.php#L178-L234
40,656
claroline/Distribution
main/core/Controller/FileController.php
FileController.stream
private function stream(ResourceNode $resourceNode) { //temporary because otherwise injected resource must have the "open" right $this->checkPermission('OPEN', $resourceNode, [], true); // free the session as soon as possible // see https://github.com/claroline/CoreBundle/commit/7cee6de85bbc9448f86eb98af2abb1cb072c7b6b $this->session->save(); /** @var File $file */ $file = $this->resourceManager->getResourceFromNode($resourceNode); $path = $this->fileDir.DIRECTORY_SEPARATOR.$file->getHashName(); if (!file_exists($path)) { return new JsonResponse(['File not found'], 500); } $response = new BinaryFileResponse($path); $response->headers->set('Content-Type', $resourceNode->getMimeType()); return $response; }
php
private function stream(ResourceNode $resourceNode) { //temporary because otherwise injected resource must have the "open" right $this->checkPermission('OPEN', $resourceNode, [], true); // free the session as soon as possible // see https://github.com/claroline/CoreBundle/commit/7cee6de85bbc9448f86eb98af2abb1cb072c7b6b $this->session->save(); /** @var File $file */ $file = $this->resourceManager->getResourceFromNode($resourceNode); $path = $this->fileDir.DIRECTORY_SEPARATOR.$file->getHashName(); if (!file_exists($path)) { return new JsonResponse(['File not found'], 500); } $response = new BinaryFileResponse($path); $response->headers->set('Content-Type', $resourceNode->getMimeType()); return $response; }
[ "private", "function", "stream", "(", "ResourceNode", "$", "resourceNode", ")", "{", "//temporary because otherwise injected resource must have the \"open\" right", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "resourceNode", ",", "[", "]", ",", "true"...
Streams a resource file to the user browser. @param ResourceNode $resourceNode @return BinaryFileResponse
[ "Streams", "a", "resource", "file", "to", "the", "user", "browser", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/FileController.php#L279-L300
40,657
claroline/Distribution
main/core/Controller/LayoutController.php
LayoutController.footerAction
public function footerAction() { // TODO: find the lightest way to get that information $version = $this->get('claroline.manager.version_manager')->getDistributionVersion(); $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $selfRegistration = $this->configHandler->getParameter('allow_self_registration') && $this->roleManager->validateRoleInsert(new User(), $roleUser); return $this->render('ClarolineCoreBundle:layout:footer.html.twig', [ 'footerMessage' => $this->configHandler->getParameter('footer'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), 'coreVersion' => $version, 'selfRegistration' => $selfRegistration, ]); }
php
public function footerAction() { // TODO: find the lightest way to get that information $version = $this->get('claroline.manager.version_manager')->getDistributionVersion(); $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $selfRegistration = $this->configHandler->getParameter('allow_self_registration') && $this->roleManager->validateRoleInsert(new User(), $roleUser); return $this->render('ClarolineCoreBundle:layout:footer.html.twig', [ 'footerMessage' => $this->configHandler->getParameter('footer'), 'footerLogin' => $this->configHandler->getParameter('footer_login'), 'footerWorkspaces' => $this->configHandler->getParameter('footer_workspaces'), 'headerLocale' => $this->configHandler->getParameter('header_locale'), 'coreVersion' => $version, 'selfRegistration' => $selfRegistration, ]); }
[ "public", "function", "footerAction", "(", ")", "{", "// TODO: find the lightest way to get that information", "$", "version", "=", "$", "this", "->", "get", "(", "'claroline.manager.version_manager'", ")", "->", "getDistributionVersion", "(", ")", ";", "$", "roleUser",...
Renders the platform footer. @return Response
[ "Renders", "the", "platform", "footer", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LayoutController.php#L265-L282
40,658
claroline/Distribution
main/core/Controller/LayoutController.php
LayoutController.renderWarningImpersonationAction
public function renderWarningImpersonationAction() { $token = $this->tokenStorage->getToken(); $roles = $this->utils->getRoles($token); $impersonatedRole = null; $isRoleImpersonated = false; $workspaceName = ''; $roleName = ''; foreach ($roles as $role) { if (strstr($role, 'ROLE_USURPATE_WORKSPACE_ROLE')) { $isRoleImpersonated = true; } } if ($isRoleImpersonated) { foreach ($roles as $role) { if (strstr($role, 'ROLE_WS')) { $impersonatedRole = $role; } } if (null === $impersonatedRole) { $roleName = 'ROLE_ANONYMOUS'; } else { $guid = substr($impersonatedRole, strripos($impersonatedRole, '_') + 1); $workspace = $this->workspaceManager->getOneByGuid($guid); $roleEntity = $this->roleManager->getRoleByName($impersonatedRole); $roleName = $roleEntity->getTranslationKey(); if ($workspace) { $workspaceName = $workspace->getName(); } } } return $this->render('ClarolineCoreBundle:layout:render_warning_impersonation.html.twig', [ 'isImpersonated' => $this->isImpersonated(), 'workspace' => $workspaceName, 'role' => $roleName, ]); }
php
public function renderWarningImpersonationAction() { $token = $this->tokenStorage->getToken(); $roles = $this->utils->getRoles($token); $impersonatedRole = null; $isRoleImpersonated = false; $workspaceName = ''; $roleName = ''; foreach ($roles as $role) { if (strstr($role, 'ROLE_USURPATE_WORKSPACE_ROLE')) { $isRoleImpersonated = true; } } if ($isRoleImpersonated) { foreach ($roles as $role) { if (strstr($role, 'ROLE_WS')) { $impersonatedRole = $role; } } if (null === $impersonatedRole) { $roleName = 'ROLE_ANONYMOUS'; } else { $guid = substr($impersonatedRole, strripos($impersonatedRole, '_') + 1); $workspace = $this->workspaceManager->getOneByGuid($guid); $roleEntity = $this->roleManager->getRoleByName($impersonatedRole); $roleName = $roleEntity->getTranslationKey(); if ($workspace) { $workspaceName = $workspace->getName(); } } } return $this->render('ClarolineCoreBundle:layout:render_warning_impersonation.html.twig', [ 'isImpersonated' => $this->isImpersonated(), 'workspace' => $workspaceName, 'role' => $roleName, ]); }
[ "public", "function", "renderWarningImpersonationAction", "(", ")", "{", "$", "token", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ";", "$", "roles", "=", "$", "this", "->", "utils", "->", "getRoles", "(", "$", "token", ")", ";", ...
Renders the warning bar when a workspace role is impersonated. @return Response
[ "Renders", "the", "warning", "bar", "when", "a", "workspace", "role", "is", "impersonated", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LayoutController.php#L289-L329
40,659
claroline/Distribution
plugin/exo/Entity/Misc/Cell.php
Cell.setChoices
public function setChoices(array $choices) { // Removes old choices $oldChoices = array_filter($this->choices->toArray(), function (CellChoice $choice) use ($choices) { return !in_array($choice, $choices); }); array_walk($oldChoices, function (CellChoice $choice) { $this->removeChoice($choice); }); // Adds new ones array_walk($choices, function (CellChoice $choice) { $this->addChoice($choice); }); }
php
public function setChoices(array $choices) { // Removes old choices $oldChoices = array_filter($this->choices->toArray(), function (CellChoice $choice) use ($choices) { return !in_array($choice, $choices); }); array_walk($oldChoices, function (CellChoice $choice) { $this->removeChoice($choice); }); // Adds new ones array_walk($choices, function (CellChoice $choice) { $this->addChoice($choice); }); }
[ "public", "function", "setChoices", "(", "array", "$", "choices", ")", "{", "// Removes old choices", "$", "oldChoices", "=", "array_filter", "(", "$", "this", "->", "choices", "->", "toArray", "(", ")", ",", "function", "(", "CellChoice", "$", "choice", ")"...
Sets choices collection. @param array $choices
[ "Sets", "choices", "collection", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Cell.php#L300-L314
40,660
claroline/Distribution
plugin/exo/Entity/Misc/Cell.php
Cell.getChoice
public function getChoice($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->choices as $choice) { /** @var CellChoice $choice */ $tmpText = trim($choice->getText()); if ($tmpText === $text || ( !$choice->isCaseSensitive() && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $choice; break; } } return $found; }
php
public function getChoice($text) { $found = null; $text = trim($text); $iText = strtoupper(TextNormalizer::stripDiacritics($text)); foreach ($this->choices as $choice) { /** @var CellChoice $choice */ $tmpText = trim($choice->getText()); if ($tmpText === $text || ( !$choice->isCaseSensitive() && strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText) ) { $found = $choice; break; } } return $found; }
[ "public", "function", "getChoice", "(", "$", "text", ")", "{", "$", "found", "=", "null", ";", "$", "text", "=", "trim", "(", "$", "text", ")", ";", "$", "iText", "=", "strtoupper", "(", "TextNormalizer", "::", "stripDiacritics", "(", "$", "text", ")...
Get a cell choice by text. @param string $text @return Cell|null
[ "Get", "a", "cell", "choice", "by", "text", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Entity/Misc/Cell.php#L344-L363
40,661
claroline/Distribution
plugin/exo/Manager/Attempt/ScoreManager.php
ScoreManager.applyPenalties
public function applyPenalties($score, CorrectedAnswer $correctedAnswer) { $penalties = $correctedAnswer->getPenalties(); foreach ($penalties as $penalty) { $score -= $penalty->getPenalty(); } return $score; }
php
public function applyPenalties($score, CorrectedAnswer $correctedAnswer) { $penalties = $correctedAnswer->getPenalties(); foreach ($penalties as $penalty) { $score -= $penalty->getPenalty(); } return $score; }
[ "public", "function", "applyPenalties", "(", "$", "score", ",", "CorrectedAnswer", "$", "correctedAnswer", ")", "{", "$", "penalties", "=", "$", "correctedAnswer", "->", "getPenalties", "(", ")", ";", "foreach", "(", "$", "penalties", "as", "$", "penalty", "...
Applies hint penalties to a score. @param float $score @param CorrectedAnswer $correctedAnswer @return float
[ "Applies", "hint", "penalties", "to", "a", "score", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Attempt/ScoreManager.php#L214-L222
40,662
claroline/Distribution
main/core/Repository/RevisionRepository.php
RevisionRepository.getLastRevision
public function getLastRevision(Text $text) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Resource\Revision r JOIN r.text t2 WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\CoreBundle\Entity\Resource\Revision r2 JOIN r2.text t WHERE t.id = {$text->getId()}) and t2.id = {$text->getId()} "; $query = $this->_em->createQuery($dql); return $query->getSingleResult(); }
php
public function getLastRevision(Text $text) { $dql = " SELECT r FROM Claroline\CoreBundle\Entity\Resource\Revision r JOIN r.text t2 WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\CoreBundle\Entity\Resource\Revision r2 JOIN r2.text t WHERE t.id = {$text->getId()}) and t2.id = {$text->getId()} "; $query = $this->_em->createQuery($dql); return $query->getSingleResult(); }
[ "public", "function", "getLastRevision", "(", "Text", "$", "text", ")", "{", "$", "dql", "=", "\"\n SELECT r FROM Claroline\\CoreBundle\\Entity\\Resource\\Revision r\n JOIN r.text t2\n WHERE r.version = (SELECT MAX(r2.version) FROM Claroline\\CoreBundle\\Enti...
Returns the last revision of a text. @param Text $text @return Revision
[ "Returns", "the", "last", "revision", "of", "a", "text", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/RevisionRepository.php#L26-L38
40,663
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.removeMask
public function removeMask(ResourceType $resourceType, $name) { $toRemove = $this->getDecoder($resourceType, $name); if (!empty($toRemove)) { $this->om->remove($toRemove); } }
php
public function removeMask(ResourceType $resourceType, $name) { $toRemove = $this->getDecoder($resourceType, $name); if (!empty($toRemove)) { $this->om->remove($toRemove); } }
[ "public", "function", "removeMask", "(", "ResourceType", "$", "resourceType", ",", "$", "name", ")", "{", "$", "toRemove", "=", "$", "this", "->", "getDecoder", "(", "$", "resourceType", ",", "$", "name", ")", ";", "if", "(", "!", "empty", "(", "$", ...
Retrieves and removes a mask decoder. @param ResourceType $resourceType @param string $name
[ "Retrieves", "and", "removes", "a", "mask", "decoder", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L165-L171
40,664
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.renameMask
public function renameMask(ResourceType $resourceType, $currentName, $newName) { $toRename = $this->getDecoder($resourceType, $currentName); if (!empty($toRename)) { $toRename->setName($newName); $this->om->persist($toRename); } }
php
public function renameMask(ResourceType $resourceType, $currentName, $newName) { $toRename = $this->getDecoder($resourceType, $currentName); if (!empty($toRename)) { $toRename->setName($newName); $this->om->persist($toRename); } }
[ "public", "function", "renameMask", "(", "ResourceType", "$", "resourceType", ",", "$", "currentName", ",", "$", "newName", ")", "{", "$", "toRename", "=", "$", "this", "->", "getDecoder", "(", "$", "resourceType", ",", "$", "currentName", ")", ";", "if", ...
Retrieves and renames a mask decoder. @param ResourceType $resourceType @param string $currentName @param string $newName
[ "Retrieves", "and", "renames", "a", "mask", "decoder", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L180-L187
40,665
claroline/Distribution
main/core/Manager/Resource/MaskManager.php
MaskManager.getPermissionMap
public function getPermissionMap(ResourceType $type) { /** @var MaskDecoder[] $decoders */ $decoders = $this->maskRepo->findBy(['resourceType' => $type]); $permsMap = []; foreach ($decoders as $decoder) { $permsMap[$decoder->getValue()] = $decoder->getName(); } return $permsMap; }
php
public function getPermissionMap(ResourceType $type) { /** @var MaskDecoder[] $decoders */ $decoders = $this->maskRepo->findBy(['resourceType' => $type]); $permsMap = []; foreach ($decoders as $decoder) { $permsMap[$decoder->getValue()] = $decoder->getName(); } return $permsMap; }
[ "public", "function", "getPermissionMap", "(", "ResourceType", "$", "type", ")", "{", "/** @var MaskDecoder[] $decoders */", "$", "decoders", "=", "$", "this", "->", "maskRepo", "->", "findBy", "(", "[", "'resourceType'", "=>", "$", "type", "]", ")", ";", "$",...
Returns an array containing the possible permission for a resource type. @param ResourceType $type @return array
[ "Returns", "an", "array", "containing", "the", "possible", "permission", "for", "a", "resource", "type", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Resource/MaskManager.php#L196-L207
40,666
claroline/Distribution
plugin/team/Serializer/WorkspaceTeamParametersSerializer.php
WorkspaceTeamParametersSerializer.serialize
public function serialize(WorkspaceTeamParameters $parameters) { $serialized = [ 'id' => $parameters->getUuid(), 'selfRegistration' => $parameters->isSelfRegistration(), 'selfUnregistration' => $parameters->isSelfUnregistration(), 'publicDirectory' => $parameters->isPublic(), 'deletableDirectory' => $parameters->isDirDeletable(), 'allowedTeams' => $parameters->getMaxTeams(), 'workspace' => [ 'uuid' => $parameters->getWorkspace()->getUuid(), ], ]; return $serialized; }
php
public function serialize(WorkspaceTeamParameters $parameters) { $serialized = [ 'id' => $parameters->getUuid(), 'selfRegistration' => $parameters->isSelfRegistration(), 'selfUnregistration' => $parameters->isSelfUnregistration(), 'publicDirectory' => $parameters->isPublic(), 'deletableDirectory' => $parameters->isDirDeletable(), 'allowedTeams' => $parameters->getMaxTeams(), 'workspace' => [ 'uuid' => $parameters->getWorkspace()->getUuid(), ], ]; return $serialized; }
[ "public", "function", "serialize", "(", "WorkspaceTeamParameters", "$", "parameters", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "parameters", "->", "getUuid", "(", ")", ",", "'selfRegistration'", "=>", "$", "parameters", "->", "isSelfRegistration...
Serializes a WorkspaceTeamParameters entity for the JSON api. @param WorkspaceTeamParameters $parameters @return array - the serialized representation of the WorkspaceTeamParameters entity
[ "Serializes", "a", "WorkspaceTeamParameters", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/team/Serializer/WorkspaceTeamParametersSerializer.php#L45-L60
40,667
claroline/Distribution
main/installation/Manager/InstallationManager.php
InstallationManager.end
public function end(InstallableInterface $bundle, $currentVersion = null, $targetVersion = null) { $additionalInstaller = $this->getAdditionalInstaller($bundle); if ($additionalInstaller) { $additionalInstaller->end($currentVersion, $targetVersion); } }
php
public function end(InstallableInterface $bundle, $currentVersion = null, $targetVersion = null) { $additionalInstaller = $this->getAdditionalInstaller($bundle); if ($additionalInstaller) { $additionalInstaller->end($currentVersion, $targetVersion); } }
[ "public", "function", "end", "(", "InstallableInterface", "$", "bundle", ",", "$", "currentVersion", "=", "null", ",", "$", "targetVersion", "=", "null", ")", "{", "$", "additionalInstaller", "=", "$", "this", "->", "getAdditionalInstaller", "(", "$", "bundle"...
It allows us to override some stuff and it's just easier that way.
[ "It", "allows", "us", "to", "override", "some", "stuff", "and", "it", "s", "just", "easier", "that", "way", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/installation/Manager/InstallationManager.php#L140-L147
40,668
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.retrieveTag
protected function retrieveTag($name) { $tag = $this->objectManager->getRepository('IcapBlogBundle:Tag')->findOneByName($name); if (!$tag) { //let's look if it's scheduled for an Insert... $tag = $this->getTagFromIdentityMapOrScheduledForInsert($name); if (!$tag) { $tag = new Tag(); $tag->setName($name); $this->objectManager->persist($tag); } } return $tag; }
php
protected function retrieveTag($name) { $tag = $this->objectManager->getRepository('IcapBlogBundle:Tag')->findOneByName($name); if (!$tag) { //let's look if it's scheduled for an Insert... $tag = $this->getTagFromIdentityMapOrScheduledForInsert($name); if (!$tag) { $tag = new Tag(); $tag->setName($name); $this->objectManager->persist($tag); } } return $tag; }
[ "protected", "function", "retrieveTag", "(", "$", "name", ")", "{", "$", "tag", "=", "$", "this", "->", "objectManager", "->", "getRepository", "(", "'IcapBlogBundle:Tag'", ")", "->", "findOneByName", "(", "$", "name", ")", ";", "if", "(", "!", "$", "tag...
This method is used by the workspace import function. @param string $name @return Tag
[ "This", "method", "is", "used", "by", "the", "workspace", "import", "function", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L315-L331
40,669
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.getBlogByIdOrUuid
public function getBlogByIdOrUuid($id) { if (preg_match('/^\d+$/', $id)) { $blog = $this->repo->findOneBy([ 'id' => $id, ]); } else { $blog = $this->repo->findOneBy([ 'uuid' => $id, ]); } return $blog; }
php
public function getBlogByIdOrUuid($id) { if (preg_match('/^\d+$/', $id)) { $blog = $this->repo->findOneBy([ 'id' => $id, ]); } else { $blog = $this->repo->findOneBy([ 'uuid' => $id, ]); } return $blog; }
[ "public", "function", "getBlogByIdOrUuid", "(", "$", "id", ")", "{", "if", "(", "preg_match", "(", "'/^\\d+$/'", ",", "$", "id", ")", ")", "{", "$", "blog", "=", "$", "this", "->", "repo", "->", "findOneBy", "(", "[", "'id'", "=>", "$", "id", ",", ...
Get blog by its ID or UUID. @param string $id @return Blog
[ "Get", "blog", "by", "its", "ID", "or", "UUID", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L455-L468
40,670
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.getTags
public function getTags($blog, array $postData = []) { $postUuids = array_column($postData, 'id'); $event = new GenericDataEvent([ 'class' => 'Icap\BlogBundle\Entity\Post', 'ids' => $postUuids, 'frequency' => true, ]); $this->eventDispatcher->dispatch( 'claroline_retrieve_used_tags_by_class_and_ids', $event ); $tags = $event->getResponse(); //only keep max tag number, if defined if ($blog->getOptions()->isTagTopMode() && $blog->getOptions()->getMaxTag() > 0) { arsort($tags); $tags = array_slice($tags, 0, $blog->getOptions()->getMaxTag()); } return (object) $tags; }
php
public function getTags($blog, array $postData = []) { $postUuids = array_column($postData, 'id'); $event = new GenericDataEvent([ 'class' => 'Icap\BlogBundle\Entity\Post', 'ids' => $postUuids, 'frequency' => true, ]); $this->eventDispatcher->dispatch( 'claroline_retrieve_used_tags_by_class_and_ids', $event ); $tags = $event->getResponse(); //only keep max tag number, if defined if ($blog->getOptions()->isTagTopMode() && $blog->getOptions()->getMaxTag() > 0) { arsort($tags); $tags = array_slice($tags, 0, $blog->getOptions()->getMaxTag()); } return (object) $tags; }
[ "public", "function", "getTags", "(", "$", "blog", ",", "array", "$", "postData", "=", "[", "]", ")", "{", "$", "postUuids", "=", "array_column", "(", "$", "postData", ",", "'id'", ")", ";", "$", "event", "=", "new", "GenericDataEvent", "(", "[", "'c...
Get tags used in the blog. @param Blog $blog @param array $posts @return array
[ "Get", "tags", "used", "in", "the", "blog", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L478-L501
40,671
claroline/Distribution
plugin/blog/Manager/BlogManager.php
BlogManager.replaceMemberAuthor
public function replaceMemberAuthor(User $from, User $to) { $fromIsMember = false; $froms = $this->memberRepo->findByUser($from); if (count($froms) > 0) { $fromIsMember = true; } $toIsMember = false; $tos = $this->memberRepo->findByUser($to); if (count($tos) > 0) { $toIsMember = true; } if ($toIsMember && $fromIsMember) { //user kept already have its member entry, delete the old one foreach ($froms as $member) { $this->objectManager->remove($member); } $this->objectManager->flush(); } elseif (!$toIsMember && $fromIsMember) { //update entry for kept user foreach ($froms as $member) { $member->setUser($to); } $this->objectManager->flush(); } }
php
public function replaceMemberAuthor(User $from, User $to) { $fromIsMember = false; $froms = $this->memberRepo->findByUser($from); if (count($froms) > 0) { $fromIsMember = true; } $toIsMember = false; $tos = $this->memberRepo->findByUser($to); if (count($tos) > 0) { $toIsMember = true; } if ($toIsMember && $fromIsMember) { //user kept already have its member entry, delete the old one foreach ($froms as $member) { $this->objectManager->remove($member); } $this->objectManager->flush(); } elseif (!$toIsMember && $fromIsMember) { //update entry for kept user foreach ($froms as $member) { $member->setUser($to); } $this->objectManager->flush(); } }
[ "public", "function", "replaceMemberAuthor", "(", "User", "$", "from", ",", "User", "$", "to", ")", "{", "$", "fromIsMember", "=", "false", ";", "$", "froms", "=", "$", "this", "->", "memberRepo", "->", "findByUser", "(", "$", "from", ")", ";", "if", ...
Find all member for a given user and the replace him by another. @param User $from @param User $to
[ "Find", "all", "member", "for", "a", "given", "user", "and", "the", "replace", "him", "by", "another", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Manager/BlogManager.php#L509-L536
40,672
claroline/Distribution
plugin/website/Manager/WebsiteManager.php
WebsiteManager.copyWebsite
public function copyWebsite(Website $orgWebsite, Website $newWebsite) { $orgRoot = $orgWebsite->getRoot(); $orgOptions = $orgWebsite->getOptions(); $websitePages = $this->websitePageRepository->children($orgRoot); array_unshift($websitePages, $orgRoot); $newWebsitePagesMap = []; foreach ($websitePages as $websitePage) { $newWebsitePage = new WebsitePage(); $newWebsitePage->setWebsite($newWebsite); $newWebsitePage->importFromArray($websitePage->exportToArray()); if ($websitePage->isRoot()) { $newWebsite->setRoot($newWebsitePage); $this->om->persist($newWebsite); } else { $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()]; $newWebsitePage->setParent($newWebsitePageParent); $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent); } if ($websitePage->getIsHomepage()) { $newWebsite->setHomePage($newWebsitePage); } $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage; } $this->om->flush(); $newWebsite->getOptions()->importFromArray( $this->webDir, $orgOptions->exportToArray($this->webDir), $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir() ); return $newWebsite; }
php
public function copyWebsite(Website $orgWebsite, Website $newWebsite) { $orgRoot = $orgWebsite->getRoot(); $orgOptions = $orgWebsite->getOptions(); $websitePages = $this->websitePageRepository->children($orgRoot); array_unshift($websitePages, $orgRoot); $newWebsitePagesMap = []; foreach ($websitePages as $websitePage) { $newWebsitePage = new WebsitePage(); $newWebsitePage->setWebsite($newWebsite); $newWebsitePage->importFromArray($websitePage->exportToArray()); if ($websitePage->isRoot()) { $newWebsite->setRoot($newWebsitePage); $this->om->persist($newWebsite); } else { $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()]; $newWebsitePage->setParent($newWebsitePageParent); $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent); } if ($websitePage->getIsHomepage()) { $newWebsite->setHomePage($newWebsitePage); } $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage; } $this->om->flush(); $newWebsite->getOptions()->importFromArray( $this->webDir, $orgOptions->exportToArray($this->webDir), $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir() ); return $newWebsite; }
[ "public", "function", "copyWebsite", "(", "Website", "$", "orgWebsite", ",", "Website", "$", "newWebsite", ")", "{", "$", "orgRoot", "=", "$", "orgWebsite", "->", "getRoot", "(", ")", ";", "$", "orgOptions", "=", "$", "orgWebsite", "->", "getOptions", "(",...
Copies website to a location. @param Website $orgWebsite @return Website
[ "Copies", "website", "to", "a", "location", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/website/Manager/WebsiteManager.php#L79-L113
40,673
claroline/Distribution
main/core/API/Serializer/User/OrganizationSerializer.php
OrganizationSerializer.serialize
public function serialize(Organization $organization, array $options = []) { $data = [ 'id' => $organization->getUuid(), 'name' => $organization->getName(), 'code' => $organization->getCode(), 'email' => $organization->getEmail(), 'type' => $organization->getType(), 'parent' => !empty($organization->getParent()) ? [ 'id' => $organization->getParent()->getUuid(), 'name' => $organization->getParent()->getName(), ] : null, 'meta' => [ 'default' => $organization->getDefault(), 'position' => $organization->getPosition(), ], 'managers' => array_map(function (User $administrator) { return [ 'id' => $administrator->getId(), 'username' => $administrator->getUsername(), ]; }, $organization->getAdministrators()->toArray()), 'locations' => array_map(function (Location $location) { return [ 'id' => $location->getId(), 'name' => $location->getName(), ]; }, $organization->getLocations()->toArray()), ]; if (in_array(Options::IS_RECURSIVE, $options)) { $data['children'] = array_map(function (Organization $child) use ($options) { return $this->serialize($child, $options); }, $organization->getChildren()->toArray()); } return $data; }
php
public function serialize(Organization $organization, array $options = []) { $data = [ 'id' => $organization->getUuid(), 'name' => $organization->getName(), 'code' => $organization->getCode(), 'email' => $organization->getEmail(), 'type' => $organization->getType(), 'parent' => !empty($organization->getParent()) ? [ 'id' => $organization->getParent()->getUuid(), 'name' => $organization->getParent()->getName(), ] : null, 'meta' => [ 'default' => $organization->getDefault(), 'position' => $organization->getPosition(), ], 'managers' => array_map(function (User $administrator) { return [ 'id' => $administrator->getId(), 'username' => $administrator->getUsername(), ]; }, $organization->getAdministrators()->toArray()), 'locations' => array_map(function (Location $location) { return [ 'id' => $location->getId(), 'name' => $location->getName(), ]; }, $organization->getLocations()->toArray()), ]; if (in_array(Options::IS_RECURSIVE, $options)) { $data['children'] = array_map(function (Organization $child) use ($options) { return $this->serialize($child, $options); }, $organization->getChildren()->toArray()); } return $data; }
[ "public", "function", "serialize", "(", "Organization", "$", "organization", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'id'", "=>", "$", "organization", "->", "getUuid", "(", ")", ",", "'name'", "=>", "$", "organiza...
Serializes an Organization entity for the JSON api. @param Organization $organization - the organization to serialize @param array $options @return array - the serialized representation of the workspace
[ "Serializes", "an", "Organization", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/User/OrganizationSerializer.php#L46-L83
40,674
claroline/Distribution
plugin/wiki/Entity/Section.php
Section.setNewActiveContributionToSection
public function setNewActiveContributionToSection(User $user = null) { $oldActiveContribution = $this->getActiveContribution(); $newActiveContribution = new Contribution(); $newActiveContribution->setSection($this); if (null === $oldActiveContribution) { if (null === $user) { $user = $this->getAuthor(); } } else { if (null === $user) { $user = $oldActiveContribution->getContributor(); } if (null === $user) { $user = $this->getAuthor(); } $newActiveContribution->setTitle($oldActiveContribution->getTitle()); $newActiveContribution->setText($oldActiveContribution->getText()); } $newActiveContribution->setContributor($user); $this->setActiveContribution($newActiveContribution); }
php
public function setNewActiveContributionToSection(User $user = null) { $oldActiveContribution = $this->getActiveContribution(); $newActiveContribution = new Contribution(); $newActiveContribution->setSection($this); if (null === $oldActiveContribution) { if (null === $user) { $user = $this->getAuthor(); } } else { if (null === $user) { $user = $oldActiveContribution->getContributor(); } if (null === $user) { $user = $this->getAuthor(); } $newActiveContribution->setTitle($oldActiveContribution->getTitle()); $newActiveContribution->setText($oldActiveContribution->getText()); } $newActiveContribution->setContributor($user); $this->setActiveContribution($newActiveContribution); }
[ "public", "function", "setNewActiveContributionToSection", "(", "User", "$", "user", "=", "null", ")", "{", "$", "oldActiveContribution", "=", "$", "this", "->", "getActiveContribution", "(", ")", ";", "$", "newActiveContribution", "=", "new", "Contribution", "(",...
Creates a new non persisted contribution and sets it as section's active contribution. @param \Claroline\CoreBundle\Entity\User $user
[ "Creates", "a", "new", "non", "persisted", "contribution", "and", "sets", "it", "as", "section", "s", "active", "contribution", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/wiki/Entity/Section.php#L453-L474
40,675
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.serialize
public function serialize(ClozeQuestion $clozeQuestion, array $options = []) { $serialized = [ 'text' => $clozeQuestion->getText(), 'holes' => $this->serializeHoles($clozeQuestion), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($clozeQuestion, $options); } return $serialized; }
php
public function serialize(ClozeQuestion $clozeQuestion, array $options = []) { $serialized = [ 'text' => $clozeQuestion->getText(), 'holes' => $this->serializeHoles($clozeQuestion), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['solutions'] = $this->serializeSolutions($clozeQuestion, $options); } return $serialized; }
[ "public", "function", "serialize", "(", "ClozeQuestion", "$", "clozeQuestion", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'text'", "=>", "$", "clozeQuestion", "->", "getText", "(", ")", ",", "'holes'", "=>", "$",...
Converts a Cloze question into a JSON-encodable structure. @param ClozeQuestion $clozeQuestion @param array $options @return array
[ "Converts", "a", "Cloze", "question", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L48-L60
40,676
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserialize
public function deserialize($data, ClozeQuestion $clozeQuestion = null, array $options = []) { if (empty($clozeQuestion)) { $clozeQuestion = new ClozeQuestion(); } $this->sipe('text', 'setText', $data, $clozeQuestion); $this->deserializeHoles($clozeQuestion, $data['holes'], $data['solutions'], $options); return $clozeQuestion; }
php
public function deserialize($data, ClozeQuestion $clozeQuestion = null, array $options = []) { if (empty($clozeQuestion)) { $clozeQuestion = new ClozeQuestion(); } $this->sipe('text', 'setText', $data, $clozeQuestion); $this->deserializeHoles($clozeQuestion, $data['holes'], $data['solutions'], $options); return $clozeQuestion; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ClozeQuestion", "$", "clozeQuestion", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "clozeQuestion", ")", ")", "{", "$", "clozeQuestion", "...
Converts raw data into a Cloze question entity. @param array $data @param ClozeQuestion $clozeQuestion @param array $options @return ClozeQuestion
[ "Converts", "raw", "data", "into", "a", "Cloze", "question", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L71-L81
40,677
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserializeHoles
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = []) { $holeEntities = $clozeQuestion->getHoles()->toArray(); foreach ($holes as $holeData) { $hole = null; // Searches for an existing hole entity. foreach ($holeEntities as $entityIndex => $entityHole) { /** @var Hole $entityHole */ if ($entityHole->getUuid() === $holeData['id']) { $hole = $entityHole; unset($holeEntities[$entityIndex]); break; } } $hole = $hole ?: new Hole(); $hole->setUuid($holeData['id']); if (!empty($holeData['size'])) { $hole->setSize($holeData['size']); } if (!empty($holeData['choices'])) { $hole->setSelector(true); } else { $hole->setSelector(false); } foreach ($solutions as $solution) { if ($solution['holeId'] === $holeData['id']) { $this->deserializeHoleKeywords($hole, $solution['answers'], $options); break; } } $clozeQuestion->addHole($hole); } // Remaining holes are no longer in the Question foreach ($holeEntities as $holeToRemove) { $clozeQuestion->removeHole($holeToRemove); } }
php
private function deserializeHoles(ClozeQuestion $clozeQuestion, array $holes, array $solutions, array $options = []) { $holeEntities = $clozeQuestion->getHoles()->toArray(); foreach ($holes as $holeData) { $hole = null; // Searches for an existing hole entity. foreach ($holeEntities as $entityIndex => $entityHole) { /** @var Hole $entityHole */ if ($entityHole->getUuid() === $holeData['id']) { $hole = $entityHole; unset($holeEntities[$entityIndex]); break; } } $hole = $hole ?: new Hole(); $hole->setUuid($holeData['id']); if (!empty($holeData['size'])) { $hole->setSize($holeData['size']); } if (!empty($holeData['choices'])) { $hole->setSelector(true); } else { $hole->setSelector(false); } foreach ($solutions as $solution) { if ($solution['holeId'] === $holeData['id']) { $this->deserializeHoleKeywords($hole, $solution['answers'], $options); break; } } $clozeQuestion->addHole($hole); } // Remaining holes are no longer in the Question foreach ($holeEntities as $holeToRemove) { $clozeQuestion->removeHole($holeToRemove); } }
[ "private", "function", "deserializeHoles", "(", "ClozeQuestion", "$", "clozeQuestion", ",", "array", "$", "holes", ",", "array", "$", "solutions", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "holeEntities", "=", "$", "clozeQuestion", "->", ...
Deserializes Question holes. @param ClozeQuestion $clozeQuestion @param array $holes @param array $solutions @param array $options
[ "Deserializes", "Question", "holes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L122-L167
40,678
claroline/Distribution
plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php
ClozeQuestionSerializer.deserializeHoleKeywords
private function deserializeHoleKeywords(Hole $hole, array $keywords, array $options = []) { $updatedKeywords = $this->keywordSerializer->deserializeCollection($keywords, $hole->getKeywords()->toArray(), $options); $hole->setKeywords($updatedKeywords); }
php
private function deserializeHoleKeywords(Hole $hole, array $keywords, array $options = []) { $updatedKeywords = $this->keywordSerializer->deserializeCollection($keywords, $hole->getKeywords()->toArray(), $options); $hole->setKeywords($updatedKeywords); }
[ "private", "function", "deserializeHoleKeywords", "(", "Hole", "$", "hole", ",", "array", "$", "keywords", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "updatedKeywords", "=", "$", "this", "->", "keywordSerializer", "->", "deserializeCollection"...
Deserializes the keywords of a Hole. @param Hole $hole @param array $keywords @param array $options
[ "Deserializes", "the", "keywords", "of", "a", "Hole", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/ClozeQuestionSerializer.php#L176-L180
40,679
claroline/Distribution
plugin/exo/Library/Item/Definition/GraphicDefinition.php
GraphicDefinition.refreshIdentifiers
public function refreshIdentifiers(AbstractItem $item) { // generate image id $item->getImage()->refreshUuid(); /** @var Area $area */ foreach ($item->getAreas() as $area) { $area->refreshUuid(); } }
php
public function refreshIdentifiers(AbstractItem $item) { // generate image id $item->getImage()->refreshUuid(); /** @var Area $area */ foreach ($item->getAreas() as $area) { $area->refreshUuid(); } }
[ "public", "function", "refreshIdentifiers", "(", "AbstractItem", "$", "item", ")", "{", "// generate image id", "$", "item", "->", "getImage", "(", ")", "->", "refreshUuid", "(", ")", ";", "/** @var Area $area */", "foreach", "(", "$", "item", "->", "getAreas", ...
Refreshes image and areas UUIDs. @param GraphicQuestion $item
[ "Refreshes", "image", "and", "areas", "UUIDs", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/GraphicDefinition.php#L191-L200
40,680
claroline/Distribution
main/core/Controller/APINew/Resource/LogController.php
LogController.getResourceNodeFilteredQuery
private function getResourceNodeFilteredQuery(Request $request, ResourceNode $node) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['resourceNode' => $node]); return $query; }
php
private function getResourceNodeFilteredQuery(Request $request, ResourceNode $node) { $query = $request->query->all(); $hiddenFilters = isset($query['hiddenFilters']) ? $query['hiddenFilters'] : []; $query['hiddenFilters'] = array_merge($hiddenFilters, ['resourceNode' => $node]); return $query; }
[ "private", "function", "getResourceNodeFilteredQuery", "(", "Request", "$", "request", ",", "ResourceNode", "$", "node", ")", "{", "$", "query", "=", "$", "request", "->", "query", "->", "all", "(", ")", ";", "$", "hiddenFilters", "=", "isset", "(", "$", ...
Add resource node filter to request. @param Request $request @param ResourceNode $node @return array
[ "Add", "resource", "node", "filter", "to", "request", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/Resource/LogController.php#L236-L243
40,681
claroline/Distribution
main/core/Form/DataTransformer/DateRangeToTextTransformer.php
DateRangeToTextTransformer.reverseTransform
public function reverseTransform($string) { $startDate = time(); $endDate = time(); $separator = $this->translator->trans('date_range.separator', array(), 'platform'); if ($string != null) { $array = explode(' '.$separator.' ', $string); if (array_key_exists(0, $array)) { $dateFormat = $this->translator->trans('date_range.format', array(), 'platform'); $startDate = $endDate = \DateTime::createFromFormat($dateFormat, $array[0])->getTimestamp(); if (array_key_exists(1, $array)) { $endDate = \DateTime::createFromFormat($dateFormat, $array[1])->getTimestamp(); } } return array($startDate, $endDate); } }
php
public function reverseTransform($string) { $startDate = time(); $endDate = time(); $separator = $this->translator->trans('date_range.separator', array(), 'platform'); if ($string != null) { $array = explode(' '.$separator.' ', $string); if (array_key_exists(0, $array)) { $dateFormat = $this->translator->trans('date_range.format', array(), 'platform'); $startDate = $endDate = \DateTime::createFromFormat($dateFormat, $array[0])->getTimestamp(); if (array_key_exists(1, $array)) { $endDate = \DateTime::createFromFormat($dateFormat, $array[1])->getTimestamp(); } } return array($startDate, $endDate); } }
[ "public", "function", "reverseTransform", "(", "$", "string", ")", "{", "$", "startDate", "=", "time", "(", ")", ";", "$", "endDate", "=", "time", "(", ")", ";", "$", "separator", "=", "$", "this", "->", "translator", "->", "trans", "(", "'date_range.s...
Transforms a string to an array of 2 dates. @param string $string @return array of strings (names for tags)
[ "Transforms", "a", "string", "to", "an", "array", "of", "2", "dates", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Form/DataTransformer/DateRangeToTextTransformer.php#L62-L82
40,682
claroline/Distribution
main/core/Controller/LocaleController.php
LocaleController.changeAction
public function changeAction(Request $request, $locale) { if (($token = $this->tokenStorage->getToken()) && 'anon.' !== $token->getUser()) { $this->localeManager->setUserLocale($locale); } $request->setLocale($locale); $request->getSession()->set('_locale', $locale); return new RedirectResponse( $request->headers->get('referer') ); }
php
public function changeAction(Request $request, $locale) { if (($token = $this->tokenStorage->getToken()) && 'anon.' !== $token->getUser()) { $this->localeManager->setUserLocale($locale); } $request->setLocale($locale); $request->getSession()->set('_locale', $locale); return new RedirectResponse( $request->headers->get('referer') ); }
[ "public", "function", "changeAction", "(", "Request", "$", "request", ",", "$", "locale", ")", "{", "if", "(", "(", "$", "token", "=", "$", "this", "->", "tokenStorage", "->", "getToken", "(", ")", ")", "&&", "'anon.'", "!==", "$", "token", "->", "ge...
Change locale. @EXT\Route("/change/{locale}", name="claroline_locale_change") @param Request $request @param string $locale @return RedirectResponse
[ "Change", "locale", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/LocaleController.php#L75-L87
40,683
claroline/Distribution
main/app/API/Transfer/Adapter/Explain/Csv/ExplanationBuilder.php
ExplanationBuilder.explainOneOf
private function explainOneOf($data, $explanation, $currentPath, $isArray = false) { $explanation->addOneOf(array_map(function ($oneOf) use ($currentPath, $isArray) { return $this->explainSchema($oneOf, null, $currentPath, $isArray); }, $data->oneOf), 'an auto generated descr', true); }
php
private function explainOneOf($data, $explanation, $currentPath, $isArray = false) { $explanation->addOneOf(array_map(function ($oneOf) use ($currentPath, $isArray) { return $this->explainSchema($oneOf, null, $currentPath, $isArray); }, $data->oneOf), 'an auto generated descr', true); }
[ "private", "function", "explainOneOf", "(", "$", "data", ",", "$", "explanation", ",", "$", "currentPath", ",", "$", "isArray", "=", "false", ")", "{", "$", "explanation", "->", "addOneOf", "(", "array_map", "(", "function", "(", "$", "oneOf", ")", "use"...
A oneOf is simply an other schema that needs to be explained.
[ "A", "oneOf", "is", "simply", "an", "other", "schema", "that", "needs", "to", "be", "explained", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/app/API/Transfer/Adapter/Explain/Csv/ExplanationBuilder.php#L54-L59
40,684
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.createRights
public function createRights(ResourceNode $node, array $rights = [], $withDefault = true) { foreach ($rights as $data) { $resourceTypes = $this->checkResourceTypes($data['create']); $this->rightsManager->create($data, $data['role'], $node, false, $resourceTypes); } if ($withDefault) { if (!array_key_exists('ROLE_ANONYMOUS', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_ANONYMOUS']), $node, false, [] ); } if (!array_key_exists('ROLE_USER', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_USER']), $node, false, [] ); } } }
php
public function createRights(ResourceNode $node, array $rights = [], $withDefault = true) { foreach ($rights as $data) { $resourceTypes = $this->checkResourceTypes($data['create']); $this->rightsManager->create($data, $data['role'], $node, false, $resourceTypes); } if ($withDefault) { if (!array_key_exists('ROLE_ANONYMOUS', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_ANONYMOUS']), $node, false, [] ); } if (!array_key_exists('ROLE_USER', $rights)) { $this->rightsManager->create( 0, $this->roleRepo->findOneBy(['name' => 'ROLE_USER']), $node, false, [] ); } } }
[ "public", "function", "createRights", "(", "ResourceNode", "$", "node", ",", "array", "$", "rights", "=", "[", "]", ",", "$", "withDefault", "=", "true", ")", "{", "foreach", "(", "$", "rights", "as", "$", "data", ")", "{", "$", "resourceTypes", "=", ...
Create the rights for a node. array $rights should be defined that way: array('ROLE_WS_XXX' => array('open' => true, 'edit' => false, ... 'create' => array('directory', ...), 'role' => $entity)) @param \Claroline\CoreBundle\Entity\Resource\ResourceNode $node @param array $rights @param bool $withDefault
[ "Create", "the", "rights", "for", "a", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L352-L378
40,685
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.setPublishedStatus
public function setPublishedStatus(array $nodes, $arePublished, $isRecursive = false) { $this->om->startFlushSuite(); foreach ($nodes as $node) { $node->setPublished($arePublished); $this->om->persist($node); //do it on every children aswell if ($isRecursive) { $descendants = $this->resourceNodeRepo->findDescendants($node, true); $this->setPublishedStatus($descendants, $arePublished, false); } //only warn for the roots $this->dispatcher->dispatch( "publication_change_{$node->getResourceType()->getName()}", 'Resource\PublicationChange', [$this->getResourceFromNode($node)] ); $usersToNotify = $node->getWorkspace() && !$node->getWorkspace()->isDisabledNotifications() ? $this->container->get('claroline.manager.user_manager')->getUsersByWorkspaces([$node->getWorkspace()], null, null, false) : []; $this->dispatcher->dispatch('log', 'Log\LogResourcePublish', [$node, $usersToNotify]); } $this->om->endFlushSuite(); return $nodes; }
php
public function setPublishedStatus(array $nodes, $arePublished, $isRecursive = false) { $this->om->startFlushSuite(); foreach ($nodes as $node) { $node->setPublished($arePublished); $this->om->persist($node); //do it on every children aswell if ($isRecursive) { $descendants = $this->resourceNodeRepo->findDescendants($node, true); $this->setPublishedStatus($descendants, $arePublished, false); } //only warn for the roots $this->dispatcher->dispatch( "publication_change_{$node->getResourceType()->getName()}", 'Resource\PublicationChange', [$this->getResourceFromNode($node)] ); $usersToNotify = $node->getWorkspace() && !$node->getWorkspace()->isDisabledNotifications() ? $this->container->get('claroline.manager.user_manager')->getUsersByWorkspaces([$node->getWorkspace()], null, null, false) : []; $this->dispatcher->dispatch('log', 'Log\LogResourcePublish', [$node, $usersToNotify]); } $this->om->endFlushSuite(); return $nodes; }
[ "public", "function", "setPublishedStatus", "(", "array", "$", "nodes", ",", "$", "arePublished", ",", "$", "isRecursive", "=", "false", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", ...
Sets the publication flag of a collection of nodes. @param ResourceNode[] $nodes @param bool $arePublished @param bool $isRecursive @return ResourceNode[]
[ "Sets", "the", "publication", "flag", "of", "a", "collection", "of", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L599-L629
40,686
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.rename
public function rename(ResourceNode $node, $name, $noFlush = false) { $node->setName($name); $name = $this->getUniqueName($node, $node->getParent()); $node->setName($name); $this->om->persist($node); $this->logChangeSet($node); if (!$noFlush) { $this->om->flush(); } return $node; }
php
public function rename(ResourceNode $node, $name, $noFlush = false) { $node->setName($name); $name = $this->getUniqueName($node, $node->getParent()); $node->setName($name); $this->om->persist($node); $this->logChangeSet($node); if (!$noFlush) { $this->om->flush(); } return $node; }
[ "public", "function", "rename", "(", "ResourceNode", "$", "node", ",", "$", "name", ",", "$", "noFlush", "=", "false", ")", "{", "$", "node", "->", "setName", "(", "$", "name", ")", ";", "$", "name", "=", "$", "this", "->", "getUniqueName", "(", "$...
Renames a node. @param ResourceNode $node @param string $name @param bool $noFlush @return ResourceNode @deprecated
[ "Renames", "a", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L958-L971
40,687
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.addPublicFileDirectory
public function addPublicFileDirectory(Workspace $workspace) { $directory = new Directory(); $dirName = $this->translator->trans('my_public_documents', [], 'platform'); $directory->setName($dirName); $directory->setUploadDestination(true); $parent = $this->getNodeScheduledForInsert($workspace, $workspace->getName()); if (!$parent) { $parent = $this->resourceNodeRepo->findOneBy(['workspace' => $workspace->getId(), 'parent' => $parent]); } $role = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); /** @var Directory $publicDir */ $publicDir = $this->create( $directory, $this->getResourceTypeByName('directory'), $workspace->getCreator(), $workspace, $parent, null, ['ROLE_ANONYMOUS' => ['open' => true, 'export' => true, 'create' => [], 'role' => $role]], true ); return $publicDir; }
php
public function addPublicFileDirectory(Workspace $workspace) { $directory = new Directory(); $dirName = $this->translator->trans('my_public_documents', [], 'platform'); $directory->setName($dirName); $directory->setUploadDestination(true); $parent = $this->getNodeScheduledForInsert($workspace, $workspace->getName()); if (!$parent) { $parent = $this->resourceNodeRepo->findOneBy(['workspace' => $workspace->getId(), 'parent' => $parent]); } $role = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); /** @var Directory $publicDir */ $publicDir = $this->create( $directory, $this->getResourceTypeByName('directory'), $workspace->getCreator(), $workspace, $parent, null, ['ROLE_ANONYMOUS' => ['open' => true, 'export' => true, 'create' => [], 'role' => $role]], true ); return $publicDir; }
[ "public", "function", "addPublicFileDirectory", "(", "Workspace", "$", "workspace", ")", "{", "$", "directory", "=", "new", "Directory", "(", ")", ";", "$", "dirName", "=", "$", "this", "->", "translator", "->", "trans", "(", "'my_public_documents'", ",", "[...
Adds the public file directory in a workspace. @todo move in workspace manager @param Workspace $workspace @return Directory
[ "Adds", "the", "public", "file", "directory", "in", "a", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L1296-L1321
40,688
claroline/Distribution
main/core/Manager/ResourceManager.php
ResourceManager.restore
public function restore(ResourceNode $resourceNode) { $this->setActive($resourceNode); $workspace = $resourceNode->getWorkspace(); if ($workspace) { $root = $this->getWorkspaceRoot($workspace); $resourceNode->setParent($root); } $name = substr($resourceNode->getName(), 0, strrpos($resourceNode->getName(), '_')); $resourceNode->setName($name); $resourceNode->setName($this->getUniqueName($resourceNode)); $this->om->persist($resourceNode); $this->om->flush(); }
php
public function restore(ResourceNode $resourceNode) { $this->setActive($resourceNode); $workspace = $resourceNode->getWorkspace(); if ($workspace) { $root = $this->getWorkspaceRoot($workspace); $resourceNode->setParent($root); } $name = substr($resourceNode->getName(), 0, strrpos($resourceNode->getName(), '_')); $resourceNode->setName($name); $resourceNode->setName($this->getUniqueName($resourceNode)); $this->om->persist($resourceNode); $this->om->flush(); }
[ "public", "function", "restore", "(", "ResourceNode", "$", "resourceNode", ")", "{", "$", "this", "->", "setActive", "(", "$", "resourceNode", ")", ";", "$", "workspace", "=", "$", "resourceNode", "->", "getWorkspace", "(", ")", ";", "if", "(", "$", "wor...
Restores a soft deleted resource node. @param ResourceNode $resourceNode
[ "Restores", "a", "soft", "deleted", "resource", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ResourceManager.php#L1459-L1472
40,689
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.countByAbility
public function countByAbility(Ability $ability) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.ability = :ability') ->setParameter(':ability', $ability) ->getQuery() ->getSingleScalarResult(); }
php
public function countByAbility(Ability $ability) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.ability = :ability') ->setParameter(':ability', $ability) ->getQuery() ->getSingleScalarResult(); }
[ "public", "function", "countByAbility", "(", "Ability", "$", "ability", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'ca'", ")", "->", "select", "(", "'COUNT(ca)'", ")", "->", "where", "(", "'ca.ability = :ability'", ")", "->", "setParame...
Returns the number of existing associations between competencies and a given ability. @param Ability $ability @return int
[ "Returns", "the", "number", "of", "existing", "associations", "between", "competencies", "and", "a", "given", "ability", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L19-L27
40,690
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.countByCompetency
public function countByCompetency(Competency $competency) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.competency = :competency') ->setParameter(':competency', $competency) ->getQuery() ->getSingleScalarResult(); }
php
public function countByCompetency(Competency $competency) { return $this->createQueryBuilder('ca') ->select('COUNT(ca)') ->where('ca.competency = :competency') ->setParameter(':competency', $competency) ->getQuery() ->getSingleScalarResult(); }
[ "public", "function", "countByCompetency", "(", "Competency", "$", "competency", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'ca'", ")", "->", "select", "(", "'COUNT(ca)'", ")", "->", "where", "(", "'ca.competency = :competency'", ")", "->...
Returns the number of abilities associated with a given competency. @param Competency $competency @return mixed
[ "Returns", "the", "number", "of", "abilities", "associated", "with", "a", "given", "competency", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L36-L44
40,691
claroline/Distribution
plugin/competency/Repository/CompetencyAbilityRepository.php
CompetencyAbilityRepository.findOneByTerms
public function findOneByTerms(Competency $parent, Ability $ability) { $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]); if (!$link) { throw new \RuntimeException( "Competency {$parent->getId()} is not linked to ability {$ability->getId()}" ); } return $link; }
php
public function findOneByTerms(Competency $parent, Ability $ability) { $link = $this->findOneBy(['competency' => $parent, 'ability' => $ability]); if (!$link) { throw new \RuntimeException( "Competency {$parent->getId()} is not linked to ability {$ability->getId()}" ); } return $link; }
[ "public", "function", "findOneByTerms", "(", "Competency", "$", "parent", ",", "Ability", "$", "ability", ")", "{", "$", "link", "=", "$", "this", "->", "findOneBy", "(", "[", "'competency'", "=>", "$", "parent", ",", "'ability'", "=>", "$", "ability", "...
Returns the association between a competency and an ability. @param Competency $parent @param Ability $ability @return null|object @throws \Exception if the ability is not linked to the competency
[ "Returns", "the", "association", "between", "a", "competency", "and", "an", "ability", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyAbilityRepository.php#L56-L67
40,692
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.handleEvaluation
public function handleEvaluation(ResourceUserEvaluation $evaluation) { $this->clearCache(); $this->om->startFlushSuite(); $resource = $evaluation->getResourceNode(); $abilities = $this->abilityRepo->findByResource($resource); $user = $evaluation->getUser(); foreach ($abilities as $ability) { $this->setCompetencyProgressResourceId($ability, $user, $resource->getId()); $progress = $this->getAbilityProgress($ability, $user); if ($evaluation->isSuccessful()) { $progress->addPassedResource($resource); if (AbilityProgress::STATUS_ACQUIRED !== $progress->getStatus()) { if ($progress->getPassedResourceCount() >= $ability->getMinResourceCount()) { $progress->setStatus(AbilityProgress::STATUS_ACQUIRED); $this->om->forceFlush(); } else { $progress->setStatus(AbilityProgress::STATUS_PENDING); } } $this->computeCompetencyProgress($ability, $user); } else { $progress->addFailedResource($resource); } } $this->om->endFlushSuite(); }
php
public function handleEvaluation(ResourceUserEvaluation $evaluation) { $this->clearCache(); $this->om->startFlushSuite(); $resource = $evaluation->getResourceNode(); $abilities = $this->abilityRepo->findByResource($resource); $user = $evaluation->getUser(); foreach ($abilities as $ability) { $this->setCompetencyProgressResourceId($ability, $user, $resource->getId()); $progress = $this->getAbilityProgress($ability, $user); if ($evaluation->isSuccessful()) { $progress->addPassedResource($resource); if (AbilityProgress::STATUS_ACQUIRED !== $progress->getStatus()) { if ($progress->getPassedResourceCount() >= $ability->getMinResourceCount()) { $progress->setStatus(AbilityProgress::STATUS_ACQUIRED); $this->om->forceFlush(); } else { $progress->setStatus(AbilityProgress::STATUS_PENDING); } } $this->computeCompetencyProgress($ability, $user); } else { $progress->addFailedResource($resource); } } $this->om->endFlushSuite(); }
[ "public", "function", "handleEvaluation", "(", "ResourceUserEvaluation", "$", "evaluation", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "resource", "=", "$", "evaluation", ...
Computes and logs the progression of a user. @param ResourceUserEvaluation $evaluation
[ "Computes", "and", "logs", "the", "progression", "of", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L62-L94
40,693
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.recomputeUserProgress
public function recomputeUserProgress($subject) { $this->clearCache(); $percentage = null; if ($subject instanceof User) { $percentage = $this->computeUserProgress($subject); } elseif ($subject instanceof Group) { foreach ($subject->getUsers() as $user) { $this->computeUserProgress($user); } } else { throw new \InvalidArgumentException( 'Subject must be an instance of User or Group' ); } $this->om->flush(); return $percentage; }
php
public function recomputeUserProgress($subject) { $this->clearCache(); $percentage = null; if ($subject instanceof User) { $percentage = $this->computeUserProgress($subject); } elseif ($subject instanceof Group) { foreach ($subject->getUsers() as $user) { $this->computeUserProgress($user); } } else { throw new \InvalidArgumentException( 'Subject must be an instance of User or Group' ); } $this->om->flush(); return $percentage; }
[ "public", "function", "recomputeUserProgress", "(", "$", "subject", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "percentage", "=", "null", ";", "if", "(", "$", "subject", "instanceof", "User", ")", "{", "$", "percentage", "=", "$", "...
Recomputes the progression of a user or a group of users. In case the subject is a user, returns the computed percentage, otherwise returns null. Note: this method recomputes only the percentage of reached objectives. @param User|Group $subject @return null|int
[ "Recomputes", "the", "progression", "of", "a", "user", "or", "a", "group", "of", "users", ".", "In", "case", "the", "subject", "is", "a", "user", "returns", "the", "computed", "percentage", "otherwise", "returns", "null", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L107-L127
40,694
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.recomputeObjectiveProgress
public function recomputeObjectiveProgress(Objective $objective) { $this->clearCache(); $users = $this->objectiveRepo->findUsersWithObjective($objective); foreach ($users as $user) { $this->computeUserObjective($objective, $user); $this->computeUserProgress($user); } $this->om->flush(); }
php
public function recomputeObjectiveProgress(Objective $objective) { $this->clearCache(); $users = $this->objectiveRepo->findUsersWithObjective($objective); foreach ($users as $user) { $this->computeUserObjective($objective, $user); $this->computeUserProgress($user); } $this->om->flush(); }
[ "public", "function", "recomputeObjectiveProgress", "(", "Objective", "$", "objective", ")", "{", "$", "this", "->", "clearCache", "(", ")", ";", "$", "users", "=", "$", "this", "->", "objectiveRepo", "->", "findUsersWithObjective", "(", "$", "objective", ")",...
Recomputes an objective progress for all the users and groups of users to which that objective is assigned. Note: this method doesn't compute competency progress. @param Objective $objective
[ "Recomputes", "an", "objective", "progress", "for", "all", "the", "users", "and", "groups", "of", "users", "to", "which", "that", "objective", "is", "assigned", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L137-L148
40,695
claroline/Distribution
plugin/competency/Manager/ProgressManager.php
ProgressManager.listLeafCompetencyLogs
public function listLeafCompetencyLogs(Competency $competency, User $user) { return $this->abilityRepo->findEvaluationsByCompetency($competency, $user); }
php
public function listLeafCompetencyLogs(Competency $competency, User $user) { return $this->abilityRepo->findEvaluationsByCompetency($competency, $user); }
[ "public", "function", "listLeafCompetencyLogs", "(", "Competency", "$", "competency", ",", "User", "$", "user", ")", "{", "return", "$", "this", "->", "abilityRepo", "->", "findEvaluationsByCompetency", "(", "$", "competency", ",", "$", "user", ")", ";", "}" ]
Returns user evaluation data for a given leaf competency. @param Competency $competency @param User $user @return mixed
[ "Returns", "user", "evaluation", "data", "for", "a", "given", "leaf", "competency", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ProgressManager.php#L158-L161
40,696
claroline/Distribution
plugin/bibliography/Serializer/BookReferenceConfigurationSerializer.php
BookReferenceConfigurationSerializer.deserialize
public function deserialize($data, BookReferenceConfiguration $bookReferenceConfiguration = null, array $options = []) { if (empty($bookReferenceConfiguration)) { $bookReferenceConfiguration = new BookReferenceConfiguration(); } $this->sipe('apiKey', 'setApiKey', $data, $bookReferenceConfiguration); return $bookReferenceConfiguration; }
php
public function deserialize($data, BookReferenceConfiguration $bookReferenceConfiguration = null, array $options = []) { if (empty($bookReferenceConfiguration)) { $bookReferenceConfiguration = new BookReferenceConfiguration(); } $this->sipe('apiKey', 'setApiKey', $data, $bookReferenceConfiguration); return $bookReferenceConfiguration; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "BookReferenceConfiguration", "$", "bookReferenceConfiguration", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "bookReferenceConfiguration", ")", ")...
De-serializes a book reference configuration. @param $data @param BookReferenceConfiguration|null $bookReferenceConfiguration @param array $options @return BookReferenceConfiguration
[ "De", "-", "serializes", "a", "book", "reference", "configuration", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/bibliography/Serializer/BookReferenceConfigurationSerializer.php#L47-L56
40,697
claroline/Distribution
plugin/wiki/Listener/Resource/WikiListener.php
WikiListener.load
public function load(LoadResourceEvent $event) { $resourceNode = $event->getResourceNode(); /** @var Wiki $wiki */ $wiki = $event->getResource(); $sectionTree = $this->sectionManager->getSerializedSectionTree( $wiki, $this->tokenStorage->getToken()->getUser() instanceof User ? $this->tokenStorage->getToken()->getUser() : null, $this->checkPermission('EDIT', $resourceNode) ); $event->setData([ 'wiki' => $this->serializer->serialize($wiki), 'sections' => $sectionTree, ]); $event->stopPropagation(); }
php
public function load(LoadResourceEvent $event) { $resourceNode = $event->getResourceNode(); /** @var Wiki $wiki */ $wiki = $event->getResource(); $sectionTree = $this->sectionManager->getSerializedSectionTree( $wiki, $this->tokenStorage->getToken()->getUser() instanceof User ? $this->tokenStorage->getToken()->getUser() : null, $this->checkPermission('EDIT', $resourceNode) ); $event->setData([ 'wiki' => $this->serializer->serialize($wiki), 'sections' => $sectionTree, ]); $event->stopPropagation(); }
[ "public", "function", "load", "(", "LoadResourceEvent", "$", "event", ")", "{", "$", "resourceNode", "=", "$", "event", "->", "getResourceNode", "(", ")", ";", "/** @var Wiki $wiki */", "$", "wiki", "=", "$", "event", "->", "getResource", "(", ")", ";", "$...
Loads a Wiki resource. @DI\Observe("resource.icap_wiki.load") @param LoadResourceEvent $event
[ "Loads", "a", "Wiki", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/wiki/Listener/Resource/WikiListener.php#L96-L114
40,698
claroline/Distribution
main/core/Event/Log/LogRoleSubscribeEvent.php
LogRoleSubscribeEvent.getExcludeUserIds
public function getExcludeUserIds() { $userIds = array(); $currentGroupId = -1; //First of all we need to test if subject is group or user //In case of group we need to exclude all these users that already exist in role if ($this->receiverGroup !== null) { $currentGroupId = $this->receiverGroup->getId(); $roleUsers = $this->role->getUsers(); foreach ($roleUsers as $user) { array_push($userIds, $user->getId()); } } //For both cases (user or group) we need to exclude all users already enrolled in other groups $roleGroups = $this->role->getGroups(); if ($roleGroups) { foreach ($roleGroups as $group) { if ($group->getId() != $currentGroupId) { $userIds = array_merge($userIds, $group->getUserIds()); } } } $userIds = array_unique($userIds); return $userIds; }
php
public function getExcludeUserIds() { $userIds = array(); $currentGroupId = -1; //First of all we need to test if subject is group or user //In case of group we need to exclude all these users that already exist in role if ($this->receiverGroup !== null) { $currentGroupId = $this->receiverGroup->getId(); $roleUsers = $this->role->getUsers(); foreach ($roleUsers as $user) { array_push($userIds, $user->getId()); } } //For both cases (user or group) we need to exclude all users already enrolled in other groups $roleGroups = $this->role->getGroups(); if ($roleGroups) { foreach ($roleGroups as $group) { if ($group->getId() != $currentGroupId) { $userIds = array_merge($userIds, $group->getUserIds()); } } } $userIds = array_unique($userIds); return $userIds; }
[ "public", "function", "getExcludeUserIds", "(", ")", "{", "$", "userIds", "=", "array", "(", ")", ";", "$", "currentGroupId", "=", "-", "1", ";", "//First of all we need to test if subject is group or user", "//In case of group we need to exclude all these users that already ...
Get excludeUsers array of user ids. @return array
[ "Get", "excludeUsers", "array", "of", "user", "ids", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/Log/LogRoleSubscribeEvent.php#L123-L150
40,699
claroline/Distribution
main/core/Event/Log/LogRoleSubscribeEvent.php
LogRoleSubscribeEvent.getActionKey
public function getActionKey() { if ($this->receiver !== null) { if ($this->role->getWorkspace() === null) { return $this::ACTION_USER; } else { return $this::ACTION_WORKSPACE_USER; } } else { if ($this->role->getWorkspace() === null) { return $this::ACTION_GROUP; } else { return $this::ACTION_WORKSPACE_GROUP; } } }
php
public function getActionKey() { if ($this->receiver !== null) { if ($this->role->getWorkspace() === null) { return $this::ACTION_USER; } else { return $this::ACTION_WORKSPACE_USER; } } else { if ($this->role->getWorkspace() === null) { return $this::ACTION_GROUP; } else { return $this::ACTION_WORKSPACE_GROUP; } } }
[ "public", "function", "getActionKey", "(", ")", "{", "if", "(", "$", "this", "->", "receiver", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "role", "->", "getWorkspace", "(", ")", "===", "null", ")", "{", "return", "$", "this", "::", "ACT...
Get actionKey string. @return string
[ "Get", "actionKey", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Event/Log/LogRoleSubscribeEvent.php#L157-L172