Skip to content

Commit

Permalink
[WTH Core] Updates to template generator (#408)
Browse files Browse the repository at this point in the history
* Create create-new-hack.yml

* Update create-new-hack.yml

* rename hack

* lf for create hack

* gitkeep

* yml

* create 0

* renames

* name

* title

* new template files

* template files

* copy lectures pptx

* template fixes
  • Loading branch information
jordanbean-msft authored Jun 16, 2022
1 parent 591a9b7 commit f9fb692
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github/workflows/create-wth-template.sh eol=lf
4 changes: 2 additions & 2 deletions .github/workflows/create-new-hack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:
required: true
default: YetAnotherHack
numberOfChallenges:
description: The number of challenges you want
description: The number of challenges you want (note that it is better to auto-generate more challenges than you think you will need, you can always delete the files later)
required: true
default: 3
default: '3'
jobs:
createNewWhatTheHackTemplate:
runs-on: ubuntu-latest
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/create-wth-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ CreateDirectoryStructure() {
# create the Coach & Coach/Solutions directories
mkdir -p $rootPath/Coach/Solutions

#add a file to allow git to store an "empty" directory
touch $rootPath/Coach/Solutions/.gitkeep

# copying the Coach Lectures template file in the /Coach directory
cp $templateDirectoryName/WTH-Lectures-Template.pptx $rootPath/Coach/Lectures.pptx

if $verbosityArg; then
echo "Creating $rootPath/Student/Resources directories..."
fi

# create the Student & Student/Resources directories
mkdir -p $rootPath/Student/Resources

#add a file to allow git to store an "empty" directory
touch $rootPath/Student/Resources/.gitkeep
}

PreprocessTemplateFile() {
Expand Down Expand Up @@ -82,8 +91,12 @@ GenerateChallengesSection() {

local challengesSection=""

for challengeNumber in $(seq -f "%02g" 1 $numberOfChallenges); do
eval challengesSection+=\$\'- Challenge $challengeNumber: **[Title of Challenge]\($directoryName/$typeName-$challengeNumber.md\)**\\n\\t - Description of challenge\\n\'
for challengeNumber in $(seq -f "%02g" 0 $numberOfChallenges); do
if [[ $challengeNumber -eq "00" ]]; then
eval challengesSection+=\$\'- Challenge $challengeNumber: **[Prerequisites - Ready, Set, GO!]\($directoryName/$typeName-$challengeNumber.md\)**\\n\\t - Prepare your workstation to work with Azure.\\n\'
else
eval challengesSection+=\$\'- Challenge $challengeNumber: **[Title of Challenge]\($directoryName/$typeName-$challengeNumber.md\)**\\n\\t - Description of challenge\\n\'
fi
done

echo "$challengesSection"
Expand All @@ -101,7 +114,7 @@ CreateHackDescription() {
WriteMarkdownFile "$rootPath/README.md" "WTH-HackDescription-Template.md"
}

GenerateNavitationLink() {
GenerateNavigationLink() {
local -r suffixNumber=$1
local -r numberOfChallenges=$2
local -r linkName=$3
Expand All @@ -113,7 +126,7 @@ GenerateNavitationLink() {

#have to account for the fact that there is 0 at the beginning of the challenge number, a 08 is interpreted as octal
#therefore, the $((10#$suffixNumber)) syntax
if [[ $((10#$suffixNumber)) -gt 1 ]]; then
if [[ $((10#$suffixNumber)) -gt 0 ]]; then
local -r previousChallengeNumber=$(printf %02d $((10#$suffixNumber - 1)))
previousNavigationLink="[< Previous $linkName](./$linkName-$previousChallengeNumber.md) - "
fi
Expand Down Expand Up @@ -152,9 +165,13 @@ CreateChallengeMarkdownFile() {
echo "Creating $fullPath/$prefix-$suffixNumber.md..."
fi

local -r navigationLine=$(GenerateNavitationLink $suffixNumber $numberOfChallenges "Challenge" false)
local -r navigationLine=$(GenerateNavigationLink $suffixNumber $numberOfChallenges "Challenge" false)

WriteMarkdownFile "$fullPath/$prefix-$suffixNumber.md" "WTH-Challenge-Template.md"
if [[ $suffixNumber -eq "00" ]]; then
WriteMarkdownFile "$fullPath/$prefix-$suffixNumber.md" "WTH-ChallengeZero-Template.md"
else
WriteMarkdownFile "$fullPath/$prefix-$suffixNumber.md" "WTH-Challenge-Template.md"
fi
}

CreateSolutionMarkdownFile() {
Expand All @@ -166,7 +183,7 @@ CreateSolutionMarkdownFile() {
echo "Creating $fullPath/$prefix-$suffixNumber.md..."
fi

local -r navigationLine=$(GenerateNavitationLink $suffixNumber $numberOfChallenges "Solution" true)
local -r navigationLine=$(GenerateNavigationLink $suffixNumber $numberOfChallenges "Solution" true)

WriteMarkdownFile "$fullPath/$prefix-$suffixNumber.md" "WTH-Challenge-Solution-Template.md"
}
Expand All @@ -179,7 +196,7 @@ CreateChallenges() {
echo "Creating $numberOfChallenges challenge Markdown files in $fullPath..."
fi

for challengeNumber in $(seq -f "%02g" 1 $numberOfChallenges); do
for challengeNumber in $(seq -f "%02g" 0 $numberOfChallenges); do
CreateChallengeMarkdownFile "$fullPath" "Challenge" $challengeNumber $numberOfChallenges
done
}
Expand Down Expand Up @@ -207,7 +224,7 @@ CreateSolutions() {
echo "Creating $numberOfSolutions solution Markdown files in $fullPath..."
fi

for solutionNumber in $(seq -f "%02g" 1 $numberOfSolutions); do
for solutionNumber in $(seq -f "%02g" 0 $numberOfSolutions); do
CreateSolutionMarkdownFile "$fullPath" "Solution" $solutionNumber
done
}
Expand All @@ -234,20 +251,20 @@ while getopts ":c:dhn:p:v" option; do
d) deleteExistingDirectoryArg=true;;
h) Help
exit;;
n) nameOfChallengeArg=${OPTARG};;
n) nameOfHackArg=${OPTARG};;
p) pathArg=${OPTARG};;
v) verbosityArg=true
esac
done

if $verbosityArg; then
echo "Number of Challenges: $numberOfChallengesArg"
echo "Name of Challenge: $nameOfChallengeArg"
echo "Name of Challenge: $nameOfHackArg"
echo "Path: $pathArg"
echo "Delete existing directory: $deleteExistingDirectoryArg"
fi

declare -r wthDirectoryName="xxx-$nameOfChallengeArg"
declare -r wthDirectoryName="xxx-$nameOfHackArg"

declare -r rootPath="$pathArg/$wthDirectoryName"

Expand Down
13 changes: 10 additions & 3 deletions 000-HowToHack/WTH-Challenge-Solution-Template.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
<!-- REMOVE_ME # Challenge ${suffixNumber} - <Title of Challenge> - Coach's Guide (remove this from your MD files if you are writing them manually, this is for the automation script) REMOVE_ME -->

<!-- REPLACE_ME (this section will be removed by the automation script) -->

# Challenge 01 - \<Title of Challenge> - Coach's Guide

<!-- REPLACE_ME (this section will be removed by the automation script) -->

<!-- REMOVE_ME ${navigationLine} (remove this from your MD files if you are writing them manually, this is for the automation script) REMOVE_ME -->

<!-- REPLACE_ME (this section will be removed by the automation script) -->

[< Previous Solution](./Solution-01.md) - **[Home](./README.md)** - [Next Solution >](./Solution-03.md)

<!-- REPLACE_ME (this section will be removed by the automation script) -->

## Notes & Guidance

This is the only section you need to include.

Use general non-bulleted text for the beginning of a solution area for this challenge

- Then move into bullets
- And sub-bullets and even
- sub-sub-bullets
- And sub-bullets and even
- sub-sub-bullets

Break things apart with more than one bullet list
- Like this

- Like this
- One
- Right
- Here
2 changes: 1 addition & 1 deletion 000-HowToHack/WTH-Challenge-Template.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ To complete this challenge successfully, you should be able to:

## Learning Resources

*List of relevant links and online articles that should give the attendees the knowledge needed to complete the challenge.*
_List of relevant links and online articles that should give the attendees the knowledge needed to complete the challenge._

*Think of this list as giving the students a head start on some easy Internet searches. However, try not to include documentation links that are the literal step-by-step answer of the challenge's scenario.*

Expand Down
51 changes: 28 additions & 23 deletions 000-HowToHack/WTH-ChallengeZero-Template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@

<!-- REPLACE_ME (this section will be removed by the automation script) -->
<!-- If you are using and editing this template manually, ensure the navigation link below is updated to link to next challenge relative to the current challenge. The "Home" link should always link to the homepage of the hack which is the README.md in the hack's parent directory. -->

**[Home](../README.md)** - [Next Challenge >](./Challenge-01.md)

<!-- REPLACE_ME (this section will be removed by the automation script) -->

***This is a template for "Challenge Zero" which focuses on getting prerequisites set up for the hack. The italicized text provides hints & examples of what should or should NOT go in each section.***
**_This is a template for "Challenge Zero" which focuses on getting prerequisites set up for the hack. The italicized text provides hints & examples of what should or should NOT go in each section._**

***We have included links to some common What The Hack pre-reqs in this template. All common prerequisite links go to the WTH-CommonPrerequisites page where there are more details on what each tool's purpose is.***
**_We have included links to some common What The Hack pre-reqs in this template. All common prerequisite links go to the WTH-CommonPrerequisites page where there are more details on what each tool's purpose is._**

***You should remove any common pre-reqs that are not required for your hack. Then add additional pre-reqs that are required for your hack in the Description section below.***
**_You should remove any common pre-reqs that are not required for your hack. Then add additional pre-reqs that are required for your hack in the Description section below._**

***You should remove all italicized & sample text in this template and replace with your content.***
**_You should remove all italicized & sample text in this template and replace with your content._**

## Introduction

<!-- REMOVE_ME Thank you for participating in the ${nameOfChallengeArg} What The Hack. Before you can hack, you will need to set up some prerequisites. (remove this from your MD files if you are writing them manually, this is for the automation script) REMOVE_ME -->
<!-- REMOVE_ME Thank you for participating in the ${nameOfHackArg} What The Hack. Before you can hack, you will need to set up some prerequisites. (remove this from your MD files if you are writing them manually, this is for the automation script) REMOVE_ME -->

<!-- REPLACE_ME (this section will be removed by the automation script) -->

Thank you for participating in the IoT Hack of the Century What The Hack. Before you can hack, you will need to set up some prerequisites.

<!-- REPLACE_ME (this section will be removed by the automation script) -->

## Common Prerequisites

We have compiled a list of common tools and software that will come in handy to complete most What The Hack Azure-based hacks!
We have compiled a list of common tools and software that will come in handy to complete most What The Hack Azure-based hacks!

You might not need all of them for the hack you are participating in. However, if you work with Azure on a regular basis, these are all things you should consider having in your toolbox.

Expand All @@ -45,25 +49,26 @@ You might not need all of them for the hack you are participating in. However, i

## Description

*This section should clearly state any additional prerequisite tools that need to be installed or set up in the Azure environment that the student will hack in.*
_This section should clearly state any additional prerequisite tools that need to be installed or set up in the Azure environment that the student will hack in._

*While ordered lists are generally not welcome in What The Hack challenge descriptions, you can use one here in Challenge Zero IF and only IF the steps you are asking the student to perform are not core to the learning objectives of the hack.*
_While ordered lists are generally not welcome in What The Hack challenge descriptions, you can use one here in Challenge Zero IF and only IF the steps you are asking the student to perform are not core to the learning objectives of the hack._

*For example, if the hack is on IoT Devices and you want the student to deploy an ARM/Bicep template that sets up the environment they will hack in without them needing to understand how ARM/Bicep templates work, you can provide step-by-step instructions on how to deploy the ARM/Bicep template.*
_For example, if the hack is on IoT Devices and you want the student to deploy an ARM/Bicep template that sets up the environment they will hack in without them needing to understand how ARM/Bicep templates work, you can provide step-by-step instructions on how to deploy the ARM/Bicep template._

*Optionally, you may provide resource files such as a sample application, code snippets, or templates as learning aids for the students. These files are stored in the hack's \`Student/Resources\` folder. It is the coach's responsibility to package these resources into a Resources.zip file and provide it to the students at the start of the hack. You should leave the sample text below in that refers to the Resources.zip file.*
_Optionally, you may provide resource files such as a sample application, code snippets, or templates as learning aids for the students. These files are stored in the hack's \`Student/Resources\` folder. It is the coach's responsibility to package these resources into a Resources.zip file and provide it to the students at the start of the hack. You should leave the sample text below in that refers to the Resources.zip file._

***NOTE:** Do NOT provide direct links to files or folders in the What The Hack repository from the student guide. Instead, you should refer to the Resources.zip file provided by the coach.*
**\*NOTE:** Do NOT provide direct links to files or folders in the What The Hack repository from the student guide. Instead, you should refer to the Resources.zip file provided by the coach.\*

***NOTE:** Any direct links to the What The Hack repo will be flagged for review during the review process by the WTH V-Team, including exception cases.*
**\*NOTE:** Any direct links to the What The Hack repo will be flagged for review during the review process by the WTH V-Team, including exception cases.\*

*Sample challenge zero text for the IoT Hack Of The Century:*
_Sample challenge zero text for the IoT Hack Of The Century:_

Now that you have the common pre-requisites installed on your workstation, there are prerequisites specifc to this hack.

Your coach will provide you with a Resources.zip file that contains resources you will need to complete the hack. If you plan to work locally, you should unpack it on your workstation. If you plan to use the Azure Cloud Shell, you should upload it to the Cloud Shell and unpack it there.

Please install these additional tools:

- [Azure IoT Tools](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools) extension for Visual Studio Code
- .NET SDK 6.0 or later installed on your development machine. This can be downloaded from [here](https://www.microsoft.com/net/download/all) for multiple platforms.

Expand All @@ -77,32 +82,32 @@ az group deployment create -g myIoT-rg --name HackEnvironment -f setupIoTEnviron

## Success Criteria

*Success criteria goes here. The success criteria should be a list of checks so a student knows they have completed the challenge successfully. These should be things that can be demonstrated to a coach.*
_Success criteria goes here. The success criteria should be a list of checks so a student knows they have completed the challenge successfully. These should be things that can be demonstrated to a coach._

*The success criteria should not be a list of instructions.*
_The success criteria should not be a list of instructions._

*Success criteria should always start with language like: "Validate XXX..." or "Verify YYY..." or "Show ZZZ..." or "Demonstrate you understand VVV..."*
_Success criteria should always start with language like: "Validate XXX..." or "Verify YYY..." or "Show ZZZ..." or "Demonstrate you understand VVV..."_

*Sample success criteria for the IoT prerequisites challenge:*
_Sample success criteria for the IoT prerequisites challenge:_

To complete this challenge successfully, you should be able to:

- Verify that you have a bash shell with the Azure CLI available.
- Verify that the ARM template has deployed the following resources in Azure:
- Verify that the ARM template has deployed the following resources in Azure:
- Azure IoT Hub
- Virtual Network
- Jumpbox VM

## Learning Resources

*List of relevant links and online articles that should give the attendees the knowledge needed to complete the challenge.*
_List of relevant links and online articles that should give the attendees the knowledge needed to complete the challenge._

*Think of this list as giving the students a head start on some easy Internet searches. However, try not to include documentation links that are the literal step-by-step answer of the challenge's scenario.*
_Think of this list as giving the students a head start on some easy Internet searches. However, try not to include documentation links that are the literal step-by-step answer of the challenge's scenario._

***Note:** Use descriptive text for each link instead of just URLs.*
**\*Note:** Use descriptive text for each link instead of just URLs.\*

*Sample IoT resource links:*
_Sample IoT resource links:_

- [What is a Thingamajig?](https://www.bing.com/search?q=what+is+a+thingamajig)
- [10 Tips for Never Forgetting Your Thingamajic](https://www.youtube.com/watch?v=dQw4w9WgXcQ)
- [IoT & Thingamajigs: Together Forever](https://www.youtube.com/watch?v=yPYZpwSpKmA)

Loading

0 comments on commit f9fb692

Please sign in to comment.