Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
attempt_mgmt
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
attempt_mgmt
Commits
9e850b04
Commit
9e850b04
authored
3 months ago
by
Paul Mrvik
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3487209
by globexplorer: Once an attempt has been set to closed it should stop to update!
parent
74758003
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/AttemptFactory.php
+31
-13
31 additions, 13 deletions
src/AttemptFactory.php
with
31 additions
and
13 deletions
src/AttemptFactory.php
+
31
−
13
View file @
9e850b04
...
...
@@ -188,7 +188,7 @@ final class AttemptFactory {
}
public
function
getAttemptFieldByProperty
(
$entity
,
$property
)
{
public
function
getAttemptFieldByProperty
(
EntityInterface
$entity
,
$property
)
{
$field_value
=
NULL
;
...
...
@@ -204,15 +204,10 @@ final class AttemptFactory {
$field
=
NULL
;
if
(
$entity
instanceof
EntityInterface
)
{
$bundle
=
$entity
->
bundle
();
if
(
$attempt_field
=
$this
->
getAvailableAttemptManagementField
(
$entity
->
getEntityTypeId
(),
$entity
->
bundle
()))
{
if
(
$field
=
$entity
->
get
(
$attempt_field
)
->
getValue
())
{
$field
=
$field
[
0
];
}
}
if
(
$attempt_field
=
$this
->
getAvailableAttemptManagementField
(
$entity
->
getEntityTypeId
(),
$entity
->
bundle
()))
{
if
(
$field
=
$entity
->
get
(
$attempt_field
)
->
getValue
())
{
$field
=
$field
[
0
];
}
}
return
$field
;
...
...
@@ -311,10 +306,10 @@ final class AttemptFactory {
$update_previous_attempt
=
FALSE
;
}
if
(
$entity
instanceof
EntityInterface
)
{
// Write attempt and return UUID
if
(
$attempt_type
=
$this
->
getAttemptFieldByProperty
(
$entity
,
'attempt_type'
))
{
if
(
$entity
)
{
// Write attempt and return UUID
if
(
$attempt_type
=
$this
->
getAttemptFieldByProperty
(
$entity
,
'attempt_type'
))
{
try
{
$storage
=
$this
->
entityTypeManager
->
getStorage
(
'attempt_mgmt_attempt'
);
...
...
@@ -376,11 +371,34 @@ final class AttemptFactory {
}
}
/**
* Check if attempt closed
*
* @param string $attempt_uuid
* The uuid for the attempt
*
* @return bool
* TRUE | FALSE.
*/
protected
function
isAttemptClosed
(
$attempt_uuid
)
{
$attempts
=
$this
->
entityTypeManager
->
getStorage
(
'attempt_mgmt_attempt'
)
->
loadByProperties
([
'uuid'
=>
$attempt_uuid
,
'closed'
=>
TRUE
]);
if
(
!
empty
(
$attempts
))
{
return
TRUE
;
}
return
FALSE
;
}
public
function
updateAttempt
(
string
$attempt_uuid
,
array
$field_data
,
EntityInterface
$entity
,
$user_id
,
$finished
=
FALSE
):
bool
{
$success
=
FALSE
;
// First let's check if the attempt is closed. When closed no update should be done!
$attempt_closed
=
$this
->
isAttemptClosed
(
$attempt_uuid
);
if
(
$attempt_closed
)
{
return
$success
;
}
// For anon. user we need to save the session id.
if
(
$user_id
==
0
)
{
$session_id
=
$this
->
getSessionIDForUnauthenticatedUsers
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment