diff --git a/src/ChamiloLMS/Transaction/ExerciseAttemptTransactionLog.php b/src/ChamiloLMS/Transaction/ExerciseAttemptTransactionLog.php index a8beebeb1a..34bc25d110 100644 --- a/src/ChamiloLMS/Transaction/ExerciseAttemptTransactionLog.php +++ b/src/ChamiloLMS/Transaction/ExerciseAttemptTransactionLog.php @@ -46,12 +46,10 @@ class ExerciseAttemptTransactionLog extends TransactionLog if (!$exercise->read($exercise_stat_info['exe_exo_id'])) { throw new TransactionExportException(sprintf('The associated exercise id "%d" does not currently exist in the database.', $exercise_stat_info['exe_exo_id'])); } + // Prepare the export. $this->data['stat_info'] = $exercise_stat_info; $this->data['attempt_info'] = $attempt; - $content = (array) $this; - - return json_encode($content); } /** diff --git a/src/ChamiloLMS/Transaction/TransactionLog.php b/src/ChamiloLMS/Transaction/TransactionLog.php index 0ceb76b999..269a3d5ea7 100644 --- a/src/ChamiloLMS/Transaction/TransactionLog.php +++ b/src/ChamiloLMS/Transaction/TransactionLog.php @@ -288,10 +288,25 @@ abstract class TransactionLog * @trows TransactionExportException * If any step for exporting the element fails, an exception should be * raised. + */ + abstract public function export(); + + /** + * Export the transaction thorugh export() and then convert it to JSON. + * + * @trows TransactionExportException + * If any step for exporting the element fails, an exception should be + * raised. * * @return string * JSON string representing this transaction as expected by corresponding * import(). */ - abstract public function export(); + public function exportJson() + { + $this->export(); + $content = (array) $this; + + return json_encode($content); + } }