Skip to content

Commit

Permalink
Begin implementation of setupShareFolders() function
Browse files Browse the repository at this point in the history
  • Loading branch information
sjsyrek committed Jan 31, 2016
1 parent 6209902 commit 45dbd84
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
60 changes: 46 additions & 14 deletions src/Exposify.gs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@


//TODO: rewrite functions for folder sharing, collecting and returning assignments
//TODO: write warning roster functions
//TODO: make error messages and alert windows more informative
//TODO: revise comments
//TODO: create nicer finish window for Create Folder Structure
//TODO: add tab indexes to dialogs


/**
Expand Down Expand Up @@ -96,17 +92,17 @@ var MIME_TYPE_GOOGLE_SHEET = 'application/vnd.google-apps.spreadsheet';
/**
* Default text to display for various alert messages throughout the application.
*/
var ALERT_INSTALL_THANKS = 'Thanks for installing Exposify! Add a new section by selecting \"Setup New Expos Section\" in the Exposify menu.';
var ALERT_INSTALL_THANKS = 'Thanks for installing Exposify! Add a section to your gradebook by selecting "Setup new Gradebook" in the Exposify "Setup" menu.';
var ALERT_ASSIGNMENTS_CREATE_TEMPLATES_SUCCESS = 'New document files successfully created for the students in section $.';
var ALERT_ADMIN_GENERATE_GRADEBOOK_SUCCESS = 'New gradebook file for "$" successfully created!';
var ALERT_ADMIN_GENERATE_WARNING_ROSTER_SUCCESS = 'Warning roster for "$" successfully created!';
var ALERT_ADMIN_GENERATE_GRADEBOOK_SUCCESS = 'New gradebook file for $ successfully created!';
var ALERT_ADMIN_GENERATE_WARNING_ROSTER_SUCCESS = 'Warning roster for section $ successfully created!';
var ALERT_ADMIN_NO_WARNINGS = 'There are no warnings to issue for this section!';
var ALERT_NO_GRADEBOOK = 'You have not set up a gradebook yet for this sheet. Do that before anything else.';
var ALERT_SETUP_ADD_STUDENTS_SUCCESS = '\'$\' successfully imported! You should double-check the spreadsheet to make sure it\'s correct.';
var ALERT_SETUP_CREATE_CONTACTS_SUCCESS = 'New contact group successfully created for $.';
var ALERT_SETUP_SHARE_FOLDERS_MISSING_COURSE_FOLDER = 'There is no course folder for this course. Use the Create Folder Structure command to create one before executing this command.';
var ALERT_SETUP_SHARE_FOLDERS_MISSING_GRADED_FOLDER = 'There is no folder for graded papers for this course. Use the Create Folder Structure command to create one before executing this command.';
var ALERT_SETUP_SHARE_FOLDERS_SUCCESS = 'The folders were successfully shared!';
var ALERT_SETUP_SHARE_FOLDERS_MISSING_GRADED_FOLDER = 'The course folder was successfully shared, but there is no folder for graded papers for this course. Use the Create Folder Structure command to create one before executing this command again.';
var ALERT_SETUP_SHARE_FOLDERS_SUCCESS = 'The course folders for section $ were successfully shared!';
var ALERT_SETUP_NEW_GRADEBOOK_ALREADY_EXISTS = 'A gradebook for section $ already exists. If you want to overwrite it, make it the active spreadsheet and try again.';
var ALERT_SETUP_NEW_GRADEBOOK_SUCCESS = 'New gradebook created for $.';

Expand All @@ -120,8 +116,6 @@ var ERROR_SETUP_NEW_GRADEBOOK_FORMAT = 'There was a problem formatting the page.
var ERROR_SETUP_ADD_STUDENTS = 'There was a problem reading the file.';
var ERROR_SETUP_ADD_STUDENTS_EMPTY = 'I could not find any students in the file \"$\" for this section. Make sure you didn\'t modify it after downloading it from Sakai and that it\'s the correct section';
var ERROR_SETUP_ADD_STUDENTS_INVALID = '\'$\' is not a valid CSV or Google Sheets file. Please try again.';
var ERROR_SETUP_SHARE_FOLDERS = 'There was a problem sharing the folders. Please try again.';
var ERROR_ASSIGNMENTS_CALC_WORD_COUNTS = 'There is no course folder for this course. Use the Create Folder Structure command to create one before executing this command.';

