Lingara Lingara المستندات أدلة التعلّم API المكتبات التطبيقات البناء تطبيق الويب
اللغة: العربية

السياق والموافقة

هذه الصفحة مترجمة من الإنجليزية. إذا اختلفت النسختان، فالصفحة الإنجليزية هي الصحيحة. اقرأ الصفحة الإنجليزية

لا يعرف تطبيقك شيئًا عن المتعلّم إلا عبر شرائح السياق. كل شريحة سجلّ صغير بحقول ثابتة. يسرد بيانك الشرائح التي يطلبها، ويوافق المتعلّم على كل واحدة منها عند تثبيت تطبيقك، ولا ترسل Lingara الشريحة إلا ما دام الأمران قائمين.

الشرائح

الشريحةالحقلما يحتويه
languagessource_langاللغة التي يدرس المتعلّم منها، بوصفها وسم لغة مثل en.
target_langاللغة التي يتعلّمها.
levelمستواه فيها، من 1 إلى 9، إن كان قد حدّد مستوى.
plan_summaryplan_idمعرّف أحدث خطة درس له، ويميّز خطةً عن أخرى. لا يستطيع تطبيقك جلب الخطة به، لأن رمز تطبيقك يقرأ حسابك أنت، لا حساب المتعلّم.
titleالعنوان المولَّد للخطة، 120 حرفًا على الأكثر، إن كان لها عنوان.
target_langاللغة التي تعلّمها الخطة.
set_countعدد المجموعات في الخطة، 200 على الأكثر.
sets_completedعدد تلك المجموعات التي أنهاها المتعلّم.
review_duedueعدد البطاقات التعليمية المستحقة الآن، 100000 على الأكثر.
learnedعدد الكلمات التي تعلّمها، 100000 على الأكثر.
tutor_topictopicموضوع أحدث محادثة له مع المدرّس، من 1 إلى 120 حرفًا. يأتي من عنوان خطة أو من الشاشة التي هو عليها، ولا يأتي أبدًا من كلماته هو.

ما لا تحمله أي شريحة

لا تحمل أي شريحة عنوان بريد إلكتروني ولا اسمًا ولا معرّف مستخدم ولا أي شيء كتبه المتعلّم. يعرف تطبيقك من هو المتعلّم من subject في الطلب، وهي قيمة ثابتة تختلف لكل تطبيق. فرمز تطبيقك يقرأ حسابك أنت، لا حساب المتعلّم أبدًا، ولذا فالشرائح هي كل ما يعرفه تطبيقك عنه.

الموافقة

  • يوافق المتعلّم على كل شريحة عند تثبيت تطبيقك. ولتغيير ما وافق عليه، يلغي تثبيت تطبيقك ثم يثبّته مجددًا.
  • إذا عدّلت بيانك ليطلب شرائح أقل، تتوقف الشرائح التي حذفتها فورًا.
  • إذا عدّلته ليطلب المزيد، لا تصل الشرائح الجديدة إلى أي متعلّم حتى يعيد التثبيت.
  • تتحقّق Lingara من الموافقة مجددًا في كل طلب، وتُسقط أي شريحة لم يوافق عليها المتعلّم أو لم يعد بيانك يطلبها. وتُسقَط كذلك الشريحة التي لا تطابق سجلّها، ولا يُسقَط الطلب كله أبدًا.

يبني المثال أدناه سطره من الشرائح التي أُعطيت له ولا يستدعي أي API.

لغة مثال الشيفرة

TypeScript

// The app's own client reads its owner's account, never the learner's. The
// slices are all a render knows about the learner.
function planLine(request: AppRenderRequest): string {
  let line = "";
  for (const slice of request.context) {
    // A slice is present only when the learner agreed to share it.
    if (slice.kind === "languages") line += `${slice.source_lang} → ${slice.target_lang}. `;
    if (slice.kind === "plan_summary") line += `${slice.sets_completed}/${slice.set_count} sets.`;
  }
  return line;
}

Rust

