<commit_before><link rel="import" href="..\..\bower_components/polymer/polymer.html">
<link rel="import" href="..\..\bower_components/paper-input/paper-input.html">
<link rel="import" href="..\..\bower_components/paper-item/paper-item.html">
<!-- <link rel="import" href="../cocurricular-service/cocurricular-service.html"> -->
<link rel="import" href="../term-assesment-service/term-assesment-service.html">


<dom-module id="cc-dance-onetofour-item-card">
  <template>
    <style>
      :host {
        display: block;
      }
      table{
        border-collapse: collapse;
        width: 100%;
      }
    
      #p1{
        width: -5px;
      }
      
      paper-input{
        text-align: center;
      }
    </style>
   <div>
       <table border="1">
        <tr><td hidden><paper-input value="{{studid}}"></paper-input><paper-item value="{{studname}}"></paper-item></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{interest}}" id="p1" on-change="FnInterest"></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{rhythm}}" id="p2" on-change="FnRhythm"></paper-input></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{grace}}" id="p3" on-change="FnGrace"></paper-input></td>
        <td><paper-checkbox disabled="{{read}}" checked id="{{studid}}" on-change="FnChange"></paper-checkbox></td>
        </tr>
      </table> 
    </div>
    <paper-dialog modal id="adialog" entry-animation="scale-up-animation" exit-animation="fade-out-animation">
      <p>Mark as absent?</p>
      <paper-button on-click="FnYes">Ok</paper-button>  
      <!-- <paper-button on-click="FnNo">No</paper-button>       -->
    </paper-dialog>
     <!-- <cocurricular-service id="assesmentservice"></cocurricular-service> -->
    <term-assesment-service id="assesmentservice"></term-assesment-service>     
     <iron-ajax        
        method="post"
        id="fetchgradesajax"
        url="{{fetchgradesurl}}"
        params="{{fetchgradesparam}}"
        handle-as="json"
        content-type="application/json"
        on-response="fetchgradesResponse"
        debounce-duration="300"
     >
  </template>
  <script>
  (function() {
    
    'use strict';
    var interest,rhythm,grace;
    var lower=[];
    var higher=[];
    var grade=[];

    Polymer({
      is: 'cc-dance-onetofour-item-card',
      ready:function(){       
      },
      FnYes:function(){
        var id='adialog';          
          document.getElementById(id).opened=false;          
          // this.read=true;
      },
      FnNo:function(){
        var id='adialog';          
          document.getElementById(id).opened=false;          
          // this.read=true;
      },
      FnChange:function(e){
         // alert(e.target.checked);
        if(e.target.checked==false){
          var id='adialog';          
          document.getElementById(id).opened=true;          
          this.read=true;
          this.interest=0;
          this.rhythm=0;
          this.grace=0;          
          localStorage.setItem("curr_sess_absflag",0);
          this.callService();
        }

      },
      FnInterest:function(){
        interest=parseFloat(this.interest).toFixed(2);        
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.interest);
        if(this.flag==1)
          // this.FnValidateCall();
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Interest",this.interest,1);
      } ,
      FnRhythm:function(){
        rhythm=parseFloat(this.rhythm).toFixed(2);        
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.rhythm);
        if(this.flag==1)
          // this.FnValidateCall();
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Rhythm",this.rhythm,2);  
      },
      FnGrace:function(){
        grace=parseFloat(this.grace).toFixed(2);
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.grace);
        if(this.flag==0)
        this.FnValidateCall();

        if(this.flag==1)
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Grace",this.grace,3);  
      },
      FnValidateCall:function(){
        this.flag=1;
         if(this.interest==""||this.interest==null||this.rhythm==""||this.rhythm==null||this.grace==""||this.grace==null){
        this.$.p1.validate();
        this.$.p2.validate();
        this.$.p3.validate();
        } 
        else{     
        localStorage.setItem("curr_sess_absflag",1);   
        this.total=parseInt(this.interest)+parseInt(this.rhythm)+parseInt(this.grace);
        this.reduction=parseFloat(this.total)/3;
        this.callFetchGrade();      
        }
      },
      callFetchGrade:function(){
        this.fetchgradesurl=sessionStorage.getItem("addrinfo")+"/fetchgrade-service"; 
        this.$.fetchgradesajax.generateRequest(); 
      },
      fetchgradesResponse:function(e){
        var returnval=e.detail.response.returnval;       
        for(var i=0;i<returnval.length;i++){
          lower.push(returnval[i].lower_limit);
          higher.push(returnval[i].higher_limit);
          grade.push(returnval[i].grade);
        }
        this.grade=this.FnFindGrade((parseInt(this.reduction)));  
        this.callService();  
      },
      FnFindGrade:function(mark){        
        for(var i=0;i<lower.length;i++){          
          if(mark>=lower[i]&&mark<=higher[i]){            
            this.grade=grade[i];
          }
        }
        return this.grade;        
      },
      callService:function(){
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Interest",this.interest,1);
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Rhythm",this.rhythm,2);  
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Grace",this.grace,3);  
        // this.$.assesmentservice.calloverallinsertcocurricularmarkService(this.studid,this.studname,"Dance",this.total,this.reduction,this.grade);
      }     
    });
  })();
  </script>
</dom-module>
<commit_msg>dance<commit_after><link rel="import" href="..\..\bower_components/polymer/polymer.html">
<link rel="import" href="..\..\bower_components/paper-input/paper-input.html">
<link rel="import" href="..\..\bower_components/paper-item/paper-item.html">
<!-- <link rel="import" href="../cocurricular-service/cocurricular-service.html"> -->
<link rel="import" href="../term-assesment-service/term-assesment-service.html">


