idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
49,500
public function breadcrumbs ( $ route , $ parsedRoute ) { if ( isset ( $ parsedRoute [ 'action' ] ) ) { switch ( $ parsedRoute [ 'action' ] ) { case 'index' : return $ this -> breadcrumbsIndex ( $ route , $ parsedRoute ) ; } } return null ; }
Builds breadcrumbs for a particular route .
49,501
protected function getDeliveries ( ) { $ service = $ this -> getServiceManager ( ) -> get ( ProctorService :: SERVICE_ID ) ; $ proctor = \ common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ context = $ this -> hasRequestParameter ( 'context' ) ? $ this -> getRequestParameter ( 'context' ) : null ; $ deliveries = $ service -> getProctorableDeliveries ( $ proctor , $ context ) ; $ data = array ( ) ; foreach ( $ deliveries as $ delivery ) { $ executions = $ service -> getProctorableDeliveryExecutions ( $ proctor , $ delivery , $ context ) ; $ deliveryData = DeliveryHelper :: buildDeliveryData ( $ delivery , $ executions ) ; $ deliveryData [ 'url' ] = _url ( 'index' , 'Monitor' , null , is_null ( $ context ) ? [ 'delivery' => $ delivery -> getUri ( ) ] : [ 'delivery' => $ delivery -> getUri ( ) , 'context' => $ context ] ) ; $ data [ ] = $ deliveryData ; } return $ data ; }
Lists all available deliveries
49,502
public function get ( $ deliveryExecutionId , $ eventId = null ) { $ queryBuilder = $ this -> getQueryBuilder ( ) ; $ queryBuilder -> select ( '*' ) -> from ( static :: TABLE_NAME ) -> where ( static :: DELIVERY_EXECUTION_ID . '=:delivery_execution_id' ) -> setParameter ( 'delivery_execution_id' , $ deliveryExecutionId ) ; if ( $ eventId !== null ) { $ queryBuilder -> andWhere ( static :: EVENT_ID . '=:event_id' ) -> setParameter ( 'event_id' , $ eventId ) ; ; } $ queryBuilder -> orderBy ( static :: ID , 'ASC' ) ; $ data = $ queryBuilder -> execute ( ) -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ result = $ this -> decodeValues ( $ data ) ; return $ result ; }
Get logged data by delivery execution id
49,503
public function getProctorableDeliveries ( User $ proctor , $ context = null ) { return DeliveryAssemblyService :: singleton ( ) -> getRootClass ( ) -> searchInstances ( array ( self :: ACCESSIBLE_PROCTOR => self :: ACCESSIBLE_PROCTOR_ENABLED ) , array ( 'recursive' => true ) ) ; }
Gets all deliveries available for a proctor
49,504
private function isProctoredDelivery ( \ core_kernel_classes_Resource $ delivery ) { $ hasProctor = $ delivery -> getOnePropertyValue ( $ this -> getProperty ( ProctorService :: ACCESSIBLE_PROCTOR ) ) ; $ result = $ hasProctor instanceof \ core_kernel_classes_Resource && $ hasProctor -> getUri ( ) == ProctorService :: ACCESSIBLE_PROCTOR_ENABLED ; return $ result ; }
Check whether secure plugins must be used .
49,505
public function check ( RunnerServiceContext $ context ) { parent :: check ( $ context ) ; $ state = $ context -> getTestSession ( ) -> getState ( ) ; if ( $ state == AssessmentTestSessionState :: SUSPENDED ) { throw new QtiRunnerPausedException ( ) ; } return true ; }
Check whether the test is in a runnable state .
49,506
protected function buildData ( DeliveryExecutionInterface $ deliveryExecution , $ data ) { $ dataObject = $ this -> createMonitoringData ( $ deliveryExecution , $ data ) ; return $ dataObject ; }
Ensure that all DeliveryMonitoringData are unique per delivery execution id
49,507
protected function loadData ( $ deliveryExecutionId ) { $ qb = $ this -> getPersistence ( ) -> getPlatForm ( ) -> getQueryBuilder ( ) ; $ qb -> select ( '*' ) -> from ( self :: TABLE_NAME ) -> where ( self :: DELIVERY_EXECUTION_ID . '= :deid' ) -> setParameter ( 'deid' , $ deliveryExecutionId ) ; $ data = $ qb -> execute ( ) -> fetch ( \ PDO :: FETCH_ASSOC ) ; $ kvData = $ this -> getKvData ( [ $ deliveryExecutionId ] ) ; if ( isset ( $ kvData [ $ deliveryExecutionId ] ) ) { $ data = array_merge ( $ data , $ kvData [ $ deliveryExecutionId ] ) ; } return $ data ; }
Load data instead of searching Returns false on failure
49,508
public function find ( array $ criteria = [ ] , array $ options = [ ] , $ together = false ) { $ result = [ ] ; $ this -> joins = [ ] ; $ this -> queryParams = [ ] ; $ this -> selectColumns = $ this -> getPrimaryColumns ( ) ; $ this -> groupColumns = [ 't.delivery_execution_id' ] ; $ defaultOptions = [ 'order' => join ( ' ' , [ static :: DEFAULT_SORT_COLUMN , static :: DEFAULT_SORT_ORDER , static :: DEFAULT_SORT_TYPE ] ) , 'offset' => 0 , 'asArray' => false ] ; $ options = array_merge ( $ defaultOptions , $ options ) ; $ options [ 'order' ] = $ this -> prepareOrderStmt ( $ options [ 'order' ] ) ; $ fromClause = "FROM " . self :: TABLE_NAME . " t " ; $ whereClause = $ this -> prepareCondition ( $ criteria , $ this -> queryParams , $ selectClause ) ; if ( $ whereClause !== '' ) { $ whereClause = 'WHERE ' . $ whereClause ; } $ selectClause = "SELECT " . implode ( ',' , $ this -> selectColumns ) ; $ sql = $ selectClause . ' ' . $ fromClause . PHP_EOL . implode ( PHP_EOL , $ this -> joins ) . PHP_EOL . $ whereClause . PHP_EOL . 'GROUP BY ' . implode ( ',' , $ this -> groupColumns ) . PHP_EOL ; $ sql .= "ORDER BY " . $ options [ 'order' ] ; if ( isset ( $ options [ 'limit' ] ) ) { $ sql = $ this -> getPersistence ( ) -> getPlatForm ( ) -> limitStatement ( $ sql , $ options [ 'limit' ] , $ options [ 'offset' ] ) ; } $ stmt = $ this -> getPersistence ( ) -> query ( $ sql , $ this -> queryParams ) ; $ data = $ stmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; if ( $ together ) { $ ids = array_column ( $ data , static :: COLUMN_ID ) ; $ kvData = $ this -> getKvData ( $ ids ) ; foreach ( $ data as & $ row ) { if ( isset ( $ kvData [ $ row [ static :: COLUMN_ID ] ] ) ) { $ row = array_merge ( $ row , $ kvData [ $ row [ static :: COLUMN_ID ] ] ) ; } } unset ( $ row ) ; } if ( $ options [ 'asArray' ] ) { $ result = $ data ; } else { foreach ( $ data as $ row ) { $ deliveryExecution = ServiceProxy :: singleton ( ) -> getDeliveryExecution ( $ row [ self :: COLUMN_DELIVERY_EXECUTION_ID ] ) ; $ result [ ] = $ this -> buildData ( $ deliveryExecution , $ row ) ; } } return $ result ; }
Find delivery monitoring data .
49,509
protected function getKvData ( array $ ids ) { if ( empty ( $ ids ) ) { return [ ] ; } $ result = [ ] ; $ sql = 'SELECT * FROM ' . self :: KV_TABLE_NAME . ' WHERE ' . self :: KV_COLUMN_PARENT_ID . ' IN(' . join ( ',' , array_map ( function ( ) { return '?' ; } , $ ids ) ) . ')' ; $ secondaryData = $ this -> getPersistence ( ) -> query ( $ sql , $ ids ) -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; foreach ( $ secondaryData as $ data ) { $ result [ $ data [ self :: KV_COLUMN_PARENT_ID ] ] [ $ data [ self :: KV_COLUMN_KEY ] ] = $ data [ self :: KV_COLUMN_VALUE ] ; } return $ result ; }
Get secondary data by parent data id
49,510
protected function isNewRecord ( DeliveryMonitoringDataInterface $ deliveryMonitoring ) { $ data = $ deliveryMonitoring -> get ( ) ; $ deliveryExecutionId = $ data [ self :: COLUMN_DELIVERY_EXECUTION_ID ] ; $ sql = "SELECT EXISTS( " . PHP_EOL . "SELECT " . self :: COLUMN_DELIVERY_EXECUTION_ID . PHP_EOL . "FROM " . self :: TABLE_NAME . PHP_EOL . "WHERE " . self :: COLUMN_DELIVERY_EXECUTION_ID . "=?)" ; $ exists = $ this -> getPersistence ( ) -> query ( $ sql , [ $ deliveryExecutionId ] ) -> fetch ( \ PDO :: FETCH_COLUMN ) ; return ! ( ( boolean ) $ exists ) ; }
Check if record for delivery execution already exists in the storage .
49,511
public function deliveryLabelChanged ( MetadataModified $ event ) { $ resource = $ event -> getResource ( ) ; if ( $ event -> getMetadataUri ( ) === OntologyRdfs :: RDFS_LABEL ) { $ assemblyClass = DeliveryAssemblyService :: singleton ( ) -> getRootClass ( ) ; if ( $ resource -> isInstanceOf ( $ assemblyClass ) ) { $ queueService = $ this -> getServiceLocator ( ) -> get ( QueueDispatcherInterface :: SERVICE_ID ) ; $ queueService -> createTask ( new DeliveryUpdaterTask ( ) , [ $ resource -> getUri ( ) , $ event -> getMetadataValue ( ) ] , 'Update delivery label' ) ; } } }
Update the label of the delivery across the entrie cache
49,512
public function deliveryAuthorized ( AuthorizationGranted $ event ) { $ deliveryExecution = $ event -> getDeliveryExecution ( ) ; $ data = $ this -> createMonitoringData ( $ deliveryExecution ) ; $ data -> update ( DeliveryMonitoringService :: AUTHORIZED_BY , $ event -> getAuthorizer ( ) -> getIdentifier ( ) ) ; if ( ! $ this -> partialSave ( $ data ) ) { \ common_Logger :: w ( 'monitor cache for authorization could not be updated' ) ; } }
Sets the protor who authorized this delivery execution
49,513
private function updateStatus ( ) { $ status = $ this -> deliveryExecution -> getState ( ) -> getUri ( ) ; $ this -> addValue ( DeliveryMonitoringService :: STATUS , $ status , true ) ; if ( $ status == ProctoredDeliveryExecution :: STATE_PAUSED ) { $ this -> addValue ( DeliveryMonitoringService :: LAST_PAUSE_TIMESTAMP , microtime ( true ) , true ) ; } }
Update test session state
49,514
private function updateRemainingTime ( ) { $ result = null ; $ remaining = 0 ; $ hasTimer = false ; $ session = $ this -> getTestSession ( ) ; if ( $ session !== null && $ session -> isRunning ( ) ) { $ remaining = PHP_INT_MAX ; $ timeConstraints = $ session -> getTimeConstraints ( ) ; foreach ( $ timeConstraints as $ tc ) { $ maximumRemainingTime = $ tc -> getMaximumRemainingTime ( ) ; if ( $ maximumRemainingTime !== false ) { $ hasTimer = true ; $ remaining = min ( $ remaining , $ maximumRemainingTime -> getSeconds ( true ) ) ; } } } if ( $ hasTimer ) { $ result = $ remaining ; } $ this -> addValue ( DeliveryMonitoringService :: REMAINING_TIME , $ result , true ) ; }
Update remaining time of delivery execution
49,515
private function updateDiffTimestamp ( ) { $ diffTimestamp = 0 ; $ lastTimeStamp = 0 ; $ lastActivity = 0 ; if ( isset ( $ this -> data [ DeliveryMonitoringService :: LAST_PAUSE_TIMESTAMP ] ) ) { $ lastTimeStamp = $ this -> data [ DeliveryMonitoringService :: LAST_PAUSE_TIMESTAMP ] ; } if ( isset ( $ this -> data [ DeliveryMonitoringService :: LAST_TEST_TAKER_ACTIVITY ] ) ) { $ lastActivity = $ this -> data [ DeliveryMonitoringService :: LAST_TEST_TAKER_ACTIVITY ] ; } if ( $ lastTimeStamp - $ lastActivity > 0 ) { $ diffTimestamp = isset ( $ this -> data [ DeliveryMonitoringService :: DIFF_TIMESTAMP ] ) ? $ this -> data [ DeliveryMonitoringService :: DIFF_TIMESTAMP ] : 0 ; $ diffTimestamp += $ lastTimeStamp - $ lastActivity ; } $ this -> addValue ( DeliveryMonitoringService :: DIFF_TIMESTAMP , $ diffTimestamp , true ) ; }
Update diff between last_pause_timestamp and last_test_taker_activity
49,516
private function updateExtraTime ( ) { $ testSession = $ this -> getTestSession ( ) ; if ( $ testSession instanceof TestSession ) { $ timer = $ testSession -> getTimer ( ) ; $ timerTarget = $ testSession -> getTimerTarget ( ) ; } else { $ timerTarget = TimePoint :: TARGET_SERVER ; $ qtiTimerFactory = $ this -> getServiceLocator ( ) -> get ( QtiTimerFactory :: SERVICE_ID ) ; $ timer = $ qtiTimerFactory -> getTimer ( $ this -> deliveryExecution -> getIdentifier ( ) , $ this -> deliveryExecution -> getUserIdentifier ( ) ) ; } $ deliveryExecutionManager = $ this -> getServiceLocator ( ) -> get ( DeliveryExecutionManagerService :: SERVICE_ID ) ; $ maxTimeSeconds = $ deliveryExecutionManager -> getTimeLimits ( $ testSession ) ; $ data = $ this -> get ( ) ; $ oldConsumedExtraTime = isset ( $ data [ DeliveryMonitoringService :: CONSUMED_EXTRA_TIME ] ) ? $ data [ DeliveryMonitoringService :: CONSUMED_EXTRA_TIME ] : 0 ; $ consumedExtraTime = max ( $ oldConsumedExtraTime , $ timer -> getConsumedExtraTime ( null , $ maxTimeSeconds , $ timerTarget ) ) ; $ this -> addValue ( DeliveryMonitoringService :: EXTRA_TIME , $ timer -> getExtraTime ( $ maxTimeSeconds ) , true ) ; $ this -> addValue ( DeliveryMonitoringService :: CONSUMED_EXTRA_TIME , $ consumedExtraTime , true ) ; }
Update extra time allowed for the delivery execution
49,517
public function index ( ) { $ user = common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ startedExecutions = $ this -> service -> getResumableDeliveries ( $ user ) ; foreach ( $ startedExecutions as $ startedExecution ) { if ( $ startedExecution -> getDelivery ( ) -> exists ( ) ) { $ this -> revoke ( $ startedExecution ) ; } } parent :: index ( ) ; }
Overrides the content extension data
49,518
public function awaitingAuthorization ( ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; $ deliveryExecutionStateService = $ this -> getServiceManager ( ) -> get ( DeliveryExecutionStateService :: SERVICE_ID ) ; $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ runDeliveryUrl = _url ( 'runDeliveryExecution' , null , null , array ( 'deliveryExecution' => $ deliveryExecution -> getIdentifier ( ) ) ) ; if ( DeliveryExecutionState :: STATE_ACTIVE == $ executionState ) { $ deliveryExecutionStateService -> pauseExecution ( $ deliveryExecution , [ 'reasons' => [ 'category' => 'System' ] , 'comment' => __ ( 'System generated pause.' ) , ] ) ; } if ( ! in_array ( $ executionState , array ( DeliveryExecutionState :: STATE_FINISHED , DeliveryExecutionState :: STATE_TERMINATED ) ) ) { if ( DeliveryExecutionState :: STATE_AUTHORIZED !== $ executionState ) { $ deliveryExecutionStateService -> waitExecution ( $ deliveryExecution ) ; } $ this -> setData ( 'deliveryExecution' , $ deliveryExecution -> getIdentifier ( ) ) ; $ this -> setData ( 'deliveryLabel' , addslashes ( $ deliveryExecution -> getLabel ( ) ) ) ; $ this -> setData ( 'returnUrl' , $ this -> getReturnUrl ( ) ) ; $ this -> setData ( 'cancelUrl' , _url ( 'cancelExecution' , 'DeliveryServer' , 'taoProctoring' , [ 'deliveryExecution' => $ deliveryExecution -> getIdentifier ( ) ] ) ) ; $ this -> setData ( 'cancelable' , $ deliveryExecutionStateService -> isCancelable ( $ deliveryExecution ) ) ; $ this -> setData ( 'userLabel' , common_session_SessionManager :: getSession ( ) -> getUserLabel ( ) ) ; $ this -> setData ( 'client_config_url' , $ this -> getClientConfigUrl ( ) ) ; $ this -> setData ( 'showControls' , true ) ; $ this -> setData ( 'runDeliveryUrl' , $ runDeliveryUrl ) ; $ this -> setData ( 'homeUrl' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringHome' ) ) ; $ this -> setData ( 'logout' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringLogout' ) ) ; $ this -> setData ( 'content-template' , 'DeliveryServer/awaiting.tpl' ) ; $ this -> setData ( 'content-extension' , 'taoProctoring' ) ; $ this -> setView ( 'DeliveryServer/layout.tpl' , 'taoDelivery' ) ; } else { common_Logger :: i ( get_called_class ( ) . '::awaitingAuthorization(): cannot wait authorization for delivery execution ' . $ deliveryExecution -> getIdentifier ( ) . ' with state ' . $ executionState ) ; return $ this -> redirect ( $ this -> getReturnUrl ( ) ) ; } }
The awaiting authorization screen
49,519
public function isAuthorized ( ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ authorized = false ; $ success = true ; $ message = null ; switch ( $ executionState ) { case DeliveryExecutionState :: STATE_AUTHORIZED : $ authorized = true ; break ; case DeliveryExecutionState :: STATE_TERMINATED : case DeliveryExecutionState :: STATE_FINISHED : $ success = false ; $ message = __ ( 'The assessment has been terminated. You cannot interact with it anymore.' ) ; break ; case DeliveryExecutionState :: STATE_PAUSED : $ success = false ; $ message = __ ( 'The assessment has been suspended. To resume your assessment, please relaunch it and contact your proctor if required.' ) ; break ; } $ this -> returnJson ( array ( 'authorized' => $ authorized , 'success' => $ success , 'message' => $ message ) ) ; }
The action called to check if the requested delivery execution has been authorized by the proctor
49,520
public function cancelExecution ( ) { $ deliveryExecution = $ this -> getCurrentDeliveryExecution ( ) ; $ deliveryExecutionStateService = $ this -> getServiceManager ( ) -> get ( DeliveryExecutionStateService :: SERVICE_ID ) ; $ reason = [ 'reasons' => [ 'category' => 'Examinee' , 'subCategory' => 'Navigation' ] , ] ; if ( $ deliveryExecution -> getState ( ) -> getUri ( ) === DeliveryExecutionState :: STATE_AUTHORIZED ) { $ reason [ 'comment' ] = __ ( 'Automatically reset by the system due to the test taker choosing not to proceed with the authorized test.' ) ; } else { $ reason [ 'comment' ] = __ ( 'Automatically reset by the system due to authorization request being cancelled by test taker.' ) ; } $ deliveryExecutionStateService -> cancelExecution ( $ deliveryExecution , $ reason ) ; return $ this -> redirect ( $ this -> getReturnUrl ( ) ) ; }
Cancel delivery authorization request .
49,521
protected function getCategories ( ) { return array ( array ( 'id' => 'environment' , 'label' => __ ( 'Environment' ) , 'categories' => array ( array ( 'id' => 'comfort' , 'label' => __ ( 'Comfort' ) ) , array ( 'id' => 'disturbance' , 'label' => __ ( 'Disturbance' ) ) , array ( 'id' => 'noise' , 'label' => __ ( 'Noise' ) ) , array ( 'id' => 'powerOutage' , 'label' => __ ( 'Power Outage' ) ) , array ( 'id' => 'weather' , 'label' => __ ( 'Weather' ) ) , ) ) , array ( 'id' => 'examinee' , 'label' => __ ( 'Examinee' ) , 'categories' => array ( array ( 'id' => 'behaviour' , 'label' => __ ( 'Behaviour' ) ) , array ( 'id' => 'complaint' , 'label' => __ ( 'Complaint' ) ) , array ( 'id' => 'idAuthorization' , 'label' => __ ( 'ID/Authorization' ) ) , array ( 'id' => 'illness' , 'label' => __ ( 'Illness' ) ) , array ( 'id' => 'late' , 'label' => __ ( 'Late' ) ) , array ( 'id' => 'navigation' , 'label' => __ ( 'Navigation' ) ) , array ( 'id' => 'noShow' , 'label' => __ ( 'No Show' ) ) , ) ) , array ( 'id' => 'proctorStaff' , 'label' => __ ( 'Proctor/Staff' ) , 'categories' => array ( array ( 'id' => 'behaviour' , 'label' => __ ( 'Behaviour' ) ) , array ( 'id' => 'compliance' , 'label' => __ ( 'Compliance' ) ) , array ( 'id' => 'error' , 'label' => __ ( 'Error' ) ) , array ( 'id' => 'late' , 'label' => __ ( 'Late' ) ) , array ( 'id' => 'noShow' , 'label' => __ ( 'No Show' ) ) , ) ) , array ( 'id' => 'technical' , 'label' => __ ( 'Technical' ) , 'categories' => array ( array ( 'id' => 'freezing' , 'label' => __ ( 'Freezing' ) ) , array ( 'id' => 'launching' , 'label' => __ ( 'Launching' ) ) , array ( 'id' => 'network' , 'label' => __ ( 'Network' ) ) , array ( 'id' => 'printing' , 'label' => __ ( 'Printing' ) ) , array ( 'id' => 'testingWorkstation' , 'label' => __ ( 'Testing Workstation' ) ) , ) ) , array ( 'id' => 'other' , 'label' => __ ( 'Other' ) ) ) ; }
Default category list . It can be overwritten by child classes . Pay attention to the keys!
49,522
public function index ( ) { $ this -> setData ( 'homeUrl' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringHome' ) ) ; $ this -> setData ( 'logout' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringLogout' ) ) ; $ this -> composeView ( 'delivery-monitoring' , null , 'pages/index.tpl' , 'tao' ) ; }
Monitoring view of a selected delivery
49,523
public function deliveryExecutions ( ) { $ dataTable = new DeliveriesMonitorDatatable ( $ this -> getCurrentDelivery ( ) , $ this -> getRequest ( ) ) ; $ this -> getServiceManager ( ) -> propagate ( $ dataTable ) ; $ this -> returnJson ( $ dataTable ) ; }
Gets the list of current executions for a delivery
49,524
public function authoriseExecutions ( ) { $ deliveryExecution = $ this -> getRequestParameter ( 'execution' ) ; $ reason = $ this -> getRequestParameter ( 'reason' ) ; $ testCenter = $ this -> getRequestParameter ( 'testCenter' ) ; if ( ! is_array ( $ deliveryExecution ) ) { $ deliveryExecution = array ( $ deliveryExecution ) ; } try { $ data = DeliveryHelper :: authoriseExecutions ( $ deliveryExecution , $ reason , $ testCenter ) ; $ response = [ 'success' => ! count ( $ data [ 'unprocessed' ] ) , 'data' => $ data ] ; if ( ! $ response [ 'success' ] ) { $ response [ 'errorCode' ] = self :: ERROR_AUTHORIZE_EXECUTIONS ; $ response [ 'errorMsg' ] = __ ( 'Some delivery executions have not been authorized' ) ; } $ this -> returnJson ( $ response ) ; } catch ( QtiTestExtractionFailedException $ e ) { $ response = [ 'success' => false , 'data' => [ ] , 'errorCode' => self :: ERROR_AUTHORIZE_EXECUTIONS , 'errorMsg' => __ ( 'Decryption failed because of using the wrong customer app key.' ) , ] ; $ this -> returnJson ( $ response ) ; } catch ( ServiceNotFoundException $ e ) { \ common_Logger :: w ( 'No delivery service defined for proctoring' ) ; $ this -> returnError ( 'Proctoring interface not available' ) ; } }
Authorises a delivery execution
49,525
public function terminateExecutions ( ) { $ deliveryExecution = $ this -> getRequestParameter ( 'execution' ) ; $ reason = $ this -> getRequestParameter ( 'reason' ) ; if ( ! is_array ( $ deliveryExecution ) ) { $ deliveryExecution = array ( $ deliveryExecution ) ; } try { $ data = DeliveryHelper :: terminateExecutions ( $ deliveryExecution , $ reason ) ; $ response = [ 'success' => ! count ( $ data [ 'unprocessed' ] ) , 'data' => $ data ] ; if ( ! $ response [ 'success' ] ) { $ response [ 'errorCode' ] = self :: ERROR_TERMINATE_EXECUTIONS ; $ response [ 'errorMsg' ] = __ ( 'Some delivery executions have not been terminated' ) ; } $ this -> returnJson ( $ response ) ; } catch ( ServiceNotFoundException $ e ) { \ common_Logger :: w ( 'No delivery service defined for proctoring' ) ; $ this -> returnError ( 'Proctoring interface not available' ) ; } }
Terminates delivery executions
49,526
public function onDeliveryCreated ( DeliveryCreatedEvent $ event ) { $ delivery = $ this -> getResource ( $ event -> getDeliveryUri ( ) ) ; $ proctoredByDefault = $ this -> isProctoredByDefault ( ) ; $ delivery -> editPropertyValues ( $ this -> getProperty ( ProctorService :: ACCESSIBLE_PROCTOR ) , ( $ proctoredByDefault ? ProctorService :: ACCESSIBLE_PROCTOR_ENABLED : ProctorService :: ACCESSIBLE_PROCTOR_DISABLED ) ) ; }
Listen create event for delivery
49,527
public function onDeliveryUpdated ( DeliveryUpdatedEvent $ event ) { $ data = $ event -> jsonSerialize ( ) ; $ deliveryData = ! empty ( $ data [ 'data' ] ) ? $ data [ 'data' ] : [ ] ; $ delivery = $ this -> getResource ( $ event -> getDeliveryUri ( ) ) ; if ( isset ( $ deliveryData [ ProctorService :: ACCESSIBLE_PROCTOR ] ) && ! $ deliveryData [ ProctorService :: ACCESSIBLE_PROCTOR ] ) { $ delivery -> editPropertyValues ( $ this -> getProperty ( ProctorService :: ACCESSIBLE_PROCTOR ) , ProctorService :: ACCESSIBLE_PROCTOR_DISABLED ) ; } }
Listen update event for delivery
49,528
public function getData ( ) { $ awaiting = $ this -> getNumberOfAssessments ( DeliveryExecution :: STATE_AWAITING ) ; $ authorized = $ this -> getNumberOfAssessments ( DeliveryExecution :: STATE_AUTHORIZED ) ; $ paused = $ this -> getNumberOfAssessments ( DeliveryExecution :: STATE_PAUSED ) ; $ active = $ this -> getNumberOfAssessments ( DeliveryExecution :: STATE_ACTIVE ) ; $ current = $ awaiting + $ authorized + $ paused + $ active ; $ assessments = [ self :: GROUPFIELD_USER_ACTIVITY => [ self :: FIELD_ACTIVE_PROCTORS => $ this -> getNumberOfActiveUsers ( ProctorService :: ROLE_PROCTOR ) , self :: FIELD_ACTIVE_TEST_TAKERS => $ this -> getNumberOfActiveUsers ( TaoRoles :: DELIVERY ) , ] , self :: FIELD_TOTAL_ASSESSMENTS => $ this -> getNumberOfAssessments ( ) , self :: FIELD_TOTAL_CURRENT_ASSESSMENTS => $ current , self :: STATE_AWAITING_ASSESSMENT => $ awaiting , self :: STATE_AUTHORIZED_BUT_NOT_STARTED_ASSESSMENTS => $ authorized , self :: STATE_PAUSED_ASSESSMENTS => $ paused , self :: STATE_IN_PROGRESS_ASSESSMENTS => $ active ] ; return $ assessments ; }
Return comprehensive activity monitoring data .
49,529
public function assessmentActivity ( ) { $ service = $ this -> getServiceLocator ( ) -> get ( ActivityMonitoringService :: SERVICE_ID ) ; $ this -> setData ( 'reason_categories' , DeliveryHelper :: getAllReasonsCategories ( ) ) ; $ config = [ ActivityMonitoringService :: OPTION_USER_ACTIVITY_WIDGETS => $ service -> getOption ( ActivityMonitoringService :: OPTION_USER_ACTIVITY_WIDGETS ) , ActivityMonitoringService :: OPTION_ASSESSMENT_ACTIVITY_AUTO_REFRESH => $ service -> getOption ( ActivityMonitoringService :: OPTION_ASSESSMENT_ACTIVITY_AUTO_REFRESH ) , ActivityMonitoringService :: OPTION_COMPLETED_ASSESSMENTS_AUTO_REFRESH => $ service -> getOption ( ActivityMonitoringService :: OPTION_COMPLETED_ASSESSMENTS_AUTO_REFRESH ) , ] ; $ this -> setData ( 'config' , $ config ) ; $ this -> setView ( 'Tools/assessment_activity.tpl' ) ; }
Show assessment activity dashboard
49,530
public function assessmentActivityData ( ) { $ service = $ this -> getServiceLocator ( ) -> get ( ActivityMonitoringService :: SERVICE_ID ) ; $ data = $ service -> getData ( ) ; $ this -> returnJson ( [ 'success' => true , 'data' => $ data ] ) ; }
Show assessment activity data as json
49,531
public function completedAssessmentsData ( ) { $ timePeriod = $ this -> getRequestParameter ( 'interval' ) ; $ eventLog = $ this -> getServiceLocator ( ) -> get ( \ oat \ taoEventLog \ model \ eventLog \ LoggerService :: SERVICE_ID ) ; $ tz = new \ DateTimeZone ( \ common_session_SessionManager :: getSession ( ) -> getTimeZone ( ) ) ; $ timeKeys = $ this -> getTimeKeys ( $ timePeriod ) ; $ interval = $ this -> getInterval ( $ timePeriod ) ; foreach ( $ timeKeys as $ timeKey ) { $ to = clone ( $ timeKey ) ; $ from = clone ( $ to ) ; $ from -> sub ( $ interval ) ; $ countEvents = $ eventLog -> count ( [ [ 'occurred' , 'between' , $ from -> format ( 'Y-m-d H:i:s' ) , $ to -> format ( 'Y-m-d H:i:s' ) ] , [ 'event_name' , '=' , DeliveryExecutionFinished :: class ] , ] ) ; $ result [ 'time' ] [ ] = $ to -> setTimezone ( $ tz ) -> format ( 'Y-m-d H:i:s' ) ; $ result [ 'amount' ] [ ] = $ countEvents ; } $ this -> returnJson ( $ result , 200 ) ; }
Get completed assessments data
49,532
public function pauseActiveExecutions ( ) { if ( ! $ this -> isRequestPost ( ) ) { throw new \ common_exception_BadRequest ( 'Invalid request. Only POST method allowed.' ) ; } $ reason = $ this -> hasRequestParameter ( 'reason' ) ? $ this -> getRequestParameter ( 'reason' ) : [ 'reasons' => [ 'category' => 'Technical' , 'subCategory' => 'ACT' ] , 'comment' => __ ( 'Pause due to server maintenance' ) , ] ; $ monitoringService = $ this -> getServiceLocator ( ) -> get ( DeliveryMonitoringService :: SERVICE_ID ) ; $ deliveryExecutions = $ monitoringService -> find ( [ DeliveryMonitoringService :: STATUS => DeliveryExecution :: STATE_ACTIVE ] , [ 'asArray' => true ] ) ; $ ids = array_map ( function ( $ deliveryExecution ) { return $ deliveryExecution [ 'delivery_execution_id' ] ; } , $ deliveryExecutions ) ; $ stats = DeliveryHelper :: pauseExecutions ( $ ids , $ reason ) ; $ paused = $ stats [ 'processed' ] ; $ notPaused = $ stats [ 'unprocessed' ] ; $ this -> returnJson ( [ 'success' => true , 'data' => [ 'message' => count ( $ paused ) . ' ' . __ ( 'sessions paused' ) , 'processed' => $ paused , 'unprocessed' => $ notPaused ] ] ) ; }
Action pauses all the active delivery executions
49,533
private static function createErrorMessage ( $ deliveryExecution , $ action ) { if ( $ deliveryExecution -> getState ( ) -> getUri ( ) === DeliveryExecution :: STATE_FINISHED ) { $ errorMsg = __ ( '%s could not be %s because it is finished. Please refresh your data.' , $ deliveryExecution -> getLabel ( ) , $ action ) ; } else if ( $ deliveryExecution -> getState ( ) -> getUri ( ) === DeliveryExecution :: STATE_TERMINATED ) { $ errorMsg = __ ( '%s could not be %s because it is terminated. Please refresh your data.' , $ deliveryExecution -> getLabel ( ) , $ action ) ; } else { $ errorMsg = __ ( '%s could not be %s.' , $ deliveryExecution -> getLabel ( ) , $ action ) ; } return $ errorMsg ; }
Creates a standard error message with different actions
49,534
public static function getCurrentDeliveryExecutions ( core_kernel_classes_Resource $ delivery , core_kernel_classes_Resource $ testCenter , array $ options = array ( ) ) { $ deliveryService = ServiceManager :: getServiceManager ( ) -> get ( DeliveryMonitoringService :: SERVICE_ID ) ; return self :: adjustDeliveryExecutions ( $ deliveryService -> getCurrentDeliveryExecutions ( $ delivery , $ testCenter , $ options ) , $ options ) ; }
Gets the aggregated data for a filtered set of delivery executions of a given delivery This is performance critical would need to find a way to optimize to obtain such information
49,535
public static function pauseExecutions ( $ deliveryExecutions , $ reason = null ) { $ deliveryExecutionStateService = ServiceManager :: getServiceManager ( ) -> get ( DeliveryExecutionStateService :: SERVICE_ID ) ; $ result = [ 'processed' => [ ] , 'unprocessed' => [ ] ] ; foreach ( $ deliveryExecutions as $ deliveryExecution ) { if ( is_string ( $ deliveryExecution ) ) { $ deliveryExecution = self :: getDeliveryExecutionById ( $ deliveryExecution ) ; } try { $ isPaused = $ deliveryExecutionStateService -> pauseExecution ( $ deliveryExecution , $ reason ) ; if ( $ isPaused ) { $ result [ 'processed' ] [ $ deliveryExecution -> getIdentifier ( ) ] = true ; } else { $ result [ 'unprocessed' ] [ $ deliveryExecution -> getIdentifier ( ) ] = self :: createErrorMessage ( $ deliveryExecution , __ ( 'paused' ) ) ; } } catch ( \ Exception $ exception ) { $ result [ 'unprocessed' ] [ $ deliveryExecution -> getIdentifier ( ) ] = $ exception -> getMessage ( ) ; } } return $ result ; }
Pauses a list of delivery executions
49,536
public static function adjustColumnName ( $ column ) { if ( isset ( self :: $ columnsMap [ $ column ] ) ) { $ column = self :: $ columnsMap [ $ column ] ; } return $ column ; }
Converts a frontend column name into database column name . Useful to translate the name of a column to sort .
49,537
private static function _getUserExtraFields ( ) { if ( ! self :: $ extraFields ) { $ proctoringExtension = \ common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoProctoring' ) ; $ userExtraFields = $ proctoringExtension -> getConfig ( 'monitoringUserExtraFields' ) ; $ userExtraFieldsSettings = $ proctoringExtension -> getConfig ( 'monitoringUserExtraFieldsSettings' ) ; if ( ! empty ( $ userExtraFields ) && is_array ( $ userExtraFields ) ) { foreach ( $ userExtraFields as $ name => $ uri ) { $ property = new \ core_kernel_classes_Property ( $ uri ) ; $ settings = array_key_exists ( $ name , $ userExtraFieldsSettings ) ? $ userExtraFieldsSettings [ $ name ] : [ ] ; self :: $ extraFields [ ] = array_merge ( array ( 'id' => $ name , 'property' => $ property , 'label' => $ property -> getLabel ( ) , ) , $ settings ) ; } } } return self :: $ extraFields ; }
Get array of user specific extra fields to be displayed in the monitoring data table
49,538
public static function getExtraFields ( ) { return array_map ( function ( $ field ) { $ extra = [ 'id' => $ field [ 'id' ] , 'label' => $ field [ 'label' ] , 'filterable' => array_key_exists ( 'filterable' , $ field ) ? $ field [ 'filterable' ] : false , ] ; if ( array_key_exists ( 'columnPosition' , $ field ) ) { $ extra [ 'columnPosition' ] = $ field [ 'columnPosition' ] ; } return $ extra ; } , self :: _getUserExtraFields ( ) ) ; }
Return array of extra fields to be displayed in the monitoring data table
49,539
public static function getAllReasonsCategories ( $ hasAccessToReactivate = false ) { $ categoryService = ServiceManager :: getServiceManager ( ) -> get ( ReasonCategoryService :: SERVICE_ID ) ; $ response = array ( 'authorize' => array ( ) , 'pause' => $ categoryService -> getIrregularities ( ) , 'terminate' => $ categoryService -> getIrregularities ( ) , 'report' => $ categoryService -> getIrregularities ( ) , 'print' => [ ] , ) ; if ( $ hasAccessToReactivate ) { $ response [ 'reactivate' ] = $ categoryService -> getIrregularities ( ) ; } return $ response ; }
Get the list of all available categories sorted by action names
49,540
public function getResponsibleService ( User $ user , $ deliveryId = null ) { if ( ! isset ( $ this -> service ) ) { foreach ( $ this -> getOption ( self :: SERVICE_HANDLERS ) as $ handler ) { if ( ! is_a ( $ handler , DelegatedServiceHandler :: class ) ) { throw new \ common_exception_NoImplementation ( 'Handler should be instance of DelegatorServiceHandler.' ) ; } $ handler -> setServiceLocator ( $ this -> getServiceLocator ( ) ) ; if ( $ handler -> isSuitable ( $ user , $ deliveryId ) ) { $ this -> service = $ handler ; break ; } } } return $ this -> service ; }
Returns applicable service
49,541
protected function getTextConverterService ( ) { if ( ! $ this -> textConverterService ) { $ this -> textConverterService = ServiceManager :: getServiceManager ( ) -> get ( ProctoringTextConverter :: SERVICE_ID ) ; } return $ this -> textConverterService ; }
Get the TextConverterService
49,542
public function index ( ) { $ formContainer = new IrregularitiesExportForm ( $ this -> getRequestParameter ( 'uri' ) ) ; $ myForm = $ formContainer -> getForm ( ) ; if ( $ myForm -> isValid ( ) && $ myForm -> isSubmited ( ) ) { $ delivery = $ this -> getResource ( \ tao_helpers_Uri :: decode ( $ this -> getRequestParameter ( 'uri' ) ) ) ; $ from = $ this -> hasRequestParameter ( 'from' ) ? strtotime ( $ this -> getRequestParameter ( 'from' ) ) : '' ; $ to = $ this -> hasRequestParameter ( 'to' ) ? strtotime ( $ this -> getRequestParameter ( 'to' ) ) : '' ; $ IrregularityReport = $ this -> getServiceLocator ( ) -> get ( IrregularityReport :: SERVICE_ID ) ; return $ this -> returnTaskJson ( $ IrregularityReport -> getIrregularities ( $ delivery , $ from , $ to ) ) ; } else { $ this -> setData ( 'myForm' , $ myForm -> render ( ) ) ; $ this -> setView ( 'Irregularities/index.tpl' ) ; } }
Displays the form to export irregularities and handles it after submit
49,543
protected function getLayout ( ) { $ this -> setData ( 'homeUrl' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringHome' ) ) ; $ this -> setData ( 'logout' , $ this -> getServiceManager ( ) -> get ( DefaultUrlService :: SERVICE_ID ) -> getUrl ( 'ProctoringLogout' ) ) ; return [ 'layout.tpl' , 'taoProctoring' ] ; }
Gets the path to the layout
49,544
protected function getRequestOptions ( array $ defaults = [ ] ) { $ defaults = array_merge ( $ this -> getDefaultOptions ( ) , $ defaults ) ; $ page = $ this -> hasRequestParameter ( 'page' ) ? $ this -> getRequestParameter ( 'page' ) : $ defaults [ 'page' ] ; $ rows = $ this -> hasRequestParameter ( 'rows' ) ? $ this -> getRequestParameter ( 'rows' ) : $ defaults [ 'rows' ] ; $ sortBy = $ this -> hasRequestParameter ( 'sortby' ) ? $ this -> getRequestParameter ( 'sortby' ) : $ defaults [ 'sortby' ] ; $ sortOrder = $ this -> hasRequestParameter ( 'sortorder' ) ? $ this -> getRequestParameter ( 'sortorder' ) : $ defaults [ 'sortorder' ] ; $ filter = $ this -> hasRequestParameter ( 'filter' ) ? $ this -> getRequestParameter ( 'filter' ) : $ defaults [ 'filter' ] ; $ filterquery = $ this -> hasRequestParameter ( 'filterquery' ) ? $ this -> getRequestParameter ( 'filterquery' ) : $ defaults [ 'filter' ] ; $ periodStart = $ this -> hasRequestParameter ( 'periodStart' ) ? $ this -> getRequestParameter ( 'periodStart' ) : $ defaults [ 'periodStart' ] ; $ periodEnd = $ this -> hasRequestParameter ( 'periodEnd' ) ? $ this -> getRequestParameter ( 'periodEnd' ) : $ defaults [ 'periodEnd' ] ; $ detailed = $ this -> hasRequestParameter ( 'detailed' ) ? $ this -> getRequestParameter ( 'detailed' ) : 'false' ; $ detailed = filter_var ( $ detailed , FILTER_VALIDATE_BOOLEAN ) ; return array ( 'page' => $ page , 'rows' => $ rows , 'sortBy' => $ sortBy , 'sortOrder' => $ sortOrder , 'filter' => $ filter ? $ filter : $ filterquery , 'periodStart' => $ periodStart , 'detailed' => $ detailed , 'periodEnd' => $ periodEnd ) ; }
Gets the data table request options
49,545
public function terminateExecution ( DeliveryExecution $ deliveryExecution , $ reason = null ) { $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ result = false ; if ( ProctoredDeliveryExecution :: STATE_TERMINATED !== $ executionState && ProctoredDeliveryExecution :: STATE_FINISHED !== $ executionState ) { $ proctor = \ common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ eventManager = $ this -> getServiceManager ( ) -> get ( EventManager :: CONFIG_ID ) ; $ session = $ this -> getTestSessionService ( ) -> getTestSession ( $ deliveryExecution ) ; $ logData = [ 'reason' => $ reason , 'timestamp' => microtime ( true ) , 'context' => $ this -> getContext ( $ deliveryExecution ) , 'itemId' => $ session ? $ this -> getCurrentItemId ( $ deliveryExecution ) : null , ] ; $ this -> getDeliveryLogService ( ) -> log ( $ deliveryExecution -> getIdentifier ( ) , 'TEST_TERMINATE' , $ logData ) ; if ( $ session ) { if ( $ session -> isRunning ( ) ) { $ session -> endTestSession ( ) ; } $ this -> getTestSessionService ( ) -> persist ( $ session ) ; $ this -> getServiceLocator ( ) -> get ( ExtendedStateService :: SERVICE_ID ) -> persist ( $ session -> getSessionId ( ) ) ; } $ this -> setState ( $ deliveryExecution , ProctoredDeliveryExecution :: STATE_TERMINATED ) ; $ eventManager -> trigger ( new DeliveryExecutionTerminated ( $ deliveryExecution , $ proctor , $ reason ) ) ; $ result = true ; } return $ result ; }
Terminates a delivery execution
49,546
public function pause ( DeliveryExecution $ deliveryExecution , $ reason = null ) { $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ result = false ; if ( ProctoredDeliveryExecution :: STATE_TERMINATED !== $ executionState && ProctoredDeliveryExecution :: STATE_FINISHED !== $ executionState ) { $ session = $ this -> getTestSessionService ( ) -> getTestSession ( $ deliveryExecution ) ; $ data = [ 'reason' => $ reason , 'timestamp' => microtime ( true ) , 'context' => $ this -> getContext ( $ deliveryExecution ) , ] ; $ this -> setState ( $ deliveryExecution , ProctoredDeliveryExecution :: STATE_PAUSED ) ; if ( $ session ) { $ data [ 'itemId' ] = $ this -> getCurrentItemId ( $ deliveryExecution ) ; if ( $ session -> getState ( ) !== AssessmentTestSessionState :: SUSPENDED ) { $ session -> suspend ( ) ; $ this -> getTestSessionService ( ) -> persist ( $ session ) ; } $ this -> getServiceLocator ( ) -> get ( ExtendedStateService :: SERVICE_ID ) -> persist ( $ session -> getSessionId ( ) ) ; } $ this -> getDeliveryLogService ( ) -> log ( $ deliveryExecution -> getIdentifier ( ) , 'TEST_PAUSE' , $ data ) ; $ result = true ; } return $ result ; }
Pauses a delivery execution
49,547
public function reportExecution ( DeliveryExecution $ deliveryExecution , $ reason ) { $ deliveryLog = $ this -> getDeliveryLogService ( ) ; $ data = [ 'reason' => $ reason , 'timestamp' => microtime ( true ) , 'itemId' => $ this -> getCurrentItemId ( $ deliveryExecution ) , 'context' => $ this -> getContext ( $ deliveryExecution ) ] ; $ returnValue = $ deliveryLog -> log ( $ deliveryExecution -> getIdentifier ( ) , 'TEST_IRREGULARITY' , $ data ) ; $ eventManager = $ this -> getServiceManager ( ) -> get ( EventManager :: SERVICE_ID ) ; $ eventManager -> trigger ( new DeliveryExecutionIrregularityReport ( $ deliveryExecution ) ) ; return $ returnValue ; }
Report irregularity to a delivery execution
49,548
protected function canBeAuthorised ( DeliveryExecution $ deliveryExecution ) { $ result = false ; $ user = \ common_session_SessionManager :: getSession ( ) -> getUser ( ) ; $ stateUri = $ deliveryExecution -> getState ( ) -> getUri ( ) ; if ( $ stateUri === ProctoredDeliveryExecution :: STATE_AWAITING ) { $ result = true ; } if ( $ user instanceof GuestTestUser && ! in_array ( $ stateUri , [ ProctoredDeliveryExecution :: STATE_FINISHED , ProctoredDeliveryExecution :: STATE_TERMINATED , ProctoredDeliveryExecution :: STATE_CANCELED , ] ) ) { $ result = true ; } return $ result ; }
Whether delivery execution can be moved to authorised state .
49,549
protected function getCurrentItemId ( DeliveryExecution $ deliveryExecution ) { $ result = null ; $ session = $ this -> getTestSessionService ( ) -> getTestSession ( $ deliveryExecution ) ; if ( $ session ) { $ item = $ session -> getCurrentAssessmentItemRef ( ) ; if ( $ item ) { $ result = $ item -> getIdentifier ( ) ; } } return $ result ; }
Get identifier of current item .
49,550
public function catchSessionPause ( TestExecutionPausedEvent $ event ) { $ deliveryExecution = ServiceProxy :: singleton ( ) -> getDeliveryExecution ( $ event -> getTestExecutionId ( ) ) ; $ requestParams = \ Context :: getInstance ( ) -> getRequest ( ) -> getParameters ( ) ; $ reason = null ; if ( isset ( $ requestParams [ 'reason' ] ) ) { $ reason = $ requestParams [ 'reason' ] ; } if ( $ deliveryExecution -> getState ( ) -> getUri ( ) !== DeliveryExecution :: STATE_PAUSED ) { $ this -> pause ( $ deliveryExecution , $ reason ) ; } }
Pause delivery execution if test session was paused .
49,551
public function isExpired ( DeliveryExecution $ deliveryExecution ) { $ result = false ; $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; $ lastTestTakersEvent = $ this -> getLastTestTakersEvent ( $ deliveryExecution ) ; if ( in_array ( $ executionState , [ DeliveryExecutionState :: STATE_AWAITING , DeliveryExecutionState :: STATE_AUTHORIZED , ] ) && $ lastTestTakersEvent ) { $ deliveryExecutionStateService = $ this -> getServiceLocator ( ) -> get ( DeliveryExecutionStateService :: SERVICE_ID ) ; $ delay = $ deliveryExecutionStateService -> getOption ( DeliveryExecutionStateService :: OPTION_CANCELLATION_DELAY ) ; $ lastTestEventTime = ( new DateTimeImmutable ( ) ) -> setTimestamp ( $ lastTestTakersEvent [ 'created_at' ] ) ; $ result = ( $ lastTestEventTime -> add ( new DateInterval ( $ delay ) ) < ( new DateTimeImmutable ( ) ) ) ; } return $ result ; }
Checks if delivery execution was abandoned after authorization
49,552
public function import ( $ filePath , $ extraProperties = [ ] , $ options = [ ] ) { $ extraProperties [ UserRdf :: PROPERTY_ROLES ] = ProctorService :: ROLE_PROCTOR ; $ extraProperties [ 'roles' ] = ProctorService :: ROLE_PROCTOR ; return parent :: import ( $ filePath , $ extraProperties , $ options ) ; }
Add test taker role to user to import
49,553
public function getResultsData ( DeliveryExecutionInterface $ deliveryExecution ) { $ result = [ ] ; $ resultService = $ this -> getResultService ( $ deliveryExecution -> getDelivery ( ) ) ; $ itemsData = $ resultService -> getItemVariableDataFromDeliveryResult ( $ deliveryExecution -> getIdentifier ( ) , 'lastSubmitted' ) ; foreach ( $ itemsData as $ itemData ) { $ rawResult = [ ] ; $ rawResult [ 'label' ] = $ itemData [ 'label' ] ; foreach ( $ itemData [ 'sortedVars' ] as $ variables ) { $ variableValues = array_map ( function ( $ variable ) { $ variable = current ( $ variable ) ; return $ variable [ 'var' ] -> getValue ( ) ; } , $ variables ) ; $ rawResult = array_merge ( $ rawResult , $ variableValues ) ; } ; $ result [ ] = $ rawResult ; } return $ result ; }
Get session results
49,554
public function getDeliveryData ( DeliveryExecutionInterface $ deliveryExecution ) { $ result = [ 'start' => $ deliveryExecution -> getStartTime ( ) , 'end' => $ deliveryExecution -> getFinishTime ( ) , 'label' => $ deliveryExecution -> getLabel ( ) ] ; return $ result ; }
Get delivery execution data
49,555
protected function getResultService ( \ core_kernel_classes_Resource $ delivery ) { $ ResultServiceWrapper = $ this -> getServiceManager ( ) -> get ( ResultServiceWrapper :: SERVICE_ID ) ; $ resultsService = $ ResultServiceWrapper -> getService ( ) ; $ implementation = $ resultsService -> getReadableImplementation ( $ delivery ) ; $ resultsService -> setImplementation ( $ implementation ) ; return $ resultsService ; }
Get result service instance .
49,556
public function getTextRegistry ( ) { return array ( 'Assign administrator' => __ ( 'Assign administrator' ) , 'Assign proctors' => __ ( 'Assign proctors' ) , 'Please select one or more test site to manage proctors' => __ ( 'Please select one or more test site to manage proctors' ) , 'Create Proctor' => __ ( 'Create Proctor' ) , 'Create and authorize a proctor to the selected test sites' => __ ( 'Create and authorize a proctor to the selected test sites' ) , 'Manage Proctors' => __ ( 'Manage Proctors' ) , 'Define sub-centers' => __ ( 'Define sub-centers' ) , 'The proctors will be authorized. Continue ?' => __ ( 'The proctors will be authorized. Continue ?' ) , 'The proctors will be revoked. Continue ?' => __ ( 'The proctors will be revoked. Continue ?' ) , 'The proctor will be authorized. Continue ?' => __ ( 'The proctor will be authorized. Continue ?' ) , 'The proctor will be revoked. Continue ?' => __ ( 'The proctor will be revoked. Continue ?' ) , 'Authorized proctors' => __ ( 'Authorized proctors' ) , 'Partially authorized proctors' => __ ( 'Partially authorized proctors' ) , 'No assigned proctors' => __ ( 'No assigned proctors' ) , 'Assigned proctors' => __ ( 'Assigned proctors' ) , 'Creates and authorizes proctor' => __ ( 'Creates and authorizes proctor' ) , 'Authorize the selected proctors' => __ ( 'Authorize the selected proctors' ) , 'Authorize the proctor' => __ ( 'Authorize the proctor' ) , 'Revoke authorization for the selected proctors' => __ ( 'Revoke authorization for the selected proctor' ) , 'Revoke the proctor' => __ ( 'Revoke the proctor' ) , 'Proctors authorized' => __ ( 'Proctors authorized' ) , 'Proctors revoked' => __ ( 'Proctors revoked' ) , 'Proctor created' => __ ( 'Proctor created' ) , 'No proctors in request param' => __ ( 'No proctors in request param' ) , 'Test site %s' => __ ( 'Test site %s' ) , 'Test center saved' => __ ( 'Test center saved' ) , 'Edit test center' => __ ( 'Edit test center' ) ) ; }
Return the translation of key
49,557
protected function action ( $ deliveryExecution , $ executionId , $ isEndDate = false ) { $ this -> getDeliveryStateService ( ) -> terminateExecution ( $ deliveryExecution , [ 'reasons' => [ 'category' => 'Technical' ] , 'comment' => $ isEndDate ? 'The assessment was automatically terminated because end time expired.' : 'The assessment was automatically terminated.' ] ) ; $ this -> report -> add ( Report :: createSuccess ( 'Execution terminated with success:' . $ executionId ) ) ; }
Terminate delivery execution
49,558
protected function actionBasedOnEndDate ( DateTimeImmutable $ endDateTime , $ executionId ) { try { $ deliveryExecution = $ this -> getServiceProxy ( ) -> getDeliveryExecution ( $ executionId ) ; $ lastInteraction = $ this -> getLastInteractionDateTime ( $ deliveryExecution ) ; if ( $ lastInteraction === null ) { $ this -> report -> add ( Report :: createFailure ( 'Execution last interaction cannot be found: ' . $ executionId ) ) ; return false ; } if ( new DateTimeImmutable ( 'now' ) >= $ endDateTime ) { $ this -> action ( $ deliveryExecution , $ executionId , true ) ; return true ; } $ this -> report -> add ( Report :: createInfo ( 'Execution not expired yet:' . $ executionId . ' Last Interaction:' . $ lastInteraction -> format ( 'Y-m-d H:i:s' ) . ' Time when will expire:' . $ endDateTime -> format ( 'Y-m-d H:i:s' ) ) ) ; } catch ( \ common_exception_NotFound $ e ) { $ this -> report -> add ( Report :: createFailure ( 'Execution cannot be found: ' . $ executionId ) ) ; $ this -> report -> add ( Report :: createFailure ( $ e -> getMessage ( ) ) ) ; } return false ; }
Run an action if the end date matches the condition
49,559
protected function actionBasedOnTTL ( $ executionId ) { try { $ deliveryExecution = $ this -> getServiceProxy ( ) -> getDeliveryExecution ( $ executionId ) ; $ lastInteraction = $ this -> getLastInteractionDateTime ( $ deliveryExecution ) ; if ( $ lastInteraction === null ) { $ this -> report -> add ( Report :: createFailure ( 'Execution last interaction cannot be found: ' . $ executionId ) ) ; return false ; } $ ttl = $ this -> getTtlAsActive ( ) ; if ( $ ttl === null ) { $ this -> report -> add ( Report :: createFailure ( 'Execution ttl not set: ' . $ executionId ) ) ; return false ; } $ timeUntilToLive = clone $ lastInteraction ; $ timeUntilToLive = $ timeUntilToLive -> add ( new DateInterval ( $ ttl ) ) ; if ( ( new DateTimeImmutable ( 'now' ) ) >= $ timeUntilToLive ) { $ this -> action ( $ deliveryExecution , $ executionId ) ; return true ; } else { $ this -> report -> add ( Report :: createInfo ( 'Execution not expired yet:' . $ executionId . ' Last Interaction: ' . $ lastInteraction -> format ( 'Y-m-d H:i:s' ) . ' Time when will expire: ' . $ timeUntilToLive -> format ( 'Y-m-d H:i:s' ) ) ) ; } } catch ( \ common_exception_NotFound $ e ) { $ this -> report -> add ( Report :: createFailure ( 'Execution cannot be found: ' . $ executionId ) ) ; $ this -> report -> add ( Report :: createFailure ( $ e -> getMessage ( ) ) ) ; } return false ; }
Run an action if TTL matches the condition
49,560
private function getDeliveryEndDateProperty ( ) { $ this -> propertyDeliveryEndDate = $ this -> propertyDeliveryEndDate ? : $ this -> getProperty ( DeliveryAssemblyService :: PROPERTY_END ) ; return $ this -> propertyDeliveryEndDate ; }
Caching property to avoid multiple generations
49,561
protected function breadcrumbsIndex ( $ route , $ parsedRoute ) { $ urlContext = [ ] ; if ( isset ( $ parsedRoute [ 'params' ] ) ) { if ( isset ( $ parsedRoute [ 'params' ] [ 'session' ] ) ) { $ session = $ parsedRoute [ 'params' ] [ 'session' ] ; $ urlContext [ 'session' ] = is_array ( $ session ) ? implode ( ',' , $ session ) : $ session ; } if ( isset ( $ parsedRoute [ 'params' ] [ 'delivery' ] ) ) { $ urlContext [ 'delivery' ] = $ parsedRoute [ 'params' ] [ 'delivery' ] ; } if ( isset ( $ parsedRoute [ 'params' ] [ 'context' ] ) ) { $ urlContext [ 'context' ] = $ parsedRoute [ 'params' ] [ 'context' ] ; } } $ breadcrumbs = array ( 'id' => 'history' , 'url' => _url ( 'sessionHistory' , 'Reporting' , 'taoProctoring' , $ urlContext ) , 'label' => __ ( 'Session history' ) ) ; return $ breadcrumbs ; }
Gets the breadcrumbs for the sessionHistory page
49,562
protected function isExpired ( DeliveryExecution $ deliveryExecution ) { $ result = false ; $ executionState = $ deliveryExecution -> getState ( ) -> getUri ( ) ; if ( in_array ( $ executionState , [ DeliveryExecutionState :: STATE_PAUSED , DeliveryExecutionState :: STATE_ACTIVE , ] ) ) { $ deliveryExecutionStateService = $ this -> getServiceLocator ( ) -> get ( DeliveryExecutionStateService :: SERVICE_ID ) ; if ( $ executionState === DeliveryExecutionState :: STATE_ACTIVE ) { $ lastTestTakersEvent = $ this -> getLastTestTakersEvent ( $ deliveryExecution ) ; $ lastEventTime = ( new DateTimeImmutable ( ) ) -> setTimestamp ( $ lastTestTakersEvent [ 'created_at' ] ) ; } else { $ lastEventTime = $ this -> getLastPause ( $ deliveryExecution ) ; } if ( $ lastEventTime && $ deliveryExecutionStateService -> hasOption ( DeliveryExecutionStateService :: OPTION_TERMINATION_DELAY_AFTER_PAUSE ) ) { $ delay = $ deliveryExecutionStateService -> getOption ( DeliveryExecutionStateService :: OPTION_TERMINATION_DELAY_AFTER_PAUSE ) ; $ result = ( $ lastEventTime -> add ( new DateInterval ( $ delay ) ) < ( new DateTimeImmutable ( 'now' ) ) ) ; } } return $ result ; }
Checks if delivery execution was expired after pausing
49,563
protected function getLastPause ( DeliveryExecution $ deliveryExecution ) { $ deliveryLogService = $ this -> getServiceLocator ( ) -> get ( DeliveryLog :: SERVICE_ID ) ; $ pauses = array_reverse ( $ deliveryLogService -> get ( $ deliveryExecution -> getIdentifier ( ) , 'TEST_PAUSE' ) ) ; return isset ( $ pauses [ 0 ] ) ? ( new DateTimeImmutable ( ) ) -> setTimestamp ( $ pauses [ 0 ] [ 'created_at' ] ) : null ; }
Get time of last pause
49,564
public function getDeliveryTimer ( $ deliveryExecution ) { if ( is_string ( $ deliveryExecution ) ) { $ deliveryExecution = $ this -> getDeliveryExecutionById ( $ deliveryExecution ) ; } $ testSessionService = $ this -> getServiceLocator ( ) -> get ( TestSessionService :: SERVICE_ID ) ; $ testSession = $ testSessionService -> getTestSession ( $ deliveryExecution ) ; if ( $ testSession instanceof TestSession ) { $ timer = $ testSession -> getTimer ( ) ; } else { $ qtiTimerFactory = $ this -> getServiceLocator ( ) -> get ( QtiTimerFactory :: SERVICE_ID ) ; $ timer = $ qtiTimerFactory -> getTimer ( $ deliveryExecution -> getIdentifier ( ) , $ deliveryExecution -> getUserIdentifier ( ) ) ; } return $ timer ; }
Gets the delivery time counter
49,565
public function getTimeLimits ( $ testSession ) { $ seconds = null ; if ( $ item = $ testSession -> getCurrentAssessmentItemRef ( ) ) { $ seconds = $ this -> getPartTimeLimits ( $ item ) ; } if ( ! $ seconds && $ section = $ testSession -> getCurrentAssessmentSection ( ) ) { $ seconds = $ this -> getPartTimeLimits ( $ section ) ; } if ( ! $ seconds && $ testPart = $ testSession -> getCurrentTestPart ( ) ) { $ seconds = $ this -> getPartTimeLimits ( $ testPart ) ; } if ( ! $ seconds && $ assessmentTest = $ testSession -> getAssessmentTest ( ) ) { $ seconds = $ this -> getPartTimeLimits ( $ assessmentTest ) ; } return $ seconds ; }
Gets the actual time limits for a test session
49,566
public function getTokenAndUser ( ) { $ adapter = $ this -> getAdapter ( ) ; $ isOAuth2 = $ this -> version === self :: OAUTH_VERSION_2 ; $ token = $ adapter -> getAccessToken ( $ this -> provider ) ; $ user = $ this -> provider -> getUser ( $ token ) ; return [ 'adapterKey' => $ this -> provider -> getProviderName ( ) , 'token' => $ token -> getTokenValue ( ) , 'version' => $ token -> getTokenVersion ( ) , 'scope' => $ isOAuth2 ? $ token -> getScope ( ) : null , 'refreshToken' => $ isOAuth2 ? $ token -> getRefreshToken ( ) : null , 'expireTime' => $ isOAuth2 ? gmdate ( 'Y-m-d H:i:s' , $ token -> getExpireTimestamp ( ) ) : null , 'remoteUserId' => $ user -> getId ( ) , 'remoteUserName' => $ user -> getName ( ) , 'remoteEmail' => $ user -> getEmail ( ) , 'remoteImageUrl' => $ user -> getAvatar ( ) , 'remoteExtra' => json_encode ( $ user -> getExtra ( ) ) , ] ; }
To compatible with old version
49,567
public function debug ( $ logPath ) { $ adapter = $ this -> getAdapter ( ) ; $ adapter -> getEmitter ( ) -> attach ( new LogSubscriber ( $ logPath , Formatter :: DEBUG ) ) ; return $ this ; }
Enable debug mode Guzzle will print all request and response on screen
49,568
public function createTraverser ( ContextInterface $ context ) { $ traverser = new PhpParser \ NodeTraverser ; $ stack = new ContextStack ( $ context ) ; $ traverser -> addVisitor ( new NodeVisitors \ ClassVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ InterfaceVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ MethodVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ GlobalFunctionVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ CodeCoverageIgnoreVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ CatchVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ ExitVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ GlobalVarVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ StaticVariableVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ SuperGlobalVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ StaticCallVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ CodeInGlobalSpaceVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ ErrorSuppressionVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ NewVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ IncludeVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ GlobalFunctionCallVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ ClassConstantFetchVisitor ( $ stack , $ context ) ) ; $ traverser -> addVisitor ( new NodeVisitors \ StaticPropertyFetchVisitor ( $ stack , $ context ) ) ; return $ traverser ; }
Create a node traverser object
49,569
public function generate ( ) { $ startTime = microtime ( true ) ; if ( ! is_dir ( $ this -> reportDir ) ) { echo "Creating new directory {$this->reportDir}... " ; mkdir ( $ this -> reportDir ) ; echo "OK\n" ; } echo "Generating HTML report to {$this->reportDir} ... " ; $ this -> iterate ( $ this -> report ) ; $ totalTime = number_format ( microtime ( true ) - $ startTime , 2 ) ; echo "OK ({$totalTime}s).\n" ; }
Generate HTML report
49,570
protected function iterate ( ContextInterface $ root ) { $ this -> generateIndexFile ( $ root ) ; foreach ( $ root -> getChildren ( ) as $ item ) { if ( $ item instanceof FileContext ) { $ this -> generateFile ( $ item ) ; } elseif ( $ item instanceof DirectoryContext ) { $ this -> iterate ( $ item ) ; } } }
Iterate the report
49,571
public function scan ( FileContext $ file ) { $ filename = $ file -> getName ( ) ; $ code = file_get_contents ( $ filename ) ; try { $ stmts = $ this -> parser -> parse ( $ code ) ; $ traverser = $ this -> factory -> createTraverser ( $ file ) ; $ traverser -> traverse ( $ stmts ) ; } catch ( PhpParser \ Error $ e ) { echo "\n\nParse Error: " . $ e -> getMessage ( ) . " ({$filename})\n" ; } catch ( \ Exception $ e ) { echo "\n\n" . $ e -> getMessage ( ) . " (in {$filename})\n" ; } catch ( \ Throwable $ e ) { echo "\n\n" . $ e -> getMessage ( ) . " (while analysing {$filename})\n" ; } }
Scan a php file
49,572
protected function addChild ( ContextInterface $ child ) { $ length = count ( $ this -> stack ) ; $ this -> stack [ $ length - 1 ] -> addChild ( $ child ) ; }
Add a child to current context
49,573
public function addIssue ( IssueInterface $ issue ) { $ length = count ( $ this -> stack ) ; $ this -> stack [ $ length - 1 ] -> addIssue ( $ issue ) ; }
Add an issue to current context
49,574
public function findContextOfType ( ContextSpecificationInterface $ filter ) { foreach ( $ this -> stack as $ context ) { if ( $ filter -> isSatisfiedBy ( $ context ) ) { return $ context ; } } return false ; }
Find context in stack matching specification
49,575
public function isAllowedOnGlobalSpace ( PhpParser \ Node $ node ) { return ( $ node instanceof Stmt \ Class_ || $ node instanceof Stmt \ Function_ || $ node instanceof Stmt \ Trait_ || ( $ node instanceof Stmt \ UseUse || $ node instanceof Stmt \ Use_ ) || ( $ node instanceof Stmt \ Namespace_ || $ node instanceof Node \ Name ) || $ node instanceof Stmt \ Interface_ ) ; }
Is node allowed on global space?
49,576
public function isClassSafeForInstantiation ( $ className ) { $ className = strtolower ( $ className ) ; if ( FALSE !== strpos ( $ className , '\\' ) ) { return false ; } if ( $ className === 'parent' ) { return true ; } if ( in_array ( $ className , $ this -> unsafeForInstantiation ) ) { return false ; } elseif ( in_array ( $ className , array_map ( 'strtolower' , get_declared_classes ( ) ) ) ) { return true ; } return false ; }
Is this a php internal class?
49,577
public function generate ( ) { $ startTime = microtime ( true ) ; if ( ! is_dir ( $ this -> reportDir ) ) { echo "Creating new directory {$this->reportDir}... " ; mkdir ( $ this -> reportDir ) ; echo "OK\n" ; } echo "Generating CSV report to {$this->reportDir} ... " ; $ this -> generateCsvForDirectory ( $ this -> report ) ; foreach ( $ this -> report -> getChildrenRecursively ( new DirectorySpecification ) as $ item ) { $ this -> generateCsvForDirectory ( $ item ) ; } $ totalTime = number_format ( microtime ( true ) - $ startTime , 2 ) ; echo "OK ({$totalTime}s).\n" ; }
Generate CSV report
49,578
public function getChildren ( ContextSpecificationInterface $ filter = null ) { if ( $ filter === null ) { return $ this -> children ; } else { return array_filter ( $ this -> children , [ $ filter , 'isSatisfiedBy' ] ) ; } }
Filter and list children
49,579
public function getChildrenRecursively ( ContextSpecificationInterface $ filter = null ) { $ list = $ this -> getChildren ( $ filter ) ; foreach ( $ this -> getChildren ( ) as $ child ) { if ( $ child -> hasChildren ( ) ) { $ list = array_merge ( $ list , $ child -> getChildrenRecursively ( $ filter ) ) ; } } return $ list ; }
Return all children recursively
49,580
public function hasIssues ( $ recursive = false , ContextSpecificationInterface $ filter = null ) { if ( $ recursive === true ) { foreach ( $ this -> getChildrenRecursively ( $ filter ) as $ child ) { if ( $ child -> hasIssues ( false , $ filter ) ) { return true ; } } } return ( count ( $ this -> issues ) > 0 ) ; }
Are there any issues?
49,581
public function getIssues ( $ recursive = false , ContextSpecificationInterface $ filter = null ) { $ list = $ this -> issues ; if ( $ recursive === true ) { foreach ( $ this -> getChildrenRecursively ( $ filter ) as $ child ) { foreach ( $ child -> getIssues ( false , $ filter ) as $ issue ) { $ list [ ] = $ issue ; } } } return $ list ; }
Return all issues
49,582
public function getIssuesCount ( ContextSpecificationInterface $ filter = null ) { $ count = count ( $ this -> issues ) ; foreach ( $ this -> getChildren ( $ filter ) as $ child ) { $ count += $ child -> getIssuesCount ( $ filter ) ; } return $ count ; }
Counts all issues recursively
49,583
public function isValid ( $ email ) { if ( ! $ this -> isEmail ( $ email ) ) { return false ; } if ( $ this -> isExample ( $ email ) ) { return false ; } if ( $ this -> isDisposable ( $ email ) ) { return false ; } if ( $ this -> isRole ( $ email ) ) { return false ; } if ( ! $ this -> hasMx ( $ email ) ) { return false ; } return true ; }
Validate an email address using ALL the functions of this library .
49,584
public function isSendable ( $ email ) { if ( ! $ this -> isEmail ( $ email ) ) { return false ; } if ( $ this -> isExample ( $ email ) ) { return false ; } if ( ! $ this -> hasMx ( $ email ) ) { return false ; } return true ; }
Validate an email address using isEmail isExample and hasMx .
49,585
public function isDisposable ( $ email ) { if ( ! $ this -> isEmail ( $ email ) ) { return null ; } $ hostname = $ this -> hostnameFromEmail ( $ email ) ; if ( $ hostname ) { if ( is_null ( $ this -> disposable ) ) { $ data = new \ EmailData \ Data ( ) ; $ file = $ data -> getPathToDataFile ( 'php' ) ; $ this -> disposable = include ( $ file ) ; } if ( in_array ( $ hostname , $ this -> disposable ) ) { return true ; } return false ; } return null ; }
Detected disposable email domains
49,586
public function isRole ( $ email ) { if ( ! $ this -> isEmail ( $ email ) ) { return null ; } $ user = $ this -> userFromEmail ( $ email ) ; if ( $ user ) { if ( is_null ( $ this -> role ) ) { $ this -> role = include ( 'data/role.php' ) ; } if ( in_array ( $ user , $ this -> role ) ) { return true ; } return false ; } return null ; }
Detected role based email addresses
49,587
public function hasMx ( $ email ) { if ( ! $ this -> isEmail ( $ email ) ) { return null ; } $ hostname = $ this -> hostnameFromEmail ( $ email ) ; if ( $ hostname ) { return checkdnsrr ( $ hostname , 'MX' ) ; } return null ; }
Test email address for MX records
49,588
private function userFromEmail ( $ email ) { $ parts = explode ( '@' , $ email ) ; if ( count ( $ parts ) == 2 ) { return strtolower ( $ parts [ 0 ] ) ; } return null ; }
Get the user form an email address
49,589
private function hostnameFromEmail ( $ email ) { $ parts = explode ( '@' , $ email ) ; if ( count ( $ parts ) == 2 ) { return strtolower ( $ parts [ 1 ] ) ; } return null ; }
Get the hostname form an email address
49,590
public function isDirExcluded ( $ path ) { foreach ( $ this -> excludedDirs as $ needle ) { if ( empty ( $ needle ) ) { continue ; } $ needleLen = strlen ( $ needle ) ; $ pathChunk = substr ( $ path , - $ needleLen , $ needleLen ) ; if ( $ pathChunk == $ needle ) { return true ; } } return false ; }
Is this path excluded from the scan?
49,591
public static function current ( ) { $ token = Request :: header ( 'X-Auth-Token' , Input :: get ( 'X-Auth-Token' ) ) ; if ( static :: $ _current === null && $ token ) { static :: $ _current = static :: where ( 'token' , $ token ) -> where ( 'expire_at' , '>=' , Carbon :: now ( ) ) -> first ( ) ; } return static :: $ _current ; }
current - get current active AuthToken instance
49,592
public function forgotPassword ( ) { $ data = $ this -> getData ( ) ; $ auth = Auth :: where ( 'email' , $ data [ 'email' ] ) -> first ( ) ; if ( ! $ auth ) { throw new Exceptions \ NotFoundException ( "invalid_user" ) ; } if ( ! isset ( $ data [ 'subject' ] ) ) { $ data [ 'subject' ] = 'Forgot your password?' ; } $ body_data = Context :: unsafe ( function ( ) use ( & $ auth ) { $ array = $ auth -> generateForgotPasswordToken ( ) -> toArray ( ) ; $ array [ 'token' ] = $ auth -> getAttribute ( Auth :: FORGOT_PASSWORD_FIELD ) ; return $ array ; } ) ; $ template = isset ( $ data [ 'template' ] ) ? $ data [ 'template' ] : self :: TEMPLATE_FORGOT_PASSWORD ; return array ( 'success' => ( Mail :: send ( array ( 'subject' => $ data [ 'subject' ] , 'from' => Config :: get ( 'mail.from' , 'no-reply@api.2l.cx' ) , 'to' => $ auth -> email , 'body' => Module :: template ( $ template ) -> compile ( $ body_data ) ) ) === 1 ) ) ; }
Trigger forgot password email
49,593
public function resetPassword ( ) { $ data = $ this -> getData ( ) ; if ( ! isset ( $ data [ 'token' ] ) === 0 ) { throw new Exceptions \ BadRequestException ( "you must provide a 'token'." ) ; } if ( ! isset ( $ data [ 'password' ] ) || strlen ( $ data [ 'password' ] ) === 0 ) { throw new Exceptions \ BadRequestException ( "you must provide a valid 'password'." ) ; } Context :: setTrusted ( true ) ; $ auth = Auth :: where ( Auth :: FORGOT_PASSWORD_FIELD , $ data [ 'token' ] ) -> first ( ) ; if ( $ auth && $ auth -> resetPassword ( $ data [ 'password' ] ) ) { return array ( 'success' => true ) ; } else { throw new Exceptions \ UnauthorizedException ( "invalid_token" ) ; } }
Reset auth password
49,594
public function toArray ( ) { $ array = parent :: toArray ( ) ; if ( isset ( $ this -> schema [ 'attributes' ] ) ) { foreach ( $ this -> schema [ 'attributes' ] as $ attribute ) { @ settype ( $ array [ $ attribute [ 'name' ] ] , $ attribute [ 'type' ] ) ; } } $ observer = static :: getObserver ( $ this -> getTable ( ) ) ; if ( $ observer ) { if ( method_exists ( $ observer , 'toArray' ) ) { return $ observer -> toArray ( $ this , $ array ) ; } } return $ array ; }
toArray . Modules may define a custom toArray method .
49,595
public static function message ( $ template_body = null , $ options = array ( ) ) { $ message = new Message ( ) ; MailHelper :: setMessage ( $ message ) ; if ( $ template_body ) { $ template = Module :: template ( $ template_body ) ; $ message -> body ( $ template -> compile ( $ options ) ) ; } return $ message ; }
Create a new Message .
49,596
public static function attachment ( $ path_or_data = null , $ filename = null , $ contentType = null ) { $ from_path = realpath ( $ path_or_data ) ; if ( $ from_path ) { $ attachment = Swift_Attachment :: fromPath ( $ path_or_data , $ contentType ) ; $ attachment -> setFilename ( $ filename ) ; } else { $ attachment = Swift_Attachment :: newInstance ( $ path_or_data , $ filename , $ contentType ) ; } return $ attachment ; }
Create a new Attachment .
49,597
public function open ( $ savePath , $ sessionName ) { try { $ this -> _tableRestProxy -> getTable ( $ this -> _sessionContainer ) ; } catch ( ServiceException $ e ) { $ this -> _tableRestProxy -> createTable ( $ this -> _sessionContainer ) ; } return TRUE ; }
Callback function for session handler . It s invoked while the session is being opened .
49,598
public function read ( $ sessionId ) { try { $ result = $ this -> _tableRestProxy -> getEntity ( $ this -> _sessionContainer , $ this -> _sessionContainerPartition , $ sessionId ) ; $ entity = $ result -> getEntity ( ) ; return unserialize ( base64_decode ( $ entity -> getPropertyValue ( 'data' ) ) ) ; } catch ( ServiceException $ e ) { return '' ; } }
Callback function for session handler . It s invoked while the session data is being read .
49,599
public function write ( $ sessionId , $ sessionData ) { $ serializedData = base64_encode ( serialize ( $ sessionData ) ) ; try { $ result = $ this -> _tableRestProxy -> getEntity ( $ this -> _sessionContainer , $ this -> _sessionContainerPartition , $ sessionId ) ; $ entity = $ result -> getEntity ( ) ; $ entity -> setPropertyValue ( 'data' , $ serializedData ) ; $ entity -> setPropertyValue ( 'expires' , time ( ) ) ; $ this -> _tableRestProxy -> updateEntity ( $ this -> _sessionContainer , $ entity ) ; } catch ( ServiceException $ e ) { $ entity = new Entity ( ) ; $ entity -> setPartitionKey ( $ this -> _sessionContainerPartition ) ; $ entity -> setRowKey ( $ sessionId ) ; $ entity -> addProperty ( 'data' , EdmType :: STRING , $ serializedData ) ; $ entity -> addProperty ( 'expires' , EdmType :: INT32 , time ( ) ) ; $ this -> _tableRestProxy -> insertEntity ( $ this -> _sessionContainer , $ entity ) ; } return TRUE ; }
Callback function for session handler . It s invoked while the session data is being written .