tx-io: Separate transaction export process from json encoding.

skala
Marco Villegas 13 years ago
parent 152c10b2cd
commit e43ad4e6e9
  1. 4
      src/ChamiloLMS/Transaction/ExerciseAttemptTransactionLog.php
  2. 17
      src/ChamiloLMS/Transaction/TransactionLog.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);
}
/**

@ -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);
}
}

Loading…
Cancel
Save