Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
373796c
feat: Candev Application (#306)
arnaudroy97 Sep 29, 2021
b27eb5e
Adds a Confirm Presence Form (#303)
axalrub Sep 29, 2021
f20fcbb
Adds a recipe that creates a solution form (#300)
axalrub Sep 29, 2021
b00de74
redesigns judging list page (#299)
axalrub Oct 4, 2021
955b410
add Candev test and fixes (#317)
arnaudroy97 Oct 12, 2021
ad95063
fix candev test
arnaudroy97 Oct 13, 2021
6289c0d
Fix Score ContentType and tests
arnaudroy97 Oct 13, 2021
74efdd7
fix test
arnaudroy97 Oct 14, 2021
e6a25d9
fix scoringPage bug
arnaudroy97 Oct 15, 2021
e815950
fix bug
arnaudroy97 Oct 15, 2021
9b6e909
Update pr_ci.yml (#321)
arnaudroy97 Oct 22, 2021
54967c3
Add MatchTeam & AssignCases algo (#320)
arnaudroy97 Oct 26, 2021
ab3fadf
Update scoring related content types (#324)
arnaudroy97 Nov 3, 2021
cf761e0
Add 'complete' or 'incomplete' tag to challenge submissions (#322)
arnaudroy97 Nov 8, 2021
ed225ea
Change Indexes name prefix from Hackathon to Candev
arnaudroy97 Nov 10, 2021
3e5dc73
Rename Indexes to match previous changes
arnaudroy97 Nov 10, 2021
3081d11
Fix errors with index migration
arnaudroy97 Nov 12, 2021
acd604b
Added admin button to select N participants
arnaudroy97 Nov 18, 2021
6dde451
Fix topic selection on teamEdit
arnaudroy97 Nov 22, 2021
baf400a
Add Attendance and CheckIn & Add challenges features to widgets
arnaudroy97 Nov 24, 2021
7a26d29
Fix Migrations
arnaudroy97 Nov 25, 2021
ef30eaa
Add custom setting to show partial challenge
arnaudroy97 Nov 25, 2021
2c40fdc
Fix TeamDashboardWidget & update tests
arnaudroy97 Nov 26, 2021
b853095
Add Check-In button and process
arnaudroy97 Nov 30, 2021
03dd62d
scoring and judging
arnaudroy97 Dec 16, 2021
ecc991e
Fix scoring & tests
arnaudroy97 Dec 17, 2021
bb5fe98
Score page reduce index (#327)
axalrub Dec 20, 2021
511d25a
Add algo to eliminate teams after round 1 of judging
arnaudroy97 Dec 21, 2021
b492348
Fix migrations errors
arnaudroy97 Dec 22, 2021
c797a82
fix Migrations
arnaudroy97 Dec 22, 2021
43d0993
fixes
arnaudroy97 Dec 24, 2021
20f9401
Fix migration errors
arnaudroy97 Jan 5, 2022
2a7778f
fixes and add judgingResultWidget
arnaudroy97 Jan 18, 2022
3823b6e
only translate candev app to prevent API limit
arnaudroy97 Jan 18, 2022
44615a6
fix
arnaudroy97 Jan 18, 2022
6a100de
add translation & fixes
arnaudroy97 Jan 18, 2022
42de8eb
Add translation
arnaudroy97 Jan 18, 2022
c8a2c9d
fixes to teamdashboard
arnaudroy97 Jan 20, 2022
e9c257e
Fixes
arnaudroy97 Feb 5, 2022
d350b61
fix avrgIndex
arnaudroy97 Feb 5, 2022
909416a
fix
arnaudroy97 Feb 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/pr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- feature/candev
push:
paths-ignore:
- '**/*.md'
Expand Down
17 changes: 16 additions & 1 deletion StatCan.OrchardCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{E8DD6EC8-A
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatCan.OrchardCore.Scheduling", "src\Apps\StatCan.OrchardCore.Scheduling\StatCan.OrchardCore.Scheduling.csproj", "{56F32388-650F-433C-919F-8C265F99411D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatCan.OrchardCore.Configuration", "src\Modules\StatCan.OrchardCore.Configuration\StatCan.OrchardCore.Configuration.csproj", "{DEA6A849-3230-43DE-A9A0-3C22DA8E316E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatCan.OrchardCore.Configuration", "src\Modules\StatCan.OrchardCore.Configuration\StatCan.OrchardCore.Configuration.csproj", "{DEA6A849-3230-43DE-A9A0-3C22DA8E316E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StatCan.OrchardCore.Candev", "src\Apps\StatCan.OrchardCore.Candev\StatCan.OrchardCore.Candev.csproj", "{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -466,6 +468,18 @@ Global
{DEA6A849-3230-43DE-A9A0-3C22DA8E316E}.Release|x64.Build.0 = Release|Any CPU
{DEA6A849-3230-43DE-A9A0-3C22DA8E316E}.Release|x86.ActiveCfg = Release|Any CPU
{DEA6A849-3230-43DE-A9A0-3C22DA8E316E}.Release|x86.Build.0 = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|x64.ActiveCfg = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|x64.Build.0 = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|x86.ActiveCfg = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Debug|x86.Build.0 = Debug|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|Any CPU.Build.0 = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|x64.ActiveCfg = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|x64.Build.0 = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|x86.ActiveCfg = Release|Any CPU
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -506,6 +520,7 @@ Global
{E8DD6EC8-AA09-440F-937A-1901293389E1} = {8EA5EBF0-41C6-11EA-890A-ED68CBADDC1F}
{56F32388-650F-433C-919F-8C265F99411D} = {E8DD6EC8-AA09-440F-937A-1901293389E1}
{DEA6A849-3230-43DE-A9A0-3C22DA8E316E} = {5E638520-41E8-11EA-885A-BDD3BB7B4F92}
{2CFB2F3C-61E5-45AE-906A-3DF746EBE1C6} = {E8DD6EC8-AA09-440F-937A-1901293389E1}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8FF197F3-C3E2-4D83-80AC-D59BE36DD4AF}
Expand Down
44 changes: 44 additions & 0 deletions src/Apps/StatCan.OrchardCore.Candev/AdminMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Localization;
using OrchardCore.ContentManagement;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.Navigation;
using YesSql;

namespace StatCan.OrchardCore.Candev
{
public class AdminMenu : INavigationProvider
{
private readonly IContentManager _contentManager;
private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly ISession _session;

public AdminMenu(IStringLocalizer<AdminMenu> localizer, ISession session, IContentManager contentManager, IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
_contentManager = contentManager;
_session = session;
T = localizer;
}

public IStringLocalizer T { get; set; }

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
{
// We want to add our menus to the "admin" menu only.
if (!string.Equals(name, "admin", StringComparison.OrdinalIgnoreCase))
{
return Task.CompletedTask;
}

builder
.Add(T["Admin Panel"], "-100", rootView =>
{
rootView.Action("Index", "Admin", new { area = "StatCan.OrchardCore.Candev" });
});

return Task.CompletedTask;
}
}
}
112 changes: 112 additions & 0 deletions src/Apps/StatCan.OrchardCore.Candev/Commands/CandevCommands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using Microsoft.Extensions.Localization;
using OrchardCore.Environment.Commands;
using StatCan.OrchardCore.Candev.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StatCan.OrchardCore.Candev.Commands
{
public class CandevCommands : DefaultCommandHandler
{
private readonly ICandevService _candevService;

public CandevCommands(
ICandevService candevService,
IStringLocalizer<CandevCommands> localizer) : base(localizer)
{
_candevService = candevService;
}

[OrchardSwitch]
public string TeamName { get; set; }

[OrchardSwitch]
public string TeamTopics { get; set; }

[OrchardSwitch]
public string ChallengeTitle { get; set; }

[OrchardSwitch]
public string TopicName { get; set; }

[OrchardSwitch]
public string TopicChallenge { get; set; }

[OrchardSwitch]
public string TeamId { get; set; }

[OrchardSwitch]
public string UserName { get; set; }

[CommandName("createTeam")]
[CommandHelp("createTeam /TeamName:<teamName> /TeamTopics:{topicId,topicId,...}\r\n\t" + "Creates a new Team")]
[OrchardSwitches("TeamName,TeamTopics")]
public async Task<string> CreateTeamAsync()
{
var teamTopics = (TeamTopics ?? "").Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();

var teamId = await _candevService.CreateTeam(TeamName, teamTopics);

if (teamId != null)
{
Context.Output.WriteLine(S["Team created successfully"]);
return teamId;
}

Context.Output.WriteLine(S["Error during CreateTeam Command"]);
return null;
}

[CommandName("createChallenge")]
[CommandHelp("createChallenge /ChallengeTitle:<challengeTitle>\r\n\t" + "Creates a new Challenge")]
[OrchardSwitches("ChallengeTitle")]
public async Task<string> CreateChallengeAsync()
{
var challengeId = await _candevService.CreateChallenge(ChallengeTitle);

if (challengeId != null)
{
Context.Output.WriteLine(S["Challenge created successfully"]);
return challengeId;
}

Context.Output.WriteLine(S["Error during CreateChallenge Command"]);
return null;
}

[CommandName("createTopic")]
[CommandHelp("createTopic /TopicName:<topicName> /TopicChallenge:<challengeId>\r\n\t" + "Creates a new Topic")]
[OrchardSwitches("TopicName,TopicChallenge")]
public async Task<string> CreateTopicAsync()
{
var topicId = await _candevService.CreateTopic(TopicName, TopicChallenge);

if (topicId != null)
{
Context.Output.WriteLine(S["Topic created successfully"]);
return topicId;
}

Context.Output.WriteLine(S["Error during CreateTopic Command"]);
return null;
}

[CommandName("joinTeam")]
[CommandHelp("joinTeam /TeamId:<teamId> /UserName:<username>\r\n\t" + "Makes a hacker join a Team")]
[OrchardSwitches("TeamId,UserName")]
public async Task JoinTeamAsync()
{
var team = await _candevService.JoinTeam(TeamId, UserName);

if (team != null)
{
Context.Output.WriteLine(S["Topic created successfully"]);
}

Context.Output.WriteLine(S["Error during JoinTeam Command"]);
}
}
}
138 changes: 138 additions & 0 deletions src/Apps/StatCan.OrchardCore.Candev/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using OrchardCore.ContentManagement;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.ModelBinding;
using YesSql;
using Microsoft.AspNetCore.Mvc.Localization;
using OrchardCore.Settings;
using OrchardCore.Entities;
using StatCan.OrchardCore.Candev.Services;
using OrchardCore.DisplayManagement.Notify;

namespace StatCan.OrchardCore.Candev.Controllers
{
public class AdminController : Controller, IUpdateModel
{
private readonly ISiteService _siteService;
private readonly ISession _session;
private readonly ICandevService _candevService;
private readonly INotifier _notifier;

public dynamic New { get; set; }

public AdminController(ISiteService siteService, ISession session, IShapeFactory shapeFactory,
ICandevService hackathonService,
IHtmlLocalizer<AdminController> localizer,
INotifier notifier)
{
_siteService = siteService;
_session = session;
New = shapeFactory;
_candevService = hackathonService;
H = localizer;
_notifier = notifier;
}

public IHtmlLocalizer H {get;}

public async Task<IActionResult> Index()
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

var viewModel = await New.ViewModel();
return View(viewModel);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> AssignCases(string returnUrl)
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

var site = await _siteService.GetSiteSettingsAsync();
var hackathonCustomSettings = site.As<ContentItem>("HackathonCustomSettings");
if (hackathonCustomSettings.Content["TeamCustomSettings"]["TeamEditable"].Value == true)
{
return Unauthorized();
}

await _candevService.AssignCases();

await _session.SaveChangesAsync();
_notifier.Success(H["Cases have been assigned."]);
return RedirectToAction("Index");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> MatchTeams(string returnUrl)
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

var site = await _siteService.GetSiteSettingsAsync();
var hackathonCustomSettings = site.As<ContentItem>("HackathonCustomSettings");
if (hackathonCustomSettings.Content["TeamCustomSettings"]["TeamEditable"].Value == true)
{
return Unauthorized();
}

await _candevService.MatchTeams();

await _session.SaveChangesAsync();
_notifier.Success(H["Teams have been matched."]);
return RedirectToAction("Index");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> SelectNHackers(int n)
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

await _candevService.SelectNHackers(n);
_notifier.Success(H["Participants have been selected."]);
return RedirectToAction("Index");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> CheckIn()
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

await _candevService.CheckIn();
_notifier.Success(H["Checked-In participants have been selected."]);
return RedirectToAction("Index");
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> EliminateTeams()
{
if (!HttpContext.User.IsInRole("Administrator"))
{
return Unauthorized();
}

await _candevService.EliminateTeams();
_notifier.Success(H["Teams have been eliminated (In the running set to false)"]);
return RedirectToAction("Index");
}
}
}
Loading