Skip to content

Commit

Permalink
MUC.DAI exams
Browse files Browse the repository at this point in the history
  • Loading branch information
obcode committed May 7, 2024
1 parent d522e48 commit c73a61d
Show file tree
Hide file tree
Showing 16 changed files with 1,046 additions and 254 deletions.
4 changes: 4 additions & 0 deletions db/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ func (db *DB) getCollectionSemester(collectionName string) *mongo.Collection {
func (db *DB) getCollectionSemesterFromContext(ctx context.Context) *mongo.Collection {
return db.Client.Database(db.databaseName).Collection(ctx.Value(CollectionName("collectionName")).(string))
}

func (db *DB) getMucDaiCollection(program string) *mongo.Collection {
return db.Client.Database(db.databaseName).Collection(fmt.Sprintf("mucdai_%s", program))
}
41 changes: 41 additions & 0 deletions db/mucdai.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package db

import (
"context"

"github.com/rs/zerolog/log"
"go.mongodb.org/mongo-driver/bson"
)

type MucDaiExam struct {
PrimussAncode int `bson:"Nr"`
Module string `bson:"Modulname"`
ExamType string `bson:"Prüfungsform"`
Grading string `bson:"Bewertung"`
Duration int `bson:"Dauer"`
MainExamer string `bson:"Erstpruefender"`
SecondExamer string `bson:"Zweitpruefender"`
IsRepeaterExam string `bson:"IstWiederholung"`
Program string `bson:"Studiengruppe"`
Planer string `bson:"Prüfungsplanung"`
}

func (db *DB) MucDaiExamsForProgram(ctx context.Context, program string) ([]*MucDaiExam, error) {
collection := db.getMucDaiCollection(program)

cur, err := collection.Find(ctx, bson.D{})
if err != nil {
log.Error().Err(err).Str("program", program).Msg("cannot get exams for MUC.DAI program")
return nil, err
}
defer cur.Close(ctx)

exams := make([]*MucDaiExam, 0)
err = cur.All(ctx, &exams)
if err != nil {
log.Error().Err(err).Str("program", program).Msg("cannot decode exams for MUC.DAI program")
return nil, err
}

return exams, nil
}
14 changes: 14 additions & 0 deletions graph/exam.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ extend type Query {

externalExams: [ExternalExam!]!

mucdaiExams: [MucDaiExam!]!

generatedExams: [GeneratedExam!]!
generatedExam(ancode: Int!): GeneratedExam

Expand Down Expand Up @@ -102,6 +104,18 @@ type ExternalExam {
duration: Int!
}

type MucDaiExam {
primussAncode: Int!
module: String!
mainExamer: String!
mainExamerID: Int
examType: String!
duration: Int!
isRepeaterExam: Boolean!
program: String!
plannedBy: String!
}

type ConnectedExam {
zpaExam: ZPAExam!
primussExams: [PrimussExam!]!
Expand Down
7 changes: 6 additions & 1 deletion graph/exam.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c73a61d

Please sign in to comment.