From e555e5440d6cc5a3cf4110341b32e4285f8e4590 Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Wed, 19 Nov 2025 13:52:54 -0800 Subject: [PATCH] Added a command `gam print course-counts` --- wiki/Classroom-Membership.md | 44 +++++++++++++++++------ wiki/GamUpdates.md | 6 ++++ wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md | 4 +-- wiki/Version-and-Help.md | 12 +++---- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/wiki/Classroom-Membership.md b/wiki/Classroom-Membership.md index 73024341..cbdbceb3 100644 --- a/wiki/Classroom-Membership.md +++ b/wiki/Classroom-Membership.md @@ -172,20 +172,42 @@ for /f "delims=" %a in ('gam print course-participants teacher asmith states act ## Display course counts for teachers-students You can get a count of the number of courses in which a teacher or student is a participant. ``` -gam config csv_output_header_filter profile.emailAddress redirect csv ./Teachers.csv print course-participants states active show teachers -gam config csv_output_header_filter profile.emailAddress redirect csv ./Students.csv print course-participants states active show students +gam print course-counts students|teachers [todrive *] + (course|class )*|([teacher ] [student ] [states ]) + [mincount ] + [formatjson [quotechar ]] ``` +By default, the `print course-counts` command displays participant counts about all courses. -Download the following script: https://github.com/taers232c/GAM-Scripts3/blob/master/CountKeyValues.py +To get participant counts for a specific set of courses, use the following option; it can be repeated to select multiple courses. +* `(course|class )*` - Display courses with the specified ``. -Edit the script. -``` -KEY_FIELD = 'profile.emailAddress' # Set to a column header in KeyValues.csv -MIN_KEY_COUNT = 0 # 0 - Show all counts; N - Show counts >= N -``` +To get participant counts for courses based on their having a particular participant, use the following options. Both options can be specified. +* `teacher ` - Display courses with the specified teacher. +* `student ` - Display courses with the specified student. -Run the script. +To get participant counts for courses based on their state, use the following option. This option can be combined with the `teacher` and `student` options. +By default, all course states are selected. +* `states ` - Display courses with any of the specified states. + +By default, all count values are displayed, use `mincount ` to limit the display to those counts +greater that or equal to the specified ``. + +By default, Gam displays the counts as columns of fields; the following option causes the output to be in JSON format, +* `formatjson` - Display the fields in JSON format. + +By default, when writing CSV files, Gam uses a quote character of double quote `"`. The quote character is used to enclose columns that contain +the quote character itself, the column delimiter (comma by default) and new-line characters. Any quote characters within the column are doubled. +When using the `formatjson` option, double quotes are used extensively in the data resulting in hard to read/process output. +The `quotechar ` option allows you to choose an alternate quote character, single quote for instance, that makes for readable/processable output. +`quotechar` defaults to `gam.cfg/csv_output_quote_char`. When uploading CSV files to Google, double quote `"` should be used. + +### Example +For teachers in all active courses, print the number of classes for which they are a participant. ``` -python ./CountKeyValues.py Teachers.csv TeacherCounts.csv -python ./CountKeyValues.py Students.csv StudentCounts.csv +gam print coursecounts teachers states active +``` +For teachers in all active courses, print the number of classes (if it is >= 5) for which they are a participant. +``` +gam print coursecounts teachers states active mincount 5 ``` diff --git a/wiki/GamUpdates.md b/wiki/GamUpdates.md index a8137ae4..9e149a40 100644 --- a/wiki/GamUpdates.md +++ b/wiki/GamUpdates.md @@ -10,6 +10,12 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads-Installs-GAM7](https://github.com/GAM-team/GAM/wiki/Downloads-Installs) for Windows or other options, including manual installation +### 7.28.10 + +Added a command `gam print course-counts` that dsplays the count of the number of courses in which a teacher or student is a participant. + +* See: https://github.com/GAM-team/GAM/wiki/Classroom-Membership#display-course-counts-for-teachers-students + ### 7.28.09 Fixed bug in `gam print cigroups ... descriptionmatchpattern [not] ` that caused a trap. diff --git a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md index e8c00015..918712bb 100644 --- a/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md +++ b/wiki/How-to-Upgrade-Legacy-GAM-to-GAM7.md @@ -252,7 +252,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin$ gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAM 7.28.09 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.28.10 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.14.0 64-bit final macOS Tahoe 26.1 x86_64 @@ -990,7 +990,7 @@ writes the credentials into the file oauth2.txt. C:\>del C:\GAMConfig\oauth2.txt C:\>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAM 7.28.09 - https://github.com/GAM-team/GAM - pythonsource +GAM 7.28.10 - https://github.com/GAM-team/GAM - pythonsource GAM Team Python 3.14.0 64-bit final Windows 11 10.0.26200 AMD64 diff --git a/wiki/Version-and-Help.md b/wiki/Version-and-Help.md index eae061b7..643c5bbd 100644 --- a/wiki/Version-and-Help.md +++ b/wiki/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAM 7.28.09 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.28.10 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.14.0 64-bit final macOS Tahoe 26.1 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAM 7.28.09 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.28.10 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.14.0 64-bit final macOS Tahoe 26.1 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAM 7.28.09 - https://github.com/GAM-team/GAM - pyinstaller +GAM 7.28.10 - https://github.com/GAM-team/GAM - pyinstaller GAM Team Python 3.14.0 64-bit final macOS Tahoe 26.1 x86_64 @@ -68,7 +68,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gam7 Version Check: Current: 5.35.08 - Latest: 7.28.09 + Latest: 7.28.10 echo $? 1 ``` @@ -76,7 +76,7 @@ echo $? Print the current version number without details ``` gam version simple -7.28.09 +7.28.10 ``` In Linux/MacOS you can do: ``` @@ -86,7 +86,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 7.28.09 - https://github.com/GAM-team/GAM +GAM 7.28.10 - https://github.com/GAM-team/GAM GAM Team Python 3.14.0 64-bit final macOS Tahoe 26.1 x86_64