npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eclass/grade-scales

v1.5.14

Published

Módulo para calcular notas en base a una escala.

Downloads

202

Readme

@eclass/grade-scales

npm Build Status downloads dependencies devDependency Status

Instalación

  npm i @eclass/grade-scales

Este módulo permite calcular notas en base a una escala de notas. La escala debe tener algunos valores que se listan a continuación:

Formato Escala de notas

const scale = {
  name: "Chile 50% (1-7, aprobación 50%, nota 4)",
  keyname: "Chile50",
  min: 1,
  max: 7,
  passingGrade: 4,
  passingPercentage: 50,
  roundType: "round",
  prepend: "",
  append: "",
  decimals: 1,
  decimalSeparator: ","
}

eClass - Grade Scales

Las funciones principales nos permiten calcular las notas y formatearlas.

getGrade() : number

En base a una escala se calcula la nota según los puntos totales y los obtenidos.

  const grade = getGrade(scale, 10, 6)
  // output: console.log({ grade })
  { grade: 4.6 }

getGradeFormatted(): Object

Devuelve la nota formateada con el estado si está "Aprobada" o "Reprobada"

  const grade = getGradeQualification(scale, 10, 6)
  // output: console.log({ grade })
  {
    value: 4.6,
    valueFormatted: '4,6',
    status: {
      id: 1,
      name: 'Aprobado',
      detail: 'La nota está aprobada',
      style: 'approved',
      enabled: true
    }
  }

getQualification(): Object

Si tenemos la nota ya calculada podemos darle formato con la función

  const qualification = getQualification(scale, 5.6)
  // output: console.log({ qualification })
  {
    value: 5.6,
    valueFormatted: '5,6',
    status: {
      id: 1,
      name: 'Aprobado',
      detail: 'La nota está aprobada',
      style: 'approved',
      enabled: true
    }
  }

getAverage() : number

Según la escala calcula el promedio en base a un set de notas.

  const average = getAverage(scale, { grades: [3, 4, 6] })
  // output: console.log({ average })
  {
    average: {
      value: 4.7,
      valueFormatted: '4,7',
      status: {
        id: 1,
        name: 'Aprobado',
        detail: 'La nota está aprobada',
        style: 'approved',
        enabled: true
      }
    }
  }

Además puede recibir un arreglo de valores con las ponderaciones para calcular el promedio de notas.

  const average = getAverage(scale, { 
    grades: [3, 4, 7],
    weights: [20, 30, 50]
  })
  // output
  {: console.log({ // })
    average: {
      value: 5.3,
      valueFormatted: '5,3',
      status: {
        id: 1,
        name: 'Aprobado',
        detail: 'La nota está aprobada',
        style: 'approved',
        enabled: true
      }
    }
  }

convertToScale() : number

Transforma una nota de una escala a otra.

  const newScale = {
    name: 'Porcentaje (1-100%, aprobación 60%, nota 70)',
    keyname: 'Porcentaje_1-100_60',
    min: 1,
    max: 100,
    passingGrade: 70,
    passingPercentage: 60,
    roundType: 'round',
    prepend: '',
    append: '%',
    decimals: 0,
    decimalSeparator: ','
  }

  const converted = convertToScale({ scale, grade: 4.8 }, newScale)
  // output: console.log({ converted })
  { converted: 64 }

getGrades() : Array

Calcula todas las notas de una escala según el puntaje máximo

  const grades = getGrades(scale, 1, 0)
  // output: console.log({ grades })
  [
    {
      points: { obtained: 0, total: 1 },
      grade: 1,
      qualification: { value: 1, valueFormatted: '1', status: [Object] },
      isApproved: false,
      formatted: '1'
    },
    {
      points: { obtained: 1, total: 1 },
      grade: 7,
      qualification: { value: 7, valueFormatted: '7', status: [Object] },
      isApproved: true,
      formatted: '7'
    }
  ]

Otras funciones

gradeFormat(): string

Formatea una nota según el estilo de la escala.

  const format = gradeFormat(scale, 2.5)
  // output: console.log({ format })
  { format: '2,5' }

gradeIsApproved() : boolean

Calcula la nota si está aprobada o reprobada

  const isApproved = gradeIsApproved(scale, 5)
  // output: console.log({ isApproved })
  { isApproved: true }

gradeRound() : number

Calcula la nota si está aprobada o reprobada

  const rounded = gradeRound(scale, 5.3551)
  // output: console.log({ rounded })
  { rounded: 5.4 }

gradeStatus(): QualificationType

Calcula la nota si está aprobada o reprobada con formato

  const status = gradeStatus(scale, 4.3)
  // output: console.log({ status })
  {
    status: {
      id: 1,
      name: 'Aprobado',
      detail: 'La nota está aprobada',
      style: 'approved',
      enabled: true
    }
  }

License

MIT