@@ -134,6 +134,15 @@ ActiveCode.prototype.createControls = function () {
134134 $ ( butt ) . css ( "display" , "none" )
135135 }
136136
137+ if ( $ ( this . origElem ) . data ( 'gradebutton' ) ) {
138+ butt = document . createElement ( "button" ) ;
139+ $ ( butt ) . addClass ( "ac_opt btn btn-default" ) ;
140+ $ ( butt ) . text ( "Show Feedback" ) ;
141+ $ ( butt ) . css ( "margin-left" , "10px" ) ;
142+ this . gradeButton = butt ;
143+ ctrlDiv . appendChild ( butt ) ;
144+ $ ( butt ) . click ( this . createGradeSummary . bind ( this ) )
145+ }
137146 // Show/Hide Code
138147 if ( this . hidecode ) {
139148 butt = document . createElement ( "button" ) ;
@@ -220,6 +229,43 @@ ActiveCode.prototype.loadEditor = function () {
220229
221230} ;
222231
232+ ActiveCode . prototype . createGradeSummary = function ( ) {
233+ // get grade and comments for this assignment
234+ // get summary of all grades for this student
235+ // display grades in modal window
236+ var showGradeSummary = function ( data , status , whatever ) {
237+ var report = eval ( data ) [ 0 ] ;
238+ // check for report['message']
239+ if ( report [ 'grade' ] ) {
240+ body = "<h4>Grade Report</h4>" +
241+ "<p>This assignment: " + report [ 'grade' ] + "</p>" +
242+ "<p>" + report [ 'comment' ] + "</p>" +
243+ "<p>Number of graded assignments: " + report [ 'count' ] + "</p>" +
244+ "<p>Average score: " + report [ 'avg' ] + "</p>"
245+
246+ } else {
247+ body = "<h4>You must be Logged in to see your grade</h4>" ;
248+ }
249+ var html = '<div class="modal fade">' +
250+ ' <div class="modal-dialog compare-modal">' +
251+ ' <div class="modal-content">' +
252+ ' <div class="modal-header">' +
253+ ' <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>' +
254+ ' <h4 class="modal-title">Assignment Feedback</h4>' +
255+ ' </div>' +
256+ ' <div class="modal-body">' +
257+ body +
258+ ' </div>' +
259+ ' </div>' +
260+ ' </div>' +
261+ '</div>' ;
262+
263+ el = $ ( html ) ;
264+ el . modal ( ) ;
265+ }
266+ var data = { 'div_id' : this . divid }
267+ jQuery . get ( eBookConfig . ajaxURL + 'getassignmentgrade' , data , showGradeSummary ) ;
268+ }
223269
224270ActiveCode . prototype . hideCodelens = function ( button , div_id ) {
225271 this . codelens . style . display = 'none'
0 commit comments