@@ -80,7 +80,8 @@ export class ActiveCode extends RunestoneBase {
8080 this . code = $ ( orig ) . text ( ) || "\n\n\n\n\n" ;
8181 this . parsonspersonalize = $ ( orig ) . data ( "parsonspersonalize" ) ; // CodeTailor: <choose 1 out of two> Allows the instructor to choose personalization level: solution-level or block-and-solution level
8282 this . parsonsexample = $ ( orig ) . data ( "parsonsexample" ) ; // CodeTailor: <choose 1 out of two> Allows the instructor to choose an example Parsons problem or LLM-example (default auto-fill, means the example is generated by LLM)
83- this . puzzleScaffoldingDivid = `help_puzzle_${ this . parsonspersonalize } _${ this . divid } ` ; // CodeTailor: the div id for the puzzle scaffolding help window
83+ this . codetailortimestamp = Math . floor ( Date . now ( ) / 1000 ) ;
84+ this . puzzleScaffoldingDivid = `${ this . divid } _codetailor_${ this . parsonspersonalize } _${ this . sid } _${ this . codetailortimestamp } ` ; // CodeTailor: the div id for the puzzle scaffolding help window
8485 this . language = $ ( orig ) . data ( "lang" ) ;
8586 this . timelimit = $ ( orig ) . data ( "timelimit" ) ;
8687 this . highlightLines = $ ( orig ) . data ( "highlight-lines" ) ;
@@ -635,6 +636,7 @@ export class ActiveCode extends RunestoneBase {
635636 return promise ;
636637 }
637638
639+
638640 // isNewHelp: when true, this handler was not called by pressing the button.
639641 // it was used to open a new generated help.
640642 async reopenHelpBtnHandler ( isNewHelp ) {
@@ -693,9 +695,9 @@ export class ActiveCode extends RunestoneBase {
693695 reopen : true ,
694696 }
695697 this . logBookEvent ( {
696- event : "gptparsons_base_reopen " ,
698+ event : "codetailor_base_reopen " ,
697699 act : JSON . stringify ( reopen_act ) ,
698- div_id : this . divid
700+ div_id : this . puzzleScaffoldingDivid
699701 } ) ;
700702 return ;
701703 }
@@ -732,66 +734,45 @@ export class ActiveCode extends RunestoneBase {
732734
733735 // Function to handle sending the rest of the data and splitting large strings into chunks
734736 const logActInParts = ( act ) => {
735- // First, send the smaller fields (non-chunked) with event name "gptparsons -0"
737+ // First, send the smaller fields (non-chunked) with event name "codetailor -0"
736738 const basicData = {
737739 type : act . type ,
738740 reopen : act . reopen ,
739741 generation_type : act . generation_type ,
740742 solution_type : act . solution_type ,
741743 } ;
742744
743- // First, send the smaller fields (non-chunked) with event name "gptparsons -0"
745+ // First, send the smaller fields (non-chunked) with event name "codetailor -0"
744746 // // console.log("Sending basic data:", basicData);
745747 this . logBookEvent ( {
746- event : "gptparsons_base " , // Special event name for the first log
748+ event : "codetailor_base " , // Special event name for the first log
747749 act : JSON . stringify ( basicData ) ,
748- div_id : this . divid
750+ div_id : this . puzzleScaffoldingDivid
749751 } ) ;
750752
751753 // Split and send the code chunks
752- if ( act . code_answer ) {
753- let chunkIndex = 1 ; // Initialize a single counter for all chunks
754- const codeChunks = splitIntoChunks ( act . code_answer , 512 ) ;
755- codeChunks . forEach ( ( chunk ) => {
756- this . logBookEvent ( {
757- event : `gptparsons_code_${ chunkIndex } ` ,
758- act : JSON . stringify ( {
759- reopen : ! isNewHelp ,
760- type : 'code' ,
761- content : chunk ,
762- chunkIndex : chunkIndex ,
763- totalChunks : codeChunks . length + ( act . puzzle ? splitIntoChunks ( act . puzzle , 512 ) . length : 0 )
764- } ) ,
765- div_id : this . divid
766- } ) ;
767- chunkIndex ++ ;
768- } ) ;
769- }
754+ const puzzle_json = {
755+ type : act . type ,
756+ generation_type : act . generation_type ,
757+ solution_type : act . solution_type ,
758+ code_answer : act . code_answer || null ,
759+ } ;
770760
771- // Split and send the puzzle chunks if they exist
772- if ( act . puzzle ) {
773- const puzzleChunks = splitIntoChunks ( act . puzzle , 512 ) ;
774- let puzzleIndex = 1 ;
775- puzzleChunks . forEach ( ( chunk ) => {
776- this . logBookEvent ( {
777- event : `gptparsons_puzzle_${ puzzleIndex } ` ,
778- act : JSON . stringify ( {
779- reopen : ! isNewHelp ,
780- type : 'puzzle' ,
781- content : chunk ,
782- chunkIndex : puzzleIndex ,
783- totalChunks : puzzleChunks . length
784- } ) ,
785- div_id : this . divid
786- } ) ;
787- puzzleIndex ++ ;
788- } ) ;
789- }
761+ // Send ONE request to the new table
762+ this . logCodeTailorEvent ( {
763+ div_id : this . divid ,
764+ sid : this . sid ,
765+ ctid : this . puzzleScaffoldingDivid ,
766+ course : this . courseName , // must match request.state.user.course_name
767+ htmlsrc : this . puzzleHTML || null , // raw puzzle HTML
768+ puzzle_json : puzzle_json , // JSON column
769+ } ) ;
790770 }
791771
792772 // Log the data in parts
793773 logActInParts ( act ) ;
794774
775+
795776 let probDescHTML = $ ( this . outerDiv ) . find ( ".ac_question" ) . last ( ) . html ( ) ;
796777 if ( puzzle_rst !== "correctCode" && puzzle_rst !== "emptyHelpParsons" ) {
797778 var puzzleCode = `
@@ -851,9 +832,9 @@ export class ActiveCode extends RunestoneBase {
851832 type : 'close_help'
852833 }
853834 this . logBookEvent ( {
854- event : "gptparsons_close " ,
835+ event : "codetailor_close " ,
855836 act : JSON . stringify ( { ...act } ) , // Clone to avoid future changes affecting the log
856- div_id : close_divId
837+ div_id : this . puzzleScaffoldingDivid
857838 } ) ;
858839 $ ( `#scaffolding-container-${ this . divid } ` ) . addClass ( 'hidden' ) ;
859840 }
@@ -913,9 +894,9 @@ export class ActiveCode extends RunestoneBase {
913894 type : 'copy_help'
914895 }
915896 this . logBookEvent ( {
916- event : "gptparsons_copy " ,
897+ event : "codetailor_copy " ,
917898 act : JSON . stringify ( { ...act } ) , // Clone to avoid future changes affecting the log
918- div_id : this . divid
899+ div_id : this . puzzleScaffoldingDivid
919900 } ) ;
920901 $ ( `#copy-answer-button-${ this . puzzleScaffoldingDivid } ` ) . text ( 'Copied!' ) . prop ( 'disabled' , true ) ;
921902
@@ -1018,9 +999,9 @@ export class ActiveCode extends RunestoneBase {
1018999 }
10191000
10201001 this . logBookEvent ( {
1021- event : "gptparsons_request_base " ,
1002+ event : "codetailor_request_base " ,
10221003 act : this . parsonspersonalize ,
1023- div_id : this . divid
1004+ div_id : this . puzzleScaffoldingDivid
10241005 } ) ;
10251006
10261007 // Split and send the code chunks
@@ -1029,14 +1010,14 @@ export class ActiveCode extends RunestoneBase {
10291010 const codeChunks = splitIntoChunks ( request_act . code , 512 ) ;
10301011 codeChunks . forEach ( ( chunk ) => {
10311012 this . logBookEvent ( {
1032- event : `gptparsons_request_code_ ${ requestChunkIndex } ` ,
1013+ event : `codetailor_request_code_ ${ requestChunkIndex } ` ,
10331014 act : JSON . stringify ( {
10341015 type : 'code' ,
10351016 content : chunk ,
10361017 requestChunkIndex : requestChunkIndex ,
10371018 totalChunks : requestChunkIndex . length + splitIntoChunks ( request_act . code , 512 ) . length
10381019 } ) ,
1039- div_id : this . divid
1020+ div_id : this . puzzleScaffoldingDivid
10401021 } ) ;
10411022 requestChunkIndex ++ ;
10421023 } ) ;
0 commit comments