Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
mod_workshop_portfolio_caller Class Reference

Workshop portfolio caller class to integrate with portfolio API. More...

Inheritance diagram for mod_workshop_portfolio_caller:
portfolio_module_caller_base portfolio_caller_base

Public Member Functions

 __construct ($callbackargs)
 Explicit constructor to set the properties declared by the parent class.
 
 check_permissions ()
 Make sure that the current user is allowed to do the export.
 
 expected_time ()
 How long might we expect this export to take.
 
 expected_time_file ()
 Helper method to calculate expected time for multi or single file exports.
 
 export_config_form (&$mform, $instance)
 If this caller wants any additional config items, they should be defined here.
 
 export_config_validation ($data)
 Just like the moodle form validation function, this is passed in the data array from the form and if a non empty array is returned, form processing will stop.
 
 get ($key)
 Override the parent get function to make sure when we're asked for a course, We retrieve the object from the database as needed.
 
 get_allowed_export_config ()
 Similar to the other allowed_config functions if you need export config, you must provide a list of what the fields are.
 
 get_export_config ($key)
 Returns a particular export config value.
 
 get_export_summary ()
 After the user submits their config, they're given a confirm screen summarising what they've chosen.
 
 get_mimetype ()
 Gets mimetype.
 
 get_navigation ()
 Get navigation that logically follows from the place the user was before.
 
 get_return_url ()
 Return URL for redirecting the user back to where the export started.
 
 get_sha1 ()
 Return the SHA1 hash of the exported content.
 
 get_sha1_file ()
 Helper function to calculate the sha1 for multi or single file exports.
 
 has_export_config ()
 Whether this caller wants any additional config during export (eg options or metadata)
 
 heading_summary ()
 Return a string to put at the header summarising this export.
 
 load_data ()
 Load data required for the export.
 
 prepare_package ()
 Prepare the package ready to be passed off to the portfolio plugin.
 
 prepare_package_file ()
 Helper function to copy files into the temp area for single or multi file exports.
 
 set ($field, &$value)
 Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.
 
 set_context ($PAGE)
 Overridden to return the course module context.
 
 set_export_config ($config)
 Stores the config generated at export time.
 
 set_file_and_format_data ($ids=null)
 Set up the required files for this export.
 
 set_formats_from_button ($formats)
 The button-location always knows best what the formats are... so it should be trusted.
 
 supported_formats ()
 Array of formats this caller supports.
 

Static Public Member Functions

static base_supported_formats ()
 What export formats the workshop generally supports.
 
static display_name ()
 Return a nice name to be displayed about this export location.
 
static expected_callbackargs ()
 Return array of expected callback arguments and whether they are required or not.
 

Protected Member Functions

 add_area_files ($filearea, $itemid)
 Helper method to add all files from the given location to $this->multifiles.
 
 add_format ($format)
 Adds a new format to the list of supported formats.
 
 export_assessment (workshop_assessment $assessment)
 Render the content of an assessment.
 
 export_content (workshop_submission $workshopsubmission)
 Render the content of the submission.
 
 export_content_leap2a (portfolio_format_leap2a_writer $leapwriter, workshop_submission $workshopsubmission, $html)
 Add a LEAP2A entry element that corresponds to a submission including attachments.
 
 export_files_list ($filearea)
 Export the files in the given file area in a list.
 
 export_header (workshop_submission $workshopsubmission)
 Render the header of the exported content.
 
 format_exported_text ($text, $format)
 Helper function to call format_text() on exported text.
 

Protected Attributes

array $assessments = []
 of objects List of assessments of the exported submission.
 
object $cm
 coursemodule object.
 
stdclass $course
 course object
 
array $exportconfig = array()
 configuration used for export.
 
stdClass $exporter
 a reference to the exporter object
 
int $id
 cmid
 
string $intendedmimetype
 set this for generated-file exports
 
stored_file object $multifiles
 set this for multi file exports
 
stored_file $singlefile
 single file exports configuration
 
object $submission
 The submission being exported.
 
int $submissionid
 ID if the exported submission, set via the constructor.
 
array $supportedformats
 can be optionally overridden by subclass constructors
 
stdclass $user
 user currently exporting content
 
workshop $workshop
 The workshop instance where the export is happening.
 

Detailed Description

Workshop portfolio caller class to integrate with portfolio API.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

mod_workshop_portfolio_caller::__construct ( $callbackargs)

Explicit constructor to set the properties declared by the parent class.

Firstly we call the parent's constructor to set the $this->id property from the passed argument. Then we populate the $this->cm so that the default parent class methods work well.

Parameters
array$callbackargs

