Giter Site home page Giter Site logo

eclass / grade-scales Goto Github PK

View Code? Open in Web Editor NEW
1.0 13.0 0.0 560 KB

Herramienta para calcular puntaje y notas según una escala. Se considera el % de exigencia. Además se puede transformar una nota a otra escala.

Home Page: https://eclass.io

License: MIT License

TypeScript 96.16% Shell 1.80% JavaScript 2.04%
calcula-notas grade-scales typescript

grade-scales's Introduction

@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

grade-scales's People

Contributors

lgaticaq avatar renovate-bot avatar renovate[bot] avatar segonzalezr avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grade-scales's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm eslint-plugin-node Available
npm eslint-plugin-standard Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency eslint-plugin-array-func to v3.1.8
  • chore(deps): update dependency eslint-config-prettier to v8.10.0
  • chore(deps): update dependency eslint-plugin-import to v2.29.1
  • chore(deps): update dependency eslint-plugin-prettier to v4.2.1
  • chore(deps): update dependency eslint-plugin-security to v1.7.1
  • chore(deps): update dependency eslint-plugin-sonarjs to v0.25.1
  • chore(deps): update dependency prettier to v2.8.8
  • chore(deps): update dependency ts-node to v10.9.2
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency eslint-config-prettier to v9
  • chore(deps): update dependency eslint-config-standard to v17
  • chore(deps): update dependency eslint-plugin-array-func to v5
  • chore(deps): update dependency eslint-plugin-prettier to v5
  • chore(deps): update dependency eslint-plugin-promise to v6
  • chore(deps): update dependency eslint-plugin-security to v3
  • chore(deps): update dependency eslint-plugin-sonarjs to v1
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency node to v20 (node, @types/node)
  • chore(deps): update dependency prettier to v3
  • chore(deps): update dependency typescript to v5
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v2
  • actions/setup-node v2
  • actions/checkout v2
  • actions/setup-node v2
npm
package.json
  • @commitlint/cli 13.1.0
  • @commitlint/config-conventional 13.1.0
  • @eclass/eslint-config-typescript 2.0.1
  • @semantic-release/changelog 5.0.1
  • @semantic-release/git 9.0.1
  • @types/node 14.17.17
  • @typescript-eslint/eslint-plugin 4.31.1
  • @typescript-eslint/parser 4.31.1
  • eslint 7.32.0
  • eslint-config-prettier 8.3.0
  • eslint-config-standard 16.0.3
  • eslint-plugin-array-func 3.1.7
  • eslint-plugin-eslint-comments 3.2.0
  • eslint-plugin-import 2.26.0
  • eslint-plugin-node 11.1.0
  • eslint-plugin-prettier 4.0.0
  • eslint-plugin-promise 5.2.0
  • eslint-plugin-security 1.4.0
  • eslint-plugin-sonarjs 0.10.0
  • eslint-plugin-standard 5.0.0
  • husky 7.0.2
  • lint-staged 11.2.6
  • prettier 2.4.1
  • semantic-release 18.0.0
  • ts-node 10.7.0
  • typescript 4.4.3
  • node >=12.14.0
nvm
.nvmrc
  • node 14.17.6

  • Check this box to trigger a request for Renovate to run again on this repository

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.