Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Classes
datalib.php File Reference

Code for loading and saving question attempts to and from the database. More...

Classes

class  qubaid_condition
 This class represents a restriction on the set of question_usage ids to include in a larger database query. More...
 
class  qubaid_join
 This class represents a restriction on the set of question_usage ids to include in a larger database query based on JOINing to some other tables. More...
 
class  qubaid_list
 This class represents a restriction on the set of question_usage ids to include in a larger database query based on an explicit list of ids. More...
 
class  question_engine_data_mapper
 This class controls the loading and saving of question engine data to and from the database. More...
 
class  question_engine_unit_of_work
 Implementation of the unit of work pattern for the question engine. More...
 
class  question_file_loader
 This class is the mirror image of question_file_saver. More...
 
class  question_file_saver
 This class represents the promise to save some files from a particular draft file area into a particular file area. More...
 
interface  question_response_files
 The interface implemented by question_file_saver and question_file_loader. More...
 

Detailed Description

Code for loading and saving question attempts to and from the database.

Note that many of the methods of this class should be considered private to the question engine. They should be accessed through the question_engine class. For example, you should call question_engine::save_questions_usage_by_activity() rather than question_engine_data_mapper::insert_questions_usage_by_activity(). The exception to this is some of the reporting methods, like question_engine_data_mapper::load_attempts_at_question().

A note for future reference. This code is pretty efficient but there are some potential optimisations that could be contemplated, at the cost of making the code more complex:

  1. (This is probably not worth doing.) In the unit-of-work save method, we could get all the ids for steps due to be deleted or modified, and delete all the question_attempt_step_data for all of those steps in one query. That would save one DB query for each ->stepsupdated. However that number is 0 except when re-grading, and when regrading, there are many more inserts into question_attempt_step_data than deletes, so it is really hardly worth it.
License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later