<commit_before># -*- coding: utf-8 -*-

require 'digest/md5'
require 'ftools'

class CoursesController < ApplicationController
  # GET /courses
  # GET /courses.xml
  def index
    @courses = Course.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @courses }
    end
  end

  # GET /courses/1
  # GET /courses/1.xml
  def show
    @course = Course.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @course }
    end
  end

  # GET /courses/new
  # GET /courses/new.xml
  def new
    @course = Course.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @course }
    end
  end

  # GET /courses/1/edit
  def edit
    @course = Course.find(params[:id])
  end

  # POST /courses
  # POST /courses.xml
  def create
    @course = Course.new(params[:course])

    respond_to do |format|
      if @course.save
        flash[:notice] = 'Course was successfully created.'
        format.html { redirect_to(@course) }
        format.xml  { render :xml => @course, :status => :created, :location => @course }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @course.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /courses/1
  # PUT /courses/1.xml
  def update
    @course = Course.find(params[:id])

    respond_to do |format|
      if @course.update_attributes(params[:course])
        flash[:notice] = 'Course was successfully updated.'
        format.html { redirect_to(@course) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @course.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /courses/1
  # DELETE /courses/1.xml
  def destroy
    @course = Course.find(params[:id])
    @course.destroy

    respond_to do |format|
      format.html { redirect_to(courses_url) }
      format.xml  { head :ok }
    end
  end
  
  # DELETE /courses/drop_prof?course=1&prof=1
  def drop_prof
    @course = Course.find(params[:id])
    @prof = Prof.find(params[:prof_id])
    @course.profs.delete(@prof)
    
    respond_to do |format|
      format.html { redirect_to(@course) }
      format.xml { head :ok }
    end
  end
  
  def add_prof
    @course = Course.find(params[:id])
    @prof = Prof.find(params[:courses][:profs])
    @course.profs << @prof
    
    respond_to do |format|
      format.html { redirect_to(@course) }
      format.xml { head :ok }
    end
  end
  def get_direct_pdf(c,p)
    @course = c
    @prof = p
    workdir = '/var/www-seee/web/public/forms/'
    hexdigest = Digest::SHA256.hexdigest(@prof.fullname + @course.title)    
    filename = @course.students.to_s + '_' + hexdigest
    if not FileTest.exists?(workdir + filename + '.pdf')
      b = Evalbogen.new
      b.workdir = workdir
      b.tutoren = @course.tutors.map { |t| t.abbr_name}.reverse
      b.dozent = @prof.fullname
      b.semester = @course.semester.title
      b.veranstaltung = @course.title
      @course.form ||= 0
      b.bogen_basefile = @course.form.to_s<commit_msg>get_direct_die_roms_stinken_pdf ...<commit_after># -*- coding: utf-8 -*-

require 'digest/md5'
require 'ftools'

class CoursesController < ApplicationController
  # GET /courses
  # GET /courses.xml
  def index
    @courses = Course.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @courses }
    end
  end

  # GET /courses/1
  # GET /courses/1.xml
  def show
    @course = Course.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @course }
    end
  end

  # GET /courses/new
  # GET /courses/new.xml
  def new
    @course = Course.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @course }
    end
  end

  # GET /courses/1/edit
  def edit
    @course = Course.find(params[:id])
  end

  # POST /courses
  # POST /courses.xml
  def create
    @course = Course.new(params[:course])

    respond_to do |format|
      if @course.save
        flash[:notice] = 'Course was successfully created.'
        format.html { redirect_to(@course) }
        format.xml  { render :xml => @course, :status => :created, :location => @course }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @course.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /courses/1
  # PUT /courses/1.xml
  def update
    @course = Course.find(params[:id])

    respond_to do |format|
      if @course.update_attributes(params[:course])
        flash[:notice] = 'Course was successfully updated.'
        format.html { redirect_to(@course) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @course.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /courses/1
  # DELETE /courses/1.xml
  def destroy
    @course = Course.find(params[:id])
    @course.destroy

    respond_to do |format|
      format.html { redirect_to(courses_url) }
      format.xml  { head :ok }
    end
  end
  
  # DELETE /courses/drop_prof?course=1&prof=1
  def drop_prof
    @course = Course.find(params[:id])
    @prof = Prof.find(params[:prof_id])
    @course.profs.delete(@prof)
    
    respond_to do |format|
      format.html { redirect_to(@course) }
      format.xml { head :ok }
    end
  end
  
  def add_prof
    @course = Course.find(params[:id])
    @prof = Prof.find(params[:courses][:profs])
    @course.profs << @prof
    
    respond_to do |format|
      format.html { redirect_to(@course) }
      format.xml { head :ok }
    end
  end
  def get_direct_die_roms_stinken_pdf(c)
    @course = c
    workdir = '/var/www-seee/web/public/forms/'
    hexdigest = Digest::SHA256.hexdigest(@course.id.to_s + @course.title)    
    filename = @course.students.to_s + '_' + hexdigest
    if not FileTest.exists?(workdir + filename + '.pdf')
      b = Evalbogen.new
      b.workdir = workdir
      b.tutoren = @course.tutors.map { |t| t.abbr_name}.reverse
      b.semester = @course.semester.title
      b.veranstaltung = @course.title
      @course.form ||= 0
      b.bogen_basefile = @course.form.to_s
      
      b.output_to_file_and_compile(filename)
    end    
    
    File.copy(workdir + filename + '.pdf', './' + @course.title + ' - ' + @course.id.to_s + ' - ' + @course.students.to_s + ' pcs.pdf')
  end
  def get_direct_pdf(c,p)
    @course = c
    @prof = p
    workdir = '/var/www-seee/web/public/forms/'
    hexdigest = Digest::SHA256.hexdigest(@prof.fullname + @course.title)    
    filename = @course.students.to_s + '_' + hexdigest
    if not FileTest.exists?(workdir + filename + '.pdf')
      b = Evalbogen.new
      b.workdir = workdir
      b.tutoren = @course.tutors.map { |t| t.abbr_name}.reverse
      b.dozent = @prof.fullname
      b.semester = @course.semester.title
      b.veranstaltung = @course.title
      @course.form ||= 0
      b.bogen_basefile = @course.form.to_s
{'fraction_non_alphanumeric': 0.13373059866962306, 'fraction_numerical': 0.0047117516629711755, 'mean_word_length': 2.397834274952919, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 3, 'xml': 44}, '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': '1776608', 'n_tokens_mistral': 2566, 'n_tokens_neox': 2510, 'n_words': 535}