Skip to content

Instantly share code, notes, and snippets.

View blacksheep557's full-sized avatar
🎯
Focusing

Rahul Masih blacksheep557

🎯
Focusing
View GitHub Profile
import {coursesDao as dao} from './coursesDao';
import {enrichCoursesWithPIIFilteredTeacherProfiles} from "./coursesCtrl";
import {classRequestApi} from "../api/classRequestApi";
import {courseApi} from "../api/courseApi";
import {purchasesDao} from "../purchases/purchasesDao";
import {findEnrolledStudentIdsForNextMeeting} from "../students/enrolmentCheckSvc";
const errors = require('@feathersjs/errors');
export const onlinePublicCoursesCtrl = {
async function enrollStudents(course, courseId, studentIds) {
// if (!isPublicGroup(course)) { // private courses should work fine with default enrolment by omission (since student will never join its own course half-way through)
// return;
// }
await Promise.all(studentIds.map(async stId => {
const existingPurchasesForStudent = await dao.find({query: {courseId: courseId, studentIds: stId}});
const existingEnrolments = await enrolmentsDao.find({query: {userId: stId, courseId: `${course._id}`}});
if (isStudentReEnrolling(existingEnrolments)) {
const enrolment = existingEnrolments[0];
async function enrollStudents(course, courseId, studentIds) {
if (!isPublicGroup(course)) { // private courses should work fine with default enrolment by omission (since student will never join its own course half-way through)
return;
}
await Promise.all(studentIds.map(async stId => {
const existingPurchasesForStudent = await dao.find({query: {courseId: courseId, studentIds: stId}});
const existingEnrolments = await enrolmentsDao.find({query: {userId: stId, courseId: `${course._id}`}});
if (existingPurchasesForStudent.length === 0 || ensureTheStudentIsEnrolled(existingEnrolments)) {
await enrolmentsDao.create({
creationTime: Date.now(),
const request = require("request");
function getContacts() {
// we have a max of 50 pages
const options = (page) => ({
url: `https://api.jurnal.id/core/api/v1/contacts?contact_index={"curr_page":${page},"selected_tab":1,"sort_asc":true,"show_archive":false}`,
headers: {
'apikey': /// TODO: add apikey here
}
});
function canBePlaced(board, x, y, n) {
//rows above the current column
for (let row = 0; row < y; row++) {
if (board[row][x]) return false
}
let row = y;
let col = x;
// upper-left diagonal
while (row >= 0 && col >= 0) {
const wine = {
"vintage": {
"id": 156018871,
"seo_name": "alexandrie-cellars-alexandrie-brut-nv",
"name": "Alexandrie Cellars Alexandrie Brut",
"statistics": {"status": "Normal", "ratings_count": 259, "ratings_average": 4.6, "labels_count": 741},
"image": {
"location": "//images.vivino.com/thumbs/uc3qkd0HQHaTGIG7AJ1UPA_pl_480x640.png", "variations": {
"bottle_large": "//images.vivino.com/thumbs/uc3qkd0HQHaTGIG7AJ1UPA_pb_x960.png",
"bottle_medium": "//images.vivino.com/thumbs/uc3qkd0HQHaTGIG7AJ1UPA_pb_x600.png",
map_1 = {'1': {'name': 'Binary', 'callback': bin}, '2': {'name': 'Octal', 'callback': oct}}
for conv_id in map_1:
conversion_object = map_1[conv_id]
name = conversion_object['name']
print(f'{conv_id} {name}')
conv_id = input("Enter the conversion : ")
input_number = int(input("Enter the number : "))
conversion_object = map_1[conv_id]
callback = conversion_object['callback']
print(callback(input_number))
base = int(input("Enter the length of the base of the triangle : "))
height = int(input("Enter the length of the height of the triangle : "))
print(f"The area of the triangle is : {.5 * base * height}")
const result = {
"name": "Alex Bomberg",
"reviews": [
{
"image": "https://lh6.googleusercontent.com/-2QOW8fkH3WA/X6c9VN_EN1I/AAAAAAAAAAk/7ojEkFqIEJsL7_hIMF2hGoDM9lzw7gzPQCJUFGAYYCw/w36-h36-p-k-no/",
"title": "Gloucester Services Northbound",
"subtitle": "M5, Brookthorpe, Gloucester GL4 0DN, United Kingdom - ",
"time": " 3 days ago",
"reviewText": "Great farm shop. Massive selection of local produce. Well worth a stop!",
"likesCount": 0
const output = {
"name": "Alex Bomberg",
"reviews": [
{
"reviewText": "Great farm shop. Massive selection of local produce. Well worth a stop!",
"likesCount": 0
},
{
"reviewText": "Mark is highly experienced, friendly and very knowledge in his craft. Mark did an amazing renovation job for me and has done lots of framing that is first class.",
"likesCount": 1