Skip to content

Commit

Permalink
Bug SAFeSEA#32, fixes to EssayAnalyser & utils/autoload [iet:1029…
Browse files Browse the repository at this point in the history
…9633]

[ci skip]
  • Loading branch information
nfreear committed Feb 2, 2018
1 parent 388f5a7 commit 089a539
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions app/utils/EssayAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function analyseAndSave( $taskId, $userId )

$times->duration = $times->end - $times->start;

$log->debug(__METHOD__ . ":end - $taskId,$versionId - seconds:$duration");
$log->debug(__METHOD__ . ":end - $taskId,$versionId - seconds:" . $times->duration);

$post_data[ 'text' ] = substr( $post_data[ 'text' ], 0, 30 ) . ' [...]';
self::_debug([ __METHOD__, 'POST', $post_data ]);
Expand All @@ -77,7 +77,7 @@ public function analyseAndSave( $taskId, $userId )

/* @var $draft Draft */

$result->db_result = $this->saveDraft( $taskId, $userId, $post, $times );
$result->db_result = $this->saveDraft( $taskId, $userId, $post, $times, $json );
// Was: $result = $draft->save();

// redirect to the "drafts review" page
Expand All @@ -92,7 +92,7 @@ public function analyseAndSave( $taskId, $userId )
}
else
{ $json = $request->body;
$ret = json_decode($json,true);
$ret = json_decode($json, true);

$result->status = 500;

Expand All @@ -105,14 +105,19 @@ public function analyseAndSave( $taskId, $userId )
}

/**
* Create a Draft object, and save to the database.
* Create a Draft model object, and save to the database.
* @param int $taskId
* @param int $userId
* @param array $post Post-data from the end-user.
* @param object $times
* @param string $analysisJson
*/
protected function saveDraft( $taskId, $userId, $post, $times )
protected function saveDraft( $taskId, $userId, $post, $times, $analysisJson )
{
/* @var $draft Draft */
$draft = Model::factory('Draft')->create();
$draft->type = 0;
$draft->analysis = $json;
$draft->analysis = $analysisJson; // Was: $json;
$draft->task_id = $taskId;
$draft->version = $post["version"];
$draft->name = $post["name"];
Expand All @@ -121,7 +126,7 @@ protected function saveDraft( $taskId, $userId, $post, $times )
// Was: $draft->date = date('Y-m-d H:i:s e');

$draft->text = $post[ 'text' ]; // The original text.
$draft->tstart = $time->start;
$draft->tstart = $times->start;
$draft->tend = $times->end;

$counts = json_encode($post[ 'counts' ]); // JSON via Countable.js.
Expand Down
1 change: 1 addition & 0 deletions app/utils/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Utilities.
require_once __DIR__ . '/../utils/DBConnection.php';
require_once __DIR__ . '/../utils/CliApp.php';
require_once __DIR__ . '/../utils/EssayAnalyser.php';
require_once __DIR__ . '/../utils/AnalysisUtils.php';
require_once __DIR__ . '/../utils/LoggerMiddleware.php';
require_once __DIR__ . '/../utils/PDOAdmin.php';
Expand Down

0 comments on commit 089a539

Please sign in to comment.