Skip to content

Commit

Permalink
Merge pull request #211 from kzi-nastava/feat/add-exam-application-wi…
Browse files Browse the repository at this point in the history
…ndow-layout

Feat: add exam application window layout
  • Loading branch information
anasinik authored Apr 29, 2024
2 parents 5bca650 + 55e94c4 commit b0d9f7e
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 62 deletions.
49 changes: 49 additions & 0 deletions LangLang/View/ExamSlotGUI/ExamApplications.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Window x:Class="LangLang.View.ExamSlotGUI.ExamApplications"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LangLang.View.ExamSlotGUI"
mc:Ignorable="d"
Title="ExamApplications" Height="450" Width="500"
WindowStartupLocation="CenterScreen"
ResizeMode="NoResize">
<Grid>
<!-- start of applications label-->
<Label x:Name="coursesLbl" Content="Applications for the exam" Grid.Row="0" HorizontalAlignment="Center" Height="28" Margin="0,10,0,0" VerticalAlignment="Top" Width="310" FontStyle="Italic" Foreground="Black" RenderTransformOrigin="0.499,0.077" FontFamily="Arial" FontWeight="Bold" HorizontalContentAlignment="Center">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleX="0"/>
<RotateTransform/>
<TranslateTransform X="0"/>
</TransformGroup>
</Label.RenderTransform>
<Label.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Black" Offset="1"/>
<GradientStop Color="#FFFFBDBD" Offset="0.889"/>
<GradientStop Color="#FFFFF7F7" Offset="0.2"/>
</LinearGradientBrush>
</Label.Background>
</Label>
<!-- end of label -->

<!--table for students-->
<DataGrid EnableRowVirtualization="False" CanUserAddRows="False" AutoGenerateColumns="False" x:Name="studentsTable" Margin="49,43,49,82" SelectedItem="{Binding SelectedStudent, UpdateSourceTrigger=PropertyChanged}">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="Name" Binding="{Binding Name}"/>
<DataGridTextColumn IsReadOnly="True" Header="LastName" Binding="{Binding LastName}"/>
<DataGridTextColumn IsReadOnly="True" Header="Email" Binding="{Binding Email}"/>
<DataGridTextColumn IsReadOnly="True" Header="Phone number" Binding="{Binding PhoneNumber}"/>
<DataGridTextColumn IsReadOnly="True" Header="BirthDate" Binding="{Binding BirthDate}"/>
</DataGrid.Columns>
</DataGrid>

<StackPanel HorizontalAlignment="Center" Height="58" Margin="0,350,0,0" VerticalAlignment="Top" Width="402"/>
<Button x:Name="conifrmListBtn" Content="Confirm the list of students" HorizontalAlignment="Left" Height="39" Margin="49,350,0,0" VerticalAlignment="Top" Width="209" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="conifrmListBtn_Click"/>
<Button x:Name="disallowBtn" Content="Disallow exam taking" HorizontalAlignment="Left" Height="39" Margin="263,350,0,0" VerticalAlignment="Top" Width="178" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="disallowBtn_Click"/>


</Grid>
</Window>
31 changes: 31 additions & 0 deletions LangLang/View/ExamSlotGUI/ExamApplications.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using LangLang.Core.Controller;
using LangLang.DTO;
using System.Windows;


namespace LangLang.View.ExamSlotGUI
{
/// <summary>
/// Interaction logic for ExamApplications.xaml
/// </summary>
public partial class ExamApplications : Window
{
public StudentDTO SelectedStudent { get; set; }
public ExamApplications(AppController appController)
{
InitializeComponent();

}

private void conifrmListBtn_Click(object sender, RoutedEventArgs e)
{
// TODO: implement
}

private void disallowBtn_Click(object sender, RoutedEventArgs e)
{
// TODO: implement
}

}
}
31 changes: 21 additions & 10 deletions LangLang/View/TutorWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:LangLang"
mc:Ignorable="d"
Title="TutorWindow" Height="450" Width="600">
WindowStartupLocation="CenterScreen"
Title="TutorWindow" Height="550" Width="600"
ResizeMode="NoResize">
<TabControl>
<!--COURSE TAB-->
<TabItem Header="Courses">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="92*"/>
<ColumnDefinition Width="9*"/>
<ColumnDefinition Width="493*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="3*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

