From cb35117da13e69e1adaf2e7528436c6e1e4bb887 Mon Sep 17 00:00:00 2001 From: Nikitosiki Date: Mon, 8 May 2023 20:49:16 +0300 Subject: [PATCH] Added certificate page for teacher, now teacher can issue certificates. --- .../DataBaseStructure/types/GenderType.cs | 1 + ...Component_AnswerTaskForTeacher.Designer.cs | 1 + .../Component_RowUserCertificate.Designer.cs | 338 ++++++++++++++++++ .../Component_RowUserCertificate.cs | 181 ++++++++++ .../Component_RowUserCertificate.resx | 60 ++++ ...ainBlock_CertificateForTeacher.Designer.cs | 178 +++++++++ .../PanelMainBlock_CertificateForTeacher.cs | 118 ++++++ .../PanelMainBlock_CertificateForTeacher.resx | 60 ++++ .../TeacherButtonEvents.cs | 13 +- .../MainBlock/Navbar/PanelMainBlock_Navbar.cs | 4 +- ...PanelMainBlock_TasksForStudent.Designer.cs | 116 +++--- .../Tasks/PanelMainBlock_TasksForStudent.resx | 3 - SkillCourse/SkillCourse.csproj | 6 + SkillCourse/handlers/StudentHandler.cs | 6 +- SkillCourse/handlers/TeatherHandler.cs | 55 ++- SkillCourse/handlers/UserHandler.cs | 17 +- SkillCourse/helperConfig/UserTextSize.cs | 5 + 17 files changed, 1079 insertions(+), 83 deletions(-) create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.Designer.cs create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.cs create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.resx create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.Designer.cs create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.cs create mode 100644 SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.resx diff --git a/SkillCourse/DataBaseStructure/types/GenderType.cs b/SkillCourse/DataBaseStructure/types/GenderType.cs index 28ed241..cbbaf6c 100644 --- a/SkillCourse/DataBaseStructure/types/GenderType.cs +++ b/SkillCourse/DataBaseStructure/types/GenderType.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; diff --git a/SkillCourse/PanelComponents/CoursePage/Component_AnswerTaskForTeacher.Designer.cs b/SkillCourse/PanelComponents/CoursePage/Component_AnswerTaskForTeacher.Designer.cs index 3fecbf1..6716875 100644 --- a/SkillCourse/PanelComponents/CoursePage/Component_AnswerTaskForTeacher.Designer.cs +++ b/SkillCourse/PanelComponents/CoursePage/Component_AnswerTaskForTeacher.Designer.cs @@ -232,6 +232,7 @@ private void InitializeComponent() component_Grade.Grade = 0; component_Grade.Location = new Point(61, 51); component_Grade.Margin = new Padding(0); + component_Grade.MinimumSize = new Size(63, 42); component_Grade.Name = "component_Grade"; component_Grade.Size = new Size(63, 42); component_Grade.TabIndex = 0; diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.Designer.cs b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.Designer.cs new file mode 100644 index 0000000..ee6fcf2 --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.Designer.cs @@ -0,0 +1,338 @@ +namespace SkillCourse.Panels.MainBlock.CertificatePage +{ + partial class Component_RowUserCertificate + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + panel7 = new Panel(); + panel10 = new Panel(); + tableLayoutPanel2 = new TableLayoutPanel(); + label7 = new Label(); + panel1 = new Panel(); + panel2 = new Panel(); + tableLayoutPanel3 = new TableLayoutPanel(); + labelStudName = new Label(); + panelText = new Panel(); + tableLayoutPanel4 = new TableLayoutPanel(); + labelText = new Label(); + panelIndex = new Panel(); + labelId = new Label(); + tableLayoutPanel1 = new TableLayoutPanel(); + labelStatus = new Label(); + panelButIssue = new Panel(); + newButtonIssue = new yt_DesignUI.NewButton(); + panel1.SuspendLayout(); + panel2.SuspendLayout(); + tableLayoutPanel3.SuspendLayout(); + panelText.SuspendLayout(); + tableLayoutPanel4.SuspendLayout(); + panelIndex.SuspendLayout(); + tableLayoutPanel1.SuspendLayout(); + panelButIssue.SuspendLayout(); + SuspendLayout(); + // + // panel7 + // + panel7.Location = new Point(0, 0); + panel7.Name = "panel7"; + panel7.Size = new Size(200, 100); + panel7.TabIndex = 0; + // + // panel10 + // + panel10.Location = new Point(0, 0); + panel10.Name = "panel10"; + panel10.Size = new Size(200, 100); + panel10.TabIndex = 0; + // + // tableLayoutPanel2 + // + tableLayoutPanel2.ColumnCount = 3; + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle()); + tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel2.Dock = DockStyle.Fill; + tableLayoutPanel2.Location = new Point(0, 0); + tableLayoutPanel2.Name = "tableLayoutPanel2"; + tableLayoutPanel2.RowCount = 3; + tableLayoutPanel2.Size = new Size(200, 100); + tableLayoutPanel2.TabIndex = 0; + // + // label7 + // + label7.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); + label7.ForeColor = SystemColors.Control; + label7.Location = new Point(70, 0); + label7.Name = "label7"; + label7.Size = new Size(59, 31); + label7.TabIndex = 5; + label7.Text = "0 / 5"; + label7.TextAlign = ContentAlignment.MiddleCenter; + // + // panel1 + // + panel1.AutoSize = true; + panel1.Controls.Add(panel2); + panel1.Controls.Add(panelIndex); + panel1.Controls.Add(tableLayoutPanel1); + panel1.Dock = DockStyle.Fill; + panel1.Location = new Point(0, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(1157, 145); + panel1.TabIndex = 3; + // + // panel2 + // + panel2.AutoSize = true; + panel2.Controls.Add(tableLayoutPanel3); + panel2.Dock = DockStyle.Fill; + panel2.Location = new Point(83, 0); + panel2.Name = "panel2"; + panel2.Size = new Size(888, 145); + panel2.TabIndex = 9; + // + // tableLayoutPanel3 + // + tableLayoutPanel3.AutoSize = true; + tableLayoutPanel3.ColumnCount = 1; + tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + tableLayoutPanel3.Controls.Add(labelStudName, 0, 1); + tableLayoutPanel3.Controls.Add(panelText, 0, 2); + tableLayoutPanel3.Dock = DockStyle.Fill; + tableLayoutPanel3.Location = new Point(0, 0); + tableLayoutPanel3.Name = "tableLayoutPanel3"; + tableLayoutPanel3.RowCount = 4; + tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableLayoutPanel3.RowStyles.Add(new RowStyle()); + tableLayoutPanel3.RowStyles.Add(new RowStyle()); + tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableLayoutPanel3.Size = new Size(888, 145); + tableLayoutPanel3.TabIndex = 10; + tableLayoutPanel3.Resize += tableLayoutPanel3_Resize; + // + // labelStudName + // + labelStudName.AutoSize = true; + labelStudName.Font = new Font("Segoe UI Variable Display", 12F, FontStyle.Regular, GraphicsUnit.Point); + labelStudName.ForeColor = Color.FromArgb(142, 173, 212); + labelStudName.Location = new Point(5, 20); + labelStudName.Margin = new Padding(5, 0, 3, 0); + labelStudName.Name = "labelStudName"; + labelStudName.Padding = new Padding(21, 0, 0, 0); + labelStudName.Size = new Size(241, 27); + labelStudName.TabIndex = 9; + labelStudName.Text = "Student: Nikita Savenko"; + // + // panelText + // + panelText.Controls.Add(tableLayoutPanel4); + panelText.Dock = DockStyle.Top; + panelText.Location = new Point(3, 50); + panelText.Name = "panelText"; + panelText.Size = new Size(882, 44); + panelText.TabIndex = 10; + // + // tableLayoutPanel4 + // + tableLayoutPanel4.AutoSize = true; + tableLayoutPanel4.ColumnCount = 1; + tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + tableLayoutPanel4.Controls.Add(labelText, 0, 0); + tableLayoutPanel4.Dock = DockStyle.Top; + tableLayoutPanel4.Location = new Point(0, 0); + tableLayoutPanel4.Name = "tableLayoutPanel4"; + tableLayoutPanel4.RowCount = 1; + tableLayoutPanel4.RowStyles.Add(new RowStyle()); + tableLayoutPanel4.Size = new Size(882, 31); + tableLayoutPanel4.TabIndex = 0; + // + // labelText + // + labelText.AutoSize = true; + labelText.Dock = DockStyle.Top; + labelText.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); + labelText.ForeColor = SystemColors.Control; + labelText.Location = new Point(3, 0); + labelText.Name = "labelText"; + labelText.Padding = new Padding(18, 0, 0, 0); + labelText.Size = new Size(876, 31); + labelText.TabIndex = 10; + labelText.Text = "Course: \"fsdfsdfsd\""; + labelText.TextChanged += labelText_TextChanged; + // + // panelIndex + // + panelIndex.AutoSize = true; + panelIndex.Controls.Add(labelId); + panelIndex.Dock = DockStyle.Left; + panelIndex.Location = new Point(0, 0); + panelIndex.MinimumSize = new Size(83, 0); + panelIndex.Name = "panelIndex"; + panelIndex.Size = new Size(83, 145); + panelIndex.TabIndex = 8; + // + // labelId + // + labelId.AutoSize = true; + labelId.Dock = DockStyle.Left; + labelId.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); + labelId.ForeColor = SystemColors.Control; + labelId.Location = new Point(0, 0); + labelId.MinimumSize = new Size(83, 0); + labelId.Name = "labelId"; + labelId.Padding = new Padding(0, 29, 0, 0); + labelId.Size = new Size(83, 70); + labelId.TabIndex = 5; + labelId.Text = "●"; + labelId.TextAlign = ContentAlignment.MiddleCenter; + // + // tableLayoutPanel1 + // + tableLayoutPanel1.AutoSize = true; + tableLayoutPanel1.ColumnCount = 3; + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle()); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.Controls.Add(labelStatus, 1, 2); + tableLayoutPanel1.Controls.Add(panelButIssue, 1, 1); + tableLayoutPanel1.Dock = DockStyle.Right; + tableLayoutPanel1.Location = new Point(971, 0); + tableLayoutPanel1.MinimumSize = new Size(186, 101); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 5; + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle()); + tableLayoutPanel1.RowStyles.Add(new RowStyle()); + tableLayoutPanel1.RowStyles.Add(new RowStyle()); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableLayoutPanel1.Size = new Size(186, 145); + tableLayoutPanel1.TabIndex = 1; + // + // labelStatus + // + labelStatus.Dock = DockStyle.Fill; + labelStatus.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); + labelStatus.ForeColor = SystemColors.Control; + labelStatus.Location = new Point(34, 77); + labelStatus.Name = "labelStatus"; + labelStatus.Padding = new Padding(3, 0, 0, 0); + labelStatus.Size = new Size(118, 31); + labelStatus.TabIndex = 7; + labelStatus.Text = "Status"; + labelStatus.TextAlign = ContentAlignment.MiddleCenter; + // + // panelButIssue + // + panelButIssue.AutoSize = true; + panelButIssue.Controls.Add(newButtonIssue); + panelButIssue.Dock = DockStyle.Fill; + panelButIssue.Location = new Point(34, 39); + panelButIssue.MinimumSize = new Size(118, 31); + panelButIssue.Name = "panelButIssue"; + panelButIssue.Size = new Size(118, 35); + panelButIssue.TabIndex = 10; + panelButIssue.Visible = false; + // + // newButtonIssue + // + newButtonIssue.BackColor = Color.FromArgb(80, 175, 138); + newButtonIssue.BackColorAdditional = Color.Gray; + newButtonIssue.BackColorGradientEnabled = false; + newButtonIssue.BackColorGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Horizontal; + newButtonIssue.BorderColor = Color.FromArgb(80, 175, 138); + newButtonIssue.BorderColorEnabled = false; + newButtonIssue.BorderColorOnHover = Color.FromArgb(80, 175, 138); + newButtonIssue.BorderColorOnHoverEnabled = false; + newButtonIssue.Dock = DockStyle.Top; + newButtonIssue.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + newButtonIssue.ForeColor = SystemColors.Control; + newButtonIssue.Location = new Point(0, 0); + newButtonIssue.Name = "newButtonIssue"; + newButtonIssue.RippleColor = Color.Black; + newButtonIssue.Rounding = 20; + newButtonIssue.RoundingEnable = true; + newButtonIssue.Size = new Size(118, 35); + newButtonIssue.TabIndex = 6; + newButtonIssue.Text = "Issue"; + newButtonIssue.TextHover = null; + newButtonIssue.UseDownPressEffectOnClick = false; + newButtonIssue.UseMainGradientEffect = false; + newButtonIssue.UseRippleEffect = true; + newButtonIssue.UseVisualStyleBackColor = false; + newButtonIssue.UseZoomEffectOnHover = false; + newButtonIssue.Click += newButtonIssue_Click; + // + // Component_RowUserCertificate + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + AutoSize = true; + BackColor = Color.FromArgb(40, 49, 60); + Controls.Add(panel1); + MinimumSize = new Size(0, 101); + Name = "Component_RowUserCertificate"; + Size = new Size(1157, 145); + panel1.ResumeLayout(false); + panel1.PerformLayout(); + panel2.ResumeLayout(false); + panel2.PerformLayout(); + tableLayoutPanel3.ResumeLayout(false); + tableLayoutPanel3.PerformLayout(); + panelText.ResumeLayout(false); + panelText.PerformLayout(); + tableLayoutPanel4.ResumeLayout(false); + tableLayoutPanel4.PerformLayout(); + panelIndex.ResumeLayout(false); + panelIndex.PerformLayout(); + tableLayoutPanel1.ResumeLayout(false); + tableLayoutPanel1.PerformLayout(); + panelButIssue.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Panel panel7; + private Panel panel10; + private TableLayoutPanel tableLayoutPanel2; + private Label label7; + private Panel panel1; + private Panel panel2; + private Label labelStudName; + private Panel panelIndex; + private TableLayoutPanel tableLayoutPanel3; + private TableLayoutPanel tableLayoutPanel1; + private Label labelStatus; + private Panel panelButIssue; + private yt_DesignUI.NewButton newButtonIssue; + private Panel panelText; + private TableLayoutPanel tableLayoutPanel4; + private Label labelText; + private Label labelId; + } +} diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.cs b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.cs new file mode 100644 index 0000000..6426917 --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.cs @@ -0,0 +1,181 @@ +using CPProject.components.ui; +using SkillCourse.DataBaseStructure; +using SkillCourse.Forms; +using SkillCourse.handlers; +using SkillCourse.helperConfig; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Task = SkillCourse.DataBaseStructure.Task; + +namespace SkillCourse.Panels.MainBlock.CertificatePage +{ + public partial class Component_RowUserCertificate : UserControl + { + public Teather handler = (Teather)AccountHandler.Instance.UserLog; + public SubscriptionCourse ThisSub { get; private set; } + + public Component_RowUserCertificate(SubscriptionCourse sub, bool isWaiting) + { + InitializeComponent(); + Dock = DockStyle.Top; + ThisSub = sub; + Student stud = UserHandler.GetStudent(sub); + + labelStudName.Text = $"Student: {stud.FirstName} {stud.LastName}"; + labelText.Text = $"Course: \"{UserHandler.GetCourse(sub).Name}\""; + StateProcentBar(handler.ProcentCompleteCourse(sub)); + ReSizeDescription(); + + if (!isWaiting) tableLayoutPanel1.Hide(); + AddMouseHandlers(this); + } + + private void StateProcentBar(int procent) + { + if (procent == 100) + { + labelStatus.Visible = false; + panelButIssue.Visible = true; + } + else + labelStatus.Text = procent + "%"; + } + + + private void labelText_TextChanged(object sender, EventArgs e) + { + ReSizeDescription(); + } + + private void tableLayoutPanel3_Resize(object sender, EventArgs e) + { + ReSizeDescription(); + } + + //private void ReSizeDescription() + //{ + // System.Windows.Forms.Label thisLabel = labelText; + // System.Windows.Forms.Panel thispanel = panelText; + + // Size textSize = TextRenderer.MeasureText(thisLabel.Text, thisLabel.Font, + // new Size(thisLabel.Size.Width - thisLabel.Padding.Horizontal, thisLabel.Size.Height), + // TextFormatFlags.WordBreak); + // thispanel.Size = new System.Drawing.Size(thisLabel.Width, textSize.Height); + //} + + private void ReSizeDescription() + { + panelText.Size = new System.Drawing.Size(labelText.Width - labelText.Padding.Horizontal, labelText.Height); + } + + private void newButtonIssue_Click(object sender, EventArgs e) + { + var thisParent = this.Parent; + while (true) + { + if (thisParent.Parent == null) + break; + + thisParent = thisParent.Parent; + } + + AnswerToTask answerForm = new AnswerToTask(new Size(thisParent.ClientSize.Width, thisParent.ClientSize.Height), + String.Empty, UserTextSize.Certificate.maxLenghtDescription, false); + answerForm.LoatLocationY = ((SystemInformation.CaptionHeight) / 2); + DialogResult result = answerForm.ShowDialog(this); + + if (result == DialogResult.OK) + { + handler.AddCertificate(ThisSub.IdCourse, ThisSub.IdStudent, answerForm.Text); + + + // Говно код - не смотреть + var parentObj = this.Parent; + while (true) + { + if (parentObj == null) + break; + + if (parentObj is PanelMainBlock_CertificateForTeacher parent) + { + parent.UpdatePanel_OnSelectedIndexChanged(); + break; + } + else + parentObj = parentObj.Parent; + } + } + } + + + private void clickOnThis(object sender, EventArgs e) + { + if (UserHandler.GetUser(ThisSub.IdStudent) is User user) + NavigatePages.OpenNextPage(new PanelMainBlock_UserPage(user)); + } + + #region ThisHover + + private System.Windows.Forms.Timer hoverEventTimer = new System.Windows.Forms.Timer(); + + private bool isMouseHover = false; + private bool IsTimerHoverChecking { get; set; } = false; + public int TimerHoverDelay { get; set; } = 20; + + private void OnHoverTimerTick(object? sender, EventArgs e) + { + hoverEventTimer.Stop(); + IsTimerHoverChecking = false; + setBorderOnHover(isMouseHover); + } + + private void onHover(bool visible) + { + isMouseHover = visible; + if (!IsTimerHoverChecking) + { + hoverEventTimer.Interval = TimerHoverDelay; + hoverEventTimer.Tick += new EventHandler(OnHoverTimerTick); + hoverEventTimer.Start(); + IsTimerHoverChecking = true; + } + } + + private void setBorderOnHover(bool visible) + { + if (visible) + { + this.BackColor = Color.FromArgb(48, 58, 72); + this.Invalidate(true); + } + else + { + this.BackColor = Color.FromArgb(40, 49, 60); + this.Invalidate(true); + } + } + + private void AddMouseHandlers(Control control) + { + control.Click += new EventHandler(clickOnThis); + control.MouseEnter += new EventHandler((object? sender, EventArgs e) => { onHover(true); }); + control.MouseLeave += new EventHandler((object? sender, EventArgs e) => { onHover(false); }); + + foreach (Control childControl in control.Controls) + { + if (!(childControl is CustomRoundedButton) && !(childControl is Button)) + AddMouseHandlers(childControl); + } + } + + #endregion + } +} diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.resx b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/Component_RowUserCertificate.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.Designer.cs b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.Designer.cs new file mode 100644 index 0000000..2890189 --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.Designer.cs @@ -0,0 +1,178 @@ +namespace SkillCourse.Panels.MainBlock.CertificatePage +{ + partial class PanelMainBlock_CertificateForTeacher + { + /// + /// Обязательная переменная конструктора. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + tableLayoutPanel1 = new TableLayoutPanel(); + panel3 = new Panel(); + panel4 = new Panel(); + panel5 = new Panel(); + customComboBox1 = new PanelComponents.CustomComboBox(); + label15 = new Label(); + label1 = new Label(); + panelMain = new Panel(); + tableLayoutPanel1.SuspendLayout(); + panel3.SuspendLayout(); + panel4.SuspendLayout(); + panel5.SuspendLayout(); + SuspendLayout(); + // + // tableLayoutPanel1 + // + tableLayoutPanel1.AutoScroll = true; + tableLayoutPanel1.ColumnCount = 3; + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 17F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); + tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 25F)); + tableLayoutPanel1.Controls.Add(panel3, 1, 1); + tableLayoutPanel1.Controls.Add(panelMain, 1, 3); + tableLayoutPanel1.Dock = DockStyle.Fill; + tableLayoutPanel1.Location = new Point(0, 0); + tableLayoutPanel1.Name = "tableLayoutPanel1"; + tableLayoutPanel1.RowCount = 5; + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 10F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 60F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); + tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 5F)); + tableLayoutPanel1.Size = new Size(1012, 673); + tableLayoutPanel1.TabIndex = 11; + // + // panel3 + // + panel3.Controls.Add(panel4); + panel3.Controls.Add(label1); + panel3.Dock = DockStyle.Fill; + panel3.Location = new Point(20, 13); + panel3.Name = "panel3"; + panel3.Size = new Size(964, 54); + panel3.TabIndex = 10; + // + // panel4 + // + panel4.Controls.Add(panel5); + panel4.Controls.Add(label15); + panel4.Dock = DockStyle.Right; + panel4.Location = new Point(516, 0); + panel4.Name = "panel4"; + panel4.Size = new Size(448, 54); + panel4.TabIndex = 10; + // + // panel5 + // + panel5.Controls.Add(customComboBox1); + panel5.Dock = DockStyle.Fill; + panel5.Location = new Point(85, 0); + panel5.Name = "panel5"; + panel5.Size = new Size(363, 54); + panel5.TabIndex = 9; + // + // customComboBox1 + // + customComboBox1.BackColor = Color.FromArgb(40, 49, 60); + customComboBox1.BorderColor = Color.FromArgb(80, 175, 138); + customComboBox1.BorderRadius = 0; + customComboBox1.BorderSize = 1; + customComboBox1.Dock = DockStyle.Fill; + customComboBox1.DropDownStyle = ComboBoxStyle.DropDown; + customComboBox1.Font = new Font("Segoe UI", 10.8F, FontStyle.Regular, GraphicsUnit.Point); + customComboBox1.ForeColor = SystemColors.Control; + customComboBox1.IconColor = SystemColors.Control; + customComboBox1.ListBackColor = Color.FromArgb(40, 49, 60); + customComboBox1.ListTextColor = Color.Silver; + customComboBox1.Location = new Point(0, 0); + customComboBox1.Margin = new Padding(9, 6, 0, 0); + customComboBox1.MinimumSize = new Size(125, 25); + customComboBox1.Name = "customComboBox1"; + customComboBox1.Padding = new Padding(1); + customComboBox1.Size = new Size(363, 54); + customComboBox1.TabIndex = 9; + customComboBox1.Texts = "All"; + customComboBox1.OnSelectedIndexChanged += customComboBox1_OnSelectedIndexChanged; + // + // label15 + // + label15.Dock = DockStyle.Left; + label15.Font = new Font("Segoe UI", 10.2F, FontStyle.Regular, GraphicsUnit.Point); + label15.ForeColor = SystemColors.ControlLight; + label15.Location = new Point(0, 0); + label15.Name = "label15"; + label15.Size = new Size(85, 54); + label15.TabIndex = 8; + label15.Text = "Course"; + label15.TextAlign = ContentAlignment.MiddleCenter; + // + // label1 + // + label1.Dock = DockStyle.Left; + label1.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); + label1.ForeColor = SystemColors.Control; + label1.Location = new Point(0, 0); + label1.Name = "label1"; + label1.Padding = new Padding(20, 0, 0, 0); + label1.Size = new Size(305, 54); + label1.TabIndex = 9; + label1.Text = "Assigned"; + label1.TextAlign = ContentAlignment.MiddleLeft; + // + // panelMain + // + panelMain.AutoScroll = true; + panelMain.Dock = DockStyle.Fill; + panelMain.Location = new Point(20, 93); + panelMain.Name = "panelMain"; + panelMain.Size = new Size(964, 572); + panelMain.TabIndex = 11; + // + // PanelMainBlock_CertificateForTeacher + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = Color.FromArgb(40, 49, 60); + Controls.Add(tableLayoutPanel1); + Name = "PanelMainBlock_CertificateForTeacher"; + Size = new Size(1012, 673); + tableLayoutPanel1.ResumeLayout(false); + panel3.ResumeLayout(false); + panel4.ResumeLayout(false); + panel5.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private TableLayoutPanel tableLayoutPanel1; + private Label label1; + private PanelComponents.CustomComboBox customComboBox1; + private Label label15; + private Panel panel3; + private Panel panel4; + private Panel panel5; + private Panel panelMain; + } +} diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.cs b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.cs new file mode 100644 index 0000000..0b557f5 --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.cs @@ -0,0 +1,118 @@ +using SkillCourse.DataBaseStructure; +using SkillCourse.handlers; +using SkillCourse.PanelComponents; +using SkillCourse.Panels.MainBlock.Notification; +using System.Data; +using Task = SkillCourse.DataBaseStructure.Task; + +namespace SkillCourse.Panels.MainBlock.CertificatePage +{ + public partial class PanelMainBlock_CertificateForTeacher : UserControl + { + private Teather handler = (Teather)AccountHandler.Instance.UserLog; + + private List thisSubCourse = new List(); + private List ListSubStudents { get; set; } = new List(); + + private TypeBlockTasks thisTypePage = TypeBlockTasks.Waiting; + + + public PanelMainBlock_CertificateForTeacher(TypeBlockTasks thisTypePage) + { + InitializeComponent(); + Dock = DockStyle.Fill; + + customComboBox1.Items.Add("All"); + customComboBox1.Items.AddRange(handler.MyCourses.Select(course => course.Name).ToArray()); + this.thisTypePage = thisTypePage; + Name += thisTypePage.ToString(); + + UpdatePanel_OnSelectedIndexChanged(); + + FillListControlTasks(); + FillPanel(); + } + + private void AddCertainTasksToList(Course course) + { + switch (thisTypePage) + { + case TypeBlockTasks.Waiting: + label1.Text = "Waiting"; + thisSubCourse.AddRange(handler.GetOnlySub_Waiting(course)); + break; + + case TypeBlockTasks.Issued: + label1.Text = "Issued"; + thisSubCourse.AddRange(handler.GetOnlySub_Issued(course)); + break; + } + } + + private void FillListControlTasks() + { + int i = 0; + ListSubStudents.Clear(); + foreach (var sub in thisSubCourse) + { + ListSubStudents.Add(new Component_RowUserCertificate(sub, thisTypePage == TypeBlockTasks.Waiting ? true : false)); + } + ListSubStudents.Reverse(); + } + + private void FillPanel() + { + panelMain.Controls.Clear(); + panelMain.Controls.AddRange(ListSubStudents.ToArray()); + + if (panelMain.Controls.Count < 1) + { + panelMain.Controls.Add(new PanelMainBlock_MessageText("There is nothing here.")); + panelMain.Controls[0].Dock = DockStyle.Fill; + } + } + + private void customComboBox1_OnSelectedIndexChanged(object sender, EventArgs e) + => UpdatePanel_OnSelectedIndexChanged(); + + private void RemoveThisTaskToPanel(UserControl task) + { + panelMain.Controls.Remove(task); + + if (panelMain.Controls.Count < 1) + { + panelMain.Controls.Add(new PanelMainBlock_MessageText("There is nothing here.")); + panelMain.Controls[0].Dock = DockStyle.Fill; + } + } + + public void UpdatePanel_OnSelectedIndexChanged() + { + thisSubCourse.Clear(); + + string nameSelectCoure = customComboBox1.Texts; + if (nameSelectCoure == "All") + { + foreach (var course in handler.MyCourses) + { + AddCertainTasksToList(course); + } + } + else + { + if (UserHandler.FindCourse(nameSelectCoure) is Course selectCourse) + AddCertainTasksToList(selectCourse); + } + + FillListControlTasks(); + FillPanel(); + } + + public enum TypeBlockTasks + { + Waiting, + Issued + + } + } +} diff --git a/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.resx b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SkillCourse/Panels/MainBlock/CertificatePage/PanelMainBlock_CertificateForTeacher.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SkillCourse/Panels/MainBlock/Navbar/NavigationButtonEvents/TeacherButtonEvents.cs b/SkillCourse/Panels/MainBlock/Navbar/NavigationButtonEvents/TeacherButtonEvents.cs index ed151ff..f1d5397 100644 --- a/SkillCourse/Panels/MainBlock/Navbar/NavigationButtonEvents/TeacherButtonEvents.cs +++ b/SkillCourse/Panels/MainBlock/Navbar/NavigationButtonEvents/TeacherButtonEvents.cs @@ -1,4 +1,5 @@ using SkillCourse.DataBaseStructure; +using SkillCourse.Panels.MainBlock.CertificatePage; using SkillCourse.Panels.MainBlock.Tasks; using System; using System.Collections.Generic; @@ -61,16 +62,16 @@ private static PanelMainBlock_Navbar NavBarHandler //------- Certificate - public static Action Certificate_IssuedClick = () => + public static Action Certificate_WaitingClick = () => { - NavigatePages.OpenNewPage(new PanelMainBlock_NotImplemented(), NavBarHandler.PanelParent); - NavBarHandler.UpdateStateButtons("Certificates", "Issued"); + NavigatePages.OpenNewPage(new PanelMainBlock_CertificateForTeacher(PanelMainBlock_CertificateForTeacher.TypeBlockTasks.Waiting), NavBarHandler.PanelParent); + NavBarHandler.UpdateStateButtons("Certificates", "Waiting"); }; - public static Action Certificate_WaitingClick = () => + public static Action Certificate_IssuedClick = () => { - NavigatePages.OpenNewPage(new PanelMainBlock_NotImplemented(), NavBarHandler.PanelParent); - NavBarHandler.UpdateStateButtons("Certificates", "Waiting"); + NavigatePages.OpenNewPage(new PanelMainBlock_CertificateForTeacher(PanelMainBlock_CertificateForTeacher.TypeBlockTasks.Issued), NavBarHandler.PanelParent); + NavBarHandler.UpdateStateButtons("Certificates", "Issued"); }; public static Action Certificate_CheckClick = () => diff --git a/SkillCourse/Panels/MainBlock/Navbar/PanelMainBlock_Navbar.cs b/SkillCourse/Panels/MainBlock/Navbar/PanelMainBlock_Navbar.cs index 2444e41..8d9d606 100644 --- a/SkillCourse/Panels/MainBlock/Navbar/PanelMainBlock_Navbar.cs +++ b/SkillCourse/Panels/MainBlock/Navbar/PanelMainBlock_Navbar.cs @@ -244,8 +244,8 @@ private void AddBNForTeacher(ref List listControls) List CertificatesDopButtons = new List() { - new Component_NavigationDopBut("Issued", TeacherButtonEvents.Certificate_IssuedClick), new Component_NavigationDopBut("Waiting", TeacherButtonEvents.Certificate_WaitingClick), + new Component_NavigationDopBut("Issued", TeacherButtonEvents.Certificate_IssuedClick), new Component_NavigationDopBut("Check", TeacherButtonEvents.Certificate_CheckClick) }; CertificatesDopButtons.Reverse(); @@ -253,7 +253,7 @@ private void AddBNForTeacher(ref List listControls) listControls.Add( new Component_NavigationBut("Certificates", Properties.Resources.ResourceManager.GetObject("add_certificate_wght400_GRAD0_opsz48_32") as Image, - false, TeacherButtonEvents.Certificate_IssuedClick, CertificatesDopButtons)); + false, TeacherButtonEvents.Certificate_WaitingClick, CertificatesDopButtons)); //------- Students diff --git a/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.Designer.cs b/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.Designer.cs index ceeb5ca..99ec8d4 100644 --- a/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.Designer.cs +++ b/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.Designer.cs @@ -28,20 +28,18 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PanelMainBlock_TasksForStudent)); tableLayoutPanel1 = new TableLayoutPanel(); - label3 = new Label(); - panel3 = new Panel(); + panelMain = new Panel(); + label1 = new Label(); panel4 = new Panel(); + label15 = new Label(); panel5 = new Panel(); customComboBox1 = new PanelComponents.CustomComboBox(); - label15 = new Label(); - label1 = new Label(); - panelMain = new Panel(); + panel3 = new Panel(); tableLayoutPanel1.SuspendLayout(); - panel3.SuspendLayout(); panel4.SuspendLayout(); panel5.SuspendLayout(); + panel3.SuspendLayout(); SuspendLayout(); // // tableLayoutPanel1 @@ -51,7 +49,6 @@ private void InitializeComponent() tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 17F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 25F)); - tableLayoutPanel1.Controls.Add(label3, 1, 2); tableLayoutPanel1.Controls.Add(panel3, 1, 1); tableLayoutPanel1.Controls.Add(panelMain, 1, 3); tableLayoutPanel1.Dock = DockStyle.Fill; @@ -66,26 +63,27 @@ private void InitializeComponent() tableLayoutPanel1.Size = new Size(1012, 673); tableLayoutPanel1.TabIndex = 11; // - // label3 + // panelMain // - label3.AutoSize = true; - label3.ForeColor = SystemColors.ControlLight; - label3.Location = new Point(20, 70); - label3.Name = "label3"; - label3.Padding = new Padding(0, 3, 0, 0); - label3.Size = new Size(963, 20); - label3.TabIndex = 12; - label3.Text = resources.GetString("label3.Text"); + panelMain.AutoScroll = true; + panelMain.Dock = DockStyle.Fill; + panelMain.Location = new Point(20, 93); + panelMain.Name = "panelMain"; + panelMain.Size = new Size(964, 572); + panelMain.TabIndex = 11; // - // panel3 + // label1 // - panel3.Controls.Add(panel4); - panel3.Controls.Add(label1); - panel3.Dock = DockStyle.Fill; - panel3.Location = new Point(20, 13); - panel3.Name = "panel3"; - panel3.Size = new Size(964, 54); - panel3.TabIndex = 10; + label1.Dock = DockStyle.Left; + label1.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); + label1.ForeColor = SystemColors.Control; + label1.Location = new Point(0, 0); + label1.Name = "label1"; + label1.Padding = new Padding(20, 0, 0, 0); + label1.Size = new Size(305, 54); + label1.TabIndex = 9; + label1.Text = "Assigned"; + label1.TextAlign = ContentAlignment.MiddleLeft; // // panel4 // @@ -97,6 +95,18 @@ private void InitializeComponent() panel4.Size = new Size(448, 54); panel4.TabIndex = 10; // + // label15 + // + label15.Dock = DockStyle.Left; + label15.Font = new Font("Segoe UI", 10.2F, FontStyle.Regular, GraphicsUnit.Point); + label15.ForeColor = SystemColors.ControlLight; + label15.Location = new Point(0, 0); + label15.Name = "label15"; + label15.Size = new Size(85, 54); + label15.TabIndex = 8; + label15.Text = "Course"; + label15.TextAlign = ContentAlignment.MiddleCenter; + // // panel5 // panel5.Controls.Add(customComboBox1); @@ -129,66 +139,40 @@ private void InitializeComponent() customComboBox1.Texts = "All"; customComboBox1.OnSelectedIndexChanged += customComboBox1_OnSelectedIndexChanged; // - // label15 - // - label15.Dock = DockStyle.Left; - label15.Font = new Font("Segoe UI", 10.2F, FontStyle.Regular, GraphicsUnit.Point); - label15.ForeColor = SystemColors.ControlLight; - label15.Location = new Point(0, 0); - label15.Name = "label15"; - label15.Size = new Size(85, 54); - label15.TabIndex = 8; - label15.Text = "Course"; - label15.TextAlign = ContentAlignment.MiddleCenter; - // - // label1 - // - label1.Dock = DockStyle.Left; - label1.Font = new Font("Segoe UI", 13.8F, FontStyle.Regular, GraphicsUnit.Point); - label1.ForeColor = SystemColors.Control; - label1.Location = new Point(0, 0); - label1.Name = "label1"; - label1.Padding = new Padding(20, 0, 0, 0); - label1.Size = new Size(305, 54); - label1.TabIndex = 9; - label1.Text = "Assigned"; - label1.TextAlign = ContentAlignment.MiddleLeft; - // - // panelMain + // panel3 // - panelMain.AutoScroll = true; - panelMain.Dock = DockStyle.Fill; - panelMain.Location = new Point(20, 93); - panelMain.Name = "panelMain"; - panelMain.Size = new Size(964, 572); - panelMain.TabIndex = 11; + panel3.Controls.Add(panel4); + panel3.Controls.Add(label1); + panel3.Dock = DockStyle.Fill; + panel3.Location = new Point(20, 13); + panel3.Name = "panel3"; + panel3.Size = new Size(964, 54); + panel3.TabIndex = 10; // - // PanelMainBlock_TaskAssigned + // PanelMainBlock_TasksForStudent // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.FromArgb(40, 49, 60); Controls.Add(tableLayoutPanel1); - Name = "PanelMainBlock_TaskAssigned"; + Name = "PanelMainBlock_TasksForStudent"; Size = new Size(1012, 673); tableLayoutPanel1.ResumeLayout(false); - tableLayoutPanel1.PerformLayout(); - panel3.ResumeLayout(false); panel4.ResumeLayout(false); panel5.ResumeLayout(false); + panel3.ResumeLayout(false); ResumeLayout(false); } #endregion private TableLayoutPanel tableLayoutPanel1; - private Label label1; - private PanelComponents.CustomComboBox customComboBox1; - private Label label15; + private Panel panelMain; private Panel panel3; private Panel panel4; private Panel panel5; - private Panel panelMain; - private Label label3; + private PanelComponents.CustomComboBox customComboBox1; + private Label label15; + private Label label1; } } diff --git a/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.resx b/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.resx index ca6efdd..f298a7b 100644 --- a/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.resx +++ b/SkillCourse/Panels/MainBlock/Tasks/PanelMainBlock_TasksForStudent.resx @@ -57,7 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - \ No newline at end of file diff --git a/SkillCourse/SkillCourse.csproj b/SkillCourse/SkillCourse.csproj index 9177f73..933d718 100644 --- a/SkillCourse/SkillCourse.csproj +++ b/SkillCourse/SkillCourse.csproj @@ -31,6 +31,12 @@ UserControl + + UserControl + + + UserControl + UserControl diff --git a/SkillCourse/handlers/StudentHandler.cs b/SkillCourse/handlers/StudentHandler.cs index 1a43c1e..d7d9364 100644 --- a/SkillCourse/handlers/StudentHandler.cs +++ b/SkillCourse/handlers/StudentHandler.cs @@ -58,7 +58,7 @@ public List GetOnlyTask_Assigned(Course course) return DataBase.Tasks .Where(task => task.IdCourse == course.IdCourse && task.TaskTypeMessage == false && - DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.State == StateTask.Done)) + DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.IdUser == this.IdUser && answerTask.State == StateTask.Done)) .OrderBy(task => task.TaskStartTime) .ToList(); } @@ -68,7 +68,7 @@ public List GetOnlyTask_Checked(Course course) return DataBase.Tasks .Where(task => task.IdCourse == course.IdCourse && task.TaskTypeMessage == false && - DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.State == StateTask.Checked)) + DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.IdUser == this.IdUser && answerTask.State == StateTask.Checked)) .OrderBy(task => task.TaskStartTime) .ToList(); } @@ -79,7 +79,7 @@ public List GetOnlyTask_Missing(Course course) .Where(task => task.IdCourse == course.IdCourse && task.TaskTypeMessage == false && (!DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask) || - DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.State == StateTask.NotDone))) + DataBase.AnswerTasks.Any(answerTask => answerTask.IdTask == task.IdTask && answerTask.IdUser == this.IdUser && answerTask.State == StateTask.NotDone))) .OrderBy(task => task.TaskStartTime) .ToList(); } diff --git a/SkillCourse/handlers/TeatherHandler.cs b/SkillCourse/handlers/TeatherHandler.cs index 31de1bb..828d60c 100644 --- a/SkillCourse/handlers/TeatherHandler.cs +++ b/SkillCourse/handlers/TeatherHandler.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.ConstrainedExecution; using System.Text; using System.Text.Json.Serialization; using System.Threading.Tasks; @@ -49,6 +50,20 @@ public List GetAllAnswerTask_Checked(Task task) // Провер return DataBase.AnswerTasks.Where(anwer => anwer.IdTask == task.IdTask && anwer.State == StateTask.Checked).ToList(); } + public List GetOnlySub_Waiting(Course course) // У которых ещё нету сертификата + { + return DataBase.Subscriptions.Where(sub => sub.IdCourse == course.IdCourse && + !DataBase.Certificates.Any(cer => cer.IdCourse == course.IdCourse && cer.IdOwner == sub.IdStudent)) + .ToList(); + } + + public List GetOnlySub_Issued(Course course) // Которым уже выдан сертификат + { + return DataBase.Subscriptions.Where(sub => sub.IdCourse == course.IdCourse && + DataBase.Certificates.Any(cer => cer.IdCourse == course.IdCourse && cer.IdOwner == sub.IdStudent)) + .ToList(); + } + public List GetTasksNoMessage(Course course) { return DataBase.Tasks.Where(task => task.IdCourse == course.IdCourse && task.TaskTypeMessage == false).ToList(); @@ -107,6 +122,28 @@ public List FindAllCourses(string search) .ToList(); } + public int ProcentCompleteCourse(SubscriptionCourse sub) + { + List tasksCourseThisSub = DataBase.Tasks.Where(task => task.IdCourse == sub.IdCourse).ToList(); + + int allTask = DataBase.Tasks.Where(task => task.IdCourse == sub.IdCourse && task.TaskTypeMessage == false).Count(); + + // Если заданий нету, то мы выполнилит на 100% + if (allTask == 0) + return 100; + + int completeTask = DataBase.AnswerTasks.Where(answer => + (answer.State == StateTask.Done || answer.State == StateTask.Checked) && + answer.IdUser == sub.IdStudent && + tasksCourseThisSub.Any(task => task.IdTask == answer.IdTask) + ).Count(); + + if (completeTask == 0) + return 0; + + return (Int32)(((double)completeTask / (double)allTask) * 100); + } + public Course? CreateCourse(Course newCourse) { try @@ -231,6 +268,14 @@ public bool AddTaskToCourse(Course course, string textTask, bool taskTypeMessage } } + public bool AddCertificate(int idCourse, int idStudent, string description) + { + return AddCertificate( + DataBase.Courses.Find(course => course.IdCourse == idCourse), + DataBase.Users.Students().Find(user => user.IdUser == idStudent), + description); + } + public bool AddCertificate(Course course, Student student, string description) { try @@ -246,13 +291,19 @@ public bool AddCertificate(Course course, Student student, string description) // Находим задачи для заданного курса - List courseTasks = DataBase.Tasks.Where(task => task.IdCourse == course.IdCourse).ToList(); + List courseTasks = DataBase.Tasks.Where(task => task.IdCourse == course.IdCourse && task.TaskTypeMessage == false).ToList(); // Находим ответы на задачи для перечисления заданий и студента List completedTasks = DataBase.AnswerTasks.Where(ans => ans.IdUser == student.IdUser) .Join(courseTasks, ans => ans.IdTask, task => task.IdTask, (ans, task) => ans).ToList(); - return courseTasks.Count == completedTasks.Count; + if (courseTasks.Count != completedTasks.Count) + return false; + + Certificate newCertificate = new Certificate(description, DateTime.Now, this.IdUser, student.IdUser, course.IdCourse); + DataBase.Certificates.Add(newCertificate); + + return true; } return false; diff --git a/SkillCourse/handlers/UserHandler.cs b/SkillCourse/handlers/UserHandler.cs index ccdc914..cbdb296 100644 --- a/SkillCourse/handlers/UserHandler.cs +++ b/SkillCourse/handlers/UserHandler.cs @@ -24,6 +24,16 @@ private static SkillCourseDB DataBase } } + public static User? GetUser(int idUser) + { + return DataBase.Users.Find(user => user.IdUser == idUser); + } + + public static Course? GetCourse(SubscriptionCourse sub) + { + return DataBase.Courses.Find(cour => cour.IdCourse == sub.IdCourse); + } + public static Course? GetCourse(int idCourse) { return DataBase.Courses.Find(cour => cour.IdCourse == idCourse); @@ -52,7 +62,12 @@ public static string GetFullName(int idUser) public static Student? GetStudent(AnswerTask answer) { - return DataBase.Users.Students().FindLast(user => user.IdUser == answer.IdUser); + return DataBase.Users.Students().Find(user => user.IdUser == answer.IdUser); + } + + public static Student? GetStudent(SubscriptionCourse sub) + { + return DataBase.Users.Students().Find(user => user.IdUser == sub.IdStudent); } public static List GetStudents(Course course) diff --git a/SkillCourse/helperConfig/UserTextSize.cs b/SkillCourse/helperConfig/UserTextSize.cs index a3f6c0e..bebe1ee 100644 --- a/SkillCourse/helperConfig/UserTextSize.cs +++ b/SkillCourse/helperConfig/UserTextSize.cs @@ -23,5 +23,10 @@ public static class AnswerTask { public static readonly int maxLenghtName = 500; } + + public static class Certificate + { + public static readonly int maxLenghtDescription = 200; + } } }