<commit_before>/**
 * Copyright (C) 2011 Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
define([
  'i18n!rubric_assessment',
  'jquery' /* $ */,
  'str/htmlEscape',
  'jquery.instructure_forms' /* fillFormData */,
  'jqueryui/dialog',
  'jquery.instructure_misc_helpers' /* truncateText */,
  'jquery.instructure_misc_plugins' /* showIf */,
  'jquery.templateData' /* fillTemplateData, getTemplateData */,
  'vendor/jquery.scrollTo' /* /\.scrollTo/ */
], function(I18n, $, htmlEscape) {

// TODO: stop managing this in the view and get it out of the global scope submissions/show.html.erb
window.rubricAssessment = {
  init: function(){
    var $rubric_criterion_comments_dialog = $("#rubric_criterion_comments_dialog");

    $('.rubric')
      .delegate(".rating", 'click', function(event) {
        $(this).parents(".criterion").find(".criterion_points").val($(this).find(".points").text()).change();
      })
      .delegate(".long_description_link", 'click', function(event) {
        event.preventDefault();
        if(!$(this).parents(".rubric").hasClass('editing')) {
          var data = $(this).parents(".criterion").getTemplateData({textValues: ['long_description', 'description']}),
              is_learning_outcome = $(this).parents(".criterion").hasClass("learning_outcome_criterion");
          $("#rubric_long_description_dialog")
            .fillTemplateData({data: data, htmlValues: ( is_learning_outcome ? ['long_description'] : [] )})
            .find(".editing").hide().end()
            .find(".displaying").show().end()
            .dialog('close').dialog({
              autoOpen: false,
              title: I18n.t('titles.criterion_long_description', "Criterion Long Description"),
              width: 400
            }).dialog('open');
        }
      })
      .delegate(".criterion .saved_custom_rating", 'change', function() {
        if($(this).parents(".rubric").hasClass('assessing')) { 
          var val = $(this).val();
          if(val && val.length > 0) {
            $(this).parents(".custom_ratings_entry").find(".custom_rating_field").val(unescape(val));
          }
        }
      })
      .delegate('.criterion_comments', 'click', function(event) {
        event.preventDefault();
        event.preventDefault();
        var $criterion = $(this).parents(".criterion"),
            comments = $criterion.getTemplateData({textValues: ['custom_rating']}).custom_rating,
            editing = $(this).closest('td').children('.editing').is(':visible'),
            data = {
              criterion_comments: comments,
              criterion_description: $criterion.find(".description:first").text()
            };
        $rubric_criterion_comments_dialog.data('current_rating', $criterion);
        $rubric_criterion_comments_dialog.fillTemplateData({data: data});
        $rubric_criterion_comments_dialog.fillFormData(data);
        $rubric_criterion_comments_dialog.find(".editing").showIf(editing);
        $rubric_criterion_comments_dialog.find(".displaying").showIf(!editing);
        $rubric_criterion_comments_dialog.dialog('close').dialog({
          autoOpen: false,
          title: I18n.t('titles.additional_comments', "Additional Comments"),
          width: 400
        }).dialog('open');
      })
      // cant use a .delegate because up above when we delegate '.rating' 'click' it calls .change() and that doesnt bubble right so it doesen't get caught
      .find(".criterion_points").bind('keypress change blur', function(event) {
        var $obj = $(event.target);
        if($obj.parents(".rubric").hasClass('assessing')) {
          var val = parseFloat($obj.val(), 10);
          if(isNaN(val)) { val = null; }
          var $criterion = $obj.parents(".criterion");
          $criterion.find(".rating.selected").removeClass('selected');
          if (val || val === 0) {
            $criterion.find(".criterion_description").addClass('completed');
            $criterion.find(".rating").each(function() {
              var rating_val = parseFloat($(this).find(".points").text(), 10);
              if(rating_val == val) {
                $(this).addClass('selected');
              }
            });
          } else {
            $criterion.find(".criterion_description").removeClass('completed');
          }
          var total = 0;
          $obj.parents(".rubric").find(".criterion:visible:not(.ignore_criterion_for_scoring) .criterion_points").each(function() {
            var val = parseFloat($(this).val(), 10);
            if(isNaN(val)) { val = 0; }
            total += val;
          });
          $obj.parents(".rubric").find(".rubric_total").text(total);
        }
      });

    $(".rubric_summary").delegate(".rating_comments_dialog_link", 'click', function(event) {
      event.preventDefault();
      var $criterion = $(this).parents(".criterion"),
          comments = $criterion.getTemplateData({textValues: ['rating_custom']}).rating_custom,
          data = {
            criterion_comments: comments,
            criterion_description: $criterion.find(".criterion_description:first").text()
          };

      $rubric_criterion_comments_dialog.data('current_rating', $criterion);
      $rubric_criterion_comments_dialog.fillTemplateData({data: data});
      $rubric_criterion_comments_dialog.fillFormData(data);
      $rubric_criterion_comments_dialog.find(".editing").hide();
      $rubric_criterion_comments_dialog.find(".displaying").show();
      $rubric_criterion_comments_dialog.dialog('close').dialog({
        autoOpen: false,
        title: I18n.t('titles.additional_comments', "Additional Comments"),
        width: 400
      }).dialog('open');
    });


<commit_msg>remove unwanted info in rubric comments dialog<commit_after>/**
 * Copyright (C) 2011 Instructure, Inc.
 *
 * This file is part of Canvas.
 *
 * Canvas is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Affero General Public License as published by the Free
 * Software Foundation, version 3 of the License.
 *
 * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
 * details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
define([
  'i18n!rubric_assessment',
  'jquery' /* $ */,
  'str/htmlEscape',
  'jquery.instructure_forms' /* fillFormData */,
  'jqueryui/dialog',
  'jquery.instructure_misc_helpers' /* truncateText */,
  'jquery.instructure_misc_plugins' /* showIf */,
  'jquery.templateData' /* fillTemplateData, getTemplateData */,
  'vendor/jquery.scrollTo' /* /\.scrollTo/ */
], function(I18n, $, htmlEscape) {

// TODO: stop managing this in the view and get it out of the global scope submissions/show.html.erb
window.rubricAssessment = {
  init: function(){
    var $rubric_criterion_comments_dialog = $("#rubric_criterion_comments_dialog");

    $('.rubric')
      .delegate(".rating", 'click', function(event) {
        $(this).parents(".criterion").find(".criterion_points").val($(this).find(".points").text()).change();
      })
      .delegate(".long_description_link", 'click', function(event) {
        event.preventDefault();
        if(!$(this).parents(".rubric").hasClass('editing')) {
          var data = $(this).parents(".criterion").getTemplateData({textValues: ['long_description', 'description']}),
              is_learning_outcome = $(this).parents(".criterion").hasClass("learning_outcome_criterion");
          $("#rubric_long_description_dialog")
            .fillTemplateData({data: data, htmlValues: ( is_learning_outcome ? ['long_description'] : [] )})
            .find(".editing").hide().end()
            .find(".displaying").show().end()
            .dialog('close').dialog({
              autoOpen: false,
              title: I18n.t('titles.criterion_long_description', "Criterion Long Description"),
              width: 400
            }).dialog('open');
        }
      })
      .delegate(".criterion .saved_custom_rating", 'change', function() {
        if($(this).parents(".rubric").hasClass('assessing')) { 
          var val = $(this).val();
          if(val && val.length > 0) {
            $(this).parents(".custom_ratings_entry").find(".custom_rating_field").val(unescape(val));
          }
        }
      })
      .delegate('.criterion_comments', 'click', function(event) {
        event.preventDefault();
        event.preventDefault();
        var $criterion = $(this).parents(".criterion"),
            comments = $criterion.getTemplateData({textValues: ['custom_rating']}).custom_rating,
            editing = $(this).closest('td').children('.editing').is(':visible'),
            data = {
              criterion_comments: comments,
              criterion_description: $criterion.find(".description:first").text()
            };
        $rubric_criterion_comments_dialog.data('current_rating', $criterion);
        $rubric_criterion_comments_dialog.fillTemplateData({data: data});
        $rubric_criterion_comments_dialog.fillFormData(data);
        $rubric_criterion_comments_dialog.find(".editing").showIf(editing);
        $rubric_criterion_comments_dialog.find(".displaying").showIf(!editing);
        $rubric_criterion_comments_dialog.dialog('close').dialog({
          autoOpen: false,
          title: I18n.t('titles.additional_comments', "Additional Comments"),
          width: 400
        }).dialog('open');
      })
      // cant use a .delegate because up above when we delegate '.rating' 'click' it calls .change() and that doesnt bubble right so it doesen't get caught
      .find(".criterion_points").bind('keypress change blur', function(event) {
        var $obj = $(event.target);
        if($obj.parents(".rubric").hasClass('assessing')) {
          var val = parseFloat($obj.val(), 10);
          if(isNaN(val)) { val = null; }
          var $criterion = $obj.parents(".criterion");
          $criterion.find(".rating.selected").removeClass('selected');
          if (val || val === 0) {
            $criterion.find(".criterion_description").addClass('completed');
            $criterion.find(".rating").each(function() {
              var rating_val = parseFloat($(this).find(".points").text(), 10);
              if(rating_val == val) {
                $(this).addClass('selected');
              }
            });
          } else {
            $criterion.find(".criterion_description").removeClass('completed');
          }
          var total = 0;
          $obj.parents(".rubric").find(".criterion:visible:not(.ignore_criterion_for_scoring) .criterion_points").each(function() {
            var val = parseFloat($(this).val(), 10);
            if(isNaN(val)) { val = 0; }
            total += val;
          });
          $obj.parents(".rubric").find(".rubric_total").text(total);
        }
      });

    $(".rubric_summary").delegate(".rating_comments_dialog_link", 'click', function(event) {
      event.preventDefault();
      var $criterion = $(this).parents(".criterion"),
          comments = $criterion.getTemplateData({textValues: ['rating_custom']}).rating_custom,
          criterion_name = $criterion.find(".criterion_description:first").text().split(/\b\s+/)[0],
          data = {
            criterion_comments: comments,
            criterion_description: criterion_name + ' description: ' + $criterion.find(".criterion_description .long_description:first").text()
          };

      $rubric_criterion_comments_dialog.data('current_rating', $criterion);
      $rubric_criterion_comments_dialog.fillTemplateData({data: data});
      $rubric_criterion_comments_dialog.fillFormData(data);
      $rubric_criterion_comments_dialog.find(".editing").hide();
      $rubric_criterion_comments_dialog.find(".displaying").show();
      $rubric_criterion_comments_dialog.dialog('close').dialog({
        autoOpen: false,
        title: I18n.t('titles.additional_comments', "Additional Comments"),
        width: 400
      }).dialog('open');
    });



{'fraction_non_alphanumeric': 0.15545625587958609, 'fraction_numerical': 0.005409219190968956, 'mean_word_length': 2.9965538847117794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5549919', 'n_tokens_mistral': 3606, 'n_tokens_neox': 3513, 'n_words': 677}