Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 84 additions & 0 deletions .github/workflows/autograder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: C++ Classroom Autograder

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential

- name: Create build directory
run: mkdir build

- name: Configure CMake
run: cd build && cmake ..

- name: Build
run: cd build && make

- name: Run tests
run: cd build && ctest --output-on-failure

- name: Run assignment executables
run: |
echo "Running Assignment 1:"
cd build && ./assignments/assignment1/assignment1

grade-assignment:
needs: build-and-test
runs-on: ubuntu-latest
if: always()

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake build-essential

- name: Build and test with detailed output
id: test
run: |
mkdir build
cd build
cmake ..
make
echo "TESTS_OUTPUT<<EOF" >> $GITHUB_OUTPUT
ctest --verbose >> $GITHUB_OUTPUT || echo "Tests failed" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Generate Grade Report
run: |
echo "# πŸ“Š Autograding Report" >> grade_report.md
echo "" >> grade_report.md
echo "## Build Status: βœ… PASSED" >> grade_report.md
echo "" >> grade_report.md
echo "## Test Results:" >> grade_report.md
echo '```' >> grade_report.md
cd build && ctest --verbose || echo "Some tests failed"
echo '```' >> grade_report.md
echo "" >> grade_report.md
echo "## πŸ’‘ Tips for Improvement:" >> grade_report.md
echo "- Ensure all functions are implemented correctly" >> grade_report.md
echo "- Check that your code handles edge cases" >> grade_report.md
echo "- Make sure to follow the function signatures in the header file" >> grade_report.md

- name: Upload grade report
uses: actions/upload-artifact@v4
with:
name: grade-report
path: grade_report.md
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# C++ build artifacts
build/
*.o
*.obj
*.exe
*.dll
*.so
*.a
*.lib

# CMake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
Makefile
*.cmake
!CMakeLists.txt

# IDE files
.vscode/
.idea/
*.vcxproj*
*.sln
*.suo
*.user

# Test results
test_results/
*.xml

# OS files
.DS_Store
Thumbs.db

# Temporary files
*.tmp
*.temp
*~
33 changes: 33 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 3.14)
project(CPPClassroom)

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add compiler flags for better error messages and debugging
set(CMAKE_CXX_FLAGS "-Wall -Wextra -g")

# Include FetchContent for downloading dependencies
include(FetchContent)

# Fetch Google Test
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG release-1.12.1
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Enable testing
enable_testing()

# Add subdirectories for assignments
add_subdirectory(assignments/assignment1)

# Optionally add more assignments as they are created
# add_subdirectory(assignments/assignment2)
# add_subdirectory(assignments/assignment3)
200 changes: 200 additions & 0 deletions INSTRUCTOR_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# πŸ‘¨β€πŸ« Instructor Guide - C++ Classroom

## Overview
This repository has been set up as a complete C++ programming classroom with automated testing and grading capabilities. Students can submit assignments and receive instant feedback through GitHub Actions.

## 🎯 Key Features
- βœ… **Automated Testing**: Unit tests run on every commit/push
- βœ… **Professional Build System**: CMake + Google Test framework
- βœ… **Instant Feedback**: Grade reports generated automatically
- βœ… **Scalable**: Easy to add new assignments
- βœ… **Student-Friendly**: Helper scripts and clear documentation

## πŸ“ Repository Structure

```
β”œβ”€β”€ assignments/
β”‚ └── assignment1/ # Example: Hello World with Functions
β”‚ β”œβ”€β”€ src/ # Student code goes here
β”‚ β”œβ”€β”€ include/ # Header files
β”‚ β”œβ”€β”€ tests/ # Unit tests (instructor-created)
β”‚ β”œβ”€β”€ CMakeLists.txt # Build config
β”‚ └── README.md # Assignment instructions
β”œβ”€β”€ template/ # Template for creating new assignments
β”œβ”€β”€ .github/workflows/ # GitHub Actions for autograding
β”œβ”€β”€ CMakeLists.txt # Root build configuration
β”œβ”€β”€ run_tests.sh # Student helper script
└── README.md # Student documentation
```

## πŸš€ Quick Start for Instructors

### Adding New Assignments

1. **Copy the template:**
```bash
cp -r template assignments/assignment2
cd assignments/assignment2
```

2. **Customize the assignment:**
- Edit `CMakeLists.txt`: Change `ASSIGNMENT_NAME` to "assignment2"
- Write assignment code in `src/` and `include/`
- Create comprehensive tests in `tests/`
- Update `README.md` with assignment instructions

