From 32c4b59725df39fae610b2a665f66f8e95d13cac Mon Sep 17 00:00:00 2001 From: Marco De Donno Date: Sat, 3 Mar 2018 00:34:30 +0100 Subject: [PATCH] Add the button to delete the submission of the conclusion --- backend/TE/AppDB.php | 14 +++++++++++++ js/backend.admin.js | 50 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/backend/TE/AppDB.php b/backend/TE/AppDB.php index 406b649..8ed7856 100644 --- a/backend/TE/AppDB.php +++ b/backend/TE/AppDB.php @@ -619,6 +619,20 @@ class AppDB_TE extends AppDB $this->commitTransactionIf( $token ); } + public function unsubmittConclusion( $aid ) + { + $this->checkAdmin(); + + $token = $this->beginTransactionIf(); + + $res = $this->query( "DELETE FROM observation WHERE restype = 3 AND resstep = 2 AND assignment = " . ( int ) $aid . ";" ); + $res = $this->query( "DELETE FROM minutia WHERE restype = 3 AND resstep = 2 AND assignment = " . ( int ) $aid . ";" ); + $res = $this->query( "DELETE FROM annotation WHERE restype = 3 AND resstep = 2 AND assignment = " . ( int ) $aid . ";" ); + $res = $this->query( "DELETE FROM result WHERE type = 3 AND step = 2 AND assignment = " . ( int ) $aid . ";" ); + + $this->commitTransactionIf( $token ); + } + public function deleteConclusion( $aid ) { $this->checkAdmin(); diff --git a/js/backend.admin.js b/js/backend.admin.js index d5c9120..494f668 100644 --- a/js/backend.admin.js +++ b/js/backend.admin.js @@ -955,7 +955,55 @@ Pianos4Backend.AdminExercise = function( selector, params ) }, } ); - + cols.push( + { + title: 'Sub.', + render: function( data, i, j, cell ) + { + if( data[ i ].progress.status == 4 ) + { + cell.append( + $( '' ) + .attr( 'src', 'css/icons/backend/Delete16.png' ) + .attr( 'alt', 'conclusionDelete' ) + .css( 'cursor', 'pointer' ) + .click( function() + { + $( '
' ) + .text( 'Do you really want to delete the un-submitt the conclusion ?' ) + .dialog( { + title: "Confirm conclusion un-submition", + modal: true, + buttons: { + 'OK': function() + { + var dlg = $( this ); + udb.app().getModel().rpc( 'unsubmittConclusion', { + aid: parseInt( data[ i ][ 'id' ] ) + }, function() + { + cell.remove(); + dlg.dialog( 'close' ); + }); + }, + 'Cancel': function() + { + $( this ).dialog( 'close' ); + }, + }, + close: function() + { + $( this ).remove(); + } + } ); + + } ) + ); + } + }, + } + ); + resdiv.qtable( { data: ex.assignments, columnMode: 'mapping', -- GitLab