<!--label for courses table-->
<Label x:Name="coursesLbl" Content="Your courses" Grid.Row="0" HorizontalAlignment="Center" Height="24" Margin="0,10,0,0" VerticalAlignment="Top" Width="310" FontStyle="Italic" Foreground="Black" RenderTransformOrigin="0.5,0.5" FontFamily="Arial" FontWeight="Bold" HorizontalContentAlignment="Center">
<Label x:Name="coursesLbl" Content="Your courses" Grid.Row="0" HorizontalAlignment="Left" Height="24" Margin="41,10,0,0" VerticalAlignment="Top" Width="310" FontStyle="Italic" Foreground="Black" RenderTransformOrigin="0.5,0.5" FontFamily="Arial" FontWeight="Bold" HorizontalContentAlignment="Center" Grid.Column="2">
<Label.RenderTransform>
<TransformGroup>
<ScaleTransform/>
Expand All @@ -35,7 +42,7 @@
</Label>

<!--buttons for CRUD-->
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Vertical" Grid.Row="1">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Vertical" Grid.Row="1" Grid.Column="2" Margin="40,0,0,0">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<Button Name="courseCreateWindowBtn" Content="Create course" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="CourseCreateWindowBtn_Click" />
<Button Click="CourseDeleteBtn_Click" x:Name="courseDeleteBtn" Content="Delete course" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" />
Expand All @@ -45,7 +52,7 @@
</StackPanel>

<!--table for courses-->
<DataGrid EnableRowVirtualization="False" CanUserAddRows="False" AutoGenerateColumns="False" x:Name="coursesTable" Margin="15,45,15,0" SelectedItem="{Binding SelectedCourse, UpdateSourceTrigger=PropertyChanged}" SelectionChanged="CoursesTable_SelectionChanged">
<DataGrid EnableRowVirtualization="False" CanUserAddRows="False" AutoGenerateColumns="False" x:Name="coursesTable" Margin="15,45,15,101" SelectedItem="{Binding SelectedCourse, UpdateSourceTrigger=PropertyChanged}" SelectionChanged="CoursesTable_SelectionChanged" Grid.ColumnSpan="3" Grid.RowSpan="2">
<DataGrid.Columns>
<DataGridTextColumn x:Name="idColumn" IsReadOnly="True" Header="Id" Binding="{Binding Id}"/>
<DataGridTextColumn IsReadOnly="True" Header="Language" Binding="{Binding Language}"/>
Expand All @@ -59,12 +66,12 @@
<!--end of table for courses-->
</Grid>
</TabItem>

<!--EXAM SLOTS TAB-->
<TabItem Header="Exam slots">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="3*" />
<RowDefinition Height="2*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>

Expand All @@ -91,18 +98,22 @@
<StackPanel HorizontalAlignment="Center" Grid.Row="1" VerticalAlignment="Center" Orientation="Vertical" >
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<Button Name="examSlotCreateWindowBtn" Content="Create exam" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotCreateWindowBtn_Click" />
<Button Content="Delete exam" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotDeleteBtn_Click" />
<Button Content="Update exam" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotUpdateWindowBtn_Click" />
<Button Content="Delete exam" Name = "deleteExamBtn" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotDeleteBtn_Click" />
<Button Content="Update exam" Name = "updateExamBtn" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotUpdateWindowBtn_Click" />
</StackPanel>
<Button Content="Search exams" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ExamSlotSearchBtn_Click" />
<StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Width="289">
<Button Content="Exam applications" Name = "examApplicationBtn" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ButtonSeeStudentInfo_Click" Width="140" />
<Button Content="Enter results" Name = "enterResultsBtn" Padding="5" Height="33" Margin="5" BorderBrush="White" Background="#FFFFDBDB" Foreground="#FF514141" FontFamily="Segoe UI Black" Click="ButtonEnterResults_Click" Width="129" />
</StackPanel>
</StackPanel>

<!--table for exam slots-->
<DataGrid Grid.Column="1" Margin="15,45,15,0" AutoGenerateColumns="False"
x:Name="ExamSlotsDataGrid"
ItemsSource="{Binding ExamSlots, UpdateSourceTrigger=PropertyChanged}"
SelectedItem="{Binding SelectedExamSlot, UpdateSourceTrigger=PropertyChanged}"
SelectionMode="Single" IsReadOnly="True">
SelectionMode="Single" IsReadOnly="True" SelectionChanged="ExamSlotsDataGrid_SelectionChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="Course ID" Binding="{Binding CourseId}"/>
<DataGridTextColumn Header="Max Students" Binding="{Binding MaxStudents}"/>
Expand All @@ -115,5 +126,5 @@

</TabItem>
</TabControl>

</Window>
111 changes: 59 additions & 52 deletions LangLang/View/TutorWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
using LangLang.Core.Controller;
using LangLang.Core.Model;

using LangLang.DTO;
using LangLang.View;
using LangLang.View.CourseGUI;
using LangLang.View.ExamSlotGUI;
using LangLang.Core.Observer;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Reflection;
using System.Xml.Linq;
using System.Reflection.Emit;
using System.Diagnostics;

