Created
August 16, 2013 09:00
-
-
Save imsickofmaps/6248370 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.cms_performance_learner = function(im) { | |
| var p = self.get_contact(im); | |
| p.add_callback(function(result) { | |
| var emis = result.contact["extras-rts_emis"]; | |
| var id = result.contact["extras-rts_id"]; | |
| var data = self.performance_data_learner_collect(emis, id); | |
| var boys_data = data[0]; | |
| var girls_data = data[1]; | |
| // Need to ensure no double save | |
| var contact_key = result.contact.key; | |
| if (result.contact["extras-rts_last_save_performance_learner"] != 'true') { | |
| console.log("Starts here..."); | |
| var p_lp = new Promise(); | |
| p_lp.add_callback(function(){ | |
| console.log("Here!"); | |
| var p_lp_boys = self.cms_post("data/learnerperformance/", data_boys); | |
| return p_lp_boys; | |
| }); | |
| p_lp.add_callback(function(){ | |
| console.log("Here Now!"); | |
| var p_lp_girls = self.cms_post("data/learnerperformance/", data_girls); | |
| return p_lp_girls; | |
| }); | |
| p_lp.add_callback(function(contact_key) { | |
| console.log("Here Finally!"); | |
| return im.api_request('contacts.update_extras', { | |
| key: result.contact.key, | |
| fields: { | |
| "rts_last_save_performance_learner": 'true' | |
| } | |
| }); | |
| }); | |
| return p_lp; | |
| } | |
| }); | |
| return p; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment