@@ -334,7 +334,7 @@ function createGradingPanel(element, acid, studentId, multiGrader) {
334334 function show ( data ) {
335335 // get rid of any other modals -- incase they are just hanging out.
336336 //jQuery('.modal.modal-grader:not(#modal-template .modal)').remove();
337-
337+ // the submit button is connected to the save function by a jquery submit event.
338338 var rightDiv = jQuery ( element ) ;
339339
340340 jQuery ( "#gradingform" , rightDiv ) . remove ( ) ;
@@ -536,13 +536,18 @@ function makeOption(text, value, disabledQ) {
536536function populateQuestions ( select , question_names ) {
537537 $ ( select ) . empty ( ) ;
538538 var chapter = "" ;
539+ var questiontext ;
539540 for ( i = 0 ; i < question_names . length ; i ++ ) {
540541 var q = question_names [ i ] ;
541- var questiontext = "" ;
542- questiontext = q ;
543- /*
544- };*/
545- select . add ( makeOption ( questiontext , question_names [ i ] ) ) ;
542+ if ( q . endsWith ( "+" ) ) {
543+ q = q . substring ( 0 , q . length - 1 ) ;
544+ questiontext = q + " ✓" ;
545+ } else {
546+ questiontext = q ;
547+ }
548+
549+ // makeOption(text,value)
550+ select . add ( makeOption ( questiontext , q ) ) ;
546551 }
547552
548553 $ ( select ) . select2 ( {
@@ -1615,7 +1620,7 @@ function create_question(formdata) {
16151620}
16161621
16171622// Given a question ID, preview it.
1618- function preview_question_id ( question_id , preview_div ) {
1623+ function preview_question_id ( question_id , preview_div , sid , gradeit ) {
16191624 if ( arguments . length == 1 ) {
16201625 preview_div = "component-preview" ;
16211626 }
@@ -1624,10 +1629,65 @@ function preview_question_id(question_id, preview_div) {
16241629 acid : question_id ,
16251630 } ) . done ( function ( html_src ) {
16261631 // Render it.
1627- renderRunestoneComponent ( html_src , preview_div , { acid : question_id } ) ;
1632+ data = { acid : question_id } ;
1633+ if ( sid ) {
1634+ data . sid = sid ;
1635+ data . graderactive = true ;
1636+ data . useRunestoneServices = true ;
1637+ }
1638+ renderRunestoneComponent ( html_src , preview_div , data ) ;
1639+ if ( gradeit ) {
1640+ let pd = document . getElementById ( preview_div ) ;
1641+ pd . appendChild ( renderGradingComponents ( sid , question_id ) ) ;
1642+ }
16281643 } ) ;
16291644}
16301645
1646+ function renderGradingComponents ( sid , divid ) {
1647+ let div = document . createElement ( "div" ) ;
1648+ let grade = document . createElement ( "input" ) ;
1649+ let gradelabel = document . createElement ( "label" ) ;
1650+ gradelabel . for = "grade-input" ;
1651+ $ ( gradelabel ) . text ( "Grade" ) ;
1652+ grade . type = "text" ;
1653+ grade . id = "grade-input" ;
1654+ let comment = document . createElement ( "input" ) ;
1655+ let commentlabel = document . createElement ( "label" ) ;
1656+ $ ( commentlabel ) . text ( "Comment" ) ;
1657+ comment . type = "text" ;
1658+ comment . id = "comment-input" ;
1659+ commentlabel . for = "comment-input" ;
1660+
1661+ let butt = document . createElement ( "button" ) ;
1662+ $ ( butt ) . text ( "Save Grade" ) ;
1663+ $ ( butt ) . addClass ( "btn btn-normal" ) ;
1664+
1665+ $ ( butt ) . click ( function ( ) {
1666+ jQuery . ajax ( {
1667+ url : eBookConfig . gradeRecordingUrl ,
1668+ type : "POST" ,
1669+ dataType : "JSON" ,
1670+ data : {
1671+ acid : divid ,
1672+ sid : sid ,
1673+ grade : $ ( grade ) . val ( ) ,
1674+ comment : $ ( comment ) . val ( ) ,
1675+ } ,
1676+ success : function ( data ) {
1677+ $ ( grade ) . css ( "background" , "lightgreen" ) ;
1678+ $ ( comment ) . css ( "background" , "lightgreen" ) ;
1679+ } ,
1680+ } ) ;
1681+ } ) ;
1682+ div . appendChild ( gradelabel ) ;
1683+ div . appendChild ( grade ) ;
1684+ div . appendChild ( commentlabel ) ;
1685+ div . appendChild ( comment ) ;
1686+ div . appendChild ( butt ) ;
1687+
1688+ return div ;
1689+ }
1690+
16311691// Called by the "Preview" button of the "Write" panel.
16321692function preview_question ( form , preview_div ) {
16331693 if ( arguments . length == 1 ) {
0 commit comments