/**
* The COURSE_FORMATS object literal contains the basic data used to format Exposify gradebooks,
Expand Down Expand Up @@ -1713,8 +1707,9 @@ Exposify.prototype.getFirstDayOfSpringBreak = function(year) {


/**
* Get the specified folder for the gradebook on the active spreadsheet.
* @param {Sheet} sheet - A Google Apps Sheet object, the gradebook for which we want the associated folder.
* Search for and return the subfolder, if one exists, if a given parent folder.
* @param {Folder} folder - The parent folder to search in.
* @param {string} name - The name of the folder we're looking for.
*/
Exposify.prototype.getFolder = function(folder, name) {
try {
Expand Down Expand Up @@ -2317,7 +2312,44 @@ Exposify.prototype.setupNewGradebook = function(sheet, courseInfo) {
*/
Exposify.prototype.setupShareFolders = function(sheet) {
try {

var section = this.getSectionTitle(sheet);
var students = this.getStudents(sheet);
var that = this;
var emails = this.students.filter(function(student) { return student.email; });
var courseFolder = this.getCourseFolder(sheet);
if (courseFolder === null) {
var alert = this.alert({msg: ALERT_SETUP_SHARE_FOLDERS_MISSING_COURSE_FOLDER, title: 'Share Folders'});
alert();
return;
}
courseFolder.setShareableByEditors(false);
var currentEditors = courseFolder.getEditors();
currentEditors.forEach(function(editor) {
if (that.arrayContains(emails, editor) === false) { courseFolder.removeEditor(editor); }
});
emails.forEach(function(email) {
if (that.arrayContains(currentEditors, email) === false) { courseFolder.addEditor(email); }
});
var gradedPapersFolder = this.getGradedPapersFolder(sheet);
if (gradedPapersFolder === null) {
var alert = this.alert({msg: ALERT_SETUP_SHARE_FOLDERS_MISSING_GRADED_FOLDER, title: 'Share Folders'});
alert();
return;
}
var subFolders = gradedPapersFolder.getFolders();
var studentFolders = [];
while (subFolders.hasNext()) { studentFolders.push(subFolders.next().getName()); }
students.forEach(function(student) {
var name = that.getNameFirstLast(student.name);
var email = student.email;
if (arrayContains(studentFolders, name)) {
var studentFolder = that.getFolder(name);
if (studentFolder.getAccess(email) !== DriveApp.Permission.EDIT) {
studentFolder.addEditor(email);
}
}
});
spreadsheet.toast(ALERT_SETUP_SHARE_FOLDERS_SUCCESS.replace('$', section), TOAST_TITLE, TOAST_DISPLAY_TIME);
} catch(e) { this.logError('Exposify.prototype.setupShareFolders', e); }
} // end Exposify.prototype.setupShareFolders

Expand Down
2 changes: 1 addition & 1 deletion src/help.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3><span>New gradebook</span></h3>
<h3><span>Add students to gradebook</span></h3>
You can add students manually, of course, but it's far more convenient to let Exposify do it for you! Go to the "Site Info" section of the Sakai page for your course and click the link above your roster that says <b>[Download participant data file compatible with Microsoft Excel]</b>. Upload this file to Google Drive. The file can be in the original csv format, or you can convert it to Google Sheets format, but do not otherwise modify it before running this command. Select the file and your students should automagically appear in your gradebook. Note that Exposify matches your gradebook's section number to the downloaded data file, so your section code must be correct. Once students have been added, you can modify the list however you want, though it's a good idea to use a consistent naming format.
<h3><span>Create contact group for students</span></h3>
If you use Google Contacts (or even just Gmail), you may find it handy to have a contact group for your section containing your students's names and email addresses. This way, when you compose a new email draft, autocomplete will fill in their email addresses for you, and you won't have to look them up. You can also email the entire contact group, if you so desire. Note that if you change the student list in the gradebook after running this command, the contact list won't automatically update. You can run the command again to do that, however.
If you use Google Contacts (or even just Gmail), you may find it handy to have a contact group for your section containing your students's names and email addresses. This way, when you compose a new email draft, autocomplete will fill in their email addresses for you, and you won't have to look them up. You can also email the entire contact group, if you so desire. Note that if you change the student list in the gradebook after running this command, the contact list won't automatically update. You can run the command again to do that, however. For some reason, this command can be very slow sometimes. Be patient!
<h3><span>Create or update folder structure for this section</span></h3>
In order to keep your teaching admin organized, you may find it useful to create a standard set of folders for each semester that you teach. This command will automatically create a root semester folder (meant only for you), a section folder (for you and all the students), and a graded papers folder that contains individual, private folders for each student. If you have multiple gradebooks in the spreadsheet, Exposify will place all the section folders from the same semester in the same root semester folder. The idea is that students compose their paper drafts and collaborate in the section folder, you copy them into the root folder for grading, and then you return the graded copies to them privately in their own, individual folders. If you modify the student list after creating the folder structure, run this command again to update it. You may want to wait until after add/drop to create it to avoid the extra work. Note that if you change the course name, section, or semester in the gradebook, other commands that use your folder structure may not function as intended.
<h3><span>Share folders with students</span></h3>
Expand Down

0 comments on commit 45dbd84

Please sign in to comment.