Imagara vor 2 Jahren
Ursprung
Commit
2aa1fe8c24

+ 1 - 1
MyTests/EDM.Designer.cs

@@ -1,4 +1,4 @@
-// Создание кода T4 для модели "C:\Users\pc\Source\Repos\StTest\MyTests\EDM.edmx" включено. 
+// Создание кода T4 для модели "C:\Users\milic\source\repos\MyTests\MyTests\EDM.edmx" включено. 
 // Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
 // на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
 // открыта в конструкторе.

+ 119 - 119
MyTests/EDM.edmx

@@ -4,123 +4,123 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-    <Schema Namespace="MyTestsDataBaseModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
-        <EntityType Name="Answers">
-          <Key>
-            <PropertyRef Name="IdUserAnswer" />
-          </Key>
-          <Property Name="IdUserAnswer" Type="int" Nullable="false" />
-          <Property Name="IdQuestion" Type="int" Nullable="false" />
-          <Property Name="IdUser" Type="int" Nullable="false" />
-          <Property Name="Answer" Type="nvarchar" MaxLength="150" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Questions">
-          <Key>
-            <PropertyRef Name="IdQuestion" />
-          </Key>
-          <Property Name="IdQuestion" Type="int" Nullable="false" />
-          <Property Name="IdTest" Type="int" Nullable="false" />
-          <Property Name="Content" Type="nvarchar" MaxLength="150" Nullable="false" />
-          <Property Name="Answer" Type="nvarchar" MaxLength="150" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Tests">
-          <Key>
-            <PropertyRef Name="IdTest" />
-          </Key>
-          <Property Name="IdTest" Type="int" Nullable="false" />
-          <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" />
-          <Property Name="IsVisible" Type="bit" Nullable="false" />
-          <Property Name="CanAgain" Type="bit" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Users">
-          <Key>
-            <PropertyRef Name="IdUser" />
-          </Key>
-          <Property Name="IdUser" Type="int" Nullable="false" />
-          <Property Name="Login" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Password" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <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="25" Nullable="false" />
-          <Property Name="Surname" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Patronymic" Type="nvarchar" MaxLength="50" Nullable="false" />
-        </EntityType>
-        <Association Name="FK_Answers_Questions">
-          <End Role="Questions" Type="Self.Questions" Multiplicity="1" />
-          <End Role="Answers" Type="Self.Answers" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Questions">
-              <PropertyRef Name="IdQuestion" />
-            </Principal>
-            <Dependent Role="Answers">
-              <PropertyRef Name="IdQuestion" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Answers_Users">
-          <End Role="Users" Type="Self.Users" Multiplicity="1" />
-          <End Role="Answers" Type="Self.Answers" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Users">
-              <PropertyRef Name="IdUser" />
-            </Principal>
-            <Dependent Role="Answers">
-              <PropertyRef Name="IdUser" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Questions_Tests">
-          <End Role="Tests" Type="Self.Tests" Multiplicity="1" />
-          <End Role="Questions" Type="Self.Questions" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Tests">
-              <PropertyRef Name="IdTest" />
-            </Principal>
-            <Dependent Role="Questions">
-              <PropertyRef Name="IdTest" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Tests_Users">
-          <End Role="Users" Type="Self.Users" Multiplicity="1" />
-          <End Role="Tests" Type="Self.Tests" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Users">
-              <PropertyRef Name="IdUser" />
-            </Principal>
-            <Dependent Role="Tests">
-              <PropertyRef Name="IdUser" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <EntityContainer Name="MyTestsDataBaseModelStoreContainer">
-          <EntitySet Name="Answers" EntityType="Self.Answers" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="Questions" EntityType="Self.Questions" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="Tests" EntityType="Self.Tests" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
-          <AssociationSet Name="FK_Answers_Questions" Association="Self.FK_Answers_Questions">
-            <End Role="Questions" EntitySet="Questions" />
-            <End Role="Answers" EntitySet="Answers" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Answers_Users" Association="Self.FK_Answers_Users">
-            <End Role="Users" EntitySet="Users" />
-            <End Role="Answers" EntitySet="Answers" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Questions_Tests" Association="Self.FK_Questions_Tests">
-            <End Role="Tests" EntitySet="Tests" />
-            <End Role="Questions" EntitySet="Questions" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Tests_Users" Association="Self.FK_Tests_Users">
-            <End Role="Users" EntitySet="Users" />
-            <End Role="Tests" EntitySet="Tests" />
-          </AssociationSet>
-        </EntityContainer>
-      </Schema></edmx:StorageModels>
+    <Schema Namespace="MyTestsDataBaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2012" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+  <EntityContainer Name="MyTestsDataBaseModelStoreContainer">
+    <EntitySet Name="Answers" EntityType="MyTestsDataBaseModel.Store.Answers" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Questions" EntityType="MyTestsDataBaseModel.Store.Questions" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Tests" EntityType="MyTestsDataBaseModel.Store.Tests" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Users" EntityType="MyTestsDataBaseModel.Store.Users" store:Type="Tables" Schema="dbo" />
+    <AssociationSet Name="FK_Answers_Questions" Association="MyTestsDataBaseModel.Store.FK_Answers_Questions">
+      <End Role="Questions" EntitySet="Questions" />
+      <End Role="Answers" EntitySet="Answers" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Answers_Users" Association="MyTestsDataBaseModel.Store.FK_Answers_Users">
+      <End Role="Users" EntitySet="Users" />
+      <End Role="Answers" EntitySet="Answers" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Questions_Tests" Association="MyTestsDataBaseModel.Store.FK_Questions_Tests">
+      <End Role="Tests" EntitySet="Tests" />
+      <End Role="Questions" EntitySet="Questions" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Tests_Users" Association="MyTestsDataBaseModel.Store.FK_Tests_Users">
+      <End Role="Users" EntitySet="Users" />
+      <End Role="Tests" EntitySet="Tests" />
+    </AssociationSet>
+  </EntityContainer>
+  <EntityType Name="Answers">
+    <Key>
+      <PropertyRef Name="IdUserAnswer" />
+    </Key>
+    <Property Name="IdUserAnswer" Type="int" Nullable="false" />
+    <Property Name="IdQuestion" Type="int" Nullable="false" />
+    <Property Name="IdUser" Type="int" Nullable="false" />
+    <Property Name="Answer" Type="nvarchar" Nullable="false" MaxLength="150" />
+  </EntityType>
+  <EntityType Name="Questions">
+    <Key>
+      <PropertyRef Name="IdQuestion" />
+    </Key>
+    <Property Name="IdQuestion" Type="int" Nullable="false" />
+    <Property Name="IdTest" Type="int" Nullable="false" />
+    <Property Name="Content" Type="nvarchar" Nullable="false" MaxLength="150" />
+    <Property Name="Answer" Type="nvarchar" Nullable="false" MaxLength="150" />
+  </EntityType>
+  <EntityType Name="Tests">
+    <Key>
+      <PropertyRef Name="IdTest" />
+    </Key>
+    <Property Name="IdTest" Type="int" Nullable="false" />
+    <Property Name="IdUser" Type="int" Nullable="false" />
+    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="150" />
+    <Property Name="Image" Type="varbinary(max)" Nullable="true" />
+    <Property Name="IsAnswersVisible" Type="bit" Nullable="false" />
+    <Property Name="IsVisible" Type="bit" Nullable="false" />
+    <Property Name="CanAgain" Type="bit" Nullable="false" />
+  </EntityType>
+  <EntityType Name="Users">
+    <Key>
+      <PropertyRef Name="IdUser" />
+    </Key>
+    <Property Name="IdUser" Type="int" Nullable="false" />
+    <Property Name="Login" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Password" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Email" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Info" Type="nvarchar" Nullable="true" MaxLength="50" />
+    <Property Name="Image" Type="varbinary(max)" Nullable="true" />
+    <Property Name="Post" Type="nvarchar" Nullable="false" MaxLength="25" />
+    <Property Name="Surname" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Patronymic" Type="nvarchar" Nullable="false" MaxLength="50" />
+  </EntityType>
+  <Association Name="FK_Answers_Questions">
+    <End Role="Questions" Type="MyTestsDataBaseModel.Store.Questions" Multiplicity="1" />
+    <End Role="Answers" Type="MyTestsDataBaseModel.Store.Answers" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Questions">
+        <PropertyRef Name="IdQuestion" />
+      </Principal>
+      <Dependent Role="Answers">
+        <PropertyRef Name="IdQuestion" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Answers_Users">
+    <End Role="Users" Type="MyTestsDataBaseModel.Store.Users" Multiplicity="1" />
+    <End Role="Answers" Type="MyTestsDataBaseModel.Store.Answers" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Users">
+        <PropertyRef Name="IdUser" />
+      </Principal>
+      <Dependent Role="Answers">
+        <PropertyRef Name="IdUser" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Questions_Tests">
+    <End Role="Tests" Type="MyTestsDataBaseModel.Store.Tests" Multiplicity="1" />
+    <End Role="Questions" Type="MyTestsDataBaseModel.Store.Questions" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Tests">
+        <PropertyRef Name="IdTest" />
+      </Principal>
+      <Dependent Role="Questions">
+        <PropertyRef Name="IdTest" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Tests_Users">
+    <End Role="Users" Type="MyTestsDataBaseModel.Store.Users" Multiplicity="1" />
+    <End Role="Tests" Type="MyTestsDataBaseModel.Store.Tests" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Users">
+        <PropertyRef Name="IdUser" />
+      </Principal>
+      <Dependent Role="Tests">
+        <PropertyRef Name="IdUser" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+</Schema></edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="MyTestsDataBaseModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
@@ -276,13 +276,13 @@
     <EntitySetMapping Name="Tests">
       <EntityTypeMapping TypeName="IsTypeOf(MyTestsDataBaseModel.Tests)">
         <MappingFragment StoreEntitySet="Tests">
