Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle_mod-hvp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle_mod-hvp
Commits
5cff08e2
Commit
5cff08e2
authored
8 years ago
by
Frode Petterson
Browse files
Options
Downloads
Patches
Plain Diff
Use coursemodule property for content files
This fixes content file handling issues when creating new content.
parent
2b9f59be
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/file_storage.php
+19
-15
19 additions, 15 deletions
classes/file_storage.php
editor
+1
-1
1 addition, 1 deletion
editor
lib.php
+1
-1
1 addition, 1 deletion
lib.php
with
21 additions
and
17 deletions
classes/file_storage.php
+
19
−
15
View file @
5cff08e2
...
@@ -378,9 +378,9 @@ class file_storage implements \H5PFileStorage {
...
@@ -378,9 +378,9 @@ class file_storage implements \H5PFileStorage {
*
*
* @param string $file path + name
* @param string $file path + name
* @param string|int $fromid Content ID or 'editor' string
* @param string|int $fromid Content ID or 'editor' string
* @param
int $toid
Target Content
ID
* @param
stdClass $tocontent
Target Content
*/
*/
public
function
cloneContentFile
(
$file
,
$fromid
,
$to
id
)
{
public
function
cloneContentFile
(
$file
,
$fromid
,
$to
content
)
{
// Determine source file area and item id
// Determine source file area and item id
$sourcefilearea
=
(
$fromid
===
'editor'
?
$fromid
:
'content'
);
$sourcefilearea
=
(
$fromid
===
'editor'
?
$fromid
:
'content'
);
$sourceitemid
=
(
$fromid
===
'editor'
?
0
:
$fromid
);
$sourceitemid
=
(
$fromid
===
'editor'
?
0
:
$fromid
);
...
@@ -392,20 +392,19 @@ class file_storage implements \H5PFileStorage {
...
@@ -392,20 +392,19 @@ class file_storage implements \H5PFileStorage {
}
}
// Check to make sure source doesn't exist already
// Check to make sure source doesn't exist already
if
(
$this
->
getFile
(
'content'
,
$to
id
,
$file
)
!==
false
)
{
if
(
$this
->
getFile
(
'content'
,
$to
content
,
$file
)
!==
false
)
{
return
;
// File exists, no need to copy
return
;
// File exists, no need to copy
}
}
// Grab context for cm
// Grab context for CM
$cm
=
\get_coursemodule_from_instance
(
'hvp'
,
$toid
);
$context
=
\context_module
::
instance
(
$tocontent
->
coursemodule
);
$context
=
\context_module
::
instance
(
$cm
->
id
);
// Create new file record
// Create new file record
$record
=
array
(
$record
=
array
(
'contextid'
=>
$context
->
id
,
'contextid'
=>
$context
->
id
,
'component'
=>
'mod_hvp'
,
'component'
=>
'mod_hvp'
,
'filearea'
=>
'content'
,
'filearea'
=>
'content'
,
'itemid'
=>
$toid
,
'itemid'
=>
$to
content
->
id
,
'filepath'
=>
$this
->
getFilepath
(
$file
),
'filepath'
=>
$this
->
getFilepath
(
$file
),
'filename'
=>
$this
->
getFilename
(
$file
)
'filename'
=>
$this
->
getFilename
(
$file
)
);
);
...
@@ -418,11 +417,11 @@ class file_storage implements \H5PFileStorage {
...
@@ -418,11 +417,11 @@ class file_storage implements \H5PFileStorage {
* Used when saving content.
* Used when saving content.
*
*
* @param string $file path + name
* @param string $file path + name
* @param
int
$content
id
* @param
stdClass
$content
* @return string|int File ID or NULL if not found
* @return string|int File ID or NULL if not found
*/
*/
public
function
getContentFile
(
$file
,
$content
id
)
{
public
function
getContentFile
(
$file
,
$content
)
{
$file
=
$this
->
getFile
(
'content'
,
$content
id
,
$file
);
$file
=
$this
->
getFile
(
'content'
,
$content
,
$file
);
return
(
$file
===
false
?
null
:
$file
->
get_id
());
return
(
$file
===
false
?
null
:
$file
->
get_id
());
}
}
...
@@ -431,10 +430,10 @@ class file_storage implements \H5PFileStorage {
...
@@ -431,10 +430,10 @@ class file_storage implements \H5PFileStorage {
* Used when saving content.
* Used when saving content.
*
*
* @param string $file path + name
* @param string $file path + name
* @param
int
$content
id
* @param
stdClass
$content
*/
*/
public
function
removeContentFile
(
$file
,
$content
id
)
{
public
function
removeContentFile
(
$file
,
$content
)
{
$file
=
$this
->
getFile
(
'content'
,
$content
id
,
$file
);
$file
=
$this
->
getFile
(
'content'
,
$content
,
$file
);
if
(
$file
!==
false
)
{
if
(
$file
!==
false
)
{
$file
->
delete
();
$file
->
delete
();
}
}
...
@@ -547,7 +546,7 @@ class file_storage implements \H5PFileStorage {
...
@@ -547,7 +546,7 @@ class file_storage implements \H5PFileStorage {
* Help make it easy to load content files.
* Help make it easy to load content files.
*
*
* @param string $filearea
* @param string $filearea
* @param int $itemid
* @param int
|stdClass
$itemid
* @param string $file path + name
* @param string $file path + name
*/
*/
private
function
getFile
(
$filearea
,
$itemid
,
$file
)
{
private
function
getFile
(
$filearea
,
$itemid
,
$file
)
{
...
@@ -557,8 +556,13 @@ class file_storage implements \H5PFileStorage {
...
@@ -557,8 +556,13 @@ class file_storage implements \H5PFileStorage {
// Use Course context
// Use Course context
$context
=
\context_course
::
instance
(
$COURSE
->
id
);
$context
=
\context_course
::
instance
(
$COURSE
->
id
);
}
}
elseif
(
is_object
(
$itemid
))
{
// Grab CM context from item
$context
=
\context_module
::
instance
(
$itemid
->
coursemodule
);
$itemid
=
$itemid
->
id
;
}
else
{
else
{
// Use CM context
// Use
item ID to find
CM context
$cm
=
\get_coursemodule_from_instance
(
'hvp'
,
$itemid
);
$cm
=
\get_coursemodule_from_instance
(
'hvp'
,
$itemid
);
$context
=
\context_module
::
instance
(
$cm
->
id
);
$context
=
\context_module
::
instance
(
$cm
->
id
);
}
}
...
...
This diff is collapsed.
Click to expand it.
editor
@
d1ad5947
Compare
23f20f7b
...
d1ad5947
Subproject commit
23f20f7bafd8e8c9ddafe5a6768c42f01975b0e7
Subproject commit
d1ad5947b82ccbe2c3badad8d804f4d44fdc8efa
This diff is collapsed.
Click to expand it.
lib.php
+
1
−
1
View file @
5cff08e2
...
@@ -159,7 +159,7 @@ function hvp_save_content($hvp) {
...
@@ -159,7 +159,7 @@ function hvp_save_content($hvp) {
$params
=
json_decode
(
$hvp
->
params
);
$params
=
json_decode
(
$hvp
->
params
);
// Move any uploaded images or files. Determine content dependencies.
// Move any uploaded images or files. Determine content dependencies.
$editor
->
processParameters
(
$hvp
->
id
,
$hvp
->
library
,
$params
,
isset
(
$oldlib
)
?
$oldlib
:
NULL
,
isset
(
$oldparams
)
?
$oldparams
:
NULL
);
$editor
->
processParameters
(
$hvp
,
$hvp
->
library
,
$params
,
isset
(
$oldlib
)
?
$oldlib
:
NULL
,
isset
(
$oldparams
)
?
$oldparams
:
NULL
);
}
}
return
$hvp
->
id
;
return
$hvp
->
id
;
...
...
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