diff --git a/src/assets/img/login/faq_url.png b/src/assets/img/login/faq_url.png new file mode 100644 index 000000000..13d92cd50 Binary files /dev/null and b/src/assets/img/login/faq_url.png differ diff --git a/src/assets/lang/en.json b/src/assets/lang/en.json index 51b1c753d..e33e9f8ab 100644 --- a/src/assets/lang/en.json +++ b/src/assets/lang/en.json @@ -1331,7 +1331,7 @@ "core.block.blocks": "Blocks", "core.browser": "Browser", "core.cancel": "Cancel", - "core.cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.", + "core.cannotconnect": "Cannot connect: Verify that you have correctly typed your site address.", "core.cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "core.captureaudio": "Record audio", "core.capturedimage": "Taken picture.", @@ -1707,7 +1707,17 @@ "core.login.emailnotmatch": "Emails do not match", "core.login.erroraccesscontrolalloworigin": "The cross-origin call you're trying to perform has been rejected. Please check https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium", "core.login.errordeletesite": "An error occurred while deleting this site. Please try again.", + "core.login.errorexampleurl": "The URL https://campus.example.edu is only an example URL, it's not a real site. Please use the URL of your school or organization's site.", "core.login.errorupdatesite": "An error occurred while updating the site's token.", + "core.login.faqcannotconnectanswer": "Please, contact your site administrator.", + "core.login.faqcannotconnectquestion": "I typed my site address correctly but I still can't connect.", + "core.login.faqsetupsiteanswer": "Visit {{$link}} to check out the different options you have to create your own Moodle site.", + "core.login.faqsetupsitelinktitle": "Get started.", + "core.login.faqsetupsitequestion": "I want to set up my own Moodle site.", + "core.login.faqtestappanswer": "To test the app in a Moodle Demo Site, type \"teacher\" or \"student\" in the \"Your site address\" field and click the \"Connect!\" button.", + "core.login.faqtestappquestion": "I just want to test the app, what can I do?", + "core.login.faqwhatisurlanswer": "

Every organisation or school has their own custom address for their Moodle site.