-          <ScalarProperty Name="CanAgain" ColumnName="CanAgain" />
-                <ScalarProperty Name="IdTest" ColumnName="IdTest" />
+          <ScalarProperty Name="IdTest" ColumnName="IdTest" />
           <ScalarProperty Name="IdUser" ColumnName="IdUser" />
           <ScalarProperty Name="Name" ColumnName="Name" />
           <ScalarProperty Name="Image" ColumnName="Image" />
           <ScalarProperty Name="IsAnswersVisible" ColumnName="IsAnswersVisible" />
           <ScalarProperty Name="IsVisible" ColumnName="IsVisible" />
+          <ScalarProperty Name="CanAgain" ColumnName="CanAgain" />
         </MappingFragment>
       </EntityTypeMapping>
     </EntitySetMapping>

+ 4 - 1
MyTests/EDM.edmx.sql

@@ -2,8 +2,8 @@
 -- --------------------------------------------------
 -- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
 -- --------------------------------------------------
+-- Date Created: 08/12/2022 17:57:11
+-- Generated from EDMX file: C:\Users\milic\source\repos\MyTests\MyTests\EDM.edmx
 -- --------------------------------------------------
 
 SET QUOTED_IDENTIFIER OFF;
@@ -76,7 +76,8 @@ CREATE TABLE [dbo].[Tests] (
     [Name] nvarchar(150)  NOT NULL,
     [Image] varbinary(max)  NULL,
     [IsAnswersVisible] bit  NOT NULL,
-    [IsVisible] bit  NOT NULL
+    [IsVisible] bit  NOT NULL,
+    [CanAgain] bit  NOT NULL
 );
 GO
 