// The app's own client reads its owner's account, never the learner's. The
// slices are all a render knows about the learner.
/// The learner's target language and, when they shared their plan, its
/// `(sets_completed, set_count)`.
fn shared_plan(request: &AppRenderRequest) -> (String, Option<(u32, u32)>) {
    let (mut target_lang, mut progress) = (String::from("zh"), None);
    for slice in &request.context {
        match slice {
            ContextSlice::Languages(languages) => target_lang = languages.target_lang.clone(),
            ContextSlice::PlanSummary(summary) => progress = Some((summary.sets_completed, summary.set_count)),
            _ => {}
        }
    }
    (target_lang, progress)
}

Go

// The app's own client reads its owner's account, never the learner's.
// The slices are all a render knows about the learner.
//
// Each slice is present only when the learner agreed to share it.
card := lingaraapps.NewCard().Heading("Your plan", 1)
for _, slice := range req.Context {
	switch s := slice.(type) {
	case lingaraapps.ContextSliceLanguages:
		card.Text(fmt.Sprintf("Learning %s from %s", s.TargetLang, s.SourceLang))
	case lingaraapps.ContextSlicePlanSummary:
		card.Text(fmt.Sprintf("%d of %d sets done", s.SetsCompleted, s.SetCount))
	}
}

Java

import com.getlingara.apps.Card;
import com.getlingara.apps.Reply;
import com.getlingara.apps.model.AppRenderRequest;
import com.getlingara.apps.model.ContextSlice;
import com.getlingara.apps.model.ContextSliceLanguages;
import com.getlingara.apps.model.ContextSlicePlanSummary;

// The app's own client reads its owner's account, never the learner's. The slices are all a
// render knows about the learner.
static Reply render(AppRenderRequest request) {
  Card.Builder card = Card.card();
  // A slice is present only when the learner agreed to share it; the context is read-only.
  for (ContextSlice slice : request.getContext()) {
    if (slice instanceof ContextSliceLanguages languages) {
      card.heading("Learning " + languages.targetLang(), 1);
    } else if (slice instanceof ContextSlicePlanSummary summary) {
      card.text(summary.setsCompleted() + " of " + summary.setCount() + " sets done");
    }
  }
  return card.heading("Today", 2).build();
}

Kotlin

import com.getlingara.apps.kotlin.Reply
import com.getlingara.apps.kotlin.card
import com.getlingara.apps.kotlin.model.AppRenderRequest
import com.getlingara.apps.kotlin.model.ContextSliceLanguages
import com.getlingara.apps.kotlin.model.ContextSlicePlanSummary

// The app's own client reads its owner's account, never the learner's. The slices are all a
// render knows about the learner.
fun renderWithContext(request: AppRenderRequest): Reply {
    // A slice is present only when the learner agreed to share it; the context is read-only.
    val languages = request.context.filterIsInstance<ContextSliceLanguages>().firstOrNull()
    val summary = request.context.filterIsInstance<ContextSlicePlanSummary>().firstOrNull()
    return card {
        heading("Learning ${languages?.targetLang ?: "today"}", 1)
        if (summary != null) {
            text("${summary.setsCompleted} of ${summary.setCount} sets done")
        }
    }
}

Ruby

# The app's own client reads its owner's account, never the learner's. The
# slices are all a render knows about the learner.
#
# A slice is present only when the learner agreed to share it.
request.context.filter_map do |slice|
  case slice
  in Lingara::Apps::ContextSliceLanguages(source_lang:, target_lang:)
    "#{source_lang} → #{target_lang}."
  in Lingara::Apps::ContextSlicePlanSummary(sets_completed:, set_count:)
    "#{sets_completed}/#{set_count} sets."
  else nil
  end
end.join(" ")

PHP

use Lingara\Apps\Generated\ContextSliceLanguages;
use Lingara\Apps\Generated\ContextSlicePlanSummary;

function planLine(AppRenderRequest $request): string
{
    // The app's own client reads its owner's account, never the learner's. The
    // slices are all a render knows about the learner.
    $line = '';
    // A slice is present only when the learner agreed to share it.
    foreach ($request->getContext() as $slice) {
        if ($slice instanceof ContextSliceLanguages) {
            $line .= "{$slice->sourceLang} → {$slice->targetLang}. ";
        } elseif ($slice instanceof ContextSlicePlanSummary) {
            $line .= "{$slice->setsCompleted}/{$slice->setCount} sets.";
        }
    }
    return $line;
}

انظر أيضًا