Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
c6ddabc8
Commit
c6ddabc8
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-4351: limit the participant folder peek view to current participants
parent
5cd865e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/course/nodes/PFCourseNode.java
+19
-14
19 additions, 14 deletions
src/main/java/org/olat/course/nodes/PFCourseNode.java
src/main/java/org/olat/course/nodes/pf/ui/PFPeekviewController.java
+15
-21
15 additions, 21 deletions
...ava/org/olat/course/nodes/pf/ui/PFPeekviewController.java
with
34 additions
and
35 deletions
src/main/java/org/olat/course/nodes/PFCourseNode.java
+
19
−
14
View file @
c6ddabc8
...
...
@@ -22,7 +22,9 @@ package org.olat.course.nodes;
import
java.io.File
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -164,9 +166,9 @@ public class PFCourseNode extends AbstractAccessableCourseNode {
public
boolean
isInDropboxTimeFrame
()
{
ModuleConfiguration
config
=
getModuleConfiguration
();
Date
start
=
config
.
getBooleanEntry
(
CONFIG_KEY_DATESTART
)
!=
null
?
(
Date
)
config
.
getDateValue
(
CONFIG_KEY_DATESTART
)
:
new
Date
();
config
.
getDateValue
(
CONFIG_KEY_DATESTART
)
:
new
Date
();
Date
end
=
config
.
getBooleanEntry
(
CONFIG_KEY_DATEEND
)
!=
null
?
(
Date
)
config
.
getDateValue
(
CONFIG_KEY_DATEEND
)
:
new
Date
();
config
.
getDateValue
(
CONFIG_KEY_DATEEND
)
:
new
Date
();
Date
current
=
new
Date
();
return
start
.
before
(
current
)
&&
end
.
after
(
current
);
...
...
@@ -182,13 +184,13 @@ public class PFCourseNode extends AbstractAccessableCourseNode {
public
Date
getDateStart
()
{
ModuleConfiguration
config
=
getModuleConfiguration
();
return
config
.
getBooleanEntry
(
CONFIG_KEY_DATESTART
)
!=
null
?
(
Date
)
config
.
getDateValue
(
CONFIG_KEY_DATESTART
)
:
new
Date
();
config
.
getDateValue
(
CONFIG_KEY_DATESTART
)
:
new
Date
();
}
public
Date
getDateEnd
()
{
ModuleConfiguration
config
=
getModuleConfiguration
();
return
config
.
getBooleanEntry
(
CONFIG_KEY_DATEEND
)
!=
null
?
(
Date
)
config
.
getDateValue
(
CONFIG_KEY_DATEEND
)
:
new
Date
();
config
.
getDateValue
(
CONFIG_KEY_DATEEND
)
:
new
Date
();
}
...
...
@@ -228,28 +230,31 @@ public class PFCourseNode extends AbstractAccessableCourseNode {
@Override
public
Controller
createPeekViewRunController
(
UserRequest
ureq
,
WindowControl
wControl
,
UserCourseEnvironment
userCourseEnv
,
NodeEvaluation
ne
)
{
VFSContainer
rootFolder
=
null
;
CourseEnvironment
courseEnv
=
userCourseEnv
.
getCourseEnvironment
();
Identity
identity
=
userCourseEnv
.
getIdentityEnvironment
().
getIdentity
();
Path
folderRelPath
=
null
;
List
<
VFSContainer
>
rootFolder
=
new
ArrayList
<>();
LocalFolderImpl
baseContainer
=
courseEnv
.
getCourseBaseContainer
();
PFManager
pfManager
=
CoreSpringFactory
.
getImpl
(
PFManager
.
class
);
if
(
userCourseEnv
.
isCoach
()
||
userCourseEnv
.
isAdmin
())
{
folderRelPath
=
Paths
.
get
(
baseContainer
.
getBasefile
().
toPath
().
toString
(),
PFManager
.
FILENAME_PARTICIPANTFOLDER
,
getIdent
());
rootFolder
=
new
LocalFolderImpl
(
folderRelPath
.
toFile
());
List
<
Identity
>
participants
=
pfManager
.
getParticipants
(
identity
,
courseEnv
,
userCourseEnv
.
isAdmin
());
for
(
Identity
participant:
participants
)
{
Path
folderRelPath
=
Paths
.
get
(
baseContainer
.
getBasefile
().
toPath
().
toString
(),
PFManager
.
FILENAME_PARTICIPANTFOLDER
,
getIdent
(),
pfManager
.
getIdFolderName
(
participant
));
rootFolder
.
add
(
new
LocalFolderImpl
(
folderRelPath
.
toFile
()));
}
}
else
if
(
userCourseEnv
.
isParticipant
())
{
folderRelPath
=
Paths
.
get
(
baseContainer
.
getBasefile
().
toPath
().
toString
(),
Path
folderRelPath
=
Paths
.
get
(
baseContainer
.
getBasefile
().
toPath
().
toString
(),
PFManager
.
FILENAME_PARTICIPANTFOLDER
,
getIdent
(),
pfManager
.
getIdFolderName
(
identity
));
rootFolder
=
new
LocalFolderImpl
(
folderRelPath
.
toFile
());
rootFolder
.
add
(
new
LocalFolderImpl
(
folderRelPath
.
toFile
())
)
;
}
if
(
rootFolder
==
null
)
{
if
(
rootFolder
.
isEmpty
()
)
{
return
super
.
createPeekViewRunController
(
ureq
,
wControl
,
userCourseEnv
,
ne
);
}
else
{
return
new
PFPeekviewController
(
ureq
,
wControl
,
rootFolder
,
getIdent
(),
4
);
}
return
new
PFPeekviewController
(
ureq
,
wControl
,
rootFolder
,
getIdent
(),
4
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/olat/course/nodes/pf/ui/PFPeekviewController.java
+
15
−
21
View file @
c6ddabc8
...
...
@@ -25,7 +25,6 @@ import java.util.Comparator;
import
java.util.Date
;
import
java.util.List
;
import
org.olat.core.CoreSpringFactory
;
import
org.olat.core.commons.modules.bc.FolderModule
;
import
org.olat.core.gui.UserRequest
;
import
org.olat.core.gui.components.Component
;
...
...
@@ -45,6 +44,7 @@ import org.olat.core.util.vfs.VFSItem;
import
org.olat.core.util.vfs.VFSLeaf
;
import
org.olat.core.util.vfs.filters.VFSItemFilter
;
import
org.olat.core.util.vfs.filters.VFSSystemItemFilter
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
*
* @author Fabian Kiefer, fabian.kiefer@frentix.com, http://www.frentix.com
...
...
@@ -53,33 +53,34 @@ import org.olat.core.util.vfs.filters.VFSSystemItemFilter;
public
class
PFPeekviewController
extends
BasicController
implements
Controller
{
// comparator to sort the messages list by creation date
private
static
final
Comparator
<
VFSLeaf
>
dateSortingComparator
=
new
Comparator
<
VFSLeaf
>(){
public
int
compare
(
final
VFSLeaf
leaf1
,
final
VFSLeaf
leaf2
)
{
return
Long
.
valueOf
(
leaf2
.
getLastModified
()).
compareTo
(
leaf1
.
getLastModified
());
//last first
}};
private
static
final
Comparator
<
VFSLeaf
>
dateSortingComparator
=
(
leaf1
,
leaf2
)
->
Long
.
compare
(
leaf2
.
getLastModified
(),
leaf1
.
getLastModified
());
//last first
// the current course node id
private
final
String
nodeId
;
private
static
final
VFSItemFilter
attachmentExcludeFilter
=
new
VFSSystemItemFilter
();
public
PFPeekviewController
(
UserRequest
ureq
,
WindowControl
wControl
,
VFSContainer
rootFolder
,
String
nodeId
,
int
itemsToDisplay
)
{
@Autowired
private
FolderModule
folderModule
;
public
PFPeekviewController
(
UserRequest
ureq
,
WindowControl
wControl
,
List
<
VFSContainer
>
folders
,
String
nodeId
,
int
itemsToDisplay
)
{
super
(
ureq
,
wControl
);
this
.
nodeId
=
nodeId
;
VelocityContainer
peekviewVC
=
createVelocityContainer
(
"peekview"
);
// add items, only as many as configured
List
<
VFSLeaf
>
allLeafs
=
new
ArrayList
<>();
addItems
(
rootFolder
,
allLeafs
);
for
(
VFSContainer
rootFolder:
folders
)
{
addItems
(
rootFolder
,
allLeafs
);
}
// Sort messages by last modified date
Collections
.
sort
(
allLeafs
,
dateSortingComparator
);
boolean
forceDownload
=
CoreSpringFactory
.
getImpl
(
F
olderModule
.
class
).
isForceDownload
();
boolean
forceDownload
=
f
olderModule
.
isForceDownload
();
// only take the configured amount of messages
List
<
VFSLeaf
>
leafs
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
allLeafs
.
size
();
i
++)
{
if
(
leafs
.
size
()
==
itemsToDisplay
)
{
break
;
}
for
(
int
i
=
0
;
i
<
allLeafs
.
size
()
&&
i
<
itemsToDisplay
;
i
++)
{
VFSLeaf
leaf
=
allLeafs
.
get
(
i
);
leafs
.
add
(
leaf
);
// add link to item
...
...
@@ -90,8 +91,6 @@ public class PFPeekviewController extends BasicController implements Controller
CSSHelper
.
createFiletypeIconCssClassFor
(
leaf
.
getName
()));
dlComp
.
setElementCssClass
(
"o_gotoNode"
);
peekviewVC
.
put
(
"nodeLinkDL_"
+(
i
+
1
),
dlComp
);
}
else
{
// hu? don't konw how to work with non-local impls
}
}
peekviewVC
.
contextPut
(
"leafs"
,
leafs
);
...
...
@@ -124,15 +123,10 @@ public class PFPeekviewController extends BasicController implements Controller
// exclude files which are also excluded in FolderComponent
for
(
VFSItem
vfsItem
:
container
.
getItems
(
attachmentExcludeFilter
))
{
if
(
vfsItem
instanceof
VFSLeaf
)
{
// add leaf to our list
VFSLeaf
leaf
=
(
VFSLeaf
)
vfsItem
;
allLeafs
.
add
(
leaf
);
allLeafs
.
add
((
VFSLeaf
)
vfsItem
);
}
else
if
(
vfsItem
instanceof
VFSContainer
)
{
// do it recursively for all children
VFSContainer
childContainer
=
(
VFSContainer
)
vfsItem
;
addItems
(
childContainer
,
allLeafs
);
}
else
{
// hu?
addItems
((
VFSContainer
)
vfsItem
,
allLeafs
);
}
}
}
...
...
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