To find the address of the Moodle site you want to connect to, do the following:

  1. Open a web browser and go to your school's or organisation's Moodle site login page
  2. At the top of the page, on the address bar, you will see the URL of your Moodle site. E.g. \"campus.example.edu\".{{$image}}
  3. Copy the address (do not copy the /login and what comes after), paste it into the Moodle App and click \"Connect!\"
  4. Now you can log into your site, using your username and password
  5. ", + "core.login.faqwhatisurlquestion": "What is the URL of my Moodle site? How can I find my school’s site?", "core.login.findyoursite": "Find your site", "core.login.firsttime": "Is this your first time here?", "core.login.forcepasswordchangenotice": "You must change your password to proceed.", @@ -1736,7 +1746,6 @@ "core.login.mobileservicesnotenabled": "Mobile access is not enabled on your site. Please contact your site administrator if you think it should be enabled.", "core.login.mustconfirm": "You need to confirm your account", "core.login.newaccount": "New account", - "core.login.newsitedescription": "Please enter the URL of your Moodle site. Note that it might not be configured to work with this app.", "core.login.notloggedin": "You need to be logged in.", "core.login.password": "Password", "core.login.passwordforgotten": "Forgotten password", @@ -1762,7 +1771,7 @@ "core.login.selectacountry": "Select a country", "core.login.selectsite": "Please select your site:", "core.login.signupplugindisabled": "{{$a}} is not enabled.", - "core.login.siteaddress": "Site address", + "core.login.siteaddress": "Your site address", "core.login.sitehasredirect": "Your site contains at least one HTTP redirect. The app cannot follow redirects, this could be the issue that's preventing the app from connecting to your site.", "core.login.siteinmaintenance": "Your site is in maintenance mode", "core.login.sitepolicynotagreederror": "Site policy not agreed.", @@ -1816,6 +1825,7 @@ "core.more": "more", "core.mygroups": "My groups", "core.name": "Name", + "core.needhelp": "Need help?", "core.networkerroriframemsg": "This content is not available offline. Please connect to the internet and try again.", "core.networkerrormsg": "There was a problem connecting to the site. Please check your connection and try again.", "core.never": "Never", @@ -2090,6 +2100,7 @@ "core.warningofflinedatadeleted": "Offline data from {{component}} '{{name}}' has been deleted. {{error}}", "core.whatisyourage": "What is your age?", "core.wheredoyoulive": "In which country do you live?", + "core.whoissiteadmin": "\"Site Administrators\" are the people who manage the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.", "core.whoops": "Oops!", "core.whyisthishappening": "Why is this happening?", "core.whyisthisrequired": "Why is this required?", diff --git a/src/core/login/lang/en.json b/src/core/login/lang/en.json index 054a51168..3624b1063 100644 --- a/src/core/login/lang/en.json +++ b/src/core/login/lang/en.json @@ -24,7 +24,17 @@ "emailnotmatch": "Emails do not match", "erroraccesscontrolalloworigin": "The cross-origin call you're trying to perform has been rejected. Please check https://docs.moodle.org/dev/Moodle_Mobile_development_using_Chrome_or_Chromium", "errordeletesite": "An error occurred while deleting this site. Please try again.", + "errorexampleurl": "The URL https://campus.example.edu is only an example URL, it's not a real site. Please use the URL of your school or organization's site.", "errorupdatesite": "An error occurred while updating the site's token.", + "faqcannotconnectanswer": "Please, contact your site administrator.", + "faqcannotconnectquestion": "I typed my site address correctly but I still can't connect.", + "faqsetupsiteanswer": "Visit {{$link}} to check out the different options you have to create your own Moodle site.", + "faqsetupsitelinktitle": "Get started.", + "faqsetupsitequestion": "I want to set up my own Moodle site.", + "faqtestappanswer": "To test the app in a Moodle Demo Site, type \"teacher\" or \"student\" in the \"Your site address\" field and click the \"Connect!\" button.", + "faqtestappquestion": "I just want to test the app, what can I do?", + "faqwhatisurlanswer": "

    Every organisation or school has their own custom address for their Moodle site.

    To find the address of the Moodle site you want to connect to, do the following:

    1. Open a web browser and go to your school's or organisation's Moodle site login page
    2. At the top of the page, on the address bar, you will see the URL of your Moodle site. E.g. \"campus.example.edu\".{{$image}}
    3. Copy the address (do not copy the /login and what comes after), paste it into the Moodle App and click \"Connect!\"
    4. Now you can log into your site, using your username and password
    5. ", + "faqwhatisurlquestion": "What is the URL of my Moodle site? How can I find my school’s site?", "findyoursite": "Find your site", "firsttime": "Is this your first time here?", "forcepasswordchangenotice": "You must change your password to proceed.", @@ -53,7 +63,6 @@ "mobileservicesnotenabled": "Mobile access is not enabled on your site. Please contact your site administrator if you think it should be enabled.", "mustconfirm": "You need to confirm your account", "newaccount": "New account", - "newsitedescription": "Please enter the URL of your Moodle site. Note that it might not be configured to work with this app.", "notloggedin": "You need to be logged in.", "password": "Password", "passwordforgotten": "Forgotten password", @@ -79,7 +88,7 @@ "selectacountry": "Select a country", "selectsite": "Please select your site:", "signupplugindisabled": "{{$a}} is not enabled.", - "siteaddress": "Site address", + "siteaddress": "Your site address", "sitehasredirect": "Your site contains at least one HTTP redirect. The app cannot follow redirects, this could be the issue that's preventing the app from connecting to your site.", "siteinmaintenance": "Your site is in maintenance mode", "sitepolicynotagreederror": "Site policy not agreed.", diff --git a/src/core/login/pages/site-help/site-help.html b/src/core/login/pages/site-help/site-help.html index ae21bace1..2aa5a8247 100644 --- a/src/core/login/pages/site-help/site-help.html +++ b/src/core/login/pages/site-help/site-help.html @@ -10,5 +10,31 @@ - + + +

      {{ 'core.login.faqwhatisurlquestion' | translate }}

      +
      + +
      +
      +
      + +

      {{ 'core.login.faqcannotconnectquestion' | translate }}

      +
      + +

      {{ 'core.login.faqcannotconnectanswer' | translate }} {{ 'core.whoissiteadmin' | translate }}

      +
      + +

      {{ 'core.login.faqsetupsitequestion' | translate }}

      +
      + +

      +
      + +

      {{ 'core.login.faqtestappquestion' | translate }}

      +
      + +

      {{ 'core.login.faqtestappanswer' | translate }}

      +
      +
      diff --git a/src/core/login/pages/site-help/site-help.scss b/src/core/login/pages/site-help/site-help.scss new file mode 100644 index 000000000..01699c80f --- /dev/null +++ b/src/core/login/pages/site-help/site-help.scss @@ -0,0 +1,5 @@ +page-core-login-site-help { + .content { + background-color: $white; + } +} \ No newline at end of file diff --git a/src/core/login/pages/site-help/site-help.ts b/src/core/login/pages/site-help/site-help.ts index 90d948b75..eb489e3c2 100644 --- a/src/core/login/pages/site-help/site-help.ts +++ b/src/core/login/pages/site-help/site-help.ts @@ -14,6 +14,7 @@ import { Component } from '@angular/core'; import { IonicPage, ViewController } from 'ionic-angular'; +import { TranslateService } from '@ngx-translate/core'; /** * Component that displays some help regarding the CoreLoginSitePage. @@ -24,7 +25,17 @@ import { IonicPage, ViewController } from 'ionic-angular'; templateUrl: 'site-help.html', }) export class CoreLoginSiteHelpPage { - constructor(private viewCtrl: ViewController) { } + + urlImageHtml: string; + setupLinkHtml: string; + + constructor(protected viewCtrl: ViewController, + protected translate: TranslateService) { + + this.urlImageHtml = ''; + this.setupLinkHtml = 'https://moodle.com/getstarted/'; + } /** * Close help modal. diff --git a/src/core/login/pages/site/site.html b/src/core/login/pages/site/site.html index 8da75c237..6d13b7507 100644 --- a/src/core/login/pages/site/site.html +++ b/src/core/login/pages/site/site.html @@ -6,9 +6,6 @@ - @@ -20,9 +17,9 @@
      -

      {{ 'core.login.newsitedescription' | translate }}

      - +

      {{ 'core.login.siteaddress' | translate }}

      +
      @@ -50,5 +47,36 @@

      {{ 'core.login.selectsite' | translate }}

      {{site.name}} + + +
      + + + {{ 'core.whoops' | translate }} + + +

      + +

      {{ 'core.login.problemconnectingerror' | translate }}

      +

      {{ error.url }}

      +

      {{ 'core.login.problemconnectingerrorcontinue' | translate }}

      +
      +
      + + {{ 'core.login.stillcantconnect' | translate }} + + +

      {{ 'core.login.contactyouradministrator' | translate }}

      +

      {{ 'core.whoissiteadmin' | translate }}

      +
      +
      +
      + + + + + diff --git a/src/core/login/pages/site/site.scss b/src/core/login/pages/site/site.scss index 53fafed91..0a740cead 100644 --- a/src/core/login/pages/site/site.scss +++ b/src/core/login/pages/site/site.scss @@ -10,4 +10,24 @@ ion-app.app-root page-core-login-site { background-color: $searchbar-ios-toolbar-input-background; } } + + .core-site-error { + background: $red-light; + margin-left: 0; + margin-right: 0; + width: 100%; + user-select: text; + + p, ion-card-header { + color: $red-dark; + user-select: text; + } + ion-card-header { + font-weight: bold; + } + } + + .core-login-need-help { + text-decoration: underline; + } } \ No newline at end of file diff --git a/src/core/login/pages/site/site.ts b/src/core/login/pages/site/site.ts index 9e44cbd4f..ebf6cfcaf 100644 --- a/src/core/login/pages/site/site.ts +++ b/src/core/login/pages/site/site.ts @@ -18,10 +18,32 @@ import { CoreAppProvider } from '@providers/app'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider, CoreSiteCheckResponse } from '@providers/sites'; import { CoreDomUtilsProvider } from '@providers/utils/dom'; +import { CoreUrlUtilsProvider } from '@providers/utils/url'; import { CoreConfigConstants } from '../../../../configconstants'; import { CoreLoginHelperProvider } from '../../providers/helper'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { CoreUrl } from '@classes/utils/url'; +import { TranslateService } from '@ngx-translate/core'; + +/** + * Data about an error when connecting to a site. + */ +type CoreLoginSiteError = { + /** + * The error message that ocurred. + */ + message: string; + + /** + * URL the user entered. + */ + url?: string; + + /** + * URL the user entered with protocol added if needed. + */ + fullUrl?: string; +}; /** * Page to enter or select the site URL to connect to. @@ -41,6 +63,7 @@ export class CoreLoginSitePage { fixedDisplay = 'buttons'; showKeyboard = false; filter = ''; + error: CoreLoginSiteError; constructor(navParams: NavParams, protected navCtrl: NavController, @@ -50,7 +73,9 @@ export class CoreLoginSitePage { protected loginHelper: CoreLoginHelperProvider, protected modalCtrl: ModalController, protected domUtils: CoreDomUtilsProvider, - protected eventsProvider: CoreEventsProvider) { + protected eventsProvider: CoreEventsProvider, + protected translate: TranslateService, + protected urlUtils: CoreUrlUtilsProvider) { this.showKeyboard = !!navParams.get('showKeyboard'); @@ -99,6 +124,14 @@ export class CoreLoginSitePage { url = url.trim(); + if (url.match(/^(https?:\/\/)?campus\.example\.edu/)) { + this.showLoginIssue(null, this.translate.instant('core.login.errorexampleurl')); + + return; + } + + this.hideLoginIssue(); + const modal = this.domUtils.showModalLoading(), siteData = this.sitesProvider.getDemoSiteData(url); @@ -164,6 +197,13 @@ export class CoreLoginSitePage { modal.present(); } + /** + * Hide the login error. + */ + protected hideLoginIssue(): void { + this.error = null; + } + /** * Show an error that aims people to solve the issue. * @@ -171,12 +211,14 @@ export class CoreLoginSitePage { * @param error Error to display. */ protected showLoginIssue(url: string, error: any): void { - const modal = this.modalCtrl.create('CoreLoginSiteErrorPage', { - siteUrl: url, - issue: this.domUtils.getErrorMessage(error) - }); + this.error = { + url: url, + message: this.domUtils.getErrorMessage(error), + }; - modal.present(); + if (url) { + this.error.fullUrl = this.urlUtils.isAbsoluteURL(url) ? url : 'https://' + url; + } } /** diff --git a/src/lang/en.json b/src/lang/en.json index 876b80259..3b9ccff0f 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -12,7 +12,7 @@ "back": "Back", "browser": "Browser", "cancel": "Cancel", - "cannotconnect": "Cannot connect: Verify that you have correctly typed the URL and that your site uses Moodle {{$a}} or later.", + "cannotconnect": "Cannot connect: Verify that you have correctly typed your site address.", "cannotdownloadfiles": "File downloading is disabled. Please contact your site administrator.", "captureaudio": "Record audio", "capturedimage": "Taken picture.", @@ -167,6 +167,7 @@ "more": "more", "mygroups": "My groups", "name": "Name", + "needhelp": "Need help?", "networkerroriframemsg": "This content is not available offline. Please connect to the internet and try again.", "networkerrormsg": "There was a problem connecting to the site. Please check your connection and try again.", "never": "Never", @@ -293,6 +294,7 @@ "warningofflinedatadeleted": "Offline data from {{component}} '{{name}}' has been deleted. {{error}}", "whatisyourage": "What is your age?", "wheredoyoulive": "In which country do you live?", + "whoissiteadmin": "\"Site Administrators\" are the people who manage the Moodle at your school/university/company or learning organisation. If you don't know how to contact them, please contact your teachers/trainers.", "whoops": "Oops!", "whyisthishappening": "Why is this happening?", "whyisthisrequired": "Why is this required?",