@@ -44,7 +44,6 @@ export default class SQLHParons extends RunestoneBase {
4444 this . code = $ ( orig ) . text ( ) || "\n\n\n\n\n" ;
4545 this . language = $ ( orig ) . data ( "lang" ) ;
4646 this . includes = $ ( orig ) . data ( "include" ) ;
47- this . hidehistory = $ ( orig ) . data ( "hidehistory" ) ;
4847 this . question = $ ( opts . orig ) . find ( `#${ this . divid } _question` ) [ 0 ] ;
4948 this . tie = $ ( orig ) . data ( "tie" ) ;
5049 this . dburl = $ ( orig ) . data ( "dburl" ) ;
@@ -56,7 +55,6 @@ export default class SQLHParons extends RunestoneBase {
5655 this . logResults = true ;
5756 this . output = null ; // create pre for output
5857 this . controlDiv = null ;
59- this . historyScrubber = null ;
6058 this . timestamps = [ "Original" ] ;
6159 this . autorun = $ ( orig ) . data ( "autorun" ) ;
6260 if ( this . includes ) {
@@ -72,7 +70,6 @@ export default class SQLHParons extends RunestoneBase {
7270 this . suffix = this . code . substring ( suffStart + 5 ) ;
7371 this . code = this . code . substring ( 0 , suffStart ) ;
7472 }
75- this . history = [ this . code ] ;
7673 this . createEditor ( ) ;
7774 this . createOutput ( ) ;
7875 this . createControls ( ) ;
@@ -177,137 +174,6 @@ export default class SQLHParons extends RunestoneBase {
177174 this . runButton . disabled = false ;
178175 }
179176
180- // copied from activecode
181- addHistoryButton ( ctrlDiv ) {
182- let butt = document . createElement ( "button" ) ;
183- $ ( butt ) . text ( $ . i18n ( "msg_activecode_load_history" ) ) ;
184- $ ( butt ) . addClass ( "btn btn-default" ) ;
185- $ ( butt ) . attr ( "type" , "button" ) ;
186- ctrlDiv . appendChild ( butt ) ;
187- this . histButton = butt ;
188- $ ( butt ) . click ( this . addHistoryScrubber . bind ( this ) ) ;
189- if ( this . graderactive ) {
190- this . addHistoryScrubber ( true ) ;
191- }
192- }
193-
194- // copied from activecode
195- // _`addHistoryScrubber`
196- // ---------------------
197- // Activecode -- If the code has not changed wrt the scrubber position value then don't save the code or reposition the scrubber
198- // -- still call runlog, but add a parameter to not save the code
199- // add an initial load history button
200- // if there is no edit then there is no append to_save (True/False)
201- async addHistoryScrubber ( pos_last ) {
202- let response ;
203- var reqData = {
204- acid : this . divid ,
205- } ;
206- if ( this . sid !== undefined ) {
207- reqData [ "sid" ] = this . sid ;
208- }
209- console . log ( "before get hist" ) ;
210- if (
211- eBookConfig . practice_mode ||
212- ( this . isTimed && ! this . assessmentTaken )
213- ) {
214- // If this is timed and already taken we should restore history info
215- this . renderScrubber ( ) ;
216- } else {
217- let request = new Request ( `${ eBookConfig . new_server_prefix } /assessment/gethist` , {
218- method : "POST" ,
219- headers : this . jsonHeaders ,
220- body : JSON . stringify ( reqData ) ,
221- } ) ;
222- try {
223- response = await fetch ( request ) ;
224- let data = await response . json ( ) ;
225- if ( ! response . ok ) {
226- throw new Error ( `Failed to get the history data: ${ data . detail } ` ) ;
227- }
228- data = data . detail ;
229- if ( data . history !== undefined ) {
230- this . history = this . history . concat ( data . history ) ;
231- for ( let t in data . timestamps ) {
232- this . timestamps . push (
233- new Date ( data . timestamps [ t ] ) . toLocaleString ( )
234- ) ;
235- }
236- }
237- } catch ( e ) {
238- console . log ( `unable to fetch history: ${ e } ` ) ;
239- }
240- this . renderScrubber ( pos_last ) ;
241- }
242- return "success" ;
243- }
244-
245- renderScrubber ( pos_last ) {
246- console . log ( "making a new scrubber" ) ;
247- var scrubberDiv = document . createElement ( "div" ) ;
248- $ ( scrubberDiv ) . css ( "display" , "inline-block" ) ;
249- $ ( scrubberDiv ) . css ( "margin-left" , "10px" ) ;
250- $ ( scrubberDiv ) . css ( "margin-right" , "10px" ) ;
251- $ ( scrubberDiv ) . css ( {
252- "min-width" : "200px" ,
253- "max-width" : "300px" ,
254- } ) ;
255- var scrubber = document . createElement ( "div" ) ;
256- this . timestampP = document . createElement ( "span" ) ;
257- this . slideit = function ( ) {
258- this . editor . setValue ( this . history [ $ ( scrubber ) . slider ( "value" ) ] ) ;
259- var curVal = this . timestamps [ $ ( scrubber ) . slider ( "value" ) ] ;
260- let pos = $ ( scrubber ) . slider ( "value" ) ;
261- let outOf = this . history . length ;
262- $ ( this . timestampP ) . text ( `${ curVal } - ${ pos + 1 } of ${ outOf } ` ) ;
263- this . logBookEvent ( {
264- event : "activecode" ,
265- act : "slide:" + curVal ,
266- div_id : this . divid ,
267- } ) ;
268- } ;
269- $ ( scrubber ) . slider ( {
270- max : this . history . length - 1 ,
271- value : this . history . length - 1 ,
272- } ) ;
273- $ ( scrubber ) . css ( "margin" , "10px" ) ;
274- $ ( scrubber ) . on ( "slide" , this . slideit . bind ( this ) ) ;
275- $ ( scrubber ) . on ( "slidechange" , this . slideit . bind ( this ) ) ;
276- scrubberDiv . appendChild ( scrubber ) ;
277- scrubberDiv . appendChild ( this . timestampP ) ;
278- // If there is a deadline set then position the scrubber at the last submission
279- // prior to the deadline
280- if ( this . deadline ) {
281- let i = 0 ;
282- let done = false ;
283- while ( i < this . history . length && ! done ) {
284- if ( new Date ( this . timestamps [ i ] ) > this . deadline ) {
285- done = true ;
286- } else {
287- i += 1 ;
288- }
289- }
290- i = i - 1 ;
291- scrubber . value = Math . max ( i , 0 ) ;
292- this . editor . setValue ( this . history [ scrubber . value ] ) ;
293- $ ( scrubber ) . slider ( "value" , scrubber . value ) ;
294- } else if ( pos_last ) {
295- scrubber . value = this . history . length - 1 ;
296- this . editor . setValue ( this . history [ scrubber . value ] ) ;
297- } else {
298- scrubber . value = 0 ;
299- }
300- let pos = $ ( scrubber ) . slider ( "value" ) ;
301- let outOf = this . history . length ;
302- let ts = this . timestamps [ $ ( scrubber ) . slider ( "value" ) ] ;
303- $ ( this . timestampP ) . text ( `${ ts } - ${ pos + 1 } of ${ outOf } ` ) ;
304- $ ( this . histButton ) . remove ( ) ;
305- this . histButton = null ;
306- this . historyScrubber = scrubber ;
307- $ ( scrubberDiv ) . insertAfter ( this . runButton ) ;
308- } // end definition of helper
309-
310-
311177 // copied from activecode
312178 createEditor ( index ) {
313179 this . outerDiv = document . createElement ( "div" ) ;
@@ -444,10 +310,6 @@ export default class SQLHParons extends RunestoneBase {
444310 this . runButton . onclick = this . runButtonHandler . bind ( this ) ;
445311 $ ( butt ) . attr ( "type" , "button" ) ;
446312
447- if ( ! this . hidehistory ) {
448- this . addHistoryButton ( ctrlDiv ) ;
449- }
450-
451313 $ ( this . outerDiv ) . prepend ( ctrlDiv ) ;
452314 if ( this . question ) {
453315 if ( $ ( this . question ) . html ( ) . match ( / ^ \s + $ / ) ) {
@@ -540,19 +402,6 @@ export default class SQLHParons extends RunestoneBase {
540402 } ) ;
541403 }
542404
543- try {
544- this . saveCode = await this . manage_scrubber ( this . saveCode ) ;
545- if ( this . slideit ) {
546- $ ( this . historyScrubber ) . on (
547- "slidechange" ,
548- this . slideit . bind ( this )
549- ) ;
550- }
551- $ ( this . historyScrubber ) . slider ( "enable" ) ;
552- } catch ( e ) {
553- console . log ( `Failed to update scrubber ${ e } ` ) ;
554- }
555-
556405 respDiv = document . createElement ( "div" ) ;
557406 respDiv . id = divid ;
558407 this . outDiv . appendChild ( respDiv ) ;
0 commit comments