updated project 2
This commit is contained in:
@@ -11,10 +11,9 @@ declare -A CHALLENGE_CATEGORIES=(
|
||||
["net"]="Network Operations"
|
||||
)
|
||||
|
||||
# Challenge definitions with detailed metadata
|
||||
# Challenge definitions with metadata
|
||||
# Format: type|name|difficulty|skills|task|hints|setup_requirements|verification_criteria
|
||||
declare -A CHALLENGES=(
|
||||
# Level 1: File Operations
|
||||
["1.1"]="file_search|Find Recent Files|1|file_ops,search|Find all .conf files modified in the last 24 hours and save the list to recent_configs.txt|Try using find with -mtime|none|output_file=recent_configs.txt;file_count=10"
|
||||
["1.2"]="file_count|File Statistics|1|file_ops,search|Generate a report showing count of files by extension|Consider using find and awk|none|report_exists=true;extension_count=5"
|
||||
["1.3"]="file_organize|Smart File Organizer|2|file_ops|Create directories for different file types and sort files accordingly|Look into file command|none|dir_structure=complete;files_sorted=true"
|
||||
@@ -223,18 +222,18 @@ calculate_bonus_points() {
|
||||
echo $((time_bonus + efficiency_bonus))
|
||||
}
|
||||
|
||||
# Get challenge details with color formatting
|
||||
# Get challenge details
|
||||
get_challenge_details() {
|
||||
local challenge_id=$1
|
||||
IFS='|' read -r type name difficulty skills task hints requirements _ <<< "${CHALLENGES[$challenge_id]}"
|
||||
|
||||
cat << EOF
|
||||
${BOLD}Challenge ${challenge_id}${NC}: ${YELLOW}$name${NC}
|
||||
${BLUE}Difficulty${NC}: $(printf '★%.0s' $(seq 1 "$difficulty"))
|
||||
${BLUE}Skills${NC}: $skills
|
||||
${BLUE}Task${NC}: $task
|
||||
${BLUE}Hint${NC}: $hints
|
||||
EOF
|
||||
if [[ -n "${CHALLENGES[$challenge_id]:-}" ]]; then
|
||||
IFS='|' read -r type name difficulty skills task hints requirements criteria <<< "${CHALLENGES[$challenge_id]}"
|
||||
echo -e "${BLUE}Challenge $challenge_id:${NC} $name"
|
||||
echo -e "${BLUE}Difficulty:${NC} $(printf '★%.0s' $(seq 1 "$difficulty"))"
|
||||
echo -e "${BLUE}Skills:${NC} $skills"
|
||||
echo -e "${BLUE}Task:${NC} $task"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Update challenge status
|
||||
@@ -254,10 +253,10 @@ update_challenge_status() {
|
||||
|
||||
# List available challenges
|
||||
list_challenges() {
|
||||
echo -e "\n${BOLD}Available Challenges:${NC}"
|
||||
echo -e "\n${BLUE}Available Challenges:${NC}"
|
||||
for challenge_id in "${!CHALLENGES[@]}"; do
|
||||
IFS='|' read -r type name difficulty skills task hints requirements _ <<< "${CHALLENGES[$challenge_id]}"
|
||||
if ! is_challenge_completed "$challenge_id"; then
|
||||
IFS='|' read -r type name difficulty skills task _ <<< "${CHALLENGES[$challenge_id]}"
|
||||
echo -e "\n${YELLOW}Challenge $challenge_id${NC} ($difficulty★)"
|
||||
echo "Type: $type"
|
||||
echo "Skills: $skills"
|
||||
|
||||
@@ -60,18 +60,8 @@ log_message() {
|
||||
local severity=$1
|
||||
local message=$2
|
||||
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
local color
|
||||
|
||||
case $severity in
|
||||
"INFO") color=$BLUE ;;
|
||||
"SUCCESS") color=$GREEN ;;
|
||||
"WARNING") color=$YELLOW ;;
|
||||
"ERROR") color=$RED ;;
|
||||
*) color=$NC ;;
|
||||
esac
|
||||
|
||||
echo -e "${color}[$severity]${NC} $message"
|
||||
echo "[$timestamp] [$severity] $message" >> "$LOG_FILE"
|
||||
echo "[$timestamp] [$severity] $message" >> "$DATA_DIR/challenge.log"
|
||||
echo -e "${BLUE}[$severity]${NC} $message"
|
||||
}
|
||||
|
||||
# Initialize environment with comprehensive setup
|
||||
@@ -254,6 +244,14 @@ show_recommendations() {
|
||||
# Check if challenge is completed
|
||||
is_challenge_completed() {
|
||||
local challenge=$1
|
||||
grep -q "^$challenge," "$SCORE_FILE" && return 0
|
||||
return 1
|
||||
grep -q "^$challenge," "$SCORE_FILE"
|
||||
return $?
|
||||
}
|
||||
|
||||
# Award points function
|
||||
award_points() {
|
||||
local challenge=$1
|
||||
local points=$2
|
||||
echo "$challenge,$points,$(date +%s)" >> "$SCORE_FILE"
|
||||
log_message "INFO" "Awarded $points points for challenge $challenge"
|
||||
}
|
||||
@@ -5,36 +5,30 @@ source "$(dirname "$0")/common.sh"
|
||||
|
||||
# Challenge-specific setup
|
||||
setup_file_challenges() {
|
||||
log_message "Setting up file system challenges..."
|
||||
log_message "INFO" "Setting up file system challenges..."
|
||||
|
||||
# Create complex directory structure
|
||||
for dir in {1..5}; do
|
||||
mkdir -p "$CHALLENGE_DIR/files/project$dir/{src,config,logs,data}"
|
||||
# Create project directories
|
||||
for i in {1..5}; do
|
||||
mkdir -p "$CHALLENGE_DIR/files/project$i"/{src,config,logs,data}
|
||||
|
||||
# Create various file types
|
||||
touch "$CHALLENGE_DIR/files/project$dir/src/main.py"
|
||||
touch "$CHALLENGE_DIR/files/project$dir/src/test.py"
|
||||
echo "debug=true" > "$CHALLENGE_DIR/files/project$dir/config/settings.conf"
|
||||
touch "$CHALLENGE_DIR/files/project$i/src/main.py"
|
||||
touch "$CHALLENGE_DIR/files/project$i/src/test.py"
|
||||
echo "debug=true" > "$CHALLENGE_DIR/files/project$i/config/settings.conf"
|
||||
|
||||
# Create log files with realistic content
|
||||
for severity in INFO WARN ERROR DEBUG; do
|
||||
for i in {1..10}; do
|
||||
echo "[$(date -d "@$(($(date +%s) - RANDOM % 86400))" '+%Y-%m-%d %H:%M:%S')] [$severity] Message $i" >> "$CHALLENGE_DIR/files/project$dir/logs/app.log"
|
||||
for j in {1..10}; do
|
||||
echo "[$(date -d "@$(($(date +%s) - RANDOM % 86400))" '+%Y-%m-%d %H:%M:%S')] [$severity] Message $j" >> "$CHALLENGE_DIR/files/project$i/logs/app.log"
|
||||
done
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
setup_permission_challenges() {
|
||||
log_message "Setting up permission challenges..."
|
||||
log_message "INFO" "Setting up permission challenges..."
|
||||
|
||||
# Create test users and groups
|
||||
for i in {1..3}; do
|
||||
sudo groupadd -f "app_group$i" 2>/dev/null
|
||||
sudo useradd -M -N -g "app_group$i" "app_user$i" 2>/dev/null
|
||||
done
|
||||
|
||||
# Create files with specific permissions
|
||||
# Create test files with specific permissions
|
||||
mkdir -p "$CHALLENGE_DIR/files/permissions_test"
|
||||
for i in {1..5}; do
|
||||
echo "content$i" > "$CHALLENGE_DIR/files/permissions_test/file$i.txt"
|
||||
@@ -159,7 +153,7 @@ main() {
|
||||
create_verification_functions
|
||||
create_challenge_tracker
|
||||
|
||||
log_message "Challenge environment ready!"
|
||||
log_message "SUCCESS" "Level 1 Setup Complete!"
|
||||
cat << EOF
|
||||
${GREEN}Level 1 Setup Complete!${NC}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user