<%= form_for('new_form', :remote => true, :method => :post,:url => add_score_student_work_path(work.id),:id=>'add_score_'+work.id.to_s) do |f|%>
    <li >
      <span class="tit_fb"> 评价：</span>
      <%= f.text_area 'user_message', :class => 'hwork_ping_text', :id => 'score_comment_'+work.id.to_s, :placeholder => l(:text_caracters_maximum,:count=>250),:maxlength => 250 %>
      <div class="cl"></div>
    </li>
    <p id="hint_message_<%=work.id %>" style="margin-left: 65px;"></p>
    <li >
      <span class="tit_fb mt2"> 评分：</span>
      <input type="number" name="score" id="score_<%= work.id%>" value="<%= (score.nil? || score.score.nil?) ? -1 : score.score%>" min="-1" max="100" size="4" data-units="dollars" />
      <span class="ml5">分</span>
      <span id="score_notice_span_<%= work.id%>" class="ml5 c_red" style="display: none;">未评分</span>
      <div class="cl"></div></li>
    <li >
      <% if @is_teacher%> <!-- 老师才可以上传批阅结果 -->
          <span class="tit_fb"> 批阅结果：</span>
          <div>
            <%= render :partial => 'student_work/student_work_attachment_form', :locals => {:work => work,:score => score} %>
          </div>
          <div class="cl"></div>
          <span class="c_red ml5" style="display: none;" id="none_notice_<%= work.id%>">评语、评分、批阅结果至少有一个不为空。</span>
      <%end%>
      <a href="javascript:void(0);" id="work_submit_<%= work.id %>" class="blue_n_btn fr evaluation_submit" onclick="score_submit('<%=work.id %>');">提交</a>
      <div class="cl"></div>
    </li>
<% end%>
<script type="text/javascript">
  var first_click_score = true;
    function score_submit(id){
        <% if !@is_teacher %>
            if ($.trim($('#score_comment_'+id).val()) == "") {
                $('#hint_message_'+id).html("为了对其他学生的作品负责，请您务必填写评语");
                $("#hint_message_"+id).css('color','#ff0000');
                $("#score_comment_"+id).focus();
            } else if (parseFloat($("#score_"+id).val()) == -1) {
                $('#score_notice_span_'+id).html("请先评分");
                $('#score_notice_span_'+id).show();
                $("#score_"+id).focus();
            }
            else if(first_click_score) {
                first_click_score = false;
                $("#work_submit_"+id).parent().parent().submit();
                $('#about_hwork_'+id).html('');
            }
        <% else %>
            if($.trim($('#score_comment_'+id).val()) == "" && parseFloat($("#score_"+id).val()) == -1 && $("#attachments_fields"+id).children().length == 0){
                $("#none_notice_"+id).show();
            } else if(parseFloat($("#score_"+id).val()) == -1) {
                $.ajax({
                    type: "GET",
                    url: "/student_work/"+id+"/add_comments_to_work",
                    data: 'text',
                    success: function (data) {
                    }
                });
            }
            else if(first_click_score) {
                first_click_score = false;
                $("#work_submit_" + id).parent().parent().submit();
            }
        <% end %>
    }
    function submit_teacher_score(id){
        if (first_click_score) {
            first_click_score = false;
            $("#work_submit_"+id).parent().parent().submit();
            hideModal();
        }
    }
</script>