Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
question_file_saver Class Reference

This class represents the promise to save some files from a particular draft file area into a particular file area. More...

Inheritance diagram for question_file_saver:
question_response_files

Public Member Functions

 __construct ($draftitemid, $component, $filearea, $text=null)
 Constructor. More...
 
 __toString ()
 
 get_files ()
 Get the files that were submitted. More...
 
 save_files ($itemid, $context)
 Actually save the files. More...
 

Protected Member Functions

 compute_value ($draftitemid, $text)
 Compute the value that should be stored in the question_attempt_step_data table. More...
 

Protected Attributes

string $component
 the owning component name.
 
int $draftitemid
 the id of the draft file area to save files from.
 
string $filearea
 the file area name.
 
string $value = null
 the value to store in the question_attempt_step_data to represent these files.
 

Detailed Description

This class represents the promise to save some files from a particular draft file area into a particular file area.

It is used beause the necessary information about what to save is to hand in the question_attempt::process_response_files() method, but we don't know if this question attempt will actually be saved in the database until later, when the question_engine_unit_of_work is saved, if it is.

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

Constructor & Destructor Documentation

◆ __construct()

question_file_saver::__construct (   $draftitemid,
  $component,
  $filearea,
  $text = null 
)

Constructor.

Parameters
int$draftitemidthe draft area to save the files from.
string$componentthe component for the file area to save into.
string$fileareathe name of the file area to save into.
string$textoptional content containing file links.

Member Function Documentation

◆ compute_value()

question_file_saver::compute_value (   $draftitemid,
  $text 
)
protected

Compute the value that should be stored in the question_attempt_step_data table.

Contains a hash that (almost) uniquely encodes all the files.

Parameters
int$draftitemidthe draft file area itemid.
string$textoptional content containing file links.
Return values
stringthe value.

◆ get_files()

question_file_saver::get_files ( )

Get the files that were submitted.

Return values
arrayof stored_files objects.

Implements question_response_files.

◆ save_files()

question_file_saver::save_files (   $itemid,
  $context 
)

Actually save the files.

Parameters
integer$itemidthe item id for the file area to save into.
context$contextthe context where the files should be saved.

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