repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
claroline/Distribution
main/core/Entity/Facet/FieldFacet.php
FieldFacet.getRootFieldFacetChoices
public function getRootFieldFacetChoices() { $roots = []; if (!empty($this->fieldFacetChoices)) { foreach ($this->fieldFacetChoices as $choice) { if (empty($choice->getParent())) { $roots[] = $choice; } } } return $roots; }
php
public function getRootFieldFacetChoices() { $roots = []; if (!empty($this->fieldFacetChoices)) { foreach ($this->fieldFacetChoices as $choice) { if (empty($choice->getParent())) { $roots[] = $choice; } } } return $roots; }
[ "public", "function", "getRootFieldFacetChoices", "(", ")", "{", "$", "roots", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "fieldFacetChoices", ")", ")", "{", "foreach", "(", "$", "this", "->", "fieldFacetChoices", "as", "$", "...
Get root choices. @return FieldFacetChoice[]
[ "Get", "root", "choices", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Facet/FieldFacet.php#L352-L365
train
claroline/Distribution
plugin/exo/Listener/Resource/ExerciseListener.php
ExerciseListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $currentUser = $this->tokenStorage->getToken()->getUser(); $canEdit = $this->authorization->isGranted('EDIT', new ResourceCollection([$exercise->getResourceNode()])); $options = []; if ($canEdit || $exercise->hasStatistics()) { $options[] = Transfer::INCLUDE_SOLUTIONS; } // fetch additional user data $nbUserPapers = 0; $nbUserPapersDayCount = 0; $userEvaluation = null; if ($currentUser instanceof User) { $nbUserPapers = (int) $this->paperManager->countUserFinishedPapers($exercise, $currentUser); $nbUserPapersDayCount = (int) $this->paperManager->countUserFinishedDayPapers($exercise, $currentUser); $userEvaluation = $this->serializer->serialize( $this->resourceEvalManager->getResourceUserEvaluation($exercise->getResourceNode(), $currentUser) ); } $event->setData([ 'quiz' => $this->serializer->serialize($exercise, $options), 'paperCount' => (int) $this->paperManager->countExercisePapers($exercise), // user data 'userPaperCount' => $nbUserPapers, 'userPaperDayCount' => $nbUserPapersDayCount, 'userEvaluation' => $userEvaluation, ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $currentUser = $this->tokenStorage->getToken()->getUser(); $canEdit = $this->authorization->isGranted('EDIT', new ResourceCollection([$exercise->getResourceNode()])); $options = []; if ($canEdit || $exercise->hasStatistics()) { $options[] = Transfer::INCLUDE_SOLUTIONS; } // fetch additional user data $nbUserPapers = 0; $nbUserPapersDayCount = 0; $userEvaluation = null; if ($currentUser instanceof User) { $nbUserPapers = (int) $this->paperManager->countUserFinishedPapers($exercise, $currentUser); $nbUserPapersDayCount = (int) $this->paperManager->countUserFinishedDayPapers($exercise, $currentUser); $userEvaluation = $this->serializer->serialize( $this->resourceEvalManager->getResourceUserEvaluation($exercise->getResourceNode(), $currentUser) ); } $event->setData([ 'quiz' => $this->serializer->serialize($exercise, $options), 'paperCount' => (int) $this->paperManager->countExercisePapers($exercise), // user data 'userPaperCount' => $nbUserPapers, 'userPaperDayCount' => $nbUserPapersDayCount, 'userEvaluation' => $userEvaluation, ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var Exercise $exercise */", "$", "exercise", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "currentUser", "=", "$", "this", "->", "tokenStorage", "->", "getTo...
Loads the Exercise resource. @DI\Observe("resource.ujm_exercise.load") @param LoadResourceEvent $event
[ "Loads", "the", "Exercise", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Listener/Resource/ExerciseListener.php#L112-L147
train
claroline/Distribution
plugin/exo/Listener/Resource/ExerciseListener.php
ExerciseListener.onDelete
public function onDelete(DeleteResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $deletable = $this->exerciseManager->isDeletable($exercise); if (!$deletable) { // If papers, the Exercise is not completely removed $event->enableSoftDelete(); } $event->stopPropagation(); }
php
public function onDelete(DeleteResourceEvent $event) { /** @var Exercise $exercise */ $exercise = $event->getResource(); $deletable = $this->exerciseManager->isDeletable($exercise); if (!$deletable) { // If papers, the Exercise is not completely removed $event->enableSoftDelete(); } $event->stopPropagation(); }
[ "public", "function", "onDelete", "(", "DeleteResourceEvent", "$", "event", ")", "{", "/** @var Exercise $exercise */", "$", "exercise", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "deletable", "=", "$", "this", "->", "exerciseManager", "->", "...
Deletes an Exercise resource. @DI\Observe("delete_ujm_exercise") @param DeleteResourceEvent $event
[ "Deletes", "an", "Exercise", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Listener/Resource/ExerciseListener.php#L156-L168
train
claroline/Distribution
main/core/Listener/Administration/LogsListener.php
LogsListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:logs.html.twig', [ 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_ADMIN), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $content = $this->templating->render( 'ClarolineCoreBundle:administration:logs.html.twig', [ 'actions' => $this->eventManager->getEventsForApiFilter(LogGenericEvent::DISPLAYED_ADMIN), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "content", "=", "$", "this", "->", "templating", "->", "render", "(", "'ClarolineCoreBundle:administration:logs.html.twig'", ",", "[", "'actions'", "=>", "$", "th...
Displays logs administration tool. @DI\Observe("administration_tool_platform_logs") @param OpenAdministrationToolEvent $event
[ "Displays", "logs", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/LogsListener.php#L49-L59
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.selectAsEntity
public function selectAsEntity($joinSingleRelatives = false, $class = null) { $this->init(); $eol = PHP_EOL; if ($class) { $this->selectClause = 'SELECT resource'.PHP_EOL; $this->fromClause = "FROM {$class} resource{$eol} JOIN resource.resourceNode node{$eol}"; } else { $this->selectClause = 'SELECT node'.PHP_EOL; } $this->joinSingleRelatives = $joinSingleRelatives; return $this; }
php
public function selectAsEntity($joinSingleRelatives = false, $class = null) { $this->init(); $eol = PHP_EOL; if ($class) { $this->selectClause = 'SELECT resource'.PHP_EOL; $this->fromClause = "FROM {$class} resource{$eol} JOIN resource.resourceNode node{$eol}"; } else { $this->selectClause = 'SELECT node'.PHP_EOL; } $this->joinSingleRelatives = $joinSingleRelatives; return $this; }
[ "public", "function", "selectAsEntity", "(", "$", "joinSingleRelatives", "=", "false", ",", "$", "class", "=", "null", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "eol", "=", "PHP_EOL", ";", "if", "(", "$", "class", ")", "{", "$", "thi...
Selects nodes as entities. @param bool $joinSingleRelatives Whether the creator, type and icon must be joined to the query @param string $class @return ResourceQueryBuilder
[ "Selects", "nodes", "as", "entities", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L81-L96
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.selectAsArray
public function selectAsArray($withMaxPermissions = false, $withLastOpenDate = false) { $this->init(); $this->resultAsArray = true; $this->joinSingleRelatives = true; $eol = PHP_EOL; $this->selectClause = "SELECT DISTINCT{$eol}". " node.id as id,{$eol}". " node.uuid as uuid,{$eol}". " node.name as name,{$eol}". " node.path as path,{$eol}". " IDENTITY(node.parent) as parent_id,{$eol}". " creator.username as creator_username,{$eol}". " creator.id as creator_id,{$eol}". " resourceType.name as type,{$eol}". " icon.relativeUrl as large_icon,{$eol}". " node.mimeType as mime_type,{$eol}". " node.index as index_dir,{$eol}". " node.creationDate as creation_date,{$eol}". " node.modificationDate as modification_date,{$eol}". " node.published as published,{$eol}". " node.accessibleFrom as accessible_from,{$eol}". " node.accessibleUntil as accessible_until,{$eol}". " node.deletable as deletable{$eol}"; if ($withMaxPermissions) { $this->leftJoinRights = true; $this->selectClause .= ",{$eol}rights.mask"; } if ($withLastOpenDate) { $this->leftJoinLogs = true; $this->selectClause .= ",{$eol}log.dateLog as last_opened"; } $this->selectClause .= $eol; return $this; }
php
public function selectAsArray($withMaxPermissions = false, $withLastOpenDate = false) { $this->init(); $this->resultAsArray = true; $this->joinSingleRelatives = true; $eol = PHP_EOL; $this->selectClause = "SELECT DISTINCT{$eol}". " node.id as id,{$eol}". " node.uuid as uuid,{$eol}". " node.name as name,{$eol}". " node.path as path,{$eol}". " IDENTITY(node.parent) as parent_id,{$eol}". " creator.username as creator_username,{$eol}". " creator.id as creator_id,{$eol}". " resourceType.name as type,{$eol}". " icon.relativeUrl as large_icon,{$eol}". " node.mimeType as mime_type,{$eol}". " node.index as index_dir,{$eol}". " node.creationDate as creation_date,{$eol}". " node.modificationDate as modification_date,{$eol}". " node.published as published,{$eol}". " node.accessibleFrom as accessible_from,{$eol}". " node.accessibleUntil as accessible_until,{$eol}". " node.deletable as deletable{$eol}"; if ($withMaxPermissions) { $this->leftJoinRights = true; $this->selectClause .= ",{$eol}rights.mask"; } if ($withLastOpenDate) { $this->leftJoinLogs = true; $this->selectClause .= ",{$eol}log.dateLog as last_opened"; } $this->selectClause .= $eol; return $this; }
[ "public", "function", "selectAsArray", "(", "$", "withMaxPermissions", "=", "false", ",", "$", "withLastOpenDate", "=", "false", ")", "{", "$", "this", "->", "init", "(", ")", ";", "$", "this", "->", "resultAsArray", "=", "true", ";", "$", "this", "->", ...
Selects nodes as arrays. Resource type, creator and icon are always added to the query. @param bool $withMaxPermissions Whether maximum permissions must be calculated and added to the result @param bool $withLastOpenDate @return ResourceQueryBuilder
[ "Selects", "nodes", "as", "arrays", ".", "Resource", "type", "creator", "and", "icon", "are", "always", "added", "to", "the", "query", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L106-L145
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereInWorkspace
public function whereInWorkspace(Workspace $workspace) { $this->addWhereClause('node.workspace = :workspace_id'); $this->parameters[':workspace_id'] = $workspace->getId(); return $this; }
php
public function whereInWorkspace(Workspace $workspace) { $this->addWhereClause('node.workspace = :workspace_id'); $this->parameters[':workspace_id'] = $workspace->getId(); return $this; }
[ "public", "function", "whereInWorkspace", "(", "Workspace", "$", "workspace", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.workspace = :workspace_id'", ")", ";", "$", "this", "->", "parameters", "[", "':workspace_id'", "]", "=", "$", "workspace", "...
Filters nodes belonging to a given workspace. @param Workspace $workspace @return ResourceQueryBuilder
[ "Filters", "nodes", "belonging", "to", "a", "given", "workspace", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L154-L160
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereParentIs
public function whereParentIs(ResourceNode $parent) { $this->addWhereClause('node.parent = :ar_parentId'); $this->parameters[':ar_parentId'] = $parent->getId(); return $this; }
php
public function whereParentIs(ResourceNode $parent) { $this->addWhereClause('node.parent = :ar_parentId'); $this->parameters[':ar_parentId'] = $parent->getId(); return $this; }
[ "public", "function", "whereParentIs", "(", "ResourceNode", "$", "parent", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.parent = :ar_parentId'", ")", ";", "$", "this", "->", "parameters", "[", "':ar_parentId'", "]", "=", "$", "parent", "->", "get...
Filters nodes that are the immediate children of a given node. @param ResourceNode $parent @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "are", "the", "immediate", "children", "of", "a", "given", "node", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L178-L184
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.wherePathLike
public function wherePathLike($path, $includeGivenPath = true) { $this->addWhereClause('node.path LIKE :pathlike'); $this->parameters[':pathlike'] = $path.'%'; if (!$includeGivenPath) { $this->addWhereClause('node.path <> :path'); $this->parameters[':path'] = $path; } return $this; }
php
public function wherePathLike($path, $includeGivenPath = true) { $this->addWhereClause('node.path LIKE :pathlike'); $this->parameters[':pathlike'] = $path.'%'; if (!$includeGivenPath) { $this->addWhereClause('node.path <> :path'); $this->parameters[':path'] = $path; } return $this; }
[ "public", "function", "wherePathLike", "(", "$", "path", ",", "$", "includeGivenPath", "=", "true", ")", "{", "$", "this", "->", "addWhereClause", "(", "'node.path LIKE :pathlike'", ")", ";", "$", "this", "->", "parameters", "[", "':pathlike'", "]", "=", "$"...
Filters nodes whose path begins with a given path. @param string $path @param bool $includeGivenPath @return ResourceQueryBuilder
[ "Filters", "nodes", "whose", "path", "begins", "with", "a", "given", "path", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L194-L205
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.whereIsExportable
public function whereIsExportable($isExportable) { $this->joinSingleRelatives = true; $this->addWhereClause('resourceType.isExportable = :isExportable'); $this->parameters[':isExportable'] = $isExportable; return $this; }
php
public function whereIsExportable($isExportable) { $this->joinSingleRelatives = true; $this->addWhereClause('resourceType.isExportable = :isExportable'); $this->parameters[':isExportable'] = $isExportable; return $this; }
[ "public", "function", "whereIsExportable", "(", "$", "isExportable", ")", "{", "$", "this", "->", "joinSingleRelatives", "=", "true", ";", "$", "this", "->", "addWhereClause", "(", "'resourceType.isExportable = :isExportable'", ")", ";", "$", "this", "->", "parame...
Filters nodes that can or cannot be exported. @param bool $isExportable @return ResourceQueryBuilder
[ "Filters", "nodes", "that", "can", "or", "cannot", "be", "exported", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L375-L382
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.getDql
public function getDql() { if (null === $this->selectClause) { throw new MissingSelectClauseException('Select clause is missing'); } $eol = PHP_EOL; $joinRelatives = $this->joinSingleRelatives ? $this->joinRelativesClause : ''; if ($this->leftJoinPlugins) { $joinRelatives .= " LEFT JOIN node.resourceType rtp{$eol} LEFT JOIN rtp.plugin p{$eol}"; } $joinRoles = $this->leftJoinRoles ? "LEFT JOIN node.workspace workspace{$eol}". "LEFT JOIN workspace.roles role{$eol}" : ''; $joinRights = $this->leftJoinRights ? "LEFT JOIN node.rights rights{$eol}". "JOIN rights.role rightRole{$eol}" : ''; $joinLogs = $this->leftJoinLogs ? "JOIN node.logs log{$eol}". "JOIN log.resourceNode log_node{$eol}" : ''; $dql = $this->selectClause. $this->fromClause. $joinRelatives. $joinRoles. $joinRights. $joinLogs. $this->joinClause. $this->whereClause. $this->groupByClause. $this->orderClause; return $dql; }
php
public function getDql() { if (null === $this->selectClause) { throw new MissingSelectClauseException('Select clause is missing'); } $eol = PHP_EOL; $joinRelatives = $this->joinSingleRelatives ? $this->joinRelativesClause : ''; if ($this->leftJoinPlugins) { $joinRelatives .= " LEFT JOIN node.resourceType rtp{$eol} LEFT JOIN rtp.plugin p{$eol}"; } $joinRoles = $this->leftJoinRoles ? "LEFT JOIN node.workspace workspace{$eol}". "LEFT JOIN workspace.roles role{$eol}" : ''; $joinRights = $this->leftJoinRights ? "LEFT JOIN node.rights rights{$eol}". "JOIN rights.role rightRole{$eol}" : ''; $joinLogs = $this->leftJoinLogs ? "JOIN node.logs log{$eol}". "JOIN log.resourceNode log_node{$eol}" : ''; $dql = $this->selectClause. $this->fromClause. $joinRelatives. $joinRoles. $joinRights. $joinLogs. $this->joinClause. $this->whereClause. $this->groupByClause. $this->orderClause; return $dql; }
[ "public", "function", "getDql", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "selectClause", ")", "{", "throw", "new", "MissingSelectClauseException", "(", "'Select clause is missing'", ")", ";", "}", "$", "eol", "=", "PHP_EOL", ";", "$", "j...
Returns the dql query string. @return string @throws MissingSelectClauseException if no select method was previously called
[ "Returns", "the", "dql", "query", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L499-L536
train
claroline/Distribution
main/core/Repository/ResourceQueryBuilder.php
ResourceQueryBuilder.addWhereClause
public function addWhereClause($clause) { if (null === $this->whereClause) { $this->whereClause = "WHERE {$clause}".PHP_EOL; } else { $this->whereClause = $this->whereClause."AND {$clause}".PHP_EOL; } }
php
public function addWhereClause($clause) { if (null === $this->whereClause) { $this->whereClause = "WHERE {$clause}".PHP_EOL; } else { $this->whereClause = $this->whereClause."AND {$clause}".PHP_EOL; } }
[ "public", "function", "addWhereClause", "(", "$", "clause", ")", "{", "if", "(", "null", "===", "$", "this", "->", "whereClause", ")", "{", "$", "this", "->", "whereClause", "=", "\"WHERE {$clause}\"", ".", "PHP_EOL", ";", "}", "else", "{", "$", "this", ...
Adds a statement to the query "WHERE" clause. @param string $clause
[ "Adds", "a", "statement", "to", "the", "query", "WHERE", "clause", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/ResourceQueryBuilder.php#L553-L560
train
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.create
public function create(array $data) { if ($this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured')) { return $this->update($data, new ScheduledTask()); } return null; }
php
public function create(array $data) { if ($this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured')) { return $this->update($data, new ScheduledTask()); } return null; }
[ "public", "function", "create", "(", "array", "$", "data", ")", "{", "if", "(", "$", "this", "->", "configHandler", "->", "hasParameter", "(", "'is_cron_configured'", ")", "&&", "$", "this", "->", "configHandler", "->", "getParameter", "(", "'is_cron_configure...
Creates a new ScheduledTask. @param array $data @return ScheduledTask
[ "Creates", "a", "new", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L82-L90
train
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.update
public function update(array $data, ScheduledTask $scheduledTask) { $errors = $this->validate($data); if (count($errors) > 0) { throw new InvalidDataException('Scheduled task is not valid', $errors); } $scheduledTask = $this->om->getObject($data, ScheduledTask::class); $this->serializer->deserialize($data, $scheduledTask); $this->om->persist($scheduledTask); $this->om->flush(); return $scheduledTask; }
php
public function update(array $data, ScheduledTask $scheduledTask) { $errors = $this->validate($data); if (count($errors) > 0) { throw new InvalidDataException('Scheduled task is not valid', $errors); } $scheduledTask = $this->om->getObject($data, ScheduledTask::class); $this->serializer->deserialize($data, $scheduledTask); $this->om->persist($scheduledTask); $this->om->flush(); return $scheduledTask; }
[ "public", "function", "update", "(", "array", "$", "data", ",", "ScheduledTask", "$", "scheduledTask", ")", "{", "$", "errors", "=", "$", "this", "->", "validate", "(", "$", "data", ")", ";", "if", "(", "count", "(", "$", "errors", ")", ">", "0", "...
Updates a ScheduledTask. @param array $data @param ScheduledTask $scheduledTask @return ScheduledTask @throws InvalidDataException
[ "Updates", "a", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L102-L116
train
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.delete
public function delete(ScheduledTask $scheduledTask) { $this->om->remove($scheduledTask); $this->om->flush(); }
php
public function delete(ScheduledTask $scheduledTask) { $this->om->remove($scheduledTask); $this->om->flush(); }
[ "public", "function", "delete", "(", "ScheduledTask", "$", "scheduledTask", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "scheduledTask", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a ScheduledTask. @param ScheduledTask $scheduledTask
[ "Deletes", "a", "ScheduledTask", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L147-L151
train
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.deleteBulk
public function deleteBulk(array $scheduledTasks) { $this->om->startFlushSuite(); foreach ($scheduledTasks as $scheduledTask) { $this->delete($scheduledTask); } $this->om->endFlushSuite(); }
php
public function deleteBulk(array $scheduledTasks) { $this->om->startFlushSuite(); foreach ($scheduledTasks as $scheduledTask) { $this->delete($scheduledTask); } $this->om->endFlushSuite(); }
[ "public", "function", "deleteBulk", "(", "array", "$", "scheduledTasks", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "foreach", "(", "$", "scheduledTasks", "as", "$", "scheduledTask", ")", "{", "$", "this", "->", "delete", ...
Deletes a list of ScheduledTasks. @param ScheduledTask[] $scheduledTasks
[ "Deletes", "a", "list", "of", "ScheduledTasks", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L158-L165
train
claroline/Distribution
main/core/Manager/Task/ScheduledTaskManager.php
ScheduledTaskManager.markAsExecuted
public function markAsExecuted(ScheduledTask $task, \DateTime $executionDate = null) { if (empty($executionDate)) { $executionDate = new \DateTime(); } $task->setExecutionDate($executionDate); $this->om->persist($task); $this->om->flush(); }
php
public function markAsExecuted(ScheduledTask $task, \DateTime $executionDate = null) { if (empty($executionDate)) { $executionDate = new \DateTime(); } $task->setExecutionDate($executionDate); $this->om->persist($task); $this->om->flush(); }
[ "public", "function", "markAsExecuted", "(", "ScheduledTask", "$", "task", ",", "\\", "DateTime", "$", "executionDate", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "executionDate", ")", ")", "{", "$", "executionDate", "=", "new", "\\", "DateTime",...
Flags a ScheduledTask as executed. @param ScheduledTask $task @param \DateTime $executionDate
[ "Flags", "a", "ScheduledTask", "as", "executed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/Task/ScheduledTaskManager.php#L173-L183
train
claroline/Distribution
plugin/claco-form/Listener/Resource/ClacoFormListener.php
ClacoFormListener.onLoad
public function onLoad(LoadResourceEvent $event) { /** @var ClacoForm $clacoForm */ $clacoForm = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isAnon = 'anon.' === $user; $myEntries = $isAnon ? [] : $this->clacoFormManager->getUserEntries($clacoForm, $user); $canGeneratePdf = !$isAnon && $this->platformConfigHandler->hasParameter('knp_pdf_binary_path') && file_exists($this->platformConfigHandler->getParameter('knp_pdf_binary_path')); $cascadeLevelMax = $this->platformConfigHandler->hasParameter('claco_form_cascade_select_level_max') ? $this->platformConfigHandler->getParameter('claco_form_cascade_select_level_max') : 2; $roles = []; $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $roleAnonymous = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); $workspaceRoles = $this->roleManager->getWorkspaceRoles($clacoForm->getResourceNode()->getWorkspace()); $roles[] = $this->serializer->serialize($roleUser, [Options::SERIALIZE_MINIMAL]); $roles[] = $this->serializer->serialize($roleAnonymous, [Options::SERIALIZE_MINIMAL]); foreach ($workspaceRoles as $workspaceRole) { $roles[] = $this->serializer->serialize($workspaceRole, [Options::SERIALIZE_MINIMAL]); } $myRoles = $isAnon ? [$roleAnonymous->getName()] : $user->getRoles(); $event->setData([ 'clacoForm' => $this->serializer->serialize($clacoForm), 'canGeneratePdf' => $canGeneratePdf, 'cascadeLevelMax' => $cascadeLevelMax, 'myEntriesCount' => count($myEntries), 'roles' => $roles, 'myRoles' => $myRoles, ]); $event->stopPropagation(); }
php
public function onLoad(LoadResourceEvent $event) { /** @var ClacoForm $clacoForm */ $clacoForm = $event->getResource(); $user = $this->tokenStorage->getToken()->getUser(); $isAnon = 'anon.' === $user; $myEntries = $isAnon ? [] : $this->clacoFormManager->getUserEntries($clacoForm, $user); $canGeneratePdf = !$isAnon && $this->platformConfigHandler->hasParameter('knp_pdf_binary_path') && file_exists($this->platformConfigHandler->getParameter('knp_pdf_binary_path')); $cascadeLevelMax = $this->platformConfigHandler->hasParameter('claco_form_cascade_select_level_max') ? $this->platformConfigHandler->getParameter('claco_form_cascade_select_level_max') : 2; $roles = []; $roleUser = $this->roleManager->getRoleByName('ROLE_USER'); $roleAnonymous = $this->roleManager->getRoleByName('ROLE_ANONYMOUS'); $workspaceRoles = $this->roleManager->getWorkspaceRoles($clacoForm->getResourceNode()->getWorkspace()); $roles[] = $this->serializer->serialize($roleUser, [Options::SERIALIZE_MINIMAL]); $roles[] = $this->serializer->serialize($roleAnonymous, [Options::SERIALIZE_MINIMAL]); foreach ($workspaceRoles as $workspaceRole) { $roles[] = $this->serializer->serialize($workspaceRole, [Options::SERIALIZE_MINIMAL]); } $myRoles = $isAnon ? [$roleAnonymous->getName()] : $user->getRoles(); $event->setData([ 'clacoForm' => $this->serializer->serialize($clacoForm), 'canGeneratePdf' => $canGeneratePdf, 'cascadeLevelMax' => $cascadeLevelMax, 'myEntriesCount' => count($myEntries), 'roles' => $roles, 'myRoles' => $myRoles, ]); $event->stopPropagation(); }
[ "public", "function", "onLoad", "(", "LoadResourceEvent", "$", "event", ")", "{", "/** @var ClacoForm $clacoForm */", "$", "clacoForm", "=", "$", "event", "->", "getResource", "(", ")", ";", "$", "user", "=", "$", "this", "->", "tokenStorage", "->", "getToken"...
Loads the ClacoForm resource. @DI\Observe("resource.claroline_claco_form.load") @param LoadResourceEvent $event
[ "Loads", "the", "ClacoForm", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Listener/Resource/ClacoFormListener.php#L91-L125
train
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.getUserOptions
public function getUserOptions(User $user) { $options = $this->optionsRepo->findOneBy(['user' => $user]); if (is_null($options)) { $options = new Options(); $options->setUser($user); $defaultValues = [ 'show_all_my_contacts' => true, 'show_all_visible_users' => true, 'show_username' => true, 'show_mail' => false, 'show_phone' => false, 'show_picture' => true, ]; $options->setOptions($defaultValues); $this->om->persist($options); $this->om->flush(); } return $options; }
php
public function getUserOptions(User $user) { $options = $this->optionsRepo->findOneBy(['user' => $user]); if (is_null($options)) { $options = new Options(); $options->setUser($user); $defaultValues = [ 'show_all_my_contacts' => true, 'show_all_visible_users' => true, 'show_username' => true, 'show_mail' => false, 'show_phone' => false, 'show_picture' => true, ]; $options->setOptions($defaultValues); $this->om->persist($options); $this->om->flush(); } return $options; }
[ "public", "function", "getUserOptions", "(", "User", "$", "user", ")", "{", "$", "options", "=", "$", "this", "->", "optionsRepo", "->", "findOneBy", "(", "[", "'user'", "=>", "$", "user", "]", ")", ";", "if", "(", "is_null", "(", "$", "options", ")"...
Fetches user options. @param User $user @return Options
[ "Fetches", "user", "options", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L56-L77
train
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.createContacts
public function createContacts(User $currentUser, array $users) { $this->om->startFlushSuite(); $createdContacts = []; foreach ($users as $user) { $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]); if (is_null($contact)) { $contact = new Contact(); $contact->setUser($currentUser); $contact->setContact($user); $this->om->persist($contact); $createdContacts[] = $contact; } } $this->om->endFlushSuite(); return $createdContacts; }
php
public function createContacts(User $currentUser, array $users) { $this->om->startFlushSuite(); $createdContacts = []; foreach ($users as $user) { $contact = $this->contactRepo->findOneBy(['user' => $currentUser, 'contact' => $user]); if (is_null($contact)) { $contact = new Contact(); $contact->setUser($currentUser); $contact->setContact($user); $this->om->persist($contact); $createdContacts[] = $contact; } } $this->om->endFlushSuite(); return $createdContacts; }
[ "public", "function", "createContacts", "(", "User", "$", "currentUser", ",", "array", "$", "users", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "createdContacts", "=", "[", "]", ";", "foreach", "(", "$", "users", "a...
Creates contacts from a list of user. @param User $currentUser @param User[] $users @return Contact[]
[ "Creates", "contacts", "from", "a", "list", "of", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L87-L106
train
claroline/Distribution
main/core/Manager/ContactManager.php
ContactManager.deleteContact
public function deleteContact(Contact $contact) { $this->om->remove($contact); $this->om->flush(); }
php
public function deleteContact(Contact $contact) { $this->om->remove($contact); $this->om->flush(); }
[ "public", "function", "deleteContact", "(", "Contact", "$", "contact", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "contact", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Removes a contact. @param Contact $contact
[ "Removes", "a", "contact", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ContactManager.php#L113-L117
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.update
public function update(Dropzone $dropzone, array $data) { $this->crud->update('Claroline\DropZoneBundle\Entity\Dropzone', $data); $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($dropzone); $this->eventDispatcher->dispatch('log', new LogDropzoneConfigureEvent($dropzone, $changeSet)); return $dropzone; }
php
public function update(Dropzone $dropzone, array $data) { $this->crud->update('Claroline\DropZoneBundle\Entity\Dropzone', $data); $uow = $this->om->getUnitOfWork(); $uow->computeChangeSets(); $changeSet = $uow->getEntityChangeSet($dropzone); $this->eventDispatcher->dispatch('log', new LogDropzoneConfigureEvent($dropzone, $changeSet)); return $dropzone; }
[ "public", "function", "update", "(", "Dropzone", "$", "dropzone", ",", "array", "$", "data", ")", "{", "$", "this", "->", "crud", "->", "update", "(", "'Claroline\\DropZoneBundle\\Entity\\Dropzone'", ",", "$", "data", ")", ";", "$", "uow", "=", "$", "this"...
Updates a Dropzone. @param Dropzone $dropzone @param array $data @return Dropzone
[ "Updates", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L222-L233
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.delete
public function delete(Dropzone $dropzone) { $this->om->startFlushSuite(); $uuid = $dropzone->getUuid(); $ds = DIRECTORY_SEPARATOR; $dropzoneDir = $this->filesDir.$ds.'dropzone'.$ds.$uuid; if ($this->fileSystem->exists($dropzoneDir)) { $this->fileSystem->remove($dropzoneDir); } $this->crud->delete($dropzone); $this->om->endFlushSuite(); }
php
public function delete(Dropzone $dropzone) { $this->om->startFlushSuite(); $uuid = $dropzone->getUuid(); $ds = DIRECTORY_SEPARATOR; $dropzoneDir = $this->filesDir.$ds.'dropzone'.$ds.$uuid; if ($this->fileSystem->exists($dropzoneDir)) { $this->fileSystem->remove($dropzoneDir); } $this->crud->delete($dropzone); $this->om->endFlushSuite(); }
[ "public", "function", "delete", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "uuid", "=", "$", "dropzone", "->", "getUuid", "(", ")", ";", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", ...
Deletes a Dropzone. @param Dropzone $dropzone
[ "Deletes", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L240-L252
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.setDefaultDropType
public function setDefaultDropType(Dropzone $dropzone) { $dropzone->setDropType(Dropzone::DROP_TYPE_USER); $this->om->persist($dropzone); $this->om->flush(); }
php
public function setDefaultDropType(Dropzone $dropzone) { $dropzone->setDropType(Dropzone::DROP_TYPE_USER); $this->om->persist($dropzone); $this->om->flush(); }
[ "public", "function", "setDefaultDropType", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "dropzone", "->", "setDropType", "(", "Dropzone", "::", "DROP_TYPE_USER", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "dropzone", ")", ";", "$", ...
Sets Dropzone drop type to default. @param Dropzone $dropzone
[ "Sets", "Dropzone", "drop", "type", "to", "default", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L259-L264
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUserDrop
public function getUserDrop(Dropzone $dropzone, User $user, $withCreation = false) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null]); $drop = count($drops) > 0 ? $drops[0] : null; if (empty($drop) && $withCreation) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $this->om->persist($drop); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } return $drop; }
php
public function getUserDrop(Dropzone $dropzone, User $user, $withCreation = false) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null]); $drop = count($drops) > 0 ? $drops[0] : null; if (empty($drop) && $withCreation) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $this->om->persist($drop); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } return $drop; }
[ "public", "function", "getUserDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ",", "$", "withCreation", "=", "false", ")", "{", "$", "drops", "=", "$", "this", "->", "dropRepo", "->", "findBy", "(", "[", "'dropzone'", "=>", "$", "dro...
Gets user drop or creates one. @param Dropzone $dropzone @param User $user @param bool $withCreation @return Drop
[ "Gets", "user", "drop", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L287-L311
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getTeamDrop
public function getTeamDrop(Dropzone $dropzone, Team $team, User $user, $withCreation = false) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $team->getUuid()]); if ($withCreation) { if (empty($drop)) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $drop->setTeamId($team->getId()); $drop->setTeamUuid($team->getUuid()); $drop->setTeamName($team->getName()); foreach ($team->getRole()->getUsers() as $teamUser) { $drop->addUser($teamUser); /* TODO: checks that a valid status is not overwritten */ $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $teamUser, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); } $this->om->persist($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } elseif (!$drop->hasUser($user)) { $this->om->startFlushSuite(); $drop->addUser($user); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->persist($drop); $this->om->endFlushSuite(); } } return $drop; }
php
public function getTeamDrop(Dropzone $dropzone, Team $team, User $user, $withCreation = false) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $team->getUuid()]); if ($withCreation) { if (empty($drop)) { $this->om->startFlushSuite(); $drop = new Drop(); $drop->setUser($user); $drop->setDropzone($dropzone); $drop->setTeamId($team->getId()); $drop->setTeamUuid($team->getUuid()); $drop->setTeamName($team->getName()); foreach ($team->getRole()->getUsers() as $teamUser) { $drop->addUser($teamUser); /* TODO: checks that a valid status is not overwritten */ $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $teamUser, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); } $this->om->persist($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropStartEvent($dropzone, $drop)); } elseif (!$drop->hasUser($user)) { $this->om->startFlushSuite(); $drop->addUser($user); $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_INCOMPLETE] ); $this->om->persist($drop); $this->om->endFlushSuite(); } } return $drop; }
[ "public", "function", "getTeamDrop", "(", "Dropzone", "$", "dropzone", ",", "Team", "$", "team", ",", "User", "$", "user", ",", "$", "withCreation", "=", "false", ")", "{", "$", "drop", "=", "$", "this", "->", "dropRepo", "->", "findOneBy", "(", "[", ...
Gets team drop or creates one. @param Dropzone $dropzone @param Team $team @param User $user @param bool $withCreation @return Drop
[ "Gets", "team", "drop", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L323-L366
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getTeamDrops
public function getTeamDrops(Dropzone $dropzone, User $user) { $drops = $this->dropRepo->findTeamDrops($dropzone, $user); return $drops; }
php
public function getTeamDrops(Dropzone $dropzone, User $user) { $drops = $this->dropRepo->findTeamDrops($dropzone, $user); return $drops; }
[ "public", "function", "getTeamDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "drops", "=", "$", "this", "->", "dropRepo", "->", "findTeamDrops", "(", "$", "dropzone", ",", "$", "user", ")", ";", "return", "$", "drops...
Gets Team drops or create one. @param Dropzone $dropzone @param User $user @return array
[ "Gets", "Team", "drops", "or", "create", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L376-L381
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteDrop
public function deleteDrop(Drop $drop) { $this->om->startFlushSuite(); $documents = $drop->getDocuments(); foreach ($documents as $document) { $this->deleteDocument($document); } $this->om->remove($drop); $this->om->endFlushSuite(); }
php
public function deleteDrop(Drop $drop) { $this->om->startFlushSuite(); $documents = $drop->getDocuments(); foreach ($documents as $document) { $this->deleteDocument($document); } $this->om->remove($drop); $this->om->endFlushSuite(); }
[ "public", "function", "deleteDrop", "(", "Drop", "$", "drop", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "documents", "=", "$", "drop", "->", "getDocuments", "(", ")", ";", "foreach", "(", "$", "documents", "as", ...
Deletes a Drop. @param Drop $drop
[ "Deletes", "a", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L388-L398
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUserTeamId
public function getUserTeamId(Dropzone $dropzone, User $user) { $teamId = null; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $teamId = $teamDrops[0]->getTeamUuid(); } } return $teamId; }
php
public function getUserTeamId(Dropzone $dropzone, User $user) { $teamId = null; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $teamId = $teamDrops[0]->getTeamUuid(); } } return $teamId; }
[ "public", "function", "getUserTeamId", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "teamId", "=", "null", ";", "if", "(", "Dropzone", "::", "DROP_TYPE_TEAM", "===", "$", "dropzone", "->", "getDropType", "(", ")", ")", "{", ...
Retrieves teamId of user. @param Dropzone $dropzone @param User $user @return string|null
[ "Retrieves", "teamId", "of", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L408-L421
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createDocument
public function createDocument(Drop $drop, User $user, $documentType, $documentData) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate(new \DateTime()); $document->setType($documentType); if (Document::DOCUMENT_TYPE_RESOURCE === $document->getType()) { $resourceNode = $this->resourceNodeRepo->findOneBy(['uuid' => $documentData]); $document->setData($resourceNode); } else { $document->setData($documentData); } $this->om->persist($document); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $document)); return $document; }
php
public function createDocument(Drop $drop, User $user, $documentType, $documentData) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate(new \DateTime()); $document->setType($documentType); if (Document::DOCUMENT_TYPE_RESOURCE === $document->getType()) { $resourceNode = $this->resourceNodeRepo->findOneBy(['uuid' => $documentData]); $document->setData($resourceNode); } else { $document->setData($documentData); } $this->om->persist($document); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $document)); return $document; }
[ "public", "function", "createDocument", "(", "Drop", "$", "drop", ",", "User", "$", "user", ",", "$", "documentType", ",", "$", "documentData", ")", "{", "$", "document", "=", "new", "Document", "(", ")", ";", "$", "document", "->", "setDrop", "(", "$"...
Creates a Document. @param Drop $drop @param User $user @param int $documentType @param mixed $documentData @return Document
[ "Creates", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L440-L460
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createFilesDocuments
public function createFilesDocuments(Drop $drop, User $user, array $files) { $documents = []; $documentEntities = []; $currentDate = new \DateTime(); $dropzone = $drop->getDropzone(); $this->om->startFlushSuite(); foreach ($files as $file) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate($currentDate); $document->setType(Document::DOCUMENT_TYPE_FILE); $data = $this->registerUplodadedFile($dropzone, $file); $document->setFile($data); $this->om->persist($document); $documentEntities[] = $document; $documents[] = $this->serializeDocument($document); } $this->om->endFlushSuite(); //tracking for each document, after flush foreach ($documentEntities as $entity) { $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $entity)); } return $documents; }
php
public function createFilesDocuments(Drop $drop, User $user, array $files) { $documents = []; $documentEntities = []; $currentDate = new \DateTime(); $dropzone = $drop->getDropzone(); $this->om->startFlushSuite(); foreach ($files as $file) { $document = new Document(); $document->setDrop($drop); $document->setUser($user); $document->setDropDate($currentDate); $document->setType(Document::DOCUMENT_TYPE_FILE); $data = $this->registerUplodadedFile($dropzone, $file); $document->setFile($data); $this->om->persist($document); $documentEntities[] = $document; $documents[] = $this->serializeDocument($document); } $this->om->endFlushSuite(); //tracking for each document, after flush foreach ($documentEntities as $entity) { $this->eventDispatcher->dispatch('log', new LogDocumentCreateEvent($drop->getDropzone(), $drop, $entity)); } return $documents; }
[ "public", "function", "createFilesDocuments", "(", "Drop", "$", "drop", ",", "User", "$", "user", ",", "array", "$", "files", ")", "{", "$", "documents", "=", "[", "]", ";", "$", "documentEntities", "=", "[", "]", ";", "$", "currentDate", "=", "new", ...
Creates Files Documents. @param Drop $drop @param User $user @param array $files @return array
[ "Creates", "Files", "Documents", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L471-L499
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.submitDrop
public function submitDrop(Drop $drop, User $user) { $this->om->startFlushSuite(); $drop->setFinished(true); $drop->setDropDate(new \DateTime()); if ($drop->getTeamUuid()) { $drop->setUser($user); } $users = $drop->getTeamUuid() ? $drop->getUsers() : [$drop->getUser()]; $this->om->persist($drop); $this->checkCompletion($drop->getDropzone(), $users, $drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropEndEvent($drop->getDropzone(), $drop, $this->roleManager)); }
php
public function submitDrop(Drop $drop, User $user) { $this->om->startFlushSuite(); $drop->setFinished(true); $drop->setDropDate(new \DateTime()); if ($drop->getTeamUuid()) { $drop->setUser($user); } $users = $drop->getTeamUuid() ? $drop->getUsers() : [$drop->getUser()]; $this->om->persist($drop); $this->checkCompletion($drop->getDropzone(), $users, $drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogDropEndEvent($drop->getDropzone(), $drop, $this->roleManager)); }
[ "public", "function", "submitDrop", "(", "Drop", "$", "drop", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "drop", "->", "setFinished", "(", "true", ")", ";", "$", "drop", "->", "setDropDat...
Terminates a drop. @param Drop $drop @param User $user
[ "Terminates", "a", "drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L527-L544
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.computeDropScore
public function computeDropScore(Drop $drop) { $corrections = $drop->getCorrections(); $score = 0; $nbValidCorrection = 0; foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { $score += $correction->getScore(); ++$nbValidCorrection; } } $score = $nbValidCorrection > 0 ? round($score / $nbValidCorrection, 2) : null; $drop->setScore($score); $this->om->persist($drop); $this->om->flush(); return $drop; }
php
public function computeDropScore(Drop $drop) { $corrections = $drop->getCorrections(); $score = 0; $nbValidCorrection = 0; foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { $score += $correction->getScore(); ++$nbValidCorrection; } } $score = $nbValidCorrection > 0 ? round($score / $nbValidCorrection, 2) : null; $drop->setScore($score); $this->om->persist($drop); $this->om->flush(); return $drop; }
[ "public", "function", "computeDropScore", "(", "Drop", "$", "drop", ")", "{", "$", "corrections", "=", "$", "drop", "->", "getCorrections", "(", ")", ";", "$", "score", "=", "0", ";", "$", "nbValidCorrection", "=", "0", ";", "foreach", "(", "$", "corre...
Computes Drop score from submitted Corrections. @param Drop $drop @return Drop
[ "Computes", "Drop", "score", "from", "submitted", "Corrections", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L553-L571
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.closeAllUnfinishedDrops
public function closeAllUnfinishedDrops(Dropzone $dropzone) { $this->om->startFlushSuite(); $currentDate = new \DateTime(); $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'finished' => false]); /** @var Drop $drop */ foreach ($drops as $drop) { $drop->setFinished(true); $drop->setDropDate($currentDate); $drop->setAutoClosedDrop(true); $this->om->persist($drop); } $dropzone->setDropClosed(true); $this->om->persist($dropzone); $this->om->endFlushSuite(); }
php
public function closeAllUnfinishedDrops(Dropzone $dropzone) { $this->om->startFlushSuite(); $currentDate = new \DateTime(); $drops = $this->dropRepo->findBy(['dropzone' => $dropzone, 'finished' => false]); /** @var Drop $drop */ foreach ($drops as $drop) { $drop->setFinished(true); $drop->setDropDate($currentDate); $drop->setAutoClosedDrop(true); $this->om->persist($drop); } $dropzone->setDropClosed(true); $this->om->persist($dropzone); $this->om->endFlushSuite(); }
[ "public", "function", "closeAllUnfinishedDrops", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "currentDate", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "drops", "=", "$", "this",...
Closes all unfinished drops. @param Dropzone $dropzone
[ "Closes", "all", "unfinished", "drops", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L647-L665
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.saveCorrection
public function saveCorrection(array $data, User $user) { $this->om->startFlushSuite(); $existingCorrection = $this->correctionRepo->findOneBy(['uuid' => $data['id']]); $isNew = empty($existingCorrection); $correction = $this->serializer->get(Correction::class)->deserialize($data); $correction->setUser($user); $dropzone = $correction->getDrop()->getDropzone(); if (!$isNew) { $correction->setLastEditionDate(new \DateTime()); } $correction = $this->computeCorrectionScore($correction); $this->om->persist($correction); $this->om->endFlushSuite(); if ($isNew) { $this->eventDispatcher->dispatch('log', new LogCorrectionStartEvent($dropzone, $correction->getDrop(), $correction)); } else { $this->eventDispatcher->dispatch('log', new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction)); } return $correction; }
php
public function saveCorrection(array $data, User $user) { $this->om->startFlushSuite(); $existingCorrection = $this->correctionRepo->findOneBy(['uuid' => $data['id']]); $isNew = empty($existingCorrection); $correction = $this->serializer->get(Correction::class)->deserialize($data); $correction->setUser($user); $dropzone = $correction->getDrop()->getDropzone(); if (!$isNew) { $correction->setLastEditionDate(new \DateTime()); } $correction = $this->computeCorrectionScore($correction); $this->om->persist($correction); $this->om->endFlushSuite(); if ($isNew) { $this->eventDispatcher->dispatch('log', new LogCorrectionStartEvent($dropzone, $correction->getDrop(), $correction)); } else { $this->eventDispatcher->dispatch('log', new LogCorrectionUpdateEvent($dropzone, $correction->getDrop(), $correction)); } return $correction; }
[ "public", "function", "saveCorrection", "(", "array", "$", "data", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "existingCorrection", "=", "$", "this", "->", "correctionRepo", "->", "findOneBy", ...
Updates a Correction. @param array $data @param User $user @return Correction
[ "Updates", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L675-L698
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.submitCorrection
public function submitCorrection(Correction $correction, User $user) { $this->om->startFlushSuite(); $correction->setFinished(true); $correction->setEndDate(new \DateTime()); $correction->setUser($user); $this->om->persist($correction); $this->om->forceFlush(); $drop = $this->computeDropScore($correction->getDrop()); $dropzone = $drop->getDropzone(); $userDrop = null; $users = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: $users = [$user]; $userDrop = $this->getUserDrop($dropzone, $user); break; case Dropzone::DROP_TYPE_TEAM: $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $users = $teamDrops[0]->getUsers(); $userDrop = $teamDrops[0]; } break; } $this->eventDispatcher->dispatch('log', new LogCorrectionEndEvent($dropzone, $correction->getDrop(), $correction)); $this->om->forceFlush(); $this->checkSuccess($drop); $this->checkCompletion($dropzone, $users, $userDrop); $this->om->endFlushSuite(); return $correction; }
php
public function submitCorrection(Correction $correction, User $user) { $this->om->startFlushSuite(); $correction->setFinished(true); $correction->setEndDate(new \DateTime()); $correction->setUser($user); $this->om->persist($correction); $this->om->forceFlush(); $drop = $this->computeDropScore($correction->getDrop()); $dropzone = $drop->getDropzone(); $userDrop = null; $users = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: $users = [$user]; $userDrop = $this->getUserDrop($dropzone, $user); break; case Dropzone::DROP_TYPE_TEAM: $teamDrops = $this->getTeamDrops($dropzone, $user); if (1 === count($teamDrops)) { $users = $teamDrops[0]->getUsers(); $userDrop = $teamDrops[0]; } break; } $this->eventDispatcher->dispatch('log', new LogCorrectionEndEvent($dropzone, $correction->getDrop(), $correction)); $this->om->forceFlush(); $this->checkSuccess($drop); $this->checkCompletion($dropzone, $users, $userDrop); $this->om->endFlushSuite(); return $correction; }
[ "public", "function", "submitCorrection", "(", "Correction", "$", "correction", ",", "User", "$", "user", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "correction", "->", "setFinished", "(", "true", ")", ";", "$", "corr...
Submits a Correction. @param Correction $correction @param User $user @return Correction
[ "Submits", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L708-L745
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.switchCorrectionValidation
public function switchCorrectionValidation(Correction $correction) { $this->om->startFlushSuite(); $correction->setValid(!$correction->isValid()); $this->om->persist($correction); $drop = $this->computeDropScore($correction->getDrop()); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionValidationChangeEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction)); return $correction; }
php
public function switchCorrectionValidation(Correction $correction) { $this->om->startFlushSuite(); $correction->setValid(!$correction->isValid()); $this->om->persist($correction); $drop = $this->computeDropScore($correction->getDrop()); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionValidationChangeEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction)); return $correction; }
[ "public", "function", "switchCorrectionValidation", "(", "Correction", "$", "correction", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "correction", "->", "setValid", "(", "!", "$", "correction", "->", "isValid", "(", ")", ...
Switch Correction validation. @param Correction $correction @return Correction
[ "Switch", "Correction", "validation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L754-L768
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteCorrection
public function deleteCorrection(Correction $correction) { $this->om->startFlushSuite(); $drop = $correction->getDrop(); $drop->removeCorrection($correction); $this->om->remove($correction); $drop = $this->computeDropScore($drop); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionDeleteEvent($correction->getDrop()->getDropzone(), $drop, $correction)); }
php
public function deleteCorrection(Correction $correction) { $this->om->startFlushSuite(); $drop = $correction->getDrop(); $drop->removeCorrection($correction); $this->om->remove($correction); $drop = $this->computeDropScore($drop); $this->checkSuccess($drop); $this->om->endFlushSuite(); $this->eventDispatcher->dispatch('log', new LogCorrectionDeleteEvent($correction->getDrop()->getDropzone(), $drop, $correction)); }
[ "public", "function", "deleteCorrection", "(", "Correction", "$", "correction", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "drop", "=", "$", "correction", "->", "getDrop", "(", ")", ";", "$", "drop", "->", "removeCorr...
Deletes a Correction. @param Correction $correction
[ "Deletes", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L775-L788
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.denyCorrection
public function denyCorrection(Correction $correction, $comment = null) { $correction->setCorrectionDenied(true); $correction->setCorrectionDeniedComment($comment); $this->om->persist($correction); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogCorrectionReportEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction, $this->roleManager)); return $correction; }
php
public function denyCorrection(Correction $correction, $comment = null) { $correction->setCorrectionDenied(true); $correction->setCorrectionDeniedComment($comment); $this->om->persist($correction); $this->om->flush(); $this->eventDispatcher->dispatch('log', new LogCorrectionReportEvent($correction->getDrop()->getDropzone(), $correction->getDrop(), $correction, $this->roleManager)); return $correction; }
[ "public", "function", "denyCorrection", "(", "Correction", "$", "correction", ",", "$", "comment", "=", "null", ")", "{", "$", "correction", "->", "setCorrectionDenied", "(", "true", ")", ";", "$", "correction", "->", "setCorrectionDeniedComment", "(", "$", "c...
Denies a Correction. @param Correction $correction @param string $comment @return Correction
[ "Denies", "a", "Correction", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L798-L808
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.computeCorrectionScore
public function computeCorrectionScore(Correction $correction) { $drop = $correction->getDrop(); $dropzone = $drop->getDropzone(); $criteria = $dropzone->getCriteria(); if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) { $score = 0; $criteriaIds = []; $scoreMax = $dropzone->getScoreMax(); $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria); $grades = $correction->getGrades(); foreach ($criteria as $criterion) { $criteriaIds[] = $criterion->getUuid(); } foreach ($grades as $grade) { $gradeCriterion = $grade->getCriterion(); if (in_array($gradeCriterion->getUuid(), $criteriaIds)) { $score += $grade->getValue(); } } $score = round(($score / $total) * $scoreMax, 2); $correction->setScore($score); } $this->om->persist($correction); $this->om->flush(); return $correction; }
php
public function computeCorrectionScore(Correction $correction) { $drop = $correction->getDrop(); $dropzone = $drop->getDropzone(); $criteria = $dropzone->getCriteria(); if ($dropzone->isCriteriaEnabled() && count($criteria) > 0) { $score = 0; $criteriaIds = []; $scoreMax = $dropzone->getScoreMax(); $total = ($dropzone->getCriteriaTotal() - 1) * count($criteria); $grades = $correction->getGrades(); foreach ($criteria as $criterion) { $criteriaIds[] = $criterion->getUuid(); } foreach ($grades as $grade) { $gradeCriterion = $grade->getCriterion(); if (in_array($gradeCriterion->getUuid(), $criteriaIds)) { $score += $grade->getValue(); } } $score = round(($score / $total) * $scoreMax, 2); $correction->setScore($score); } $this->om->persist($correction); $this->om->flush(); return $correction; }
[ "public", "function", "computeCorrectionScore", "(", "Correction", "$", "correction", ")", "{", "$", "drop", "=", "$", "correction", "->", "getDrop", "(", ")", ";", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "criteria", "...
Computes Correction score from criteria grades. @param Correction $correction @return Correction
[ "Computes", "Correction", "score", "from", "criteria", "grades", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L817-L847
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.saveTool
public function saveTool(array $data) { $tool = $this->serializer->get(DropzoneTool::class)->deserialize($data); $this->om->persist($tool); $this->om->flush(); return $tool; }
php
public function saveTool(array $data) { $tool = $this->serializer->get(DropzoneTool::class)->deserialize($data); $this->om->persist($tool); $this->om->flush(); return $tool; }
[ "public", "function", "saveTool", "(", "array", "$", "data", ")", "{", "$", "tool", "=", "$", "this", "->", "serializer", "->", "get", "(", "DropzoneTool", "::", "class", ")", "->", "deserialize", "(", "$", "data", ")", ";", "$", "this", "->", "om", ...
Updates a Tool. @param array $data @return Tool
[ "Updates", "a", "Tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L868-L875
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.deleteTool
public function deleteTool(DropzoneTool $tool) { $this->om->remove($tool); $this->om->flush(); }
php
public function deleteTool(DropzoneTool $tool) { $this->om->remove($tool); $this->om->flush(); }
[ "public", "function", "deleteTool", "(", "DropzoneTool", "$", "tool", ")", "{", "$", "this", "->", "om", "->", "remove", "(", "$", "tool", ")", ";", "$", "this", "->", "om", "->", "flush", "(", ")", ";", "}" ]
Deletes a Tool. @param DropzoneTool $tool
[ "Deletes", "a", "Tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L882-L886
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getFinishedUserDrop
public function getFinishedUserDrop(Dropzone $dropzone, User $user = null, $teamId = null) { $drop = null; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drop = $this->dropRepo->findOneBy([ 'dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null, 'finished' => true, ]); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $teamId, 'finished' => true]); } break; } return $drop; }
php
public function getFinishedUserDrop(Dropzone $dropzone, User $user = null, $teamId = null) { $drop = null; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drop = $this->dropRepo->findOneBy([ 'dropzone' => $dropzone, 'user' => $user, 'teamUuid' => null, 'finished' => true, ]); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drop = $this->dropRepo->findOneBy(['dropzone' => $dropzone, 'teamUuid' => $teamId, 'finished' => true]); } break; } return $drop; }
[ "public", "function", "getFinishedUserDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drop", "=", "null", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "(", ")...
Gets user|team drop if it is finished. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "user|team", "drop", "if", "it", "is", "finished", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L910-L933
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getFinishedPeerDrops
public function getFinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserFinishedPeerDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamFinishedPeerDrops($dropzone, $teamId); } break; } return $drops; }
php
public function getFinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserFinishedPeerDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamFinishedPeerDrops($dropzone, $teamId); } break; } return $drops; }
[ "public", "function", "getFinishedPeerDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drops", "=", "[", "]", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "("...
Gets drops corrected by user|team. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "drops", "corrected", "by", "user|team", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L944-L962
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getUnfinishedPeerDrops
public function getUnfinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserUnfinishedPeerDrop($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamUnfinishedPeerDrop($dropzone, $teamId); } break; } return $drops; }
php
public function getUnfinishedPeerDrops(Dropzone $dropzone, User $user = null, $teamId = null) { $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserUnfinishedPeerDrop($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamUnfinishedPeerDrop($dropzone, $teamId); } break; } return $drops; }
[ "public", "function", "getUnfinishedPeerDrops", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ")", "{", "$", "drops", "=", "[", "]", ";", "switch", "(", "$", "dropzone", "->", "getDropType", "...
Gets drops corrected by user|team but that are not finished. @param Dropzone $dropzone @param User $user @param string $teamId @return array
[ "Gets", "drops", "corrected", "by", "user|team", "but", "that", "are", "not", "finished", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L973-L991
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getPeerDrop
public function getPeerDrop(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null, $withCreation = true) { $peerDrop = null; /* Gets user|team drop to check if it is finished before allowing peer review */ $userDrop = $this->getFinishedUserDrop($dropzone, $user, $teamId); /* user|team drop is finished */ if (!empty($userDrop)) { /* Gets drops where user|team has an unfinished correction */ $unfinishedDrops = $this->getUnfinishedPeerDrops($dropzone, $user, $teamId); if (count($unfinishedDrops) > 0) { /* Returns the first drop with an unfinished correction */ $peerDrop = $unfinishedDrops[0]; } else { /* Gets drops where user|team has a finished correction */ $finishedDrops = $this->getFinishedPeerDrops($dropzone, $user, $teamId); $nbCorrections = count($finishedDrops); /* Fetches a drop for peer correction if user|team has not made the expected number of corrections */ if ($withCreation && $dropzone->isReviewEnabled() && $nbCorrections < $dropzone->getExpectedCorrectionTotal()) { $peerDrop = $this->getAvailableDropForPeer($dropzone, $user, $teamId, $teamName); } } } return $peerDrop; }
php
public function getPeerDrop(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null, $withCreation = true) { $peerDrop = null; /* Gets user|team drop to check if it is finished before allowing peer review */ $userDrop = $this->getFinishedUserDrop($dropzone, $user, $teamId); /* user|team drop is finished */ if (!empty($userDrop)) { /* Gets drops where user|team has an unfinished correction */ $unfinishedDrops = $this->getUnfinishedPeerDrops($dropzone, $user, $teamId); if (count($unfinishedDrops) > 0) { /* Returns the first drop with an unfinished correction */ $peerDrop = $unfinishedDrops[0]; } else { /* Gets drops where user|team has a finished correction */ $finishedDrops = $this->getFinishedPeerDrops($dropzone, $user, $teamId); $nbCorrections = count($finishedDrops); /* Fetches a drop for peer correction if user|team has not made the expected number of corrections */ if ($withCreation && $dropzone->isReviewEnabled() && $nbCorrections < $dropzone->getExpectedCorrectionTotal()) { $peerDrop = $this->getAvailableDropForPeer($dropzone, $user, $teamId, $teamName); } } } return $peerDrop; }
[ "public", "function", "getPeerDrop", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ",", "$", "teamName", "=", "null", ",", "$", "withCreation", "=", "true", ")", "{", "$", "peerDrop", "=", "...
Gets a drop for peer evaluation. @param Dropzone $dropzone @param User $user @param string $teamId @param string $teamName @param bool $withCreation @return Drop | null
[ "Gets", "a", "drop", "for", "peer", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1004-L1032
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getAvailableDropForPeer
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null) { $peerDrop = null; $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId); } break; } $validDrops = []; foreach ($drops as $drop) { $corrections = $drop->getCorrections(); if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) { $validDrops[] = $drop; } } if (count($validDrops) > 0) { /* Selects the drop with the least corrections */ $peerDrop = $this->getDropWithTheLeastCorrections($validDrops); /* Creates empty correction */ $correction = new Correction(); $correction->setDrop($peerDrop); $correction->setUser($user); $correction->setTeamUuid($teamId); $correction->setTeamName($teamName); $currentDate = new \DateTime(); $correction->setStartDate($currentDate); $correction->setLastEditionDate($currentDate); $peerDrop->addCorrection($correction); $this->om->persist($correction); $this->om->flush(); } return $peerDrop; }
php
public function getAvailableDropForPeer(Dropzone $dropzone, User $user = null, $teamId = null, $teamName = null) { $peerDrop = null; $drops = []; switch ($dropzone->getDropType()) { case Dropzone::DROP_TYPE_USER: if (!empty($user)) { $drops = $this->dropRepo->findUserAvailableDrops($dropzone, $user); } break; case Dropzone::DROP_TYPE_TEAM: if ($teamId) { $drops = $this->dropRepo->findTeamAvailableDrops($dropzone, $teamId); } break; } $validDrops = []; foreach ($drops as $drop) { $corrections = $drop->getCorrections(); if (count($corrections) < $dropzone->getExpectedCorrectionTotal()) { $validDrops[] = $drop; } } if (count($validDrops) > 0) { /* Selects the drop with the least corrections */ $peerDrop = $this->getDropWithTheLeastCorrections($validDrops); /* Creates empty correction */ $correction = new Correction(); $correction->setDrop($peerDrop); $correction->setUser($user); $correction->setTeamUuid($teamId); $correction->setTeamName($teamName); $currentDate = new \DateTime(); $correction->setStartDate($currentDate); $correction->setLastEditionDate($currentDate); $peerDrop->addCorrection($correction); $this->om->persist($correction); $this->om->flush(); } return $peerDrop; }
[ "public", "function", "getAvailableDropForPeer", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", "=", "null", ",", "$", "teamId", "=", "null", ",", "$", "teamName", "=", "null", ")", "{", "$", "peerDrop", "=", "null", ";", "$", "drops", "="...
Gets available drop for peer evaluation. @param Dropzone $dropzone @param User $user @param string $teamId @param string $teamName @return Drop | null
[ "Gets", "available", "drop", "for", "peer", "evaluation", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1044-L1089
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.executeTool
public function executeTool(DropzoneTool $tool, Document $document) { if (DropzoneTool::COMPILATIO === $tool->getType() && Document::DOCUMENT_TYPE_FILE === $document->getType()) { $toolDocument = $this->dropzoneToolDocumentRepo->findOneBy(['tool' => $tool, 'document' => $document]); $toolData = $tool->getData(); $compilatio = new \SoapClient($toolData['url']); if (empty($toolDocument)) { $documentData = $document->getFile(); $params = []; $params[] = $toolData['key']; $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['mimeType']); $params[] = base64_encode(file_get_contents($this->filesDir.DIRECTORY_SEPARATOR.$documentData['url'])); $idDocument = $compilatio->__call('addDocumentBase64', $params); $analysisParams = []; $analysisParams[] = $toolData['key']; $analysisParams[] = $idDocument; $compilatio->__call('startDocumentAnalyse', $analysisParams); $reportUrl = $compilatio->__call('getDocumentReportUrl', $analysisParams); if ($idDocument && $reportUrl) { $this->createToolDocument($tool, $document, $idDocument, $reportUrl); } } } return $document; }
php
public function executeTool(DropzoneTool $tool, Document $document) { if (DropzoneTool::COMPILATIO === $tool->getType() && Document::DOCUMENT_TYPE_FILE === $document->getType()) { $toolDocument = $this->dropzoneToolDocumentRepo->findOneBy(['tool' => $tool, 'document' => $document]); $toolData = $tool->getData(); $compilatio = new \SoapClient($toolData['url']); if (empty($toolDocument)) { $documentData = $document->getFile(); $params = []; $params[] = $toolData['key']; $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['name']); $params[] = utf8_encode($documentData['mimeType']); $params[] = base64_encode(file_get_contents($this->filesDir.DIRECTORY_SEPARATOR.$documentData['url'])); $idDocument = $compilatio->__call('addDocumentBase64', $params); $analysisParams = []; $analysisParams[] = $toolData['key']; $analysisParams[] = $idDocument; $compilatio->__call('startDocumentAnalyse', $analysisParams); $reportUrl = $compilatio->__call('getDocumentReportUrl', $analysisParams); if ($idDocument && $reportUrl) { $this->createToolDocument($tool, $document, $idDocument, $reportUrl); } } } return $document; }
[ "public", "function", "executeTool", "(", "DropzoneTool", "$", "tool", ",", "Document", "$", "document", ")", "{", "if", "(", "DropzoneTool", "::", "COMPILATIO", "===", "$", "tool", "->", "getType", "(", ")", "&&", "Document", "::", "DOCUMENT_TYPE_FILE", "==...
Executes a Tool on a Document. @param DropzoneTool $tool @param Document $document @return Document
[ "Executes", "a", "Tool", "on", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1099-L1129
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.createToolDocument
public function createToolDocument(DropzoneTool $tool, Document $document, $idDocument = null, $reportUrl = null) { $toolDocument = new DropzoneToolDocument(); $toolDocument->setTool($tool); $toolDocument->setDocument($document); $data = ['idDocument' => $idDocument, 'reportUrl' => $reportUrl]; $toolDocument->setData($data); $this->om->persist($toolDocument); $this->om->flush(); }
php
public function createToolDocument(DropzoneTool $tool, Document $document, $idDocument = null, $reportUrl = null) { $toolDocument = new DropzoneToolDocument(); $toolDocument->setTool($tool); $toolDocument->setDocument($document); $data = ['idDocument' => $idDocument, 'reportUrl' => $reportUrl]; $toolDocument->setData($data); $this->om->persist($toolDocument); $this->om->flush(); }
[ "public", "function", "createToolDocument", "(", "DropzoneTool", "$", "tool", ",", "Document", "$", "document", ",", "$", "idDocument", "=", "null", ",", "$", "reportUrl", "=", "null", ")", "{", "$", "toolDocument", "=", "new", "DropzoneToolDocument", "(", "...
Associates data generated by a Tool to a Document. @param DropzoneTool $tool @param Document $document @param string $idDocument @param string $reportUrl
[ "Associates", "data", "generated", "by", "a", "Tool", "to", "a", "Document", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1139-L1148
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.checkCompletion
public function checkCompletion(Dropzone $dropzone, array $users, Drop $drop = null) { $fixedStatusList = [ AbstractResourceEvaluation::STATUS_COMPLETED, AbstractResourceEvaluation::STATUS_PASSED, AbstractResourceEvaluation::STATUS_FAILED, ]; $teamId = !empty($drop) ? $drop->getTeamUuid() : null; $this->om->startFlushSuite(); /* By default drop is complete if teacher review is enabled or drop is unlocked for user */ $isComplete = !empty($drop) ? $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedUser()) : false; /* If drop is not complete by default, checks for the number of finished corrections done by user */ if (!$isComplete) { $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $finishedPeerDrops = $this->getFinishedPeerDrops($dropzone, $users[0], $teamId); $isComplete = count($finishedPeerDrops) >= $expectedCorrectionTotal; } if ($isComplete) { foreach ($users as $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (!empty($userEval) && !in_array($userEval->getStatus(), $fixedStatusList)) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_COMPLETED, 'progression' => 100] ); } elseif (!empty($drop)) { $this->updateDropProgression($dropzone, $drop, 100); } //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } } $this->om->endFlushSuite(); }
php
public function checkCompletion(Dropzone $dropzone, array $users, Drop $drop = null) { $fixedStatusList = [ AbstractResourceEvaluation::STATUS_COMPLETED, AbstractResourceEvaluation::STATUS_PASSED, AbstractResourceEvaluation::STATUS_FAILED, ]; $teamId = !empty($drop) ? $drop->getTeamUuid() : null; $this->om->startFlushSuite(); /* By default drop is complete if teacher review is enabled or drop is unlocked for user */ $isComplete = !empty($drop) ? $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedUser()) : false; /* If drop is not complete by default, checks for the number of finished corrections done by user */ if (!$isComplete) { $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $finishedPeerDrops = $this->getFinishedPeerDrops($dropzone, $users[0], $teamId); $isComplete = count($finishedPeerDrops) >= $expectedCorrectionTotal; } if ($isComplete) { foreach ($users as $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (!empty($userEval) && !in_array($userEval->getStatus(), $fixedStatusList)) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_COMPLETED, 'progression' => 100] ); } elseif (!empty($drop)) { $this->updateDropProgression($dropzone, $drop, 100); } //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } } $this->om->endFlushSuite(); }
[ "public", "function", "checkCompletion", "(", "Dropzone", "$", "dropzone", ",", "array", "$", "users", ",", "Drop", "$", "drop", "=", "null", ")", "{", "$", "fixedStatusList", "=", "[", "AbstractResourceEvaluation", "::", "STATUS_COMPLETED", ",", "AbstractResour...
Computes Complete status for a user. @param Dropzone $dropzone @param array $users @param Drop $drop
[ "Computes", "Complete", "status", "for", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1157-L1196
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.checkSuccess
public function checkSuccess(Drop $drop) { $this->om->startFlushSuite(); $dropzone = $drop->getDropzone(); $users = [$drop->getUser()]; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $users = $drop->getUsers(); } $computeStatus = $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedDrop()); if (!$computeStatus) { $nbValidCorrections = 0; $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $corrections = $drop->getCorrections(); foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { ++$nbValidCorrections; } } $computeStatus = $nbValidCorrections >= $expectedCorrectionTotal; } if ($computeStatus) { $score = $drop->getScore(); $scoreToPass = $dropzone->getScoreToPass(); $scoreMax = $dropzone->getScoreMax(); $status = !empty($scoreMax) && (($score / $scoreMax) * 100) >= $scoreToPass ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; foreach ($users as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $scoreMax, 'data' => $this->serializeDrop($drop), ], ['status' => true, 'score' => true] ); } $this->eventDispatcher->dispatch('log', new LogDropEvaluateEvent($dropzone, $drop, $drop->getScore())); //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } $this->om->endFlushSuite(); }
php
public function checkSuccess(Drop $drop) { $this->om->startFlushSuite(); $dropzone = $drop->getDropzone(); $users = [$drop->getUser()]; if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { $users = $drop->getUsers(); } $computeStatus = $drop->isFinished() && (!$dropzone->isPeerReview() || $drop->isUnlockedDrop()); if (!$computeStatus) { $nbValidCorrections = 0; $expectedCorrectionTotal = $dropzone->getExpectedCorrectionTotal(); $corrections = $drop->getCorrections(); foreach ($corrections as $correction) { if ($correction->isFinished() && $correction->isValid()) { ++$nbValidCorrections; } } $computeStatus = $nbValidCorrections >= $expectedCorrectionTotal; } if ($computeStatus) { $score = $drop->getScore(); $scoreToPass = $dropzone->getScoreToPass(); $scoreMax = $dropzone->getScoreMax(); $status = !empty($scoreMax) && (($score / $scoreMax) * 100) >= $scoreToPass ? AbstractResourceEvaluation::STATUS_PASSED : AbstractResourceEvaluation::STATUS_FAILED; foreach ($users as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, [ 'status' => $status, 'score' => $score, 'scoreMax' => $scoreMax, 'data' => $this->serializeDrop($drop), ], ['status' => true, 'score' => true] ); } $this->eventDispatcher->dispatch('log', new LogDropEvaluateEvent($dropzone, $drop, $drop->getScore())); //TODO user whose score is available must be notified by LogDropGradeAvailableEvent, when he has done his corrections AND his drop has been corrected } $this->om->endFlushSuite(); }
[ "public", "function", "checkSuccess", "(", "Drop", "$", "drop", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "dropzone", "=", "$", "drop", "->", "getDropzone", "(", ")", ";", "$", "users", "=", "[", "$", "drop", "...
Computes Success status for a Drop. @param Drop $drop
[ "Computes", "Success", "status", "for", "a", "Drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1203-L1256
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.generateResourceUserEvaluation
public function generateResourceUserEvaluation(Dropzone $dropzone, User $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (empty($userEval)) { $userEval = $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_NOT_ATTEMPTED] ); } return $userEval; }
php
public function generateResourceUserEvaluation(Dropzone $dropzone, User $user) { $userEval = $this->resourceEvalManager->getResourceUserEvaluation($dropzone->getResourceNode(), $user, false); if (empty($userEval)) { $userEval = $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['status' => AbstractResourceEvaluation::STATUS_NOT_ATTEMPTED] ); } return $userEval; }
[ "public", "function", "generateResourceUserEvaluation", "(", "Dropzone", "$", "dropzone", ",", "User", "$", "user", ")", "{", "$", "userEval", "=", "$", "this", "->", "resourceEvalManager", "->", "getResourceUserEvaluation", "(", "$", "dropzone", "->", "getResourc...
Retrieves ResourceUserEvaluation for a Dropzone and an user or creates one. @param Dropzone $dropzone @param User $user @return ResourceUserEvaluation
[ "Retrieves", "ResourceUserEvaluation", "for", "a", "Dropzone", "and", "an", "user", "or", "creates", "one", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1266-L1280
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.updateDropProgression
public function updateDropProgression(Dropzone $dropzone, Drop $drop, $progression) { $this->om->startFlushSuite(); if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { foreach ($drop->getUsers() as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } } else { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $drop->getUser(), null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } $this->om->endFlushSuite(); }
php
public function updateDropProgression(Dropzone $dropzone, Drop $drop, $progression) { $this->om->startFlushSuite(); if (Dropzone::DROP_TYPE_TEAM === $dropzone->getDropType()) { foreach ($drop->getUsers() as $user) { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $user, null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } } else { $this->resourceEvalManager->createResourceEvaluation( $dropzone->getResourceNode(), $drop->getUser(), null, ['progression' => $progression, 'data' => $this->serializeDrop($drop)], ['progression' => true] ); } $this->om->endFlushSuite(); }
[ "public", "function", "updateDropProgression", "(", "Dropzone", "$", "dropzone", ",", "Drop", "$", "drop", ",", "$", "progression", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "if", "(", "Dropzone", "::", "DROP_TYPE_TEAM", "=...
Updates progression of ResourceEvaluation for drop. @param Dropzone $dropzone @param Drop $drop @param int $progression @return ResourceUserEvaluation
[ "Updates", "progression", "of", "ResourceEvaluation", "for", "drop", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1291-L1315
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.getAllCorrectionsData
public function getAllCorrectionsData(Dropzone $dropzone) { $data = []; $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); foreach ($corrections as $correction) { $teamId = $correction->getTeamUuid(); $key = empty($teamId) ? 'user_'.$correction->getUser()->getUuid() : 'team_'.$teamId; if (!isset($data[$key])) { $data[$key] = []; } $data[$key][] = $this->serializeCorrection($correction); } return $data; }
php
public function getAllCorrectionsData(Dropzone $dropzone) { $data = []; $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); foreach ($corrections as $correction) { $teamId = $correction->getTeamUuid(); $key = empty($teamId) ? 'user_'.$correction->getUser()->getUuid() : 'team_'.$teamId; if (!isset($data[$key])) { $data[$key] = []; } $data[$key][] = $this->serializeCorrection($correction); } return $data; }
[ "public", "function", "getAllCorrectionsData", "(", "Dropzone", "$", "dropzone", ")", "{", "$", "data", "=", "[", "]", ";", "$", "corrections", "=", "$", "this", "->", "correctionRepo", "->", "findAllCorrectionsByDropzone", "(", "$", "dropzone", ")", ";", "f...
Retrieves all corrections made for a Dropzone. @param Dropzone $dropzone @return array
[ "Retrieves", "all", "corrections", "made", "for", "a", "Dropzone", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1324-L1340
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.copyDropzone
public function copyDropzone(Dropzone $dropzone, DropZone $newDropzone) { foreach ($dropzone->getCriteria() as $criterion) { $newCriterion = new Criterion(); $newCriterion->setDropzone($newDropzone); $newCriterion->setInstruction($criterion->getInstruction()); $this->om->persist($newCriterion); } return $newDropzone; }
php
public function copyDropzone(Dropzone $dropzone, DropZone $newDropzone) { foreach ($dropzone->getCriteria() as $criterion) { $newCriterion = new Criterion(); $newCriterion->setDropzone($newDropzone); $newCriterion->setInstruction($criterion->getInstruction()); $this->om->persist($newCriterion); } return $newDropzone; }
[ "public", "function", "copyDropzone", "(", "Dropzone", "$", "dropzone", ",", "DropZone", "$", "newDropzone", ")", "{", "foreach", "(", "$", "dropzone", "->", "getCriteria", "(", ")", "as", "$", "criterion", ")", "{", "$", "newCriterion", "=", "new", "Crite...
Copy a Dropzone resource. @param Dropzone $dropzone @return Dropzone
[ "Copy", "a", "Dropzone", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1410-L1420
train
claroline/Distribution
plugin/drop-zone/Manager/DropzoneManager.php
DropzoneManager.updateScoreByScoreMax
public function updateScoreByScoreMax(Dropzone $dropzone, $oldScoreMax, $newScoreMax) { $ratio = !empty($oldScoreMax) && !empty($newScoreMax) ? $newScoreMax / $oldScoreMax : 0; if ($ratio) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone]); $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); $i = 0; $this->om->startFlushSuite(); foreach ($drops as $drop) { $score = $drop->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $drop->setScore($newScore); $this->om->persist($drop); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } foreach ($corrections as $correction) { $score = $correction->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $correction->setScore($newScore); $this->om->persist($correction); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } $this->om->endFlushSuite(); } }
php
public function updateScoreByScoreMax(Dropzone $dropzone, $oldScoreMax, $newScoreMax) { $ratio = !empty($oldScoreMax) && !empty($newScoreMax) ? $newScoreMax / $oldScoreMax : 0; if ($ratio) { $drops = $this->dropRepo->findBy(['dropzone' => $dropzone]); $corrections = $this->correctionRepo->findAllCorrectionsByDropzone($dropzone); $i = 0; $this->om->startFlushSuite(); foreach ($drops as $drop) { $score = $drop->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $drop->setScore($newScore); $this->om->persist($drop); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } foreach ($corrections as $correction) { $score = $correction->getScore(); if ($score) { $newScore = round($score * $ratio, 2); $correction->setScore($newScore); $this->om->persist($correction); } ++$i; if (0 === 200 % $i) { $this->om->forceFlush(); } } $this->om->endFlushSuite(); } }
[ "public", "function", "updateScoreByScoreMax", "(", "Dropzone", "$", "dropzone", ",", "$", "oldScoreMax", ",", "$", "newScoreMax", ")", "{", "$", "ratio", "=", "!", "empty", "(", "$", "oldScoreMax", ")", "&&", "!", "empty", "(", "$", "newScoreMax", ")", ...
Fetches all drops and corrections and updates their score depending on new score max. @param Dropzone $dropzone @param float $oldScoreMax @param float $newScoreMax
[ "Fetches", "all", "drops", "and", "corrections", "and", "updates", "their", "score", "depending", "on", "new", "score", "max", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Manager/DropzoneManager.php#L1531-L1572
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.listUnpublishedAction
public function listUnpublishedAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); if ($this->checkPermission('MODERATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode())) { $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, PostManager::GET_UNPUBLISHED_POSTS, true); return new JsonResponse($posts); } else { throw new AccessDeniedException(); } }
php
public function listUnpublishedAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); if ($this->checkPermission('MODERATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode())) { $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, PostManager::GET_UNPUBLISHED_POSTS, true); return new JsonResponse($posts); } else { throw new AccessDeniedException(); } }
[ "public", "function", "listUnpublishedAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ...
Get unpublished blog posts. @EXT\Route("/moderation", name="apiv2_blog_post_list_unpublished") @EXT\Method("GET") @param Blog $blog @return array
[ "Get", "unpublished", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L80-L98
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.listAction
public function listAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, !$blog->getOptions()->getDisplayFullPosts()); return new JsonResponse($posts); }
php
public function listAction(Request $request, Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $parameters = $request->query->all(); //if no edit rights, list only published posts $posts = $this->postManager->getPosts( $blog->getId(), $parameters, $this->checkPermission('ADMINISTRATE', $blog->getResourceNode()) || $this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode()) ? PostManager::GET_ALL_POSTS : PostManager::GET_PUBLISHED_POSTS, !$blog->getOptions()->getDisplayFullPosts()); return new JsonResponse($posts); }
[ "public", "function", "listAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";", "$...
Get blog posts. @EXT\Route("", name="apiv2_blog_post_list") @EXT\Method("GET") @param Blog $blog @return array
[ "Get", "blog", "posts", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L110-L128
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.getAction
public function getAction(Request $request, Blog $blog, $postId) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $post = $this->postManager->getPostByIdOrSlug($blog, $postId); if (is_null($post)) { throw new NotFoundHttpException('Post not found'); } $this->trackingManager->dispatchPostReadEvent($post); $session = $request->getSession(); $sessionViewCounterKey = 'blog_post_view_counter_'.$post->getId(); $now = time(); if ($now >= ($session->get($sessionViewCounterKey) + $this->logThreshold)) { $session->set($sessionViewCounterKey, $now); $this->postManager->updatePostViewCount($post); } return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function getAction(Request $request, Blog $blog, $postId) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); $post = $this->postManager->getPostByIdOrSlug($blog, $postId); if (is_null($post)) { throw new NotFoundHttpException('Post not found'); } $this->trackingManager->dispatchPostReadEvent($post); $session = $request->getSession(); $sessionViewCounterKey = 'blog_post_view_counter_'.$post->getId(); $now = time(); if ($now >= ($session->get($sessionViewCounterKey) + $this->logThreshold)) { $session->set($sessionViewCounterKey, $now); $this->postManager->updatePostViewCount($post); } return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "getAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "$", "postId", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "...
Get blog post. @EXT\Route("/{postId}", name="apiv2_blog_post_get") @EXT\Method("GET") @EXT\ParamConverter("blog", options={"mapping": {"blogId": "uuid"}}) @param Blog $blog @param Post $post @return array
[ "Get", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L142-L163
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.createPostAction
public function createPostAction(Request $request, Blog $blog, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('POST', $blog->getResourceNode())) { $data = json_decode($request->getContent(), true); $post = $this->postManager->createPost($blog, $this->postSerializer->deserialize($data), $user); } else { throw new AccessDeniedException(); } return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function createPostAction(Request $request, Blog $blog, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('POST', $blog->getResourceNode())) { $data = json_decode($request->getContent(), true); $post = $this->postManager->createPost($blog, $this->postSerializer->deserialize($data), $user); } else { throw new AccessDeniedException(); } return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "createPostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ...
Create blog post. @EXT\Route("/new", name="apiv2_blog_post_new") @EXT\Method({"POST", "PUT"}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param User $user @return array
[ "Create", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L177-L188
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.updatePostAction
public function updatePostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $post = $this->postManager->updatePost($blog, $post, $this->postSerializer->deserialize($data), $user); return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function updatePostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $data = json_decode($request->getContent(), true); $post = $this->postManager->updatePost($blog, $post, $this->postSerializer->deserialize($data), $user); return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "updatePostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "Post", "$", "post", ",", "User", "$", "user", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNod...
Update blog post. @EXT\Route("/update/{postId}", name="apiv2_blog_post_update") @EXT\Method("PUT") @EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param Post $post @param User $user @return array
[ "Update", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L204-L212
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.deletePostAction
public function deletePostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $this->postManager->deletePost($blog, $post, $user); return new JsonResponse($post->getId()); }
php
public function deletePostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $this->postManager->deletePost($blog, $post, $user); return new JsonResponse($post->getId()); }
[ "public", "function", "deletePostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "Post", "$", "post", ",", "User", "$", "user", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNod...
Delete blog post. @EXT\Route("/delete/{postId}", name="apiv2_blog_post_delete") @EXT\Method("DELETE") @EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param Post $post @param User $user @return array
[ "Delete", "blog", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L228-L234
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.publishPostAction
public function publishPostAction(Request $request, Blog $blog, Post $post, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode())) { $this->postManager->switchPublicationState($post); return new JsonResponse($this->postSerializer->serialize($post)); } else { throw new AccessDeniedException(); } }
php
public function publishPostAction(Request $request, Blog $blog, Post $post, User $user) { if ($this->checkPermission('EDIT', $blog->getResourceNode()) || $this->checkPermission('MODERATE', $blog->getResourceNode())) { $this->postManager->switchPublicationState($post); return new JsonResponse($this->postSerializer->serialize($post)); } else { throw new AccessDeniedException(); } }
[ "public", "function", "publishPostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "Post", "$", "post", ",", "User", "$", "user", ")", "{", "if", "(", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", ...
Switch post publication state. @EXT\Route("/publish/{postId}", name="apiv2_blog_post_publish") @EXT\Method("PUT") @EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param Post $post @param User $user @return array
[ "Switch", "post", "publication", "state", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L250-L260
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.pinPostAction
public function pinPostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $this->postManager->switchPinState($post); return new JsonResponse($this->postSerializer->serialize($post)); }
php
public function pinPostAction(Request $request, Blog $blog, Post $post, User $user) { $this->checkPermission('EDIT', $blog->getResourceNode(), [], true); $this->postManager->switchPinState($post); return new JsonResponse($this->postSerializer->serialize($post)); }
[ "public", "function", "pinPostAction", "(", "Request", "$", "request", ",", "Blog", "$", "blog", ",", "Post", "$", "post", ",", "User", "$", "user", ")", "{", "$", "this", "->", "checkPermission", "(", "'EDIT'", ",", "$", "blog", "->", "getResourceNode",...
Pin post. @EXT\Route("/pin/{postId}", name="apiv2_blog_post_pin") @EXT\Method("PUT") @EXT\ParamConverter("post", class="IcapBlogBundle:Post", options={"mapping": {"postId": "uuid"}}) @EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false}) @param Blog $blog @param Post $post @param User $user @return array
[ "Pin", "post", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L276-L283
train
claroline/Distribution
plugin/blog/Controller/API/PostController.php
PostController.getBlogAuthorsAction
public function getBlogAuthorsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); return $this->postManager->getAuthors($blog); }
php
public function getBlogAuthorsAction(Blog $blog) { $this->checkPermission('OPEN', $blog->getResourceNode(), [], true); return $this->postManager->getAuthors($blog); }
[ "public", "function", "getBlogAuthorsAction", "(", "Blog", "$", "blog", ")", "{", "$", "this", "->", "checkPermission", "(", "'OPEN'", ",", "$", "blog", "->", "getResourceNode", "(", ")", ",", "[", "]", ",", "true", ")", ";", "return", "$", "this", "->...
Get all authors for a given blog. @EXT\Route("/authors/get", name="apiv2_blog_post_authors") @EXT\Method("GET")
[ "Get", "all", "authors", "for", "a", "given", "blog", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/blog/Controller/API/PostController.php#L291-L296
train
claroline/Distribution
plugin/claco-form/Serializer/FieldChoiceCategorySerializer.php
FieldChoiceCategorySerializer.serialize
public function serialize(FieldChoiceCategory $fieldChoiceCategory) { $serialized = [ 'id' => $fieldChoiceCategory->getUuid(), 'field' => $this->fieldSerializer->serialize($fieldChoiceCategory->getField(), [Options::SERIALIZE_MINIMAL]), 'category' => [ 'id' => $fieldChoiceCategory->getCategory()->getUuid(), ], 'value' => $fieldChoiceCategory->getValue(), ]; return $serialized; }
php
public function serialize(FieldChoiceCategory $fieldChoiceCategory) { $serialized = [ 'id' => $fieldChoiceCategory->getUuid(), 'field' => $this->fieldSerializer->serialize($fieldChoiceCategory->getField(), [Options::SERIALIZE_MINIMAL]), 'category' => [ 'id' => $fieldChoiceCategory->getCategory()->getUuid(), ], 'value' => $fieldChoiceCategory->getValue(), ]; return $serialized; }
[ "public", "function", "serialize", "(", "FieldChoiceCategory", "$", "fieldChoiceCategory", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "fieldChoiceCategory", "->", "getUuid", "(", ")", ",", "'field'", "=>", "$", "this", "->", "fieldSerializer", "...
Serializes a FieldChoiceCategory entity for the JSON api. @param FieldChoiceCategory $fieldChoiceCategory @return array - the serialized representation of the field
[ "Serializes", "a", "FieldChoiceCategory", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/FieldChoiceCategorySerializer.php#L52-L64
train
claroline/Distribution
main/core/Manager/IconSetManager.php
IconSetManager.calibrateIconSets
public function calibrateIconSets() { $this->log('Calibrating icon sets...'); // Get decalibrated icon types $mimeTypes = $this->iconItemRepo->findMimeTypesForCalibration(); if (!empty($mimeTypes)) { $this->log('Calibrating icons for mime types: \''.implode('\', \'', $mimeTypes).'\''); $activeSet = $this->getActiveResourceIconSet(); $activeSetIcons = $this->getIconSetIconsByType($activeSet, true); $resourceIcons = $this ->om ->getRepository('ClarolineCoreBundle:Resource\ResourceIcon') ->findByMimeTypes($mimeTypes); // Fix paths for resourceIcons foreach ($resourceIcons as $resourceIcon) { $curMimeType = $resourceIcon->getMimeType(); $activeSetIcon = $activeSetIcons->getByMimeType($curMimeType); if (!is_null($activeSetIcon) && $activeSetIcon->getResourceIcon()->getId() !== $resourceIcon->getId()) { $resourceIcon->setRelativeUrl($activeSetIcon->getRelativeUrl()); $resourceIconShortcut = $resourceIcon->getShortcutIcon(); $resourceIconShortcut->setRelativeUrl( $activeSetIcon->getResourceIcon()->getShortcutIcon()->getRelativeUrl() ); $this->om->persist($resourceIcon); $this->om->persist($resourceIconShortcut); } } $this->om->flush(); // Recalibrate IconItems $this->iconItemRepo->recalibrateIconItemsForMimeTypes($mimeTypes); // Update resource icons reference after calibration $this->iconItemRepo->updateResourceIconsReferenceAfterCalibration($mimeTypes); // Delete redundant resource icons (the one's duplicated) $this->iconItemRepo->deleteRedundantResourceIconsAfterCalibration($mimeTypes); $this->log('Icon sets calibrated with success.'); return; } $this->log('No mime types found for calibration. Everything works fine.'); return; }
php
public function calibrateIconSets() { $this->log('Calibrating icon sets...'); // Get decalibrated icon types $mimeTypes = $this->iconItemRepo->findMimeTypesForCalibration(); if (!empty($mimeTypes)) { $this->log('Calibrating icons for mime types: \''.implode('\', \'', $mimeTypes).'\''); $activeSet = $this->getActiveResourceIconSet(); $activeSetIcons = $this->getIconSetIconsByType($activeSet, true); $resourceIcons = $this ->om ->getRepository('ClarolineCoreBundle:Resource\ResourceIcon') ->findByMimeTypes($mimeTypes); // Fix paths for resourceIcons foreach ($resourceIcons as $resourceIcon) { $curMimeType = $resourceIcon->getMimeType(); $activeSetIcon = $activeSetIcons->getByMimeType($curMimeType); if (!is_null($activeSetIcon) && $activeSetIcon->getResourceIcon()->getId() !== $resourceIcon->getId()) { $resourceIcon->setRelativeUrl($activeSetIcon->getRelativeUrl()); $resourceIconShortcut = $resourceIcon->getShortcutIcon(); $resourceIconShortcut->setRelativeUrl( $activeSetIcon->getResourceIcon()->getShortcutIcon()->getRelativeUrl() ); $this->om->persist($resourceIcon); $this->om->persist($resourceIconShortcut); } } $this->om->flush(); // Recalibrate IconItems $this->iconItemRepo->recalibrateIconItemsForMimeTypes($mimeTypes); // Update resource icons reference after calibration $this->iconItemRepo->updateResourceIconsReferenceAfterCalibration($mimeTypes); // Delete redundant resource icons (the one's duplicated) $this->iconItemRepo->deleteRedundantResourceIconsAfterCalibration($mimeTypes); $this->log('Icon sets calibrated with success.'); return; } $this->log('No mime types found for calibration. Everything works fine.'); return; }
[ "public", "function", "calibrateIconSets", "(", ")", "{", "$", "this", "->", "log", "(", "'Calibrating icon sets...'", ")", ";", "// Get decalibrated icon types", "$", "mimeTypes", "=", "$", "this", "->", "iconItemRepo", "->", "findMimeTypesForCalibration", "(", ")"...
Re-calibrates icons for icon sets for the case where these icons have been de-calibrated.
[ "Re", "-", "calibrates", "icons", "for", "icon", "sets", "for", "the", "case", "where", "these", "icons", "have", "been", "de", "-", "calibrated", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/IconSetManager.php#L464-L505
train
claroline/Distribution
main/core/Manager/IconSetManager.php
IconSetManager.extractResourceIconSetZipAndReturnNewIconItems
private function extractResourceIconSetZipAndReturnNewIconItems( IconSet $iconSet, ResourceIconSetIconItemList $iconSetIconItemList ) { $ds = DIRECTORY_SEPARATOR; $zipFile = $iconSet->getIconsZipfile(); $cname = $iconSet->getCname(); $iconSetDir = $this->iconSetsWebDir.$ds.$cname; if (!empty($zipFile)) { $zipArchive = new \ZipArchive(); if (true === $zipArchive->open($zipFile)) { //Test to see if a resource stamp icon is present in zip file $resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir); if (!empty($resourceStamp)) { $iconSet->setResourceStampIcon($resourceStamp); $this->om->persist($iconSet); if ($iconSet->isActive()) { $this->regenerateShortcutForAllResourceIcons($resourceStamp); } } //List filenames and extract all files without subfolders for ($i = 0; $i < $zipArchive->numFiles; ++$i) { $file = $zipArchive->getNameIndex($i); $fileinfo = pathinfo($file); $filename = $fileinfo['filename']; //If file associated with one of mimeTypes then extract it. Otherwise don't $alreadyInSet = $iconSetIconItemList->isInSetIcons($filename); $iconItemFilenameList = $alreadyInSet ? $iconSetIconItemList->getSetIcons() : $iconSetIconItemList->getDefaultIcons(); $iconNameTypes = $iconItemFilenameList->getItemByKey($filename); if (!empty($iconNameTypes)) { $iconPath = $iconSetDir.$ds.$fileinfo['basename']; $this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']); $zipArchive->extractTo($iconSetDir, [$file]); foreach ($iconNameTypes->getMimeTypes() as $type) { // If icon don't exist, create it, otherwise update it's url in case of extension change $icon = $iconItemFilenameList->getIconByMimeType($type); if (!$alreadyInSet) { $resourceIcon = $icon->getResourceIcon(); $this->createIconItemForResourceIconSet( $iconSet, $this->getRelativePathForResourceIcon($iconPath), $resourceIcon ); } else { $this->updateIconItemForResourceIconSet( $iconSet, $this->getRelativePathForResourceIcon($iconPath), $icon ); } } } } $zipArchive->close(); } } }
php
private function extractResourceIconSetZipAndReturnNewIconItems( IconSet $iconSet, ResourceIconSetIconItemList $iconSetIconItemList ) { $ds = DIRECTORY_SEPARATOR; $zipFile = $iconSet->getIconsZipfile(); $cname = $iconSet->getCname(); $iconSetDir = $this->iconSetsWebDir.$ds.$cname; if (!empty($zipFile)) { $zipArchive = new \ZipArchive(); if (true === $zipArchive->open($zipFile)) { //Test to see if a resource stamp icon is present in zip file $resourceStamp = $this->extractResourceStampIconFromZip($zipArchive, $iconSetDir); if (!empty($resourceStamp)) { $iconSet->setResourceStampIcon($resourceStamp); $this->om->persist($iconSet); if ($iconSet->isActive()) { $this->regenerateShortcutForAllResourceIcons($resourceStamp); } } //List filenames and extract all files without subfolders for ($i = 0; $i < $zipArchive->numFiles; ++$i) { $file = $zipArchive->getNameIndex($i); $fileinfo = pathinfo($file); $filename = $fileinfo['filename']; //If file associated with one of mimeTypes then extract it. Otherwise don't $alreadyInSet = $iconSetIconItemList->isInSetIcons($filename); $iconItemFilenameList = $alreadyInSet ? $iconSetIconItemList->getSetIcons() : $iconSetIconItemList->getDefaultIcons(); $iconNameTypes = $iconItemFilenameList->getItemByKey($filename); if (!empty($iconNameTypes)) { $iconPath = $iconSetDir.$ds.$fileinfo['basename']; $this->fs->remove($iconSetDir.DIRECTORY_SEPARATOR.$fileinfo['basename']); $zipArchive->extractTo($iconSetDir, [$file]); foreach ($iconNameTypes->getMimeTypes() as $type) { // If icon don't exist, create it, otherwise update it's url in case of extension change $icon = $iconItemFilenameList->getIconByMimeType($type); if (!$alreadyInSet) { $resourceIcon = $icon->getResourceIcon(); $this->createIconItemForResourceIconSet( $iconSet, $this->getRelativePathForResourceIcon($iconPath), $resourceIcon ); } else { $this->updateIconItemForResourceIconSet( $iconSet, $this->getRelativePathForResourceIcon($iconPath), $icon ); } } } } $zipArchive->close(); } } }
[ "private", "function", "extractResourceIconSetZipAndReturnNewIconItems", "(", "IconSet", "$", "iconSet", ",", "ResourceIconSetIconItemList", "$", "iconSetIconItemList", ")", "{", "$", "ds", "=", "DIRECTORY_SEPARATOR", ";", "$", "zipFile", "=", "$", "iconSet", "->", "g...
Extracts icons from provided zipfile into iconSet directory. @param IconSet $iconSet @param $iconSetIconItemList @return array
[ "Extracts", "icons", "from", "provided", "zipfile", "into", "iconSet", "directory", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/IconSetManager.php#L538-L597
train
claroline/Distribution
plugin/agenda/Entity/EventInvitation.php
EventInvitation.setEvent
public function setEvent(\Claroline\AgendaBundle\Entity\Event $event) { $this->event = $event; return $this; }
php
public function setEvent(\Claroline\AgendaBundle\Entity\Event $event) { $this->event = $event; return $this; }
[ "public", "function", "setEvent", "(", "\\", "Claroline", "\\", "AgendaBundle", "\\", "Entity", "\\", "Event", "$", "event", ")", "{", "$", "this", "->", "event", "=", "$", "event", ";", "return", "$", "this", ";", "}" ]
Set event. @param \Claroline\AgendaBundle\Entity\Event $event @return EventInvitation
[ "Set", "event", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/agenda/Entity/EventInvitation.php#L130-L135
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.ensureHasScale
public function ensureHasScale() { if (!$this->hasScales()) { $defaultScale = new Scale(); $defaultScale->setName( $this->translator->trans('scale.default_name', [], 'competency') ); $defaultLevel = new Level(); $defaultLevel->setValue(0); $defaultLevel->setName( $this->translator->trans('scale.default_level_name', [], 'competency') ); $defaultScale->setLevels(new ArrayCollection([$defaultLevel])); $this->om->persist($defaultScale); $this->om->flush(); } }
php
public function ensureHasScale() { if (!$this->hasScales()) { $defaultScale = new Scale(); $defaultScale->setName( $this->translator->trans('scale.default_name', [], 'competency') ); $defaultLevel = new Level(); $defaultLevel->setValue(0); $defaultLevel->setName( $this->translator->trans('scale.default_level_name', [], 'competency') ); $defaultScale->setLevels(new ArrayCollection([$defaultLevel])); $this->om->persist($defaultScale); $this->om->flush(); } }
[ "public", "function", "ensureHasScale", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasScales", "(", ")", ")", "{", "$", "defaultScale", "=", "new", "Scale", "(", ")", ";", "$", "defaultScale", "->", "setName", "(", "$", "this", "->", "transla...
Creates a default scale if no scale exists yet.
[ "Creates", "a", "default", "scale", "if", "no", "scale", "exists", "yet", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L70-L86
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.exportFramework
public function exportFramework(Competency $framework) { $loaded = $this->loadCompetency($framework); return $this->converter->convertToJson($loaded); }
php
public function exportFramework(Competency $framework) { $loaded = $this->loadCompetency($framework); return $this->converter->convertToJson($loaded); }
[ "public", "function", "exportFramework", "(", "Competency", "$", "framework", ")", "{", "$", "loaded", "=", "$", "this", "->", "loadCompetency", "(", "$", "framework", ")", ";", "return", "$", "this", "->", "converter", "->", "convertToJson", "(", "$", "lo...
Returns the JSON representation of a competency framework. @param Competency $framework @return string
[ "Returns", "the", "JSON", "representation", "of", "a", "competency", "framework", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L109-L114
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.importFramework
public function importFramework($frameworkData) { $framework = $this->converter->convertToEntity($frameworkData); $this->om->persist($framework); $this->om->flush(); return $framework; }
php
public function importFramework($frameworkData) { $framework = $this->converter->convertToEntity($frameworkData); $this->om->persist($framework); $this->om->flush(); return $framework; }
[ "public", "function", "importFramework", "(", "$", "frameworkData", ")", "{", "$", "framework", "=", "$", "this", "->", "converter", "->", "convertToEntity", "(", "$", "frameworkData", ")", ";", "$", "this", "->", "om", "->", "persist", "(", "$", "framewor...
Imports a competency framework described in a JSON string. @param string $frameworkData @return Competency
[ "Imports", "a", "competency", "framework", "described", "in", "a", "JSON", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L123-L131
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.walkCollection
public function walkCollection($collection, \Closure $callback) { if (is_array($collection)) { $result = []; foreach ($collection as $key => $item) { $result[$key] = $this->walkCollection($item, $callback); } return $callback($result); } return $collection; }
php
public function walkCollection($collection, \Closure $callback) { if (is_array($collection)) { $result = []; foreach ($collection as $key => $item) { $result[$key] = $this->walkCollection($item, $callback); } return $callback($result); } return $collection; }
[ "public", "function", "walkCollection", "(", "$", "collection", ",", "\\", "Closure", "$", "callback", ")", "{", "if", "(", "is_array", "(", "$", "collection", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", ...
Utility method. Walks a collection recursively, applying a callback on each element. Unlike array_walk_recursive : - the result is a *copy* of the original collection - all the nodes are visited, not only the leafs @param mixed $collection @param \Closure $callback @return mixed
[ "Utility", "method", ".", "Walks", "a", "collection", "recursively", "applying", "a", "callback", "on", "each", "element", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L181-L194
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.associateCompetencyToResources
public function associateCompetencyToResources(Competency $competency, array $nodes) { $associatedNodes = []; foreach ($nodes as $node) { if (!$competency->isLinkedToResource($node)) { $competency->linkResource($node); $associatedNodes[] = $node; } } $this->om->persist($competency); $this->om->flush(); return $associatedNodes; }
php
public function associateCompetencyToResources(Competency $competency, array $nodes) { $associatedNodes = []; foreach ($nodes as $node) { if (!$competency->isLinkedToResource($node)) { $competency->linkResource($node); $associatedNodes[] = $node; } } $this->om->persist($competency); $this->om->flush(); return $associatedNodes; }
[ "public", "function", "associateCompetencyToResources", "(", "Competency", "$", "competency", ",", "array", "$", "nodes", ")", "{", "$", "associatedNodes", "=", "[", "]", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "!", "$"...
Associates a competency to several resource nodes. @param Competency $competency @param array $nodes @return string
[ "Associates", "a", "competency", "to", "several", "resource", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L204-L218
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.dissociateCompetencyFromResources
public function dissociateCompetencyFromResources(Competency $competency, array $nodes) { foreach ($nodes as $node) { $competency->removeResource($node); } $this->om->persist($competency); $this->om->flush(); }
php
public function dissociateCompetencyFromResources(Competency $competency, array $nodes) { foreach ($nodes as $node) { $competency->removeResource($node); } $this->om->persist($competency); $this->om->flush(); }
[ "public", "function", "dissociateCompetencyFromResources", "(", "Competency", "$", "competency", ",", "array", "$", "nodes", ")", "{", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "competency", "->", "removeResource", "(", "$", "node", ")"...
Dissociates a competency from several resource nodes. @param Competency $competency @param array $nodes @return string
[ "Dissociates", "a", "competency", "from", "several", "resource", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L228-L235
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.associateAbilityToResources
public function associateAbilityToResources(Ability $ability, array $nodes) { $associatedNodes = []; foreach ($nodes as $node) { if (!$ability->isLinkedToResource($node)) { $ability->linkResource($node); $associatedNodes[] = $node; } } $this->om->persist($ability); $this->om->flush(); return $associatedNodes; }
php
public function associateAbilityToResources(Ability $ability, array $nodes) { $associatedNodes = []; foreach ($nodes as $node) { if (!$ability->isLinkedToResource($node)) { $ability->linkResource($node); $associatedNodes[] = $node; } } $this->om->persist($ability); $this->om->flush(); return $associatedNodes; }
[ "public", "function", "associateAbilityToResources", "(", "Ability", "$", "ability", ",", "array", "$", "nodes", ")", "{", "$", "associatedNodes", "=", "[", "]", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "!", "$", "abil...
Associates an ability to several resource nodes. @param Ability $ability @param array $nodes @return string
[ "Associates", "an", "ability", "to", "several", "resource", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L245-L259
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.dissociateAbilityFromResources
public function dissociateAbilityFromResources(Ability $ability, array $nodes) { foreach ($nodes as $node) { $ability->removeResource($node); } $this->om->persist($ability); $this->om->flush(); }
php
public function dissociateAbilityFromResources(Ability $ability, array $nodes) { foreach ($nodes as $node) { $ability->removeResource($node); } $this->om->persist($ability); $this->om->flush(); }
[ "public", "function", "dissociateAbilityFromResources", "(", "Ability", "$", "ability", ",", "array", "$", "nodes", ")", "{", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "ability", "->", "removeResource", "(", "$", "node", ")", ";", "...
Dissociates an ability from several resource nodes. @param Ability $ability @param array $nodes @return string
[ "Dissociates", "an", "ability", "from", "several", "resource", "nodes", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L269-L276
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.listFrameworks
public function listFrameworks($shortArrays = false) { $frameworks = $this->competencyRepo->findBy(['parent' => null]); return !$shortArrays ? $frameworks : array_map(function ($framework) { return [ 'id' => $framework->getId(), 'name' => $framework->getName(), 'description' => $framework->getDescription(), ]; }, $frameworks); }
php
public function listFrameworks($shortArrays = false) { $frameworks = $this->competencyRepo->findBy(['parent' => null]); return !$shortArrays ? $frameworks : array_map(function ($framework) { return [ 'id' => $framework->getId(), 'name' => $framework->getName(), 'description' => $framework->getDescription(), ]; }, $frameworks); }
[ "public", "function", "listFrameworks", "(", "$", "shortArrays", "=", "false", ")", "{", "$", "frameworks", "=", "$", "this", "->", "competencyRepo", "->", "findBy", "(", "[", "'parent'", "=>", "null", "]", ")", ";", "return", "!", "$", "shortArrays", "?...
Returns the list of registered frameworks. @param bool $shortArrays Whether full entities or minimal arrays should be returned @return array
[ "Returns", "the", "list", "of", "registered", "frameworks", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L287-L300
train
claroline/Distribution
plugin/competency/Manager/CompetencyManager.php
CompetencyManager.loadAbility
public function loadAbility(Competency $parent, Ability $ability) { $link = $this->competencyAbilityRepo->findOneByTerms($parent, $ability); $ability->setLevel($link->getLevel()); }
php
public function loadAbility(Competency $parent, Ability $ability) { $link = $this->competencyAbilityRepo->findOneByTerms($parent, $ability); $ability->setLevel($link->getLevel()); }
[ "public", "function", "loadAbility", "(", "Competency", "$", "parent", ",", "Ability", "$", "ability", ")", "{", "$", "link", "=", "$", "this", "->", "competencyAbilityRepo", "->", "findOneByTerms", "(", "$", "parent", ",", "$", "ability", ")", ";", "$", ...
Sets the level temporary attribute of an ability. @param Competency $parent @param Ability $ability
[ "Sets", "the", "level", "temporary", "attribute", "of", "an", "ability", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/CompetencyManager.php#L308-L312
train
claroline/Distribution
plugin/competency/Repository/ObjectiveRepository.php
ObjectiveRepository.findByUser
public function findByUser(User $user, $asArray = true) { $groupQb = $this->_em->createQueryBuilder() ->select('g') ->from('Claroline\CoreBundle\Entity\Group', 'g') ->join('g.users', 'gu') ->where('gu = :user'); $select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o'; $query = $this->createQueryBuilder('o') ->select($select) ->leftJoin('o.objectiveCompetencies', 'oc') ->leftJoin('o.users', 'ou') ->leftJoin('o.groups', 'og') ->leftJoin( 'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress', 'op', 'WITH', 'op.user = :user AND op.objective = o' ) ->andWhere($groupQb->expr()->orX( 'ou = :user', $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL()) )) ->groupBy('o.id') ->setParameter(':user', $user) ->getQuery(); return $query->{$asArray ? 'getArrayResult' : 'getResult'}(); }
php
public function findByUser(User $user, $asArray = true) { $groupQb = $this->_em->createQueryBuilder() ->select('g') ->from('Claroline\CoreBundle\Entity\Group', 'g') ->join('g.users', 'gu') ->where('gu = :user'); $select = $asArray ? 'o.id, o.name, op.percentage AS progress, COUNT(oc) AS competencyCount' : 'o'; $query = $this->createQueryBuilder('o') ->select($select) ->leftJoin('o.objectiveCompetencies', 'oc') ->leftJoin('o.users', 'ou') ->leftJoin('o.groups', 'og') ->leftJoin( 'HeVinci\CompetencyBundle\Entity\Progress\ObjectiveProgress', 'op', 'WITH', 'op.user = :user AND op.objective = o' ) ->andWhere($groupQb->expr()->orX( 'ou = :user', $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL()) )) ->groupBy('o.id') ->setParameter(':user', $user) ->getQuery(); return $query->{$asArray ? 'getArrayResult' : 'getResult'}(); }
[ "public", "function", "findByUser", "(", "User", "$", "user", ",", "$", "asArray", "=", "true", ")", "{", "$", "groupQb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'g'", ")", "->", "from", "(", "'Claro...
Returns the objectives assigned to a user. Objectives assigned to groups whose the user is a member of are also returned. @param User $user @param bool $asArray @return array
[ "Returns", "the", "objectives", "assigned", "to", "a", "user", ".", "Objectives", "assigned", "to", "groups", "whose", "the", "user", "is", "a", "member", "of", "are", "also", "returned", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L40-L70
train
claroline/Distribution
plugin/competency/Repository/ObjectiveRepository.php
ObjectiveRepository.findByGroup
public function findByGroup(Group $group) { return $this->createQueryBuilder('o') ->select('o.id', 'o.name') ->join('o.groups', 'g') ->where('g = :group') ->groupBy('o.id') ->setParameter(':group', $group) ->getQuery() ->getArrayResult(); }
php
public function findByGroup(Group $group) { return $this->createQueryBuilder('o') ->select('o.id', 'o.name') ->join('o.groups', 'g') ->where('g = :group') ->groupBy('o.id') ->setParameter(':group', $group) ->getQuery() ->getArrayResult(); }
[ "public", "function", "findByGroup", "(", "Group", "$", "group", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'o'", ")", "->", "select", "(", "'o.id'", ",", "'o.name'", ")", "->", "join", "(", "'o.groups'", ",", "'g'", ")", "->", ...
Returns an array representation of the objectives assigned to a group. @param Group $group @return array
[ "Returns", "an", "array", "representation", "of", "the", "objectives", "assigned", "to", "a", "group", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L91-L101
train
claroline/Distribution
plugin/competency/Repository/ObjectiveRepository.php
ObjectiveRepository.findByCompetencyAndUser
public function findByCompetencyAndUser(Competency $competency, User $user) { $groupQb = $this->_em->createQueryBuilder() ->select('g') ->from('Claroline\CoreBundle\Entity\Group', 'g') ->join('g.users', 'gu') ->where('gu = :user'); return $this->createQueryBuilder('o') ->select('o') ->leftJoin('o.objectiveCompetencies', 'oc') ->leftJoin('o.users', 'ou') ->leftJoin('o.groups', 'og') ->where('oc.competency = :competency') ->andWhere($groupQb->expr()->orX( 'ou = :user', $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL()) )) ->setParameters([ 'competency' => $competency, 'user' => $user, ]) ->distinct() ->getQuery() ->getResult(); }
php
public function findByCompetencyAndUser(Competency $competency, User $user) { $groupQb = $this->_em->createQueryBuilder() ->select('g') ->from('Claroline\CoreBundle\Entity\Group', 'g') ->join('g.users', 'gu') ->where('gu = :user'); return $this->createQueryBuilder('o') ->select('o') ->leftJoin('o.objectiveCompetencies', 'oc') ->leftJoin('o.users', 'ou') ->leftJoin('o.groups', 'og') ->where('oc.competency = :competency') ->andWhere($groupQb->expr()->orX( 'ou = :user', $groupQb->expr()->in('og', $groupQb->getQuery()->getDQL()) )) ->setParameters([ 'competency' => $competency, 'user' => $user, ]) ->distinct() ->getQuery() ->getResult(); }
[ "public", "function", "findByCompetencyAndUser", "(", "Competency", "$", "competency", ",", "User", "$", "user", ")", "{", "$", "groupQb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'g'", ")", "->", "from", ...
Returns the objectives assigned to a user which includes a given competency. Objectives assigned to groups whose the user is a member of are also returned. @param Competency $competency @param User $user @return array
[ "Returns", "the", "objectives", "assigned", "to", "a", "user", "which", "includes", "a", "given", "competency", ".", "Objectives", "assigned", "to", "groups", "whose", "the", "user", "is", "a", "member", "of", "are", "also", "returned", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L113-L138
train
claroline/Distribution
plugin/competency/Repository/ObjectiveRepository.php
ObjectiveRepository.findUsersWithObjective
public function findUsersWithObjective(Objective $objective) { $usersQb = $this->createQueryBuilder('o1') ->select('ou.id') ->join('o1.users', 'ou') ->where('o1 = :objective'); $groupsQb = $this->createQueryBuilder('o2') ->select('og.id') ->join('o2.groups', 'og') ->where('o2 = :objective'); return $this->_em->createQueryBuilder() ->select('u') ->from('Claroline\CoreBundle\Entity\User', 'u') ->leftJoin('HeVinci\CompetencyBundle\Entity\Progress\UserProgress', 'up', 'WITH', 'up.user = u') ->leftJoin('u.groups', 'ug') ->where((new Expr())->in('u.id', $usersQb->getDQL())) ->orWhere((new Expr())->in('ug.id', $groupsQb->getDQL())) ->setParameter(':objective', $objective) ->getQuery() ->getResult(); }
php
public function findUsersWithObjective(Objective $objective) { $usersQb = $this->createQueryBuilder('o1') ->select('ou.id') ->join('o1.users', 'ou') ->where('o1 = :objective'); $groupsQb = $this->createQueryBuilder('o2') ->select('og.id') ->join('o2.groups', 'og') ->where('o2 = :objective'); return $this->_em->createQueryBuilder() ->select('u') ->from('Claroline\CoreBundle\Entity\User', 'u') ->leftJoin('HeVinci\CompetencyBundle\Entity\Progress\UserProgress', 'up', 'WITH', 'up.user = u') ->leftJoin('u.groups', 'ug') ->where((new Expr())->in('u.id', $usersQb->getDQL())) ->orWhere((new Expr())->in('ug.id', $groupsQb->getDQL())) ->setParameter(':objective', $objective) ->getQuery() ->getResult(); }
[ "public", "function", "findUsersWithObjective", "(", "Objective", "$", "objective", ")", "{", "$", "usersQb", "=", "$", "this", "->", "createQueryBuilder", "(", "'o1'", ")", "->", "select", "(", "'ou.id'", ")", "->", "join", "(", "'o1.users'", ",", "'ou'", ...
Returns all the users and group members who have a given objective. @param Objective $objective @return array
[ "Returns", "all", "the", "users", "and", "group", "members", "who", "have", "a", "given", "objective", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/ObjectiveRepository.php#L147-L168
train
claroline/Distribution
plugin/competency/Repository/CompetencyRepository.php
CompetencyRepository.findByResource
public function findByResource(ResourceNode $resource) { return $this->createQueryBuilder('c') ->select('c') ->join('c.resources', 'r') ->where('r = :resource') ->setParameter(':resource', $resource) ->getQuery() ->getResult(); }
php
public function findByResource(ResourceNode $resource) { return $this->createQueryBuilder('c') ->select('c') ->join('c.resources', 'r') ->where('r = :resource') ->setParameter(':resource', $resource) ->getQuery() ->getResult(); }
[ "public", "function", "findByResource", "(", "ResourceNode", "$", "resource", ")", "{", "return", "$", "this", "->", "createQueryBuilder", "(", "'c'", ")", "->", "select", "(", "'c'", ")", "->", "join", "(", "'c.resources'", ",", "'r'", ")", "->", "where",...
Returns the competencies associated with a resource. @param ResourceNode $resource @return array
[ "Returns", "the", "competencies", "associated", "with", "a", "resource", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L30-L39
train
claroline/Distribution
plugin/competency/Repository/CompetencyRepository.php
CompetencyRepository.findFirstUsersByName
public function findFirstUsersByName($search) { return $this->_em->createQueryBuilder() ->select( 'u.id', "CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name" ) ->from('ClarolineCoreBundle:User', 'u') ->where('u.firstName LIKE :search') ->orWhere('u.lastName LIKE :search') ->orWhere('u.username LIKE :search') ->setMaxResults(5) ->setParameter(':search', "%{$search}%") ->getQuery() ->getArrayResult(); }
php
public function findFirstUsersByName($search) { return $this->_em->createQueryBuilder() ->select( 'u.id', "CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name" ) ->from('ClarolineCoreBundle:User', 'u') ->where('u.firstName LIKE :search') ->orWhere('u.lastName LIKE :search') ->orWhere('u.username LIKE :search') ->setMaxResults(5) ->setParameter(':search', "%{$search}%") ->getQuery() ->getArrayResult(); }
[ "public", "function", "findFirstUsersByName", "(", "$", "search", ")", "{", "return", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'u.id'", ",", "\"CONCAT(u.firstName, ' ', u.lastName, ' (', u.username, ')') AS name\"", ")", "-...
Returns the first five users whose first name, last name or username include a given string. Note: this should definitely not be here @param string $search @return array
[ "Returns", "the", "first", "five", "users", "whose", "first", "name", "last", "name", "or", "username", "include", "a", "given", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L51-L66
train
claroline/Distribution
plugin/competency/Repository/CompetencyRepository.php
CompetencyRepository.findFirstGroupsByName
public function findFirstGroupsByName($search) { return $this->_em->createQueryBuilder() ->select('g.id, g.name') ->from('ClarolineCoreBundle:Group', 'g') ->where('g.name LIKE :search') ->setMaxResults(5) ->setParameter(':search', "%{$search}%") ->getQuery() ->getArrayResult(); }
php
public function findFirstGroupsByName($search) { return $this->_em->createQueryBuilder() ->select('g.id, g.name') ->from('ClarolineCoreBundle:Group', 'g') ->where('g.name LIKE :search') ->setMaxResults(5) ->setParameter(':search', "%{$search}%") ->getQuery() ->getArrayResult(); }
[ "public", "function", "findFirstGroupsByName", "(", "$", "search", ")", "{", "return", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", "->", "select", "(", "'g.id, g.name'", ")", "->", "from", "(", "'ClarolineCoreBundle:Group'", ",", "'g'", ")"...
Returns the first five users whose name includes a given string. Note: this should definitely not be here @param string $search @return array
[ "Returns", "the", "first", "five", "users", "whose", "name", "includes", "a", "given", "string", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/CompetencyRepository.php#L77-L87
train
claroline/Distribution
plugin/exo/Serializer/Item/HintSerializer.php
HintSerializer.serialize
public function serialize(Hint $hint, array $options = []) { $serialized = [ 'id' => $hint->getUuid(), 'penalty' => $hint->getPenalty(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['value'] = $hint->getData(); } return $serialized; }
php
public function serialize(Hint $hint, array $options = []) { $serialized = [ 'id' => $hint->getUuid(), 'penalty' => $hint->getPenalty(), ]; if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) { $serialized['value'] = $hint->getData(); } return $serialized; }
[ "public", "function", "serialize", "(", "Hint", "$", "hint", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "hint", "->", "getUuid", "(", ")", ",", "'penalty'", "=>", "$", "hint", "->", "getPe...
Converts a Hint into a JSON-encodable structure. @param Hint $hint @param array $options @return array
[ "Converts", "a", "Hint", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/HintSerializer.php#L28-L40
train
claroline/Distribution
plugin/exo/Serializer/Item/HintSerializer.php
HintSerializer.deserialize
public function deserialize($data, Hint $hint = null, array $options = []) { $hint = $hint ?: new Hint(); $this->sipe('id', 'setUuid', $data, $hint); $this->sipe('penalty', 'setPenalty', $data, $hint); $this->sipe('value', 'setData', $data, $hint); if (in_array(Transfer::REFRESH_UUID, $options)) { $hint->refreshUuid(); } return $hint; }
php
public function deserialize($data, Hint $hint = null, array $options = []) { $hint = $hint ?: new Hint(); $this->sipe('id', 'setUuid', $data, $hint); $this->sipe('penalty', 'setPenalty', $data, $hint); $this->sipe('value', 'setData', $data, $hint); if (in_array(Transfer::REFRESH_UUID, $options)) { $hint->refreshUuid(); } return $hint; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "Hint", "$", "hint", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "hint", "=", "$", "hint", "?", ":", "new", "Hint", "(", ")", ";", "$", "this", "->", "sipe...
Converts raw data into a Hint entity. @param array $data @param Hint $hint @param array $options @return Hint
[ "Converts", "raw", "data", "into", "a", "Hint", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/HintSerializer.php#L51-L63
train
claroline/Distribution
main/core/API/Serializer/Resource/ResourceCommentSerializer.php
ResourceCommentSerializer.serialize
public function serialize(ResourceComment $comment, array $options = []) { $serialized = [ 'id' => $comment->getUuid(), 'content' => $comment->getContent(), 'user' => $comment->getUser() ? $this->userSerializer->serialize($comment->getUser(), [Options::SERIALIZE_MINIMAL]) : null, 'creationDate' => $comment->getCreationDate() ? DateNormalizer::normalize($comment->getCreationDate()) : null, 'editionDate' => $comment->getEditionDate() ? DateNormalizer::normalize($comment->getEditionDate()) : null, ]; return $serialized; }
php
public function serialize(ResourceComment $comment, array $options = []) { $serialized = [ 'id' => $comment->getUuid(), 'content' => $comment->getContent(), 'user' => $comment->getUser() ? $this->userSerializer->serialize($comment->getUser(), [Options::SERIALIZE_MINIMAL]) : null, 'creationDate' => $comment->getCreationDate() ? DateNormalizer::normalize($comment->getCreationDate()) : null, 'editionDate' => $comment->getEditionDate() ? DateNormalizer::normalize($comment->getEditionDate()) : null, ]; return $serialized; }
[ "public", "function", "serialize", "(", "ResourceComment", "$", "comment", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "comment", "->", "getUuid", "(", ")", ",", "'content'", "=>", "$", "commen...
Serializes a ResourceComment entity for the JSON api. @param ResourceComment $comment - the comment to serialize @param array $options @return array - the serialized representation of the comment
[ "Serializes", "a", "ResourceComment", "entity", "for", "the", "JSON", "api", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceCommentSerializer.php#L53-L64
train
claroline/Distribution
main/core/Manager/RoleManager.php
RoleManager.validateRoleInsert
public function validateRoleInsert(AbstractRoleSubject $ars, Role $role) { $total = $this->countUsersByRoleIncludingGroup($role); //cli always win! if ('ROLE_ADMIN' === $role->getName() && 'cli' === php_sapi_name() || //web installer too null === $this->container->get('security.token_storage')->getToken()) { return true; } if ('ROLE_ADMIN' === $role->getName() && !$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) { return false; } //if we already have the role, then it's ok if ($ars->hasRole($role->getName())) { return true; } if (null === $role->getMaxUsers()) { return true; } if ($role->getWorkspace()) { $maxUsers = $role->getWorkspace()->getMaxUsers(); $countByWorkspace = $this->container->get('claroline.api.finder')->fetch( User::class, ['workspace' => $role->getWorkspace()->getUuid()], null, 0, -1, true ); if ($maxUsers <= $countByWorkspace) { return false; } } if ($ars instanceof User) { return $total < $role->getMaxUsers(); } if ($ars instanceof Group) { $userCount = $this->userRepo->countUsersOfGroup($ars); $userWithRoleCount = $this->userRepo->countUsersOfGroupByRole($ars, $role); return $total + $userCount - $userWithRoleCount < $role->getMaxUsers(); } return false; }
php
public function validateRoleInsert(AbstractRoleSubject $ars, Role $role) { $total = $this->countUsersByRoleIncludingGroup($role); //cli always win! if ('ROLE_ADMIN' === $role->getName() && 'cli' === php_sapi_name() || //web installer too null === $this->container->get('security.token_storage')->getToken()) { return true; } if ('ROLE_ADMIN' === $role->getName() && !$this->container->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) { return false; } //if we already have the role, then it's ok if ($ars->hasRole($role->getName())) { return true; } if (null === $role->getMaxUsers()) { return true; } if ($role->getWorkspace()) { $maxUsers = $role->getWorkspace()->getMaxUsers(); $countByWorkspace = $this->container->get('claroline.api.finder')->fetch( User::class, ['workspace' => $role->getWorkspace()->getUuid()], null, 0, -1, true ); if ($maxUsers <= $countByWorkspace) { return false; } } if ($ars instanceof User) { return $total < $role->getMaxUsers(); } if ($ars instanceof Group) { $userCount = $this->userRepo->countUsersOfGroup($ars); $userWithRoleCount = $this->userRepo->countUsersOfGroupByRole($ars, $role); return $total + $userCount - $userWithRoleCount < $role->getMaxUsers(); } return false; }
[ "public", "function", "validateRoleInsert", "(", "AbstractRoleSubject", "$", "ars", ",", "Role", "$", "role", ")", "{", "$", "total", "=", "$", "this", "->", "countUsersByRoleIncludingGroup", "(", "$", "role", ")", ";", "//cli always win!", "if", "(", "'ROLE_A...
Returns if a role can be added to a RoleSubject. @param AbstractRoleSubject $ars @param Role $role @return bool
[ "Returns", "if", "a", "role", "can", "be", "added", "to", "a", "RoleSubject", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/RoleManager.php#L820-L872
train
claroline/Distribution
main/core/Manager/RoleManager.php
RoleManager.initializeLimit
public function initializeLimit(Role $role) { $count = $this->countUsersByRoleIncludingGroup($role); $role->setMaxUsers($count); $this->om->persist($role); $this->om->flush(); }
php
public function initializeLimit(Role $role) { $count = $this->countUsersByRoleIncludingGroup($role); $role->setMaxUsers($count); $this->om->persist($role); $this->om->flush(); }
[ "public", "function", "initializeLimit", "(", "Role", "$", "role", ")", "{", "$", "count", "=", "$", "this", "->", "countUsersByRoleIncludingGroup", "(", "$", "role", ")", ";", "$", "role", "->", "setMaxUsers", "(", "$", "count", ")", ";", "$", "this", ...
This functions sets the role limit equal to the current number of users having that role. @param Role $role
[ "This", "functions", "sets", "the", "role", "limit", "equal", "to", "the", "current", "number", "of", "users", "having", "that", "role", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/RoleManager.php#L918-L924
train
claroline/Distribution
main/core/Listener/Administration/WorkspaceListener.php
WorkspaceListener.onDisplayTool
public function onDisplayTool(OpenAdministrationToolEvent $event) { $workspaceTools = $this->toolManager->getAvailableWorkspaceTools(); $content = $this->templating->render( 'ClarolineCoreBundle:administration:workspaces.html.twig', [ 'parameters' => $this->parametersSerializer->serialize(), 'tools' => array_map(function (Tool $tool) { return ['name' => $tool->getName()]; }, $workspaceTools), 'models' => $this->finder->search( Workspace::class, ['filters' => ['model' => true]], [Options::SERIALIZE_MINIMAL] ), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
php
public function onDisplayTool(OpenAdministrationToolEvent $event) { $workspaceTools = $this->toolManager->getAvailableWorkspaceTools(); $content = $this->templating->render( 'ClarolineCoreBundle:administration:workspaces.html.twig', [ 'parameters' => $this->parametersSerializer->serialize(), 'tools' => array_map(function (Tool $tool) { return ['name' => $tool->getName()]; }, $workspaceTools), 'models' => $this->finder->search( Workspace::class, ['filters' => ['model' => true]], [Options::SERIALIZE_MINIMAL] ), ] ); $event->setResponse(new Response($content)); $event->stopPropagation(); }
[ "public", "function", "onDisplayTool", "(", "OpenAdministrationToolEvent", "$", "event", ")", "{", "$", "workspaceTools", "=", "$", "this", "->", "toolManager", "->", "getAvailableWorkspaceTools", "(", ")", ";", "$", "content", "=", "$", "this", "->", "templatin...
Displays workspace administration tool. @DI\Observe("administration_tool_workspace_management") @param OpenAdministrationToolEvent $event
[ "Displays", "workspace", "administration", "tool", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/WorkspaceListener.php#L68-L89
train
claroline/Distribution
plugin/slideshow/Entity/Resource/Slideshow.php
Slideshow.addSlide
public function addSlide(Slide $slide) { if (!$this->slides->contains($slide)) { $this->slides->add($slide); $slide->setSlideshow($this); } }
php
public function addSlide(Slide $slide) { if (!$this->slides->contains($slide)) { $this->slides->add($slide); $slide->setSlideshow($this); } }
[ "public", "function", "addSlide", "(", "Slide", "$", "slide", ")", "{", "if", "(", "!", "$", "this", "->", "slides", "->", "contains", "(", "$", "slide", ")", ")", "{", "$", "this", "->", "slides", "->", "add", "(", "$", "slide", ")", ";", "$", ...
Add a slide to the slideshow. @param Slide $slide
[ "Add", "a", "slide", "to", "the", "slideshow", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/slideshow/Entity/Resource/Slideshow.php#L205-L211
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemObjectSerializer.php
ItemObjectSerializer.serialize
public function serialize(ItemObject $itemObject, array $options = []) { $serialized = [ 'id' => $itemObject->getUuid(), 'type' => $itemObject->getMimeType(), ]; if (1 === preg_match('#^text\/[^/]+$#', $itemObject->getMimeType())) { $serialized['data'] = $itemObject->getData(); } else { $serialized['url'] = $itemObject->getData(); } return $serialized; }
php
public function serialize(ItemObject $itemObject, array $options = []) { $serialized = [ 'id' => $itemObject->getUuid(), 'type' => $itemObject->getMimeType(), ]; if (1 === preg_match('#^text\/[^/]+$#', $itemObject->getMimeType())) { $serialized['data'] = $itemObject->getData(); } else { $serialized['url'] = $itemObject->getData(); } return $serialized; }
[ "public", "function", "serialize", "(", "ItemObject", "$", "itemObject", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "serialized", "=", "[", "'id'", "=>", "$", "itemObject", "->", "getUuid", "(", ")", ",", "'type'", "=>", "$", "itemObje...
Converts a ItemObject into a JSON-encodable structure. @param ItemObject $itemObject @param array $options @return array
[ "Converts", "a", "ItemObject", "into", "a", "JSON", "-", "encodable", "structure", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemObjectSerializer.php#L28-L42
train
claroline/Distribution
plugin/exo/Serializer/Item/ItemObjectSerializer.php
ItemObjectSerializer.deserialize
public function deserialize($data, ItemObject $itemObject = null, array $options = []) { $itemObject = $itemObject ?: new ItemObject(); $this->sipe('id', 'setUuid', $data, $itemObject); if (in_array(Transfer::REFRESH_UUID, $options)) { $itemObject->refreshUuid(); } $this->sipe('type', 'setMimeType', $data, $itemObject); $this->sipe('url', 'setData', $data, $itemObject); $this->sipe('data', 'setData', $data, $itemObject); return $itemObject; }
php
public function deserialize($data, ItemObject $itemObject = null, array $options = []) { $itemObject = $itemObject ?: new ItemObject(); $this->sipe('id', 'setUuid', $data, $itemObject); if (in_array(Transfer::REFRESH_UUID, $options)) { $itemObject->refreshUuid(); } $this->sipe('type', 'setMimeType', $data, $itemObject); $this->sipe('url', 'setData', $data, $itemObject); $this->sipe('data', 'setData', $data, $itemObject); return $itemObject; }
[ "public", "function", "deserialize", "(", "$", "data", ",", "ItemObject", "$", "itemObject", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "itemObject", "=", "$", "itemObject", "?", ":", "new", "ItemObject", "(", ")", ";", ...
Converts raw data into a ItemObject entity. @param array $data @param ItemObject $itemObject @param array $options @return ItemObject
[ "Converts", "raw", "data", "into", "a", "ItemObject", "entity", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/ItemObjectSerializer.php#L53-L67
train
claroline/Distribution
main/core/Manager/FacetManager.php
FacetManager.createField
public function createField($name, $isRequired, $type, ResourceNode $resourceNode = null) { $fieldFacet = new FieldFacet(); $fieldFacet->setLabel($name); $fieldFacet->setType($type); $fieldFacet->setRequired($isRequired); $fieldFacet->setResourceNode($resourceNode); $this->om->persist($fieldFacet); $this->om->flush(); return $fieldFacet; }
php
public function createField($name, $isRequired, $type, ResourceNode $resourceNode = null) { $fieldFacet = new FieldFacet(); $fieldFacet->setLabel($name); $fieldFacet->setType($type); $fieldFacet->setRequired($isRequired); $fieldFacet->setResourceNode($resourceNode); $this->om->persist($fieldFacet); $this->om->flush(); return $fieldFacet; }
[ "public", "function", "createField", "(", "$", "name", ",", "$", "isRequired", ",", "$", "type", ",", "ResourceNode", "$", "resourceNode", "=", "null", ")", "{", "$", "fieldFacet", "=", "new", "FieldFacet", "(", ")", ";", "$", "fieldFacet", "->", "setLab...
used by clacoForm Manager. @deprecated @todo remove me
[ "used", "by", "clacoForm", "Manager", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L81-L92
train
claroline/Distribution
main/core/Manager/FacetManager.php
FacetManager.addField
public function addField(PanelFacet $panelFacet, $name, $isRequired, $type) { $this->om->startFlushSuite(); $position = $this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet'); $fieldFacet = $this->createField($name, $isRequired, $type); $fieldFacet->setPanelFacet($panelFacet); $fieldFacet->setPosition($position); $this->om->persist($fieldFacet); $this->om->endFlushSuite(); return $fieldFacet; }
php
public function addField(PanelFacet $panelFacet, $name, $isRequired, $type) { $this->om->startFlushSuite(); $position = $this->om->count('Claroline\CoreBundle\Entity\Facet\FieldFacet'); $fieldFacet = $this->createField($name, $isRequired, $type); $fieldFacet->setPanelFacet($panelFacet); $fieldFacet->setPosition($position); $this->om->persist($fieldFacet); $this->om->endFlushSuite(); return $fieldFacet; }
[ "public", "function", "addField", "(", "PanelFacet", "$", "panelFacet", ",", "$", "name", ",", "$", "isRequired", ",", "$", "type", ")", "{", "$", "this", "->", "om", "->", "startFlushSuite", "(", ")", ";", "$", "position", "=", "$", "this", "->", "o...
Creates a new field for a facet. @param PanelFacet $facet @param string $name @param int $type @deprecated @todo remove me Used by claco form widget config
[ "Creates", "a", "new", "field", "for", "a", "facet", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L107-L118
train
claroline/Distribution
main/core/Manager/FacetManager.php
FacetManager.addPanel
public function addPanel(Facet $facet, $name, $collapse = false, $autoEditable = false) { $panelFacet = new PanelFacet(); $panelFacet->setName($name); $panelFacet->setFacet($facet); $panelFacet->setIsDefaultCollapsed($collapse); $panelFacet->setIsEditable($autoEditable); $panelFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\PanelFacet')); $this->om->persist($panelFacet); $this->om->flush(); return $panelFacet; }
php
public function addPanel(Facet $facet, $name, $collapse = false, $autoEditable = false) { $panelFacet = new PanelFacet(); $panelFacet->setName($name); $panelFacet->setFacet($facet); $panelFacet->setIsDefaultCollapsed($collapse); $panelFacet->setIsEditable($autoEditable); $panelFacet->setPosition($this->om->count('Claroline\CoreBundle\Entity\Facet\PanelFacet')); $this->om->persist($panelFacet); $this->om->flush(); return $panelFacet; }
[ "public", "function", "addPanel", "(", "Facet", "$", "facet", ",", "$", "name", ",", "$", "collapse", "=", "false", ",", "$", "autoEditable", "=", "false", ")", "{", "$", "panelFacet", "=", "new", "PanelFacet", "(", ")", ";", "$", "panelFacet", "->", ...
Adds a panel in a facet. Used by persister and Updater04000 Can be removed. @param Facet $facet @param string $name @return PanelFacet
[ "Adds", "a", "panel", "in", "a", "facet", ".", "Used", "by", "persister", "and", "Updater04000", "Can", "be", "removed", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L130-L142
train
claroline/Distribution
main/core/Manager/FacetManager.php
FacetManager.setFieldValue
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false) { if (!$this->authorization->isGranted('edit', new FieldFacetCollection([$field], $user)) && !$force) { throw new AccessDeniedException(); } $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue') ->findOneBy(['user' => $user, 'fieldFacet' => $field]); if (null === $fieldFacetValue) { $fieldFacetValue = new FieldFacetValue(); $fieldFacetValue->setUser($user); $fieldFacetValue->setFieldFacet($field); } switch ($field->getType()) { case FieldFacet::DATE_TYPE: $date = is_string($value) ? new \DateTime($value) : $value; $fieldFacetValue->setDateValue($date); break; case FieldFacet::NUMBER_TYPE: $fieldFacetValue->setFloatValue($value); break; case FieldFacet::CHOICE_TYPE: $options = $field->getOptions(); if (isset($options['multiple']) && $options['multiple']) { $fieldFacetValue->setArrayValue($value); } else { $fieldFacetValue->setStringValue($value); } break; case FieldFacet::CASCADE_TYPE: $fieldFacetValue->setArrayValue($value); break; default: $fieldFacetValue->setStringValue($value); } $this->om->persist($fieldFacetValue); $this->om->flush(); }
php
public function setFieldValue(User $user, FieldFacet $field, $value, $force = false) { if (!$this->authorization->isGranted('edit', new FieldFacetCollection([$field], $user)) && !$force) { throw new AccessDeniedException(); } $fieldFacetValue = $this->om->getRepository('ClarolineCoreBundle:Facet\FieldFacetValue') ->findOneBy(['user' => $user, 'fieldFacet' => $field]); if (null === $fieldFacetValue) { $fieldFacetValue = new FieldFacetValue(); $fieldFacetValue->setUser($user); $fieldFacetValue->setFieldFacet($field); } switch ($field->getType()) { case FieldFacet::DATE_TYPE: $date = is_string($value) ? new \DateTime($value) : $value; $fieldFacetValue->setDateValue($date); break; case FieldFacet::NUMBER_TYPE: $fieldFacetValue->setFloatValue($value); break; case FieldFacet::CHOICE_TYPE: $options = $field->getOptions(); if (isset($options['multiple']) && $options['multiple']) { $fieldFacetValue->setArrayValue($value); } else { $fieldFacetValue->setStringValue($value); } break; case FieldFacet::CASCADE_TYPE: $fieldFacetValue->setArrayValue($value); break; default: $fieldFacetValue->setStringValue($value); } $this->om->persist($fieldFacetValue); $this->om->flush(); }
[ "public", "function", "setFieldValue", "(", "User", "$", "user", ",", "FieldFacet", "$", "field", ",", "$", "value", ",", "$", "force", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "authorization", "->", "isGranted", "(", "'edit'", ",", ...
Set the value of a field for a user. @param User $user @param FieldFacet $field @param mixed $value Has some use at the registration/csv import. Should be removed eventually @deprecated @throws \Exception
[ "Set", "the", "value", "of", "a", "field", "for", "a", "user", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L158-L201
train
claroline/Distribution
main/core/Manager/FacetManager.php
FacetManager.editField
public function editField(FieldFacet $fieldFacet, $name, $isRequired, $type) { $fieldFacet->setLabel($name); $fieldFacet->setType($type); $fieldFacet->setRequired($isRequired); $this->om->persist($fieldFacet); $this->om->flush(); return $fieldFacet; }
php
public function editField(FieldFacet $fieldFacet, $name, $isRequired, $type) { $fieldFacet->setLabel($name); $fieldFacet->setType($type); $fieldFacet->setRequired($isRequired); $this->om->persist($fieldFacet); $this->om->flush(); return $fieldFacet; }
[ "public", "function", "editField", "(", "FieldFacet", "$", "fieldFacet", ",", "$", "name", ",", "$", "isRequired", ",", "$", "type", ")", "{", "$", "fieldFacet", "->", "setLabel", "(", "$", "name", ")", ";", "$", "fieldFacet", "->", "setType", "(", "$"...
Used by clacoform manager. @deprecated
[ "Used", "by", "clacoform", "manager", "." ]
a2d9762eddba5732447a2915c977a3ce859103b6
https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/FacetManager.php#L219-L228
train