<dom-module id="cc-dance-onetofour-item-card">
  <template>
    <style>
      :host {
        display: block;
      }
      table{
        border-collapse: collapse;
        width: 100%;
      }
    
      #p1{
        width: -5px;
      }
      
      paper-input{
        text-align: center;
      }
    </style>
   <div>
       <table border="1">
        <tr><td hidden><paper-input value="{{studid}}"></paper-input><paper-item value="{{studname}}"></paper-item></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{interest}}" id="p1" on-change="FnInterest"></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{rhythm}}" id="p2" on-change="FnRhythm"></paper-input></td>
        <td><paper-input disabled="{{read}}" required allowed-pattern="^[0-9.a,]+$" value="{{grace}}" id="p3" on-change="FnGrace"></paper-input></td>
        <td><paper-checkbox disabled="{{read}}" checked id="{{studid}}" on-change="FnChange"></paper-checkbox></td>
        </tr>
      </table> 
    </div>
    <paper-dialog modal id="adialog" entry-animation="scale-up-animation" exit-animation="fade-out-animation">
      <p>Mark as absent?</p>
      <paper-button on-click="FnYes">Ok</paper-button>  
      <!-- <paper-button on-click="FnNo">No</paper-button>       -->
    </paper-dialog>
     <!-- <cocurricular-service id="assesmentservice"></cocurricular-service> -->
    <term-assesment-service id="assesmentservice"></term-assesment-service>     
     <iron-ajax        
        method="post"
        id="fetchgradesajax"
        url="{{fetchgradesurl}}"
        params="{{fetchgradesparam}}"
        handle-as="json"
        content-type="application/json"
        on-response="fetchgradesResponse"
        debounce-duration="300"
     >
  </template>
  <script>
  (function() {
    
    'use strict';
    var interest,rhythm,grace;
    var lower=[];
    var higher=[];
    var grade=[];

    Polymer({
      is: 'cc-dance-onetofour-item-card',
      ready:function(){       
      this.flag=0;
      },
      FnYes:function(){
        var id='adialog';          
          document.getElementById(id).opened=false;          
          // this.read=true;
      },
      FnNo:function(){
        var id='adialog';          
          document.getElementById(id).opened=false;          
          // this.read=true;
      },
      FnChange:function(e){
         // alert(e.target.checked);
        if(e.target.checked==false){
          var id='adialog';          
          document.getElementById(id).opened=true;          
          this.read=true;
          this.interest=0;
          this.rhythm=0;
          this.grace=0;          
          localStorage.setItem("curr_sess_absflag",0);
          this.callService();
        }

      },
      FnInterest:function(){
        interest=parseFloat(this.interest).toFixed(2);        
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.interest);
        if(this.flag==1)
          // this.FnValidateCall();
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Interest",this.interest,1);
      } ,
      FnRhythm:function(){
        rhythm=parseFloat(this.rhythm).toFixed(2);        
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.rhythm);
        if(this.flag==1)
          // this.FnValidateCall();
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Rhythm",this.rhythm,2);  
      },
      FnGrace:function(){
        grace=parseFloat(this.grace).toFixed(2);
        document.querySelector('cc-dance-onetofour-card').FnToggleDialog(this.grace);
        if(this.flag==0)
        this.FnValidateCall();

        if(this.flag==1)
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Grace",this.grace,3);  
      },
      FnValidateCall:function(){
        this.flag=1;
         if(this.interest==""||this.interest==null||this.rhythm==""||this.rhythm==null||this.grace==""||this.grace==null){
        this.$.p1.validate();
        this.$.p2.validate();
        this.$.p3.validate();
        } 
        else{     
        localStorage.setItem("curr_sess_absflag",1);   
        this.total=parseInt(this.interest)+parseInt(this.rhythm)+parseInt(this.grace);
        this.reduction=parseFloat(this.total)/3;
        this.callFetchGrade();      
        }
      },
      callFetchGrade:function(){
        this.fetchgradesurl=sessionStorage.getItem("addrinfo")+"/fetchgrade-service"; 
        this.$.fetchgradesajax.generateRequest(); 
      },
      fetchgradesResponse:function(e){
        var returnval=e.detail.response.returnval;       
        for(var i=0;i<returnval.length;i++){
          lower.push(returnval[i].lower_limit);
          higher.push(returnval[i].higher_limit);
          grade.push(returnval[i].grade);
        }
        this.grade=this.FnFindGrade((parseInt(this.reduction)));  
        this.callService();  
      },
      FnFindGrade:function(mark){        
        for(var i=0;i<lower.length;i++){          
          if(mark>=lower[i]&&mark<=higher[i]){            
            this.grade=grade[i];
          }
        }
        return this.grade;        
      },
      callService:function(){
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Interest",this.interest,1);
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Rhythm",this.rhythm,2);  
        this.$.assesmentservice.callinsertassesmentmarkService(this.studid,this.studname,"Dance","Grace",this.grace,3);  
        // this.$.assesmentservice.calloverallinsertcocurricularmarkService(this.studid,this.studname,"Dance",this.total,this.reduction,this.grade);
      }     
    });
  })();
  </script>
</dom-module>

{'fraction_non_alphanumeric': 0.1760613487232192, 'fraction_numerical': 0.0068780140722586765, 'mean_word_length': 2.554369204832818, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 117, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6002208', 'n_tokens_mistral': 4060, 'n_tokens_neox': 3921, 'n_words': 385}