Reimplemented from portfolio_caller_base.

Member Function Documentation

◆ add_area_files()

mod_workshop_portfolio_caller::add_area_files ( $filearea,
$itemid )
protected

Helper method to add all files from the given location to $this->multifiles.

Parameters
string$filearea
int$itemid

◆ add_format()

portfolio_caller_base::add_format ( $format)
protectedinherited

Adds a new format to the list of supported formats.

This functions also handles removing conflicting and less specific formats at the same time.

Parameters
string$formatone of PORTFOLIO_FORMAT_XX
Return values
void

◆ base_supported_formats()

static mod_workshop_portfolio_caller::base_supported_formats ( )
static

What export formats the workshop generally supports.

If there are no files embedded/attached, the plain HTML format is added in self::load_data().

Return values
array

Reimplemented from portfolio_caller_base.

◆ check_permissions()

mod_workshop_portfolio_caller::check_permissions ( )

Make sure that the current user is allowed to do the export.

Return values
boolean

Reimplemented from portfolio_caller_base.

◆ display_name()

static mod_workshop_portfolio_caller::display_name ( )
static

Return a nice name to be displayed about this export location.

Return values
string

Reimplemented from portfolio_caller_base.

◆ expected_callbackargs()

static mod_workshop_portfolio_caller::expected_callbackargs ( )
static

Return array of expected callback arguments and whether they are required or not.

The 'id' argument is supposed to be our course module id (cmid) - see the parent class' properties.

Return values
arrayof (string)callbackname => (bool)required

Reimplemented from portfolio_caller_base.

◆ expected_time()

mod_workshop_portfolio_caller::expected_time ( )

How long might we expect this export to take.

Return values
stringsuch as PORTFOLIO_TIME_LOW

Reimplemented from portfolio_caller_base.

◆ expected_time_file()

portfolio_caller_base::expected_time_file ( )
inherited

Helper method to calculate expected time for multi or single file exports.

Return values
stringfile time expectation

◆ export_assessment()

mod_workshop_portfolio_caller::export_assessment ( workshop_assessment $assessment)
protected

Render the content of an assessment.

Parameters
workshop_assessment$assessment
Return values
stringHTML

◆ export_config_form()

portfolio_caller_base::export_config_form ( & $mform,
$instance )
inherited

If this caller wants any additional config items, they should be defined here.

Parameters
moodleform$mformpassed by reference, add elements to it.
portfolio_plugin_base$instancesubclass of portfolio_plugin_base

Reimplemented in data_portfolio_caller.

◆ export_config_validation()

portfolio_caller_base::export_config_validation ( $data)
inherited

Just like the moodle form validation function, this is passed in the data array from the form and if a non empty array is returned, form processing will stop.

Parameters
array$datadata from form.

◆ export_content()

mod_workshop_portfolio_caller::export_content ( workshop_submission $workshopsubmission)
protected

Render the content of the submission.

Parameters
workshop_submission$workshopsubmission
Return values
string

◆ export_content_leap2a()

mod_workshop_portfolio_caller::export_content_leap2a ( portfolio_format_leap2a_writer $leapwriter,
workshop_submission $workshopsubmission,
$html )
protected

Add a LEAP2A entry element that corresponds to a submission including attachments.

Parameters
portfolio_format_leap2a_writer$leapwriterWriter object to add entries to.
workshop_submission$workshopsubmission
string$htmlThe exported HTML content of the submission
Return values
intid of new entry

◆ export_files_list()

mod_workshop_portfolio_caller::export_files_list ( $filearea)
protected

Export the files in the given file area in a list.

Parameters
string$filearea
Return values
stringHTML

◆ export_header()

mod_workshop_portfolio_caller::export_header ( workshop_submission $workshopsubmission)
protected

Render the header of the exported content.

This is mainly used for the HTML output format. In case of LEAP2A export, this is not used as the information is stored in metadata and displayed as a part of the journal and entry title in Mahara.

Parameters
workshop_submission$workshopsubmission
Return values
stringHTML

◆ format_exported_text()

mod_workshop_portfolio_caller::format_exported_text ( $text,
$format )
protected

Helper function to call format_text() on exported text.

We need to call format_text() to convert the text into HTML, but we have to keep the original @PLUGINFILE@ placeholder there without a warning so that portfolio_rewrite_pluginfile_urls() can do its work.

Parameters
string$text
int$format
Return values
stringHTML

◆ get()

portfolio_module_caller_base::get ( $key)
inherited

Override the parent get function to make sure when we're asked for a course, We retrieve the object from the database as needed.

Parameters
string$keythe name of get function
Return values
stdClass