+ 1 - 1
MyTests/ImagesFunctions.cs

@@ -67,7 +67,7 @@ namespace MyTests
             }
             catch
             {
-                return new BitmapImage(new Uri("../Resources/StandartImage.png", UriKind.RelativeOrAbsolute));
+                return new BitmapImage(new Uri("../Resources/Approval.png", UriKind.RelativeOrAbsolute));
             }
             
         }

+ 4 - 4
MyTests/Pages/ProfilePage.xaml

@@ -101,16 +101,16 @@
                                Height="30"
                                Margin="10,5,5,5"
                                HorizontalAlignment="Left"
-                               Source="/MyTests;component/Resources/approval.png">
+                               Source="{Binding testImage}">
                                 </Image>
                                 <StackPanel>
                                     <StackPanel Orientation="Horizontal">
-                                        <Label Content="{Binding Name}"/>
-                                        <Label Content="{Binding Users.Login}"/>
+                                        <Label Content="{Binding test.Name}"/>
+                                        <Label Content="{Binding test.Users.Login}"/>
                                     </StackPanel>
                                     <TextBlock Margin="0,-7,0,0">
                                     <Run Text="Вопросов: " Foreground="White"/>
-                                    <Run Text="{Binding Questions.Count, Mode=OneTime}"/>
+                                    <Run Text="{Binding test.Questions.Count, Mode=OneTime}"/>
                                     </TextBlock>
                                 </StackPanel>
                             </StackPanel>

