MOBILE-2339 feedback: Peer review fixes

main
Pau Ferrer Ocaña 2018-04-12 15:15:16 +02:00
parent 701d6f7774
commit 12adb9ef19
10 changed files with 40 additions and 30 deletions

View File

@ -29,7 +29,7 @@
</ng-container>
<ng-container *ngSwitchCase="'numeric'">
<ion-input [required]="item.required" name="{{item.typ}}_{{item.id}}" type="number" [(ngModel)]="item.value"></ion-input>
<p *ngIf="item.hasError" color="error">{{ 'addon.mod_feedback.numberoutofrange' |translate }} [{{item.rangefrom}}<span *ngIf="item.rangefrom && item.rangeto">, </span>{{item.rangeto}}]</p>
<p *ngIf="item.hasError" color="error">{{ 'addon.mod_feedback.numberoutofrange' | translate }} [{{item.rangefrom}}<span *ngIf="item.rangefrom && item.rangeto">, </span>{{item.rangeto}}]</p>
</ng-container>
<ng-container *ngSwitchCase="'textarea'">
<ion-textarea [required]="item.required" name="{{item.typ}}_{{item.id}}" [attr.aria-multiline]="true" [(ngModel)]="item.value"></ion-textarea>
@ -111,7 +111,5 @@
</ion-col>
</ion-row>
</ion-grid>
</core-loading>
</ion-content>

View File

