<commit_before>namespace :db do

  desc 'Create groups for assignments'
  task :groups => :environment do
    puts 'Assign Groups/Students for Assignments'

    # remove previously existing group repos to create room for new ones
    FileUtils.rm_rf(Dir.glob('data/dev/repos/*'))

    students = Student.all
    Assignment.all.each do |assignment|
      num_groups = (assignment.short_identifier == 'A1' && ENV['A1_GROUP_AMOUNT']) ? ENV['A1_GROUP_AMOUNT'].to_i : 15
      num_groups.times do |time|
        student = students[time]
        if assignment.short_identifier == 'A1' || assignment.short_identifier == 'A3'
          student.create_group_for_working_alone_student(assignment.id)
          group = Group.find_by group_name: student.user_name
        elsif assignment.short_identifier == 'A0' || assignment.short_identifier == 'A2' || assignment.short_identifier == 'A4'
          group = Group.create(
            group_name: "#{ student.user_name } #{ assignment.short_identifier }"
          )
          grouping = Grouping.create(
            group: group,
            assignment: assignment
          )
          grouping.invite(
            [student.user_name],
            StudentMembership::STATUSES[:inviter],
            invoked_by_admin=true,
            update_permissions=false)
          grouping.invite(
            [students[time + 15].user_name],
            StudentMembership::STATUSES[:accepted],
            invoked_by_admin=true,
            update_permissions=false)
        end

        group.access_repo do |repo|
          txn = repo.get_transaction(group.grouping_for_assignment(assignment.id).inviter.user_name)
          #add files to the root folder of the repo (e.g. "A1")
          file_dir  = File.join(File.dirname(__FILE__), '/../../db/data/submission_files')
          # recursively copying contents(files & directories) inside the file_dir
          copy_dir(file_dir, txn, assignment.repository_folder)

          repo.commit(txn)
        end
      end<commit_msg>changed if statement in groups.rake<commit_after>namespace :db do

  desc 'Create groups for assignments'
  task :groups => :environment do
    puts 'Assign Groups/Students for Assignments'

    # remove previously existing group repos to create room for new ones
    FileUtils.rm_rf(Dir.glob('data/dev/repos/*'))

    students = Student.all
    Assignment.all.each do |assignment|
      num_groups = (assignment.short_identifier == 'A1' && ENV['A1_GROUP_AMOUNT']) ? ENV['A1_GROUP_AMOUNT'].to_i : 15
      num_groups.times do |time|
        student = students[time]
        # if this is an individual assignment
        if assignment.groups_min == 1 && assignment.group_max == 1
          student.create_group_for_working_alone_student(assignment.id)
          group = Group.find_by group_name: student.user_name
        # if this is a group assignment
        else
          group = Group.create(
            group_name: "#{ student.user_name } #{ assignment.short_identifier }"
          )
          grouping = Grouping.create(
            group: group,
            assignment: assignment
          )
          grouping.invite(
            [student.user_name],
            StudentMembership::STATUSES[:inviter],
            invoked_by_admin=true,
            update_permissions=false)
          grouping.invite(
            [students[time + 15].user_name],
            StudentMembership::STATUSES[:accepted],
            invoked_by_admin=true,
            update_permissions=false)
        end

        group.access_repo do |repo|
          txn = repo.get_transaction(group.grouping_for_assignment(assignment.id).inviter.user_name)
          #add files to the root folder of the repo (e.g. "A1")
          file_dir  = File.join(File.dirname(__FILE__), '/../../db/data/submission_files')
          # recursively copying contents(files & directories) inside the file_dir
          copy_dir(file_dir, txn, assignment.repository_folder)

          repo.commit(txn)
        end
      end
{'fraction_non_alphanumeric': 0.09814722083124687, 'fraction_numerical': 0.005758637956935403, 'mean_word_length': 2.4678819444444446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7110840', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1131, 'n_words': 243}