id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
40,300 | claroline/Distribution | plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php | BooleanQuestionSerializer.serialize | public function serialize(BooleanQuestion $question, array $options = [])
{
// Serializes choices
$choices = $this->serializeChoices($question, $options);
if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
shuffle($choices);
}
$serialized = ['choices' => $choices];
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['solutions'] = $this->serializeSolutions($question);
}
return $serialized;
} | php | public function serialize(BooleanQuestion $question, array $options = [])
{
// Serializes choices
$choices = $this->serializeChoices($question, $options);
if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
shuffle($choices);
}
$serialized = ['choices' => $choices];
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['solutions'] = $this->serializeSolutions($question);
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"BooleanQuestion",
"$",
"question",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// Serializes choices",
"$",
"choices",
"=",
"$",
"this",
"->",
"serializeChoices",
"(",
"$",
"question",
",",
"$",
"options",... | Converts a Boolean question into a JSON-encodable structure.
@param BooleanQuestion $question
@param array $options
@return array | [
"Converts",
"a",
"Boolean",
"question",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php#L47-L63 |
40,301 | claroline/Distribution | plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php | BooleanQuestionSerializer.deserialize | public function deserialize($data, BooleanQuestion $question = null, array $options = [])
{
if (empty($question)) {
$question = new BooleanQuestion();
}
$this->deserializeChoices($question, $data['choices'], $data['solutions'], $options);
return $question;
} | php | public function deserialize($data, BooleanQuestion $question = null, array $options = [])
{
if (empty($question)) {
$question = new BooleanQuestion();
}
$this->deserializeChoices($question, $data['choices'], $data['solutions'], $options);
return $question;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"BooleanQuestion",
"$",
"question",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"question",
")",
")",
"{",
"$",
"question",
"=",
"new",
... | Converts raw data into a Boolean question entity.
@param array $data
@param BooleanQuestion $question
@param array $options
@return BooleanQuestion | [
"Converts",
"raw",
"data",
"into",
"a",
"Boolean",
"question",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php#L74-L83 |
40,302 | claroline/Distribution | plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php | BooleanQuestionSerializer.serializeChoices | private function serializeChoices(BooleanQuestion $question, array $options = [])
{
return array_map(function (BooleanChoice $choice) use ($options) {
$choiceData = $this->contentSerializer->serialize($choice, $options);
$choiceData['id'] = $choice->getUuid();
return $choiceData;
}, $question->getChoices()->toArray());
} | php | private function serializeChoices(BooleanQuestion $question, array $options = [])
{
return array_map(function (BooleanChoice $choice) use ($options) {
$choiceData = $this->contentSerializer->serialize($choice, $options);
$choiceData['id'] = $choice->getUuid();
return $choiceData;
}, $question->getChoices()->toArray());
} | [
"private",
"function",
"serializeChoices",
"(",
"BooleanQuestion",
"$",
"question",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"BooleanChoice",
"$",
"choice",
")",
"use",
"(",
"$",
"options",
")",
"{... | Serializes the Question choices.
@param BooleanQuestion $question
@param array $options
@return array | [
"Serializes",
"the",
"Question",
"choices",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/BooleanQuestionSerializer.php#L93-L101 |
40,303 | claroline/Distribution | plugin/result/Repository/MarkRepository.php | MarkRepository.findByResult | public function findByResult(Result $result)
{
$dql = '
SELECT
u.id,
CONCAT(u.firstName, \' \', u.lastName) AS name,
m.value AS mark,
m.id AS markId
FROM Claroline\ResultBundle\Entity\Mark m
JOIN m.user u
WHERE m.result = :result
ORDER BY u.lastName ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameter('result', $result);
return $query->getArrayResult();
} | php | public function findByResult(Result $result)
{
$dql = '
SELECT
u.id,
CONCAT(u.firstName, \' \', u.lastName) AS name,
m.value AS mark,
m.id AS markId
FROM Claroline\ResultBundle\Entity\Mark m
JOIN m.user u
WHERE m.result = :result
ORDER BY u.lastName ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameter('result', $result);
return $query->getArrayResult();
} | [
"public",
"function",
"findByResult",
"(",
"Result",
"$",
"result",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT\n u.id,\n CONCAT(u.firstName, \\' \\', u.lastName) AS name,\n m.value AS mark,\n m.id AS markId\n FROM ... | Returns an array representation of the marks associated
with a given result.
@param Result $result
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"marks",
"associated",
"with",
"a",
"given",
"result",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Repository/MarkRepository.php#L28-L46 |
40,304 | claroline/Distribution | plugin/result/Repository/MarkRepository.php | MarkRepository.findByResultAndUser | public function findByResultAndUser(Result $result, User $user)
{
$dql = '
SELECT
u.id,
CONCAT(u.firstName, \' \', u.lastName) AS name,
m.value AS mark,
m.id AS markId
FROM Claroline\ResultBundle\Entity\Mark m
JOIN m.user u
WHERE m.result = :result
AND u = :user
ORDER BY u.lastName ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameters([
'result' => $result,
'user' => $user,
]);
return $query->getArrayResult();
} | php | public function findByResultAndUser(Result $result, User $user)
{
$dql = '
SELECT
u.id,
CONCAT(u.firstName, \' \', u.lastName) AS name,
m.value AS mark,
m.id AS markId
FROM Claroline\ResultBundle\Entity\Mark m
JOIN m.user u
WHERE m.result = :result
AND u = :user
ORDER BY u.lastName ASC
';
$query = $this->_em->createQuery($dql);
$query->setParameters([
'result' => $result,
'user' => $user,
]);
return $query->getArrayResult();
} | [
"public",
"function",
"findByResultAndUser",
"(",
"Result",
"$",
"result",
",",
"User",
"$",
"user",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT\n u.id,\n CONCAT(u.firstName, \\' \\', u.lastName) AS name,\n m.value AS mark,\n ... | Returns an array representation of the mark associated
with a result for a given user.
@param Result $result
@param User $user
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"mark",
"associated",
"with",
"a",
"result",
"for",
"a",
"given",
"user",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Repository/MarkRepository.php#L57-L79 |
40,305 | claroline/Distribution | plugin/competency/Repository/AbilityProgressRepository.php | AbilityProgressRepository.findByAbilitiesAndStatus | public function findByAbilitiesAndStatus(User $user, array $abilities, $status)
{
return $this->createQueryBuilder('ap')
->select('ap')
->where('ap.user = :user')
->andWhere('ap.ability IN (:abilities)')
->andWhere('ap.status = :status')
->orderBy('ap.id')
->setParameters([
':user' => $user,
':abilities' => $abilities,
':status' => $status,
])
->getQuery()
->getResult();
} | php | public function findByAbilitiesAndStatus(User $user, array $abilities, $status)
{
return $this->createQueryBuilder('ap')
->select('ap')
->where('ap.user = :user')
->andWhere('ap.ability IN (:abilities)')
->andWhere('ap.status = :status')
->orderBy('ap.id')
->setParameters([
':user' => $user,
':abilities' => $abilities,
':status' => $status,
])
->getQuery()
->getResult();
} | [
"public",
"function",
"findByAbilitiesAndStatus",
"(",
"User",
"$",
"user",
",",
"array",
"$",
"abilities",
",",
"$",
"status",
")",
"{",
"return",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'ap'",
")",
"->",
"select",
"(",
"'ap'",
")",
"->",
"where",
... | Returns progress entities for a given user which are related to
a set of abilities and have a particular status.
@param User $user
@param array $abilities
@param string $status
@return array | [
"Returns",
"progress",
"entities",
"for",
"a",
"given",
"user",
"which",
"are",
"related",
"to",
"a",
"set",
"of",
"abilities",
"and",
"have",
"a",
"particular",
"status",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Repository/AbilityProgressRepository.php#L20-L35 |
40,306 | claroline/Distribution | main/core/Controller/APINew/WidgetController.php | WidgetController.listAction | public function listAction($context = null)
{
return new JsonResponse([
'widgets' => array_map(function (Widget $widget) {
return $this->serializer->serialize($widget);
}, $this->widgetManager->getAvailable($context)),
'dataSources' => array_map(function (DataSource $dataSource) {
return $this->serializer->serialize($dataSource);
}, $this->dataSourceManager->getAvailable($context)),
]);
} | php | public function listAction($context = null)
{
return new JsonResponse([
'widgets' => array_map(function (Widget $widget) {
return $this->serializer->serialize($widget);
}, $this->widgetManager->getAvailable($context)),
'dataSources' => array_map(function (DataSource $dataSource) {
return $this->serializer->serialize($dataSource);
}, $this->dataSourceManager->getAvailable($context)),
]);
} | [
"public",
"function",
"listAction",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"[",
"'widgets'",
"=>",
"array_map",
"(",
"function",
"(",
"Widget",
"$",
"widget",
")",
"{",
"return",
"$",
"this",
"->",
"serializer",
... | Lists available widgets for a given context.
@EXT\Route("/{context}", name="apiv2_widget_available", defaults={"context"=null})
@EXT\Method("GET")
@param string $context
@return JsonResponse | [
"Lists",
"available",
"widgets",
"for",
"a",
"given",
"context",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/APINew/WidgetController.php#L72-L82 |
40,307 | claroline/Distribution | plugin/result/Repository/ResultRepository.php | ResultRepository.findByUserAndWorkspace | public function findByUserAndWorkspace(User $user, Workspace $workspace)
{
$dql = '
SELECT
n.name AS title,
m.value AS mark,
r.total AS total
FROM Claroline\ResultBundle\Entity\Result r
JOIN r.resourceNode n
JOIN n.workspace w
JOIN r.marks m
JOIN m.user u
WHERE w = :workspace
AND u = :user
ORDER BY n.creationDate DESC, n.id
';
$query = $this->_em->createQuery($dql);
$query->setParameters([
'workspace' => $workspace,
'user' => $user,
]);
return $query->getArrayResult();
} | php | public function findByUserAndWorkspace(User $user, Workspace $workspace)
{
$dql = '
SELECT
n.name AS title,
m.value AS mark,
r.total AS total
FROM Claroline\ResultBundle\Entity\Result r
JOIN r.resourceNode n
JOIN n.workspace w
JOIN r.marks m
JOIN m.user u
WHERE w = :workspace
AND u = :user
ORDER BY n.creationDate DESC, n.id
';
$query = $this->_em->createQuery($dql);
$query->setParameters([
'workspace' => $workspace,
'user' => $user,
]);
return $query->getArrayResult();
} | [
"public",
"function",
"findByUserAndWorkspace",
"(",
"User",
"$",
"user",
",",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT\n n.name AS title,\n m.value AS mark,\n r.total AS total\n FROM Clar... | Returns an array representation of all the results associated
with a user in a given workspace.
@param User $user
@param Workspace $workspace
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"all",
"the",
"results",
"associated",
"with",
"a",
"user",
"in",
"a",
"given",
"workspace",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Repository/ResultRepository.php#L29-L53 |
40,308 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceEvaluationSerializer.php | ResourceEvaluationSerializer.serialize | public function serialize(ResourceEvaluation $resourceEvaluation)
{
$serialized = [
'id' => $resourceEvaluation->getId(),
'date' => $resourceEvaluation->getDate() ? $resourceEvaluation->getDate()->format('Y-m-d H:i') : null,
'status' => $resourceEvaluation->getStatus(),
'duration' => $resourceEvaluation->getDuration(),
'score' => $resourceEvaluation->getScore(),
'scoreMin' => $resourceEvaluation->getScoreMin(),
'scoreMax' => $resourceEvaluation->getScoreMax(),
'customScore' => $resourceEvaluation->getCustomScore(),
'progression' => $resourceEvaluation->getProgression(),
'comment' => $resourceEvaluation->getComment(),
'data' => $resourceEvaluation->getData(),
'resourceUserEvaluation' => $this->resourceUserEvaluationSerializer->serialize($resourceEvaluation->getResourceUserEvaluation()),
];
return $serialized;
} | php | public function serialize(ResourceEvaluation $resourceEvaluation)
{
$serialized = [
'id' => $resourceEvaluation->getId(),
'date' => $resourceEvaluation->getDate() ? $resourceEvaluation->getDate()->format('Y-m-d H:i') : null,
'status' => $resourceEvaluation->getStatus(),
'duration' => $resourceEvaluation->getDuration(),
'score' => $resourceEvaluation->getScore(),
'scoreMin' => $resourceEvaluation->getScoreMin(),
'scoreMax' => $resourceEvaluation->getScoreMax(),
'customScore' => $resourceEvaluation->getCustomScore(),
'progression' => $resourceEvaluation->getProgression(),
'comment' => $resourceEvaluation->getComment(),
'data' => $resourceEvaluation->getData(),
'resourceUserEvaluation' => $this->resourceUserEvaluationSerializer->serialize($resourceEvaluation->getResourceUserEvaluation()),
];
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"ResourceEvaluation",
"$",
"resourceEvaluation",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"resourceEvaluation",
"->",
"getId",
"(",
")",
",",
"'date'",
"=>",
"$",
"resourceEvaluation",
"->",
"getDate",
"... | Serializes a ResourceEvaluation entity for the JSON api.
@param ResourceEvaluation $resourceEvaluation
@return array - the serialized representation of the resource evaluation | [
"Serializes",
"a",
"ResourceEvaluation",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceEvaluationSerializer.php#L37-L55 |
40,309 | claroline/Distribution | plugin/competency/Manager/ResourceManager.php | ResourceManager.loadLinkedCompetencies | public function loadLinkedCompetencies(ResourceNode $resource)
{
$abilities = $this->abilityRepo->findByResource($resource);
$competencies = $this->competencyRepo->findByResource($resource);
$result = [];
foreach ($abilities as $ability) {
$result[] = $this->loadAbility($ability);
}
foreach ($competencies as $competency) {
$result[] = $this->loadCompetency($competency);
}
return $result;
} | php | public function loadLinkedCompetencies(ResourceNode $resource)
{
$abilities = $this->abilityRepo->findByResource($resource);
$competencies = $this->competencyRepo->findByResource($resource);
$result = [];
foreach ($abilities as $ability) {
$result[] = $this->loadAbility($ability);
}
foreach ($competencies as $competency) {
$result[] = $this->loadCompetency($competency);
}
return $result;
} | [
"public",
"function",
"loadLinkedCompetencies",
"(",
"ResourceNode",
"$",
"resource",
")",
"{",
"$",
"abilities",
"=",
"$",
"this",
"->",
"abilityRepo",
"->",
"findByResource",
"(",
"$",
"resource",
")",
";",
"$",
"competencies",
"=",
"$",
"this",
"->",
"com... | Returns an array representation of all the competencies and abilities
linked to a given resource, along with their path in their competency
framework. Competencies and abilities are distinguished from each other
by the "type" key.
@param ResourceNode $resource
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"all",
"the",
"competencies",
"and",
"abilities",
"linked",
"to",
"a",
"given",
"resource",
"along",
"with",
"their",
"path",
"in",
"their",
"competency",
"framework",
".",
"Competencies",
"and",
"abilities",
"ar... | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ResourceManager.php#L44-L59 |
40,310 | claroline/Distribution | plugin/competency/Manager/ResourceManager.php | ResourceManager.removeLink | public function removeLink(ResourceNode $resource, $target)
{
if (!$target instanceof Ability && !$target instanceof Competency) {
throw new \InvalidArgumentException(
'Second argument must be a Competency or an Ability instance'
);
}
if (!$target->isLinkedToResource($resource)) {
throw new \LogicException(
"There's no link between resource {$resource->getId()} and target {$target->getId()}"
);
}
$target->removeResource($resource);
$this->om->flush();
} | php | public function removeLink(ResourceNode $resource, $target)
{
if (!$target instanceof Ability && !$target instanceof Competency) {
throw new \InvalidArgumentException(
'Second argument must be a Competency or an Ability instance'
);
}
if (!$target->isLinkedToResource($resource)) {
throw new \LogicException(
"There's no link between resource {$resource->getId()} and target {$target->getId()}"
);
}
$target->removeResource($resource);
$this->om->flush();
} | [
"public",
"function",
"removeLink",
"(",
"ResourceNode",
"$",
"resource",
",",
"$",
"target",
")",
"{",
"if",
"(",
"!",
"$",
"target",
"instanceof",
"Ability",
"&&",
"!",
"$",
"target",
"instanceof",
"Competency",
")",
"{",
"throw",
"new",
"\\",
"InvalidAr... | Removes a link between a resource and an ability or a competency.
@param ResourceNode $resource
@param Ability|Competency $target
@throws \InvalidArgumentException if the target isn't an instance of Ability or Competency
@throws \LogicException if the link doesn't exists | [
"Removes",
"a",
"link",
"between",
"a",
"resource",
"and",
"an",
"ability",
"or",
"a",
"competency",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/competency/Manager/ResourceManager.php#L102-L118 |
40,311 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceNodeSerializer.php | ResourceNodeSerializer.serialize | public function serialize(ResourceNode $resourceNode, array $options = [])
{
$serializedNode = [
//also used for the export. It's not pretty.
'autoId' => $resourceNode->getId(),
'id' => $resourceNode->getUuid(),
'name' => $resourceNode->getName(),
'path' => $resourceNode->getAncestors(),
'meta' => $this->serializeMeta($resourceNode, $options),
'permissions' => $this->rightsManager->getCurrentPermissionArray($resourceNode),
'poster' => $this->serializePoster($resourceNode),
'thumbnail' => $this->serializeThumbnail($resourceNode),
// TODO : it should not be available in minimal mode
// for now I need it to compute simple access rights (for display)
// we should compute simple access here to avoid exposing this big object
'rights' => $this->rightsManager->getRights($resourceNode, $options),
];
// TODO : it should not (I think) be available in minimal mode
// for now I need it to compute rights
if ($resourceNode->getWorkspace() && !in_array(Options::REFRESH_UUID, $options)) {
$serializedNode['workspace'] = [ // TODO : use workspace serializer with minimal option
'id' => $resourceNode->getWorkspace()->getUuid(),
'autoId' => $resourceNode->getWorkspace()->getId(), // because open url does not work with uuid
'name' => $resourceNode->getWorkspace()->getName(),
'code' => $resourceNode->getWorkspace()->getCode(),
];
}
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serializedNode = array_merge($serializedNode, [
'display' => $this->serializeDisplay($resourceNode),
'restrictions' => $this->serializeRestrictions($resourceNode),
]);
}
//maybe don't remove me, it's used by the export system
$parent = $resourceNode->getParent();
if (!empty($parent)) {
$serializedNode['parent'] = [
'id' => $parent->getUuid(),
'autoId' => $parent->getId(), // TODO : remove me
'name' => $parent->getName(),
];
}
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serializedNode['comments'] = array_map(function (ResourceComment $comment) {
return $this->serializer->serialize($comment);
}, $resourceNode->getComments()->toArray());
}
$serializedNode = $this->decorate($resourceNode, $serializedNode, $options);
return $serializedNode;
} | php | public function serialize(ResourceNode $resourceNode, array $options = [])
{
$serializedNode = [
//also used for the export. It's not pretty.
'autoId' => $resourceNode->getId(),
'id' => $resourceNode->getUuid(),
'name' => $resourceNode->getName(),
'path' => $resourceNode->getAncestors(),
'meta' => $this->serializeMeta($resourceNode, $options),
'permissions' => $this->rightsManager->getCurrentPermissionArray($resourceNode),
'poster' => $this->serializePoster($resourceNode),
'thumbnail' => $this->serializeThumbnail($resourceNode),
// TODO : it should not be available in minimal mode
// for now I need it to compute simple access rights (for display)
// we should compute simple access here to avoid exposing this big object
'rights' => $this->rightsManager->getRights($resourceNode, $options),
];
// TODO : it should not (I think) be available in minimal mode
// for now I need it to compute rights
if ($resourceNode->getWorkspace() && !in_array(Options::REFRESH_UUID, $options)) {
$serializedNode['workspace'] = [ // TODO : use workspace serializer with minimal option
'id' => $resourceNode->getWorkspace()->getUuid(),
'autoId' => $resourceNode->getWorkspace()->getId(), // because open url does not work with uuid
'name' => $resourceNode->getWorkspace()->getName(),
'code' => $resourceNode->getWorkspace()->getCode(),
];
}
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serializedNode = array_merge($serializedNode, [
'display' => $this->serializeDisplay($resourceNode),
'restrictions' => $this->serializeRestrictions($resourceNode),
]);
}
//maybe don't remove me, it's used by the export system
$parent = $resourceNode->getParent();
if (!empty($parent)) {
$serializedNode['parent'] = [
'id' => $parent->getUuid(),
'autoId' => $parent->getId(), // TODO : remove me
'name' => $parent->getName(),
];
}
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serializedNode['comments'] = array_map(function (ResourceComment $comment) {
return $this->serializer->serialize($comment);
}, $resourceNode->getComments()->toArray());
}
$serializedNode = $this->decorate($resourceNode, $serializedNode, $options);
return $serializedNode;
} | [
"public",
"function",
"serialize",
"(",
"ResourceNode",
"$",
"resourceNode",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serializedNode",
"=",
"[",
"//also used for the export. It's not pretty.",
"'autoId'",
"=>",
"$",
"resourceNode",
"->",
"getId... | Serializes a ResourceNode entity for the JSON api.
@param ResourceNode $resourceNode - the node to serialize
@param array $options
@return array - the serialized representation of the node | [
"Serializes",
"a",
"ResourceNode",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceNodeSerializer.php#L109-L166 |
40,312 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceNodeSerializer.php | ResourceNodeSerializer.decorate | private function decorate(ResourceNode $resourceNode, array $serializedNode, array $options = [])
{
// avoid plugins override the standard node properties
$unauthorizedKeys = array_keys($serializedNode);
// 'thumbnail' is a key that can be overridden by another plugin. For example: UrlBundle
// TODO : find a cleaner way to do it
if (false !== ($key = array_search('thumbnail', $unauthorizedKeys))) {
unset($unauthorizedKeys[$key]);
}
/** @var DecorateResourceNodeEvent $event */
$event = $this->eventDispatcher->dispatch(
'serialize_resource_node',
'Resource\DecorateResourceNode',
[
$resourceNode,
$unauthorizedKeys,
$options,
]
);
return array_merge($serializedNode, $event->getInjectedData());
} | php | private function decorate(ResourceNode $resourceNode, array $serializedNode, array $options = [])
{
// avoid plugins override the standard node properties
$unauthorizedKeys = array_keys($serializedNode);
// 'thumbnail' is a key that can be overridden by another plugin. For example: UrlBundle
// TODO : find a cleaner way to do it
if (false !== ($key = array_search('thumbnail', $unauthorizedKeys))) {
unset($unauthorizedKeys[$key]);
}
/** @var DecorateResourceNodeEvent $event */
$event = $this->eventDispatcher->dispatch(
'serialize_resource_node',
'Resource\DecorateResourceNode',
[
$resourceNode,
$unauthorizedKeys,
$options,
]
);
return array_merge($serializedNode, $event->getInjectedData());
} | [
"private",
"function",
"decorate",
"(",
"ResourceNode",
"$",
"resourceNode",
",",
"array",
"$",
"serializedNode",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// avoid plugins override the standard node properties",
"$",
"unauthorizedKeys",
"=",
"array_keys... | Dispatches an event to let plugins add some custom data to the serialized node.
For example, SocialMedia adds the number of likes.
@param ResourceNode $resourceNode - the original node entity
@param array $serializedNode - the serialized version of the node
@param array $options
@return array - the decorated node | [
"Dispatches",
"an",
"event",
"to",
"let",
"plugins",
"add",
"some",
"custom",
"data",
"to",
"the",
"serialized",
"node",
".",
"For",
"example",
"SocialMedia",
"adds",
"the",
"number",
"of",
"likes",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceNodeSerializer.php#L178-L201 |
40,313 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceNodeSerializer.php | ResourceNodeSerializer.serializePoster | private function serializePoster(ResourceNode $resourceNode)
{
if (!empty($resourceNode->getPoster())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $resourceNode->getPoster()]);
if ($file) {
return $this->fileSerializer->serialize($file);
}
}
return null;
} | php | private function serializePoster(ResourceNode $resourceNode)
{
if (!empty($resourceNode->getPoster())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $resourceNode->getPoster()]);
if ($file) {
return $this->fileSerializer->serialize($file);
}
}
return null;
} | [
"private",
"function",
"serializePoster",
"(",
"ResourceNode",
"$",
"resourceNode",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"resourceNode",
"->",
"getPoster",
"(",
")",
")",
")",
"{",
"/** @var PublicFile $file */",
"$",
"file",
"=",
"$",
"this",
"->",
... | Serialize the resource poster.
@param ResourceNode $resourceNode
@return array|null | [
"Serialize",
"the",
"resource",
"poster",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceNodeSerializer.php#L210-L224 |
40,314 | claroline/Distribution | main/core/API/Serializer/Resource/ResourceNodeSerializer.php | ResourceNodeSerializer.serializeThumbnail | private function serializeThumbnail(ResourceNode $resourceNode)
{
if (!empty($resourceNode->getThumbnail())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $resourceNode->getThumbnail()]);
if ($file) {
return $this->fileSerializer->serialize($file);
}
}
return null;
} | php | private function serializeThumbnail(ResourceNode $resourceNode)
{
if (!empty($resourceNode->getThumbnail())) {
/** @var PublicFile $file */
$file = $this->om
->getRepository(PublicFile::class)
->findOneBy(['url' => $resourceNode->getThumbnail()]);
if ($file) {
return $this->fileSerializer->serialize($file);
}
}
return null;
} | [
"private",
"function",
"serializeThumbnail",
"(",
"ResourceNode",
"$",
"resourceNode",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"resourceNode",
"->",
"getThumbnail",
"(",
")",
")",
")",
"{",
"/** @var PublicFile $file */",
"$",
"file",
"=",
"$",
"this",
... | Serialize the resource thumbnail.
@param ResourceNode $resourceNode
@return array|null | [
"Serialize",
"the",
"resource",
"thumbnail",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/ResourceNodeSerializer.php#L233-L247 |
40,315 | claroline/Distribution | main/core/Listener/Administration/ScheduledTaskListener.php | ScheduledTaskListener.onDisplayTool | public function onDisplayTool(OpenAdministrationToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:administration:scheduled_tasks.html.twig', [
'isCronConfigured' => $this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured'),
]
);
$event->setResponse(new Response($content));
$event->stopPropagation();
} | php | public function onDisplayTool(OpenAdministrationToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:administration:scheduled_tasks.html.twig', [
'isCronConfigured' => $this->configHandler->hasParameter('is_cron_configured') && $this->configHandler->getParameter('is_cron_configured'),
]
);
$event->setResponse(new Response($content));
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayTool",
"(",
"OpenAdministrationToolEvent",
"$",
"event",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreBundle:administration:scheduled_tasks.html.twig'",
",",
"[",
"'isCronConfigured'",
... | Displays scheduled tasks administration tool.
@DI\Observe("administration_tool_tasks_scheduling")
@param OpenAdministrationToolEvent $event | [
"Displays",
"scheduled",
"tasks",
"administration",
"tool",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Administration/ScheduledTaskListener.php#L50-L60 |
40,316 | claroline/Distribution | plugin/announcement/Listener/Resource/AnnouncementListener.php | AnnouncementListener.load | public function load(LoadResourceEvent $event)
{
$resource = $event->getResource();
$workspace = $resource->getResourceNode()->getWorkspace();
$event->setData([
'announcement' => $this->serializer->serialize($resource),
'workspaceRoles' => array_map(function (Role $role) {
return $this->serializer->serialize($role, [Options::SERIALIZE_MINIMAL]);
}, $workspace->getRoles()->toArray()),
]);
$event->stopPropagation();
} | php | public function load(LoadResourceEvent $event)
{
$resource = $event->getResource();
$workspace = $resource->getResourceNode()->getWorkspace();
$event->setData([
'announcement' => $this->serializer->serialize($resource),
'workspaceRoles' => array_map(function (Role $role) {
return $this->serializer->serialize($role, [Options::SERIALIZE_MINIMAL]);
}, $workspace->getRoles()->toArray()),
]);
$event->stopPropagation();
} | [
"public",
"function",
"load",
"(",
"LoadResourceEvent",
"$",
"event",
")",
"{",
"$",
"resource",
"=",
"$",
"event",
"->",
"getResource",
"(",
")",
";",
"$",
"workspace",
"=",
"$",
"resource",
"->",
"getResourceNode",
"(",
")",
"->",
"getWorkspace",
"(",
... | Loads an Announcement resource.
@DI\Observe("resource.claroline_announcement_aggregate.load")
@param LoadResourceEvent $event | [
"Loads",
"an",
"Announcement",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/announcement/Listener/Resource/AnnouncementListener.php#L88-L101 |
40,317 | claroline/Distribution | plugin/dropzone/Manager/CorrectionManager.php | CorrectionManager.calculateCorrectionTotalGrade | public function calculateCorrectionTotalGrade(Dropzone $dropzone, Correction $correction)
{
$nbCriteria = count($dropzone->getPeerReviewCriteria());
$maxGrade = $dropzone->getTotalCriteriaColumn() - 1;
$sumGrades = 0;
foreach ($correction->getGrades() as $grade) {
($grade->getValue() > $maxGrade) ? $sumGrades += $maxGrade : $sumGrades += $grade->getValue();
}
$totalGrade = 0;
if (0 !== $nbCriteria) {
$totalGrade = $sumGrades / ($nbCriteria);
$totalGrade = ($totalGrade * 20) / ($maxGrade);
}
return $totalGrade;
} | php | public function calculateCorrectionTotalGrade(Dropzone $dropzone, Correction $correction)
{
$nbCriteria = count($dropzone->getPeerReviewCriteria());
$maxGrade = $dropzone->getTotalCriteriaColumn() - 1;
$sumGrades = 0;
foreach ($correction->getGrades() as $grade) {
($grade->getValue() > $maxGrade) ? $sumGrades += $maxGrade : $sumGrades += $grade->getValue();
}
$totalGrade = 0;
if (0 !== $nbCriteria) {
$totalGrade = $sumGrades / ($nbCriteria);
$totalGrade = ($totalGrade * 20) / ($maxGrade);
}
return $totalGrade;
} | [
"public",
"function",
"calculateCorrectionTotalGrade",
"(",
"Dropzone",
"$",
"dropzone",
",",
"Correction",
"$",
"correction",
")",
"{",
"$",
"nbCriteria",
"=",
"count",
"(",
"$",
"dropzone",
"->",
"getPeerReviewCriteria",
"(",
")",
")",
";",
"$",
"maxGrade",
... | Calculate the grad of a copy.
@param Dropzone $dropzone
@param Correction $correction
@return float|int | [
"Calculate",
"the",
"grad",
"of",
"a",
"copy",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/dropzone/Manager/CorrectionManager.php#L42-L58 |
40,318 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.canPass | public function canPass(Exercise $exercise, User $user = null)
{
// TODO : max attempts by day
$canPass = true;
if ($user) {
$max = $exercise->getMaxAttempts();
if ($max > 0) {
$nbFinishedPapers = $this->paperManager->countUserFinishedPapers($exercise, $user);
if ($nbFinishedPapers >= $max) {
$canPass = false;
}
}
}
return $canPass;
} | php | public function canPass(Exercise $exercise, User $user = null)
{
// TODO : max attempts by day
$canPass = true;
if ($user) {
$max = $exercise->getMaxAttempts();
if ($max > 0) {
$nbFinishedPapers = $this->paperManager->countUserFinishedPapers($exercise, $user);
if ($nbFinishedPapers >= $max) {
$canPass = false;
}
}
}
return $canPass;
} | [
"public",
"function",
"canPass",
"(",
"Exercise",
"$",
"exercise",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"// TODO : max attempts by day",
"$",
"canPass",
"=",
"true",
";",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"max",
"=",
"$",
"exercise",
"... | Checks if a user is allowed to pass a quiz or not.
Based on the maximum attempt allowed and the number of already done by the user.
@param Exercise $exercise
@param User $user
@return bool | [
"Checks",
"if",
"a",
"user",
"is",
"allowed",
"to",
"pass",
"a",
"quiz",
"or",
"not",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L108-L124 |
40,319 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.canUpdate | public function canUpdate(Paper $paper, User $user = null)
{
return empty($paper->getEnd())
&& $user === $paper->getUser();
} | php | public function canUpdate(Paper $paper, User $user = null)
{
return empty($paper->getEnd())
&& $user === $paper->getUser();
} | [
"public",
"function",
"canUpdate",
"(",
"Paper",
"$",
"paper",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"return",
"empty",
"(",
"$",
"paper",
"->",
"getEnd",
"(",
")",
")",
"&&",
"$",
"user",
"===",
"$",
"paper",
"->",
"getUser",
"(",
")",
... | Checks if a user can submit answers to a paper or use hints.
A user can submit to a paper only if it is its own and the paper is not closed (= no end).
ATTENTION : As is, anonymous have access to all the other anonymous Papers !!!
@param Paper $paper
@param User $user
@return bool | [
"Checks",
"if",
"a",
"user",
"can",
"submit",
"answers",
"to",
"a",
"paper",
"or",
"use",
"hints",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L158-L162 |
40,320 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.startOrContinue | public function startOrContinue(Exercise $exercise, User $user = null)
{
$paper = null; // The paper to use for the new attempt
// If it's not an anonymous, load the previous unfinished papers
$unfinishedPapers = (null !== $user) ? $this->paperRepository->findUnfinishedPapers($exercise, $user) : [];
if (!empty($unfinishedPapers)) {
if ($exercise->isInterruptible()) {
// Continue a previous attempt
$paper = $unfinishedPapers[0];
} else {
// Close the paper
$this->end($unfinishedPapers[0], false);
}
}
// Start a new attempt is needed
if (empty($paper)) {
// Get the last paper for generation
$lastPaper = $this->getLastPaper($exercise, $user);
// Generate a new paper
$paper = $this->paperGenerator->create($exercise, $user, $lastPaper);
// Save the new paper
$this->om->persist($paper);
$this->om->flush();
}
return $paper;
} | php | public function startOrContinue(Exercise $exercise, User $user = null)
{
$paper = null; // The paper to use for the new attempt
// If it's not an anonymous, load the previous unfinished papers
$unfinishedPapers = (null !== $user) ? $this->paperRepository->findUnfinishedPapers($exercise, $user) : [];
if (!empty($unfinishedPapers)) {
if ($exercise->isInterruptible()) {
// Continue a previous attempt
$paper = $unfinishedPapers[0];
} else {
// Close the paper
$this->end($unfinishedPapers[0], false);
}
}
// Start a new attempt is needed
if (empty($paper)) {
// Get the last paper for generation
$lastPaper = $this->getLastPaper($exercise, $user);
// Generate a new paper
$paper = $this->paperGenerator->create($exercise, $user, $lastPaper);
// Save the new paper
$this->om->persist($paper);
$this->om->flush();
}
return $paper;
} | [
"public",
"function",
"startOrContinue",
"(",
"Exercise",
"$",
"exercise",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"paper",
"=",
"null",
";",
"// The paper to use for the new attempt",
"// If it's not an anonymous, load the previous unfinished papers",
"$",
... | Starts or continues an exercise paper.
Returns an unfinished paper if the user has one (and exercise allows continue)
or creates a new paper in the other cases.
Note : an anonymous user will never be able to continue a paper
@param Exercise $exercise - the exercise to play
@param User $user - the user who wants to play the exercise
@return Paper - a new paper or an unfinished one | [
"Starts",
"or",
"continues",
"an",
"exercise",
"paper",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L176-L206 |
40,321 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.submit | public function submit(Paper $paper, array $answers, $clientIp)
{
$submitted = [];
$this->om->startFlushSuite();
foreach ($answers as $answerData) {
$question = $paper->getQuestion($answerData['questionId']);
if (empty($question)) {
throw new InvalidDataException('Submitted answers are invalid', [[
'path' => '/questionId',
'message' => 'question is not part of the attempt',
]]);
}
$existingAnswer = $paper->getAnswer($answerData['questionId']);
$decodedQuestion = $this->itemSerializer->deserialize($question, new Item());
try {
if (empty($existingAnswer)) {
$answer = $this->answerManager->create($decodedQuestion, $answerData);
} else {
$answer = $this->answerManager->update($decodedQuestion, $existingAnswer, $answerData);
}
} catch (InvalidDataException $e) {
throw new InvalidDataException('Submitted answers are invalid', $e->getErrors());
}
$answer->setIp($clientIp);
$answer->setTries($answer->getTries() + 1);
// Calculate new answer score
$score = $this->itemManager->calculateScore($decodedQuestion, $answer);
$answer->setScore($score);
$paper->addAnswer($answer);
$submitted[] = $answer;
}
$this->om->persist($paper);
$this->om->endFlushSuite();
return $submitted;
} | php | public function submit(Paper $paper, array $answers, $clientIp)
{
$submitted = [];
$this->om->startFlushSuite();
foreach ($answers as $answerData) {
$question = $paper->getQuestion($answerData['questionId']);
if (empty($question)) {
throw new InvalidDataException('Submitted answers are invalid', [[
'path' => '/questionId',
'message' => 'question is not part of the attempt',
]]);
}
$existingAnswer = $paper->getAnswer($answerData['questionId']);
$decodedQuestion = $this->itemSerializer->deserialize($question, new Item());
try {
if (empty($existingAnswer)) {
$answer = $this->answerManager->create($decodedQuestion, $answerData);
} else {
$answer = $this->answerManager->update($decodedQuestion, $existingAnswer, $answerData);
}
} catch (InvalidDataException $e) {
throw new InvalidDataException('Submitted answers are invalid', $e->getErrors());
}
$answer->setIp($clientIp);
$answer->setTries($answer->getTries() + 1);
// Calculate new answer score
$score = $this->itemManager->calculateScore($decodedQuestion, $answer);
$answer->setScore($score);
$paper->addAnswer($answer);
$submitted[] = $answer;
}
$this->om->persist($paper);
$this->om->endFlushSuite();
return $submitted;
} | [
"public",
"function",
"submit",
"(",
"Paper",
"$",
"paper",
",",
"array",
"$",
"answers",
",",
"$",
"clientIp",
")",
"{",
"$",
"submitted",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"om",
"->",
"startFlushSuite",
"(",
")",
";",
"foreach",
"(",
"$",
"a... | Submits user answers to a paper.
@param Paper $paper
@param array $answers
@param string $clientIp
@throws InvalidDataException - if there is any invalid answer
@return Answer[] | [
"Submits",
"user",
"answers",
"to",
"a",
"paper",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L228-L272 |
40,322 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.end | public function end(Paper $paper, $finished = true, $generateEvaluation = true)
{
$this->om->startFlushSuite();
if (!$paper->getEnd()) {
$paper->setEnd(new \DateTime());
}
$paper->setInterrupted(!$finished);
$totalScoreOn = $paper->getExercise()->getTotalScoreOn();
$score = $this->paperManager->calculateScore($paper, $totalScoreOn);
$paper->setScore($score);
if ($generateEvaluation) {
$this->paperManager->generateResourceEvaluation($paper, $finished);
}
$this->om->persist($paper);
$this->om->endFlushSuite();
$this->paperManager->checkPaperEvaluated($paper);
} | php | public function end(Paper $paper, $finished = true, $generateEvaluation = true)
{
$this->om->startFlushSuite();
if (!$paper->getEnd()) {
$paper->setEnd(new \DateTime());
}
$paper->setInterrupted(!$finished);
$totalScoreOn = $paper->getExercise()->getTotalScoreOn();
$score = $this->paperManager->calculateScore($paper, $totalScoreOn);
$paper->setScore($score);
if ($generateEvaluation) {
$this->paperManager->generateResourceEvaluation($paper, $finished);
}
$this->om->persist($paper);
$this->om->endFlushSuite();
$this->paperManager->checkPaperEvaluated($paper);
} | [
"public",
"function",
"end",
"(",
"Paper",
"$",
"paper",
",",
"$",
"finished",
"=",
"true",
",",
"$",
"generateEvaluation",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"startFlushSuite",
"(",
")",
";",
"if",
"(",
"!",
"$",
"paper",
"->",
... | Ends a user paper.
Sets the end date of the paper and calculates its score.
@param Paper $paper
@param bool $finished
@param bool $generateEvaluation | [
"Ends",
"a",
"user",
"paper",
".",
"Sets",
"the",
"end",
"date",
"of",
"the",
"paper",
"and",
"calculates",
"its",
"score",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L282-L302 |
40,323 | claroline/Distribution | plugin/exo/Manager/AttemptManager.php | AttemptManager.useHint | public function useHint(Paper $paper, $questionId, $hintId, $clientIp)
{
$question = $paper->getQuestion($questionId);
if (empty($question)) {
throw new \LogicException("Question {$questionId} and paper {$paper->getId()} are not related");
}
$hint = null;
foreach ($question['hints'] as $questionHint) {
if ($hintId === $questionHint['id']) {
$hint = $questionHint;
break;
}
}
if (empty($hint)) {
// Hint is not related to a question of the current attempt
throw new \LogicException("Hint {$hintId} and paper {$paper->getId()} are not related");
}
// Retrieve or create the answer for the question
$answer = $paper->getAnswer($question['id']);
if (empty($answer)) {
$answer = new Answer();
$answer->setTries(0); // Using an hint is not a try. This will be updated when user will submit his answer
$answer->setQuestionId($question['id']);
$answer->setIp($clientIp);
// Link the new answer to the paper
$paper->addAnswer($answer);
}
$answer->addUsedHint($hintId);
// Calculate new answer score
$decodedQuestion = $this->itemSerializer->deserialize($question, new Item());
$score = $this->itemManager->calculateScore($decodedQuestion, $answer);
$answer->setScore($score);
$this->om->persist($answer);
$this->om->flush();
return $hint;
} | php | public function useHint(Paper $paper, $questionId, $hintId, $clientIp)
{
$question = $paper->getQuestion($questionId);
if (empty($question)) {
throw new \LogicException("Question {$questionId} and paper {$paper->getId()} are not related");
}
$hint = null;
foreach ($question['hints'] as $questionHint) {
if ($hintId === $questionHint['id']) {
$hint = $questionHint;
break;
}
}
if (empty($hint)) {
// Hint is not related to a question of the current attempt
throw new \LogicException("Hint {$hintId} and paper {$paper->getId()} are not related");
}
// Retrieve or create the answer for the question
$answer = $paper->getAnswer($question['id']);
if (empty($answer)) {
$answer = new Answer();
$answer->setTries(0); // Using an hint is not a try. This will be updated when user will submit his answer
$answer->setQuestionId($question['id']);
$answer->setIp($clientIp);
// Link the new answer to the paper
$paper->addAnswer($answer);
}
$answer->addUsedHint($hintId);
// Calculate new answer score
$decodedQuestion = $this->itemSerializer->deserialize($question, new Item());
$score = $this->itemManager->calculateScore($decodedQuestion, $answer);
$answer->setScore($score);
$this->om->persist($answer);
$this->om->flush();
return $hint;
} | [
"public",
"function",
"useHint",
"(",
"Paper",
"$",
"paper",
",",
"$",
"questionId",
",",
"$",
"hintId",
",",
"$",
"clientIp",
")",
"{",
"$",
"question",
"=",
"$",
"paper",
"->",
"getQuestion",
"(",
"$",
"questionId",
")",
";",
"if",
"(",
"empty",
"(... | Flags an hint has used in the user paper and returns the hint content.
@param Paper $paper
@param string $questionId
@param string $hintId
@param string $clientIp
@return mixed | [
"Flags",
"an",
"hint",
"has",
"used",
"in",
"the",
"user",
"paper",
"and",
"returns",
"the",
"hint",
"content",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/AttemptManager.php#L314-L360 |
40,324 | claroline/Distribution | plugin/exo/Serializer/Misc/KeywordSerializer.php | KeywordSerializer.serialize | public function serialize(Keyword $keyword, array $options = [])
{
$serialized = [
'text' => $keyword->getText(),
'caseSensitive' => $keyword->isCaseSensitive(),
'score' => $keyword->getScore(),
];
if ($keyword->getFeedback()) {
$serialized['feedback'] = $keyword->getFeedback();
}
return $serialized;
} | php | public function serialize(Keyword $keyword, array $options = [])
{
$serialized = [
'text' => $keyword->getText(),
'caseSensitive' => $keyword->isCaseSensitive(),
'score' => $keyword->getScore(),
];
if ($keyword->getFeedback()) {
$serialized['feedback'] = $keyword->getFeedback();
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"Keyword",
"$",
"keyword",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'text'",
"=>",
"$",
"keyword",
"->",
"getText",
"(",
")",
",",
"'caseSensitive'",
"=>",
"$",
"keywor... | Converts a Keyword into a JSON-encodable structure.
@param Keyword $keyword
@param array $options
@return array | [
"Converts",
"a",
"Keyword",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Misc/KeywordSerializer.php#L27-L40 |
40,325 | claroline/Distribution | main/core/Listener/Resource/Types/DirectoryListener.php | DirectoryListener.onAdd | public function onAdd(ResourceActionEvent $event)
{
$data = $event->getData();
$parent = $event->getResourceNode();
$add = $this->actionManager->get($parent, 'add');
// checks if the current user can add
$collection = new ResourceCollection([$parent], ['type' => $data['resourceNode']['meta']['type']]);
if (!$this->actionManager->hasPermission($add, $collection)) {
throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources());
}
$options = $event->getOptions();
$options[] = Options::IGNORE_CRUD_POST_EVENT;
// create the resource node
/** @var ResourceNode $resourceNode */
$resourceNode = $this->crud->create(ResourceNode::class, $data['resourceNode'], $options);
$resourceNode->setParent($parent);
$resourceNode->setWorkspace($parent->getWorkspace());
// initialize custom resource Entity
$resourceClass = $resourceNode->getResourceType()->getClass();
/** @var AbstractResource $resource */
$resource = $this->crud->create($resourceClass, !empty($data['resource']) ? $data['resource'] : [], $options);
$resource->setResourceNode($resourceNode);
// maybe do it in the serializer (if it can be done without intermediate flush)
if (!empty($data['resourceNode']['rights'])) {
foreach ($data['resourceNode']['rights'] as $rights) {
/** @var Role $role */
$role = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneBy(['name' => $rights['name']]);
$this->rightsManager->editPerms($rights['permissions'], $role, $resourceNode);
}
} else {
// todo : initialize default rights
}
$this->crud->dispatch('create', 'post', [$resource, $options]);
$this->om->persist($resource);
$this->om->persist($resourceNode);
// todo : dispatch creation event
$this->om->flush();
// todo : dispatch get/load action instead
$event->setResponse(new JsonResponse(
[
'resourceNode' => $this->serializer->serialize($resourceNode),
'resource' => $this->serializer->serialize($resource),
],
201
));
} | php | public function onAdd(ResourceActionEvent $event)
{
$data = $event->getData();
$parent = $event->getResourceNode();
$add = $this->actionManager->get($parent, 'add');
// checks if the current user can add
$collection = new ResourceCollection([$parent], ['type' => $data['resourceNode']['meta']['type']]);
if (!$this->actionManager->hasPermission($add, $collection)) {
throw new ResourceAccessException($collection->getErrorsForDisplay(), $collection->getResources());
}
$options = $event->getOptions();
$options[] = Options::IGNORE_CRUD_POST_EVENT;
// create the resource node
/** @var ResourceNode $resourceNode */
$resourceNode = $this->crud->create(ResourceNode::class, $data['resourceNode'], $options);
$resourceNode->setParent($parent);
$resourceNode->setWorkspace($parent->getWorkspace());
// initialize custom resource Entity
$resourceClass = $resourceNode->getResourceType()->getClass();
/** @var AbstractResource $resource */
$resource = $this->crud->create($resourceClass, !empty($data['resource']) ? $data['resource'] : [], $options);
$resource->setResourceNode($resourceNode);
// maybe do it in the serializer (if it can be done without intermediate flush)
if (!empty($data['resourceNode']['rights'])) {
foreach ($data['resourceNode']['rights'] as $rights) {
/** @var Role $role */
$role = $this->om->getRepository('ClarolineCoreBundle:Role')->findOneBy(['name' => $rights['name']]);
$this->rightsManager->editPerms($rights['permissions'], $role, $resourceNode);
}
} else {
// todo : initialize default rights
}
$this->crud->dispatch('create', 'post', [$resource, $options]);
$this->om->persist($resource);
$this->om->persist($resourceNode);
// todo : dispatch creation event
$this->om->flush();
// todo : dispatch get/load action instead
$event->setResponse(new JsonResponse(
[
'resourceNode' => $this->serializer->serialize($resourceNode),
'resource' => $this->serializer->serialize($resource),
],
201
));
} | [
"public",
"function",
"onAdd",
"(",
"ResourceActionEvent",
"$",
"event",
")",
"{",
"$",
"data",
"=",
"$",
"event",
"->",
"getData",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"event",
"->",
"getResourceNode",
"(",
")",
";",
"$",
"add",
"=",
"$",
"this",... | Adds a new resource inside a directory.
@DI\Observe("resource.directory.add")
@param ResourceActionEvent $event | [
"Adds",
"a",
"new",
"resource",
"inside",
"a",
"directory",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Resource/Types/DirectoryListener.php#L101-L158 |
40,326 | claroline/Distribution | main/core/Listener/Resource/Types/DirectoryListener.php | DirectoryListener.onOpen | public function onOpen(OpenResourceEvent $event)
{
$directory = $event->getResource();
$content = $this->templating->render(
'ClarolineCoreBundle:directory:index.html.twig', [
'directory' => $directory,
'_resource' => $directory,
]
);
$response = new Response($content);
$event->setResponse($response);
$event->stopPropagation();
} | php | public function onOpen(OpenResourceEvent $event)
{
$directory = $event->getResource();
$content = $this->templating->render(
'ClarolineCoreBundle:directory:index.html.twig', [
'directory' => $directory,
'_resource' => $directory,
]
);
$response = new Response($content);
$event->setResponse($response);
$event->stopPropagation();
} | [
"public",
"function",
"onOpen",
"(",
"OpenResourceEvent",
"$",
"event",
")",
"{",
"$",
"directory",
"=",
"$",
"event",
"->",
"getResource",
"(",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreBundle:direct... | Opens a directory.
@DI\Observe("open_directory")
@param OpenResourceEvent $event | [
"Opens",
"a",
"directory",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Resource/Types/DirectoryListener.php#L195-L210 |
40,327 | claroline/Distribution | main/core/Manager/ProgressionManager.php | ProgressionManager.fetchItems | public function fetchItems(Workspace $workspace, User $user = null, $levelMax = 1)
{
$workspaceRoot = $this->finder->get(ResourceNode::class)->find([
'workspace' => $workspace->getUuid(),
'parent' => null,
])[0];
$roles = $user ? $user->getRoles() : ['ROLE_ANONYMOUS'];
$filters = [
'active' => true,
'published' => true,
'hidden' => false,
'resourceTypeEnabled' => true,
'workspace' => $workspace->getUuid(),
];
$sortBy = [
'property' => 'name',
'direction' => 1,
];
if (!in_array('ROLE_ADMIN', $roles)) {
$filters['roles'] = $roles;
}
// Get all resource nodes available for current user in the workspace
$visibleNodes = $this->finder->get(ResourceNode::class)->find($filters);
$filters['parent'] = $workspaceRoot;
// Get all root resource nodes available for current user in the workspace
$rootNodes = $this->finder->get(ResourceNode::class)->find($filters, $sortBy);
$visibleNodesArray = [];
$childrenNodesArray = [];
foreach ($visibleNodes as $node) {
$visibleNodesArray[$node->getUuid()] = $node;
if ($node->getParent()) {
$parentId = $node->getParent()->getUuid();
if (!isset($childrenNodesArray[$parentId])) {
$childrenNodesArray[$parentId] = [];
}
$childrenNodesArray[$parentId][] = $node;
}
}
$items = [];
$this->formatNodes($items, $rootNodes, $visibleNodesArray, $childrenNodesArray, $user, $levelMax, 0);
return $items;
} | php | public function fetchItems(Workspace $workspace, User $user = null, $levelMax = 1)
{
$workspaceRoot = $this->finder->get(ResourceNode::class)->find([
'workspace' => $workspace->getUuid(),
'parent' => null,
])[0];
$roles = $user ? $user->getRoles() : ['ROLE_ANONYMOUS'];
$filters = [
'active' => true,
'published' => true,
'hidden' => false,
'resourceTypeEnabled' => true,
'workspace' => $workspace->getUuid(),
];
$sortBy = [
'property' => 'name',
'direction' => 1,
];
if (!in_array('ROLE_ADMIN', $roles)) {
$filters['roles'] = $roles;
}
// Get all resource nodes available for current user in the workspace
$visibleNodes = $this->finder->get(ResourceNode::class)->find($filters);
$filters['parent'] = $workspaceRoot;
// Get all root resource nodes available for current user in the workspace
$rootNodes = $this->finder->get(ResourceNode::class)->find($filters, $sortBy);
$visibleNodesArray = [];
$childrenNodesArray = [];
foreach ($visibleNodes as $node) {
$visibleNodesArray[$node->getUuid()] = $node;
if ($node->getParent()) {
$parentId = $node->getParent()->getUuid();
if (!isset($childrenNodesArray[$parentId])) {
$childrenNodesArray[$parentId] = [];
}
$childrenNodesArray[$parentId][] = $node;
}
}
$items = [];
$this->formatNodes($items, $rootNodes, $visibleNodesArray, $childrenNodesArray, $user, $levelMax, 0);
return $items;
} | [
"public",
"function",
"fetchItems",
"(",
"Workspace",
"$",
"workspace",
",",
"User",
"$",
"user",
"=",
"null",
",",
"$",
"levelMax",
"=",
"1",
")",
"{",
"$",
"workspaceRoot",
"=",
"$",
"this",
"->",
"finder",
"->",
"get",
"(",
"ResourceNode",
"::",
"cl... | Retrieves list of resource nodes accessible by user and formatted for the progression tool.
@param Workspace $workspace
@param User|null $user
@param int $levelMax
@return array | [
"Retrieves",
"list",
"of",
"resource",
"nodes",
"accessible",
"by",
"user",
"and",
"formatted",
"for",
"the",
"progression",
"tool",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ProgressionManager.php#L67-L114 |
40,328 | claroline/Distribution | main/core/Manager/ProgressionManager.php | ProgressionManager.formatNodes | private function formatNodes(
array &$items,
array $nodes,
array $visibleNodes,
array $childrenNodes,
User $user = null,
$levelMax = 1,
$level = 0
) {
foreach ($nodes as $node) {
$evaluation = $user ?
$this->resourceEvalManager->getResourceUserEvaluation($node, $user, false) :
null;
$item = $this->serializer->serialize($node, [Options::SERIALIZE_MINIMAL, Options::IS_RECURSIVE]);
$item['level'] = $level;
$item['openingUrl'] = ['claro_resource_show_short', ['id' => $item['id']]];
$item['validated'] = !is_null($evaluation) && 0 < $evaluation->getNbOpenings();
$items[] = $item;
if ((is_null($levelMax) || $level < $levelMax) && isset($childrenNodes[$node->getUuid()])) {
$children = [];
usort($childrenNodes[$node->getUuid()], function ($a, $b) {
return strcmp($a->getName(), $b->getName());
});
foreach ($childrenNodes[$node->getUuid()] as $child) {
// Checks if node is visible
if (isset($visibleNodes[$child->getUuid()])) {
$children[] = $visibleNodes[$child->getUuid()];
}
}
if (0 < count($children)) {
$this->formatNodes($items, $children, $visibleNodes, $childrenNodes, $user, $levelMax, $level + 1);
}
}
}
} | php | private function formatNodes(
array &$items,
array $nodes,
array $visibleNodes,
array $childrenNodes,
User $user = null,
$levelMax = 1,
$level = 0
) {
foreach ($nodes as $node) {
$evaluation = $user ?
$this->resourceEvalManager->getResourceUserEvaluation($node, $user, false) :
null;
$item = $this->serializer->serialize($node, [Options::SERIALIZE_MINIMAL, Options::IS_RECURSIVE]);
$item['level'] = $level;
$item['openingUrl'] = ['claro_resource_show_short', ['id' => $item['id']]];
$item['validated'] = !is_null($evaluation) && 0 < $evaluation->getNbOpenings();
$items[] = $item;
if ((is_null($levelMax) || $level < $levelMax) && isset($childrenNodes[$node->getUuid()])) {
$children = [];
usort($childrenNodes[$node->getUuid()], function ($a, $b) {
return strcmp($a->getName(), $b->getName());
});
foreach ($childrenNodes[$node->getUuid()] as $child) {
// Checks if node is visible
if (isset($visibleNodes[$child->getUuid()])) {
$children[] = $visibleNodes[$child->getUuid()];
}
}
if (0 < count($children)) {
$this->formatNodes($items, $children, $visibleNodes, $childrenNodes, $user, $levelMax, $level + 1);
}
}
}
} | [
"private",
"function",
"formatNodes",
"(",
"array",
"&",
"$",
"items",
",",
"array",
"$",
"nodes",
",",
"array",
"$",
"visibleNodes",
",",
"array",
"$",
"childrenNodes",
",",
"User",
"$",
"user",
"=",
"null",
",",
"$",
"levelMax",
"=",
"1",
",",
"$",
... | Recursive function that filters visible nodes and adds serialized version to list after adding some extra params.
@param array $items
@param array $nodes
@param array $visibleNodes
@param array $childrenNodes
@param User|null $user
@param int $levelMax
@param int $level | [
"Recursive",
"function",
"that",
"filters",
"visible",
"nodes",
"and",
"adds",
"serialized",
"version",
"to",
"list",
"after",
"adding",
"some",
"extra",
"params",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/ProgressionManager.php#L127-L164 |
40,329 | claroline/Distribution | plugin/claco-form/Serializer/CategorySerializer.php | CategorySerializer.serialize | public function serialize(Category $category, array $options = [])
{
$serialized = [
'id' => $category->getUuid(),
'name' => $category->getName(),
'details' => $category->getDetails(),
];
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serialized = array_merge($serialized, [
'managers' => array_map(function (User $manager) {
return $this->userSerializer->serialize($manager, [Options::SERIALIZE_MINIMAL]);
}, $category->getManagers()),
]);
$serialized = array_merge($serialized, [
'fieldsValues' => array_map(function (FieldChoiceCategory $fcc) {
return $this->fieldChoiceCategorySerializer->serialize($fcc);
}, $this->fieldChoiceCategoryRepo->findBy(['category' => $category])),
]);
}
return $serialized;
} | php | public function serialize(Category $category, array $options = [])
{
$serialized = [
'id' => $category->getUuid(),
'name' => $category->getName(),
'details' => $category->getDetails(),
];
if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
$serialized = array_merge($serialized, [
'managers' => array_map(function (User $manager) {
return $this->userSerializer->serialize($manager, [Options::SERIALIZE_MINIMAL]);
}, $category->getManagers()),
]);
$serialized = array_merge($serialized, [
'fieldsValues' => array_map(function (FieldChoiceCategory $fcc) {
return $this->fieldChoiceCategorySerializer->serialize($fcc);
}, $this->fieldChoiceCategoryRepo->findBy(['category' => $category])),
]);
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"Category",
"$",
"category",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'id'",
"=>",
"$",
"category",
"->",
"getUuid",
"(",
")",
",",
"'name'",
"=>",
"$",
"category",
"... | Serializes a Category entity for the JSON api.
@param Category $category - the category to serialize
@param array $options - a list of serialization options
@return array - the serialized representation of the category | [
"Serializes",
"a",
"Category",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/claco-form/Serializer/CategorySerializer.php#L70-L92 |
40,330 | claroline/Distribution | main/core/API/Serializer/MessageSerializer.php | MessageSerializer.serialize | public function serialize(AbstractMessage $message, array $options = [])
{
return [
'id' => $message->getUuid(),
'content' => $message->getContent(),
'meta' => $this->serializeMeta($message),
'parent' => $this->serializeParent($message),
'children' => array_map(function (AbstractMessage $child) use ($options) {
return $this->serialize($child, $options);
}, $message->getChildren()->toArray()),
];
} | php | public function serialize(AbstractMessage $message, array $options = [])
{
return [
'id' => $message->getUuid(),
'content' => $message->getContent(),
'meta' => $this->serializeMeta($message),
'parent' => $this->serializeParent($message),
'children' => array_map(function (AbstractMessage $child) use ($options) {
return $this->serialize($child, $options);
}, $message->getChildren()->toArray()),
];
} | [
"public",
"function",
"serialize",
"(",
"AbstractMessage",
"$",
"message",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"message",
"->",
"getUuid",
"(",
")",
",",
"'content'",
"=>",
"$",
"message",
"->",
"get... | Serializes a AbstractMessage entity.
@param AbstractMessage $message
@param array $options
@return array | [
"Serializes",
"a",
"AbstractMessage",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/MessageSerializer.php#L56-L67 |
40,331 | claroline/Distribution | main/core/Entity/Model/OrganizationsTrait.php | OrganizationsTrait.removeOrganization | public function removeOrganization($organization)
{
$this->hasOrganizationsProperty();
if ($this->organizations->contains($organization)) {
$this->organizations->removeElement($organization);
}
} | php | public function removeOrganization($organization)
{
$this->hasOrganizationsProperty();
if ($this->organizations->contains($organization)) {
$this->organizations->removeElement($organization);
}
} | [
"public",
"function",
"removeOrganization",
"(",
"$",
"organization",
")",
"{",
"$",
"this",
"->",
"hasOrganizationsProperty",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"organizations",
"->",
"contains",
"(",
"$",
"organization",
")",
")",
"{",
"$",
"th... | Removes an organization. | [
"Removes",
"an",
"organization",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Entity/Model/OrganizationsTrait.php#L25-L32 |
40,332 | claroline/Distribution | plugin/lesson/Controller/API/ChapterController.php | ChapterController.getAction | public function getAction(Request $request, Lesson $lesson, $chapterSlug)
{
$this->checkPermission('OPEN', $lesson->getResourceNode(), [], true);
$chapter = $this->chapterRepository->getChapterBySlug($chapterSlug, $lesson->getId());
if (is_null($chapter)) {
throw new NotFoundHttpException();
}
return new JsonResponse($this->chapterSerializer->serialize($chapter));
} | php | public function getAction(Request $request, Lesson $lesson, $chapterSlug)
{
$this->checkPermission('OPEN', $lesson->getResourceNode(), [], true);
$chapter = $this->chapterRepository->getChapterBySlug($chapterSlug, $lesson->getId());
if (is_null($chapter)) {
throw new NotFoundHttpException();
}
return new JsonResponse($this->chapterSerializer->serialize($chapter));
} | [
"public",
"function",
"getAction",
"(",
"Request",
"$",
"request",
",",
"Lesson",
"$",
"lesson",
",",
"$",
"chapterSlug",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'OPEN'",
",",
"$",
"lesson",
"->",
"getResourceNode",
"(",
")",
",",
"[",
"]",... | Get chapter by its slug.
@EXT\Route("/chapters/{chapterSlug}", name="apiv2_lesson_chapter_get")
@EXT\Method("GET")
@param Request $request
@param Lesson $lesson
@param string $chapterSlug
@return JsonResponse | [
"Get",
"chapter",
"by",
"its",
"slug",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lesson/Controller/API/ChapterController.php#L81-L92 |
40,333 | claroline/Distribution | plugin/lesson/Controller/API/ChapterController.php | ChapterController.createAction | public function createAction(Request $request, Lesson $lesson, Chapter $parent)
{
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$newChapter = $this->chapterManager->createChapter($lesson, json_decode($request->getContent(), true), $parent);
return new JsonResponse($this->chapterSerializer->serialize($newChapter));
} | php | public function createAction(Request $request, Lesson $lesson, Chapter $parent)
{
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$newChapter = $this->chapterManager->createChapter($lesson, json_decode($request->getContent(), true), $parent);
return new JsonResponse($this->chapterSerializer->serialize($newChapter));
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
",",
"Lesson",
"$",
"lesson",
",",
"Chapter",
"$",
"parent",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"lesson",
"->",
"getResourceNode",
"(",
")",
",",
... | Create new chapter.
@EXT\Route("/chapters/{slug}", name="apiv2_lesson_chapter_create")
@EXT\Method("POST")
@EXT\ParamConverter("parent", class="IcapLessonBundle:Chapter", options={"mapping": {"slug": "slug"}})
@param Request $request
@param Lesson $lesson
@param Chapter $parent
@return JsonResponse | [
"Create",
"new",
"chapter",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lesson/Controller/API/ChapterController.php#L107-L114 |
40,334 | claroline/Distribution | plugin/lesson/Controller/API/ChapterController.php | ChapterController.editAction | public function editAction(Request $request, Lesson $lesson, Chapter $chapter)
{
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$this->chapterManager->updateChapter($lesson, $chapter, json_decode($request->getContent(), true));
return new JsonResponse($this->chapterSerializer->serialize($chapter));
} | php | public function editAction(Request $request, Lesson $lesson, Chapter $chapter)
{
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$this->chapterManager->updateChapter($lesson, $chapter, json_decode($request->getContent(), true));
return new JsonResponse($this->chapterSerializer->serialize($chapter));
} | [
"public",
"function",
"editAction",
"(",
"Request",
"$",
"request",
",",
"Lesson",
"$",
"lesson",
",",
"Chapter",
"$",
"chapter",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"lesson",
"->",
"getResourceNode",
"(",
")",
",",
"... | Update existing chapter.
@EXT\Route("/chapters/{slug}", name="apiv2_lesson_chapter_update")
@EXT\Method("PUT")
@EXT\ParamConverter("chapter", class="IcapLessonBundle:Chapter", options={"mapping": {"slug": "slug"}})
@param Request $request
@param Lesson $lesson
@param Chapter $chapter
@return JsonResponse | [
"Update",
"existing",
"chapter",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lesson/Controller/API/ChapterController.php#L129-L136 |
40,335 | claroline/Distribution | plugin/lesson/Controller/API/ChapterController.php | ChapterController.deleteAction | public function deleteAction(Request $request, Lesson $lesson, Chapter $chapter)
{
$previousChapter = $this->chapterRepository->getPreviousChapter($chapter);
$previousSlug = $previousChapter ? $previousChapter->getSlug() : null;
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$payload = json_decode($request->getContent(), true);
$deleteChildren = $payload['deleteChildren'];
$this->chapterManager->deleteChapter($lesson, $chapter, $deleteChildren);
return new JsonResponse([
'tree' => $this->chapterManager->serializeChapterTree($lesson),
'slug' => $previousSlug,
]);
} | php | public function deleteAction(Request $request, Lesson $lesson, Chapter $chapter)
{
$previousChapter = $this->chapterRepository->getPreviousChapter($chapter);
$previousSlug = $previousChapter ? $previousChapter->getSlug() : null;
$this->checkPermission('EDIT', $lesson->getResourceNode(), [], true);
$payload = json_decode($request->getContent(), true);
$deleteChildren = $payload['deleteChildren'];
$this->chapterManager->deleteChapter($lesson, $chapter, $deleteChildren);
return new JsonResponse([
'tree' => $this->chapterManager->serializeChapterTree($lesson),
'slug' => $previousSlug,
]);
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"Lesson",
"$",
"lesson",
",",
"Chapter",
"$",
"chapter",
")",
"{",
"$",
"previousChapter",
"=",
"$",
"this",
"->",
"chapterRepository",
"->",
"getPreviousChapter",
"(",
"$",
"chapter",
... | Delete existing chapter.
@EXT\Route("/chapters/{chapterSlug}/delete", name="apiv2_lesson_chapter_delete")
@EXT\Method("DELETE")
@EXT\ParamConverter("chapter", class="IcapLessonBundle:Chapter", options={"mapping": {"chapterSlug": "slug"}})
@param Request $request
@param Lesson $lesson
@param Chapter $chapter
@return JsonResponse | [
"Delete",
"existing",
"chapter",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lesson/Controller/API/ChapterController.php#L151-L167 |
40,336 | claroline/Distribution | plugin/lesson/Controller/API/ChapterController.php | ChapterController.getTreeAction | public function getTreeAction(Lesson $lesson)
{
$this->checkPermission('OPEN', $lesson->getResourceNode(), [], true);
return new JsonResponse($this->chapterManager->serializeChapterTree($lesson));
} | php | public function getTreeAction(Lesson $lesson)
{
$this->checkPermission('OPEN', $lesson->getResourceNode(), [], true);
return new JsonResponse($this->chapterManager->serializeChapterTree($lesson));
} | [
"public",
"function",
"getTreeAction",
"(",
"Lesson",
"$",
"lesson",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'OPEN'",
",",
"$",
"lesson",
"->",
"getResourceNode",
"(",
")",
",",
"[",
"]",
",",
"true",
")",
";",
"return",
"new",
"JsonRespons... | Get chapter tree.
@EXT\Route("/tree", name="apiv2_lesson_tree_get")
@EXT\Method("GET")
@param Lesson $lesson
@return JsonResponse | [
"Get",
"chapter",
"tree",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/lesson/Controller/API/ChapterController.php#L179-L184 |
40,337 | claroline/Distribution | plugin/exo/Library/Json/JsonSchema.php | JsonSchema.validate | public function validate($data, $uri)
{
return $this->getValidator()->validate($data, $this->getSchema($uri));
} | php | public function validate($data, $uri)
{
return $this->getValidator()->validate($data, $this->getSchema($uri));
} | [
"public",
"function",
"validate",
"(",
"$",
"data",
",",
"$",
"uri",
")",
"{",
"return",
"$",
"this",
"->",
"getValidator",
"(",
")",
"->",
"validate",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"getSchema",
"(",
"$",
"uri",
")",
")",
";",
"}"
] | Validates data against the schema located at URI.
@param mixed $data - the data to validate
@param string $uri - the URI of the schema to use
@return array | [
"Validates",
"data",
"against",
"the",
"schema",
"located",
"at",
"URI",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Json/JsonSchema.php#L57-L60 |
40,338 | claroline/Distribution | plugin/exo/Library/Json/JsonSchema.php | JsonSchema.getValidator | private function getValidator()
{
if (null === $this->validator) {
$hook = function ($uri) {
return $this->uriToFile($uri);
};
$this->validator = SchemaValidator::buildDefault($hook);
}
return $this->validator;
} | php | private function getValidator()
{
if (null === $this->validator) {
$hook = function ($uri) {
return $this->uriToFile($uri);
};
$this->validator = SchemaValidator::buildDefault($hook);
}
return $this->validator;
} | [
"private",
"function",
"getValidator",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"validator",
")",
"{",
"$",
"hook",
"=",
"function",
"(",
"$",
"uri",
")",
"{",
"return",
"$",
"this",
"->",
"uriToFile",
"(",
"$",
"uri",
")",
";",
... | Get schema validator.
@return SchemaValidator | [
"Get",
"schema",
"validator",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Json/JsonSchema.php#L67-L78 |
40,339 | claroline/Distribution | plugin/exo/Library/Json/JsonSchema.php | JsonSchema.getSchema | private function getSchema($uri)
{
if (empty($this->schemas[$uri])) {
$this->schemas[$uri] = Utils::loadJsonFromFile($this->uriToFile($uri));
}
return $this->schemas[$uri];
} | php | private function getSchema($uri)
{
if (empty($this->schemas[$uri])) {
$this->schemas[$uri] = Utils::loadJsonFromFile($this->uriToFile($uri));
}
return $this->schemas[$uri];
} | [
"private",
"function",
"getSchema",
"(",
"$",
"uri",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"schemas",
"[",
"$",
"uri",
"]",
")",
")",
"{",
"$",
"this",
"->",
"schemas",
"[",
"$",
"uri",
"]",
"=",
"Utils",
"::",
"loadJsonFromFile",
... | Loads schema from URI.
@param $uri
@return mixed
@throws \JVal\Exception\JsonDecodeException | [
"Loads",
"schema",
"from",
"URI",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Json/JsonSchema.php#L89-L96 |
40,340 | claroline/Distribution | plugin/exo/Serializer/Misc/CellChoiceSerializer.php | CellChoiceSerializer.serialize | public function serialize(CellChoice $choice, array $options = [])
{
$serialized = [
'text' => $choice->getText(),
'caseSensitive' => $choice->isCaseSensitive(),
'score' => $choice->getScore(),
'expected' => $choice->isExpected(),
];
if ($choice->getFeedback()) {
$serialized['feedback'] = $choice->getFeedback();
}
return $serialized;
} | php | public function serialize(CellChoice $choice, array $options = [])
{
$serialized = [
'text' => $choice->getText(),
'caseSensitive' => $choice->isCaseSensitive(),
'score' => $choice->getScore(),
'expected' => $choice->isExpected(),
];
if ($choice->getFeedback()) {
$serialized['feedback'] = $choice->getFeedback();
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"CellChoice",
"$",
"choice",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'text'",
"=>",
"$",
"choice",
"->",
"getText",
"(",
")",
",",
"'caseSensitive'",
"=>",
"$",
"choic... | Converts a CellChoice into a JSON-encodable structure.
@param CellChoice $choice
@param array $options
@return array | [
"Converts",
"a",
"CellChoice",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Misc/CellChoiceSerializer.php#L27-L41 |
40,341 | claroline/Distribution | main/core/Repository/GroupRepository.php | GroupRepository.findGroupsByWorkspacesAndSearch | public function findGroupsByWorkspacesAndSearch(array $workspaces, $search)
{
$upperSearch = strtoupper(trim($search));
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
LEFT JOIN g.roles wr WITH wr IN (
SELECT pr
FROM Claroline\CoreBundle\Entity\Role pr
WHERE pr.type = :type
)
LEFT JOIN wr.workspace w
WHERE w IN (:workspaces)
AND UPPER(g.name) LIKE :search
ORDER BY g.name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('type', Role::WS_ROLE);
return $query->getResult();
} | php | public function findGroupsByWorkspacesAndSearch(array $workspaces, $search)
{
$upperSearch = strtoupper(trim($search));
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
LEFT JOIN g.roles wr WITH wr IN (
SELECT pr
FROM Claroline\CoreBundle\Entity\Role pr
WHERE pr.type = :type
)
LEFT JOIN wr.workspace w
WHERE w IN (:workspaces)
AND UPPER(g.name) LIKE :search
ORDER BY g.name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('workspaces', $workspaces);
$query->setParameter('search', "%{$upperSearch}%");
$query->setParameter('type', Role::WS_ROLE);
return $query->getResult();
} | [
"public",
"function",
"findGroupsByWorkspacesAndSearch",
"(",
"array",
"$",
"workspaces",
",",
"$",
"search",
")",
"{",
"$",
"upperSearch",
"=",
"strtoupper",
"(",
"trim",
"(",
"$",
"search",
")",
")",
";",
"$",
"dql",
"=",
"'\n SELECT g\n ... | Returns the groups which are member of a workspace
and whose name corresponds the search.
@param array $workspace
@param string $search
@return array[Group] | [
"Returns",
"the",
"groups",
"which",
"are",
"member",
"of",
"a",
"workspace",
"and",
"whose",
"name",
"corresponds",
"the",
"search",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L84-L106 |
40,342 | claroline/Distribution | main/core/Repository/GroupRepository.php | GroupRepository.findGroupsByNames | public function findGroupsByNames(array $names)
{
$nameCount = count($names);
$dql = '
SELECT g FROM Claroline\CoreBundle\Entity\Group g
WHERE g.name IN (:names)
';
$query = $this->_em->createQuery($dql);
$query->setParameter('names', $names);
$result = $query->getResult();
if (($groupCount = count($result)) !== $nameCount) {
throw new MissingObjectException("{$groupCount} out of {$nameCount} groups were found");
}
return $result;
} | php | public function findGroupsByNames(array $names)
{
$nameCount = count($names);
$dql = '
SELECT g FROM Claroline\CoreBundle\Entity\Group g
WHERE g.name IN (:names)
';
$query = $this->_em->createQuery($dql);
$query->setParameter('names', $names);
$result = $query->getResult();
if (($groupCount = count($result)) !== $nameCount) {
throw new MissingObjectException("{$groupCount} out of {$nameCount} groups were found");
}
return $result;
} | [
"public",
"function",
"findGroupsByNames",
"(",
"array",
"$",
"names",
")",
"{",
"$",
"nameCount",
"=",
"count",
"(",
"$",
"names",
")",
";",
"$",
"dql",
"=",
"'\n SELECT g FROM Claroline\\CoreBundle\\Entity\\Group g\n WHERE g.name IN (:names)\n ... | Returns groups by their names.
@param array $names
@return array[Group]
@throws MissingObjectException if one or more groups cannot be found | [
"Returns",
"groups",
"by",
"their",
"names",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L269-L287 |
40,343 | claroline/Distribution | main/core/Repository/GroupRepository.php | GroupRepository.findGroupByName | public function findGroupByName($name, $executeQuery = true)
{
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
WHERE g.name = :name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('name', $name);
return $executeQuery ? $query->getOneOrNullResult() : $query;
} | php | public function findGroupByName($name, $executeQuery = true)
{
$dql = '
SELECT g
FROM Claroline\CoreBundle\Entity\Group g
WHERE g.name = :name
';
$query = $this->_em->createQuery($dql);
$query->setParameter('name', $name);
return $executeQuery ? $query->getOneOrNullResult() : $query;
} | [
"public",
"function",
"findGroupByName",
"(",
"$",
"name",
",",
"$",
"executeQuery",
"=",
"true",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT g\n FROM Claroline\\CoreBundle\\Entity\\Group g\n WHERE g.name = :name\n '",
";",
"$",
"query",
"="... | Returns a group by its name.
@param string $name
@param bool $executeQuery
@return Group|null | [
"Returns",
"a",
"group",
"by",
"its",
"name",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Repository/GroupRepository.php#L305-L317 |
40,344 | claroline/Distribution | plugin/scorm/Listener/ScormListener.php | ScormListener.copySco | private function copySco(Sco $sco, Scorm $resource, Sco $scoParent = null)
{
$scoCopy = new Sco();
$scoCopy->setScorm($resource);
$scoCopy->setScoParent($scoParent);
$scoCopy->setEntryUrl($sco->getEntryUrl());
$scoCopy->setIdentifier($sco->getIdentifier());
$scoCopy->setTitle($sco->getTitle());
$scoCopy->setVisible($sco->isVisible());
$scoCopy->setParameters($sco->getParameters());
$scoCopy->setLaunchData($sco->getLaunchData());
$scoCopy->setMaxTimeAllowed($sco->getMaxTimeAllowed());
$scoCopy->setTimeLimitAction($sco->getTimeLimitAction());
$scoCopy->setBlock($sco->isBlock());
$scoCopy->setScoreToPassInt($sco->getScoreToPassInt());
$scoCopy->setScoreToPassDecimal($sco->getScoreToPassDecimal());
$scoCopy->setCompletionThreshold($sco->getCompletionThreshold());
$scoCopy->setPrerequisites($sco->getPrerequisites());
$this->om->persist($scoCopy);
foreach ($sco->getScoChildren() as $scoChild) {
$this->copySco($scoChild, $resource, $scoCopy);
}
} | php | private function copySco(Sco $sco, Scorm $resource, Sco $scoParent = null)
{
$scoCopy = new Sco();
$scoCopy->setScorm($resource);
$scoCopy->setScoParent($scoParent);
$scoCopy->setEntryUrl($sco->getEntryUrl());
$scoCopy->setIdentifier($sco->getIdentifier());
$scoCopy->setTitle($sco->getTitle());
$scoCopy->setVisible($sco->isVisible());
$scoCopy->setParameters($sco->getParameters());
$scoCopy->setLaunchData($sco->getLaunchData());
$scoCopy->setMaxTimeAllowed($sco->getMaxTimeAllowed());
$scoCopy->setTimeLimitAction($sco->getTimeLimitAction());
$scoCopy->setBlock($sco->isBlock());
$scoCopy->setScoreToPassInt($sco->getScoreToPassInt());
$scoCopy->setScoreToPassDecimal($sco->getScoreToPassDecimal());
$scoCopy->setCompletionThreshold($sco->getCompletionThreshold());
$scoCopy->setPrerequisites($sco->getPrerequisites());
$this->om->persist($scoCopy);
foreach ($sco->getScoChildren() as $scoChild) {
$this->copySco($scoChild, $resource, $scoCopy);
}
} | [
"private",
"function",
"copySco",
"(",
"Sco",
"$",
"sco",
",",
"Scorm",
"$",
"resource",
",",
"Sco",
"$",
"scoParent",
"=",
"null",
")",
"{",
"$",
"scoCopy",
"=",
"new",
"Sco",
"(",
")",
";",
"$",
"scoCopy",
"->",
"setScorm",
"(",
"$",
"resource",
... | Copy given sco and its children.
@param Sco $sco
@param Scorm $resource
@param Sco $scoParent | [
"Copy",
"given",
"sco",
"and",
"its",
"children",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/scorm/Listener/ScormListener.php#L308-L332 |
40,345 | claroline/Distribution | main/core/Manager/WidgetManager.php | WidgetManager.getAvailable | public function getAvailable($context = null)
{
$enabledPlugins = $this->pluginManager->getEnabled(true);
return $this->widgetRepository->findAllAvailable($enabledPlugins, $context);
} | php | public function getAvailable($context = null)
{
$enabledPlugins = $this->pluginManager->getEnabled(true);
return $this->widgetRepository->findAllAvailable($enabledPlugins, $context);
} | [
"public",
"function",
"getAvailable",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"enabledPlugins",
"=",
"$",
"this",
"->",
"pluginManager",
"->",
"getEnabled",
"(",
"true",
")",
";",
"return",
"$",
"this",
"->",
"widgetRepository",
"->",
"findAllAvaila... | Get the list of available widgets in the platform.
@param string $context
@return array | [
"Get",
"the",
"list",
"of",
"available",
"widgets",
"in",
"the",
"platform",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Manager/WidgetManager.php#L65-L70 |
40,346 | claroline/Distribution | plugin/drop-zone/Controller/API/DropzoneController.php | DropzoneController.updateAction | public function updateAction(Dropzone $dropzone, Request $request)
{
$this->checkPermission('EDIT', $dropzone->getResourceNode(), [], true);
try {
$this->manager->update($dropzone, json_decode($request->getContent(), true));
$closedDropStates = [
Dropzone::STATE_FINISHED,
Dropzone::STATE_PEER_REVIEW,
Dropzone::STATE_WAITING_FOR_PEER_REVIEW,
];
if (!$dropzone->getDropClosed() && $dropzone->getManualPlanning() && in_array($dropzone->getManualState(), $closedDropStates)) {
$this->manager->closeAllUnfinishedDrops($dropzone);
}
return new JsonResponse($this->manager->serialize($dropzone));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | php | public function updateAction(Dropzone $dropzone, Request $request)
{
$this->checkPermission('EDIT', $dropzone->getResourceNode(), [], true);
try {
$this->manager->update($dropzone, json_decode($request->getContent(), true));
$closedDropStates = [
Dropzone::STATE_FINISHED,
Dropzone::STATE_PEER_REVIEW,
Dropzone::STATE_WAITING_FOR_PEER_REVIEW,
];
if (!$dropzone->getDropClosed() && $dropzone->getManualPlanning() && in_array($dropzone->getManualState(), $closedDropStates)) {
$this->manager->closeAllUnfinishedDrops($dropzone);
}
return new JsonResponse($this->manager->serialize($dropzone));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | [
"public",
"function",
"updateAction",
"(",
"Dropzone",
"$",
"dropzone",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'EDIT'",
",",
"$",
"dropzone",
"->",
"getResourceNode",
"(",
")",
",",
"[",
"]",
",",
"true",
")... | Updates a Dropzone resource.
@EXT\Route("/{id}", name="claro_dropzone_update")
@EXT\Method("PUT")
@EXT\ParamConverter(
"dropzone",
class="ClarolineDropZoneBundle:Dropzone",
options={"mapping": {"id": "uuid"}}
)
@param Dropzone $dropzone
@param Request $request
@return JsonResponse | [
"Updates",
"a",
"Dropzone",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropzoneController.php#L91-L112 |
40,347 | claroline/Distribution | plugin/drop-zone/Controller/API/DropzoneController.php | DropzoneController.downloadAction | public function downloadAction(Document $document)
{
$this->checkDocumentAccess($document);
$data = $document->getData();
$response = new StreamedResponse();
$path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url'];
$response->setCallBack(
function () use ($path) {
readfile($path);
}
);
$response->headers->set('Content-Transfer-Encoding', 'octet-stream');
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']);
$response->headers->set('Content-Type', $data['mimeType']);
$response->headers->set('Connection', 'close');
$this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document));
return $response->send();
} | php | public function downloadAction(Document $document)
{
$this->checkDocumentAccess($document);
$data = $document->getData();
$response = new StreamedResponse();
$path = $this->filesDir.DIRECTORY_SEPARATOR.$data['url'];
$response->setCallBack(
function () use ($path) {
readfile($path);
}
);
$response->headers->set('Content-Transfer-Encoding', 'octet-stream');
$response->headers->set('Content-Type', 'application/force-download');
$response->headers->set('Content-Disposition', 'attachment; filename='.$data['name']);
$response->headers->set('Content-Type', $data['mimeType']);
$response->headers->set('Connection', 'close');
$this->eventDispatcher->dispatch('log', new LogDocumentOpenEvent($document->getDrop()->getDropzone(), $document->getDrop(), $document));
return $response->send();
} | [
"public",
"function",
"downloadAction",
"(",
"Document",
"$",
"document",
")",
"{",
"$",
"this",
"->",
"checkDocumentAccess",
"(",
"$",
"document",
")",
";",
"$",
"data",
"=",
"$",
"document",
"->",
"getData",
"(",
")",
";",
"$",
"response",
"=",
"new",
... | Downloads a document.
@EXT\Route("/{document}/download", name="claro_dropzone_document_download")
@EXT\Method("GET")
@EXT\ParamConverter(
"document",
class="ClarolineDropZoneBundle:Document",
options={"mapping": {"document": "uuid"}}
)
@param Document $document
@return StreamedResponse | [
"Downloads",
"a",
"document",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropzoneController.php#L407-L428 |
40,348 | claroline/Distribution | main/core/Listener/Tool/ContactsListener.php | ContactsListener.onDisplayDesktopContactTool | public function onDisplayDesktopContactTool(DisplayToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:tool:contacts.html.twig', [
'options' => $this->contactManager->getUserOptions(
$this->tokenStorage->getToken()->getUser()
),
]
);
$event->setContent($content);
$event->stopPropagation();
} | php | public function onDisplayDesktopContactTool(DisplayToolEvent $event)
{
$content = $this->templating->render(
'ClarolineCoreBundle:tool:contacts.html.twig', [
'options' => $this->contactManager->getUserOptions(
$this->tokenStorage->getToken()->getUser()
),
]
);
$event->setContent($content);
$event->stopPropagation();
} | [
"public",
"function",
"onDisplayDesktopContactTool",
"(",
"DisplayToolEvent",
"$",
"event",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"'ClarolineCoreBundle:tool:contacts.html.twig'",
",",
"[",
"'options'",
"=>",
"$",
"this"... | Displays contacts on Desktop.
@DI\Observe("open_tool_desktop_my_contacts")
@param DisplayToolEvent $event | [
"Displays",
"contacts",
"on",
"Desktop",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Listener/Tool/ContactsListener.php#L66-L78 |
40,349 | claroline/Distribution | plugin/drop-zone/Controller/API/DropController.php | DropController.createAction | public function createAction(Dropzone $dropzone, User $user, Team $team = null)
{
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
if (!empty($team)) {
$this->checkTeamUser($team, $user);
}
try {
if (empty($team)) {
// creates a User drop
$myDrop = $this->manager->getUserDrop($dropzone, $user, true);
} else {
// creates a Team drop
$myDrop = $this->manager->getTeamDrop($dropzone, $team, $user, true);
}
return new JsonResponse($this->manager->serializeDrop($myDrop));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | php | public function createAction(Dropzone $dropzone, User $user, Team $team = null)
{
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
if (!empty($team)) {
$this->checkTeamUser($team, $user);
}
try {
if (empty($team)) {
// creates a User drop
$myDrop = $this->manager->getUserDrop($dropzone, $user, true);
} else {
// creates a Team drop
$myDrop = $this->manager->getTeamDrop($dropzone, $team, $user, true);
}
return new JsonResponse($this->manager->serializeDrop($myDrop));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | [
"public",
"function",
"createAction",
"(",
"Dropzone",
"$",
"dropzone",
",",
"User",
"$",
"user",
",",
"Team",
"$",
"team",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"checkPermission",
"(",
"'OPEN'",
",",
"$",
"dropzone",
"->",
"getResourceNode",
"(",
")... | Initializes a Drop for the current User or Team.
@EXT\Route("/{id}/drops/{teamId}", name="claro_dropzone_drop_create", defaults={"teamId"=null})
@EXT\ParamConverter("dropzone", class="ClarolineDropZoneBundle:Dropzone", options={"mapping": {"id": "uuid"}})
@EXT\ParamConverter("team", class="ClarolineTeamBundle:Team", options={"mapping": {"teamId": "uuid"}})
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@EXT\Method("POST")
@param Dropzone $dropzone
@param Team $team
@param User $user
@return JsonResponse | [
"Initializes",
"a",
"Drop",
"for",
"the",
"current",
"User",
"or",
"Team",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L140-L160 |
40,350 | claroline/Distribution | plugin/drop-zone/Controller/API/DropController.php | DropController.submitAction | public function submitAction(Drop $drop, User $user)
{
$dropzone = $drop->getDropzone();
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
$this->checkDropEdition($drop, $user);
try {
$this->manager->submitDrop($drop, $user);
$progression = $dropzone->isPeerReview() ? 50 : 100;
$this->manager->updateDropProgression($dropzone, $drop, $progression);
return new JsonResponse($this->manager->serializeDrop($drop));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | php | public function submitAction(Drop $drop, User $user)
{
$dropzone = $drop->getDropzone();
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
$this->checkDropEdition($drop, $user);
try {
$this->manager->submitDrop($drop, $user);
$progression = $dropzone->isPeerReview() ? 50 : 100;
$this->manager->updateDropProgression($dropzone, $drop, $progression);
return new JsonResponse($this->manager->serializeDrop($drop));
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | [
"public",
"function",
"submitAction",
"(",
"Drop",
"$",
"drop",
",",
"User",
"$",
"user",
")",
"{",
"$",
"dropzone",
"=",
"$",
"drop",
"->",
"getDropzone",
"(",
")",
";",
"$",
"this",
"->",
"checkPermission",
"(",
"'OPEN'",
",",
"$",
"dropzone",
"->",
... | Submits Drop.
@EXT\Route("/drop/{id}/submit", name="claro_dropzone_drop_submit")
@EXT\Method("PUT")
@EXT\ParamConverter(
"drop",
class="ClarolineDropZoneBundle:Drop",
options={"mapping": {"id": "uuid"}}
)
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Drop $drop
@param User $user
@return JsonResponse | [
"Submits",
"Drop",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L179-L194 |
40,351 | claroline/Distribution | plugin/drop-zone/Controller/API/DropController.php | DropController.addDocumentAction | public function addDocumentAction(Drop $drop, $type, User $user, Request $request)
{
$dropzone = $drop->getDropzone();
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
$this->checkDropEdition($drop, $user);
$documents = [];
try {
if (!$drop->isFinished()) {
switch ($type) {
case Document::DOCUMENT_TYPE_FILE:
$files = $request->files->all();
$documents = $this->manager->createFilesDocuments($drop, $user, $files);
break;
case Document::DOCUMENT_TYPE_TEXT:
case Document::DOCUMENT_TYPE_URL:
case Document::DOCUMENT_TYPE_RESOURCE:
$uuid = $request->request->get('dropData', false);
$document = $this->manager->createDocument($drop, $user, $type, $uuid);
$documents[] = $this->manager->serializeDocument($document);
break;
}
$progression = $dropzone->isPeerReview() ? 0 : 50;
$this->manager->updateDropProgression($dropzone, $drop, $progression);
}
return new JsonResponse($documents);
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | php | public function addDocumentAction(Drop $drop, $type, User $user, Request $request)
{
$dropzone = $drop->getDropzone();
$this->checkPermission('OPEN', $dropzone->getResourceNode(), [], true);
$this->checkDropEdition($drop, $user);
$documents = [];
try {
if (!$drop->isFinished()) {
switch ($type) {
case Document::DOCUMENT_TYPE_FILE:
$files = $request->files->all();
$documents = $this->manager->createFilesDocuments($drop, $user, $files);
break;
case Document::DOCUMENT_TYPE_TEXT:
case Document::DOCUMENT_TYPE_URL:
case Document::DOCUMENT_TYPE_RESOURCE:
$uuid = $request->request->get('dropData', false);
$document = $this->manager->createDocument($drop, $user, $type, $uuid);
$documents[] = $this->manager->serializeDocument($document);
break;
}
$progression = $dropzone->isPeerReview() ? 0 : 50;
$this->manager->updateDropProgression($dropzone, $drop, $progression);
}
return new JsonResponse($documents);
} catch (\Exception $e) {
return new JsonResponse($e->getMessage(), 422);
}
} | [
"public",
"function",
"addDocumentAction",
"(",
"Drop",
"$",
"drop",
",",
"$",
"type",
",",
"User",
"$",
"user",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"dropzone",
"=",
"$",
"drop",
"->",
"getDropzone",
"(",
")",
";",
"$",
"this",
"->",
"chec... | Adds a Document to a Drop.
@EXT\Route("/drop/{id}/type/{type}", name="claro_dropzone_documents_add")
@EXT\Method("POST")
@EXT\ParamConverter(
"drop",
class="ClarolineDropZoneBundle:Drop",
options={"mapping": {"id": "uuid"}}
)
@EXT\ParamConverter("user", converter="current_user", options={"allowAnonymous"=false})
@param Drop $drop
@param int $type
@param User $user
@param Request $request
@return JsonResponse | [
"Adds",
"a",
"Document",
"to",
"a",
"Drop",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/drop-zone/Controller/API/DropController.php#L245-L275 |
40,352 | claroline/Distribution | plugin/reservation/Manager/ReservationManager.php | ReservationManager.completeJsonEventWithReservation | public function completeJsonEventWithReservation(Reservation $reservation)
{
$color = $reservation->getResource()->getColor();
return array_merge(
$reservation->getEvent()->jsonSerialize(),
[
'color' => !empty($color) ? $color : '#3a87ad',
'comment' => $reservation->getComment(),
'resourceTypeId' => $reservation->getResource()->getResourceType()->getId(),
'resourceTypeName' => $reservation->getResource()->getResourceType()->getName(),
'resourceId' => $reservation->getResource()->getId(),
'reservationId' => $reservation->getId(),
'editable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK),
'durationEditable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK),
]
);
} | php | public function completeJsonEventWithReservation(Reservation $reservation)
{
$color = $reservation->getResource()->getColor();
return array_merge(
$reservation->getEvent()->jsonSerialize(),
[
'color' => !empty($color) ? $color : '#3a87ad',
'comment' => $reservation->getComment(),
'resourceTypeId' => $reservation->getResource()->getResourceType()->getId(),
'resourceTypeName' => $reservation->getResource()->getResourceType()->getName(),
'resourceId' => $reservation->getResource()->getId(),
'reservationId' => $reservation->getId(),
'editable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK),
'durationEditable' => $this->hasAccess($reservation->getEvent()->getUser(), $reservation->getResource(), ReservationController::BOOK),
]
);
} | [
"public",
"function",
"completeJsonEventWithReservation",
"(",
"Reservation",
"$",
"reservation",
")",
"{",
"$",
"color",
"=",
"$",
"reservation",
"->",
"getResource",
"(",
")",
"->",
"getColor",
"(",
")",
";",
"return",
"array_merge",
"(",
"$",
"reservation",
... | Add to the jsonSerialize, some reservations fields | [
"Add",
"to",
"the",
"jsonSerialize",
"some",
"reservations",
"fields"
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/reservation/Manager/ReservationManager.php#L79-L96 |
40,353 | claroline/Distribution | main/core/API/Serializer/Resource/Types/FileSerializer.php | FileSerializer.serialize | public function serialize(File $file)
{
$options = [
'id' => $file->getId(),
'size' => $file->getSize(),
'autoDownload' => $file->getAutoDownload(),
'commentsActivated' => $file->getResourceNode()->isCommentsActivated(),
'hashName' => $file->getHashName(),
// We generate URL here because the stream API endpoint uses ResourceNode ID,
// but the new api only contains the ResourceNode UUID.
// NB : This will no longer be required when the stream API will use UUIDs
'url' => $this->router->generate('claro_file_get_media', [
'node' => $file->getResourceNode()->getId(),
]),
];
return $options;
} | php | public function serialize(File $file)
{
$options = [
'id' => $file->getId(),
'size' => $file->getSize(),
'autoDownload' => $file->getAutoDownload(),
'commentsActivated' => $file->getResourceNode()->isCommentsActivated(),
'hashName' => $file->getHashName(),
// We generate URL here because the stream API endpoint uses ResourceNode ID,
// but the new api only contains the ResourceNode UUID.
// NB : This will no longer be required when the stream API will use UUIDs
'url' => $this->router->generate('claro_file_get_media', [
'node' => $file->getResourceNode()->getId(),
]),
];
return $options;
} | [
"public",
"function",
"serialize",
"(",
"File",
"$",
"file",
")",
"{",
"$",
"options",
"=",
"[",
"'id'",
"=>",
"$",
"file",
"->",
"getId",
"(",
")",
",",
"'size'",
"=>",
"$",
"file",
"->",
"getSize",
"(",
")",
",",
"'autoDownload'",
"=>",
"$",
"fil... | Serializes a File resource entity for the JSON api.
@param File $file - the file to serialize
@return array - the serialized representation of the file | [
"Serializes",
"a",
"File",
"resource",
"entity",
"for",
"the",
"JSON",
"api",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/API/Serializer/Resource/Types/FileSerializer.php#L47-L66 |
40,354 | claroline/Distribution | plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php | OrderingQuestionSerializer.serialize | public function serialize(OrderingQuestion $question, array $options = [])
{
$serialized = [
'mode' => $question->getMode(),
'direction' => $question->getDirection(),
'penalty' => $question->getPenalty(),
];
// Serializes items
$items = $this->serializeItems($question, $options);
// shuffle items only in player
if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
shuffle($items);
}
$serialized['items'] = $items;
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['solutions'] = $this->serializeSolutions($question);
}
return $serialized;
} | php | public function serialize(OrderingQuestion $question, array $options = [])
{
$serialized = [
'mode' => $question->getMode(),
'direction' => $question->getDirection(),
'penalty' => $question->getPenalty(),
];
// Serializes items
$items = $this->serializeItems($question, $options);
// shuffle items only in player
if (in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
shuffle($items);
}
$serialized['items'] = $items;
if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
$serialized['solutions'] = $this->serializeSolutions($question);
}
return $serialized;
} | [
"public",
"function",
"serialize",
"(",
"OrderingQuestion",
"$",
"question",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"serialized",
"=",
"[",
"'mode'",
"=>",
"$",
"question",
"->",
"getMode",
"(",
")",
",",
"'direction'",
"=>",
"$",
... | Converts an Ordering question into a JSON-encodable structure.
@param OrderingQuestion $question
@param array $options
@return array | [
"Converts",
"an",
"Ordering",
"question",
"into",
"a",
"JSON",
"-",
"encodable",
"structure",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L47-L69 |
40,355 | claroline/Distribution | plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php | OrderingQuestionSerializer.serializeItems | private function serializeItems(OrderingQuestion $question, array $options = [])
{
return array_map(function (OrderingItem $item) use ($options) {
$itemData = $this->contentSerializer->serialize($item, $options);
$itemData['id'] = $item->getUuid();
return $itemData;
}, $question->getItems()->toArray());
} | php | private function serializeItems(OrderingQuestion $question, array $options = [])
{
return array_map(function (OrderingItem $item) use ($options) {
$itemData = $this->contentSerializer->serialize($item, $options);
$itemData['id'] = $item->getUuid();
return $itemData;
}, $question->getItems()->toArray());
} | [
"private",
"function",
"serializeItems",
"(",
"OrderingQuestion",
"$",
"question",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"array_map",
"(",
"function",
"(",
"OrderingItem",
"$",
"item",
")",
"use",
"(",
"$",
"options",
")",
"{",
... | Serializes the question items.
@param OrderingQuestion $question
@param array $options
@return array | [
"Serializes",
"the",
"question",
"items",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L79-L87 |
40,356 | claroline/Distribution | plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php | OrderingQuestionSerializer.deserialize | public function deserialize($data, OrderingQuestion $question = null, array $options = [])
{
if (empty($question)) {
$question = new OrderingQuestion();
}
if (!empty($data['penalty']) || 0 === $data['penalty']) {
$question->setPenalty($data['penalty']);
}
$this->sipe('direction', 'setDirection', $data, $question);
$this->sipe('mode', 'setMode', $data, $question);
$this->deserializeItems($question, $data['items'], $data['solutions'], $options);
return $question;
} | php | public function deserialize($data, OrderingQuestion $question = null, array $options = [])
{
if (empty($question)) {
$question = new OrderingQuestion();
}
if (!empty($data['penalty']) || 0 === $data['penalty']) {
$question->setPenalty($data['penalty']);
}
$this->sipe('direction', 'setDirection', $data, $question);
$this->sipe('mode', 'setMode', $data, $question);
$this->deserializeItems($question, $data['items'], $data['solutions'], $options);
return $question;
} | [
"public",
"function",
"deserialize",
"(",
"$",
"data",
",",
"OrderingQuestion",
"$",
"question",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"question",
")",
")",
"{",
"$",
"question",
"=",
"new",... | Converts raw data into an Ordering question entity.
@param array $data
@param OrderingQuestion $question
@param array $options
@return OrderingQuestion | [
"Converts",
"raw",
"data",
"into",
"an",
"Ordering",
"question",
"entity",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L125-L141 |
40,357 | claroline/Distribution | plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php | OrderingQuestionSerializer.deserializeItems | private function deserializeItems(OrderingQuestion $question, array $items, array $solutions, array $options = [])
{
$itemEntities = $question->getItems()->toArray();
foreach ($items as $itemData) {
$item = null;
// Searches for an existing item entity.
foreach ($itemEntities as $entityIndex => $entityItem) {
/** @var OrderingItem $entityItem */
if ($entityItem->getUuid() === $itemData['id']) {
$item = $entityItem;
unset($itemEntities[$entityIndex]);
break;
}
}
$item = $item ?: new OrderingItem();
$item->setUuid($itemData['id']);
// Deserialize item content
$item = $this->contentSerializer->deserialize($itemData, $item, $options);
// Set item score feedback and order
foreach ($solutions as $solution) {
if ($solution['itemId'] === $itemData['id']) {
$item->setScore($solution['score']);
if (isset($solution['feedback'])) {
$item->setFeedback($solution['feedback']);
}
if (isset($solution['position'])) {
$item->setPosition($solution['position']);
}
break;
}
}
$question->addItem($item);
}
// Remaining items are no longer in the Question
foreach ($itemEntities as $itemToRemove) {
$question->removeItem($itemToRemove);
}
} | php | private function deserializeItems(OrderingQuestion $question, array $items, array $solutions, array $options = [])
{
$itemEntities = $question->getItems()->toArray();
foreach ($items as $itemData) {
$item = null;
// Searches for an existing item entity.
foreach ($itemEntities as $entityIndex => $entityItem) {
/** @var OrderingItem $entityItem */
if ($entityItem->getUuid() === $itemData['id']) {
$item = $entityItem;
unset($itemEntities[$entityIndex]);
break;
}
}
$item = $item ?: new OrderingItem();
$item->setUuid($itemData['id']);
// Deserialize item content
$item = $this->contentSerializer->deserialize($itemData, $item, $options);
// Set item score feedback and order
foreach ($solutions as $solution) {
if ($solution['itemId'] === $itemData['id']) {
$item->setScore($solution['score']);
if (isset($solution['feedback'])) {
$item->setFeedback($solution['feedback']);
}
if (isset($solution['position'])) {
$item->setPosition($solution['position']);
}
break;
}
}
$question->addItem($item);
}
// Remaining items are no longer in the Question
foreach ($itemEntities as $itemToRemove) {
$question->removeItem($itemToRemove);
}
} | [
"private",
"function",
"deserializeItems",
"(",
"OrderingQuestion",
"$",
"question",
",",
"array",
"$",
"items",
",",
"array",
"$",
"solutions",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"itemEntities",
"=",
"$",
"question",
"->",
"getIte... | Deserializes Question items.
@param OrderingQuestion $question
@param array $items
@param array $solutions
@param array $options | [
"Deserializes",
"Question",
"items",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Serializer/Item/Type/OrderingQuestionSerializer.php#L151-L197 |
40,358 | claroline/Distribution | plugin/exo/Library/Item/Definition/ContentItemDefinition.php | ContentItemDefinition.deserializeQuestion | public function deserializeQuestion(array $itemData, AbstractItem $item = null, array $options = [])
{
return $this->getItemSerializer()->deserialize($itemData, $item, $options);
} | php | public function deserializeQuestion(array $itemData, AbstractItem $item = null, array $options = [])
{
return $this->getItemSerializer()->deserialize($itemData, $item, $options);
} | [
"public",
"function",
"deserializeQuestion",
"(",
"array",
"$",
"itemData",
",",
"AbstractItem",
"$",
"item",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"getItemSerializer",
"(",
")",
"->",
"deserialize... | Deserializes content item data.
@param array $itemData
@param AbstractItem $item
@param array $options
@return AbstractItem | [
"Deserializes",
"content",
"item",
"data",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Library/Item/Definition/ContentItemDefinition.php#L121-L124 |
40,359 | claroline/Distribution | main/migration/Manager/Manager.php | Manager.generateBundleMigration | public function generateBundleMigration(Bundle $bundle, $output = null)
{
$platforms = $this->getAvailablePlatforms();
$version = date('YmdHis');
$this->log("Generating migrations classes for '{$bundle->getName()}'...");
if (!$output) {
$output = $bundle;
}
foreach ($platforms as $driverName => $platform) {
$queries = $this->generator->generateMigrationQueries($bundle, $platform);
if (count($queries[Generator::QUERIES_UP]) > 0 || count($queries[Generator::QUERIES_DOWN]) > 0) {
$this->log(" - Generating migration class for {$driverName} driver...");
$this->writer->writeMigrationClass($output, $driverName, $version, $queries);
} else {
$this->log('Nothing to generate: database and mapping are synced');
break;
}
}
} | php | public function generateBundleMigration(Bundle $bundle, $output = null)
{
$platforms = $this->getAvailablePlatforms();
$version = date('YmdHis');
$this->log("Generating migrations classes for '{$bundle->getName()}'...");
if (!$output) {
$output = $bundle;
}
foreach ($platforms as $driverName => $platform) {
$queries = $this->generator->generateMigrationQueries($bundle, $platform);
if (count($queries[Generator::QUERIES_UP]) > 0 || count($queries[Generator::QUERIES_DOWN]) > 0) {
$this->log(" - Generating migration class for {$driverName} driver...");
$this->writer->writeMigrationClass($output, $driverName, $version, $queries);
} else {
$this->log('Nothing to generate: database and mapping are synced');
break;
}
}
} | [
"public",
"function",
"generateBundleMigration",
"(",
"Bundle",
"$",
"bundle",
",",
"$",
"output",
"=",
"null",
")",
"{",
"$",
"platforms",
"=",
"$",
"this",
"->",
"getAvailablePlatforms",
"(",
")",
";",
"$",
"version",
"=",
"date",
"(",
"'YmdHis'",
")",
... | Generates bundle migrations classes for all the available driver platforms.
@param \Symfony\Component\HttpKernel\Bundle\Bundle $bundle
@param \Symfony\Component\HttpKernel\Bundle\Bundle $output | [
"Generates",
"bundle",
"migrations",
"classes",
"for",
"all",
"the",
"available",
"driver",
"platforms",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/migration/Manager/Manager.php#L55-L75 |
40,360 | claroline/Distribution | plugin/exo/Manager/ExerciseManager.php | ExerciseManager.update | public function update(Exercise $exercise, array $data)
{
// Validate received data
$errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);
if (count($errors) > 0) {
throw new InvalidDataException('Exercise is not valid', $errors);
}
// Start flush suite to avoid persisting and flushing tags before quiz
$this->om->startFlushSuite();
// Update Exercise with new data
$this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]);
// Save to DB
$this->om->persist($exercise);
$this->om->endFlushSuite();
// Invalidate unfinished papers
$this->repository->invalidatePapers($exercise);
// Log exercise update
$event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise));
$this->eventDispatcher->dispatch('log', $event);
return $exercise;
} | php | public function update(Exercise $exercise, array $data)
{
// Validate received data
$errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);
if (count($errors) > 0) {
throw new InvalidDataException('Exercise is not valid', $errors);
}
// Start flush suite to avoid persisting and flushing tags before quiz
$this->om->startFlushSuite();
// Update Exercise with new data
$this->serializer->deserialize($data, $exercise, [Transfer::PERSIST_TAG]);
// Save to DB
$this->om->persist($exercise);
$this->om->endFlushSuite();
// Invalidate unfinished papers
$this->repository->invalidatePapers($exercise);
// Log exercise update
$event = new LogExerciseUpdateEvent($exercise, (array) $this->serializer->serialize($exercise));
$this->eventDispatcher->dispatch('log', $event);
return $exercise;
} | [
"public",
"function",
"update",
"(",
"Exercise",
"$",
"exercise",
",",
"array",
"$",
"data",
")",
"{",
"// Validate received data",
"$",
"errors",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"data",
",",
"[",
"Validation",
"::",
"REQUI... | Validates and updates an Exercise entity with raw data.
@param Exercise $exercise
@param array $data
@return Exercise
@throws InvalidDataException | [
"Validates",
"and",
"updates",
"an",
"Exercise",
"entity",
"with",
"raw",
"data",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L132-L157 |
40,361 | claroline/Distribution | plugin/exo/Manager/ExerciseManager.php | ExerciseManager.copy | public function copy(Exercise $exercise)
{
// Serialize quiz entities
$exerciseData = $this->serializer->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS]);
// Populate new entities with original data
$newExercise = $this->createCopy($exerciseData, null);
// Save copy to db
$this->om->flush();
return $newExercise;
} | php | public function copy(Exercise $exercise)
{
// Serialize quiz entities
$exerciseData = $this->serializer->serialize($exercise, [Transfer::INCLUDE_SOLUTIONS]);
// Populate new entities with original data
$newExercise = $this->createCopy($exerciseData, null);
// Save copy to db
$this->om->flush();
return $newExercise;
} | [
"public",
"function",
"copy",
"(",
"Exercise",
"$",
"exercise",
")",
"{",
"// Serialize quiz entities",
"$",
"exerciseData",
"=",
"$",
"this",
"->",
"serializer",
"->",
"serialize",
"(",
"$",
"exercise",
",",
"[",
"Transfer",
"::",
"INCLUDE_SOLUTIONS",
"]",
")... | Copies an Exercise resource.
@param Exercise $exercise
@return Exercise | [
"Copies",
"an",
"Exercise",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L179-L191 |
40,362 | claroline/Distribution | plugin/exo/Manager/ExerciseManager.php | ExerciseManager.isDeletable | public function isDeletable(Exercise $exercise)
{
return !$exercise->getResourceNode()->isPublished() || 0 === $this->paperManager->countExercisePapers($exercise);
} | php | public function isDeletable(Exercise $exercise)
{
return !$exercise->getResourceNode()->isPublished() || 0 === $this->paperManager->countExercisePapers($exercise);
} | [
"public",
"function",
"isDeletable",
"(",
"Exercise",
"$",
"exercise",
")",
"{",
"return",
"!",
"$",
"exercise",
"->",
"getResourceNode",
"(",
")",
"->",
"isPublished",
"(",
")",
"||",
"0",
"===",
"$",
"this",
"->",
"paperManager",
"->",
"countExercisePapers... | Checks if an Exercise can be deleted.
The exercise needs to be unpublished or have no paper to be safely removed.
@param Exercise $exercise
@return bool | [
"Checks",
"if",
"an",
"Exercise",
"can",
"be",
"deleted",
".",
"The",
"exercise",
"needs",
"to",
"be",
"unpublished",
"or",
"have",
"no",
"paper",
"to",
"be",
"safely",
"removed",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/ExerciseManager.php#L201-L204 |
40,363 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.update | public function update(Item $question, array $data)
{
// Validate received data
$errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);
if (count($errors) > 0) {
throw new InvalidDataException('Question is not valid', $errors);
}
// Update Item with new data
$this->serializer->deserialize($data, $question, [Transfer::PERSIST_TAG]);
// Save to DB
$this->om->persist($question);
$this->om->flush();
return $question;
} | php | public function update(Item $question, array $data)
{
// Validate received data
$errors = $this->validator->validate($data, [Validation::REQUIRE_SOLUTIONS]);
if (count($errors) > 0) {
throw new InvalidDataException('Question is not valid', $errors);
}
// Update Item with new data
$this->serializer->deserialize($data, $question, [Transfer::PERSIST_TAG]);
// Save to DB
$this->om->persist($question);
$this->om->flush();
return $question;
} | [
"public",
"function",
"update",
"(",
"Item",
"$",
"question",
",",
"array",
"$",
"data",
")",
"{",
"// Validate received data",
"$",
"errors",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"data",
",",
"[",
"Validation",
"::",
"REQUIRE_S... | Validates and updates a Item entity with raw data.
@param Item $question
@param array $data
@return Item
@throws InvalidDataException | [
"Validates",
"and",
"updates",
"a",
"Item",
"entity",
"with",
"raw",
"data",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L148-L164 |
40,364 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.deserialize | public function deserialize(array $data, Item $item = null, array $options = [])
{
return $this->serializer->deserialize($data, $item, $options);
} | php | public function deserialize(array $data, Item $item = null, array $options = [])
{
return $this->serializer->deserialize($data, $item, $options);
} | [
"public",
"function",
"deserialize",
"(",
"array",
"$",
"data",
",",
"Item",
"$",
"item",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"data",
",",
"$",
... | Deserializes a question.
@param array $data
@param Item $item
@param array $options
@return Item | [
"Deserializes",
"a",
"question",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L188-L191 |
40,365 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.delete | public function delete(Item $item, $user, $skipErrors = false)
{
if (!$this->canEdit($item, $user)) {
if (!$skipErrors) {
throw new \Exception('You can not delete this item.');
} else {
return;
}
}
$this->om->remove($item);
$this->om->flush();
} | php | public function delete(Item $item, $user, $skipErrors = false)
{
if (!$this->canEdit($item, $user)) {
if (!$skipErrors) {
throw new \Exception('You can not delete this item.');
} else {
return;
}
}
$this->om->remove($item);
$this->om->flush();
} | [
"public",
"function",
"delete",
"(",
"Item",
"$",
"item",
",",
"$",
"user",
",",
"$",
"skipErrors",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"canEdit",
"(",
"$",
"item",
",",
"$",
"user",
")",
")",
"{",
"if",
"(",
"!",
"$",
... | Deletes an Item.
It's only possible if the Item is not used in an Exercise.
@param Item $item
@param $user
@param bool $skipErrors
@throws \Exception | [
"Deletes",
"an",
"Item",
".",
"It",
"s",
"only",
"possible",
"if",
"the",
"Item",
"is",
"not",
"used",
"in",
"an",
"Exercise",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L203-L215 |
40,366 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.calculateScore | public function calculateScore(Item $question, Answer $answer)
{
// Let the question correct the answer
$definition = $this->itemDefinitions->get($question->getMimeType());
/** @var AnswerableItemDefinitionInterface $definition */
$corrected = $definition->correctAnswer($question->getInteraction(), json_decode($answer->getData(), true));
if (!$corrected instanceof CorrectedAnswer) {
$corrected = new CorrectedAnswer();
}
// Add hints
foreach ($answer->getUsedHints() as $hintId) {
// Get hint definition from question data
$hint = null;
foreach ($question->getHints() as $questionHint) {
if ($hintId === $questionHint->getUuid()) {
$hint = $questionHint;
break;
}
}
if ($hint) {
$corrected->addPenalty($hint);
}
}
return $this->scoreManager->calculate(json_decode($question->getScoreRule(), true), $corrected);
} | php | public function calculateScore(Item $question, Answer $answer)
{
// Let the question correct the answer
$definition = $this->itemDefinitions->get($question->getMimeType());
/** @var AnswerableItemDefinitionInterface $definition */
$corrected = $definition->correctAnswer($question->getInteraction(), json_decode($answer->getData(), true));
if (!$corrected instanceof CorrectedAnswer) {
$corrected = new CorrectedAnswer();
}
// Add hints
foreach ($answer->getUsedHints() as $hintId) {
// Get hint definition from question data
$hint = null;
foreach ($question->getHints() as $questionHint) {
if ($hintId === $questionHint->getUuid()) {
$hint = $questionHint;
break;
}
}
if ($hint) {
$corrected->addPenalty($hint);
}
}
return $this->scoreManager->calculate(json_decode($question->getScoreRule(), true), $corrected);
} | [
"public",
"function",
"calculateScore",
"(",
"Item",
"$",
"question",
",",
"Answer",
"$",
"answer",
")",
"{",
"// Let the question correct the answer",
"$",
"definition",
"=",
"$",
"this",
"->",
"itemDefinitions",
"->",
"get",
"(",
"$",
"question",
"->",
"getMim... | Calculates the score of an answer to a question.
@param Item $question
@param Answer $answer
@return float | [
"Calculates",
"the",
"score",
"of",
"an",
"answer",
"to",
"a",
"question",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L243-L269 |
40,367 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.getItemScores | public function getItemScores(Exercise $exercise, Item $question)
{
$definition = $this->itemDefinitions->get($question->getMimeType());
if ($definition instanceof AnswerableItemDefinitionInterface) {
return array_map(function ($answer) use ($question, $definition) {
$score = $this->calculateScore($question, $answer);
// get total available for the question
$expected = $definition->expectAnswer($question->getInteraction());
$total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
// report the score on 100
$score = $total > 0 ? (100 * $score) / $total : 0;
return $score;
}, $this->answerRepository->findByQuestion($question, $exercise));
}
return [];
} | php | public function getItemScores(Exercise $exercise, Item $question)
{
$definition = $this->itemDefinitions->get($question->getMimeType());
if ($definition instanceof AnswerableItemDefinitionInterface) {
return array_map(function ($answer) use ($question, $definition) {
$score = $this->calculateScore($question, $answer);
// get total available for the question
$expected = $definition->expectAnswer($question->getInteraction());
$total = $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
// report the score on 100
$score = $total > 0 ? (100 * $score) / $total : 0;
return $score;
}, $this->answerRepository->findByQuestion($question, $exercise));
}
return [];
} | [
"public",
"function",
"getItemScores",
"(",
"Exercise",
"$",
"exercise",
",",
"Item",
"$",
"question",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"itemDefinitions",
"->",
"get",
"(",
"$",
"question",
"->",
"getMimeType",
"(",
")",
")",
";",
"if... | Get all scores for an Answerable Item.
@param Exercise $exercise
@param Item $question
@return array | [
"Get",
"all",
"scores",
"for",
"an",
"Answerable",
"Item",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L279-L297 |
40,368 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.calculateTotal | public function calculateTotal(array $questionData)
{
// Get entities for score calculation
$question = $this->serializer->deserialize($questionData, new Item());
/** @var AnswerableItemDefinitionInterface $definition */
$definition = $this->itemDefinitions->get($question->getMimeType());
// Get the expected answer for the question
$expected = $definition->expectAnswer($question->getInteraction());
return $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
} | php | public function calculateTotal(array $questionData)
{
// Get entities for score calculation
$question = $this->serializer->deserialize($questionData, new Item());
/** @var AnswerableItemDefinitionInterface $definition */
$definition = $this->itemDefinitions->get($question->getMimeType());
// Get the expected answer for the question
$expected = $definition->expectAnswer($question->getInteraction());
return $this->scoreManager->calculateTotal(json_decode($question->getScoreRule(), true), $expected, $question->getInteraction());
} | [
"public",
"function",
"calculateTotal",
"(",
"array",
"$",
"questionData",
")",
"{",
"// Get entities for score calculation",
"$",
"question",
"=",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"questionData",
",",
"new",
"Item",
"(",
")",
")",... | Calculates the total score of a question.
@param array $questionData
@return float | [
"Calculates",
"the",
"total",
"score",
"of",
"a",
"question",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L306-L318 |
40,369 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.getStatistics | public function getStatistics(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
{
$questionStats = [];
// We load all the answers for the question (we need to get the entities as the response in DB are not processable as is)
$answers = $this->answerRepository->findByQuestion($question, $exercise, $finishedPapersOnly);
// Number of Users that have seen the question
$questionStats['seen'] = count($answers);
// Grab answer data to pass it decoded to the question type
// it doesn't need to know the whole Answer object
$answersData = [];
// get corrected answers for the Item in order to compute question success percentage
$correctedAnswers = [];
// Number of Users that have answered the question (no blank answer)
$questionStats['answered'] = 0;
if (!empty($answers)) {
// Let the handler of the question type parse and compile the data
$definition = $this->itemDefinitions->get($question->getMimeType());
for ($i = 0; $i < $questionStats['seen']; ++$i) {
$answer = $answers[$i];
if (!empty($answer->getData())) {
++$questionStats['answered'];
$answersData[] = json_decode($answer->getData(), true);
}
// for each answer get corresponding correction
if ($definition instanceof AnswerableItemDefinitionInterface && isset($answersData[$i])) {
$corrected = $definition->correctAnswer($question->getInteraction(), $answersData[$i]);
$correctedAnswers[] = $corrected;
}
}
// Let the handler of the question type parse and compile the data
if ($definition instanceof AnswerableItemDefinitionInterface) {
$questionStats['solutions'] = $definition->getStatistics($question->getInteraction(), $answersData, $questionStats['seen']);
}
}
// get the number of good answers among all
$nbGoodAnswers = 0;
foreach ($correctedAnswers as $corrected) {
if ($corrected instanceof CorrectedAnswer && 0 === count($corrected->getMissing()) && 0 === count($corrected->getUnexpected())) {
++$nbGoodAnswers;
}
}
// compute question success percentage
$questionStats['successPercent'] = $questionStats['answered'] > 0 ? (100 * $nbGoodAnswers) / $questionStats['answered'] : 0;
return $questionStats;
} | php | public function getStatistics(Item $question, Exercise $exercise = null, $finishedPapersOnly = false)
{
$questionStats = [];
// We load all the answers for the question (we need to get the entities as the response in DB are not processable as is)
$answers = $this->answerRepository->findByQuestion($question, $exercise, $finishedPapersOnly);
// Number of Users that have seen the question
$questionStats['seen'] = count($answers);
// Grab answer data to pass it decoded to the question type
// it doesn't need to know the whole Answer object
$answersData = [];
// get corrected answers for the Item in order to compute question success percentage
$correctedAnswers = [];
// Number of Users that have answered the question (no blank answer)
$questionStats['answered'] = 0;
if (!empty($answers)) {
// Let the handler of the question type parse and compile the data
$definition = $this->itemDefinitions->get($question->getMimeType());
for ($i = 0; $i < $questionStats['seen']; ++$i) {
$answer = $answers[$i];
if (!empty($answer->getData())) {
++$questionStats['answered'];
$answersData[] = json_decode($answer->getData(), true);
}
// for each answer get corresponding correction
if ($definition instanceof AnswerableItemDefinitionInterface && isset($answersData[$i])) {
$corrected = $definition->correctAnswer($question->getInteraction(), $answersData[$i]);
$correctedAnswers[] = $corrected;
}
}
// Let the handler of the question type parse and compile the data
if ($definition instanceof AnswerableItemDefinitionInterface) {
$questionStats['solutions'] = $definition->getStatistics($question->getInteraction(), $answersData, $questionStats['seen']);
}
}
// get the number of good answers among all
$nbGoodAnswers = 0;
foreach ($correctedAnswers as $corrected) {
if ($corrected instanceof CorrectedAnswer && 0 === count($corrected->getMissing()) && 0 === count($corrected->getUnexpected())) {
++$nbGoodAnswers;
}
}
// compute question success percentage
$questionStats['successPercent'] = $questionStats['answered'] > 0 ? (100 * $nbGoodAnswers) / $questionStats['answered'] : 0;
return $questionStats;
} | [
"public",
"function",
"getStatistics",
"(",
"Item",
"$",
"question",
",",
"Exercise",
"$",
"exercise",
"=",
"null",
",",
"$",
"finishedPapersOnly",
"=",
"false",
")",
"{",
"$",
"questionStats",
"=",
"[",
"]",
";",
"// We load all the answers for the question (we n... | Get question statistics inside an Exercise.
@param Item $question
@param Exercise $exercise
@param bool $finishedPapersOnly
@return array | [
"Get",
"question",
"statistics",
"inside",
"an",
"Exercise",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L329-L385 |
40,370 | claroline/Distribution | plugin/exo/Manager/Item/ItemManager.php | ItemManager.refreshIdentifiers | public function refreshIdentifiers(Item $item)
{
// refresh self id
$item->refreshUuid();
// refresh objects ids
foreach ($item->getObjects() as $object) {
$object->refreshUuid();
}
// refresh hints ids
foreach ($item->getHints() as $hint) {
$hint->refreshUuid();
}
if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item->getMimeType())) {
// it's a question
$definition = $this->itemDefinitions->get($item->getMimeType());
} else {
// it's a content
$definition = $this->itemDefinitions->get(ItemType::CONTENT);
}
$definition->refreshIdentifiers($item->getInteraction());
} | php | public function refreshIdentifiers(Item $item)
{
// refresh self id
$item->refreshUuid();
// refresh objects ids
foreach ($item->getObjects() as $object) {
$object->refreshUuid();
}
// refresh hints ids
foreach ($item->getHints() as $hint) {
$hint->refreshUuid();
}
if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $item->getMimeType())) {
// it's a question
$definition = $this->itemDefinitions->get($item->getMimeType());
} else {
// it's a content
$definition = $this->itemDefinitions->get(ItemType::CONTENT);
}
$definition->refreshIdentifiers($item->getInteraction());
} | [
"public",
"function",
"refreshIdentifiers",
"(",
"Item",
"$",
"item",
")",
"{",
"// refresh self id",
"$",
"item",
"->",
"refreshUuid",
"(",
")",
";",
"// refresh objects ids",
"foreach",
"(",
"$",
"item",
"->",
"getObjects",
"(",
")",
"as",
"$",
"object",
"... | Generates new UUIDs for the entities of an item.
@param Item $item | [
"Generates",
"new",
"UUIDs",
"for",
"the",
"entities",
"of",
"an",
"item",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/exo/Manager/Item/ItemManager.php#L392-L416 |
40,371 | claroline/Distribution | plugin/path/Manager/PathManager.php | PathManager.import | public function import($structure, array $data, array $resourcesCreated = [])
{
// Create a new Path object which will be populated with exported data
$path = new Path();
$pathData = $data['data']['path'];
// Populate Path properties
$path->setDescription($pathData['description']);
$path->setOpenSummary($pathData['summaryDisplayed']);
$path->setManualProgressionAllowed($pathData['manualProgressionAllowed']);
// Create steps
$stepData = $data['data']['steps'];
if (!empty($stepData)) {
$createdSteps = [];
foreach ($stepData as $step) {
$createdSteps = $this->importStep($path, $step, $resourcesCreated, $createdSteps);
}
}
// Inject empty structure into path (will be replaced by a version with updated IDs later in the import process)
$path->setStructure($structure);
return $path;
} | php | public function import($structure, array $data, array $resourcesCreated = [])
{
// Create a new Path object which will be populated with exported data
$path = new Path();
$pathData = $data['data']['path'];
// Populate Path properties
$path->setDescription($pathData['description']);
$path->setOpenSummary($pathData['summaryDisplayed']);
$path->setManualProgressionAllowed($pathData['manualProgressionAllowed']);
// Create steps
$stepData = $data['data']['steps'];
if (!empty($stepData)) {
$createdSteps = [];
foreach ($stepData as $step) {
$createdSteps = $this->importStep($path, $step, $resourcesCreated, $createdSteps);
}
}
// Inject empty structure into path (will be replaced by a version with updated IDs later in the import process)
$path->setStructure($structure);
return $path;
} | [
"public",
"function",
"import",
"(",
"$",
"structure",
",",
"array",
"$",
"data",
",",
"array",
"$",
"resourcesCreated",
"=",
"[",
"]",
")",
"{",
"// Create a new Path object which will be populated with exported data",
"$",
"path",
"=",
"new",
"Path",
"(",
")",
... | Import a Path into the Platform.
@param string $structure
@param array $data
@param array $resourcesCreated
@return Path | [
"Import",
"a",
"Path",
"into",
"the",
"Platform",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L84-L109 |
40,372 | claroline/Distribution | plugin/path/Manager/PathManager.php | PathManager.exportStep | public function exportStep(Step $step)
{
$parent = $step->getParent();
$activity = $step->getActivity();
$data = [
'uid' => $step->getId(),
'parent' => !empty($parent) ? $parent->getId() : null,
'activityId' => !empty($activity) ? $activity->getId() : null,
'activityNodeId' => !empty($activity) ? $activity->getResourceNode()->getId() : null,
'order' => $step->getOrder(),
];
return $data;
} | php | public function exportStep(Step $step)
{
$parent = $step->getParent();
$activity = $step->getActivity();
$data = [
'uid' => $step->getId(),
'parent' => !empty($parent) ? $parent->getId() : null,
'activityId' => !empty($activity) ? $activity->getId() : null,
'activityNodeId' => !empty($activity) ? $activity->getResourceNode()->getId() : null,
'order' => $step->getOrder(),
];
return $data;
} | [
"public",
"function",
"exportStep",
"(",
"Step",
"$",
"step",
")",
"{",
"$",
"parent",
"=",
"$",
"step",
"->",
"getParent",
"(",
")",
";",
"$",
"activity",
"=",
"$",
"step",
"->",
"getActivity",
"(",
")",
";",
"$",
"data",
"=",
"[",
"'uid'",
"=>",
... | Transform Step data to export it.
@param Step $step
@return array | [
"Transform",
"Step",
"data",
"to",
"export",
"it",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L118-L132 |
40,373 | claroline/Distribution | plugin/path/Manager/PathManager.php | PathManager.importStep | public function importStep(Path $path, array $data, array $createdResources = [], array $createdSteps = [])
{
$step = new Step();
$step->setPath($path);
if (!empty($data['parent'])) {
$step->setParent($createdSteps[$data['parent']]);
}
$step->setOrder($data['order']);
$step->setActivityHeight(0);
// Link Step to its Activity
if (!empty($data['activityNodeId']) && !empty($createdResources[$data['activityNodeId']])) {
// Step has an Activity
$step->setActivity($createdResources[$data['activityNodeId']]);
}
$createdSteps[$data['uid']] = $step;
$this->om->persist($step);
return $createdSteps;
} | php | public function importStep(Path $path, array $data, array $createdResources = [], array $createdSteps = [])
{
$step = new Step();
$step->setPath($path);
if (!empty($data['parent'])) {
$step->setParent($createdSteps[$data['parent']]);
}
$step->setOrder($data['order']);
$step->setActivityHeight(0);
// Link Step to its Activity
if (!empty($data['activityNodeId']) && !empty($createdResources[$data['activityNodeId']])) {
// Step has an Activity
$step->setActivity($createdResources[$data['activityNodeId']]);
}
$createdSteps[$data['uid']] = $step;
$this->om->persist($step);
return $createdSteps;
} | [
"public",
"function",
"importStep",
"(",
"Path",
"$",
"path",
",",
"array",
"$",
"data",
",",
"array",
"$",
"createdResources",
"=",
"[",
"]",
",",
"array",
"$",
"createdSteps",
"=",
"[",
"]",
")",
"{",
"$",
"step",
"=",
"new",
"Step",
"(",
")",
";... | Import a Step.
@param Path $path
@param array $data
@param array $createdResources
@param array $createdSteps
@return array | [
"Import",
"a",
"Step",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/path/Manager/PathManager.php#L144-L167 |
40,374 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.create | public function create(Result $result)
{
$this->om->persist($result);
$this->om->flush();
return $result;
} | php | public function create(Result $result)
{
$this->om->persist($result);
$this->om->flush();
return $result;
} | [
"public",
"function",
"create",
"(",
"Result",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Creates a result resource.
@param Result $result
@return Result | [
"Creates",
"a",
"result",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L78-L84 |
40,375 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.delete | public function delete(Result $result)
{
$this->om->remove($result);
$this->om->flush();
} | php | public function delete(Result $result)
{
$this->om->remove($result);
$this->om->flush();
} | [
"public",
"function",
"delete",
"(",
"Result",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"remove",
"(",
"$",
"result",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"}"
] | Deletes a result resource.
@param Result $result | [
"Deletes",
"a",
"result",
"resource",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L91-L95 |
40,376 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.getMarks | public function getMarks(Result $result, User $user, $canEdit)
{
$repo = $this->om->getRepository('ClarolineResultBundle:Mark');
return $canEdit ?
$repo->findByResult($result) :
$repo->findByResultAndUser($result, $user);
} | php | public function getMarks(Result $result, User $user, $canEdit)
{
$repo = $this->om->getRepository('ClarolineResultBundle:Mark');
return $canEdit ?
$repo->findByResult($result) :
$repo->findByResultAndUser($result, $user);
} | [
"public",
"function",
"getMarks",
"(",
"Result",
"$",
"result",
",",
"User",
"$",
"user",
",",
"$",
"canEdit",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"om",
"->",
"getRepository",
"(",
"'ClarolineResultBundle:Mark'",
")",
";",
"return",
"$",
"canE... | Returns an array representation of the marks associated with a
result. If the user passed in has the permission to edit the result,
all the marks are returned, otherwise only his mark is returned.
@param Result $result
@param User $user
@param bool $canEdit
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"marks",
"associated",
"with",
"a",
"result",
".",
"If",
"the",
"user",
"passed",
"in",
"has",
"the",
"permission",
"to",
"edit",
"the",
"result",
"all",
"the",
"marks",
"are",
"returned",
"otherwise",... | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L149-L156 |
40,377 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.getUsers | public function getUsers(Result $result, $canEdit)
{
if (!$canEdit) {
return [];
}
$repo = $this->om->getRepository('ClarolineCoreBundle:User');
$roles = $result->getResourceNode()->getWorkspace()->getRoles()->toArray();
$users = $repo->findUsersByRolesIncludingGroups($roles);
return array_map(function ($user) {
return [
'id' => $user->getId(),
'name' => "{$user->getFirstName()} {$user->getLastName()}",
];
}, $users);
} | php | public function getUsers(Result $result, $canEdit)
{
if (!$canEdit) {
return [];
}
$repo = $this->om->getRepository('ClarolineCoreBundle:User');
$roles = $result->getResourceNode()->getWorkspace()->getRoles()->toArray();
$users = $repo->findUsersByRolesIncludingGroups($roles);
return array_map(function ($user) {
return [
'id' => $user->getId(),
'name' => "{$user->getFirstName()} {$user->getLastName()}",
];
}, $users);
} | [
"public",
"function",
"getUsers",
"(",
"Result",
"$",
"result",
",",
"$",
"canEdit",
")",
"{",
"if",
"(",
"!",
"$",
"canEdit",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"repo",
"=",
"$",
"this",
"->",
"om",
"->",
"getRepository",
"(",
"'Clarolin... | Returns an array representation of the members of the workspace
in which the given result lives. If the edit flag is set to false,
an empty array is returned.
@param Result $result
@param bool $canEdit
@return array | [
"Returns",
"an",
"array",
"representation",
"of",
"the",
"members",
"of",
"the",
"workspace",
"in",
"which",
"the",
"given",
"result",
"lives",
".",
"If",
"the",
"edit",
"flag",
"is",
"set",
"to",
"false",
"an",
"empty",
"array",
"is",
"returned",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L168-L184 |
40,378 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.isValidMark | public function isValidMark(Result $result, $mark)
{
// normalize french decimal marks
$mark = str_replace(',', '.', $mark);
return is_numeric($mark) && (float) $mark <= $result->getTotal();
} | php | public function isValidMark(Result $result, $mark)
{
// normalize french decimal marks
$mark = str_replace(',', '.', $mark);
return is_numeric($mark) && (float) $mark <= $result->getTotal();
} | [
"public",
"function",
"isValidMark",
"(",
"Result",
"$",
"result",
",",
"$",
"mark",
")",
"{",
"// normalize french decimal marks",
"$",
"mark",
"=",
"str_replace",
"(",
"','",
",",
"'.'",
",",
"$",
"mark",
")",
";",
"return",
"is_numeric",
"(",
"$",
"mark... | Returns whether a mark is valid.
@param Result $result
@param mixed $mark
@return bool | [
"Returns",
"whether",
"a",
"mark",
"is",
"valid",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L194-L200 |
40,379 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.createMark | public function createMark(Result $result, User $user, $mark)
{
$mark = new Mark($result, $user, $mark);
$this->om->persist($mark);
$this->om->flush();
$newMarkEvent = new LogResultsNewMarkEvent($mark);
$this->dispatcher->dispatch('log', $newMarkEvent);
return $mark;
} | php | public function createMark(Result $result, User $user, $mark)
{
$mark = new Mark($result, $user, $mark);
$this->om->persist($mark);
$this->om->flush();
$newMarkEvent = new LogResultsNewMarkEvent($mark);
$this->dispatcher->dispatch('log', $newMarkEvent);
return $mark;
} | [
"public",
"function",
"createMark",
"(",
"Result",
"$",
"result",
",",
"User",
"$",
"user",
",",
"$",
"mark",
")",
"{",
"$",
"mark",
"=",
"new",
"Mark",
"(",
"$",
"result",
",",
"$",
"user",
",",
"$",
"mark",
")",
";",
"$",
"this",
"->",
"om",
... | Creates a new mark.
@param Result $result
@param User $user
@param string $mark
@return mark | [
"Creates",
"a",
"new",
"mark",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L211-L221 |
40,380 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.deleteMark | public function deleteMark(Mark $mark)
{
$this->om->remove($mark);
$this->om->flush();
// First of all update older mark events so as result would be 0
$this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), 0);
// Then delete mark
$deleteMarkEvent = new LogResultsDeleteMarkEvent($mark);
$this->dispatcher->dispatch('log', $deleteMarkEvent);
} | php | public function deleteMark(Mark $mark)
{
$this->om->remove($mark);
$this->om->flush();
// First of all update older mark events so as result would be 0
$this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), 0);
// Then delete mark
$deleteMarkEvent = new LogResultsDeleteMarkEvent($mark);
$this->dispatcher->dispatch('log', $deleteMarkEvent);
} | [
"public",
"function",
"deleteMark",
"(",
"Mark",
"$",
"mark",
")",
"{",
"$",
"this",
"->",
"om",
"->",
"remove",
"(",
"$",
"mark",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
")",
";",
"// First of all update older mark events so as result would b... | Deletes a mark.
@param Mark $mark | [
"Deletes",
"a",
"mark",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L228-L237 |
40,381 | claroline/Distribution | plugin/result/Manager/ResultManager.php | ResultManager.updateMark | public function updateMark(Mark $mark, $value)
{
$oldMark = $mark->getValue();
$mark->setValue($value);
$this->om->flush();
// First of all update older mark events so as result would be new value
$this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), $value);
// Then create new mark event to log update
$newMarkEvent = new LogResultsNewMarkEvent($mark, $oldMark);
$this->dispatcher->dispatch('log', $newMarkEvent);
} | php | public function updateMark(Mark $mark, $value)
{
$oldMark = $mark->getValue();
$mark->setValue($value);
$this->om->flush();
// First of all update older mark events so as result would be new value
$this->updateNewMarkEventResult($mark->getUser(), $mark->getId(), $value);
// Then create new mark event to log update
$newMarkEvent = new LogResultsNewMarkEvent($mark, $oldMark);
$this->dispatcher->dispatch('log', $newMarkEvent);
} | [
"public",
"function",
"updateMark",
"(",
"Mark",
"$",
"mark",
",",
"$",
"value",
")",
"{",
"$",
"oldMark",
"=",
"$",
"mark",
"->",
"getValue",
"(",
")",
";",
"$",
"mark",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"om",
"->... | Updates a mark.
@param Mark $mark
@param string $value | [
"Updates",
"a",
"mark",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/plugin/result/Manager/ResultManager.php#L245-L255 |
40,382 | claroline/Distribution | main/core/Security/Voter/FacetVoter.php | FacetVoter.vote | public function vote(TokenInterface $token, $object, array $attributes)
{
if ($object instanceof FieldFacetCollection) {
//fields right management is done at the Panel level
return $this->fieldFacetVote($object, $token, strtolower($attributes[0]));
}
if ($object instanceof PanelFacet) {
return $this->panelFacetVote($object, $token, strtolower($attributes[0]));
} elseif ($object instanceof Facet) {
//no implementation yet
}
return VoterInterface::ACCESS_ABSTAIN;
} | php | public function vote(TokenInterface $token, $object, array $attributes)
{
if ($object instanceof FieldFacetCollection) {
//fields right management is done at the Panel level
return $this->fieldFacetVote($object, $token, strtolower($attributes[0]));
}
if ($object instanceof PanelFacet) {
return $this->panelFacetVote($object, $token, strtolower($attributes[0]));
} elseif ($object instanceof Facet) {
//no implementation yet
}
return VoterInterface::ACCESS_ABSTAIN;
} | [
"public",
"function",
"vote",
"(",
"TokenInterface",
"$",
"token",
",",
"$",
"object",
",",
"array",
"$",
"attributes",
")",
"{",
"if",
"(",
"$",
"object",
"instanceof",
"FieldFacetCollection",
")",
"{",
"//fields right management is done at the Panel level",
"retur... | Attributes can either be "open" or "edit".
@param TokenInterface $token
@param $object
@param array $attributes | [
"Attributes",
"can",
"either",
"be",
"open",
"or",
"edit",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Security/Voter/FacetVoter.php#L55-L69 |
40,383 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.homeAction | public function homeAction($type)
{
$typeEntity = $this->manager->getType($type);
$homeType = $this->config->getParameter('home_redirection_type');
switch ($homeType) {
case 'url':
$url = $this->config->getParameter('home_redirection_url');
if ($url) {
return new RedirectResponse($url);
}
break;
case 'login':
return new RedirectResponse($this->router->generate('claro_security_login'));
case 'new':
return new RedirectResponse($this->router->generate('apiv2_home'));
}
if (is_null($typeEntity)) {
throw new NotFoundHttpException('Page not found');
} else {
$typeTemplate = $typeEntity->getTemplate();
$template = is_null($typeTemplate) ?
'ClarolineCoreBundle:home:home.html.twig' :
'ClarolineCoreBundle:home\templates\custom:'.$typeTemplate;
$response = $this->render(
$template,
[
'type' => $type,
'region' => $this->renderRegions($this->manager->getRegionContents()),
'content' => $this->typeAction($type)->getContent(),
]
);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
$response->headers->addCacheControlDirective('expires', '-1');
return $response;
}
} | php | public function homeAction($type)
{
$typeEntity = $this->manager->getType($type);
$homeType = $this->config->getParameter('home_redirection_type');
switch ($homeType) {
case 'url':
$url = $this->config->getParameter('home_redirection_url');
if ($url) {
return new RedirectResponse($url);
}
break;
case 'login':
return new RedirectResponse($this->router->generate('claro_security_login'));
case 'new':
return new RedirectResponse($this->router->generate('apiv2_home'));
}
if (is_null($typeEntity)) {
throw new NotFoundHttpException('Page not found');
} else {
$typeTemplate = $typeEntity->getTemplate();
$template = is_null($typeTemplate) ?
'ClarolineCoreBundle:home:home.html.twig' :
'ClarolineCoreBundle:home\templates\custom:'.$typeTemplate;
$response = $this->render(
$template,
[
'type' => $type,
'region' => $this->renderRegions($this->manager->getRegionContents()),
'content' => $this->typeAction($type)->getContent(),
]
);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
$response->headers->addCacheControlDirective('expires', '-1');
return $response;
}
} | [
"public",
"function",
"homeAction",
"(",
"$",
"type",
")",
"{",
"$",
"typeEntity",
"=",
"$",
"this",
"->",
"manager",
"->",
"getType",
"(",
"$",
"type",
")",
";",
"$",
"homeType",
"=",
"$",
"this",
"->",
"config",
"->",
"getParameter",
"(",
"'home_redi... | Render the home page of the platform.
@Route("/type/{type}", name="claro_get_content_by_type", options = {"expose" = true})
@Route("/", name="claro_index", defaults={"type" = "home"}, options = {"expose" = true})
@return Response | [
"Render",
"the",
"home",
"page",
"of",
"the",
"platform",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L130-L173 |
40,384 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.typeAction | public function typeAction($type, $father = null, $region = null)
{
$layout = $this->manager->contentLayout($type, $father, $region, $this->canEdit());
if ($layout) {
return $this->render('ClarolineCoreBundle:home:layout.html.twig', $this->renderContent($layout));
}
return $this->render('ClarolineCoreBundle:home:error.html.twig', ['path' => $type]);
} | php | public function typeAction($type, $father = null, $region = null)
{
$layout = $this->manager->contentLayout($type, $father, $region, $this->canEdit());
if ($layout) {
return $this->render('ClarolineCoreBundle:home:layout.html.twig', $this->renderContent($layout));
}
return $this->render('ClarolineCoreBundle:home:error.html.twig', ['path' => $type]);
} | [
"public",
"function",
"typeAction",
"(",
"$",
"type",
",",
"$",
"father",
"=",
"null",
",",
"$",
"region",
"=",
"null",
")",
"{",
"$",
"layout",
"=",
"$",
"this",
"->",
"manager",
"->",
"contentLayout",
"(",
"$",
"type",
",",
"$",
"father",
",",
"$... | Render the layout of contents by type.
@return Response | [
"Render",
"the",
"layout",
"of",
"contents",
"by",
"type",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L180-L189 |
40,385 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.typesAction | public function typesAction()
{
$types = $this->manager->getTypes();
$response = $this->render(
'ClarolineCoreBundle:home:home.html.twig',
[
'type' => '_pages',
'region' => $this->renderRegions($this->manager->getRegionContents()),
'content' => $this->render(
'ClarolineCoreBundle:home:types.html.twig',
['types' => $types, 'hasCustomTemplates' => $this->homeService->hasCustomTemplates()]
)->getContent(),
]
);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
$response->headers->addCacheControlDirective('expires', '-1');
return $response;
} | php | public function typesAction()
{
$types = $this->manager->getTypes();
$response = $this->render(
'ClarolineCoreBundle:home:home.html.twig',
[
'type' => '_pages',
'region' => $this->renderRegions($this->manager->getRegionContents()),
'content' => $this->render(
'ClarolineCoreBundle:home:types.html.twig',
['types' => $types, 'hasCustomTemplates' => $this->homeService->hasCustomTemplates()]
)->getContent(),
]
);
$response->headers->addCacheControlDirective('no-cache', true);
$response->headers->addCacheControlDirective('max-age', 0);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('no-store', true);
$response->headers->addCacheControlDirective('expires', '-1');
return $response;
} | [
"public",
"function",
"typesAction",
"(",
")",
"{",
"$",
"types",
"=",
"$",
"this",
"->",
"manager",
"->",
"getTypes",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"render",
"(",
"'ClarolineCoreBundle:home:home.html.twig'",
",",
"[",
"'type'",
"... | Render the page of types administration.
@Route("/types", name="claroline_types_manager")
@Secure(roles="ROLE_HOME_MANAGER")
@return Response | [
"Render",
"the",
"page",
"of",
"types",
"administration",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L199-L221 |
40,386 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.renameContentAction | public function renameContentAction(Type $type, $name)
{
try {
$this->manager->renameType($type, $name);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | php | public function renameContentAction(Type $type, $name)
{
try {
$this->manager->renameType($type, $name);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | [
"public",
"function",
"renameContentAction",
"(",
"Type",
"$",
"type",
",",
"$",
"name",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"renameType",
"(",
"$",
"type",
",",
"$",
"name",
")",
";",
"return",
"new",
"Response",
"(",
"'true'",
... | Rename a content form.
@Route("/rename/type/{type}/{name}", name="claro_content_rename_type", options = {"expose" = true})
@Secure(roles="ROLE_HOME_MANAGER")
@ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping" : {"type": "name"}})
@param Type $type
@param string $name
@return Response | [
"Rename",
"a",
"content",
"form",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L266-L275 |
40,387 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.changeTemplateFormAction | public function changeTemplateFormAction(Type $type)
{
$form = $this->formFactory->create(
HomeTemplateType::class,
$type,
['dir' => $this->homeService->getTemplatesDirectory()]
);
return ['form' => $form->createView(), 'type' => $type];
} | php | public function changeTemplateFormAction(Type $type)
{
$form = $this->formFactory->create(
HomeTemplateType::class,
$type,
['dir' => $this->homeService->getTemplatesDirectory()]
);
return ['form' => $form->createView(), 'type' => $type];
} | [
"public",
"function",
"changeTemplateFormAction",
"(",
"Type",
"$",
"type",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"create",
"(",
"HomeTemplateType",
"::",
"class",
",",
"$",
"type",
",",
"[",
"'dir'",
"=>",
"$",
"this",
"->"... | Edit template form.
@Route(
"/type/{type}/change/template/form",
name="claro_content_change_template_form",
options = {"expose" = true}
)
@Secure(roles="ROLE_HOME_MANAGER")
@Template("ClarolineCoreBundle:home:change_template_modal_form.html.twig")
@param Type $type
@return array | [
"Edit",
"template",
"form",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L292-L301 |
40,388 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.changeTemplateAction | public function changeTemplateAction(Type $type, Request $request)
{
$form = $this->formFactory->create(
HomeTemplateType::class,
$type,
['dir' => $this->homeService->getTemplatesDirectory()]
);
$form->handleRequest($request);
if ($form->isValid()) {
$this->manager->persistType($type);
return new JsonResponse('success', 200);
} else {
return ['form' => $form->createView(), 'type' => $type];
}
} | php | public function changeTemplateAction(Type $type, Request $request)
{
$form = $this->formFactory->create(
HomeTemplateType::class,
$type,
['dir' => $this->homeService->getTemplatesDirectory()]
);
$form->handleRequest($request);
if ($form->isValid()) {
$this->manager->persistType($type);
return new JsonResponse('success', 200);
} else {
return ['form' => $form->createView(), 'type' => $type];
}
} | [
"public",
"function",
"changeTemplateAction",
"(",
"Type",
"$",
"type",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"create",
"(",
"HomeTemplateType",
"::",
"class",
",",
"$",
"type",
",",
"[",
"'di... | Edit template.
@Route(
"/type/{type}/change/template",
name="claro_content_change_template",
options = {"expose" = true}
)
@Secure(roles="ROLE_HOME_MANAGER")
@Template("ClarolineCoreBundle:home:change_template_modal_form.html.twig")
@param Type $type
@param Request $request
@return Response|array | [
"Edit",
"template",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L319-L335 |
40,389 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.moveContentAction | public function moveContentAction($content, $type, $page)
{
try {
$this->manager->moveContent($content, $type, $page);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | php | public function moveContentAction($content, $type, $page)
{
try {
$this->manager->moveContent($content, $type, $page);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | [
"public",
"function",
"moveContentAction",
"(",
"$",
"content",
",",
"$",
"type",
",",
"$",
"page",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"moveContent",
"(",
"$",
"content",
",",
"$",
"type",
",",
"$",
"page",
")",
";",
"return",
... | Render the "move a content" form.
@Route("/move/content/{content}/{type}/{page}", name="claroline_move_content", options = {"expose" = true})
@Secure(roles="ROLE_HOME_MANAGER")
@Template("ClarolineCoreBundle:home:move.html.twig")
@ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"})
@ParamConverter("type", class = "ClarolineCoreBundle:home\Type", options = {"mapping" : {"type": "name"}})
@ParamConverter("page", class = "ClarolineCoreBundle:home\Type", options = {"mapping" : {"page": "name"}})
@return \Symfony\Component\HttpFoundation\Response | [
"Render",
"the",
"move",
"a",
"content",
"form",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L367-L376 |
40,390 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.creatorAction | public function creatorAction($type, $id = null, $content = null, $father = null)
{
//cant use @Secure(roles="ROLE_ADMIN") annotation beacause this method is called in anonymous mode
if ($this->canEdit()) {
return $this->render(
'ClarolineCoreBundle:home/types:'.$type.'.creator.twig',
$this->manager->getCreator($type, $id, $content, $father),
true
);
}
return new Response(); //return void and not an exeption
} | php | public function creatorAction($type, $id = null, $content = null, $father = null)
{
//cant use @Secure(roles="ROLE_ADMIN") annotation beacause this method is called in anonymous mode
if ($this->canEdit()) {
return $this->render(
'ClarolineCoreBundle:home/types:'.$type.'.creator.twig',
$this->manager->getCreator($type, $id, $content, $father),
true
);
}
return new Response(); //return void and not an exeption
} | [
"public",
"function",
"creatorAction",
"(",
"$",
"type",
",",
"$",
"id",
"=",
"null",
",",
"$",
"content",
"=",
"null",
",",
"$",
"father",
"=",
"null",
")",
"{",
"//cant use @Secure(roles=\"ROLE_ADMIN\") annotation beacause this method is called in anonymous mode",
"... | Render the page of the creator box.
@Route("/content/creator/{type}/{id}/{father}", name="claroline_content_creator", defaults={"father" = null})
@param string $type The type of the content to create
@return \Symfony\Component\HttpFoundation\Response | [
"Render",
"the",
"page",
"of",
"the",
"creator",
"box",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L387-L399 |
40,391 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.menuAction | public function menuAction($id, $size, $type, $father = null, $region = null, $collapse = null)
{
return $this->manager->getMenu($id, $size, $type, $father, $region, $collapse);
} | php | public function menuAction($id, $size, $type, $father = null, $region = null, $collapse = null)
{
return $this->manager->getMenu($id, $size, $type, $father, $region, $collapse);
} | [
"public",
"function",
"menuAction",
"(",
"$",
"id",
",",
"$",
"size",
",",
"$",
"type",
",",
"$",
"father",
"=",
"null",
",",
"$",
"region",
"=",
"null",
",",
"$",
"collapse",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"manager",
"->",
"... | Render the page of the menu.
@param string $id The id of the content
@param string $size The size (content-12) of the content
@param string $type The type of the content
@Template("ClarolineCoreBundle:home:menu.html.twig")
@return \Symfony\Component\HttpFoundation\Response | [
"Render",
"the",
"page",
"of",
"the",
"menu",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L412-L415 |
40,392 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.graphAction | public function graphAction(Request $request)
{
$graph = $this->manager->getGraph($request->get('generated_content_url'));
if (isset($graph['type'])) {
return $this->render(
'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig',
['content' => $graph],
true
);
}
return new Response('false');
} | php | public function graphAction(Request $request)
{
$graph = $this->manager->getGraph($request->get('generated_content_url'));
if (isset($graph['type'])) {
return $this->render(
'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig',
['content' => $graph],
true
);
}
return new Response('false');
} | [
"public",
"function",
"graphAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"graph",
"=",
"$",
"this",
"->",
"manager",
"->",
"getGraph",
"(",
"$",
"request",
"->",
"get",
"(",
"'generated_content_url'",
")",
")",
";",
"if",
"(",
"isset",
"(",
... | Render the HTML of a content generated by an external url with Open Grap meta tags.
@Route("/content/graph", name="claroline_content_graph")
@return \Symfony\Component\HttpFoundation\Response | [
"Render",
"the",
"HTML",
"of",
"a",
"content",
"generated",
"by",
"an",
"external",
"url",
"with",
"Open",
"Grap",
"meta",
"tags",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L442-L455 |
40,393 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.createAction | public function createAction($type = null, $father = null, Request $request)
{
if ($id = $this->manager->createContent($request->get('home_content'), $type, $father)) {
return new Response($id);
}
return new Response('false'); //useful in ajax
} | php | public function createAction($type = null, $father = null, Request $request)
{
if ($id = $this->manager->createContent($request->get('home_content'), $type, $father)) {
return new Response($id);
}
return new Response('false'); //useful in ajax
} | [
"public",
"function",
"createAction",
"(",
"$",
"type",
"=",
"null",
",",
"$",
"father",
"=",
"null",
",",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"manager",
"->",
"createContent",
"(",
"$",
"request",
"->",... | Create new content by POST method. This is used by ajax.
The response is the id of the new content in success, otherwise the response is the false word in a string.
@Route(
"/content/create/{type}/{father}",
name="claroline_content_create",
defaults={"type" = "home", "father" = null}
)
@Secure(roles="ROLE_HOME_MANAGER")
@return \Symfony\Component\HttpFoundation\Response | [
"Create",
"new",
"content",
"by",
"POST",
"method",
".",
"This",
"is",
"used",
"by",
"ajax",
".",
"The",
"response",
"is",
"the",
"id",
"of",
"the",
"new",
"content",
"in",
"success",
"otherwise",
"the",
"response",
"is",
"the",
"false",
"word",
"in",
... | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L489-L496 |
40,394 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.reorderAction | public function reorderAction($type, $a, Content $b = null, Content $father = null)
{
try {
$this->manager->reorderContent($type, $a, $b, $father);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | php | public function reorderAction($type, $a, Content $b = null, Content $father = null)
{
try {
$this->manager->reorderContent($type, $a, $b, $father);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | [
"public",
"function",
"reorderAction",
"(",
"$",
"type",
",",
"$",
"a",
",",
"Content",
"$",
"b",
"=",
"null",
",",
"Content",
"$",
"father",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"reorderContent",
"(",
"$",
"type",
... | Reorder contents in types. This method is used by ajax.
The response is the word true in a string in success, otherwise false.
@param string $type The type of the content
@param string $a The id of the content 1
@param string $b The id of the content 2
@param string $father The father content
@Route("/content/reorder/{type}/{a}/{b}/{father}", requirements={"a" = "\d+"}, name="claroline_content_reorder")
@Secure(roles="ROLE_HOME_MANAGER")
@ParamConverter("type", class = "ClarolineCoreBundle:Home\Type", options = {"mapping": {"type": "name"}})
@ParamConverter("a", class = "ClarolineCoreBundle:Content", options = {"id" = "a"})
@ParamConverter("b", class = "ClarolineCoreBundle:Content", options = {"id" = "b"})
@ParamConverter("father", class = "ClarolineCoreBundle:Content", options = {"id" = "father"})
@return \Symfony\Component\HttpFoundation\Response | [
"Reorder",
"contents",
"in",
"types",
".",
"This",
"method",
"is",
"used",
"by",
"ajax",
".",
"The",
"response",
"is",
"the",
"word",
"true",
"in",
"a",
"string",
"in",
"success",
"otherwise",
"false",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L545-L554 |
40,395 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.contentToRegionAction | public function contentToRegionAction($region, $content)
{
try {
$this->manager->contentToRegion($region, $content);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | php | public function contentToRegionAction($region, $content)
{
try {
$this->manager->contentToRegion($region, $content);
return new Response('true');
} catch (\Exception $e) {
return new Response('false'); //useful in ajax
}
} | [
"public",
"function",
"contentToRegionAction",
"(",
"$",
"region",
",",
"$",
"content",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"contentToRegion",
"(",
"$",
"region",
",",
"$",
"content",
")",
";",
"return",
"new",
"Response",
"(",
"'tr... | Put a content into a region in front page as left, right, footer. This is useful for menus.
@Route("/region/{region}/{content}", requirements={"content" = "\d+"}, name="claroline_content_to_region")
@ParamConverter("region", class = "ClarolineCoreBundle:Home\Region", options = {"mapping": {"region": "name"}})
@ParamConverter("content", class = "ClarolineCoreBundle:Content", options = {"id" = "content"})
@Secure(roles="ROLE_HOME_MANAGER")
@return \Symfony\Component\HttpFoundation\Response | [
"Put",
"a",
"content",
"into",
"a",
"region",
"in",
"front",
"page",
"as",
"left",
"right",
"footer",
".",
"This",
"is",
"useful",
"for",
"menus",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L648-L657 |
40,396 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.canGenerateContentAction | public function canGenerateContentAction(Request $request)
{
$content = $this->decodeRequest($request);
if ($content && $content['url'] && $this->manager->isValidUrl($content['url'])) {
$graph = $this->manager->getGraph($content['url']);
if (isset($graph['type'])) {
return $this->render(
'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig',
['content' => $graph],
true
);
}
}
return new Response('false'); //in case is not valid URL
} | php | public function canGenerateContentAction(Request $request)
{
$content = $this->decodeRequest($request);
if ($content && $content['url'] && $this->manager->isValidUrl($content['url'])) {
$graph = $this->manager->getGraph($content['url']);
if (isset($graph['type'])) {
return $this->render(
'ClarolineCoreBundle:home/graph:'.$graph['type'].'.html.twig',
['content' => $graph],
true
);
}
}
return new Response('false'); //in case is not valid URL
} | [
"public",
"function",
"canGenerateContentAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"decodeRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"content",
"&&",
"$",
"content",
"[",
"'url'",
"]",
"&&",
... | Check if a string is a valid URL.
@Route("/cangeneratecontent", name="claroline_can_generate_content", options={"expose" = true})
@Method("POST")
@param Request $request
@return Response | [
"Check",
"if",
"a",
"string",
"is",
"a",
"valid",
"URL",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L696-L712 |
40,397 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.saveMenuSettingsAction | public function saveMenuSettingsAction($menu, $login, $workspaces, $locale)
{
try {
$this->manager->saveHomeParameters($menu, $login, $workspaces, $locale);
return new Response('true');
} catch (\Exception $e) {
return new Response('false');
}
} | php | public function saveMenuSettingsAction($menu, $login, $workspaces, $locale)
{
try {
$this->manager->saveHomeParameters($menu, $login, $workspaces, $locale);
return new Response('true');
} catch (\Exception $e) {
return new Response('false');
}
} | [
"public",
"function",
"saveMenuSettingsAction",
"(",
"$",
"menu",
",",
"$",
"login",
",",
"$",
"workspaces",
",",
"$",
"locale",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"manager",
"->",
"saveHomeParameters",
"(",
"$",
"menu",
",",
"$",
"login",
",",
"... | Save the menu settings.
@Route(
"/content/menu/save/settings/{menu}/{login}/{workspaces}/{locale}",
name="claroline_content_menu_save_settings",
options = {"expose" = true}
)
@param int $menu The id of the menu
@param bool $login A Boolean that determine if there is the login button in the footer
@param bool $workspaces A Boolean that determine if there is the workspace button in the footer
@param bool $locale A boolean that determine if there is a locale button in the header
@Secure(roles="ROLE_HOME_MANAGER")
@return Response | [
"Save",
"the",
"menu",
"settings",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L751-L760 |
40,398 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.renderContent | public function renderContent($layout)
{
$tmp = ' '; // void in case of not yet content
if (isset($layout['content']) && isset($layout['type']) && is_array($layout['content'])) {
foreach ($layout['content'] as $content) {
$tmp .= $this->render(
'ClarolineCoreBundle:home/types:'.$content['type'].'.html.twig', $content, true
)->getContent();
}
}
$layout['content'] = $tmp;
return $layout;
} | php | public function renderContent($layout)
{
$tmp = ' '; // void in case of not yet content
if (isset($layout['content']) && isset($layout['type']) && is_array($layout['content'])) {
foreach ($layout['content'] as $content) {
$tmp .= $this->render(
'ClarolineCoreBundle:home/types:'.$content['type'].'.html.twig', $content, true
)->getContent();
}
}
$layout['content'] = $tmp;
return $layout;
} | [
"public",
"function",
"renderContent",
"(",
"$",
"layout",
")",
"{",
"$",
"tmp",
"=",
"' '",
";",
"// void in case of not yet content",
"if",
"(",
"isset",
"(",
"$",
"layout",
"[",
"'content'",
"]",
")",
"&&",
"isset",
"(",
"$",
"layout",
"[",
"'type'",
... | Render the HTML of the content.
@param string $layout
@return array | [
"Render",
"the",
"HTML",
"of",
"the",
"content",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L769-L784 |
40,399 | claroline/Distribution | main/core/Controller/HomeController.php | HomeController.renderRegions | public function renderRegions($regions)
{
$tmp = [];
foreach ($regions as $name => $region) {
$tmp[$name] = '';
foreach ($region as $variables) {
$tmp[$name] .= $this->render(
'ClarolineCoreBundle:home/types:'.$variables['type'].'.html.twig', $variables, true
)->getContent();
}
}
return $tmp;
} | php | public function renderRegions($regions)
{
$tmp = [];
foreach ($regions as $name => $region) {
$tmp[$name] = '';
foreach ($region as $variables) {
$tmp[$name] .= $this->render(
'ClarolineCoreBundle:home/types:'.$variables['type'].'.html.twig', $variables, true
)->getContent();
}
}
return $tmp;
} | [
"public",
"function",
"renderRegions",
"(",
"$",
"regions",
")",
"{",
"$",
"tmp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"regions",
"as",
"$",
"name",
"=>",
"$",
"region",
")",
"{",
"$",
"tmp",
"[",
"$",
"name",
"]",
"=",
"''",
";",
"foreach",
... | Render the HTML of the regions.
@param array $regions
@return string | [
"Render",
"the",
"HTML",
"of",
"the",
"regions",
"."
] | a2d9762eddba5732447a2915c977a3ce859103b6 | https://github.com/claroline/Distribution/blob/a2d9762eddba5732447a2915c977a3ce859103b6/main/core/Controller/HomeController.php#L793-L808 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.