idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
53,200
|
public function getHole ( $ uuid ) { $ found = null ; foreach ( $ this -> holes as $ hole ) { if ( $ hole -> getUuid ( ) === $ uuid ) { $ found = $ hole ; break ; } } return $ found ; }
|
Retrieves a hole by its uuid .
|
53,201
|
public function addHole ( Hole $ hole ) { if ( ! $ this -> holes -> contains ( $ hole ) ) { $ this -> holes -> add ( $ hole ) ; $ hole -> setInteractionHole ( $ this ) ; } }
|
Adds a hole .
|
53,202
|
public function removeHole ( Hole $ hole ) { if ( $ this -> holes -> contains ( $ hole ) ) { $ this -> holes -> removeElement ( $ hole ) ; } }
|
Removes a hole .
|
53,203
|
public function sipe ( $ prop , $ setter , $ data = [ ] , $ object , $ trim = true ) { if ( $ data && is_array ( $ data ) ) { try { $ value = ArrayUtils :: get ( $ data , $ prop ) ; if ( is_string ( $ value ) && $ trim ) { $ value = trim ( $ value ) ; } $ object -> { $ setter } ( $ value ) ; } catch ( \ Exception $ e ) { } } }
|
SetIfPropertyExists . Sets an entity prop from an array data source .
|
53,204
|
public function findInCollection ( $ object , $ method , $ id , $ class = null ) { foreach ( $ object -> $ method ( ) as $ el ) { if ( $ el -> getId ( ) === $ id || $ el -> getUuid ( ) === $ id ) { return $ el ; } } if ( $ class ) { return $ this -> _om -> getObject ( [ 'id' => $ id ] , $ class ) ; } }
|
alias method .
|
53,205
|
public function createDefaultToolMaskDecoders ( Tool $ tool ) { foreach ( ToolMaskDecoder :: $ defaultActions as $ action ) { $ maskDecoder = $ this -> maskRepo -> findMaskDecoderByToolAndName ( $ tool , $ action ) ; if ( is_null ( $ maskDecoder ) ) { $ maskDecoder = new ToolMaskDecoder ( ) ; $ maskDecoder -> setTool ( $ tool ) ; $ maskDecoder -> setName ( $ action ) ; $ maskDecoder -> setValue ( ToolMaskDecoder :: $ defaultValues [ $ action ] ) ; $ maskDecoder -> setGrantedIconClass ( ToolMaskDecoder :: $ defaultGrantedIconClass [ $ action ] ) ; $ maskDecoder -> setDeniedIconClass ( ToolMaskDecoder :: $ defaultDeniedIconClass [ $ action ] ) ; $ this -> om -> persist ( $ maskDecoder ) ; } } $ this -> om -> flush ( ) ; }
|
Create a mask decoder with default actions for a tool .
|
53,206
|
public function createToolMaskDecoder ( Tool $ tool , $ action , $ value , $ grantedIconClass , $ deniedIconClass ) { $ maskDecoder = new ToolMaskDecoder ( ) ; $ maskDecoder -> setTool ( $ tool ) ; $ maskDecoder -> setName ( $ action ) ; $ maskDecoder -> setValue ( $ value ) ; $ maskDecoder -> setGrantedIconClass ( $ grantedIconClass ) ; $ maskDecoder -> setDeniedIconClass ( $ deniedIconClass ) ; $ this -> om -> persist ( $ maskDecoder ) ; $ this -> om -> flush ( ) ; }
|
Create a specific mask decoder for a tool .
|
53,207
|
public function decodeMask ( $ mask , Tool $ tool ) { $ decoders = $ this -> maskRepo -> findMaskDecodersByTool ( $ tool ) ; $ perms = [ ] ; foreach ( $ decoders as $ decoder ) { $ perms [ $ decoder -> getName ( ) ] = ( $ mask & $ decoder -> getValue ( ) ) ? true : false ; } return $ perms ; }
|
Returns an array containing the permission for a mask and a tool .
|
53,208
|
public function serialize ( Theme $ theme ) { return [ 'id' => $ theme -> getUuid ( ) , 'name' => $ theme -> getName ( ) , 'normalizedName' => str_replace ( ' ' , '-' , strtolower ( $ theme -> getName ( ) ) ) , 'current' => $ theme -> getNormalizedName ( ) === str_replace ( ' ' , '-' , strtolower ( $ this -> config -> getParameter ( 'theme' ) ) ) , 'meta' => [ 'description' => $ theme -> getDescription ( ) , 'default' => $ theme -> isDefault ( ) , 'enabled' => $ theme -> isEnabled ( ) , 'custom' => $ theme -> isCustom ( ) , 'plugin' => $ theme -> getPlugin ( ) ? $ theme -> getPlugin ( ) -> getShortName ( ) : null , 'creator' => $ theme -> getUser ( ) ? $ this -> userSerializer -> serialize ( $ theme -> getUser ( ) ) : null , ] , 'parameters' => [ 'extendDefault' => $ theme -> isExtendingDefault ( ) , ] , ] ; }
|
Serializes a Theme entity for the JSON api .
|
53,209
|
public function deserialize ( array $ data , Theme $ theme = null ) { $ theme = $ theme ? : new Theme ( ) ; $ theme -> setName ( $ data [ 'name' ] ) ; return $ theme ; }
|
Deserializes JSON api data into a Theme entity .
|
53,210
|
public function updatePost ( Blog $ blog , Post $ existingPost , Post $ post , User $ user ) { $ existingPost -> setTitle ( $ post -> getTitle ( ) ) -> setContent ( $ post -> getContent ( ) ) ; if ( null !== $ post -> getPublicationDate ( ) ) { $ existingPost -> setPublicationDate ( $ post -> getPublicationDate ( ) ) ; } else { $ existingPost -> setPublicationDate ( null ) ; } $ this -> om -> flush ( ) ; $ unitOfWork = $ this -> om -> getUnitOfWork ( ) ; $ unitOfWork -> computeChangeSets ( ) ; $ changeSet = $ unitOfWork -> getEntityChangeSet ( $ existingPost ) ; $ this -> trackingManager -> dispatchPostUpdateEvent ( $ existingPost , $ changeSet ) ; if ( 'anon.' !== $ user ) { $ this -> trackingManager -> updateResourceTracking ( $ blog -> getResourceNode ( ) , $ user , new \ DateTime ( ) ) ; } return $ existingPost ; }
|
Update a post .
|
53,211
|
public function updatePostViewCount ( $ post ) { $ post -> increaseViewCounter ( ) ; $ this -> om -> persist ( $ post ) ; $ this -> om -> flush ( ) ; }
|
Update post view count .
|
53,212
|
public function switchPublicationState ( Post $ post ) { if ( ! $ post -> isPublished ( ) ) { $ post -> publish ( ) ; } else { $ post -> unpublish ( ) ; } $ this -> om -> flush ( ) ; $ unitOfWork = $ this -> om -> getUnitOfWork ( ) ; $ unitOfWork -> computeChangeSets ( ) ; $ changeSet = $ unitOfWork -> getEntityChangeSet ( $ post ) ; $ this -> trackingManager -> dispatchPostUpdateEvent ( $ post , $ changeSet ) ; return $ post ; }
|
Switch post state .
|
53,213
|
public function getAuthors ( $ blog ) { $ recordSet = $ this -> repo -> findAuthorsByBlog ( $ blog ) ; $ authorsIds = [ ] ; foreach ( $ recordSet as $ value ) { $ authorsIds [ ] = $ value [ 'id' ] ; } $ authors = $ this -> userRepo -> findBy ( [ 'id' => $ authorsIds ] , [ 'lastName' => 'ASC' ] ) ; $ serializedAuthors = [ ] ; foreach ( $ authors as $ author ) { $ serializedAuthors [ ] = $ this -> userSerializer -> serialize ( $ author , [ Options :: SERIALIZE_MINIMAL ] ) ; } return $ serializedAuthors ; }
|
Get blog post authors .
|
53,214
|
public function getArchives ( $ blog ) { $ postDatas = $ this -> repo -> findArchiveDatasByBlog ( $ blog ) ; $ archiveDatas = [ ] ; foreach ( $ postDatas as $ postData ) { $ year = $ postData [ 'year' ] ; $ month = $ postData [ 'month' ] ; $ count = $ postData [ 'count' ] ; $ archiveDatas [ $ year ] [ ] = [ 'month' => $ this -> translator -> trans ( 'month.' . date ( 'F' , mktime ( 0 , 0 , 0 , $ month , 10 ) ) , [ ] , 'platform' ) , 'monthValue' => $ month , 'count' => $ count , ] ; } return $ archiveDatas ; }
|
Get blog posts archives .
|
53,215
|
public function serialize ( FieldFacetValue $ fieldFacetValue , array $ options = [ ] ) { if ( in_array ( Options :: PROFILE_SERIALIZE , $ options ) ) { } $ serialized = [ 'id' => $ fieldFacetValue -> getId ( ) , 'value' => $ fieldFacetValue -> getValue ( ) , 'name' => $ fieldFacetValue -> getFieldFacet ( ) -> getName ( ) , ] ; if ( ! in_array ( static :: OPTION_MINIMAL , $ options ) ) { $ serialized = array_merge ( $ serialized , [ 'user' => $ fieldFacetValue -> getUser ( ) ? [ 'autoId' => $ fieldFacetValue -> getUser ( ) -> getId ( ) , 'id' => $ fieldFacetValue -> getUser ( ) -> getUuid ( ) , 'name' => $ fieldFacetValue -> getUser ( ) -> getFirstName ( ) . ' ' . $ fieldFacetValue -> getUser ( ) -> getLastName ( ) , 'firstName' => $ fieldFacetValue -> getUser ( ) -> getFirstName ( ) , 'lastName' => $ fieldFacetValue -> getUser ( ) -> getLastName ( ) , 'username' => $ fieldFacetValue -> getUser ( ) -> getUsername ( ) , 'email' => $ fieldFacetValue -> getUser ( ) -> getEmail ( ) , ] : null , 'fieldFacet' => $ this -> fieldFacetSerializer -> serialize ( $ fieldFacetValue -> getFieldFacet ( ) ) , ] ) ; } return $ serialized ; }
|
Serializes a FieldFacetValue entity for the JSON api .
|
53,216
|
public function deserialize ( array $ data , FieldFacetValue $ fieldFacetValue = null , array $ options = [ ] ) { $ fieldFacet = $ this -> container -> get ( 'claroline.persistence.object_manager' ) -> getRepository ( FieldFacet :: class ) -> findOneByUuid ( $ data [ 'fieldFacet' ] [ 'id' ] ) ; $ fieldFacetValue -> setFieldFacet ( $ fieldFacet ) ; $ value = $ data [ 'value' ] ; switch ( $ fieldFacet -> getType ( ) ) { case FieldFacet :: DATE_TYPE : $ date = is_string ( $ value ) ? new \ DateTime ( $ value ) : $ value ; $ fieldFacetValue -> setDateValue ( $ date ) ; break ; case FieldFacet :: NUMBER_TYPE : $ fieldFacetValue -> setFloatValue ( $ value ) ; break ; case FieldFacet :: CASCADE_TYPE : $ fieldFacetValue -> setArrayValue ( $ value ) ; break ; case FieldFacet :: CHOICE_TYPE : if ( is_array ( $ value ) ) { $ fieldFacetValue -> setArrayValue ( $ value ) ; } else { $ fieldFacetValue -> setStringValue ( $ value ) ; } break ; case FieldFacet :: BOOLEAN_TYPE : $ fieldFacetValue -> setBoolValue ( $ value ) ; break ; default : $ fieldFacetValue -> setStringValue ( $ value ) ; } return $ fieldFacetValue ; }
|
Deserializes a FieldFacetValue entity for the JSON api .
|
53,217
|
public function commentEditAction ( Comment $ comment , Request $ request ) { $ this -> clacoFormManager -> checkCommentEditionRight ( $ comment ) ; $ decodedRequest = $ this -> decodeRequest ( $ request ) ; $ comment = $ this -> clacoFormManager -> editComment ( $ comment , $ decodedRequest [ 'message' ] ) ; return new JsonResponse ( $ this -> commentSerializer -> serialize ( $ comment ) , 200 ) ; }
|
Edits a comment .
|
53,218
|
public function addGroup ( Group $ group ) { $ this -> hasGroupsProperty ( ) ; if ( ! $ this -> groups -> contains ( $ group ) ) { $ this -> groups -> add ( $ group ) ; } }
|
Add an group .
|
53,219
|
public function removeGroup ( Group $ group ) { $ this -> hasGroupsProperty ( ) ; if ( $ this -> groups -> contains ( $ group ) ) { $ this -> groups -> removeElement ( $ group ) ; } }
|
Removes an group .
|
53,220
|
public function persistUser ( User $ user ) { $ this -> objectManager -> persist ( $ user ) ; $ this -> objectManager -> flush ( ) ; return $ user ; }
|
Persist a user .
|
53,221
|
public function setPlatformRoles ( User $ user , $ roles ) { $ this -> roleManager -> resetRoles ( $ user ) ; $ this -> roleManager -> associateRoles ( $ user , $ roles ) ; }
|
Sets an array of platform role to a user .
|
53,222
|
public function setLocale ( User $ user , $ locale = 'en' ) { $ user -> setLocale ( $ locale ) ; $ this -> objectManager -> persist ( $ user ) ; $ this -> objectManager -> flush ( ) ; }
|
Set the user locale .
|
53,223
|
public function personalWorkspaceAllowed ( $ roles ) { $ roles [ ] = $ this -> roleManager -> getRoleByName ( 'ROLE_USER' ) ; foreach ( $ roles as $ role ) { if ( $ role -> isPersonalWorkspaceCreationEnabled ( ) ) { return true ; } } return false ; }
|
Checks if a user will have a personal workspace at his creation .
|
53,224
|
public function activateUser ( User $ user ) { $ user -> setIsEnabled ( true ) ; $ user -> setIsMailValidated ( true ) ; $ user -> setResetPasswordHash ( null ) ; $ user -> setInitDate ( new \ DateTime ( ) ) ; $ this -> objectManager -> persist ( $ user ) ; $ this -> objectManager -> flush ( ) ; }
|
Activates a User and set the init date to now .
|
53,225
|
public function logUser ( User $ user ) { $ this -> strictEventDispatcher -> dispatch ( 'log' , 'Log\LogUserLogin' , [ $ user ] ) ; $ token = new UsernamePasswordToken ( $ user , null , 'main' , $ user -> getRoles ( ) ) ; $ this -> tokenStorage -> setToken ( $ token ) ; if ( null === $ user -> getInitDate ( ) ) { $ this -> setUserInitDate ( $ user ) ; } $ user -> setLastLogin ( new \ DateTime ( ) ) ; $ this -> objectManager -> persist ( $ user ) ; $ this -> objectManager -> flush ( ) ; }
|
Logs the current user .
|
53,226
|
public function transferRoles ( User $ from , User $ to ) { $ roles = $ from -> getEntityRoles ( ) ; foreach ( $ roles as $ role ) { $ to -> addRole ( $ role ) ; } $ this -> objectManager -> flush ( ) ; return count ( $ roles ) ; }
|
Merges two users and transfers every resource to the kept user .
|
53,227
|
public function countActiveUsers ( array $ finderParams = [ ] , $ defaultPeriod = false ) { if ( $ defaultPeriod ) { $ finderParams = $ this -> formatQueryParams ( $ finderParams ) ; } $ queryParams = FinderProvider :: parseQueryParams ( $ finderParams ) ; $ resultData = $ this -> logRepository -> countActiveUsers ( $ queryParams [ 'allFilters' ] ) ; return floatval ( $ resultData ) ; }
|
Retrieve user who connected at least one time on the application .
|
53,228
|
public function refreshIdentifiers ( AbstractItem $ item ) { $ text = $ item -> getText ( ) ; foreach ( $ item -> getHoles ( ) as $ hole ) { $ oldId = $ hole -> getUuid ( ) ; $ hole -> refreshUuid ( ) ; $ text = str_replace ( '[[' . $ oldId . ']]' , '[[' . $ hole -> getUuid ( ) . ']]' , $ text ) ; } $ item -> setText ( $ text ) ; }
|
Refreshes hole UUIDs and update placeholders in text .
|
53,229
|
public function getClass ( ) { $ classMap = [ 'activity' => 'Claroline\CoreBundle\Entity\Resource\Activity' , 'claroline_scorm_12' => 'Claroline\ScormBundle\Entity\Scorm12Resource' , 'claroline_scorm_2004' => 'Claroline\ScormBundle\Entity\Scorm2004Resource' , 'icap_dropzone' => 'Icap\DropzoneBundle\Entity\Dropzone' , 'claroline_result' => 'Claroline\ResultBundle\Entity\Result' , 'innova_video_recorder' => null , 'innova_audio_recorder' => null , 'claroline_chat_room' => null , 'ujm_lti_resource' => 'UJM\LtiBundle\Entity\LtiResource' , ] ; if ( isset ( $ classMap [ $ this -> getName ( ) ] ) ) { return $ classMap [ $ this -> getName ( ) ] ; } return $ this -> class ; }
|
Returns the resource class name .
|
53,230
|
public function serialize ( Entry $ entry , array $ options = [ ] ) { $ user = $ entry -> getUser ( ) ; $ serialized = [ 'id' => $ entry -> getUuid ( ) , 'autoId' => $ entry -> getId ( ) , 'title' => $ entry -> getTitle ( ) , 'status' => $ entry -> getStatus ( ) , 'locked' => $ entry -> isLocked ( ) , 'creationDate' => $ entry -> getCreationDate ( ) ? $ entry -> getCreationDate ( ) -> format ( 'Y-m-d H:i:s' ) : null , 'editionDate' => $ entry -> getEditionDate ( ) ? $ entry -> getEditionDate ( ) -> format ( 'Y-m-d H:i:s' ) : null , 'publicationDate' => $ entry -> getPublicationDate ( ) ? $ entry -> getPublicationDate ( ) -> format ( 'Y-m-d H:i:s' ) : null , 'user' => $ user ? $ this -> userSerializer -> serialize ( $ user , [ Options :: SERIALIZE_MINIMAL ] ) : null , 'clacoForm' => [ 'id' => $ entry -> getClacoForm ( ) -> getUuid ( ) , ] , ] ; $ fieldValues = $ entry -> getFieldValues ( ) ; if ( count ( $ fieldValues ) > 0 ) { $ serialized [ 'values' ] = $ this -> serializeValues ( $ fieldValues ) ; } if ( ! in_array ( Options :: SERIALIZE_MINIMAL , $ options ) ) { $ serialized = array_merge ( $ serialized , [ 'categories' => $ this -> getCategories ( $ entry ) , 'keywords' => $ this -> getKeywords ( $ entry ) , 'comments' => $ this -> getComments ( $ entry ) , ] ) ; } return $ serialized ; }
|
Serializes an Entry entity for the JSON api .
|
53,231
|
public function followerResourcesToggleAction ( $ mode , User $ user , Request $ request ) { $ nodes = $ this -> decodeIdsString ( $ request , 'Claroline\CoreBundle\Entity\Resource\ResourceNode' ) ; $ this -> manager -> toggleFollowResources ( $ user , $ nodes , $ mode ) ; return new JsonResponse ( array_map ( function ( ResourceNode $ resourceNode ) { return $ this -> serializer -> serialize ( $ resourceNode ) ; } , $ nodes ) ) ; }
|
Follows or unfollows resources .
|
53,232
|
public function getStatistics ( Exercise $ exercise , $ maxScore ) { return [ 'maxScore' => $ maxScore , 'nbSteps' => $ exercise -> getSteps ( ) -> count ( ) , 'nbQuestions' => $ this -> exerciseRepository -> countExerciseQuestion ( $ exercise ) , 'nbPapers' => $ this -> paperManager -> countExercisePapers ( $ exercise ) , 'nbRegisteredUsers' => $ this -> paperManager -> countPapersUsers ( $ exercise ) , 'nbAnonymousUsers' => $ this -> paperManager -> countAnonymousPapers ( $ exercise ) , 'minMaxAndAvgScores' => $ this -> getMinMaxAverageScores ( $ exercise , $ maxScore ) , 'paperSuccessDistribution' => $ this -> getPapersSuccessDistribution ( $ exercise , $ maxScore ) , 'paperScoreDistribution' => $ this -> getPaperScoreDistribution ( $ exercise , $ maxScore ) , 'questionsDifficultyIndex' => $ this -> getQuestionsDifficultyIndex ( $ exercise ) , 'discriminationCoefficient' => $ this -> getDiscriminationCoefficient ( $ exercise ) , ] ; }
|
Serializes an Exercise .
|
53,233
|
public function getMinMaxAverageScores ( Exercise $ exercise , $ scoreOn ) { $ papers = $ this -> paperRepository -> findBy ( [ 'exercise' => $ exercise , ] ) ; $ scores = $ this -> getPapersScores ( $ papers , $ scoreOn ) ; $ result = [ 'min' => 0 === count ( $ scores ) ? 0 : min ( $ scores ) , 'max' => 0 === count ( $ scores ) ? 0 : max ( $ scores ) , ] ; $ average = 0 === count ( $ scores ) ? 0 : array_sum ( $ scores ) / count ( $ scores ) ; $ result [ 'avg' ] = $ average !== floor ( $ average ) ? floatval ( number_format ( $ average , 2 ) ) : $ average ; return $ result ; }
|
Returns the max min and average score for a given exercise .
|
53,234
|
public function getPapersSuccessDistribution ( Exercise $ exercise , $ scoreOn ) { $ papers = $ this -> paperRepository -> findBy ( [ 'exercise' => $ exercise , ] ) ; $ nbSuccess = 0 ; $ nbMissed = 0 ; $ nbPartialSuccess = 0 ; $ scores = $ this -> getPapersScores ( $ papers , $ scoreOn ) ; foreach ( $ scores as $ score ) { if ( $ score === floatval ( 0 ) ) { ++ $ nbMissed ; } elseif ( $ score === floatval ( $ scoreOn ) ) { ++ $ nbSuccess ; } else { ++ $ nbPartialSuccess ; } } return [ 'nbSuccess' => $ nbSuccess , 'nbMissed' => $ nbMissed , 'nbPartialSuccess' => $ nbPartialSuccess , ] ; }
|
Returns the number of fully partially successfull and missed papers for a given exercise .
|
53,235
|
public function getPaperScoreDistribution ( Exercise $ exercise , $ scoreOn ) { $ papers = $ this -> paperRepository -> findBy ( [ 'exercise' => $ exercise , ] ) ; $ scores = $ this -> getPapersScores ( $ papers , $ scoreOn ) ; $ uniqueScores = array_unique ( $ scores , SORT_NUMERIC ) ; sort ( $ uniqueScores ) ; $ paperScoreDistribution = [ ] ; foreach ( $ uniqueScores as $ key ) { $ matchingScores = array_filter ( $ scores , function ( $ score ) use ( $ key ) { return floatval ( $ score ) === floatval ( $ key ) ; } ) ; $ paperScoreDistribution [ $ key ] = [ 'yData' => count ( $ matchingScores ) , 'xData' => $ key , ] ; } return $ paperScoreDistribution ; }
|
Returns the number of papers with a particular score for a given exercise .
|
53,236
|
private function getDiscriminationCoefficient ( Exercise $ exercise ) { $ papers = $ this -> paperRepository -> findBy ( [ 'exercise' => $ exercise , ] ) ; $ itemRepository = $ this -> om -> getRepository ( 'UJMExoBundle:Item\Item' ) ; $ reportScoreOn = 100 ; $ exerciseScores = $ this -> getPapersScores ( $ papers , $ reportScoreOn ) ; $ standardDeviationE = $ this -> getStandardDeviation ( $ exerciseScores ) ; $ exerciseAverageScore = $ this -> getMinMaxAverageScores ( $ exercise , $ reportScoreOn ) [ 'avg' ] ; $ questionsScores = [ ] ; $ questionsAvgScores = [ ] ; $ questionsMarginMark = [ ] ; $ discriminationCoef = [ ] ; foreach ( $ papers as $ paper ) { $ structure = json_decode ( $ paper -> getStructure ( ) , true ) ; foreach ( $ structure [ 'steps' ] as $ step ) { foreach ( array_filter ( $ step [ 'items' ] , function ( $ item ) { return ItemType :: isSupported ( $ item [ 'type' ] ) ; } ) as $ item ) { if ( ! array_key_exists ( $ item [ 'id' ] , $ discriminationCoef ) ) { $ itemEntity = $ itemRepository -> findOneBy ( [ 'uuid' => $ item [ 'id' ] ] ) ; $ questionsScores [ $ item [ 'id' ] ] = $ this -> itemManager -> getItemScores ( $ exercise , $ itemEntity ) ; $ questionsAvgScores [ $ item [ 'id' ] ] = array_sum ( $ questionsScores [ $ item [ 'id' ] ] ) / count ( $ questionsScores [ $ item [ 'id' ] ] ) ; $ i = 0 ; foreach ( $ questionsScores [ $ item [ 'id' ] ] as $ score ) { $ questionsMarginMark [ $ item [ 'id' ] ] [ ] = ( $ score - $ questionsAvgScores [ $ item [ 'id' ] ] ) * ( $ exerciseScores [ $ i ] - $ exerciseAverageScore ) ; ++ $ i ; } $ questionProductMarginMark = $ questionsMarginMark [ $ item [ 'id' ] ] ; $ sumPenq = array_sum ( $ questionProductMarginMark ) ; $ sumPenq = round ( $ sumPenq , 3 ) ; $ standardDeviationQ = $ this -> getStandardDeviation ( $ questionsScores [ $ item [ 'id' ] ] ) ; $ n = count ( $ questionProductMarginMark ) ; $ nSxSy = $ n * $ standardDeviationQ * $ standardDeviationE ; $ coef = $ nSxSy === floatval ( 0 ) ? 0 : round ( $ sumPenq / ( $ nSxSy ) , 3 ) ; $ discriminationCoef [ $ item [ 'id' ] ] = [ 'xData' => $ itemEntity -> getTitle ( ) ? strip_tags ( $ itemEntity -> getTitle ( ) ) : strip_tags ( $ itemEntity -> getContent ( ) ) , 'yData' => $ coef , ] ; } } } } return $ discriminationCoef ; }
|
Get discrimination coefficient for an exercise .
|
53,237
|
private function getStandardDeviation ( $ array ) { $ sdSquare = function ( $ x , $ mean ) { return pow ( $ x - $ mean , 2 ) ; } ; $ nbData = count ( $ array ) > 1 ? count ( $ array ) - 1 : 1 ; $ fillNbData = count ( $ array ) > 0 ? count ( $ array ) : 1 ; return sqrt ( array_sum ( array_map ( $ sdSquare , $ array , array_fill ( 0 , count ( $ array ) , ( array_sum ( $ array ) / $ fillNbData ) ) ) ) / $ nbData ) ; }
|
Get standard deviation for the discrimination coefficient .
|
53,238
|
public function serialize ( GraphicQuestion $ graphicQuestion , array $ options = [ ] ) { $ serialized = [ 'image' => $ this -> serializeImage ( $ graphicQuestion ) , 'pointers' => $ graphicQuestion -> getAreas ( ) -> count ( ) , 'pointerMode' => 'pointer' , ] ; if ( in_array ( Transfer :: INCLUDE_SOLUTIONS , $ options ) ) { $ serialized [ 'solutions' ] = $ this -> serializeSolutions ( $ graphicQuestion ) ; } return $ serialized ; }
|
Converts a Graphic question into a JSON - encodable structure .
|
53,239
|
public function deserialize ( $ data , GraphicQuestion $ graphicQuestion = null , array $ options = [ ] ) { if ( empty ( $ graphicQuestion ) ) { $ graphicQuestion = new GraphicQuestion ( ) ; } $ this -> deserializeImage ( $ graphicQuestion , $ data [ 'image' ] ) ; $ this -> deserializeAreas ( $ graphicQuestion , $ data [ 'solutions' ] ) ; return $ graphicQuestion ; }
|
Converts raw data into a Graphic question entity .
|
53,240
|
private function serializeImage ( GraphicQuestion $ graphicQuestion ) { $ questionImg = $ graphicQuestion -> getImage ( ) ; $ image = [ ] ; if ( $ questionImg ) { $ image [ 'id' ] = $ questionImg -> getUuid ( ) ; $ image [ 'type' ] = $ questionImg -> getType ( ) ; if ( 0 === strpos ( $ questionImg -> getUrl ( ) , './' ) ) { $ image [ 'url' ] = substr ( $ questionImg -> getUrl ( ) , 2 ) ; } else { $ image [ 'url' ] = $ questionImg -> getUrl ( ) ; } $ image [ 'width' ] = $ questionImg -> getWidth ( ) ; $ image [ 'height' ] = $ questionImg -> getHeight ( ) ; } return $ image ; }
|
Serializes the Question image .
|
53,241
|
private function deserializeImage ( GraphicQuestion $ graphicQuestion , array $ imageData ) { $ image = $ graphicQuestion -> getImage ( ) ? : new Image ( ) ; $ this -> sipe ( 'id' , 'setUuid' , $ imageData , $ image ) ; $ this -> sipe ( 'type' , 'setType' , $ imageData , $ image ) ; $ this -> sipe ( 'id' , 'setTitle' , $ imageData , $ image ) ; $ this -> sipe ( 'width' , 'setWidth' , $ imageData , $ image ) ; $ this -> sipe ( 'height' , 'setHeight' , $ imageData , $ image ) ; $ objectClass = get_class ( $ graphicQuestion ) ; $ objectUuid = $ graphicQuestion -> getQuestion ( ) ? $ graphicQuestion -> getQuestion ( ) -> getUuid ( ) : null ; $ title = $ graphicQuestion -> getQuestion ( ) ? $ graphicQuestion -> getQuestion ( ) -> getTitle ( ) : null ; $ typeParts = explode ( '/' , $ imageData [ 'type' ] ) ; if ( isset ( $ imageData [ 'data' ] ) ) { $ imageName = "{$imageData['id']}.{$typeParts[1]}" ; $ publicFile = $ this -> fileUtils -> createFileFromData ( $ imageData [ 'data' ] , $ imageName , $ objectClass , $ objectUuid , $ title , $ objectClass ) ; if ( $ publicFile ) { $ image -> setUrl ( $ publicFile -> getUrl ( ) ) ; } } elseif ( isset ( $ imageData [ 'url' ] ) ) { $ image -> setUrl ( $ imageData [ 'url' ] ) ; } $ graphicQuestion -> setImage ( $ image ) ; }
|
Deserializes the Question image .
|
53,242
|
private function deserializeAreas ( GraphicQuestion $ graphicQuestion , array $ solutions ) { $ areaEntities = $ graphicQuestion -> getAreas ( ) -> toArray ( ) ; foreach ( $ solutions as $ solutionData ) { $ area = null ; foreach ( $ areaEntities as $ entityIndex => $ entityArea ) { if ( $ entityArea -> getUuid ( ) === $ solutionData [ 'area' ] [ 'id' ] ) { $ area = $ entityArea ; unset ( $ areaEntities [ $ entityIndex ] ) ; break ; } } $ area = $ area ? : new Area ( ) ; $ area -> setUuid ( $ solutionData [ 'area' ] [ 'id' ] ) ; $ area -> setScore ( $ solutionData [ 'score' ] ) ; if ( ! empty ( $ solutionData [ 'feedback' ] ) ) { $ area -> setFeedback ( $ solutionData [ 'feedback' ] ) ; } $ this -> deserializeArea ( $ area , $ solutionData [ 'area' ] ) ; $ graphicQuestion -> addArea ( $ area ) ; } foreach ( $ areaEntities as $ areaToRemove ) { $ graphicQuestion -> removeArea ( $ areaToRemove ) ; } }
|
Deserializes Question areas .
|
53,243
|
private function serializeArea ( Area $ area ) { $ areaData = [ 'id' => $ area -> getUuid ( ) , 'color' => $ area -> getColor ( ) , ] ; $ position = explode ( ',' , $ area -> getValue ( ) ) ; switch ( $ area -> getShape ( ) ) { case 'circle' : $ areaData [ 'shape' ] = 'circle' ; $ areaData [ 'radius' ] = $ area -> getSize ( ) / 2 ; $ center = $ this -> serializeCoords ( $ position ) ; $ center [ 'x' ] += $ areaData [ 'radius' ] ; $ center [ 'y' ] += $ areaData [ 'radius' ] ; $ areaData [ 'center' ] = $ center ; break ; case 'square' : $ areaData [ 'shape' ] = 'rect' ; $ areaData [ 'coords' ] = [ $ this -> serializeCoords ( $ position ) , $ this -> serializeCoords ( [ $ position [ 0 ] + $ area -> getSize ( ) , $ position [ 1 ] + $ area -> getSize ( ) ] ) , ] ; break ; case 'rect' : $ areaData [ 'shape' ] = 'rect' ; $ areaData [ 'coords' ] = [ $ this -> serializeCoords ( array_slice ( $ position , 0 , 2 ) ) , $ this -> serializeCoords ( array_slice ( $ position , 2 , 2 ) ) , ] ; break ; } return $ areaData ; }
|
Serializes an Area .
|
53,244
|
private function deserializeArea ( Area $ area , array $ data ) { if ( ! empty ( $ data [ 'color' ] ) ) { $ area -> setColor ( $ data [ 'color' ] ) ; } $ area -> setShape ( $ data [ 'shape' ] ) ; switch ( $ data [ 'shape' ] ) { case 'circle' : $ x = $ data [ 'center' ] [ 'x' ] - $ data [ 'radius' ] ; $ y = $ data [ 'center' ] [ 'y' ] - $ data [ 'radius' ] ; $ area -> setValue ( "{$x},{$y}" ) ; $ area -> setSize ( $ data [ 'radius' ] * 2 ) ; break ; case 'rect' : $ area -> setValue ( sprintf ( '%s,%s,%s,%s' , $ data [ 'coords' ] [ 0 ] [ 'x' ] , $ data [ 'coords' ] [ 0 ] [ 'y' ] , $ data [ 'coords' ] [ 1 ] [ 'x' ] , $ data [ 'coords' ] [ 1 ] [ 'y' ] ) ) ; $ area -> setSize ( $ data [ 'coords' ] [ 1 ] [ 'x' ] - $ data [ 'coords' ] [ 0 ] [ 'x' ] ) ; break ; } }
|
Deserializes an Area .
|
53,245
|
public function serialize ( FieldFacetChoice $ choice , array $ options = [ ] ) { $ serialized = [ 'id' => $ choice -> getUuid ( ) , 'name' => $ choice -> getName ( ) , 'label' => $ choice -> getName ( ) , 'value' => $ choice -> getValue ( ) , 'position' => $ choice -> getPosition ( ) , ] ; if ( ! empty ( $ choice -> getChildren ( ) ) ) { $ serialized [ 'children' ] = [ ] ; foreach ( $ choice -> getChildren ( ) as $ child ) { $ serialized [ 'children' ] [ ] = $ this -> serialize ( $ child ) ; } } return $ serialized ; }
|
Serializes a FieldFacetChoice entity for the JSON api .
|
53,246
|
private function deleteFiles ( $ dirPath ) { foreach ( glob ( $ dirPath . DIRECTORY_SEPARATOR . '{*,.[!.]*,..?*}' , GLOB_BRACE ) as $ content ) { if ( is_dir ( $ content ) ) { $ this -> deleteFiles ( $ content ) ; } else { unlink ( $ content ) ; } } rmdir ( $ dirPath ) ; }
|
Deletes recursively a directory and its content .
|
53,247
|
public function createAction ( AnnouncementAggregate $ aggregate , Request $ request ) { $ this -> checkPermission ( 'EDIT' , $ aggregate -> getResourceNode ( ) , [ ] , true ) ; $ data = $ this -> decodeRequest ( $ request ) ; $ data [ 'aggregate' ] = [ 'id' => $ aggregate -> getUuid ( ) ] ; $ announcement = $ this -> crud -> create ( $ this -> getClass ( ) , $ data , [ 'announcement_aggregate' => $ aggregate , ] ) ; return new JsonResponse ( $ this -> serializer -> serialize ( $ announcement ) , 201 ) ; }
|
Creates a new announce .
|
53,248
|
public function updateAction ( AnnouncementAggregate $ aggregate , Announcement $ announcement , Request $ request ) { $ this -> checkPermission ( 'EDIT' , $ aggregate -> getResourceNode ( ) , [ ] , true ) ; $ announcement = $ this -> crud -> update ( $ this -> getClass ( ) , $ this -> decodeRequest ( $ request ) , [ 'announcement_aggregate' => $ aggregate , ] ) ; return new JsonResponse ( $ this -> serializer -> serialize ( $ announcement ) , 201 ) ; }
|
Updates an existing announce .
|
53,249
|
public function deleteAction ( AnnouncementAggregate $ aggregate , Announcement $ announcement ) { $ this -> checkPermission ( 'EDIT' , $ aggregate -> getResourceNode ( ) , [ ] , true ) ; $ this -> crud -> delete ( $ announcement , [ 'announcement_aggregate' => $ aggregate ] ) ; return new JsonResponse ( null , 204 ) ; }
|
Deletes an announce .
|
53,250
|
public function serialize ( MatchQuestion $ setQuestion , array $ options = [ ] ) { $ serialized = [ 'random' => $ setQuestion -> getShuffle ( ) , 'penalty' => $ setQuestion -> getPenalty ( ) , ] ; $ items = array_map ( function ( Proposal $ proposal ) use ( $ options ) { $ setData = $ this -> contentSerializer -> serialize ( $ proposal , $ options ) ; $ setData [ 'id' ] = $ proposal -> getUuid ( ) ; return $ setData ; } , $ setQuestion -> getProposals ( ) -> toArray ( ) ) ; $ sets = array_map ( function ( Label $ label ) use ( $ options ) { $ itemData = $ this -> contentSerializer -> serialize ( $ label , $ options ) ; $ itemData [ 'id' ] = $ label -> getUuid ( ) ; return $ itemData ; } , $ setQuestion -> getLabels ( ) -> toArray ( ) ) ; if ( $ setQuestion -> getShuffle ( ) && in_array ( Transfer :: SHUFFLE_ANSWERS , $ options ) ) { shuffle ( $ sets ) ; shuffle ( $ items ) ; } $ serialized [ 'sets' ] = $ sets ; $ serialized [ 'items' ] = $ items ; if ( in_array ( Transfer :: INCLUDE_SOLUTIONS , $ options ) ) { $ serialized [ 'solutions' ] = $ this -> serializeSolutions ( $ setQuestion ) ; } return $ serialized ; }
|
Converts a Set question into a JSON - encodable structure .
|
53,251
|
public function deserialize ( $ data , MatchQuestion $ setQuestion = null , array $ options = [ ] ) { if ( empty ( $ setQuestion ) ) { $ setQuestion = new MatchQuestion ( ) ; } if ( ! empty ( $ data [ 'penalty' ] ) || 0 === $ data [ 'penalty' ] ) { $ setQuestion -> setPenalty ( $ data [ 'penalty' ] ) ; } $ this -> sipe ( 'random' , 'setShuffle' , $ data , $ setQuestion ) ; $ this -> deserializeLabels ( $ setQuestion , $ data [ 'sets' ] ) ; $ this -> deserializeProposals ( $ setQuestion , $ data [ 'items' ] ) ; $ this -> deserializeSolutions ( $ setQuestion , array_merge ( $ data [ 'solutions' ] [ 'associations' ] , $ data [ 'solutions' ] [ 'odd' ] ) ) ; return $ setQuestion ; }
|
Converts raw data into a Set question entity .
|
53,252
|
public function logout ( $ redirectUrl ) { if ( ! empty ( $ this -> options [ 'revoke_token_url' ] ) && $ this -> options [ 'force_login' ] === true ) { $ redirectUrl = $ this -> normalizeUrl ( $ this -> options [ 'revoke_token_url' ] , [ 'post_logout_redirect_uri' => $ redirectUrl ] ) ; } return new RedirectResponse ( $ redirectUrl ) ; }
|
Logouts User from resource Owner .
|
53,253
|
private function unlockOrLockUsers ( Dropzone $ dropzone , $ unlock = true ) { $ this -> get ( 'icap.manager.dropzone_voter' ) -> isAllowToOpen ( $ dropzone ) ; $ this -> get ( 'icap.manager.dropzone_voter' ) -> isAllowToEdit ( $ dropzone ) ; $ dropRepo = $ this -> getDoctrine ( ) -> getManager ( ) -> getRepository ( 'IcapDropzoneBundle:Drop' ) ; $ drops = $ dropRepo -> findBy ( [ 'dropzone' => $ dropzone -> getId ( ) , 'unlockedUser' => ! $ unlock ] ) ; foreach ( $ drops as $ drop ) { $ drop -> setUnlockedUser ( $ unlock ) ; } $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'icap_dropzone_examiners' , [ 'resourceId' => $ dropzone -> getId ( ) , ] ) ) ; }
|
Factorised function for lock & unlock users in a dropzone .
|
53,254
|
public function listUsersAction ( $ id , $ class , Request $ request ) { return new JsonResponse ( $ this -> finder -> search ( 'Claroline\CoreBundle\Entity\User' , array_merge ( $ request -> query -> all ( ) , [ 'hiddenFilters' => [ $ this -> getName ( ) => [ $ id ] ] ] ) ) ) ; }
|
List users of the collection .
|
53,255
|
public function addUsersAction ( $ id , $ class , Request $ request ) { $ object = $ this -> find ( $ class , $ id ) ; $ users = $ this -> decodeIdsString ( $ request , 'Claroline\CoreBundle\Entity\User' ) ; $ this -> crud -> patch ( $ object , 'user' , Crud :: COLLECTION_ADD , $ users ) ; return new JsonResponse ( $ this -> serializer -> serialize ( $ object ) ) ; }
|
Adds users to the collection .
|
53,256
|
public function removeUsersAction ( $ id , $ class , Request $ request ) { $ object = $ this -> find ( $ class , $ id ) ; $ users = $ this -> decodeIdsString ( $ request , 'Claroline\CoreBundle\Entity\User' ) ; $ this -> crud -> patch ( $ object , 'user' , Crud :: COLLECTION_REMOVE , $ users ) ; return new JsonResponse ( $ this -> serializer -> serialize ( $ object ) ) ; }
|
Removes users from the collection .
|
53,257
|
public function getUnpublishedComments ( $ blogId , $ filters ) { if ( ! isset ( $ filters [ 'hiddenFilters' ] ) ) { $ filters [ 'hiddenFilters' ] = [ ] ; } $ filters [ 'hiddenFilters' ] = array_merge ( $ filters [ 'hiddenFilters' ] , [ 'blog' => $ blogId , 'status' => false , ] ) ; return $ this -> finder -> search ( 'Icap\BlogBundle\Entity\Comment' , $ filters ) ; }
|
Get unpublished comments .
|
53,258
|
public function getReportedComments ( $ blogId , $ filters ) { if ( ! isset ( $ filters [ 'hiddenFilters' ] ) ) { $ filters [ 'hiddenFilters' ] = [ ] ; } $ filters [ 'hiddenFilters' ] = array_merge ( $ filters [ 'hiddenFilters' ] , [ 'blog' => $ blogId , 'reported' => 1 , ] ) ; return $ this -> finder -> search ( 'Icap\BlogBundle\Entity\Comment' , $ filters ) ; }
|
Get reported comments .
|
53,259
|
public function getComments ( $ blogId , $ postId , $ userId , $ filters , $ allowedToSeeOnly ) { if ( ! isset ( $ filters [ 'hiddenFilters' ] ) ) { $ filters [ 'hiddenFilters' ] = [ ] ; } $ filters [ 'hiddenFilters' ] = [ 'blog' => $ blogId , 'post' => $ postId , ] ; if ( $ allowedToSeeOnly ) { if ( null === $ userId ) { $ options = [ 'publishedOnly' => true , ] ; } else { $ options = [ 'allowedToSeeForUser' => $ userId , ] ; } $ filters [ 'hiddenFilters' ] = array_merge ( $ filters [ 'hiddenFilters' ] , $ options ) ; } return $ this -> finder -> search ( 'Icap\BlogBundle\Entity\Comment' , $ filters ) ; }
|
Get comments .
|
53,260
|
public function publishComment ( Blog $ blog , Comment $ existingComment ) { $ existingComment -> publish ( ) ; if ( BlogOptions :: COMMENT_MODERATION_PRIOR_ONCE === $ blog -> getOptions ( ) -> getCommentModerationMode ( ) && null !== $ existingComment -> getAuthor ( ) ) { if ( 0 === count ( $ this -> memberRepo -> getTrustedMember ( $ blog , $ existingComment -> getAuthor ( ) ) ) ) { $ this -> addTrustedMember ( $ blog , $ existingComment -> getAuthor ( ) ) ; } } $ this -> om -> flush ( ) ; $ this -> trackingManager -> dispatchCommentPublishEvent ( $ existingComment -> getPost ( ) , $ existingComment ) ; return $ existingComment ; }
|
Publish a comment .
|
53,261
|
private function addTrustedMember ( Blog $ blog , User $ user ) { $ member = new Member ( ) ; $ member -> setBlog ( $ blog ) ; $ member -> setUser ( $ user ) ; $ member -> setTrusted ( true ) ; $ this -> om -> persist ( $ member ) ; $ this -> om -> flush ( ) ; return $ member ; }
|
Add a trusted member to the blog can write comment without verification from a moderator .
|
53,262
|
public function addBannedMember ( Blog $ blog , User $ user ) { $ member = new Member ( ) ; $ member -> setBlog ( blog ) ; $ member -> setUser ( $ user ) ; $ member -> setBanned ( true ) ; $ this -> om -> persist ( $ member ) ; $ this -> om -> flush ( ) ; return $ member ; }
|
Add a banned member to the blog cannot write comment .
|
53,263
|
public function reportComment ( Blog $ blog , Comment $ existingComment ) { $ existingComment -> setReported ( $ existingComment -> getReported ( ) + 1 ) ; $ this -> om -> flush ( ) ; return $ existingComment ; }
|
Report a comment .
|
53,264
|
public function unpublishComment ( Blog $ blog , Comment $ existingComment ) { $ existingComment -> unpublish ( ) ; $ this -> om -> flush ( ) ; $ this -> trackingManager -> dispatchCommentPublishEvent ( $ existingComment -> getPost ( ) , $ existingComment ) ; return $ existingComment ; }
|
unpublish a comment .
|
53,265
|
public function addFieldValue ( FieldValue $ fieldValue ) { if ( ! $ this -> fieldValues -> contains ( $ fieldValue ) ) { $ this -> fieldValues -> add ( $ fieldValue ) ; } }
|
Add a field value .
|
53,266
|
public function removeValue ( FieldValue $ fieldValue ) { if ( $ this -> fieldValues -> contains ( $ fieldValue ) ) { $ this -> fieldValues -> removeElement ( $ fieldValue ) ; } }
|
Remove a field value .
|
53,267
|
public function addKeyword ( Keyword $ keyword ) { if ( ! $ this -> keywords -> contains ( $ keyword ) ) { $ this -> keywords -> add ( $ keyword ) ; } }
|
Add keyword .
|
53,268
|
public function removeKeyword ( Keyword $ keyword ) { if ( $ this -> keywords -> contains ( $ keyword ) ) { $ this -> keywords -> removeElement ( $ keyword ) ; } }
|
Remove keyword .
|
53,269
|
public function format ( $ format , array $ data , $ options ) { $ adapter = $ this -> getAdapter ( $ format ) ; return $ adapter -> format ( $ data , $ options ) ; }
|
Format a list of data for the export .
|
53,270
|
public function explainAction ( $ actionName , $ format ) { $ adapter = $ this -> getAdapter ( $ format ) ; $ action = $ this -> getExecutor ( $ actionName ) ; if ( ! $ action -> supports ( $ format ) ) { throw new \ Exception ( 'This action is not supported for the ' . $ format . ' format.' ) ; } $ schema = $ action -> getSchema ( ) ; if ( array_key_exists ( '$root' , $ schema ) ) { $ jsonSchema = $ this -> serializer -> getSchema ( $ schema [ '$root' ] ) ; if ( $ jsonSchema ) { return $ adapter -> explainSchema ( $ jsonSchema , $ action -> getMode ( ) ) ; } } $ identifiersSchema = [ ] ; foreach ( $ schema as $ prop => $ value ) { if ( $ this -> serializer -> has ( $ value ) ) { $ identifiersSchema [ $ prop ] = $ this -> serializer -> getSchema ( $ value ) ; } else { $ identifiersSchema [ $ prop ] = $ value ; } } return $ adapter -> explainIdentifiers ( $ identifiersSchema ) ; }
|
Returns the AbstractAction object for an given action .
|
53,271
|
public function getAdapter ( $ mimeTypes ) { $ mimeTypes = explode ( ';' , $ mimeTypes ) ; foreach ( $ mimeTypes as $ mimeType ) { foreach ( $ this -> adapters as $ adapter ) { if ( in_array ( ltrim ( $ mimeType ) , $ adapter -> getMimeTypes ( ) ) ) { return $ adapter ; } } } throw new \ Exception ( 'No adapter found for mime type ' . $ mimeType ) ; }
|
Returns an adapter for a given mime type .
|
53,272
|
private function detectEncoding ( $ string ) { static $ enclist = [ 'UTF-8' , 'ASCII' , 'ISO-8859-1' , 'Windows-1252' ] ; if ( function_exists ( 'mb_detect_encoding' ) ) { return mb_detect_encoding ( $ string , $ enclist , true ) ; } $ result = false ; foreach ( $ enclist as $ item ) { try { $ sample = iconv ( $ item , $ item , $ string ) ; if ( md5 ( $ sample ) === md5 ( $ string ) ) { $ result = $ item ; break ; } } catch ( ContextErrorException $ e ) { unset ( $ e ) ; } } return $ result ; }
|
Detect if encoding is UTF - 8 ASCII ISO - 8859 - 1 or Windows - 1252 .
|
53,273
|
private function hasBreakingRepeatEvent ( SessionInterface $ session , LogGenericEvent $ event ) { $ hasBreakingRepeatEvent = false ; $ breakingSignatures = [ LogWorkspaceToolReadEvent :: ACTION , LogResourceReadEvent :: ACTION , LogDesktopToolReadEvent :: ACTION , LogAdminToolReadEvent :: ACTION , ] ; $ breakingWorkspaceSignatures = [ LogDesktopToolReadEvent :: ACTION , LogAdminToolReadEvent :: ACTION , ] ; if ( $ event -> getIsWorkspaceEnterEvent ( ) || $ event -> getIsToolReadEvent ( ) || $ event -> getIsResourceReadEvent ( ) ) { if ( ! is_null ( $ session -> get ( $ event -> getAction ( ) ) ) ) { $ oldArray = json_decode ( $ session -> get ( $ event -> getAction ( ) ) ) ; $ oldSignature = $ oldArray -> logSignature ; $ oldTime = $ oldArray -> time ; foreach ( $ breakingSignatures as $ breakingSignature ) { if ( ( ( $ event -> getIsWorkspaceEnterEvent ( ) && in_array ( $ breakingSignature , $ breakingWorkspaceSignatures ) ) || ( ! $ event -> getIsWorkspaceEnterEvent ( ) && $ oldSignature !== $ breakingSignature ) ) && $ session -> get ( $ breakingSignature ) ) { $ breakingArray = json_decode ( $ session -> get ( $ breakingSignature ) ) ; if ( $ oldTime < $ breakingArray -> time ) { $ hasBreakingRepeatEvent = true ; break ; } } } } } return $ hasBreakingRepeatEvent ; }
|
Checks if a tool has been opened between 2 resources opening . If it is the case the resource opening will not be labelled as a repeat even if it is the same resource . The same is checked between 2 tools opening .
|
53,274
|
public function serialize ( Field $ field , array $ options = [ ] ) { $ serialized = [ 'id' => $ field -> getUuid ( ) , 'autoId' => $ field -> getId ( ) , 'name' => $ field -> getName ( ) , 'label' => $ field -> getName ( ) , 'type' => $ field -> getFieldType ( ) , 'required' => $ field -> isRequired ( ) , 'help' => $ field -> getHelp ( ) , 'restrictions' => [ 'isMetadata' => $ field -> getIsMetadata ( ) , 'locked' => $ field -> isLocked ( ) , 'lockedEditionOnly' => $ field -> getLockedEditionOnly ( ) , 'hidden' => $ field -> isHidden ( ) , 'order' => $ field -> getOrder ( ) , ] , ] ; if ( count ( $ field -> getDetails ( ) ) > 0 ) { $ serialized [ 'options' ] = $ field -> getDetails ( ) ; } if ( in_array ( $ field -> getType ( ) , [ FieldFacet :: CHOICE_TYPE , FieldFacet :: CASCADE_TYPE ] ) ) { $ serialized [ 'options' ] [ 'choices' ] = array_map ( function ( FieldFacetChoice $ choice ) { return $ this -> fieldFacetChoiceSerializer -> serialize ( $ choice ) ; } , $ field -> getFieldFacet ( ) -> getRootFieldFacetChoices ( ) ) ; } if ( ! in_array ( Options :: SERIALIZE_MINIMAL , $ options ) ) { $ serialized = array_merge ( $ serialized , [ 'fieldFacet' => $ this -> fieldFacetSerializer -> serialize ( $ field -> getFieldFacet ( ) ) , ] ) ; } else { $ serialized = array_merge ( $ serialized , [ 'fieldFacet' => [ 'id' => $ field -> getUuid ( ) , ] , ] ) ; } return $ serialized ; }
|
Serializes a Field entity for the JSON api .
|
53,275
|
public function checkCreation ( TokenInterface $ token , $ object ) { return $ this -> manager -> isAllowedBadgeManagement ( $ token , $ object -> getBadge ( ) ) ; }
|
ready to be overrided
|
53,276
|
public function parseOrganizationsNode ( \ DOMDocument $ dom ) { $ organizationsList = $ dom -> getElementsByTagName ( 'organizations' ) ; $ resources = $ dom -> getElementsByTagName ( 'resource' ) ; if ( $ organizationsList -> length > 0 ) { $ organizations = $ organizationsList -> item ( 0 ) ; $ organization = $ organizations -> firstChild ; if ( ! is_null ( $ organizations -> attributes ) && ! is_null ( $ organizations -> attributes -> getNamedItem ( 'default' ) ) ) { $ defaultOrganization = $ organizations -> attributes -> getNamedItem ( 'default' ) -> nodeValue ; } else { $ defaultOrganization = null ; } if ( is_null ( $ defaultOrganization ) ) { while ( ! is_null ( $ organization ) && 'organization' !== $ organization -> nodeName ) { $ organization = $ organization -> nextSibling ; } if ( is_null ( $ organization ) ) { return $ this -> parseResourceNodes ( $ resources ) ; } } else { while ( ! is_null ( $ organization ) && ( 'organization' !== $ organization -> nodeName || is_null ( $ organization -> attributes -> getNamedItem ( 'identifier' ) ) || $ organization -> attributes -> getNamedItem ( 'identifier' ) -> nodeValue !== $ defaultOrganization ) ) { $ organization = $ organization -> nextSibling ; } if ( is_null ( $ organization ) ) { throw new InvalidScormArchiveException ( 'default_organization_not_found_message' ) ; } } return $ this -> parseItemNodes ( $ organization , $ resources ) ; } else { throw new InvalidScormArchiveException ( 'no_organization_found_message' ) ; } }
|
Looks for the organization to use .
|
53,277
|
private function parseItemNodes ( \ DOMNode $ source , \ DOMNodeList $ resources , Sco $ parentSco = null ) { $ item = $ source -> firstChild ; $ scos = [ ] ; while ( ! is_null ( $ item ) ) { if ( 'item' === $ item -> nodeName ) { $ sco = new Sco ( ) ; $ scos [ ] = $ sco ; $ sco -> setScoParent ( $ parentSco ) ; $ this -> findAttrParams ( $ sco , $ item , $ resources ) ; $ this -> findNodeParams ( $ sco , $ item -> firstChild ) ; if ( $ sco -> isBlock ( ) ) { $ sco -> setScoChildren ( $ this -> parseItemNodes ( $ item , $ resources , $ sco ) ) ; } } $ item = $ item -> nextSibling ; } return $ scos ; }
|
Creates defined structure of SCOs .
|
53,278
|
private function findAttrParams ( Sco $ sco , \ DOMNode $ item , \ DOMNodeList $ resources ) { $ identifier = $ item -> attributes -> getNamedItem ( 'identifier' ) ; $ isVisible = $ item -> attributes -> getNamedItem ( 'isvisible' ) ; $ identifierRef = $ item -> attributes -> getNamedItem ( 'identifierref' ) ; $ parameters = $ item -> attributes -> getNamedItem ( 'parameters' ) ; if ( is_null ( $ identifier ) ) { throw new InvalidScormArchiveException ( 'sco_with_no_identifier_message' ) ; } $ sco -> setIdentifier ( $ identifier -> nodeValue ) ; if ( ! is_null ( $ isVisible ) && 'false' === $ isVisible ) { $ sco -> setVisible ( false ) ; } else { $ sco -> setVisible ( true ) ; } if ( ! is_null ( $ parameters ) ) { $ sco -> setParameters ( $ parameters -> nodeValue ) ; } if ( is_null ( $ identifierRef ) ) { $ sco -> setBlock ( true ) ; } else { $ sco -> setBlock ( false ) ; $ sco -> setEntryUrl ( $ this -> findEntryUrl ( $ identifierRef -> nodeValue , $ resources ) ) ; } }
|
Initializes parameters of the SCO defined in attributes of the node . It also look for the associated resource if it is a SCO and not a block .
|
53,279
|
private function findNodeParams ( Sco $ sco , \ DOMNode $ item ) { while ( ! is_null ( $ item ) ) { switch ( $ item -> nodeName ) { case 'title' : $ sco -> setTitle ( $ item -> nodeValue ) ; break ; case 'adlcp:masteryscore' : $ sco -> setScoreToPassInt ( $ item -> nodeValue ) ; break ; case 'adlcp:maxtimeallowed' : case 'imsss:attemptAbsoluteDurationLimit' : $ sco -> setMaxTimeAllowed ( $ item -> nodeValue ) ; break ; case 'adlcp:timelimitaction' : case 'adlcp:timeLimitAction' : $ action = strtolower ( $ item -> nodeValue ) ; if ( 'exit,message' === $ action || 'exit,no message' === $ action || 'continue,message' === $ action || 'continue,no message' === $ action ) { $ sco -> setTimeLimitAction ( $ action ) ; } break ; case 'adlcp:datafromlms' : case 'adlcp:dataFromLMS' : $ sco -> setLaunchData ( $ item -> nodeValue ) ; break ; case 'adlcp:prerequisites' : $ sco -> setPrerequisites ( $ item -> nodeValue ) ; break ; case 'imsss:minNormalizedMeasure' : $ sco -> setScoreToPassDecimal ( $ item -> nodeValue ) ; break ; case 'adlcp:completionThreshold' : $ sco -> setCompletionThreshold ( $ item -> nodeValue ) ; break ; } $ item = $ item -> nextSibling ; } }
|
Initializes parameters of the SCO defined in children nodes .
|
53,280
|
public function findEntryUrl ( $ identifierref , \ DOMNodeList $ resources ) { foreach ( $ resources as $ resource ) { $ identifier = $ resource -> attributes -> getNamedItem ( 'identifier' ) ; if ( ! is_null ( $ identifier ) ) { $ identifierValue = $ identifier -> nodeValue ; if ( $ identifierValue === $ identifierref ) { $ href = $ resource -> attributes -> getNamedItem ( 'href' ) ; if ( is_null ( $ href ) ) { throw new InvalidScormArchiveException ( 'sco_resource_without_href_message' ) ; } return $ href -> nodeValue ; } } } throw new InvalidScormArchiveException ( 'sco_without_resource_message' ) ; }
|
Searches for the resource with the given id and retrieve URL to its content .
|
53,281
|
public function setGradingCriteria ( \ Innova \ CollecticielBundle \ Entity \ GradingCriteria $ gradingCriteria ) { $ this -> gradingCriteria = $ gradingCriteria ; return $ this ; }
|
Set gradingCriteria .
|
53,282
|
public function setNotation ( \ Innova \ CollecticielBundle \ Entity \ Notation $ notation ) { $ this -> notation = $ notation ; return $ this ; }
|
Set notation .
|
53,283
|
public function findUnfinishedPapers ( Exercise $ exercise , User $ user ) { return $ this -> createQueryBuilder ( 'p' ) -> where ( 'p.user = :user' ) -> andWhere ( 'p.exercise = :exercise' ) -> andWhere ( 'p.end IS NULL' ) -> orderBy ( 'p.start' , 'DESC' ) -> setParameters ( [ 'user' => $ user , 'exercise' => $ exercise , ] ) -> getQuery ( ) -> getResult ( ) ; }
|
Returns the unfinished papers of a user for a given exercise if any .
|
53,284
|
public function countUserFinishedDayPapers ( Exercise $ exercise , User $ user ) { $ today = new \ DateTime ( ) ; $ today -> setTime ( 0 , 0 ) ; $ tomorrow = clone $ today ; $ tomorrow -> add ( new \ DateInterval ( 'P1D' ) ) ; return ( int ) $ this -> getEntityManager ( ) -> createQuery ( ' SELECT COUNT(p) FROM UJM\ExoBundle\Entity\Attempt\Paper AS p WHERE p.user = :user AND p.exercise = :exercise AND p.end >= :today AND p.end <= :tomorrow ' ) -> setParameters ( [ 'user' => $ user , 'exercise' => $ exercise , 'today' => $ today , 'tomorrow' => $ tomorrow , ] ) -> getSingleScalarResult ( ) ; }
|
Returns the unfinished papers of a user for a given exercise for the current day if any .
|
53,285
|
public function findScore ( Paper $ paper ) { return ( float ) $ this -> getEntityManager ( ) -> createQuery ( ' SELECT SUM(a.score) FROM UJM\ExoBundle\Entity\Attempt\Answer AS a WHERE a.paper = :paper AND a.score IS NOT NULL ' ) -> setParameters ( [ 'paper' => $ paper , ] ) -> getSingleScalarResult ( ) ; }
|
Finds the score of a paper by summing the score of each answer .
|
53,286
|
public function isFullyEvaluated ( Paper $ paper ) { return 0 === ( int ) $ this -> getEntityManager ( ) -> createQuery ( ' SELECT COUNT(a) FROM UJM\ExoBundle\Entity\Attempt\Answer AS a WHERE a.paper = :paper AND a.score IS NULL ' ) -> setParameters ( [ 'paper' => $ paper , ] ) -> getSingleScalarResult ( ) ; }
|
Checks that all the answers of a Paper have been marked .
|
53,287
|
public function countExercisePapers ( Exercise $ exercise ) { return ( int ) $ this -> getEntityManager ( ) -> createQuery ( ' SELECT COUNT(p) FROM UJM\ExoBundle\Entity\Attempt\Paper AS p WHERE p.exercise = :exercise ' ) -> setParameters ( [ 'exercise' => $ exercise , ] ) -> getSingleScalarResult ( ) ; }
|
Returns the number of papers for an exercise .
|
53,288
|
public function countUserFinishedPapers ( Exercise $ exercise , User $ user ) { return ( int ) $ this -> getEntityManager ( ) -> createQuery ( ' SELECT COUNT(p) FROM UJM\ExoBundle\Entity\Attempt\Paper AS p WHERE p.user = :user AND p.exercise = :exercise AND p.end IS NOT NULL ' ) -> setParameters ( [ 'user' => $ user , 'exercise' => $ exercise , ] ) -> getSingleScalarResult ( ) ; }
|
Counts the number of finished paper for a user and an exercise .
|
53,289
|
private function createAccess ( $ randomId , $ secret , $ token , FriendRequest $ request ) { $ access = $ this -> om -> getRepository ( 'Claroline\CoreBundle\Entity\Oauth\ClarolineAccess' ) -> findOneByRandomId ( $ randomId ) ; if ( $ access === null ) { $ access = new ClarolineAccess ( ) ; } $ access -> setRandomId ( $ randomId ) ; $ access -> setSecret ( $ secret ) ; $ access -> setAccessToken ( $ token ) ; $ request -> setIsActivated ( true ) ; $ access -> setFriendRequest ( $ request ) ; $ this -> om -> persist ( $ request ) ; $ this -> om -> persist ( $ access ) ; $ this -> om -> flush ( ) ; return $ access ; }
|
Only 1 access per client !
|
53,290
|
protected function isOrganizationManager ( TokenInterface $ token , $ object ) { $ adminOrganizations = $ token -> getUser ( ) -> getAdministratedOrganizations ( ) ; $ objectOrganizations = $ object -> getOrganizations ( ) ; foreach ( $ adminOrganizations as $ adminOrganization ) { foreach ( $ objectOrganizations as $ objectOrganization ) { if ( $ objectOrganization === $ adminOrganization ) { return true ; } } } return false ; }
|
Copied from the AbstractVoter .
|
53,291
|
public function getEntityRoles ( $ areGroupsIncluded = true ) { $ roles = [ ] ; if ( $ this -> roles ) { $ roles = $ this -> roles -> toArray ( ) ; } if ( $ areGroupsIncluded ) { foreach ( $ this -> groups as $ group ) { foreach ( $ group -> getEntityRoles ( ) as $ role ) { if ( ! in_array ( $ role , $ roles ) ) { $ roles [ ] = $ role ; } } } } return $ roles ; }
|
Returns the user s roles as an array of entities . The roles owned by groups the user is a member are included by default .
|
53,292
|
public function getGroupRoles ( ) { $ roles = [ ] ; foreach ( $ this -> groups as $ group ) { foreach ( $ group -> getEntityRoles ( ) as $ role ) { if ( ! in_array ( $ role , $ roles ) ) { $ roles [ ] = $ role ; } } } return $ roles ; }
|
Returns the roles owned by groups the user is a member .
|
53,293
|
public function hasRole ( $ roleName , $ includeGroup = true ) { $ roles = $ this -> getEntityRoles ( $ includeGroup ) ; $ roleNames = array_map ( function ( Role $ role ) { return $ role -> getName ( ) ; } , $ roles ) ; return in_array ( $ roleName , $ roleNames ) ; }
|
Checks if the user has a given role .
|
53,294
|
public function serialize ( array $ options = [ ] ) { $ facets = $ this -> repository -> findVisibleFacets ( $ this -> tokenStorage -> getToken ( ) , in_array ( Options :: REGISTRATION , $ options ) ) ; return array_map ( function ( Facet $ facet ) { return $ this -> facetSerializer -> serialize ( $ facet , [ Options :: PROFILE_SERIALIZE ] ) ; } , $ facets ) ; }
|
Serializes the profile configuration .
|
53,295
|
public function serialize ( Plugin $ plugin , array $ options = [ ] ) { return [ 'id' => $ plugin -> getId ( ) , 'name' => $ plugin -> getShortName ( ) , 'vendor' => $ plugin -> getVendorName ( ) , 'bundle' => $ plugin -> getBundleName ( ) , ] ; }
|
Serializes a Plugin entity .
|
53,296
|
public function deserialize ( $ data , Plugin $ plugin , array $ options = [ ] ) { $ this -> sipe ( 'id' , 'setUuid' , $ data , $ plugin ) ; $ this -> sipe ( 'name' , 'setDisplayName' , $ data , $ plugin ) ; $ this -> sipe ( 'vendor' , 'setVendorName' , $ data , $ plugin ) ; $ this -> sipe ( 'bundle' , 'setBundleName' , $ data , $ plugin ) ; return $ plugin ; }
|
Deserializes data into a Plugin entity .
|
53,297
|
public function deserialize ( $ data , ResourceNode $ resourceNode = null , array $ options = [ ] ) { if ( empty ( $ resourceNode ) ) { $ id = method_exists ( $ data , 'getId' ) ? $ data -> getId ( ) : $ data [ 'id' ] ; $ resourceNode = $ this -> om -> getRepository ( 'ClarolineCoreBundle:Resource\ResourceNode' ) -> find ( $ id ) ; } return $ resourceNode ; }
|
Converts raw data into a ResourceNode .
|
53,298
|
public function inject ( PlatformConfigurationHandler $ config , IPWhiteListManager $ whiteListManager ) { $ this -> config = $ config ; $ this -> whiteListManager = $ whiteListManager ; }
|
IpAuthenticator constructor .
|
53,299
|
public function getIncludeUserIds ( ) { $ ids = [ ] ; $ id = $ this -> drop -> getUser ( ) -> getId ( ) ; array_push ( $ ids , $ id ) ; return $ ids ; }
|
Get includeUsers array of user ids . Reports are only reported to user witch have the manager role .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.