@@ -23,6 +23,11 @@ import "codemirror/mode/clike/clike.js";
2323import "codemirror/mode/octave/octave.js" ;
2424import "./../css/activecode.css" ;
2525import "codemirror/lib/codemirror.css" ;
26+ import "codemirror/addon/hint/show-hint.js" ;
27+ import "codemirror/addon/hint/show-hint.css" ;
28+ import "codemirror/addon/hint/sql-hint.js" ;
29+ import "codemirror/addon/hint/anyword-hint.js" ;
30+ import "codemirror/addon/edit/matchbrackets.js" ;
2631import "./skulpt.min.js" ;
2732import "./skulpt-stdlib.js" ;
2833// Used by Skulpt.
@@ -43,6 +48,10 @@ window.edList = {};
4348var socket , connection , doc ;
4449var chatcodesServer = "chat.codes" ;
4550
51+ CodeMirror . commands . autocomplete = function ( cm ) {
52+ cm . showHint ( { hint : CodeMirror . hint . anyword } ) ;
53+ } ;
54+
4655// separate into constructor and init
4756export class ActiveCode extends RunestoneBase {
4857 constructor ( opts ) {
@@ -73,6 +82,7 @@ export class ActiveCode extends RunestoneBase {
7382 this . loadButton = null ;
7483 this . outerDiv = null ;
7584 this . partner = "" ;
85+ this . runCount = 0 ;
7686 this . logResults = true ;
7787 if ( ! eBookConfig . allow_pairs || $ ( orig ) . data ( "nopair" ) ) {
7888 this . enablePartner = false ;
@@ -176,6 +186,7 @@ export class ActiveCode extends RunestoneBase {
176186 extraKeys : {
177187 Tab : "indentMore" ,
178188 "Shift-Tab" : "indentLess" ,
189+ "Ctrl-Space" : "autocomplete" ,
179190 } ,
180191 } ) ;
181192 // Make the editor resizable
@@ -254,6 +265,10 @@ export class ActiveCode extends RunestoneBase {
254265 this . renderFeedback ( ) ;
255266 // The run is finished; re-enable the button.
256267 this . runButton . disabled = false ;
268+ this . runCount += 1 ;
269+ if ( this . is_toggle && this . runCount == 3 ) {
270+ alert ( "Help is Available Using the Toggle Question Selector" ) ;
271+ }
257272 }
258273
259274 createControls ( ) {
@@ -476,8 +491,8 @@ export class ActiveCode extends RunestoneBase {
476491 if ( ! didAgree ) {
477492 didAgree = confirm (
478493 "Pair Programming should only be used with the consent of your instructor." +
479- "Your partner must be a registered member of the class and have agreed to pair with you." +
480- "By clicking OK you certify that both of these conditions have been met."
494+ "Your partner must be a registered member of the class and have agreed to pair with you." +
495+ "By clicking OK you certify that both of these conditions have been met."
481496 ) ;
482497 if ( didAgree ) {
483498 localStorage . setItem ( "partnerAgree" , "true" ) ;
@@ -520,13 +535,13 @@ export class ActiveCode extends RunestoneBase {
520535 $ ( butt ) . attr (
521536 "href" ,
522537 "http://" +
523- chatcodesServer +
524- "/new?" +
525- $ . param ( {
526- topic : window . location . host + "-" + this . divid ,
527- code : this . editor . getValue ( ) ,
528- lang : "Python" ,
529- } )
538+ chatcodesServer +
539+ "/new?" +
540+ $ . param ( {
541+ topic : window . location . host + "-" + this . divid ,
542+ code : this . editor . getValue ( ) ,
543+ lang : "Python" ,
544+ } )
530545 ) ;
531546 this . chatButton = butt ;
532547 chatBar . appendChild ( butt ) ;
@@ -582,16 +597,21 @@ export class ActiveCode extends RunestoneBase {
582597 // If this is timed and already taken we should restore history info
583598 this . renderScrubber ( ) ;
584599 } else {
585- let request = new Request ( `${ eBookConfig . new_server_prefix } /assessment/gethist` , {
586- method : "POST" ,
587- headers : this . jsonHeaders ,
588- body : JSON . stringify ( reqData ) ,
589- } ) ;
600+ let request = new Request (
601+ `${ eBookConfig . new_server_prefix } /assessment/gethist` ,
602+ {
603+ method : "POST" ,
604+ headers : this . jsonHeaders ,
605+ body : JSON . stringify ( reqData ) ,
606+ }
607+ ) ;
590608 try {
591609 response = await fetch ( request ) ;
592610 let data = await response . json ( ) ;
593611 if ( ! response . ok ) {
594- throw new Error ( `Failed to get the history data: ${ data . detail } ` ) ;
612+ throw new Error (
613+ `Failed to get the history data: ${ data . detail } `
614+ ) ;
595615 }
596616 data = data . detail ;
597617 if ( data . history !== undefined ) {
@@ -919,7 +939,7 @@ export class ActiveCode extends RunestoneBase {
919939 } ) ;
920940 }
921941
922- toggleEditorVisibility ( ) { }
942+ toggleEditorVisibility ( ) { }
923943
924944 addErrorMessage ( err ) {
925945 // Add the error message
@@ -1057,7 +1077,7 @@ Yet another is that there is an internal error. The internal error message is:
10571077 var xl = eval ( x ) ;
10581078 xl = xl . map ( pyStr ) ;
10591079 x = xl . join ( " " ) ;
1060- } catch ( err ) { }
1080+ } catch ( err ) { }
10611081 }
10621082 }
10631083 $ ( this . output ) . css ( "visibility" , "visible" ) ;
@@ -1161,7 +1181,7 @@ Yet another is that there is an internal error. The internal error message is:
11611181 if (
11621182 this . historyScrubber &&
11631183 this . history [ $ ( this . historyScrubber ) . slider ( "value" ) ] !=
1164- this . editor . getValue ( )
1184+ this . editor . getValue ( )
11651185 ) {
11661186 saveCode = "True" ;
11671187 this . history . push ( this . editor . getValue ( ) ) ;
@@ -1220,7 +1240,7 @@ Yet another is that there is an internal error. The internal error message is:
12201240 if ( typeof sid !== "undefined" ) {
12211241 unitData . sid = sid ;
12221242 }
1223- await this . logBookEvent ( unitData )
1243+ await this . logBookEvent ( unitData ) ;
12241244 }
12251245 }
12261246
0 commit comments