Skip to content

Commit

Permalink
MDL-71470 repository_googledocs: Use file name in the source attribute
Browse files Browse the repository at this point in the history
Instead of using the file title when generating the source attribute,
we should be using only the name of the Google Drive file in order to
avoid having the original extension within the filename after the file
is imported and added into Moodle.
  • Loading branch information
Mihail Geshoski committed Apr 28, 2021
1 parent a5f0b35 commit 0ce5195
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion repository/googledocs/classes/local/node/file_node.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class file_node implements node {
/** @var string|null The title of the file node. */
private $title;

/** @var string The name of the file. */
private $name;

/** @var string|null The file's export format. */
private $exportformat;

Expand All @@ -54,6 +57,7 @@ class file_node implements node {
public function __construct(\stdClass $gdfile) {
$this->id = $gdfile->id;
$this->title = $this->generate_file_title($gdfile);
$this->name = $gdfile->name;
$this->exportformat = $this->generate_file_export_format($gdfile);
$this->link = $this->generate_file_link($gdfile);
$this->modified = ($gdfile->modifiedTime) ? strtotime($gdfile->modifiedTime) : '';
Expand Down Expand Up @@ -90,7 +94,7 @@ public function create_node_array(): ?array {
'source' => json_encode(
[
'id' => $this->id,
'name' => $this->title,
'name' => $this->name,
'link' => $this->link,
'exportformat' => $this->exportformat,
]
Expand Down

0 comments on commit 0ce5195

Please sign in to comment.