ps-naloga5/README.md
2025-12-01 22:33:35 +01:00

3.8 KiB

Redovalnica - Student Grade Management System

Package redovalnica implements a simple grade book in Go.

Description

A minimal grading system: add students and grades, list grades, and compute final results. Configurable thresholds control required grade counts and the grading range.

Installation

go get git.fri.uni-lj.si/zs7976/ps-naloga5

Package Structure

naloga5/
├── redovalnica/          # Core package with grading functionality
│   └── redovalnica.go
├── cmd/                  # Command-line application
│   └── redovalnica.go
├── go.mod
├── go.sum
└── README.md

Exported Functions

The redovalnica package exports the following functions:

DodajStudenta

func DodajStudenta(studenti map[string]Student, vpisnaStevilka string, ime string, priimek string)

Adds a new student to the grade book. If a student with the given ID already exists, the function does nothing.

DodajOceno

func DodajOceno(studenti map[string]Student, vpisnaStevilka string, ocena int)

Adds a grade to a student's record. If the student doesn't exist, the function does nothing.

IzpisVsehOcen

func IzpisVsehOcen(studenti map[string]Student)

Prints all students and their grades to standard output.

IzpisiKoncniUspeh

func IzpisiKoncniUspeh(studenti map[string]Student, minStOcen int, minOcena int, maxOcena int)

Prints the final success status for all students based on their average grades and configured parameters.

Usage as a Library

package main

import (
    "git.fri.uni-lj.si/zs7976/ps-naloga5/redovalnica"
)

func main() {
    // Create student map
    studenti := make(map[string]redovalnica.Student)
    
    // Add students
    redovalnica.DodajStudenta(studenti, "63210001", "Ana", "Novak")
    redovalnica.DodajStudenta(studenti, "63210002", "Boris", "Kralj")
    
    // Add grades
    redovalnica.DodajOceno(studenti, "63210001", 10)
    redovalnica.DodajOceno(studenti, "63210001", 9)
    redovalnica.DodajOceno(studenti, "63210001", 8)
    
    redovalnica.DodajOceno(studenti, "63210002", 6)
    redovalnica.DodajOceno(studenti, "63210002", 7)
    
    // Display all grades
    redovalnica.IzpisVsehOcen(studenti)
    
    // Display final success (minStOcen=3, minOcena=1, maxOcena=10)
    redovalnica.IzpisiKoncniUspeh(studenti, 3, 1, 10)
}

Command-Line Application

The package includes a command-line application with configurable parameters.

Building

cd cmd
go build -o redovalnica

Running

# Run with default parameters
./redovalnica

# Run with custom parameters
./redovalnica --stOcen 4 --minOcena 5 --maxOcena 10

Command-Line Flags

  • --stOcen: Minimum number of grades required for positive evaluation (default: 3)
  • --minOcena: Minimum possible grade (default: 1)
  • --maxOcena: Maximum possible grade (default: 10)

Example Output

=== Sistem Redovalnica ===
Parametri: minStOcen=3, minOcena=1, maxOcena=10

REDOVALNICA:
63210001 - Ana Novak: [10 9 8]
63210002 - Boris Kralj: [6 7 5 8]
63210003 - Janez Novak: [4 5]

Ana Novak: povprečna ocena 9.0 (3 ocen) -> Odličen študent!
Boris Kralj: povprečna ocena 6.5 (4 ocen) -> Povprečen študent
Janez Novak: povprečna ocena 4.5 (2 ocen) -> Premalo ocen

Internal functions

Unexported helpers:

  • povprecje: average grade for a student
  • izpisStudenta: format student info
  • vrniUspeh: determine success category

Documentation

For detailed API documentation, run:

go doc git.fri.uni-lj.si/zs7976/ps-naloga5/redovalnica

Or view documentation for specific functions:

go doc git.fri.uni-lj.si/zs7976/ps-naloga5/redovalnica.DodajOceno
go doc git.fri.uni-lj.si/zs7976/ps-naloga5/redovalnica.IzpisVsehOcen

Author

Žan Skvarča