---
title: "MMZI -- kolokvij 1 i 2"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
kol1 <- read.csv("kol1.csv")
kol2 <- read.csv("kol2.csv")
podaci1 <- kol1 %>% transmute(student = paste(Prezime, Ime), 
           Vrijeme = as.numeric(difftime(as.POSIXct(Završeno, format="%d. %B %Y. %H:%M"),
                                         as.POSIXct(Započeto, format="%d. %B %Y. %H:%M"),
                                         units='mins')), Bodovi = round(Bodovi)) %>% 
           filter(student != "Ukupni prosjek ") %>% mutate(kolokvij = "KOL1")
podaci2 <- kol2 %>% transmute(student = paste(Prezime, Ime), 
                              Vrijeme = as.numeric(difftime(as.POSIXct(Završeno, format="%d. %B %Y. %H:%M"),
                                                             as.POSIXct(Započeto, format="%d. %B %Y. %H:%M"),
                                                             units='mins')), Bodovi = round(Bodovi)) %>% 
           filter(student != "Ukupni prosjek ")  %>% mutate(kolokvij = "KOL2")
podaci <- podaci1 %>% bind_rows(podaci2) %>% group_by(student) %>% mutate(Ukupno = sum(Bodovi)) %>% ungroup()
bodovi30do40 <- podaci %>% filter(Ukupno %in% 30:40)
bodovi26do29 <- podaci %>% filter(Ukupno %in% 26:29)
bodovi22do25 <- podaci %>% filter(Ukupno %in% 22:25)
bodovi18do21 <- podaci %>% filter(Ukupno %in% 18:21)
bodovi14do17 <- podaci %>% filter(Ukupno %in% 14:17)
bodovi0do13 <- podaci %>% filter(Ukupno %in% 0:13)
```

Bodovi: 30 - 40
=======================================================================

```{r}
as.numeric(bodovi30do40 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(bodovi30do40) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```

Bodovi: 26 - 29
=======================================================================

```{r}
as.numeric(bodovi26do29 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=13}
ggplot(bodovi26do29) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```

Bodovi: 22 - 25
=======================================================================

```{r}
as.numeric(bodovi22do25 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=13}
ggplot(bodovi22do25) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```

Bodovi: 18 - 21
=======================================================================

```{r}
as.numeric(bodovi18do21 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=10}
ggplot(bodovi18do21) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```

Bodovi: 14 - 17
=======================================================================

```{r}
as.numeric(bodovi14do17 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=13}
ggplot(bodovi14do17) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```

Bodovi: 0 - 13
=======================================================================

```{r}
as.numeric(bodovi0do13 %>% summarize(n_distinct(student)))
```

Row
-----------------------------------------------------------------------

```{r warning=FALSE, fig.width=17, fig.height=11}
ggplot(bodovi0do13) + geom_point(aes(x=Vrijeme, y=student), size=6, color="#2266ee") + 
  geom_segment(aes(x=Vrijeme, y=student, xend = Bodovi, yend = student), size = 2, color="#2266ee") +
  geom_point(aes(x=Bodovi, y=student),size=6, color="#ff5589") + 
  geom_segment(aes(x=Bodovi, y=student, xend = 0, yend = student), size = 2, color="#ff5589") +
  geom_text(aes(x=Vrijeme, y=student, label = Vrijeme), color = "white", size = 3) +
  geom_text(aes(x=Bodovi, y=student, label = Bodovi), color = "white", size = 3) +
  labs(x="Bodovi / Vrijeme (min)") + facet_wrap(~kolokvij)
```
