dynamic_competence_map API Documentation
dcm_assessment
Created on 2024-01-10
@author: wf
Assessment
Assessment for CompetenceTree
Source code in dcm/dcm_assessment.py
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 |
|
__init__(webserver, dcm, learner, debug=False)
initialize the assessment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver(NiceguiWebServer) |
the webserver context |
required | |
dcm(DynamicCompetenceMap) |
the competence map |
required | |
learner(Learner) |
the learner to get the self assessment for |
required | |
debug(bool) |
if True show debugging information |
required |
Source code in dcm/dcm_assessment.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
clear()
clear the ui
Source code in dcm/dcm_assessment.py
198 199 200 201 202 |
|
get_index_str()
get the current achievement index
Source code in dcm/dcm_assessment.py
236 237 238 239 240 241 |
|
reset(dcm, learner)
(re)set the assessment
Parameters:
Name | Type | Description | Default |
---|---|---|---|
webserver(NiceguiWebServer) |
the webserver context |
required | |
dcm(DynamicCompetenceMap) |
the competence map |
required | |
learner(Learner) |
the learner to get the self assessment for |
required |
Source code in dcm/dcm_assessment.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
|
setup_achievements()
Setup achievements based on the competence tree.
This method iterates over the competence aspects and their facets, constructs a path for each facet, and creates an Achievement instance based on the path. These achievements are then added to the learner's achievements list.
Source code in dcm/dcm_assessment.py
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
setup_ui()
display my competence Tree elements
Source code in dcm/dcm_assessment.py
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 |
|
show_progress()
Update the progress bar based on the number of achievements with a non-None level value.
Source code in dcm/dcm_assessment.py
288 289 290 291 292 293 294 295 296 297 298 299 |
|
step(step=0)
step with the achievement view
Source code in dcm/dcm_assessment.py
338 339 340 341 342 |
|
step_area(area_step)
async
Step towards the area given in area_step. For example, 1 means next area, -1 means previous area.
Source code in dcm/dcm_assessment.py
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 |
|
store()
Store the current state of the learner's achievements.
Returns(str): the path to the file
Source code in dcm/dcm_assessment.py
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 |
|
update_achievement_view(step=0)
display the active achievement as the step indicates
Source code in dcm/dcm_assessment.py
344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
update_current_achievement_view()
show the current achievement
Source code in dcm/dcm_assessment.py
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 |
|
ButtonRow
A button row for selecting competence levels to document achievements from a CompetenceTree.
Source code in dcm/dcm_assessment.py
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 |
|
__init__(assessment, competence_tree, achievement=None)
Construct a button row for the competence levels of the given CompetenceTree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assessment |
Assessment
|
The Assessment instance. |
required |
competence_tree |
CompetenceTree
|
The Competence Tree to display buttons for. |
required |
achievement |
Achievement
|
The current achievement of the learner. |
None
|
Source code in dcm/dcm_assessment.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
handle_selection(selected_level)
handle the selected level
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_level(int) |
the selected level |
required |
Source code in dcm/dcm_assessment.py
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 |
|
set_button_states(achievement)
Set the state of buttons based on the given achievement.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
achievement |
Achievement
|
The current achievement of the learner. |
required |
Source code in dcm/dcm_assessment.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
setup_buttons()
Create buttons for each competence level defined in the CompetenceTree.
Source code in dcm/dcm_assessment.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
dcm_chart
Created on 2024-01-12
@author: wf
DcmChart
a Dynamic competence map chart
Source code in dcm/dcm_chart.py
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 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 |
|
__init__(dcm)
Constructor
Source code in dcm/dcm_chart.py
26 27 28 29 30 |
|
add_donut_segment(svg, element, segment, level_color=None, achievement_level=None, ringspec=None)
create a donut segment for the given competence element and add it to the given SVG
if level color is available an achievement needs to be potentially shown
Source code in dcm/dcm_chart.py
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 |
|
calculate_parent_segments(segments, ringspec)
Aggregates child segments into parent segments, calculating the combined start and end angles
for each parent based on its children segments. It uses the create_donut_segment
function to
ensure that newly created parent segments have the correct dimensions according to the specified ringspec
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segments |
Dict[str, DonutSegment]
|
A dictionary of child segments with paths as keys and DonutSegment objects as values. |
required |
ringspec |
RingSpec
|
A RingSpec object specifying the dimensions for the newly created parent segments. |
required |
Returns:
Type | Description |
---|---|
Dict[str, DonutSegment]
|
A dictionary of aggregated parent segments with parent paths as keys and newly created DonutSegment objects as values. |
Source code in dcm/dcm_chart.py
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
calculate_segments(ct, tree_segment)
Pre-calculate the donut segments for each level of the competence tree.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ct |
CompetenceTree
|
A CompetenceTree instance for which segments are to be calculated. |
required |
tree_segment |
DonutSegment
|
A DonutSegment instance representing the whole competence tree. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Dict[str, DonutSegment]]
|
A nested dictionary where the first-level keys are level names (e.g., 'aspect', 'area', 'facet'), |
Dict[str, Dict[str, DonutSegment]]
|
and the second-level keys are element paths with their corresponding DonutSegment objects as values. |
Source code in dcm/dcm_chart.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
|
calculate_sub_segments(ct, parent_segment, level_name, symmetry_mode, elements, lenient=True)
Calculates and returns a dictionary of DonutSegment objects for a given level in the Competence Tree.
This method divides a parent segment into sub-segments based on the number of elements in the specified level, and assigns each sub-segment to the corresponding element's path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ct |
CompetenceTree
|
An instance of CompetenceTree representing the entire competence structure. |
required |
parent_segment |
DonutSegment
|
A DonutSegment instance representing the parent segment within which the sub-segments will be calculated. |
required |
level_name |
str
|
The name of the level (e.g., 'aspect', 'area', 'facet') for which sub-segments are being calculated. |
required |
symmetry_mode |
str
|
The symmetry mode ('symmetric' or 'asymmetric') affecting segment calculation. |
required |
elements |
List[CompetenceElement]
|
A list of CompetenceElement instances at the current level. |
required |
lenient |
bool
|
if True symmetry mode will be adjusted to count in case there are no values |
True
|
Returns: A dictionary where keys are element paths and values are DonutSegment instances representing each element's segment in the visualization.
Source code in dcm/dcm_chart.py
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 442 443 444 445 446 447 448 |
|
create_donut_segment(parent_segment, start_angle, end_angle, ringspec)
Creates a new DonutSegment based on the specified parameters, calculating its inner and outer radii based on SVG configuration and ring specifications.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parent_segment |
DonutSegment
|
The parent segment from which the new segment inherits its center (cx, cy). |
required |
start_angle |
float
|
The starting angle of the new segment. |
required |
end_angle |
float
|
The ending angle of the new segment. |
required |
ringspec |
RingSpec
|
An instance of RingSpec defining the ratios for inner and outer radii, and the text mode. |
required |
Returns:
Name | Type | Description |
---|---|---|
DonutSegment |
DonutSegment
|
A new DonutSegment instance configured as specified. |
Source code in dcm/dcm_chart.py
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 |
|
generate_donut_segment_for_achievement(svg, learner, element, segment)
generate a donut segment for the learner's achievements corresponding to the given path and return it's segment definition
Source code in dcm/dcm_chart.py
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 |
|
generate_donut_segment_for_element(svg, element, learner, segment, ringspec=None)
generate a donut segment for a given element of the CompetenceTree
Source code in dcm/dcm_chart.py
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 |
|
generate_pie_elements_for_segments(svg, ct, segments, learner)
Generate pie elements for the competence tree using pre-calculated segments.
This method will iterate through the provided segments dictionary, using each pre-calculated DonutSegment to generate and render pie elements (e.g., aspects, areas, or facets) based on the learner's achievements.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
svg |
SVG
|
The SVG object where the pie elements will be drawn. |
required |
ct |
CompetenceTree
|
The competence tree structure. |
required |
segments |
Dict[str, Dict[str, DonutSegment]]
|
A nested dictionary where the first key is the level name (e.g., 'aspect', 'area', 'facet'), and the second key is an element's path, mapping to its corresponding DonutSegment. |
required |
learner |
Learner
|
The learner object containing achievement data. |
required |
Source code in dcm/dcm_chart.py
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 |
|
generate_svg(filename=None, learner=None, config=None, text_mode='empty')
Generate the SVG markup and optionally save it to a file. If a filename is given, the method will also save the SVG to that file. The SVG is generated based on internal state not shown here.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
The path to the file where the SVG should be saved. Defaults to None. |
None
|
learner(Learner) |
the learner to show the achievements for |
required | |
config |
SVGConfig
|
The configuration for the SVG canvas and legend. Defaults to default values. |
None
|
text_mode(str) |
text display mode |
required |
Returns: str: The SVG markup.
Source code in dcm/dcm_chart.py
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 |
|
generate_svg_markup(competence_tree=None, learner=None, selected_paths=[], config=None, with_java_script=True, text_mode='empty', lookup_url='')
Generate the SVG markup for the given CompetenceTree and Learner. This method creates an SVG representation of the competence map, which visualizes the structure and levels of competencies, along with highlighting the learner's achievements if provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
competence_tree |
CompetenceTree
|
The competence tree structure to be visualized. If None, the competence tree of the DcmChart instance will be used. Defaults to None. |
None
|
learner |
Learner
|
The learner whose achievements are to be visualized on the competence tree. If None, no learner-specific information will be included in the SVG. Defaults to None. |
None
|
selected_paths |
List
|
A list of paths that should be highlighted in the SVG. These paths typically represent specific competencies or achievements. Defaults to an empty list. |
[]
|
config |
SVGConfig
|
Configuration for the SVG canvas and legend. If None, default configuration settings are used. Defaults to None. |
None
|
text_mode(str) |
text display mode |
required | |
with_java_script |
bool
|
Indicates whether to include JavaScript in the SVG for interactivity. Defaults to True. |
True
|
lookup_url |
str
|
Base URL for linking to detailed descriptions or information about the competence elements. If not provided, links will not be generated. Defaults to an empty string. |
''
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
A string containing the SVG markup for the competence map. |
Raises:
Type | Description |
---|---|
ValueError
|
If there are inconsistencies or issues with the provided data that prevent the creation of a valid SVG. |
Source code in dcm/dcm_chart.py
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
|
get_element_config(element)
get a configuration for the given element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element(CompetenceElement) |
the element |
required |
Return
SVGNodeConfig: an SVG Node configuration
Source code in dcm/dcm_chart.py
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 |
|
get_stacked_segment(level, total_levels, segment, element_config)
Calculate the stacked segment for a given level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level |
int
|
The current level for which to calculate the segment. |
required |
total_levels |
int
|
The total number of levels. |
required |
segment |
DonutSegment
|
The original donut Segment. |
required |
element_config |
SVGNodeConfig
|
The element configuration. |
required |
Returns:
Type | Description |
---|---|
Tuple[DonutSegment, SVGNodeConfig]
|
Tuple[DonutSegment, SVGNodeConfig]: The calculated stacked segment and its configuration for the given level. |
Source code in dcm/dcm_chart.py
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 |
|
prepare_and_add_inner_circle(config, competence_tree, lookup_url=None)
prepare the SVG markup generation and add the inner_circle
Source code in dcm/dcm_chart.py
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 |
|
save_svg_to_file(svg_markup, filename)
Save the SVG content to a file
Source code in dcm/dcm_chart.py
625 626 627 628 629 630 |
|
dcm_cmd
Created on 2023-11-06
@author: wf
CompetenceCmd
Bases: WebserverCmd
Command line for diagrams server
Source code in dcm/dcm_cmd.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
getArgParser(description, version_msg)
override the default argparser call
Source code in dcm/dcm_cmd.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
main(argv=None)
main call
Source code in dcm/dcm_cmd.py
41 42 43 44 45 46 47 48 49 50 |
|
dcm_core
Created on 2023-06-11
@author: wf
Achievement
dataclass
Class representing an individual's achievement level for a specific competence facet.
Attributes:
Name | Type | Description |
---|---|---|
path |
str
|
The path in the CompetenceTree, used to derive tree_id, aspect_id, and facet_id. |
level |
int
|
The achieved level for this facet. |
score |
float
|
How well the achievement was reached. |
score_unit |
str
|
Unit of the score, default is "%". |
evidence |
Optional[str]
|
Optional evidence supporting the achievement. |
date_assessed |
Optional[str]
|
Optional date when the achievement was assessed (ISO-Format). |
Source code in dcm/dcm_core.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
|
CompetenceArea
dataclass
Bases: CompetenceElement
Represents a specific area within a competence aspect, containing various facets.
Attributes:
Name | Type | Description |
---|---|---|
facets |
List[CompetenceFacet]
|
A list of CompetenceFacet objects representing individual facets of this area. |
Source code in dcm/dcm_core.py
139 140 141 142 143 144 145 146 147 148 149 |
|
CompetenceAspect
dataclass
Bases: CompetenceElement
Represents a broader category of competence, which includes various areas.
Attributes:
Name | Type | Description |
---|---|---|
areas |
List[CompetenceArea]
|
A list of CompetenceArea objects representing individual areas of this aspect. |
Source code in dcm/dcm_core.py
152 153 154 155 156 157 158 159 160 161 162 |
|
CompetenceElement
dataclass
A base class representing a generic competence element with common properties.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the competence element. |
short_name(Optional[str]) |
str
|
the label to be displayed |
id |
Optional[str]
|
An optional identifier for the competence element will be set to the name if id is None. |
url |
Optional[str]
|
An optional URL for more information about the competence element. |
description |
Optional[str]
|
An optional description of the competence element. |
color_code |
str
|
A string representing a (fill) color code associated with the competence element. |
border_color |
str
|
A string representing the border color to be used e.g. "black" or "#ffffff" |
Source code in dcm/dcm_core.py
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 |
|
as_html()
convert me to html
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
html markup |
Source code in dcm/dcm_core.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
to_svg_node_config(url=None, **kwargs)
convert me to an SVGNode Configuration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url(str) |
the url to use for clicking this svg node - if None use |
required |
Source code in dcm/dcm_core.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
CompetenceFacet
dataclass
Bases: CompetenceElement
Represents a specific facet of a competence aspect, inheriting from CompetenceElement.
This class can include additional properties or methods specific to a competence facet.
Source code in dcm/dcm_core.py
129 130 131 132 133 134 135 136 |
|
CompetenceLevel
dataclass
Bases: CompetenceElement
Defines a specific level of competence within the framework.
Attributes:
Name | Type | Description |
---|---|---|
level |
int
|
level number starting from 1 as the lowest and going up to as many level as defined for the CompetenceTree |
icon(str) |
int
|
the name of a google mdi icon to be shown for this level |
utf8_icon(str) |
int
|
utf-8 char string to be used as icon |
Source code in dcm/dcm_core.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
CompetenceTree
dataclass
Bases: CompetenceElement
, YamlAble['CompetenceTree']
Represents the entire structure of competencies, including various aspects and levels.
Attributes:
Name | Type | Description |
---|---|---|
lookup_url |
Optional[str]
|
Optional URL for additional information. |
total_levels |
int
|
Total number of levels in the competence hierarchy. |
stacked_levels |
Optional[bool]
|
Indicates whether the levels are stacked. |
aspects |
List[CompetenceAspect]
|
A list of CompetenceAspect objects. |
levels |
List[CompetenceLevel]
|
A list of CompetenceLevel objects. |
element_names |
Dict[str, str]
|
A dictionary holding the names for tree, aspects, facets, and levels. The key is the type ("tree", "aspect", "facet", "level"). |
ring_specs |
Dict[str, RingSpec]
|
Specifications for the rings in the donut chart. |
total_elements |
Dict[str, int]
|
A dictionary holding the total number of elements for each type (aspects, areas, facets). |
Source code in dcm/dcm_core.py
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 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
total_valid_levels: int
property
Calculate the total number of levels excluding levels with a level of 0.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The total number of valid levels. |
__post_init__()
initalize the path variables of my hierarchy
Source code in dcm/dcm_core.py
208 209 210 211 212 213 214 |
|
add_legend(svg)
Add a legend to the SVG explaining the color codes for levels and aspects. Args: svg (SVG): The SVG object to which the legend will be added.
Source code in dcm/dcm_core.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
|
calculate_ring_specs(text_mode)
calculate the ring specifications
Source code in dcm/dcm_core.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
get_elements_for_level(level)
get the elements for the given hierarchy level
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level(int) |
the hierarchy level |
required |
Returns:
Name | Type | Description |
---|---|---|
List |
CompetencElement
|
the list of elements on this level |
Source code in dcm/dcm_core.py
286 287 288 289 290 291 292 293 294 295 296 297 298 |
|
get_level_color(achievement_level)
Retrieve the color associated with a specific achievement level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
achievement_level |
int
|
The level of achievement to get the color for. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The color code associated with the given level, or None if not found. |
Source code in dcm/dcm_core.py
390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
get_symmetry_spec()
Get the symmetry specification from the ring_specs, ensuring only one spec has the symmetry mode set.
Returns:
Type | Description |
---|---|
Tuple[str, str]
|
Tuple[str, str]: A pair of symmetry mode and the level it is applied to. |
Raises:
Type | Description |
---|---|
ValueError
|
If multiple RingSpecs have a symmetry mode set. |
Source code in dcm/dcm_core.py
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 |
|
lookup_by_path(path, lenient=True)
Look up and return a competence element (tree,aspect of facet) based on the given path.
The path is expected to be in the format "tree_id/aspect_id/facet_id". This method parses the path and retrieves the corresponding competence aspect or facet.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
The path in the format "tree_id/aspect_id/facet_id". |
required |
lenient(bool) |
if not lenient raise Exceptions for invalid paths and ids |
required |
Returns: Optional[CompetenceElement]: The competence aspect or facet corresponding to the given path.
Source code in dcm/dcm_core.py
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 |
|
set_symmetry_mode(symmetry_level, symmetry_mode)
Sets a new symmetry mode for a specified level in the competence tree. It resets the symmetry mode for all levels to None and then applies the new symmetry mode to the specified level. This method ensures that only one level has a symmetry mode set at any given time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symmetry_level(str) |
The level to apply the new symmetry mode. Valid levels include "tree", "aspect", "area", and "facet". |
required | |
symmetry_mode |
str
|
The symmetry mode to set for the specified level. Valid modes are "count", "score", and "time". |
required |
Source code in dcm/dcm_core.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
to_pretty_json()
Converts the CompetenceTree object to a pretty JSON string, handling null values.
Source code in dcm/dcm_core.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
update_paths()
update my paths
Source code in dcm/dcm_core.py
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 |
|
DynamicCompetenceMap
a visualization of a competence map
Source code in dcm/dcm_core.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
|
__init__(competence_tree, svg=None)
constructor
Source code in dcm/dcm_core.py
619 620 621 622 623 624 |
|
from_definition_string(name, definition_string, content_class, markup='json', debug=False)
classmethod
Load a DynamicCompetenceMap or Learner instance from a definition string (either JSON or YAML).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
A name identifier for the data source. |
required |
definition_string |
str
|
The string content of the definition. |
required |
content_class |
dataclass_json
|
The class which will be instantiated with the parsed data. |
required |
markup |
str
|
The markup format of the data. Defaults to 'json'. Supported values are 'json' and 'yaml'. |
'json'
|
debug(bool) |
if True supply a JSON dump of the data in /tmp/{name}.json |
required |
Returns: DynamicCompetenceMap: An instance of DynamicCompetenceMap loaded with the parsed data.
Raises:
Type | Description |
---|---|
ValueError
|
If there's an error in parsing the data. |
Source code in dcm/dcm_core.py
743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
|
get_example_dcm_definitions(markup='json', required_keys=None, as_text=True)
classmethod
Retrieve example Dynamic Competence Map (DCM) definitions from files in the specified markup format (either JSON or YAML).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
markup |
str
|
The markup format of the input files. Defaults to 'json'. Supported values are 'json' and 'yaml'. |
'json'
|
required_keys |
Optional[Tuple]
|
A tuple of keys required to validate the data. If not provided, all keys will be considered valid. |
None
|
as_text |
bool
|
If True, returns the file content as text; if False, returns parsed data. Defaults to True. |
True
|
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
A dictionary where each key is the prefix of the file name and the value is the file content as text or parsed data, depending on the value of 'as_text'. |
Raises:
Type | Description |
---|---|
Exception
|
If there's an error in reading or parsing the file, or if the file does not meet the required validation criteria. |
Source code in dcm/dcm_core.py
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
|
parse_markup(text, markup)
classmethod
Parse the given text as JSON or YAML based on the specified markup type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The string content to be parsed. |
required |
markup |
str
|
The type of markup to use for parsing. Supported values are 'json' and 'yaml'. |
required |
Returns:
Type | Description |
---|---|
Union[dict, list]
|
Union[dict, list]: The parsed data, which can be either a dictionary or a list, depending on the content. |
Raises:
Type | Description |
---|---|
ValueError
|
If an unsupported markup format is specified. |
Source code in dcm/dcm_core.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
|
Learner
A learner with achievements. Attributes: learner_id (str): Identifier for the learner. achievements (Dict[str, List[Achievement]]): A dictionary where each key is a competence element identifier and the value is a list of Achievement instances for that tree.
Source code in dcm/dcm_core.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
|
most_recent_achievement_iso_date: Optional[str]
property
Get the most recent achievement date in ISO format.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The ISO date string of the most recent achievement, or None if there are no achievements. |
add_achievement(new_achievement)
Add a new achievement for the learner.
Source code in dcm/dcm_core.py
580 581 582 583 584 585 586 587 |
|
get_competence_tree_ids()
Get all unique competence tree IDs of my achievements.
Returns:
Type | Description |
---|---|
List[str]
|
List[str]: A list of unique competence tree IDs. |
Source code in dcm/dcm_core.py
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
|
RingSpec
dataclass
Specification of rings of the donut chart.
Attributes:
Name | Type | Description |
---|---|---|
text_mode |
Optional[str]
|
The mode of text display on the ring. Default is None. |
inner_ratio |
Optional[float]
|
The inner radius of the ring, relative to the chart size. |
outer_ratio |
Optional[float]
|
The outer radius of the ring, relative to the chart size. |
symmetry_mode |
Optional[str]
|
Specifies the symmetry mode for the ring. Supports "count", "time", "score" to determine how the ring segments are balanced. Default is None. |
Source code in dcm/dcm_core.py
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 |
|
dcm_web
Created on 2024-01-26
@author: wf
RingSpecView
show a single ring specification
Source code in dcm/dcm_web.py
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 |
|
__init__(parent, ring_level, ringspec, throttle=0.1)
construct me
Source code in dcm/dcm_web.py
18 19 20 21 22 23 24 25 26 27 28 29 30 |
|
on_inner_ratio_change(gev)
Handle changes in the inner_ratio slider.
Source code in dcm/dcm_web.py
82 83 84 85 86 87 88 |
|
on_level_visible_change()
Source code in dcm/dcm_web.py
77 78 79 80 |
|
on_outer_ratio_change(gev)
Handle changes in the outer_ratio slider.
Source code in dcm/dcm_web.py
90 91 92 93 94 95 96 |
|
on_text_mode_change(args)
async
handle changes in the text_mode
Source code in dcm/dcm_web.py
98 99 100 101 102 103 104 105 106 107 108 |
|
setup_ui()
setup the user interface
Source code in dcm/dcm_web.py
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 |
|
update(rs)
update the ring specification to be modified by this ui
Source code in dcm/dcm_web.py
66 67 68 69 70 71 72 73 74 75 |
|
RingSpecsView
show a list of ringspecs
Source code in dcm/dcm_web.py
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 |
|
on_change()
if a ring spec trigger update
Source code in dcm/dcm_web.py
184 185 186 187 188 |
|
on_symmetry_change(args)
handle symmetry changes
Source code in dcm/dcm_web.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
setup_ui()
setup the user interface
Source code in dcm/dcm_web.py
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 |
|
update_rings(ct)
update the ring specifications based on the given competence tree
Source code in dcm/dcm_web.py
153 154 155 156 157 158 159 160 161 162 163 |
|
dcm_webserver
Created on 2023-11-06
@author: wf
DcmSolution
Bases: InputWebSolution
the Dynamic Competence Map solution
Source code in dcm/dcm_webserver.py
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 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
__init__(webserver, client)
Initialize the solution
Calls the constructor of the base solution Args: webserver (DynamicCompotenceMapWebServer): The webserver instance associated with this context. client (Client): The client instance this context is associated with.
Source code in dcm/dcm_webserver.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
assess(learner, tree_id=None)
run an assessment for the given learner
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learner(Learner) |
the learner to get the self assessment for |
required | |
tree_id(str) |
the identifier for the competence tree |
required |
Source code in dcm/dcm_webserver.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
|
assess_learner(dcm, learner)
assess the given Dynamic Competence Map and learner
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dcm(DynamicCompetenceMap) |
the competence map |
required | |
learner(Learner) |
the learner to get the self assessment for |
required |
Source code in dcm/dcm_webserver.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
assess_learner_by_slug(learner_slug)
async
Assess a learner based on the slug of the id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learner_slug |
str
|
The unique slug of the learner. |
required |
Raises:
Type | Description |
---|---|
HTTPException
|
If the learner file does not exist or an error occurs. |
Source code in dcm/dcm_webserver.py
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
|
assess_state()
save the session state and reflect in the UI
Source code in dcm/dcm_webserver.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
download(_args)
async
allow downloading the assessment result
Source code in dcm/dcm_webserver.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
get_learner_file_path(learner_slug)
Get the file path for a learner's JSON file based on the learner's slug.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learner_slug |
str
|
The unique slug of the learner. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The file path for the learner's JSON file. |
Source code in dcm/dcm_webserver.py
258 259 260 261 262 263 264 265 266 267 268 |
|
home()
async
Generates the home page with a selection of examples and svg display
Source code in dcm/dcm_webserver.py
426 427 428 429 430 431 432 433 |
|
load_learner(learner_slug)
Load a learner from a JSON file based on the learner's slug.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
learner_slug |
str
|
The unique slug of the learner. |
required |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the learner file does not exist. |
Source code in dcm/dcm_webserver.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
new_assess()
run a new assessment for a new learner
Source code in dcm/dcm_webserver.py
455 456 457 458 459 460 461 462 463 464 465 |
|
on_update_ringspecs()
react on changes in the ringspecs
Source code in dcm/dcm_webserver.py
510 511 512 513 514 515 516 517 |
|
prepare_svg()
prepare the SVG / javascript display
Source code in dcm/dcm_webserver.py
370 371 372 373 374 375 376 377 378 379 |
|
prepare_ui()
prepare the user interface
Source code in dcm/dcm_webserver.py
363 364 365 366 367 368 |
|
render(_click_args=None)
async
Renders the json content as an SVG visualization
Parameters:
Name | Type | Description | Default |
---|---|---|---|
click_args |
object
|
The click event arguments. |
required |
Source code in dcm/dcm_webserver.py
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 |
|
render_dcm(dcm, learner=None, selected_paths=[], clear_assessment=True)
render the dynamic competence map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
selected_paths |
List
|
A list of paths that should be highlighted |
[]
|
Source code in dcm/dcm_webserver.py
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 |
|
save_session_state()
Save the current session state to app.storage.user.
Source code in dcm/dcm_webserver.py
250 251 252 253 254 255 256 |
|
show_ui()
show the ui
Source code in dcm/dcm_webserver.py
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 |
|
DynamicCompentenceMapWebServer
Bases: InputWebserver
server to supply Dynamic Competence Map Visualizations
Source code in dcm/dcm_webserver.py
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 |
|
__init__()
Constructs all the necessary attributes for the WebServer object.
Source code in dcm/dcm_webserver.py
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 |
|
configure_run()
configure the allowed urls
Source code in dcm/dcm_webserver.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
get_config()
classmethod
get the configuration for this Webserver
Source code in dcm/dcm_webserver.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
render_svg(svg_render_request)
async
render the given request
Source code in dcm/dcm_webserver.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
|
show_description(path=None)
async
Show the HTML description of a specific competence element given by the path
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path(str) |
the path identifying the element |
required |
Returns:
Name | Type | Description |
---|---|---|
HTMLResponse |
HTMLResponse
|
The response object containing the HTML-formatted description. |
Raises:
Type | Description |
---|---|
HTTPException
|
If the example name provided does not exist in the examples collection. |
Source code in dcm/dcm_webserver.py
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 |
|
SVGRenderRequest
Bases: BaseModel
A request for rendering an SVG.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the render request. |
definition |
str
|
The string representation of the data to be rendered, in either JSON or YAML format. |
markup |
str
|
The format of the definition ('json' or 'yaml'). |
config |
SVGConfig
|
Optional configuration for SVG rendering. Defaults to None, which uses default settings. |
Source code in dcm/dcm_webserver.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|
linkml
dcm_model
Achievement
dataclass
Bases: YAMLRoot
A record of an achievement attained by a learner.
Source code in dcm/linkml/dcm_model.py
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 |
|
Learner
dataclass
Bases: YAMLRoot
An individual learner with a unique identifier and a list of achievements.
Source code in dcm/linkml/dcm_model.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
radar_chart
Created on 2024-02-05
@author: wf
RadarChart
a radar chart
Source code in dcm/radar_chart.py
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 |
|
add_scale_circles(num_circles=10, stroke_width=1.0, stroke_color='black')
Add concentric circles to the SVG based on the SVG's configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_circles |
int
|
The number of concentric circles to draw. |
10
|
stroke_width |
float
|
The stroke width of the circle lines. |
1.0
|
stroke_color |
str
|
The color of the circle lines. |
'black'
|
Source code in dcm/radar_chart.py
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 |
|
add_scores(scores, config=None)
Add the scores to the radar chart as a polygon.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
List[float]
|
The scores to be represented on the radar chart. |
required |
config |
SVGNodeConfig
|
The configuration for the polygon representing the scores. |
None
|
Source code in dcm/radar_chart.py
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 |
|
calculate_radar_chart_points(scores)
Calculate the points for the radar chart based on the given scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
List[float]
|
The scores to be represented on the radar chart. |
required |
Returns:
Type | Description |
---|---|
List[Tuple[float, float]]
|
List[Tuple[float, float]]: The list of points for the radar chart. |
Source code in dcm/radar_chart.py
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 |
|
svg
DonutSegment
dataclass
Bases: SVGNode
A donut segment representing a section of a donut chart.
Source code in dcm/svg.py
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 |
|
large_arc_flag: str
property
Determine if the arc should be drawn as a large-arc (values >= 180 degrees).
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
"1" if the arc is a large arc, otherwise "0". |
get_arc(radial_offset=0.5)
Get the Arc for the given radial offset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radial_offset(float) |
e.g. 0.0 - inner 1.0 outer 0.5 middle |
required |
Returns: Arc: the arc at the given radial offset
Source code in dcm/svg.py
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 |
|
radial_radius(radial_offset)
get the radial radius for the given radial offset
Source code in dcm/svg.py
176 177 178 179 180 181 182 183 |
|
relative_angle(angle_factor=0.5)
Calculate a relative angle of the donut segment.
Source code in dcm/svg.py
171 172 173 174 |
|
Polygon
dataclass
Bases: SVGNode
A polygon representing a series of data points in a radar chart.
Source code in dcm/svg.py
135 136 137 138 139 140 141 142 |
|
SVG
Class for creating SVG drawings.
Attributes:
Name | Type | Description |
---|---|---|
config |
SVGConfig
|
Configuration for the SVG drawing. |
Source code in dcm/svg.py
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 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 |
|
__init__(config=None)
Initialize SVG object with given configuration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
SVGConfig
|
Configuration for SVG generation. |
None
|
Source code in dcm/svg.py
227 228 229 230 231 232 233 234 235 236 237 238 |
|
add_circle(config)
Add a circle element to the SVG, optionally making it clickable and with a hover effect.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
SVGNodeConfig
|
Configuration for the circle element. |
required |
Source code in dcm/svg.py
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 |
|
add_donut_segment(config, segment)
Add a donut segment to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
SVGNodeConfig
|
Configuration for the donut segment. |
required |
Source code in dcm/svg.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 |
|
add_element(element, indent_level=1, comment=None)
Add an SVG element to the elements list with proper indentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element |
str
|
SVG element to be added. |
required |
indent_level |
int
|
Indentation level for the element. |
1
|
comment(str) |
optional comment to add |
required |
Source code in dcm/svg.py
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
|
add_group(content, group_id=None, group_class=None, indent_level=1, comment=None)
Add a group of elements to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content |
str
|
SVG content to be grouped. |
required |
group_id |
str
|
ID for the group. |
None
|
group_class |
str
|
Class for the group. |
None
|
indent_level |
int
|
Indentation level for the group. |
1
|
Source code in dcm/svg.py
550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 |
|
add_legend_column(items, title, x, y, width, height)
Add a legend column to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
items |
List[Tuple[str, str]]
|
List of tuples with color code and label. |
required |
title |
str
|
Title of the legend. |
required |
x |
int
|
X position of the legend. |
required |
y |
int
|
Y position of the legend. |
required |
width |
int
|
Width of the color box in the legend. |
required |
height |
int
|
Height of each legend item. |
required |
Source code in dcm/svg.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
|
add_polygon(polygon, indent_level=1)
Add a polygon to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polygon |
Polygon
|
The polygon to add to the SVG. |
required |
indent_level |
int
|
Indentation level for the element. |
1
|
Source code in dcm/svg.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
add_rectangle(x, y, width, height, fill=None, indent_level=1)
Add a rectangle element to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
X-coordinate of the rectangle's top-left corner. |
required |
y |
int
|
Y-coordinate of the rectangle's top-left corner. |
required |
width |
int
|
Width of the rectangle. |
required |
height |
int
|
Height of the rectangle. |
required |
fill |
str
|
Fill color of the rectangle. Defaults to the default color. |
None
|
indent_level |
int
|
Indentation level for the rectangle. |
1
|
Source code in dcm/svg.py
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
add_text(x, y, text, fill='black', font_weight='normal', text_anchor='start', transform='', center_v=False, text_class='noclick', indent_level=1)
Add text to the SVG.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
int
|
X position of the text. |
required |
y |
int
|
Y position of the text. |
required |
text(str) |
Text content. |
required | |
fill |
str
|
Fill color of the text. Defaults to "black". |
'black'
|
font_weight |
str
|
Font weight (normal, bold, etc.). Defaults to "normal". |
'normal'
|
text_anchor |
str
|
Text alignment (start, middle, end). Defaults to "start". |
'start'
|
indent_level(int) |
the indentation level to apply |
required | |
center_v |
bool
|
If True, y as the vertical center of the text. Default is False. |
False
|
text_class(str) |
"noclick" by default so that elements below are clickable |
required | |
transform |
str
|
Transformation for the text (e.g., rotation). Defaults to an empty string. |
''
|
Source code in dcm/svg.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
add_text_to_donut_segment(segment, text, direction='horizontal', color='white', text_class='noclick', indent_level=1)
Add text to a donut segment with various direction options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
DonutSegment
|
The donut segment to which text will be added. |
required |
text |
str
|
The text content to be added. |
required |
direction |
str
|
The direction in which the text should be drawn. Options are "horizontal", "angled", or "curved". |
'horizontal'
|
color |
str
|
The color of the text. Default is "white". |
'white'
|
Source code in dcm/svg.py
633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
|
get_donut_path(segment, radial_offset=0.5, middle_arc=False)
Create an SVG path definition for an arc using the properties of a DonutSegment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
segment |
DonutSegment
|
The segment for which to create the path. |
required |
radial_offset(float) |
0 to 1 - useable in middle_arc mode |
required | |
middle_arc(bool) |
if True get the middle arc |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
SVG path definition string for the full donut segment or the middle_arc if middle_arc is set to true. |
Source code in dcm/svg.py
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 |
|
get_indent(level)
get the indentation for the given level
Source code in dcm/svg.py
240 241 242 243 244 245 |
|
get_java_script()
get the java script code for interactive behavior
Source code in dcm/svg.py
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
get_svg_markup(with_java_script=False)
Generate the complete SVG markup.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
with_java_script(bool) |
if True(default) the javascript code is included otherwise |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
String containing the complete SVG markup. |
Source code in dcm/svg.py
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 |
|
get_svg_style()
Define styles for SVG elements.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
String containing style definitions for SVG. |
Source code in dcm/svg.py
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 |
|
get_text_rotation(rotation_angle)
Adjusts the rotation angle for SVG text elements to ensure that the text is upright and readable in a circular chart. The text will be rotated by 180 degrees if it is in the lower half of the chart (between 90 and 270 degrees).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rotation_angle |
float
|
The initial rotation angle of the text element. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The adjusted rotation angle for the text element. |
Source code in dcm/svg.py
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
|
get_text_width(text)
Estimate the width of a text string in the SVG based on the font size and font name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text content. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The estimated width of the text in pixels. |
Source code in dcm/svg.py
288 289 290 291 292 293 294 295 296 297 298 299 300 |
|
save(filename)
Save the SVG markup to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Filename to save the SVG markup. |
required |
Source code in dcm/svg.py
797 798 799 800 801 802 803 804 805 |
|
SVGConfig
dataclass
Configuration class for SVG generation.
Attributes:
Name | Type | Description |
---|---|---|
width |
int
|
Width of the SVG canvas in pixels. |
height |
int
|
Height of the SVG canvas in pixels. |
legend_height |
int
|
Height reserved for the legend in pixels. |
font |
str
|
Font family for text elements. |
font_size |
int
|
Font size in points for text elements. |
indent |
str
|
Indentation string, default is two spaces. |
default_color |
str
|
Default color code for SVG elements. |
with_pop(bool) |
str
|
if True support popup javascript functionality |
Source code in dcm/svg.py
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 |
|
total_height: int
property
Calculate total height of the SVG canvas including the legend.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Total height of the SVG canvas. |
SVGNode
dataclass
a generic SVG Node
Source code in dcm/svg.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
SVGNodeConfig
dataclass
Bases: SVGNode
a single SVG Node configuration to display any element
Source code in dcm/svg.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|
Text
dataclass
Class to handle text-related operations in SVG.
Attributes:
Name | Type | Description |
---|---|---|
text |
str
|
The text content. |
config |
SVGConfig
|
Configuration for SVG generation. |
Source code in dcm/svg.py
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 |
|
total_text_height: float
property
Calculate the total height of the text based on the number of lines and the line height.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The total height of the text in pixels. |
__post_init__()
Post-initialization processing to split the text into lines.
Source code in dcm/svg.py
100 101 102 103 104 |
|
version
Created on 2023-11-06
@author: wf
Version
dataclass
Version handling for nicepdf
Source code in dcm/version.py
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 |
|
xapi
Created on 2024-01-24
Experience API xAPI support module @author: wf
XAPI
Experience API xAPI support class
Source code in dcm/xapi.py
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 |
|
to_learner(competence_tree)
Convert xapi_dict to a Learner with Achievements. Args: competence_tree (CompetenceTree): The competence tree to align the achievements with. Returns: Learner: A learner object with achievements mapped from xapi_dict.
Source code in dcm/xapi.py
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 |
|