3. **Add to build system:**
```cmake
# In root CMakeLists.txt, add:
add_subdirectory(assignments/assignment2)
```

4. **Test locally:**
```bash
./run_tests.sh assignment2
```

### Example Assignment Structure
The included Assignment 1 demonstrates:
- **Function declarations** in header files (`include/hello.h`)
- **Implementation** in source files (`src/hello.cpp`)
- **Main program** (`src/main.cpp`)
- **Comprehensive unit tests** (`tests/test_hello.cpp`)

## πŸ§ͺ Testing Strategy

### Unit Tests (Google Test)
- Test individual functions with various inputs
- Include edge cases (empty strings, negative numbers, etc.)
- Verify return types and expected behavior
- Example test structure:
```cpp
TEST(AssignmentTest, FunctionName) {
EXPECT_EQ(myFunction(input), expected_output);
EXPECT_TRUE(boolFunction(input));
}
```

### Integration Tests
- Test complete program functionality
- Verify all components work together
- Can be added to the same test files

## πŸ“Š Autograding System

### GitHub Actions Workflow
Located in `.github/workflows/autograder.yml`:

1. **Build Phase**: Compiles all assignments with CMake
2. **Test Phase**: Runs all unit tests with CTest
3. **Execution Phase**: Runs assignment executables
4. **Reporting**: Generates grade reports and artifacts

### Viewing Results
Students can see results in:
- **GitHub Actions tab**: Full build and test logs
- **Artifacts**: Downloadable grade reports
- **Console output**: Immediate feedback on failures

### Customizing Grading
- Modify point distribution in workflow file
- Add custom grading logic in test files
- Create rubric-based assessments

## πŸ‘₯ Student Workflow

1. **Clone repository** (already done via GitHub Classroom)
2. **Navigate to assignment** folder
3. **Read instructions** in assignment README
4. **Implement solution** in designated files
5. **Test locally** with `./run_tests.sh`
6. **Submit via git**: `git add . && git commit -m "Solution" && git push`
7. **View results** in GitHub Actions

## πŸ”§ Maintenance

### Adding Dependencies
To add C++ libraries:
```cmake
# In CMakeLists.txt
FetchContent_Declare(
library_name
GIT_REPOSITORY https://github.com/user/library.git
GIT_TAG version
)
FetchContent_MakeAvailable(library_name)
```

### Updating Test Framework
The system uses Google Test 1.12.1. To update:
```cmake
# In root CMakeLists.txt, change:
GIT_TAG release-1.14.0 # or newer version
```

### Platform Compatibility
Current setup supports:
- βœ… Linux (Ubuntu 20.04+)
- βœ… macOS (with Xcode command line tools)
- βœ… Windows (with Visual Studio or MinGW)

## πŸ“‹ Assignment Ideas

### Beginner Level
- **Assignment 1** (included): Functions, strings, basic I/O
- **Variables and Types**: Data type exploration
- **Control Flow**: Loops, conditionals, switch statements
- **Arrays**: Basic array manipulation

### Intermediate Level
- **Classes and Objects**: OOP fundamentals
- **Dynamic Memory**: Pointers and memory management
- **File I/O**: Reading/writing files
- **STL Containers**: Vector, map, set usage

### Advanced Level
- **Templates**: Generic programming
- **Exception Handling**: Error management
- **Multi-threading**: Basic parallelism
- **Design Patterns**: Common programming patterns

## πŸ› οΈ Troubleshooting

### Common Issues

**Build Failures:**
- Check CMakeLists.txt syntax
- Verify all source files are included
- Ensure proper include paths

**Test Failures:**
- Review test logic and expected outputs
- Check for missing edge cases
- Verify function signatures match headers

**GitHub Actions Issues:**
- Check workflow YAML syntax
- Verify Ubuntu package names in dependencies
- Monitor action execution logs

### Getting Help
- Review GitHub Actions logs for detailed error messages
- Test locally before pushing to identify issues early
- Use the included `run_tests.sh` for consistent local testing

## πŸ“ˆ Scaling the Classroom

### For Larger Classes
- Use GitHub Teams for group assignments
- Implement branch protection rules
- Consider submission deadlines in workflow

### Advanced Features
- Add code quality checks (linting, static analysis)
- Implement plagiarism detection
- Create performance benchmarking tests
- Add documentation generation

---

**Happy Teaching! πŸŽ“** This system is designed to scale with your needs and provide students with immediate, actionable feedback on their C++ programming assignments.
Loading