@@ -61,6 +61,7 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
6161 </ div >
6262
6363 < div id ="pi-assignment-navigation ">
64+ {{ if current_qnum < num _questions: }}
6465 < button
6566 type ="submit "
6667 id ="nextq "
@@ -70,6 +71,19 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
7071 >
7172 Next Question
7273 </ button >
74+ {{ else: }}
75+ < div id ="asyncBtnArea " style ="display:inline-block; ">
76+ < button
77+ type ="button "
78+ id ="toggleAsyncBtn "
79+ class ="btn btn-info " {{ if peer_async_visible: }}style ="background-color:#a3d4ec; border-color:#a3d4ec; color:#fff; "{{ pass }}
80+ onclick ="showAsyncConfirm() "
81+ style ="margin-right: 4px; "
82+ >
83+ {{ if peer_async_visible: }}Undo After-Class Release{{ else: }}Release After-Class PI{{ pass }}
84+ </ button >
85+ </ div >
86+ {{ pass }}
7387 < button
7488 type ="submit "
7589 id ="restart "
@@ -349,8 +363,33 @@ <h3>Question {{ =current_qnum }} of {{ =num_questions }}</h3>
349363 var mess_count = 0 ;
350364 var answerCount = 0 ;
351365 var done = { { = is_last } }
352- if ( done ) {
353- document . getElementById ( "nextq" ) . disabled = true ;
366+
367+ var asyncReleased = { { = peer_async_visible} } ;
368+
369+ function showAsyncConfirm ( ) {
370+ var area = document . getElementById ( "asyncBtnArea" ) ;
371+ var msg = asyncReleased
372+ ? "Undo the after-class PI release?"
373+ : "Release after-class PI questions to students?" ;
374+ area . innerHTML = `
375+ <span style="margin-right:6px; font-weight:bold;">${ msg } </span>
376+ <button type="button" class="btn btn-sm btn-default" onclick="confirmToggleAsync()" style="margin-right:4px;">Yes</button>
377+ <button type="button" class="btn btn-sm btn-default" onclick="cancelAsyncConfirm()">Cancel</button>
378+ ` ;
379+ }
380+
381+ function cancelAsyncConfirm ( ) {
382+ var area = document . getElementById ( "asyncBtnArea" ) ;
383+ var label = asyncReleased ? "Undo After-Class Release" : "Release After-Class PI" ;
384+ var extraStyle = asyncReleased ? 'style="background-color:#a3d4ec; border-color:#a3d4ec; color:#fff; margin-right:4px;"' : 'style="margin-right:4px;"' ;
385+ area . innerHTML = `<button type="button" id="toggleAsyncBtn" class="btn btn-info" onclick="showAsyncConfirm()" ${ extraStyle } >${ label } </button>` ;
386+ }
387+
388+ async function confirmToggleAsync ( ) {
389+ var resp = await fetch ( "/runestone/peer/toggle_async?assignment_id={{=assignment_id}}" , { method : "POST" } ) ;
390+ var data = await resp . json ( ) ;
391+ asyncReleased = data . peer_async_visible ;
392+ cancelAsyncConfirm ( ) ;
354393 }
355394</ script >
356395{{ end }}
0 commit comments