Reimplemented from portfolio_caller_base.

◆ get_allowed_export_config()

portfolio_caller_base::get_allowed_export_config ( )
inherited

Similar to the other allowed_config functions if you need export config, you must provide a list of what the fields are.

Even if you want to store stuff during export without displaying a form to the user, you can use this.

Return values
arrayarray of allowed keys

Reimplemented in data_portfolio_caller.

◆ get_export_config()

portfolio_caller_base::get_export_config ( $key)
finalinherited

Returns a particular export config value.

Subclasses shouldn't need to override this

Parameters
string$keythe config item to fetch
Return values
null|mixedof export configuration

◆ get_export_summary()

portfolio_caller_base::get_export_summary ( )
inherited

After the user submits their config, they're given a confirm screen summarising what they've chosen.

This function should return a table of nice strings => values of what they've chosen to be displayed in a table.

Return values
bool

◆ get_mimetype()

portfolio_caller_base::get_mimetype ( )
inherited

Gets mimetype.

Return values
string

◆ get_navigation()

mod_workshop_portfolio_caller::get_navigation ( )

Get navigation that logically follows from the place the user was before.

Return values
array

Reimplemented from portfolio_module_caller_base.

◆ get_return_url()

mod_workshop_portfolio_caller::get_return_url ( )

Return URL for redirecting the user back to where the export started.

Return values
string

Reimplemented from portfolio_module_caller_base.

◆ get_sha1()

mod_workshop_portfolio_caller::get_sha1 ( )

Return the SHA1 hash of the exported content.

Return values
string

Reimplemented from portfolio_caller_base.

◆ get_sha1_file()

portfolio_caller_base::get_sha1_file ( )
inherited

Helper function to calculate the sha1 for multi or single file exports.

Return values
stringsha1 file exports

◆ has_export_config()

portfolio_caller_base::has_export_config ( )
inherited

Whether this caller wants any additional config during export (eg options or metadata)

Return values
bool

Reimplemented in data_portfolio_caller.

◆ heading_summary()

portfolio_module_caller_base::heading_summary ( )
inherited

Return a string to put at the header summarising this export.

by default, this function just display the name and module instance name. Override this to do something more specific

Return values
string

Reimplemented from portfolio_caller_base.

◆ load_data()

mod_workshop_portfolio_caller::load_data ( )

Load data required for the export.

Reimplemented from portfolio_caller_base.

◆ prepare_package()

mod_workshop_portfolio_caller::prepare_package ( )

Prepare the package ready to be passed off to the portfolio plugin.

Reimplemented from portfolio_caller_base.

◆ prepare_package_file()

portfolio_caller_base::prepare_package_file ( )
inherited

Helper function to copy files into the temp area for single or multi file exports.

Return values
stored_file|bool

◆ set()

portfolio_caller_base::set ( $field,
& $value )
finalinherited

Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.

Parameters
string$fieldproperty's name
mixed$valueproperty's value
Return values
bool
Exceptions
moodle_exception

◆ set_context()

portfolio_module_caller_base::set_context ( $PAGE)
inherited

Overridden to return the course module context.

Parameters
moodle_page$PAGEglobal PAGE

Reimplemented from portfolio_caller_base.

◆ set_export_config()

portfolio_caller_base::set_export_config ( $config)
finalinherited

Stores the config generated at export time.

Subclasses can retrieve values using

See also
get_export_config
Parameters
array$configformdata

◆ set_file_and_format_data()

portfolio_caller_base::set_file_and_format_data ( $ids = null)
inherited

Set up the required files for this export.

This supports either passing files directly or passing area arguments directly through to the files api using file_storage\get_area_files

Parameters
mixed$idsone of:
Return values
void

◆ set_formats_from_button()

portfolio_caller_base::set_formats_from_button ( $formats)
inherited

The button-location always knows best what the formats are... so it should be trusted.

Todo
MDL-31298 - re-analyze set_formats_from_button comment
Parameters
array$formatsarray of PORTFOLIO_FORMAT_XX
Return values
void

◆ supported_formats()

portfolio_caller_base::supported_formats ( )
finalinherited

Array of formats this caller supports.

Return values
arraylist of formats

Member Data Documentation

◆ $cm

object portfolio_module_caller_base::$cm
protectedinherited

coursemodule object.

set this in the constructor like $this->cm = get_coursemodule_from_instance('forum', $this->forum->id);

◆ $exportconfig

array portfolio_caller_base::$exportconfig = array()
protectedinherited

configuration used for export.

Use set_export_config and get_export_config to access


The documentation for this class was generated from the following file: