فهرست منبع

Переделочка v2

Imagara 2 سال پیش
والد
کامیت
385835f8fb

+ 5 - 2
MyTests/EDM.edmx

@@ -31,6 +31,7 @@
           <Property Name="IdUser" Type="int" Nullable="false" />
           <Property Name="Name" Type="nvarchar" MaxLength="150" Nullable="false" />
           <Property Name="Image" Type="varbinary(max)" />
+          <Property Name="IsAnswersVisible" Type="bit" Nullable="false" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
@@ -42,7 +43,7 @@
           <Property Name="Email" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="Info" Type="nvarchar" MaxLength="50" />
           <Property Name="Image" Type="varbinary(max)" />
-          <Property Name="Post" Type="nvarchar" MaxLength="10" />
+          <Property Name="Post" Type="nvarchar" MaxLength="25" />
         </EntityType>
         <Association Name="FK_Answers_Questions">
           <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
@@ -150,6 +151,7 @@
           <Property Name="Image" Type="Binary" MaxLength="Max" FixedLength="false" />
           <NavigationProperty Name="Questions" Relationship="Self.FK_Questions_Tests" FromRole="Tests" ToRole="Questions" />
           <NavigationProperty Name="Users" Relationship="Self.FK_Tests_Users" FromRole="Tests" ToRole="Users" />
+          <Property Name="IsAnswersVisible" Type="Boolean" Nullable="false" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
@@ -163,7 +165,7 @@
           <Property Name="Image" Type="Binary" MaxLength="Max" FixedLength="false" />
           <NavigationProperty Name="Answers" Relationship="Self.FK_Answers_Users" FromRole="Users" ToRole="Answers" />
           <NavigationProperty Name="Tests" Relationship="Self.FK_Tests_Users" FromRole="Users" ToRole="Tests" />
-          <Property Name="Post" Type="String" MaxLength="10" FixedLength="false" Unicode="true" />
+          <Property Name="Post" Type="String" MaxLength="25" FixedLength="false" Unicode="true" />
         </EntityType>
         <Association Name="FK_Answers_Questions">
           <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
@@ -264,6 +266,7 @@
           <EntitySetMapping Name="Tests">
             <EntityTypeMapping TypeName="MyTestsDataBaseModel.Tests">
               <MappingFragment StoreEntitySet="Tests">
+                <ScalarProperty Name="IsAnswersVisible" ColumnName="IsAnswersVisible" />
                 <ScalarProperty Name="IdTest" ColumnName="IdTest" />
                 <ScalarProperty Name="IdUser" ColumnName="IdUser" />
                 <ScalarProperty Name="Name" ColumnName="Name" />

+ 11 - 2
MyTests/MainWindow.xaml

@@ -19,9 +19,18 @@
                 MouseDown="Border_MouseDown" 
                 Grid.Row="0">
             <Grid HorizontalAlignment="Stretch">
-                <Label Content="MyTests"
+                <StackPanel Orientation="Horizontal"
+                            Margin="10,0,0,0">
+                    <Image Width="17"
+                           Height="17"
+                           Source="Resources/Ico.png">
+                    </Image>
+
+                    <Label Content="MyTests"
                        Foreground="Gray"
-                       FontWeight="SemiBold"/>
+                       FontWeight="Bold"/>
+                </StackPanel>
+                
 
                 <StackPanel HorizontalAlignment="Right"
                             Orientation="Horizontal">

+ 1 - 0
MyTests/MyTests.csproj

@@ -236,6 +236,7 @@
       <LastGenOutput>EDM.cs</LastGenOutput>
     </Content>
     <Resource Include="Resources\Approval.png" />
+    <Resource Include="Resources\Ico.png" />
     <Resource Include="Resources\Search.png" />
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

+ 3 - 3
MyTests/Pages/CurTestPage.xaml

@@ -5,8 +5,8 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:MyTests.Pages"
       mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Title="CurTestPage"
+      d:DesignHeight="450" 
+      d:DesignWidth="676"
       Background="{StaticResource color1}">
 
     <Grid Margin="20" 
@@ -16,7 +16,7 @@
             <RowDefinition Height="89*"/>
         </Grid.RowDefinitions>
         <TextBlock Name="QuestionBox"
-                   Text="Тут типа вопрос"
+                   Text="Вопрос?"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    FontSize="40"

+ 3 - 0
MyTests/Pages/LoginPage.xaml.cs

