ы ы 2 年 前
コミット
5a0c7781ae

+ 25 - 0
AlenaTest.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.1.32228.430
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AlenaTest", "AlenaTest\AlenaTest.csproj", "{E6DF3D86-7DBE-4218-AE2F-55146CEC3A65}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{E6DF3D86-7DBE-4218-AE2F-55146CEC3A65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{E6DF3D86-7DBE-4218-AE2F-55146CEC3A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{E6DF3D86-7DBE-4218-AE2F-55146CEC3A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{E6DF3D86-7DBE-4218-AE2F-55146CEC3A65}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {17F0D30B-82E3-4BB4-83A6-38559B795930}
+	EndGlobalSection
+EndGlobal

+ 18 - 0
AlenaTest/AlenaTest.csproj

@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net5.0-windows</TargetFramework>
+    <Nullable>enable</Nullable>
+    <UseWPF>true</UseWPF>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Remove="Images\PIC.png" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <Resource Include="Images\PIC.png" />
+  </ItemGroup>
+
+</Project>

+ 16 - 0
AlenaTest/App.xaml

@@ -0,0 +1,16 @@
+<Application x:Class="AlenaTest.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:AlenaTest"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+        <Style TargetType="TextBlock">
+            <Setter Property="FontFamily" Value="Comic Sans MS"></Setter>
+            <Setter Property="FontSize" Value="14"></Setter>
+        </Style>
+        <Style TargetType="Button">
+            <Setter Property="Background" Value="#ffe0e3"></Setter>
+        </Style>
+
+    </Application.Resources>
+</Application>

+ 17 - 0
AlenaTest/App.xaml.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace AlenaTest
+{
+    /// <summary>
+    /// Interaction logic for App.xaml
+    /// </summary>
+    public partial class App : Application
+    {
+    }
+}

+ 10 - 0
AlenaTest/AssemblyInfo.cs

@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+                                     //(used if a resource is not found in the page,
+                                     // or application resource dictionaries)
+    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+                                              //(used if a resource is not found in the page,
+                                              // app, or any theme specific resource dictionaries)
+)]

+ 14 - 0
AlenaTest/FrameClass.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+
+namespace AlenaTest
+{
+    public static class FrameClass
+    {
+        public static Frame frame = new Frame();
+    }
+}

BIN
AlenaTest/Images/PIC.png


+ 12 - 0
AlenaTest/MainWindow.xaml

@@ -0,0 +1,12 @@
+<Window x:Class="AlenaTest.MainWindow"
+        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:AlenaTest"
+        mc:Ignorable="d"
+        Title="Тестирование" MinHeight="519" MinWidth="391" Width="791" Height="519">
+    <Grid>
+        <Frame NavigationUIVisibility="Hidden" Source="Pages/StartPage.xaml"/>
+    </Grid>
+</Window>

+ 28 - 0
AlenaTest/MainWindow.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace AlenaTest
+{
+    /// <summary>
+    /// Interaction logic for MainWindow.xaml
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 23 - 0
AlenaTest/Pages/StartPage.xaml

@@ -0,0 +1,23 @@
+<Page x:Class="AlenaTest.Pages.StartPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:AlenaTest.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="StartPage">
+    <!--<Page.Background>
+        <ImageBrush ImageSource="/Images/PIC.png"></ImageBrush>
+    </Page.Background>-->
+    <Grid >
+        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+            <Border BorderBrush="Black" BorderThickness="1">
+            <TextBlock FontSize="30" Background="White" Text="Профориентационное тестирование" />
+            </Border>
+            <Button Content="Начать" Click="Button_Click"/>
+           
+        </StackPanel>
+  
+    </Grid>
+</Page>

+ 33 - 0
AlenaTest/Pages/StartPage.xaml.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace AlenaTest.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для StartPage.xaml
+    /// </summary>
+    public partial class StartPage : Page
+    {
+        public StartPage()
+        {
+            InitializeComponent();
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            NavigationService.Navigate(new TestPage());
+        }
+    }
+}

+ 36 - 0
AlenaTest/Pages/TestPage.xaml

@@ -0,0 +1,36 @@
+<Page x:Class="AlenaTest.Pages.TestPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:AlenaTest.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="TestPage">
+
+    <Grid  HorizontalAlignment="Center">
+        <Grid.RowDefinitions>
+            <RowDefinition />
+            <RowDefinition Height="Auto"/>
+        </Grid.RowDefinitions>
+        <ListView Width="800" Name="list" Grid.Row="0">
+                <ListView.ItemTemplate>
+                    <DataTemplate>
+                        <StackPanel>
+                            <TextBlock Text="{Binding Title}"/>
+                            <GroupBox>
+                                <StackPanel>
+                                    <RadioButton Content="{Binding A1}" Checked="RadioButton_Checked"/>
+                                    <RadioButton Content="{Binding A2}" Checked="RadioButton_Checked"/>
+                                    <RadioButton Content="{Binding A3}" Checked="RadioButton_Checked"/>
+                                </StackPanel>
+                            </GroupBox>
+                        </StackPanel>
+                    </DataTemplate>
+                </ListView.ItemTemplate>
+            </ListView>
+        <StackPanel Grid.Row="1">
+            <Button Content="Результат" Click="Button_Click"/>
+        </StackPanel>
+    </Grid>
+</Page>

+ 202 - 0
AlenaTest/Pages/TestPage.xaml.cs

@@ -0,0 +1,202 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+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.Navigation;
+using System.Windows.Shapes;
+
+namespace AlenaTest.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для TestPage.xaml
+    /// </summary>
+    public partial class TestPage : Page
+    {
+        public int PointsCoder = 0;
+        public int PointsWeb = 0;
+        public int PointsDB = 0;
+
+        public string Path = "\\q.csv";
+
+        public class Question
+        {
+            public string Title { get; set; }
+            public string A1 { get; set; }
+            public string A2 { get; set; }
+            public string A3 { get; set; }
+            public string A1r { get; set; }
+            public string A2r { get; set; }
+            public string A3r { get; set; }
+        }
+
+        List<Question> questions = new List<Question>();
+
+        List<(string, string)> answers = new List<(string, string)>();
+        
+        public TestPage()
+        {
+            InitializeComponent();
+            var lines = File.ReadAllLines(Environment.CurrentDirectory + Path);
+
+            int j = 1;
+            var q = new Question();
+
+            for (int i = 0; i < lines.Length; i++)
+            {
+                var data = lines[i].Split(";");
+                q.Title = data[0];
+                
+
+                if (j == 1)
+                {
+                    q.A1 = data[1];
+                    q.A1r = data[2];
+                }
+                if (j == 2)
+                {
+                    q.A2 = data[1];
+                    q.A2r = data[2];
+                }
+                if (j == 3)
+                {
+                    q.A3 = data[1];
+                    q.A3r = data[2];
+
+
+                    j = 1;
+                    questions.Add(q);
+                    answers.Add((q.Title, ""));
+                    q = new Question();
+                    continue;
+                }
+
+                j++;
+
+            }
+            list.ItemsSource = questions;
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            PointsCoder = 0;
+            PointsDB = 0;
+            PointsWeb = 0;
+
+            for (int i = 0; i < answers.Count; i++)
+            {
+                if (answers[i].Item2 == "")
+                {
+                    MessageBox.Show("Не все ответы выбраны!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+                    return;
+                }
+                switch (answers[i].Item2)
+                {
+                    case "Прогер":
+                        {
+                            PointsCoder++;
+
+                        } break;
+                    case "БД":
+                        {
+                            PointsDB++;
+                        }
+                        break;
+                    case "Веб":
+                        {
+                            PointsWeb++;
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+            if (PointsCoder > PointsDB)
+            {
+                if (PointsCoder > PointsWeb)
+                {
+                    MessageBox.Show("Ваш результат - программист!", "Результат");
+                }
+                else
+                {
+                    if (PointsWeb > PointsDB)
+                    {
+                        if (PointsCoder == PointsWeb)
+                        {
+                            MessageBox.Show("Ваш результат - программист и веб-разработчик!", "Результат");
+                        }
+                        else
+                        {
+                            MessageBox.Show("Ваш результат - веб-разработчик!", "Результат");
+                        }
+                    }
+                }
+            }
+            else
+            {
+                if (PointsWeb > PointsCoder)
+                {
+                    if (PointsDB > PointsWeb)
+                    {
+                        MessageBox.Show("Ваш результат - администратор баз данных", "Результат");
+                    }
+                    else
+                    {
+                        if (PointsDB == PointsWeb)
+                        {
+                            MessageBox.Show("Ваш результат - администратор баз данных и веб-разработчик!", "Результат");
+                        }
+                        else
+                        {
+                            MessageBox.Show("Ваш результат - веб-разработчик!", "Результат");
+                        }
+                    }
+                }
+                else
+                {
+                    if (PointsDB > PointsWeb)
+                    {
+                        if (PointsCoder == PointsDB)
+                        {
+                            MessageBox.Show("Ваш результат - администратор баз данных и программист", "Результат");
+                        }
+                        else
+                        {
+                            MessageBox.Show("Ваш результат - администратор баз данных", "Результат");
+                        }
+                    }
+                }
+            }
+            if (PointsWeb == PointsCoder && PointsWeb == PointsDB && PointsDB == PointsCoder)
+            {
+                MessageBox.Show("Поздравляю! Вам подходят все виды профессий!", "Результат");
+            }
+            
+        }
+
+        private void RadioButton_Checked(object sender, RoutedEventArgs e)
+        {
+            var radio = (RadioButton)sender;
+            var q = (Question)(radio).DataContext;
+            string role = "";
+            if (q.A1 == radio.Content.ToString()) role = q.A1r;
+            if (q.A2 == radio.Content.ToString()) role = q.A2r;
+            if (q.A3 == radio.Content.ToString()) role = q.A3r;
+
+            var index = answers.FindIndex(a => a.Item1 == q.Title);
+            answers[index] = (q.Title, role);
+
+
+
+        }
+    }
+}