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
ec5ebbab
Commit
ec5ebbab
authored
12 years ago
by
jkraehemann
Browse files
Options
Downloads
Patches
Plain Diff
OO-296: implemented some utility methods
parent
ff327e76
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/test/java/org/olat/util/EPortfolioTOCStructurePosition.vm
+38
-0
38 additions, 0 deletions
...test/java/org/olat/util/EPortfolioTOCStructurePosition.vm
src/test/java/org/olat/util/FunctionalEPortfolioUtil.java
+80
-16
80 additions, 16 deletions
src/test/java/org/olat/util/FunctionalEPortfolioUtil.java
with
118 additions
and
16 deletions
src/test/java/org/olat/util/EPortfolioTOCStructurePosition.vm
0 → 100644
+
38
−
0
View file @
ec5ebbab
position = -1;
if(document.querySelector)
{
var selector = "
${
tocSelector
}
";
var level1 = "
${
level1
}
";
var level2 = "
${
level2
}
";
var page = "
${
page
}
";
var structure = "
${
structure
}
";
var selection = window.document.querySelectorAll(selector);
for(i = 0; i
<
selection.length
;
i
++){
var
current =
selection.item(i);
if
(
current.className.indexOf
(
level1
)
>
= 0)
{
var currentPage = document.evaluate('//a//span[contains(text(), \'' + page + '\')]', current, null, XPathResult.ANY_TYPE, null);
if(currentPage != null)
{
current = selection.item(i + 1);
for(j = 0; current.className.indexOf(level2) >= 0; j++)
{
current = selection.item(i + 1 + j);
var currentStructure = document.evaluate('//a//span[contains(text(), \'' + structure + '\')]', current, null, XPathResult.ANY_TYPE, null);
if(currentStructure != null)
{
position = i + 1 + j;
break;
}
}
break;
}
}
}
}
position;
This diff is collapsed.
Click to expand it.
src/test/java/org/olat/util/FunctionalEPortfolioUtil.java
+
80
−
16
View file @
ec5ebbab
...
...
@@ -19,9 +19,16 @@
*/
package
org.olat.util
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
org.apache.velocity.VelocityContext
;
import
org.apache.velocity.app.VelocityEngine
;
import
org.apache.velocity.exception.MethodInvocationException
;
import
org.apache.velocity.exception.ParseErrorException
;
import
org.apache.velocity.exception.ResourceNotFoundException
;
import
org.olat.util.FunctionalHomeSiteUtil.EPortfolioAction
;
import
org.olat.util.FunctionalUtil.OlatSite
;
...
...
@@ -47,7 +54,9 @@ public class FunctionalEPortfolioUtil {
public
final
static
String
CREATE_TEMPLATE_BINDER_CSS
=
"o_sel_create_template_map"
;
public
final
static
String
OPEN_BINDER_ICON_CSS
=
"b_open_icon"
;
public
final
static
String
EPORTFOLIO_TABLE_OF_CONTENTS
=
"b_portfolio_toc"
;
public
final
static
String
EPORTFOLIO_TABLE_OF_CONTENTS_CSS
=
"b_portfolio_toc"
;
public
final
static
String
EPORTFOLIO_TOC_LEVEL1_CSS
=
"level1"
;
public
final
static
String
EPORTFOLIO_TOC_LEVEL2_CSS
=
"level2"
;
public
final
static
String
ADD_PAGE_CSS
=
"b_eportfolio_add_link"
;
public
final
static
String
PAGE_TABS_CSS
=
"b_pagination"
;
...
...
@@ -71,7 +80,9 @@ public class FunctionalEPortfolioUtil {
private
String
createTemplateBinderCss
;
private
String
openBinderCss
;
private
String
eportfolioTableOfContents
;
private
String
eportfolioTableOfContentsCss
;
private
String
eportfolioTOCLevel1Css
;
private
String
eportfolioTOCLevel2Css
;
private
String
addPageCss
;
private
String
pageTabsCss
;
...
...
@@ -97,6 +108,10 @@ public class FunctionalEPortfolioUtil {
setCreateTemplateBinderCss
(
CREATE_TEMPLATE_BINDER_CSS
);
setOpenBinderCss
(
OPEN_BINDER_ICON_CSS
);
setEPortfolioTableOfContentsCss
(
EPORTFOLIO_TABLE_OF_CONTENTS_CSS
);
setEPortfolioTOCLevel1Css
(
EPORTFOLIO_TOC_LEVEL1_CSS
);
setEPortfolioTOCLevel2Css
(
EPORTFOLIO_TOC_LEVEL2_CSS
);
setAddPageCss
(
ADD_PAGE_CSS
);
setPageTabsCss
(
PAGE_TABS_CSS
);
}
...
...
@@ -291,8 +306,10 @@ public class FunctionalEPortfolioUtil {
StringBuffer
selectorBuffer
=
new
StringBuffer
();
selectorBuffer
.
append
(
"xpath=//div[contains(@class, '"
)
.
append
(
getEPortfolioTableOfContents
())
.
append
(
"')]//ul//li//a//span[contains(text(), '"
)
.
append
(
getEPortfolioTableOfContentsCss
())
.
append
(
"')]//ul//li[contains(@class, '"
)
.
append
(
getEPortfolioTOCLevel1Css
())
.
append
(
"')]//a//span[contains(text(), '"
)
.
append
(
title
)
.
append
(
"')]"
);
...
...
@@ -378,13 +395,50 @@ public class FunctionalEPortfolioUtil {
StringBuffer
selectorBuffer
=
new
StringBuffer
();
//TODO:JK: implement me
selectorBuffer
.
append
(
"xpath=//div[contains(@class, '"
)
.
append
(
getEPortfolioTableOfContentsCss
())
.
append
(
"')]//ul//li"
);
if
(
browser
.
isElementPresent
(
selectorBuffer
.
toString
())){
return
(
true
);
}
else
{
return
(
false
);
VelocityContext
context
=
new
VelocityContext
();
context
.
put
(
"tocSelector"
,
selectorBuffer
.
toString
());
context
.
put
(
"level1"
,
getEPortfolioTOCLevel1Css
());
context
.
put
(
"level2"
,
getEPortfolioTOCLevel2Css
());
context
.
put
(
"page"
,
page
);
context
.
put
(
"structure"
,
title
);
VelocityEngine
engine
=
null
;
engine
=
new
VelocityEngine
();
StringWriter
sw
=
new
StringWriter
();
try
{
engine
.
evaluate
(
context
,
sw
,
"eportfolioTOCStructurePosition"
,
FunctionalHomeSiteUtil
.
class
.
getResourceAsStream
(
"EPortfolioTOCStructurePosition.vm"
));
Integer
i
=
new
Integer
(
browser
.
getEval
(
sw
.
toString
()));
if
(
i
.
intValue
()
!=
-
1
){
return
(
true
);
}
else
{
return
(
false
);
}
}
catch
(
ParseErrorException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
MethodInvocationException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
ResourceNotFoundException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
(
false
);
}
/**
...
...
@@ -770,21 +824,33 @@ public class FunctionalEPortfolioUtil {
return
openBinderCss
;
}
public
void
setOpenBinderCss
(
String
openBinderCss
)
{
this
.
openBinderCss
=
openBinderCss
;
}
public
String
getEPortfolioTableOfContentsCss
()
{
return
eportfolioTableOfContentsCss
;
}
public
String
getEP
ortfolioTableOfContents
(
)
{
return
eportfolioTableOfContents
;
public
void
setEPortfolioTableOfContentsCss
(
String
ep
ortfolioTableOfContents
Css
)
{
this
.
eportfolioTableOfContentsCss
=
eportfolioTableOfContents
Css
;
}
public
String
getEPortfolioTOCLevel1Css
()
{
return
eportfolioTOCLevel1Css
;
}
public
void
setEPortfolioTOCLevel1Css
(
String
eportfolioTOCLevel1Css
)
{
this
.
eportfolioTOCLevel1Css
=
eportfolioTOCLevel1Css
;
}
public
void
s
etEPortfolioT
ableOfContents
(
String
eportfolioTableOfContents
)
{
this
.
eportfolioTableOfContents
=
eportfolioTableOfContent
s
;
public
String
g
etEPortfolioT
OCLevel2Css
(
)
{
return
eportfolioTOCLevel2Cs
s
;
}
public
void
setEPortfolioTOCLevel2Css
(
String
eportfolioTOCLevel2Css
)
{
this
.
eportfolioTOCLevel2Css
=
eportfolioTOCLevel2Css
;
}
public
String
getAddPageCss
()
{
return
addPageCss
;
...
...
@@ -794,12 +860,10 @@ public class FunctionalEPortfolioUtil {
this
.
addPageCss
=
addPageCss
;
}
public
String
getPageTabsCss
()
{
return
pageTabsCss
;
}
public
void
setPageTabsCss
(
String
pageTabsCss
)
{
this
.
pageTabsCss
=
pageTabsCss
;
}
...
...
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