@@ -33,7 +33,10 @@ namespace MyTests.Pages
         private void LogButton_Click(object sender, RoutedEventArgs e)
         {
             if (Test)
+            {
+                Session.User = cnt.db.Users.Where(item => item.IdUser == 1).FirstOrDefault();
                 NavigationService.Navigate(new Pages.MainPage());
+            }
             else
             {
                 try

+ 2 - 0
MyTests/Pages/MainPage.xaml.cs

@@ -23,6 +23,8 @@ namespace MyTests.Pages
         public MainPage()
         {
             InitializeComponent();
+            if (Session.User.Post != "Преподаватель")
+                CreateTest.Visibility = Visibility.Collapsed;
         }
         private void ProfileClick(object sender, RoutedEventArgs e)
         {

+ 7 - 6
MyTests/Pages/ProfilePage.xaml

@@ -6,7 +6,7 @@
       xmlns:local="clr-namespace:MyTests.Pages"
       mc:Ignorable="d" 
       d:DesignHeight="450" 
-      d:DesignWidth="800"
+      d:DesignWidth="676"
       Title="PartInfoPage"
       Background="{StaticResource color1}">
 
@@ -100,9 +100,9 @@
                             Background="{StaticResource color2}"
                             MouseDown="TestsListBox_Selected">
                         <StackPanel Orientation="Horizontal">
-                            <Image Width="35"
-                               Height="35"
-                               Margin="5"
+                            <Image Width="30"
+                               Height="30"
+                               Margin="10,5,5,5"
                                HorizontalAlignment="Left"
                                Source="/MyTests;component/Resources/approval.png">
                             </Image>
@@ -122,12 +122,13 @@
             </ListBox.ItemTemplate>
         </ListBox>
 
-        <Button Grid.Row="2"
+        <Button Name="SaveButton"
+                Grid.Row="2"
                 Width="120"
                 Margin="5,0,5,0"
                 Content="Сохранить"
                 FontSize="20"
-                Click="SaveButton">
+                Click="SaveButton_Click">
         </Button>
     </Grid>
 </Page>

+ 6 - 7
MyTests/Pages/ProfilePage.xaml.cs

@@ -27,8 +27,12 @@ namespace MyTests.Pages
                 {
                     EmailBox.IsEnabled = false;
                     InfoBox.IsEnabled = false;
+                    SaveButton.Visibility = Visibility.Collapsed;
                 }
-                TestsLoading();
+                if(user.Post == "Преподаватель")
+                    TestsLoading();
+                else
+                    TestsListBox.Visibility = Visibility.Collapsed;
             }
         }
         private void EditImage_Click(object sender, RoutedEventArgs e)
@@ -50,7 +54,7 @@ namespace MyTests.Pages
             TestsListBox.ItemsSource = cnt.db.Tests.Where(item => item.IdUser == user.IdUser).ToList();
         }
 
-        private void SaveButton(object sender, RoutedEventArgs e)
+        private void SaveButton_Click(object sender, RoutedEventArgs e)
         {
             if (!Functions.IsValidEmail(EmailBox.Text))
                 new ErrorWindow("Email введен неверно.").Show();
@@ -65,11 +69,6 @@ namespace MyTests.Pages
             }
             
         }