+ 28 - 12
MyTests/Pages/ProfilePage.xaml.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
@@ -47,10 +48,20 @@ namespace MyTests.Pages
         }
         private void TestsLoading()
         {
-            if (user != Session.User)
-                TestsListBox.ItemsSource = cdb.db.Tests.Where(item => item.IdUser == user.IdUser && item.IsVisible == true).ToList();
-            else
-                TestsListBox.ItemsSource = cdb.db.Tests.Where(item => item.IdUser == user.IdUser).ToList();
+            List<Tests> list = user != Session.User ? cdb.db.Tests.Where(item => item.IdUser == user.IdUser && item.IsVisible == true).ToList() :
+                cdb.db.Tests.Where(item => item.IdUser == user.IdUser).ToList();
+
+            List<TestsClass> testsList = new List<TestsClass>();
+
+            foreach (Tests test in list)
+            {
+                TestsClass tc = new TestsClass();
+                tc.test = test;
+                tc.testImage = test.Image == null ? new BitmapImage(new Uri("../Resources/Approval.png", UriKind.RelativeOrAbsolute)) : ImagesFunctions.NewImage(test);
+                testsList.Add(tc);
+            }
+
+            TestsListBox.ItemsSource = testsList;
         }
 
         private void SaveButton_Click(object sender, RoutedEventArgs e)
@@ -71,14 +82,14 @@ namespace MyTests.Pages
         private void CheckResultsButton_Click(object sender, RoutedEventArgs e)
         {
             Button btn = (Button)sender;
-            if (btn.DataContext is Tests)
-                NavigationService.Navigate(new Pages.CheckTestResultsCatalog((Tests)btn.DataContext));
+            if (btn.DataContext is TestsClass)
+                NavigationService.Navigate(new Pages.CheckTestResultsCatalog(((TestsClass)btn.DataContext).test));
         }
         private void EditTestButton_Click(object sender, RoutedEventArgs e)
         {
             Button btn = (Button)sender;
-            if (btn.DataContext is Tests)
-                NavigationService.Navigate(new Pages.EditTestPage((Tests)btn.DataContext));
+            if (btn.DataContext is TestsClass)
+                NavigationService.Navigate(new Pages.EditTestPage(((TestsClass)btn.DataContext).test));
         }
 
         private void TestsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -105,21 +116,26 @@ namespace MyTests.Pages
         private void DeleteTestButton_Click(object sender, RoutedEventArgs e)
         {
             Button btn = (Button)sender;
-            if (btn.DataContext is Tests)
+            if (btn.DataContext is TestsClass)
             {
                 ConfirmationWindow confWindow = new ConfirmationWindow();
                 confWindow.ShowDialog();
                 if (confWindow.answer)
                 {
-                    foreach (Answers answer in cdb.db.Answers.Where(item => item.Questions.IdTest == ((Tests)btn.DataContext).IdTest))
+                    foreach (Answers answer in cdb.db.Answers.Where(item => item.Questions.IdTest == ((TestsClass)btn.DataContext).test.IdTest))
                         cdb.db.Answers.Remove(answer);
-                    foreach (Questions question in cdb.db.Questions.Where(item => item.IdTest == ((Tests)btn.DataContext).IdTest))
+                    foreach (Questions question in cdb.db.Questions.Where(item => item.IdTest == ((TestsClass)btn.DataContext).test.IdTest))
                         cdb.db.Questions.Remove(question);
-                    cdb.db.Tests.Remove((Tests)btn.DataContext);
+                    cdb.db.Tests.Remove(((TestsClass)btn.DataContext).test);
                     cdb.db.SaveChanges();
                     TestsLoading();
                 }
             }
         }
