Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #dp-1515 feat: question set editor integration in contribution … #1218

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { CollectionComponent } from '../../../sourcing/components/collection/col
import {DashboardComponent } from '../../../sourcing/components/dashboard/dashboard.component';
import { ContentUploaderComponent } from '../../../sourcing/components/content-uploader/content-uploader.component';
import { QuestionListComponent } from '../../../sourcing/components/question-list/question-list.component';
import { QuestionSetEditorComponent } from '../../../sourcing/components/question-set-editor/question-set-editor.component';
import { ToasterService } from '@sunbird/shared';

@Injectable({
Expand All @@ -13,6 +14,7 @@ export class ProgramComponentsService {
dashboardComponent: DashboardComponent,
collectionComponent: CollectionComponent,
uploadComponent: ContentUploaderComponent,
questionSetEditorComponent: QuestionSetEditorComponent,
questionSetComponent: QuestionListComponent,
curiositySetComponent: QuestionListComponent
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ export class ProgramsService extends DataService implements CanActivate {
data: {
request: {
"objectCategoryDefinition": {
"objectType": "Content",
"objectType": "QuestionSet",
"name": categoryName,
"channel": rootOrgId
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {DashboardComponent } from '../../../sourcing/components/dashboard/dashbo
import { ContentUploaderComponent } from '../../../sourcing/components/content-uploader/content-uploader.component';
import { QuestionListComponent } from '../../../sourcing/components/question-list/question-list.component';
import { ContentEditorComponent } from '../../../sourcing/components/content-editor/content-editor.component';
import { QuestionSetEditorComponent } from '../../../sourcing/components/question-set-editor/question-set-editor.component';
import { ToasterService } from '@sunbird/shared';

@Injectable({
Expand All @@ -15,6 +16,7 @@ export class ProgramComponentsService {
collectionComponent: CollectionComponent,
uploadComponent: ContentUploaderComponent,
questionSetComponent: QuestionListComponent,
questionSetEditorComponent: QuestionSetEditorComponent,
curiositySetComponent: QuestionListComponent,
editorComponent: ContentEditorComponent
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"type": "question"
},
{
"mimetype": "application/vnd.ekstep.quml-archive",
"type": "question"
"mimetype": "application/vnd.sunbird.questionset",
"type": "questionset"
},
{
"mimetype": "application/vnd.ekstep.html-archive",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { UUID } from 'angular2-uuid';
import { SourcingService } from '../../services';
import { map, catchError, first, filter } from 'rxjs/operators';
import { throwError, Observable } from 'rxjs';
import { Router, ActivatedRoute } from '@angular/router';
import { Router, ActivatedRoute, NavigationExtras} from '@angular/router';
import {
IChapterListComponentInput, ISessionContext,
IContentUploadComponentInput, IResourceTemplateComponentInput, IContentEditorComponentInput
Expand Down Expand Up @@ -764,8 +764,8 @@ export class ChapterListComponent implements OnInit, OnChanges, OnDestroy, After
if (!_.isEmpty(this.userService.userProfile.lastName)) {
creator = this.userService.userProfile.firstName + ' ' + this.userService.userProfile.lastName;
}
const sharedMetaData = this.helperService.fetchRootMetaData(this.sharedContext, this.selectedSharedContext);
const option = {
const sharedMetaData = this.helperService.fetchRootMetaData(this.sharedContext, this.selectedSharedContext);
let option = {
url: `content/v3/create`,
header: {
'X-Channel-Id': this.programContext.rootorg_id
Expand All @@ -790,6 +790,7 @@ export class ChapterListComponent implements OnInit, OnChanges, OnDestroy, After
}
}
};

if (this.sampleContent) {
option.data.request.content.sampleContent = this.sampleContent;
}
Expand All @@ -799,7 +800,19 @@ export class ChapterListComponent implements OnInit, OnChanges, OnDestroy, After
if (_.get(this.templateDetails, 'appIcon')) {
option.data.request.content.appIcon = _.get(this.templateDetails, 'appIcon');
}
this.actionService.post(option).pipe(map((res: any) => res.result), catchError(err => {

let createRes;
if (_.get(this.templateDetails, 'modeOfCreation') === 'questionset') {
option.url = 'questionset/v1/create';
option.data.request['questionset'] = {};
option.data.request['questionset'] = option.data.request.content;
delete option.data.request.content;
createRes = this.publicDataService.post(option);
} else {
createRes = this.actionService.post(option);
}

createRes.pipe(map((res: any) => res.result), catchError(err => {
const errInfo = {
errorMsg: 'Unable to create contentId, Please Try Again',
telemetryPageId: this.telemetryPageId,
Expand All @@ -813,8 +826,14 @@ export class ChapterListComponent implements OnInit, OnChanges, OnDestroy, After
this.contentId = result.node_id;
this.collectionHierarchyService.addResourceToHierarchy(this.sessionContext.collection, this.unitIdentifier, result.identifier)
.subscribe(() => {
// tslint:disable-next-line:max-line-length
this.componentLoadHandler('creation', this.programComponentsService.getComponentInstance(event.templateDetails.onClick), event.templateDetails.onClick);
if (_.get(this.templateDetails, 'modeOfCreation') === 'questionset') {

const queryParams = "collectionId=" + this.sessionContext.collection + "&unitId=" + this.unitIdentifier;

this.router.navigateByUrl('/contribute/questionSet/' + result.identifier + "?" + queryParams);
}
// tslint:disable-next-line:max-line-length
this.componentLoadHandler('creation', this.programComponentsService.getComponentInstance(event.templateDetails.onClick), event.templateDetails.onClick);
});
});
} else if (event.templateDetails) {
Expand All @@ -825,6 +844,10 @@ export class ChapterListComponent implements OnInit, OnChanges, OnDestroy, After
}

handlePreview(event) {
if (event.content.mimeType === 'application/vnd.sunbird.questionset') {
const queryParams = "collectionId=" + this.sessionContext.collection + "&unitId=" + this.unitIdentifier;
this.router.navigateByUrl('/contribute/questionSet/' + event.content.identifier + "?" + queryParams);
}
//const templateList = this.programsService.contentCategories;
this.programsService.getCategoryDefinition(event.content.primaryCategory, this.programContext.rootorg_id).subscribe((res)=>{
this.templateDetails = res.result.objectCategoryDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<app-loader></app-loader>
</div>
<div *ngIf="!showLoader">
<lib-editor [editorConfig]="editorConfig" ></lib-editor>
<lib-editor [editorConfig]="editorConfig" (editorEmitter)="editorEventListener($event)"></lib-editor>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ export class QuestionSetEditorComponent implements OnInit {
}
this.showLoader = false;
}

private editorEventListener($event) {
console.log($event);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ export class ResourceTemplateComponent implements OnInit, OnDestroy {
this.showModeofCreationModal = false;
this.showQuestionTypeModal = false;
switch (this.selectedtemplateDetails['modeOfCreation']) {
case 'questionset':
this.selectedtemplateDetails.onClick = 'questionSetEditorComponent';
this.selectedtemplateDetails.mimeType = ['application/vnd.sunbird.questionset'];
break;
case 'question':
this.selectedtemplateDetails.onClick = 'questionSetComponent';
const temp = _.find(this.selectedtemplateDetails.editors, {'type': 'question'});
Expand Down
2 changes: 1 addition & 1 deletion src/app/client/src/app/modules/sourcing/sourcing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { MvcPlayerComponent } from './components/mvc-player/mvc-player.component
import { SkeletonLoaderComponent } from './components/skeleton-loader/skeleton-loader.component';
import { NgInviewModule } from 'angular-inport';
import { QuestionSetEditorComponent } from './components/question-set-editor/question-set-editor.component';
import { QuestionEditorLibraryModule } from 'question-editor-library';
import { QuestionEditorLibraryModule } from 'question-editor-library-v8';
import {CarouselModule} from 'ngx-bootstrap/carousel';
@NgModule({
declarations: [QuestionListComponent, QuestionCreationComponent,
Expand Down