<commit_before># :nodoc: namespace
module Stellar

# Stellar client scoped to a course's Gradebook module.
class Gradebook
  # Maps the text in navigation links to URI objects.
  #
  # Example: navigation['Homework'] => <# URI: .../ >
  attr_reader :navigation
  
  # The course whose Gradebook is exposed by this client.
  attr_reader :course
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a Stellar client scoped to a course's Gradebook module.
  #
  # @param [Stellar::Course] the course whose gradebook is desired
  def initialize(course)
    @course = course
    @client = course.client
    @url = course.navigation['Gradebook']
    
    page = @client.get_nokogiri @url
    @navigation = Hash[page.css('#toolBox.dashboard dd a').map { |link|
      [link.inner_text, URI.join(page.url, link['href'])]
    }]
  end

  # All assignments in this course's Gradebook module.
  # @return [Stellar::Gradebook::AssignmentList] list of assignments in this
  #     gradebook
  def assignments
    @assignments ||= Stellar::Gradebook::AssignmentList.new self
  end  

# Collection of assignments in a course's Gradebook module.
class AssignmentList
  # The course's 
  attr_reader :gradebook
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a list of Gradebook assignments for a class.
  #
  # @param [Stellar::Gradebook] gradebook client scoped to a course's Gradebook
  def initialize(gradebook)
    @gradebook = gradebook
    @client = gradebook.client
    
    @url = gradebook.navigation['Assignments']
    assignment_page = @client.get_nokogiri @url
    
    @assignments = assignment_page.css('table.gradesTable tbody tr').map { |row|
      
    }.reject(&:nil?)
  end
  
  # All assignments in this course's Gradebook module.
  # @return [Array<Stellar::Gradebook>] list of assignments posted by this
  #     course 
  def all
    @assignments
  end
  
  # An assignment in the course's homework module.
  # @param [String] name the name of the desired assignment
  # @return [Stellar::Homework] an assignment with the given name, or nil if no
  #     such assignment exists 
  def named(name)
    @assignments.find { |a| a.name == name }
  end  
end  # class Stellar::Gradebook::AssignmentList

# One assignment in the Gradebook tab.
class Assignment
  # Assignment name.
  attr_reader :name
  
  # The gradebook that this assignment is in.
  attr_reader :gradebook
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a submission from a <tr> element in the Gradebook assignments page.
  #
  # @param [Nokogiri::XML::Element] tr a <tr> element in the Gradebook
  #     assignments page describing this assignment
  # @param [Stellar::Gradebook] gradebook Stellar client scoped to the
  #     course gradebook containing this assignment
  def initialize(tr, course)
    @name = name
    @url = page_url
    @course = course
    @client = course.client
    
    page = @client.get_nokogiri @url
    unless page.css('#content p b').any? { |dom| dom.inner_text.strip == name }
      raise ArgumentError, 'Invalid Gradebook page URL'
    end
  end
  
  # List of submissions associated with this problem set.
  def submissions
    page = @client.get_nokogiri @url
    @submissions ||= page.css('.gradeTable tbody tr').map { |tr|
      begin
        Stellar::Gradebook::Submission.new tr, self<commit_msg>Forgotten changes.<commit_after># :nodoc: namespace
module Stellar

# Stellar client scoped to a course's Gradebook module.
class Gradebook
  # Maps the text in navigation links to URI objects.
  #
  # Example: navigation['Homework'] => <# URI: .../ >
  attr_reader :navigation
  
  # The course whose Gradebook is exposed by this client.
  attr_reader :course
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a Stellar client scoped to a course's Gradebook module.
  #
  # @param [Stellar::Course] the course whose gradebook is desired
  def initialize(course)
    @course = course
    @client = course.client
    @url = course.navigation['Gradebook']
    
    page = @client.get_nokogiri @url
    @navigation = Hash[page.css('#toolBox.dashboard dd a').map { |link|
      [link.inner_text, URI.join(page.url, link['href'])]
    }]
  end

  # All assignments in this course's Gradebook module.
  # @return [Stellar::Gradebook::AssignmentList] list of assignments in this
  #     gradebook
  def assignments
    @assignments ||= Stellar::Gradebook::AssignmentList.new self
  end  

# Collection of assignments in a course's Gradebook module.
class AssignmentList
  # The course's 
  attr_reader :gradebook
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a list of Gradebook assignments for a class.
  #
  # @param [Stellar::Gradebook] gradebook client scoped to a course's Gradebook
  def initialize(gradebook)
    @gradebook = gradebook
    @client = gradebook.client
    
    @url = gradebook.navigation['Assignments']
    assignment_page = @client.get_nokogiri @url
    
    @assignments = assignment_page.css('table.gradesTable tbody tr').map { |row|
      
    }.reject(&:nil?)
  end
  
  # All assignments in this course's Gradebook module.
  # @return [Array<Stellar::Gradebook>] list of assignments posted by this
  #     course 
  def all
    @assignments
  end
  
  # An assignment in the course's homework module.
  # @param [String] name the name of the desired assignment
  # @return [Stellar::Homework] an assignment with the given name, or nil if no
  #     such assignment exists 
  def named(name)
    @assignments.find { |a| a.name == name }
  end  
end  # class Stellar::Gradebook::AssignmentList

# One assignment in the Gradebook tab.
class Assignment
  # Assignment name.
  attr_reader :name
  
  # URL of the assignment's main page.
  attr_reader :url
  
  # The gradebook that this assignment is in.
  attr_reader :gradebook
  
  # Generic Stellar client used to make requests.
  attr_reader :client
  
  # Creates a submission from a <tr> element in the Gradebook assignments page.
  #
  # @param [Nokogiri::XML::Element] tr a <tr> element in the Gradebook
  #     assignments page describing this assignment
  # @param [Stellar::Gradebook] gradebook Stellar client scoped to the
  #     course gradebook containing this assignment
  def initialize(tr, gradebook)
    @gradebook = gradebook
    @client = gradebook.client
    
    
    
    page = @client.get_nokogiri @url
    unless page.css('#content p b').any? { |dom| dom.inner_text.strip == name }
      raise ArgumentError, 'Invalid Gradebook page URL'
    end
  end
  
  # List of submissions associated with this problem set.
  def submissions
    page = @client.get_nokogiri @url
    @submissions ||= page.css('.gradeTable tbody tr').map { |tr|
      begin
        Stellar::Gradebook::Submission.new tr, self
{'fraction_non_alphanumeric': 0.08943325119582549, 'fraction_numerical': 0.0, 'mean_word_length': 3.328732747804266, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '1647850', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2046, 'n_words': 700}