Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public publishQuestions() {
let selectedQuestions = _.filter(this.questionList, (question) => _.get(question, 'isSelected'));
this.publishInProgress = true;
this.publishButtonStatus.emit(this.publishInProgress);
let selectedQuestionsData = _.reduce(selectedQuestions, (final, question) => {
final.ids.push(_.get(question, 'identifier'));
final.author.push(_.get(question, 'author'));
final.category.push(_.get(question, 'category'));
final.attributions = _.union(final.attributions, _.get(question, 'organisation'));
return final;
}, { ids: [], author: [], category: [], attributions: [] });
if (selectedQuestionsData.ids.length > 0) {
const questions = [];
_.forEach(_.get(selectedQuestionsData, 'ids'), (value) => {
questions.push({ 'identifier': value });
});
this.cbseService.getECMLJSON(selectedQuestionsData.ids).subscribe((theme) => {
let creator = this.userService.userProfile.firstName;
if (!_.isEmpty(this.userService.userProfile.lastName)) {
creator = this.userService.userProfile.firstName + ' ' + this.userService.userProfile.lastName;
}
const option = {
url: `private/content/v3/create`,
data: {
'request': {
'content': {
// tslint:disable-next-line:max-line-length
'name': this.resourceName || `${this.questionTypeName[this.selectedAttributes.questionType]} - ${this.selectedAttributes.topic}`,
'contentType': this.selectedAttributes.questionType === 'curiosity' ? 'CuriosityQuestionSet' : 'PracticeQuestionSet',
var getExceptionsParticiplesNounsRegexes = memoize( function() {
let exceptionsParticiplesNounsRegexes = [];
// Nouns starting with a vowel are checked with -s suffix and l' and d' prefixes.
forEach( exceptionsParticiplesNounsVowel, function( exceptionParticipleNounVowel ) {
exceptionsParticiplesNounsRegexes.push( new RegExp( "^(l'|d')?" + exceptionParticipleNounVowel + "(s)?$", "ig" ) );
} );
// Nouns starting with a consonant are checked with -s suffix.
forEach( exceptionsParticiplesNounsConsonant, function( exceptionParticipleNounConsonant ) {
exceptionsParticiplesNounsRegexes.push( new RegExp( "^" + exceptionParticipleNounConsonant + "(s)?$", "ig" ) );
} );
return exceptionsParticiplesNounsRegexes;
} );
var getExceptionsParticiplesAdjectivesVerbsRegexes = memoize( function() {
let exceptionsParticiplesAdjectivesVerbsRegexes = [];
forEach( exceptionsParticiplesAdjectivesVerbs, function( exceptionParticiplesAdjectivesVerbs ) {
exceptionsParticiplesAdjectivesVerbsRegexes.push( new RegExp( "^" + exceptionParticiplesAdjectivesVerbs + "(e|s|es)?$", "ig" ) );
} );
return exceptionsParticiplesAdjectivesVerbsRegexes;
} );
YoastReplaceVarPlugin.prototype.replaceByStore = function( data ) {
const replacementVariables = this._store.getState().snippetEditor.replacementVariables;
forEach( replacementVariables, ( replacementVariable ) => {
if ( replacementVariable.value === "" ) {
return;
}
data = data.replace( "%%" + replacementVariable.name + "%%", replacementVariable.value );
} );
return data;
};
private calculateProgress(courseId_batchId) {
const lastAccessTimeOfContentId = [];
let completedCount = 0;
const contentList = this.courseProgress[courseId_batchId].content;
_.forEach(contentList, (content) => {
if (content.status === 2) {
completedCount += 1;
}
if (content.lastAccessTime) {
lastAccessTimeOfContentId.push(content.lastAccessTime);
}
});
this.courseProgress[courseId_batchId].completedCount = completedCount;
const progress = ((this.courseProgress[courseId_batchId].completedCount / this.courseProgress[courseId_batchId].totalCount) * 100);
this.courseProgress[courseId_batchId].progress = progress > 100 ? 100 : progress;
const index = _.findIndex(contentList, { lastAccessTime: lastAccessTimeOfContentId.sort().reverse()[0] });
const lastPlayedContent = contentList[index] ? contentList[index] : contentList[0];
this.courseProgress[courseId_batchId].lastPlayedContentId = lastPlayedContent && lastPlayedContent.contentId;
}
prepareVisits() {
const visits = [];
_.forEach(this.contentList, (content, index) => {
visits.push({
objid: content.metaData.identifier,
objtype: content.metaData.contentType,
index: index,
});
});
this.telemetryImpression.edata.visits = visits;
this.telemetryImpression.edata.subtype = 'pageexit';
this.telemetryImpression = Object.assign({}, this.telemetryImpression);
}
.setIn(
['drafts', 'byId', newItem._id],
blankDraft
.set('status', 'loaded')
.set('item', newItem)
)
}
//Update drafts also
case BOOKMARK_UPDATE_SUCCESS:{
if (state.drafts.byId[action._id]){
const updatedItem = normalizeBookmark(action.item, {flat: false})
const draftItem = state.getIn(['drafts', 'byId', action._id, 'item'])
if (draftItem)
_.forEach(updatedItem, (val,field)=>{
if (val != draftItem[field])
state = state.setIn(['drafts', 'byId', action._id, 'item', field], updatedItem[field])
})
state = state.setIn(['drafts', 'byId', action._id, 'status'], updatedItem.collectionId!=-99 ? 'loaded' : 'removed')
}
return state
}
//Remove draft
case BOOKMARK_REMOVE_SUCCESS:{
if (state.drafts.byId[action._id])
return state.setIn(['drafts', 'byId', action._id, 'status'], 'removed')
return state
_.forEach(sections, (section, sectionIndex) => {
_.forEach(section.contents, (content, contentIndex) => {
sections[sectionIndex].contents[contentIndex]['userName'] = (userNamesKeyById[content.createdBy].firstName || '')
+ ' ' + (userNamesKeyById[content.createdBy].lastName || '');
sections[sectionIndex].contents[contentIndex]['metaData'] = {identifier: content.identifier};
sections[sectionIndex].contents[contentIndex]['label'] = content.participantCount || 0;
});
});
this.carouselData = sections;
.subscribe((res: ServerResponse) => {
if (res.result.response.count && res.result.response.content.length > 0) {
const userNamesKeyById = _.keyBy(res.result.response.content, 'identifier');
_.forEach(sections, (section, sectionIndex) => {
_.forEach(section.contents, (content, contentIndex) => {
sections[sectionIndex].contents[contentIndex]['userName'] = (userNamesKeyById[content.createdBy].firstName || '')
+ ' ' + (userNamesKeyById[content.createdBy].lastName || '');
sections[sectionIndex].contents[contentIndex]['metaData'] = {identifier: content.identifier};
sections[sectionIndex].contents[contentIndex]['label'] = content.participantCount || 0;
});
});
this.carouselData = sections;
this.showLoader = false;
} else {
this.toasterService.error(this.resourceService.messages.fmsg.m0056);
}
},
(err: ServerResponse) => {
var countPartialWordDeviations = function( word, locale ) {
var deviationFragments = createDeviationFragmentsMemoized( syllableMatchers( locale ) );
var remainingParts = word;
var syllableCount = 0;
forEach( deviationFragments, function( deviationFragment ) {
if ( deviationFragment.occursIn( remainingParts ) ) {
remainingParts = deviationFragment.removeFrom( remainingParts );
syllableCount += deviationFragment.getSyllables();
}
} );
return { word: remainingParts, syllableCount: syllableCount };
};