-
-        private void BackButton(object sender, RoutedEventArgs e)
-        {
-
-        }
         private void TestsListBox_Selected(object sender, RoutedEventArgs e)
         {
             try

+ 11 - 9
MyTests/Pages/ResultTestPage.xaml

@@ -5,8 +5,8 @@
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:MyTests.Pages"
       mc:Ignorable="d" 
-      d:DesignHeight="450" d:DesignWidth="800"
-      Title="ResultTestPage"
+      d:DesignHeight="450" 
+      d:DesignWidth="676"
       Background="{StaticResource color1}">
 
     <Grid Margin="20" 
@@ -25,7 +25,7 @@
                 <Run Text="Ваш результат"/>
             </TextBlock>
             <TextBlock Name="ResultTB"
-                       Text="0/20"
+                       Text="0/0"
                        FontSize="50"
                        HorizontalAlignment="Center">
             </TextBlock>
@@ -36,17 +36,19 @@
                     VerticalAlignment="Center"
                     HorizontalAlignment="Center"
                     Height="40">
-            <Button Content="Посмотреть мои ответы"
+            <Button Name="CheckAnswersButton"
+                    Content="Посмотреть мои ответы"
                     Width="150"
-                    Margin="0,0,10,0"
-                    Click="AnswersButton_Click"/>
-            <Button Content="Профиль автора"
+                    Margin="10,0,10,0"
+                    Click="AnswersButton_Click"
+                    Visibility="Collapsed"/>
+            <Button Content="Профиль преподавателя"
                     Width="150"
                     Margin="10,0,10,0"
                     Click="ProfileButton_Click"/>
-            <Button Content="К тестам"
+            <Button Content="В главное меню"
                     Width="150"
-                    Margin="10,0,0,0"
+                    Margin="10,0,10,0"
                     Click="ExitButton_Click"/>
         </StackPanel>
     </Grid>

+ 3 - 1
MyTests/Pages/ResultTestPage.xaml.cs

@@ -10,6 +10,8 @@ namespace MyTests.Pages
         public ResultTestPage()
         {
             InitializeComponent();
+            if (Session.OpenedTest.IsAnswersVisible == true)
+                CheckAnswersButton.Visibility = Visibility.Visible;
             ResultTB.Text = $"{Session.Points}/{Session.OpenedTest.Questions.Count}";
         }
 
@@ -24,7 +26,7 @@ namespace MyTests.Pages
         }
         private void ProfileButton_Click(object sender, RoutedEventArgs e)
         {
-            NavigationService.Navigate(new Pages.ProfilePage( cnt.db.Users.Where(item => item.IdUser == Session.OpenedTest.IdUser).FirstOrDefault()));
+            NavigationService.Navigate(new Pages.ProfilePage(cnt.db.Users.Where(item => item.IdUser == Session.OpenedTest.IdUser).FirstOrDefault()));
         }
     }
 }

+ 7 - 5
MyTests/Pages/TestsCatalog.xaml

@@ -18,11 +18,13 @@
                 Margin="5">
             <StackPanel Orientation="Horizontal"
                         HorizontalAlignment="Center">
-                <Button Height="45"
+                <Button Name="AddTestButton"
+                        Height="45"
                         Width="45"
                         Content="+"
                         FontSize="30"
-                        Click="AddTest_Click">
+                        Click="AddTest_Click"
+                        Visibility="Collapsed">
                 </Button>
                 <StackPanel Orientation="Horizontal"
                             Grid.Row="0"
@@ -62,9 +64,9 @@
                             Background="{StaticResource color2}"
                             MouseDown="TestsListBox_Selected">
                         <StackPanel Orientation="Horizontal">
-                            <Image Width="35"
-                               Height="35"
-                               Margin="5"
+                            <Image Width="30"
+                               Height="30"
+                               Margin="10,5,5,5"
                                HorizontalAlignment="Left"
                                Source="/MyTests;component/Resources/approval.png">
                             </Image>

+ 4 - 2
MyTests/Pages/TestsCatalog.xaml.cs

@@ -21,6 +21,8 @@ namespace MyTests.Pages
         {
             InitializeComponent();
             TestsListBox.Items.Clear();
+            if (Session.User.Post == "Преподаватель")
+                AddTestButton.Visibility = Visibility.Visible;
             LoadingTests();
         }
 
@@ -32,9 +34,9 @@ namespace MyTests.Pages
         {            
             var list = cnt.db.Tests.ToList();
             if (TestNameBox.Text != "Название теста")
-                list = list.Where(item => item.Name == TestNameBox.Text).ToList();
+                list = list.Where(item => item.Name.StartsWith(TestNameBox.Text)).ToList();
             if (AuthorTestBox.Text != "Автор")
-                list = list.Where(item => item.Users.Login == AuthorTestBox.Text).ToList();
+                list = list.Where(item => item.Users.Login.StartsWith(AuthorTestBox.Text)).ToList();
             TestsListBox.ItemsSource = list;
         }
 

BIN
MyTests/Resources/Ico.png


BIN
MyTests/Resources/approval.png


+ 1 - 0
MyTests/Tests.cs

@@ -24,6 +24,7 @@ namespace MyTests
         public int IdUser { get; set; }
         public string Name { get; set; }
         public byte[] Image { get; set; }
+        public bool IsAnswersVisible { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Questions> Questions { get; set; }

+ 1 - 0
MyTests/Users.cs

@@ -27,6 +27,7 @@ namespace MyTests
         public string Email { get; set; }
         public string Info { get; set; }
         public byte[] Image { get; set; }
+        public string Post { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Answers> Answers { get; set; }