@ -17,7 +17,6 @@ import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { CoreDirectivesModule } from '@directives/directives.module';
import { CoreComponentsModule } from '@components/components.module';
import { CorePipesModule } from '@pipes/pipes.module';
import { AddonModFeedbackComponentsModule } from '../../components/components.module';
import { AddonModFeedbackFormPage } from './form';
@ -28,7 +27,6 @@ import { AddonModFeedbackFormPage } from './form';
imports: [
CoreDirectivesModule,
CoreComponentsModule,
CorePipesModule,
AddonModFeedbackComponentsModule,
IonicPageModule.forChild(AddonModFeedbackFormPage),
TranslateModule.forChild()

View File

@ -77,7 +77,7 @@ export class AddonModFeedbackProvider {
*
* @param {any} item Item to check.
* @param {string} dependValue Value to compare.
* @return {boolean} eturn true if dependency is acomplished and it can be shown. False, otherwise.
* @return {boolean} Return true if dependency is acomplished and it can be shown. False, otherwise.
*/
protected compareDependItemMultichoice(item: any, dependValue: string): boolean {
let values, choices;
@ -772,11 +772,11 @@ export class AddonModFeedbackProvider {
/**
* Convenience function to get the page we can jump.
*
* @param {number} feedbackId [description]
* @param {number} page [description]
* @param {number} changePage [description]
* @param {string} siteId [description]
* @return {Promise<number | false>} [description]
* @param {number} feedbackId Feedback ID.
* @param {number} page Page where we want to jump.
* @param {number} changePage If page change is forward (1) or backward (-1).
* @param {string} siteId Site ID.
* @return {Promise<number | false>} Page number where to jump. Or false if completed or first page.
*/
protected getPageJumpTo(feedbackId: number, page: number, changePage: number, siteId: string): Promise<number | false> {
return this.getPageItemsWithValues(feedbackId, page, true, false, siteId).then((resp) => {
@ -1037,9 +1037,9 @@ export class AddonModFeedbackProvider {
*
* @param {number} feedbackId Feedback ID.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved when the info is retrieved.
* @return {Promise<boolean>} Promise resolved when the info is retrieved.
*/
isCompleted(feedbackId: number, siteId?: string): Promise<any> {
isCompleted(feedbackId: number, siteId?: string): Promise<boolean> {
return this.sitesProvider.getSite(siteId).then((site) => {
const params = {
feedbackid: feedbackId

View File

@ -41,6 +41,7 @@ export class AddonModFeedbackHelperProvider {
* @param {number} instance Activity instance Id. I.e FeedbackId.
* @param {string} paramName Param name where to find the instance number.
* @param {string} prefix Prefix to check if we are out of the activity context.
* @param {NavController} navCtrl Nav Controller of the view.
* @return {number} Returns the number of times the history needs to go back to find the specified page.
*/
protected getActivityHistoryBackCounter(pageName: string, instance: number, paramName: string, prefix: string,

View File

@ -27,7 +27,7 @@ export class AddonModFeedbackOfflineProvider {
protected logger;
// Variables for database.
protected FEEDBACK_TABLE = 'mma_mod_feedback_answers';
protected FEEDBACK_TABLE = 'addon_mod_feedback_answers';
protected tablesSchema = [
{
name: this.FEEDBACK_TABLE,
@ -102,7 +102,11 @@ export class AddonModFeedbackOfflineProvider {
*/
getFeedbackResponses(feedbackId: number, siteId?: string): Promise<any> {
return this.sitesProvider.getSite(siteId).then((site) => {
return site.getDb().getRecords(this.FEEDBACK_TABLE, {feedbackid: feedbackId});
return site.getDb().getRecords(this.FEEDBACK_TABLE, {feedbackid: feedbackId}).then((entries) => {
return entries.map((entry) => {
entry.responses = this.textUtils.parseJSON(entry.responses);
});
});
});
}

View File

@ -38,9 +38,9 @@ export class AddonModFeedbackSyncProvider extends CoreSyncBaseProvider {
constructor(protected sitesProvider: CoreSitesProvider, protected loggerProvider: CoreLoggerProvider,
protected appProvider: CoreAppProvider, private feedbackOffline: AddonModFeedbackOfflineProvider,
private eventsProvider: CoreEventsProvider, private feedbackProvider: AddonModFeedbackProvider,
private translate: TranslateService, private utils: CoreUtilsProvider, protected textUtils: CoreTextUtilsProvider,
protected translate: TranslateService, private utils: CoreUtilsProvider, protected textUtils: CoreTextUtilsProvider,
courseProvider: CoreCourseProvider, syncProvider: CoreSyncProvider) {
super('AddonModFeedbackSyncProvider', sitesProvider, loggerProvider, appProvider, syncProvider, textUtils);
super('AddonModFeedbackSyncProvider', loggerProvider, sitesProvider, appProvider, syncProvider, textUtils, translate);
this.componentTranslate = courseProvider.translateModuleName('feedback');
}
@ -108,7 +108,7 @@ export class AddonModFeedbackSyncProvider extends CoreSyncBaseProvider {
}
/**
* ynchronize all offline responses of a feedback.
* Synchronize all offline responses of a feedback.
*
* @param {number} feedbackId Feedback ID to be synced.
* @param {string} [siteId] Site ID. If not defined, current site.
@ -221,7 +221,16 @@ export class AddonModFeedbackSyncProvider extends CoreSyncBaseProvider {
return this.addOngoingSync(syncId, syncPromise, siteId);
}
// Convenience function to sync process page calls.
/**
* Convenience function to sync process page calls.
*
* @param {any} feedback Feedback object.
* @param {any} data Response data.
* @param {string} siteId Site Id.
* @param {number} timemodified Current completed modification time.
* @param {any} result Result object to be modified.
* @return {Promise<any>} Resolve when done or rejected with error.
*/
protected processPage(feedback: any, data: any, siteId: string, timemodified: number, result: any): Promise<any> {
// Delete all pages that are submitted before changing website.
if (timemodified > data.timemodified) {

View File

@ -97,9 +97,9 @@ export class AddonModSurveySyncProvider extends CoreSyncBaseProvider {
/**
* Sync a survey only if a certain time has passed since the last time.
*
* @param {Number} surveyId Survey ID.
* @param {Number} userId User the answers belong to.
* @param {String} [siteId] Site ID. If not defined, current site.
* @param {number} surveyId Survey ID.
* @param {number} userId User the answers belong to.
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved when the survey is synced or if it doesn't need to be synced.
*/
syncSurveyIfNeeded(surveyId: number, userId: number, siteId?: string): Promise<any> {

View File

@ -77,7 +77,7 @@ export class CoreRecaptchaComponent {
}
@Component({
selector: 'core-recaptcha',
selector: 'core-recaptcha-modal',
templateUrl: 'recaptchamodal.html'
})
export class CoreRecaptchaModalComponent {

View File

@ -376,7 +376,7 @@ export class CoreUserProvider {
* @param {string} [siteId] Site ID. If not defined, current site.
* @return {Promise<any>} Promise resolved when prefetched.
*/
prefetchProfiles(userIds: number[], courseId: number, siteId?: string): Promise<any> {
prefetchProfiles(userIds: number[], courseId?: number, siteId?: string): Promise<any> {
siteId = siteId || this.sitesProvider.getCurrentSiteId();
const treated = {},

View File

@ -18,7 +18,7 @@ import { Chart } from 'chart.js';
/**
* This component shows a chart using chart.js.
* Documentation can be found at http://www.chartjs.org/docs/.
* It does not support changes on any input.
* It only supports changes on these properties: data and labels.
*
* Example usage:
* <canvas core-chart [data]="data" [labels]="labels" [type]="type" [legend]="legend"></canvas>