+        public class TestsClass
+        {
+            public Tests test { get; set; }
+            public BitmapImage testImage { get; set; }
+        }
     }
 }

+ 3 - 3
MyTests/Pages/RegistrationPage.xaml

@@ -15,7 +15,7 @@
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition/>
-            <RowDefinition Height="20*"/>
+            <RowDefinition Height="90*"/>
             <RowDefinition/>
         </Grid.RowDefinitions>
         <Border Grid.Row="1" 
@@ -76,13 +76,13 @@
                                  FontSize="20"/>
                 <StackPanel Orientation="Horizontal"
                                 Margin="0,20,0,0">
-                    <Button Content="Регистрация"
+                    <Button Content="Назад"
                                 Height="40" 
                                 Width="150" 
                                 Margin="0,0,30,0"
                                 FontSize="20"
                                 Click="BackButton_Click"/>
-                    <Button Content="Вход"
+                    <Button Content="Регистрация"
                                 Height="40" 
                                 Width="150"
                                 FontSize="20"

+ 1 - 1
MyTests/Pages/RegistrationPage.xaml.cs

@@ -38,7 +38,7 @@ namespace MyTests.Pages
                         Login = LogBox.Text,
                         Password = Functions.EncryptPassword(PassBox.Password),
                         Email = EmailBox.Text,
-                        Post = "Пользователь",
+                        Post = cdb.db.Users.Count() == 0 ? "Преподаватель" : "Пользователь",
                         Surname = fio[0],
                         Name = fio[1],
                         Patronymic = fio[2]

+ 4 - 4
MyTests/Pages/TestsCatalog.xaml

@@ -77,16 +77,16 @@
                                Height="30"
                                Margin="10,5,5,5"
                                HorizontalAlignment="Left"
-                               Source="/MyTests;component/Resources/approval.png">
+                               Source="{Binding testImage}">
                             </Image>
                             <StackPanel>
                                 <StackPanel Orientation="Horizontal">
-                                    <Label Content="{Binding Name}"/>
-                                    <Label Content="{Binding Users.Login}"/>
+                                    <Label Content="{Binding test.Name}"/>
+                                    <Label Content="{Binding test.Users.Login}"/>
                                 </StackPanel>
                                 <TextBlock Margin="0,-6,0,0">
                                     <Run Text="Вопросов: " Foreground="White"/>
-                                    <Run Text="{Binding Questions.Count, Mode=OneTime}" />
+                                    <Run Text="{Binding test.Questions.Count, Mode=OneTime}" />
                                 </TextBlock>
                             </StackPanel>
                         </StackPanel>

+ 24 - 5
MyTests/Pages/TestsCatalog.xaml.cs

@@ -4,6 +4,7 @@ using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Input;
+using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 
 namespace MyTests.Pages
@@ -30,10 +31,22 @@ namespace MyTests.Pages
                 list = list.Where(item => item.Name.StartsWith(TestNameBox.Text)).ToList();
 
             if (AuthorTestBox.Text != "Преподаватель")