namespace LangLang
Expand Down Expand Up @@ -51,17 +35,20 @@ public TutorWindow(AppController appController, Profile currentlyLoggedIn)
this.tutor = appController.TutorController.GetAllTutors()[currentlyLoggedIn.Id];
InitializeComponent();
DataContext = this;
courseDeleteBtn.IsEnabled = false;
courseUpdateBtn.IsEnabled = false;

this.appController = appController;
examSlotsController = appController.ExamSlotController;
coursesController = appController.CourseController;

ExamSlots = new ObservableCollection<ExamSlotDTO>();
Courses = new ObservableCollection<CourseDTO>();


disableButtonsES();
disableButtonsCourse();

coursesController.Subscribe(this);
examSlotsController.Subscribe(this);

Update();
}

Expand All @@ -83,47 +70,14 @@ public void Update()

private void ExamSlotCreateWindowBtn_Click(object sender, RoutedEventArgs e)
{
//fix to courses by tutor
Trace.WriteLine("U tutorwindow " + coursesController.GetAllCourses().Count);

ExamSlotCreateWindow examSlotCreateWindow = new ExamSlotCreateWindow(coursesController.GetCoursesByTutor(tutor), examSlotsController);
examSlotCreateWindow.Show();
}

private void ExamSlotUpdateWindowBtn_Click(object sender, RoutedEventArgs e)
{

if (SelectedExamSlot == null)
{
MessageBox.Show("No exam slot selected. Please select an exam slot.");
}
else
{

ExamSlotUpdateWindow examSlotUpdateWindow = new ExamSlotUpdateWindow(SelectedExamSlot, coursesController.GetCoursesByTutor(tutor), examSlotsController);
examSlotUpdateWindow.Show();


}
/*
if (SelectedExamSlot == null)
{
MessageBox.Show("No exam slot selected. Please select an exam slot.");
}else
{
bool canBeUpdated = examSlotsController.Update(SelectedExamSlot.ToExamSlot());
if (!canBeUpdated)
{
MessageBox.Show("Exam can not be updated. There is less than 2 weeks left before the exam.");
}else
{
ExamSlotUpdateWindow examSlotUpdateWindow = new ExamSlotUpdateWindow(SelectedExamSlot, coursesController.GetAllCourses(), examSlotsController);
examSlotUpdateWindow.Show();
}
}
*/

}

private void CourseCreateWindowBtn_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -191,6 +145,21 @@ private void CoursesTable_SelectionChanged(object sender, SelectionChangedEventA
}
}

private void disableButtonsCourse()
{
courseUpdateBtn.IsEnabled = false;
courseDeleteBtn.IsEnabled = false;
}
private void enableButtonsCourse()
{
if (SelectedCourse == null) {
disableButtonsCourse();
} else
{
enableButtonsCourse();
}
}

private void disableButtonsCourse()

Check failure on line 163 in LangLang/View/TutorWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Type 'TutorWindow' already defines a member called 'disableButtonsCourse' with the same parameter types

Check failure on line 163 in LangLang/View/TutorWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Type 'TutorWindow' already defines a member called 'disableButtonsCourse' with the same parameter types
{
courseUpdateBtn.IsEnabled = false;
Expand All @@ -207,5 +176,43 @@ private void ExamSlotSearchBtn_Click(object sender, RoutedEventArgs e)
ExamSlotSearchWindow examSlotSearchWindow = new ExamSlotSearchWindow(coursesController, examSlotsController, tutor.Id);
examSlotSearchWindow.Show();
}

private void disableButtonsES()
{
deleteExamBtn.IsEnabled = false;
updateExamBtn.IsEnabled = false;
examApplicationBtn.IsEnabled = false;
enterResultsBtn.IsEnabled = false;
}

private void enableButtonsES()
{
deleteExamBtn.IsEnabled = true;
updateExamBtn.IsEnabled = true;
examApplicationBtn.IsEnabled = true;
enterResultsBtn.IsEnabled = true;
}

private void ButtonSeeStudentInfo_Click(object sender, RoutedEventArgs e)
{
ExamApplications applicationsWindow = new ExamApplications(appController);
applicationsWindow.Show();
}

private void ButtonEnterResults_Click(object sender, RoutedEventArgs e)
{
// TODO: implement
}

private void ExamSlotsDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (SelectedExamSlot == null) // when the DataGrid listener is triggered, check if there is a selection, and based on that, decide whether to enable or disable the buttons
{
disableButtonsES();
} else {
enableButtonsES();
}
}

}
}

0 comments on commit b0d9f7e

Please sign in to comment.