I've previously blogged about how to make Google Classrooms and sync them from Capita SIMS using GAM - you can see that post here. However, that post required groups made by Hapara Teacher Dashboard to work. What if you don't want or cannot afford a paid-for solution? Well, a couple of scripts will allow you to to do this.
I've gone through the process in this video:
Script to clean out "s from SIMS output (run in the path oif the script):
$Path = "c:\gam\hapara\students.csv"
(Import-CSV -Path $Path) | Select-Object -Property 'Email', 'Class Code', 'UID'| Export-CSV -Path C:\gam\hapara\classroom\students.csv -notype
(gc C:\GAM\hapara\classroom\students.csv) | % {$_ -replace '"', ""} | out-file C:\GAM\hapara\classroom\students.csv -Fo -En ascii
py classes.py
Change the file names and paths to suit yourself.
The Python code
def readStudents(infile):
students = []
try:
studentFile = open(infile, "r")
for line in studentFile:
student = line.split(",")
student[2] = student[2].replace("\n", "")
students.append(student)
except IOError:
print("Couldn't read CSV file!")
finally:
if "studentFile" in locals():
studentFile.close()
return students
def findUniqueClasses(students):
uniqueClasses = []
for i in range(1, len(students)):
if not students[i][1] in uniqueClasses:
uniqueClasses.append(students[i][1])
return uniqueClasses
def findStudentsInClasses(uniqueClasses, students):
studentsInClasses = []
for theClass in uniqueClasses:
studentsInClass = [theClass, ""]
for i in range(len(students)):
if students[i][1] == theClass:
# studentsInClass[1] = studentsInClass[1] + students[i][0] + "," + theClass + "\n"
studentsInClass[1] = studentsInClass[1] + students[i][0] + "\n"
studentsInClasses.append(studentsInClass)
return studentsInClasses
def createClassFiles(studentsInClasses):
for className in studentsInClasses:
try:
newFile = open(className[0] + ".csv", "w")
newFile.writelines(className[1])
except IOError:
print("Couldn't save the class file!" + className[0])
finally:
if "newFile" in locals():
newFile.close()
if __name__ == "__main__":
infile = "students.csv"
students = readStudents(infile)
createClassFiles(findStudentsInClasses(findUniqueClasses(students), students))
Again - this might need modding based on your file names. Code produced by my son Robert Nixon.
And finally, sync to classroom vis the following PowerShell (run in your GAM directory)
$list = Import-Csv C:\GAM\groups.csv
foreach ($entry in $list)
{
.\gam.exe course $($entry.group) sync students file $($entry.file)
}
exit
Again mod paths and filenames to suit you.
To get this working in any specific environment will take a little work - but once done - will run as scheduled tasks for as long as you want without issue or cost.
I've gone through the process in this video:
Script to clean out "s from SIMS output (run in the path oif the script):
$Path = "c:\gam\hapara\students.csv"
(Import-CSV -Path $Path) | Select-Object -Property 'Email', 'Class Code', 'UID'| Export-CSV -Path C:\gam\hapara\classroom\students.csv -notype
(gc C:\GAM\hapara\classroom\students.csv) | % {$_ -replace '"', ""} | out-file C:\GAM\hapara\classroom\students.csv -Fo -En ascii
py classes.py
Change the file names and paths to suit yourself.
The Python code
def readStudents(infile):
students = []
try:
studentFile = open(infile, "r")
for line in studentFile:
student = line.split(",")
student[2] = student[2].replace("\n", "")
students.append(student)
except IOError:
print("Couldn't read CSV file!")
finally:
if "studentFile" in locals():
studentFile.close()
return students
def findUniqueClasses(students):
uniqueClasses = []
for i in range(1, len(students)):
if not students[i][1] in uniqueClasses:
uniqueClasses.append(students[i][1])
return uniqueClasses
def findStudentsInClasses(uniqueClasses, students):
studentsInClasses = []
for theClass in uniqueClasses:
studentsInClass = [theClass, ""]
for i in range(len(students)):
if students[i][1] == theClass:
# studentsInClass[1] = studentsInClass[1] + students[i][0] + "," + theClass + "\n"
studentsInClass[1] = studentsInClass[1] + students[i][0] + "\n"
studentsInClasses.append(studentsInClass)
return studentsInClasses
def createClassFiles(studentsInClasses):
for className in studentsInClasses:
try:
newFile = open(className[0] + ".csv", "w")
newFile.writelines(className[1])
except IOError:
print("Couldn't save the class file!" + className[0])
finally:
if "newFile" in locals():
newFile.close()
if __name__ == "__main__":
infile = "students.csv"
students = readStudents(infile)
createClassFiles(findStudentsInClasses(findUniqueClasses(students), students))
Again - this might need modding based on your file names. Code produced by my son Robert Nixon.
And finally, sync to classroom vis the following PowerShell (run in your GAM directory)
$list = Import-Csv C:\GAM\groups.csv
foreach ($entry in $list)
{
.\gam.exe course $($entry.group) sync students file $($entry.file)
}
exit
Again mod paths and filenames to suit you.
To get this working in any specific environment will take a little work - but once done - will run as scheduled tasks for as long as you want without issue or cost.
Comments
Post a Comment