-                list = list.Where(item => item.Users.Surname.StartsWith(AuthorTestBox.Text) 
-                || item.Users.Name.StartsWith(AuthorTestBox.Text) 
+                list = list.Where(item => item.Users.Surname.StartsWith(AuthorTestBox.Text)
+                || item.Users.Name.StartsWith(AuthorTestBox.Text)
                 || item.Users.Patronymic.StartsWith(AuthorTestBox.Text)).ToList();
-            TestsListBox.ItemsSource = list;
+
+            List<TestsClass> testsList = new List<TestsClass>();
+
+            foreach (Tests test in list)
+            {
+                TestsClass tc = new TestsClass();
+                tc.test = test;
+                tc.testImage = test.Image == null ? new BitmapImage(new Uri("../Resources/Approval.png", UriKind.RelativeOrAbsolute)) : ImagesFunctions.NewImage(test);
+                testsList.Add(tc);
+            }
+
+            TestsListBox.ItemsSource = testsList;
+
         }
 
         private void FindTests_Click(object sender, RoutedEventArgs e)
@@ -71,7 +84,7 @@ namespace MyTests.Pages
                 {
                     Tests thisTest = cdb.db.Tests.Where(item => item.IdTest == ((Tests)TestsListBox.SelectedItem).IdTest).FirstOrDefault();
 
-                    if ((!thisTest.CanAgain && cdb.db.Answers.Where(item => item.Questions.Tests.IdTest == thisTest.IdTest).Select(item => item.IdUser).Contains(Session.User.IdUser)) && Session.User.IdUser != thisTest.IdUser) //true - может пройти снова
+                    if (!thisTest.CanAgain && cdb.db.Answers.Where(item => item.Questions.Tests.IdTest == thisTest.IdTest).Select(item => item.IdUser).Contains(Session.User.IdUser) && Session.User.IdUser != thisTest.IdUser)
                         new ErrorWindow("Этот тест не может быть пройден повторно.").ShowDialog();
                     else
                     {
@@ -81,7 +94,7 @@ namespace MyTests.Pages
                         Session.Quest.Content = cdb.db.Questions.Where(item => item.IdTest == Session.OpenedTest.IdTest).Select(item => item.Content).ToArray();
                         Session.Quest.Answer = cdb.db.Questions.Where(item => item.IdTest == Session.OpenedTest.IdTest).Select(item => item.Answer).ToArray();
                         NavigationService.Navigate(new Pages.CurTestPage());
-                    }   
+                    }
                 }
             }
             catch
@@ -89,6 +102,12 @@ namespace MyTests.Pages
                 new ErrorWindow("Ошибка открытия теста.").ShowDialog();
             }
         }
+
+        public class TestsClass
+        {
+            public Tests test { get; set; }
+            public BitmapImage testImage { get; set; }
+        }
     }
 }
 

+ 13 - 0
UnitTestProject/UnitTest1.cs

@@ -1,5 +1,8 @@
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using MyTests;
+using MyTests.Pages;
+using System.Linq;
+
 namespace UnitTestProject
 {
     [TestClass]
@@ -66,5 +69,15 @@ namespace UnitTestProject
             Assert.IsFalse(Functions.IsValidLength("Вф"));
             Assert.IsFalse(Functions.IsValidLength(""));
         }
+        public void CorrectAnswersCounterTest()
+        {
+            int testId = 1;
+            int userId = 1;
+            int expected = 1;
+            
+            Assert.AreEqual(new CheckTestResultsCatalog(null).CorrectAnswersCounter(cdb.db.Tests.Where(item => item.IdTest == testId).FirstOrDefault(),
+                cdb.db.Users.Where(item => item.IdUser == userId).FirstOrDefault()),
+                expected); 
+        }
     }
 }

+ 3 - 0
UnitTestProject/UnitTestProject.csproj

@@ -51,9 +51,12 @@
     <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
     </Reference>
+    <Reference Include="PresentationCore" />
+    <Reference Include="PresentationFramework" />
     <Reference Include="System" />
     <Reference Include="System.ComponentModel.DataAnnotations" />
     <Reference Include="System.Core" />
+    <Reference Include="WindowsBase" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="UnitTest1.cs" />