1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
| import pandas as pd
import numpy as np
from datetime import datetime, timedelta
import json
class AwarenessProgramManagement:
def __init__(self):
self.programs = {}
self.audiences = {}
self.content_modules = {}
self.training_sessions = {}
self.assessments = {}
self.metrics = {}
def create_awareness_program(self, program_id, program_config):
"""Create awareness program"""
self.programs[program_id] = {
'program_id': program_id,
'name': program_config['name'],
'description': program_config['description'],
'objectives': program_config.get('objectives', []),
'target_audiences': program_config.get('target_audiences', []),
'duration_months': program_config.get('duration_months', 12),
'frequency': program_config.get('frequency', 'monthly'),
'delivery_methods': program_config.get('delivery_methods', ['online']),
'success_metrics': program_config.get('success_metrics', []),
'status': 'active',
'created_date': datetime.now(),
'last_updated': datetime.now()
}
def define_audience(self, audience_id, audience_config):
"""Define target audience"""
self.audiences[audience_id] = {
'audience_id': audience_id,
'name': audience_config['name'],
'description': audience_config['description'],
'role_level': audience_config.get('role_level', 'general'),
'department': audience_config.get('department', 'all'),
'risk_level': audience_config.get('risk_level', 'medium'),
'specific_needs': audience_config.get('specific_needs', []),
'learning_preferences': audience_config.get('learning_preferences', []),
'size': audience_config.get('size', 0),
'current_knowledge_level': audience_config.get('current_knowledge_level', 'beginner')
}
def create_content_module(self, module_id, module_config):
"""Create content module"""
self.content_modules[module_id] = {
'module_id': module_id,
'title': module_config['title'],
'description': module_config['description'],
'content_type': module_config['content_type'],
'duration_minutes': module_config.get('duration_minutes', 30),
'difficulty_level': module_config.get('difficulty_level', 'intermediate'),
'target_audiences': module_config.get('target_audiences', []),
'learning_objectives': module_config.get('learning_objectives', []),
'content_elements': module_config.get('content_elements', []),
'interactive_elements': module_config.get('interactive_elements', []),
'assessment_questions': module_config.get('assessment_questions', []),
'created_date': datetime.now(),
'version': 1.0
}
def schedule_training_session(self, session_id, session_config):
"""Schedule training session"""
self.training_sessions[session_id] = {
'session_id': session_id,
'program_id': session_config['program_id'],
'module_id': session_config['module_id'],
'audience_id': session_config['audience_id'],
'scheduled_date': session_config['scheduled_date'],
'duration_minutes': session_config.get('duration_minutes', 60),
'delivery_method': session_config.get('delivery_method', 'online'),
'instructor': session_config.get('instructor', 'system'),
'max_participants': session_config.get('max_participants', 50),
'status': 'scheduled',
'participants': [],
'completion_rate': 0.0,
'feedback_score': 0.0
}
def register_participant(self, session_id, participant_data):
"""Register participant in session"""
if session_id not in self.training_sessions:
return False
participant = {
'participant_id': participant_data['participant_id'],
'name': participant_data['name'],
'email': participant_data['email'],
'role': participant_data.get('role', 'employee'),
'department': participant_data.get('department', 'unknown'),
'registration_date': datetime.now(),
'attendance_status': 'registered',
'completion_status': 'pending',
'completion_date': None,
'score': None,
'feedback': None
}
self.training_sessions[session_id]['participants'].append(participant)
return True
def conduct_assessment(self, session_id, assessment_data):
"""Conduct knowledge assessment"""
if session_id not in self.training_sessions:
return False
assessment_id = f"ASSESS-{len(self.assessments) + 1}"
assessment = {
'assessment_id': assessment_id,
'session_id': session_id,
'participant_id': assessment_data['participant_id'],
'questions': assessment_data['questions'],
'answers': assessment_data['answers'],
'score': assessment_data['score'],
'max_score': assessment_data['max_score'],
'percentage': (assessment_data['score'] / assessment_data['max_score'] * 100) if assessment_data['max_score'] > 0 else 0,
'completion_time': assessment_data.get('completion_time', 0),
'timestamp': datetime.now(),
'passed': assessment_data['score'] >= (assessment_data['max_score'] * 0.7) # 70% to pass
}
self.assessments[assessment_id] = assessment
# Update participant status
session = self.training_sessions[session_id]
for participant in session['participants']:
if participant['participant_id'] == assessment_data['participant_id']:
participant['completion_status'] = 'completed' if assessment['passed'] else 'failed'
participant['completion_date'] = datetime.now()
participant['score'] = assessment['percentage']
break
# Update session completion rate
completed_participants = len([p for p in session['participants'] if p['completion_status'] == 'completed'])
total_participants = len(session['participants'])
session['completion_rate'] = (completed_participants / total_participants * 100) if total_participants > 0 else 0
return True
def collect_feedback(self, session_id, feedback_data):
"""Collect participant feedback"""
if session_id not in self.training_sessions:
return False
feedback = {
'feedback_id': f"FEEDBACK-{len(self.training_sessions[session_id].get('feedback', [])) + 1}",
'participant_id': feedback_data['participant_id'],
'rating': feedback_data['rating'], # 1-5 scale
'content_quality': feedback_data.get('content_quality', 0),
'instructor_effectiveness': feedback_data.get('instructor_effectiveness', 0),
'delivery_method': feedback_data.get('delivery_method', 0),
'relevance': feedback_data.get('relevance', 0),
'comments': feedback_data.get('comments', ''),
'suggestions': feedback_data.get('suggestions', ''),
'timestamp': datetime.now()
}
if 'feedback' not in self.training_sessions[session_id]:
self.training_sessions[session_id]['feedback'] = []
self.training_sessions[session_id]['feedback'].append(feedback)
# Update session feedback score
session = self.training_sessions[session_id]
feedback_scores = [f['rating'] for f in session.get('feedback', [])]
if feedback_scores:
session['feedback_score'] = sum(feedback_scores) / len(feedback_scores)
return True
def calculate_program_metrics(self, program_id):
"""Calculate program metrics"""
if program_id not in self.programs:
return None
# Get program sessions
program_sessions = [s for s in self.training_sessions.values() if s['program_id'] == program_id]
if not program_sessions:
return None
# Calculate metrics
total_sessions = len(program_sessions)
total_participants = sum(len(s['participants']) for s in program_sessions)
completed_participants = sum(len([p for p in s['participants'] if p['completion_status'] == 'completed']) for s in program_sessions)
# Calculate rates
completion_rate = (completed_participants / total_participants * 100) if total_participants > 0 else 0
# Calculate average score
all_scores = []
for session in program_sessions:
session_scores = [p['score'] for p in session['participants'] if p['score'] is not None]
all_scores.extend(session_scores)
average_score = sum(all_scores) / len(all_scores) if all_scores else 0
# Calculate average feedback
all_feedback_scores = [s['feedback_score'] for s in program_sessions if s['feedback_score'] > 0]
average_feedback = sum(all_feedback_scores) / len(all_feedback_scores) if all_feedback_scores else 0
# Calculate participation by audience
audience_participation = {}
for session in program_sessions:
audience_id = session['audience_id']
if audience_id not in audience_participation:
audience_participation[audience_id] = 0
audience_participation[audience_id] += len(session['participants'])
metrics = {
'program_id': program_id,
'total_sessions': total_sessions,
'total_participants': total_participants,
'completed_participants': completed_participants,
'completion_rate': completion_rate,
'average_score': average_score,
'average_feedback': average_feedback,
'audience_participation': audience_participation,
'effectiveness_score': self.calculate_effectiveness_score(completion_rate, average_score, average_feedback)
}
return metrics
def calculate_effectiveness_score(self, completion_rate, average_score, average_feedback):
"""Calculate program effectiveness score"""
# Weighting: 40% completion rate, 40% average score, 20% feedback
effectiveness = (completion_rate * 0.4) + (average_score * 0.4) + (average_feedback * 20 * 0.2)
return min(effectiveness, 100) # Maximum 100
def generate_program_report(self, program_id):
"""Generate program report"""
if program_id not in self.programs:
return None
program = self.programs[program_id]
metrics = self.calculate_program_metrics(program_id)
if not metrics:
return None
# Get recent sessions
program_sessions = [s for s in self.training_sessions.values() if s['program_id'] == program_id]
recent_sessions = [s for s in program_sessions if s['scheduled_date'] >= datetime.now() - timedelta(days=30)]
# Trend analysis
trend_analysis = self.analyze_trends(program_sessions)
# Recommendations
recommendations = self.generate_recommendations(metrics, trend_analysis)
report = {
'program_id': program_id,
'program_name': program['name'],
'report_date': datetime.now(),
'metrics': metrics,
'recent_activity': {
'sessions_last_30_days': len(recent_sessions),
'participants_last_30_days': sum(len(s['participants']) for s in recent_sessions)
},
'trend_analysis': trend_analysis,
'recommendations': recommendations,
'status': 'active' if metrics['effectiveness_score'] >= 70 else 'needs_improvement'
}
return report
def analyze_trends(self, sessions):
"""Analyze program trends"""
if len(sessions) < 3:
return {'trend': 'insufficient_data'}
# Sort sessions by date
sorted_sessions = sorted(sessions, key=lambda x: x['scheduled_date'])
# Analyze participation trend
participation_trend = []
for session in sorted_sessions:
participation_trend.append(len(session['participants']))
# Calculate trend using simple linear regression
x = np.arange(len(participation_trend))
y = np.array(participation_trend)
if len(x) > 1:
slope = np.polyfit(x, y, 1)[0]
if slope > 0.1:
trend = 'increasing'
elif slope < -0.1:
trend = 'decreasing'
else:
trend = 'stable'
else:
trend = 'stable'
# Analyze score trend
score_trend = []
for session in sorted_sessions:
session_scores = [p['score'] for p in session['participants'] if p['score'] is not None]
if session_scores:
score_trend.append(sum(session_scores) / len(session_scores))
score_trend_direction = 'stable'
if len(score_trend) > 1:
score_slope = np.polyfit(np.arange(len(score_trend)), score_trend, 1)[0]
if score_slope > 0.1:
score_trend_direction = 'improving'
elif score_slope < -0.1:
score_trend_direction = 'declining'
return {
'participation_trend': trend,
'score_trend': score_trend_direction,
'data_points': len(sessions)
}
def generate_recommendations(self, metrics, trend_analysis):
"""Generate recommendations based on metrics and trends"""
recommendations = []
# Recommendations based on metrics
if metrics['completion_rate'] < 70:
recommendations.append({
'type': 'completion_rate',
'priority': 'high',
'description': f"Improve completion rate - current: {metrics['completion_rate']:.1f}%"
})
if metrics['average_score'] < 70:
recommendations.append({
'type': 'content_quality',
'priority': 'high',
'description': f"Improve content quality - average score: {metrics['average_score']:.1f}"
})
if metrics['average_feedback'] < 3.0:
recommendations.append({
'type': 'delivery_method',
'priority': 'medium',
'description': f"Improve delivery method - average feedback: {metrics['average_feedback']:.1f}/5"
})
# Recommendations based on trends
if trend_analysis['participation_trend'] == 'decreasing':
recommendations.append({
'type': 'engagement',
'priority': 'medium',
'description': "Increase engagement - decreasing participation trend"
})
if trend_analysis['score_trend'] == 'declining':
recommendations.append({
'type': 'content_update',
'priority': 'high',
'description': "Update content - declining score trend"
})
return recommendations
# Example usage
awareness_mgmt = AwarenessProgramManagement()
# Create awareness program
awareness_mgmt.create_awareness_program('PROG-001', {
'name': 'Security Awareness Program 2025',
'description': 'Annual security awareness program',
'objectives': [
'Reduce phishing incidents by 50%',
'Improve security knowledge by 30%',
'Increase incident reporting by 40%'
],
'target_audiences': ['all_employees', 'managers', 'it_staff'],
'duration_months': 12,
'frequency': 'monthly',
'delivery_methods': ['online', 'in_person', 'simulation']
})
# Define audience
awareness_mgmt.define_audience('AUD-001', {
'name': 'All Employees',
'description': 'All organization employees',
'role_level': 'general',
'department': 'all',
'risk_level': 'medium',
'size': 500,
'current_knowledge_level': 'beginner'
})
# Create content module
awareness_mgmt.create_content_module('MOD-001', {
'title': 'Phishing Awareness',
'description': 'Identification and prevention of phishing attacks',
'content_type': 'interactive_module',
'duration_minutes': 45,
'difficulty_level': 'beginner',
'target_audiences': ['AUD-001'],
'learning_objectives': [
'Identify phishing emails',
'Report suspicious emails',
'Apply security best practices'
],
'content_elements': ['videos', 'quizzes', 'simulations'],
'interactive_elements': ['phishing_simulation', 'knowledge_check']
})
# Schedule training session
awareness_mgmt.schedule_training_session('SESS-001', {
'program_id': 'PROG-001',
'module_id': 'MOD-001',
'audience_id': 'AUD-001',
'scheduled_date': datetime.now() + timedelta(days=7),
'delivery_method': 'online',
'max_participants': 50
})
# Register participants
awareness_mgmt.register_participant('SESS-001', {
'participant_id': 'PART-001',
'name': 'John Doe',
'email': 'john.doe@company.com',
'role': 'employee',
'department': 'hr'
})
# Conduct assessment
awareness_mgmt.conduct_assessment('SESS-001', {
'participant_id': 'PART-001',
'questions': 10,
'answers': 8,
'score': 8,
'max_score': 10,
'completion_time': 25
})
# Generate report
report = awareness_mgmt.generate_program_report('PROG-001')
print(f"Program report: {report['program_name']}")
print(f"Effectiveness score: {report['metrics']['effectiveness_score']:.1f}")
|