Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
f9d4f332
Commit
f9d4f332
authored
Mar 01, 2019
by
Doris Tam
Committed by
Robert Lyon
Jun 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 1810990: blocktypes: taggedposts, recentposts, documentation
Change-Id: Id0747afe59b8030ae9493513445217a29a626fd8
parent
a3943d46
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
171 additions
and
63 deletions
+171
-63
htdocs/testing/classes/generator/TestingDataGenerator.php
htdocs/testing/classes/generator/TestingDataGenerator.php
+146
-27
test/behat/features/user_content/test.feature
test/behat/features/user_content/test.feature
+25
-36
No files found.
htdocs/testing/classes/generator/TestingDataGenerator.php
View file @
f9d4f332
...
...
@@ -735,6 +735,15 @@ EOD;
if
(
is_callable
(
$classname
.
'::'
.
$functionname
))
{
$result
=
call_static_method
(
$classname
,
$functionname
,
$sortedfields
,
$ownertype
,
$ownerid
,
$title
,
$view
);
$configdata
=
array_merge
(
$configdata
,
(
array
)
$result
);
// make new block
$blockinstance
=
self
::
create_new_block_instance
(
$blocktype
,
$view
,
$viewid
,
$title
,
self
::
$viewcolcounts
,
$configdata
,
$maxcols
);
//taggedposts blocktype - block instance needs to pre-exist
if
(
$functionname
==
'generate_configdata_taggedposts'
)
{
PluginBlocktypeTaggedposts
::
instance_config_save
(
$configdata
,
$blockinstance
);
}
// setting tags to blocks
self
::
set_block_tags
(
$view
,
$blockinstance
,
$ownertype
,
$ownerid
,
$configdata
);
}
else
{
throw
new
SystemException
(
"The blocktype
{
$record
[
'type'
]
}
is not supported yet."
);
...
...
@@ -766,6 +775,53 @@ EOD;
}
else
{
$bi
->
commit
();
return
$bi
;
}
}
/**
* Set tags for blocks from information in configdata
*
* the configdata array is different from normal mahara db so that the tags
* can be stored somewhere until after the block instance has been created to be added.
*
* @param BlockInstance $bi
* @param string $ownertype
* @param int $ownerid
* @param array $configdata
*/
public
static
function
set_block_tags
(
$view
,
$bi
,
$ownertype
,
$ownerid
,
$configdata
)
{
if
(
!
array_key_exists
(
'tags'
,
$configdata
))
return
;
if
(
$view
->
get
(
'group'
))
{
$ownertype
=
'group'
;
}
else
if
(
$view
->
get
(
'institution'
))
{
$ownertype
=
'institution'
;
}
else
{
$ownertype
=
'user'
;
}
if
(
$tags
=
$configdata
[
'tags'
])
{
$tags
=
check_case_sensitive
(
$tags
,
'tag'
);
delete_records
(
'tag'
,
'resourcetype'
,
'blocktype'
,
'resourceid'
,
$bi
->
get
(
'id'
));
foreach
(
$tags
as
$tag
)
{
// truncate the tag before insert it into the database
$tag
=
substr
(
$tag
,
0
,
128
);
$tag
=
check_if_institution_tag
(
$tag
);
insert_record
(
'tag'
,
(
object
)
array
(
'resourcetype'
=>
'blocktype'
,
'resourceid'
=>
$bi
->
get
(
'id'
),
'ownertype'
=>
$ownertype
,
'ownerid'
=>
$ownerid
,
'tag'
=>
$tag
,
'ctime'
=>
db_format_timestamp
(
time
()),
'editedby'
=>
$ownerid
,
)
);
}
}
}
...
...
@@ -774,7 +830,7 @@ EOD;
* displaying the blogs that were created using the function create_blog
* given a matching blog title
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_blog
(
$sortedfields
)
{
...
...
@@ -802,7 +858,7 @@ EOD;
* displaying the blogposts that were created using the function create_blogpost
* matching a given blog and entry title
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_blogpost
(
$sortedfields
)
{
...
...
@@ -832,16 +888,16 @@ EOD;
/**
* generate a comment blocktype.
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array with redundant information as there is no specific artefact connected to it.
*/
public
static
function
generate_configdata_comment
(
$
data
)
{
public
static
function
generate_configdata_comment
(
$
sortedfields
)
{
return
array
();
}
/**
* generate configdata and instance for blocktype: creativecommons
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_creativecommons
(
$sortedfields
)
{
...
...
@@ -879,7 +935,7 @@ EOD;
*
* doesn't work in group pages
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -899,7 +955,7 @@ EOD;
/**
* generate configdata for the blocktype: rss feeds/external feeds
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_externalfeed
(
$sortedfields
)
{
...
...
@@ -924,7 +980,7 @@ EOD;
/**
* generate configdata for the blocktype: external video
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_externalvideo
(
$sortedfields
)
{
...
...
@@ -938,7 +994,7 @@ EOD;
/**
* generate configdata for the blocktype: filedownload
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -996,7 +1052,7 @@ EOD;
/**
* generate configdata for blocktype: gallery
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -1063,7 +1119,7 @@ EOD;
/**
* generate configdata for blocktype: html
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -1081,7 +1137,7 @@ EOD;
/**
* generate configdata for the blocktype: image
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -1101,7 +1157,7 @@ EOD;
/**
* generate configdata for the blocktype: internalmedia aka 'embeddedmedia
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
...
...
@@ -1136,7 +1192,7 @@ EOD;
/**
* generate configdata for the blocktype: navigation and create navblocks*
* **when copytoall is true**
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @param string $title of block to be created* (when copytoall is true)
...
...
@@ -1198,7 +1254,7 @@ EOD;
/**
* generate configdata for the blocktype: pdf
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
...
...
@@ -1216,7 +1272,7 @@ EOD;
/**
* generate configdata for the blocktype: plans
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
...
...
@@ -1246,7 +1302,7 @@ EOD;
* As well as going thorugh the general fields in the data column of the table,
* an ArtefactTypeProfileIcon is created as there are none created in bulk.
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
...
...
@@ -1296,7 +1352,9 @@ EOD;
/**
* generate configdata for blocktype: recentforumposts
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* The recentforumposts blocktype displays forumposts for a given group.
*
* @param array $sortedfields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
...
...
@@ -1323,9 +1381,36 @@ EOD;
return
$configdata
;
}
/**
* generate configdata for the blocktype: recentposts
*
* The recentposts blocktypes displays a list of recent posts for the given
* journal/blog name.
*
* @param array $sortedfields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values of db table
*/
public
static
function
generate_configdata_recentposts
(
$sortedfields
,
$ownertype
,
$ownerid
)
{
$configdata
=
array
();
foreach
(
$sortedfields
as
$key
=>
$value
)
{
if
(
$key
==
'maxposts'
)
{
$configdata
[
'count'
]
=
$value
>
0
?
$value
:
10
;
}
if
(
$key
==
'journaltitle'
)
{
if
(
!
$blogid
=
get_field
(
'artefact'
,
'id'
,
'title'
,
$value
,
'artefacttype'
,
'blog'
))
{
throw
new
SystemException
(
"A blog/journal named "
.
$value
.
" doesn't exist!"
);
}
$configdata
[
'artefactids'
][]
=
$blogid
;
}
}
return
$configdata
;
}
/**
* generate configdata for the blocktype: resumefield
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -1345,7 +1430,7 @@ EOD;
/**
* generate configdata for the blocktype: social profile
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @return array $configdata of key and values for db table
...
...
@@ -1355,7 +1440,6 @@ EOD;
if
(
$key
==
'sns'
)
{
//split the values for multiple social profile creation
$medialist
=
explode
(
','
,
$value
);
$value
=
array
();
foreach
(
$medialist
as
$media
)
{
$newprofile
=
new
ArtefactTypeSocialprofile
();
$newprofile
->
set
(
'owner'
,
$ownerid
);
...
...
@@ -1371,6 +1455,35 @@ EOD;
}
}
/**
* generate configdata for the blocktype: taggedposts
*
* The blocktype taggedposts displays a list of Journal Entries with the
* given tag
*
* @param array $sortedfields holding each chunk of data between the ; in the behat data column
* @return array $configdata of key and values for db table
*/
public
static
function
generate_configdata_taggedposts
(
$sortedfields
)
{
$configdata
=
array
();
foreach
(
$sortedfields
as
$key
=>
$value
)
{
if
(
$key
==
'maxposts'
)
{
$configdata
[
'count'
]
=
$value
>
0
?
$value
:
10
;
}
if
(
$key
==
'tags'
)
{
$tags
=
explode
(
','
,
$value
);
$configdata
[
'tagselect'
]
=
$tags
;
}
if
(
$key
==
'showfullentries'
)
{
$configdata
[
'full'
]
=
strtolower
(
$value
)
==
'no'
?
1
:
0
;
}
if
(
$key
==
'copytype'
)
{
$configdata
[
$key
]
=
strtolower
(
$value
)
==
'nocopy'
?
$value
:
'tagsonly'
;
}
}
return
$configdata
;
}
/**
* generate configdata for the blocktype: text
* @param string inside data column in behat test
...
...
@@ -1393,7 +1506,7 @@ EOD;
* holding an html artefact
* NOTE:the title of a textbox block is the same as the html artefact the textbox it is associated with; not the title of a block instance
*
* @param array $fields holding each chunk of data between the ; in the behat data column
* @param array $
sorted
fields holding each chunk of data between the ; in the behat data column
* @param string $ownertype of user
* @param string $ownerid of the user
* @param string $title of block to be created* (when copytoall is true)
...
...
@@ -2472,12 +2585,18 @@ EOD;
public
function
create_educationhistory
(
$record
)
{
$itemdata
=
array
();
$userid
=
$this
->
get_user_id
(
$record
[
'user'
]);
$artefact
=
null
;
// create artefact
$artefact
=
new
ArtefactTypeEducationhistory
();
$artefact
->
set
(
'owner'
,
$this
->
get_user_id
(
$record
[
'user'
]));
$artefact
->
commit
();
$itemdata
[
'artefact'
]
=
$artefact
->
get
(
'id'
);
if
(
$artefactid
=
get_field
(
'artefact'
,
'id'
,
'artefacttype'
,
'educationhistory'
))
{
$artefact
=
new
ArtefactTypeEducationhistory
(
$artefactid
,
null
);
$itemdata
[
'artefact'
]
=
$artefact
->
get
(
'id'
);
}
else
{
$artefact
=
new
ArtefactTypeEducationhistory
();
$artefact
->
set
(
'owner'
,
$this
->
get_user_id
(
$record
[
'user'
]));
$artefact
->
commit
();
$itemdata
[
'artefact'
]
=
$artefact
->
get
(
'id'
);
}
$formelements
=
ArtefactTypeEducationhistory
::
get_addform_elements
();
foreach
(
$formelements
as
$element
=>
$value
)
{
...
...
test/behat/features/user_content/test.feature
View file @
f9d4f332
...
...
@@ -160,48 +160,37 @@ Background:
|
Comments
|
comment
|
Page
One
|
no
|
|
|
Peer
Assessment
|
peerassessment
|
Page
One
|
auto
|
|
|
Creative
Commons
|
creativecommons
|
Page
One
|
no
|
commercialuse=yes;license=3.0;allowmods=no
|
|
Navigation
|
navigation
|
Page
One
|
no
|
collection=collection
one;copytoall=yes
|
|
Plans
|
plans
|
Page
One
|
no
|
plans=Plan
One,Plan
Two;tasksdisplaycount=10
|
|
Internal
Media:
Video
|
internalmedia
|
Page
One
|
no
|
attachment=testvid3.mp4
|
|
Internal
Media:
Audio
|
internalmedia
|
Page
One
|
no
|
attachment=mahara.mp3
|
|
Pdf
|
pdf
|
Page
Two
|
no
|
attachment=mahara_about.pdf
|
|
Recent
Forum
Posts
|
recentforumposts
|
Page
Two
|
no
|
groupname=Group1;maxposts=3
|
|
External
Video
|
externalvideo
|
Page
Two
|
no
|
source=https://youtu.be/yRxFm70nOrY
|
|
Note/Textbox
1
|
textbox
|
Page
Two
|
no
|
notetitle=secretnote;text=ma
ha
ha
ha
ra!;tags=mahara,araham;attachments=Image3.png,Image2.png,Image1.jpg;allowcomments=yes
|
|
Note/textbox
ref:1
|
textbox
|
Page
Two
|
no
|
existingnote=secretnote
|
|
Note/Textbox
copy:1
|
textbox
|
Page
Two
|
no
|
existingnote=secretnote;allowcomments=yes;copynote=true;notetitle=newsecretnote
|
|
Profile
Information
|
profileinfo
|
Page
Two
|
no
|
introtext
=Mahara
unicorn
here!
Nice
to
meet
you
:);profileicon=Image1.jpg
|
|
Profile
Information
|
profileinfo
|
Page
Two
|
no
|
introtext
=Mahara
unicorn
here!
Nice
to
meet
you
:);profileicon=Image2.png
|
|
Résumé
|
entireresume
|
Page
Two
|
no
|
tags=mahara
|
|
Résumé:
Employment
Hist.
|
resumefield
|
Page
Two
|
no
|
artefacttype=employmenthistory
|
|
Résumé:
Personal
Goal
|
resumefield
|
Page
Two
|
no
|
artefacttype=personalgoal
|
|
Résumé:
Work
Skill
|
resumefield
|
Page
Two
|
no
|
artefacttype=workskill
|
|
Résumé:
Interest
|
resumefield
|
Page
Two
|
no
|
artefacttype=interest
|
|
GoogleApps:
Google
Maps
|
googleapps
|
Page
Two
|
no
|
googleapp=<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2997.861064367898!2d174.77176941597108!3d-41.29012814856559!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6d38afd6326bfda5%3A0x5c0d858838e52d7a!2sCatalyst!5e0!3m2!1sen!2snz!4v1550707486290"
width="800"
height="600"
frameborder="0"
style="border:0"
allowfullscreen></iframe>;height=100;tags=cat,dog,monkeys
|
|
GoogleApps:
Google
Calen
|
googleapps
|
Page
Two
|
no
|
googleapp=https://calendar.google.com/calendar/embed?src=en.new_zealand%23holiday%40group.v.calendar.google.com&ctz=Pacific%2FAuckland
|
|
Recent
journal
entries
|
recentposts
|
Page
One
|
no
|
journaltitle=journal1;maxposts=10
|
|
Tagged
journal
entries
|
taggedposts
|
Page
One
|
no
|
tags=cats;
maxposts=5;showfullentries=yes;copytype=nocopy
|
Scenario
:
Login as admin to change upload settings
# To allow users to upload specific internal media types
Given
I log in as
"admin"
with password
"Kupuh1pa!"
And
I go to
"/admin/extensions/pluginconfig.php?plugintype=blocktype&pluginname=file/internalmedia"
And I set the following fields to these values
:
|
3GPP
media
file
|
1
|
|
AVI
video
file
|
1
|
|
FLV
flash
movie
|
1
|
|
MP3
audio
file
|
1
|
|
MP4
media
file
|
1
|
|
MPEG
movie
|
1
|
|
OGA
audio
file
|
1
|
|
OGG
Vorbis
audio
file
|
1
|
|
OGV
video
file
|
1
|
|
QuickTime
movie
|
1
|
|
WEBM
video
file
|
1
|
|
WMV
video
file
|
1
|
And
I press
"Save"
And
I log out
And the following "blocks" exist
:
|
title
|
type
|
page
|
retractable
|
data
|
|
Pdf
|
pdf
|
Page
Two
|
no
|
attachment=mahara_about.pdf
|
|
Recent
Forum
Posts
|
recentforumposts
|
Page
Two
|
no
|
groupname=Group1;maxposts=3
|
|
External
Video
|
externalvideo
|
Page
Two
|
no
|
source=https://youtu.be/k5t5PD5F8Wo
|
|
Note/Textbox
1
|
textbox
|
Page
Two
|
no
|
notetitle=secretnote;text=ma
ha
ha
ha
ra!;tags=mahara,araham;attachments=Image3.png,Image2.png,Image1.jpg;allowcomments=yes
|
|
Note/textbox
ref:1
|
textbox
|
Page
Two
|
no
|
existingnote=secretnote
|
|
Note/Textbox
copy:1
|
textbox
|
Page
Two
|
no
|
existingnote=secretnote;allowcomments=yes;copynote=true;notetitle=newsecretnote
|
|
Profile
Information
|
profileinfo
|
Page
Two
|
no
|
introtext
=Mahara
unicorn
here!
Nice
to
meet
you
:);profileicon=Image1.jpg
|
|
Profile
Information
|
profileinfo
|
Page
Two
|
no
|
introtext
=Mahara
unicorn
here!
Nice
to
meet
you
:);profileicon=Image2.png
|
|
Résumé
|
entireresume
|
Page
Two
|
no
|
tags=mahara
|
|
Résumé:
Personal
Goal
|
resumefield
|
Page
Two
|
no
|
artefacttype=personalgoal
|
|
Résumé:
Work
Skill
|
resumefield
|
Page
Two
|
no
|
artefacttype=workskill
|
|
Résumé:
Interest
|
resumefield
|
Page
Two
|
no
|
artefacttype=interest
|
|
Résumé:
Achievements
|
resumefield
|
Page
Two
|
no
|
artefacttype=certification
|
|
Résumé:
Employment
Hist.
|
resumefield
|
Page
Two
|
no
|
artefacttype=employmenthistory
|
|
Résumé:
Books
|
resumefield
|
Page
Two
|
no
|
artefacttype=book
|
|
Résumé:
Memberships
|
resumefield
|
Page
Two
|
no
|
artefacttype=membership
|
|
Résumé:
Education
Hist.
|
resumefield
|
Page
Two
|
no
|
artefacttype=educationhistory
|
|
GoogleApps:
Google
Maps
|
googleapps
|
Page
Two
|
no
|
googleapp=<iframe
src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d2997.861064367898!2d174.77176941597108!3d-41.29012814856559!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x6d38afd6326bfda5%3A0x5c0d858838e52d7a!2sCatalyst!5e0!3m2!1sen!2snz!4v1550707486290"
width="800"
height="600"
frameborder="0"
style="border:0"
allowfullscreen></iframe>;height=200;tags=cat,dog,monkeys
|
|
GoogleApps:
Google
Cal.
|
googleapps
|
Page
Two
|
no
|
googleapp=https://calendar.google.com/calendar/embed?src=en.new_zealand%23holiday%40group.v.calendar.google.com&ctz=Pacific%2FAuckland
|
Then
I log in as
"UserA"
with password
"Kupuh1pa!"
Scenario
:
Login as admin to change upload settings
Given
I log in as
"UserA"
with password
"Kupuh1pa!"
And
I go to portfolio page
"Page UserA"
And
I go to portfolio page
"Page Grp1"
And
I go to portfolio page
"Page One"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment